資源簡介
倍福CNC 界面
using System; using System.Windows.Forms; namespace TcApplication { static class Program { [System.Runtime.InteropServices.DllImport("User32.dll")] static extern IntPtr SetForegroundWindow(IntPtr hWnd); [System.Runtime.InteropServices.DllImport("User32.dll")] static extern IntPtr ShowWindow(IntPtr hWnd, int nCmdShow); public static MainApp mainApp; static FormSplash formSplash; static bool exceptionSignaled; static Timer timerSplashWait; const int SW_RESTORE = 9; #region Main Entry /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException = new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); if (CheckActiveProcess() == true) { Application.Exit(); return; } ShowSplashScreen(); // BasicConfigurator.Configure(); log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(Application.StartupPath "\\System\\log.xml")); // Einschalten internes Debugging der LOG Komponenete // log4net.Util.LogLog.InternalDebugging = true; MainApp.log.Info("Application started."); // set the NumberGroupSeparator for all forms System.Globalization.CultureInfo newCultureInfo = new System.Globalization.CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.LCID); newCultureInfo.NumberFormat.NumberDecimalSeparator = "."; newCultureInfo.NumberFormat.NumberGroupSeparator = ","; newCultureInfo.TextInfo.ListSeparator = ";"; Application.CurrentCulture = newCultureInfo; // load the settings MainApp.appSettings = new Settings(); MainApp.appSettings.FileName = Application.StartupPath "\\System\\AppSet.xml"; MainApp.appSettings.ReadSettings(); mainApp = new MainApp(); Application.Run(mainApp); MainApp.log.Info("Application stopped."); MainApp.appSettings.WriteSettings(); } #endregion #region Public functions public static void ShowSplashScreen() { String[] arguments = Environment.GetCommandLineArgs(); for (int i = 1; i < arguments.Length; i ) { if (arguments[i].StartsWith("/NoSplash")) return; } if (formSplash == null) formSplash = new FormSplash(); if (timerSplashWait == null) { timerSplashWait = new Timer(); timerSplashWait.Tick = new EventHandler(timerSplashWait_Tick); } formSplash.Parameters("HMI " Application.ProductVersion, 325, 296, new System.Drawing.Font("Arial", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), System.Drawing.Color.FromArgb(0, 104, 157), System.Drawing.Color.Black); formSplash.Show(); Application.DoEvents(); } static void timerSplashWait_Tick(object sender, EventArgs e) { timerSplashWait.Enabled = false; CloseSplashScreen(); } public static void CloseSplashScreen(int interval) { if (interval < 1) interval = 1; if (timerSplashWait != null) { timerSplashWait.Interval = interval; timerSplashWait.Enabled = true; } } public static void CloseSplashScreen() { if (formSplash != null) { formSplash.Close(); formSplash.Dispose(); formSplash = null; } } public static void BringSplashToFront() { if (formSplash != null) formSplash.BringToFront(); } public static void SplashTopMost(bool level) { if (formSplash != null) formSplash.TopMost = level; } #endregion #region Private functions private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { if (!exceptionSignaled) { exceptionSignaled = true; MainApp.log.Fatal(sender, e.Exception); Beckhoff.App.ExceptionDialog exc = new Beckhoff.App.ExceptionDialog(); exc.SetText(Application.ProductName " has encountered a problem.\r\n" "For further information take a look to the application event log!", e.Exception); exc.ShowDialog(); exceptionSignaled = !exc.ExceptionSignaledChecked; exc.Dispose(); exc = null; } } private static bool CheckActiveProcess() { try { int c = System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length; if (c > 0) { bool bFoundSame = false; foreach (System.Diagnostics.Process pr in System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName)) { if (pr.MainModule.FileName == Application.ExecutablePath && pr.Id != System.Diagnostics.Process.GetCurrentProcess().Id) { SetForegroundWindow(pr.MainWindowHandle); // 9 = SW_RESTORE (winuser.h) ShowWindow(pr.MainWindowHandle, SW_RESTORE); bFoundSame = true; } } return bFoundSame; } else { return false; } } catch //(System.Security.SecurityException ex) { return false; } } #endregion } }
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?Beckhoff.App.TcMenu;
namespace?TcApplication
{
///?
///?Summary?description?for?Form8.
///?
public?partial?class?Form8?:?FormTcApp
{
private?Beckhoff.Forms.TcAdsPlcServer?adsPlcServer;
private?Beckhoff.Forms.Nc.TcAdsNcServer?adsNcServer;
public?Form8()
{
InitializeComponent();
adsPlcServer?=?MainApp.GetDoc().AdsPlcServer;
adsNcServer?=?MainApp.GetDoc().AdsNcServer;
}
#region?Implementation?of?Function?Keys
public?override?void?FKeyWriteSymbol(string?symbol?string?value)
{
if?(adsPlcServer?!=?null?&&?adsPlcServer.PlcIsRunning)
{
try
{
adsPlcServer.PlcClient.WriteSymbol(symbol?value);
}
catch?(Exception?ex)
{
MainApp.log.Error(“Error?in?FKeyWriteSymbol()“?ex);
}
}
}
public?override?void?SetFKeyText(Beckhoff.App.TcFKey?fKey)
{
fKey.FKeyText(1?“Menü“);
fKey.FKeyText(2?“Test“);
fKey.FKeyText(3?“Swap“);
fKey.FKeyText(4?“Menü2“);
}
public?override?void?FKeyDownEvent(int?nIdx)
{
}
public?override?void?FKeyUpEvent(int?nIdx)
{
switch?(nIdx)
{
case?1:
FormTcMenuManager?setup?=?new?FormTcMenuManager(LocalMenu);
setup.ShowDialog();
break;
case?2:
string[]?elements;
LocalMenu.GetPathElements(out?elements);
string?tmp?=?““;
for?(int?i?=?0;?i? {
tmp?=?tmp?+?elements[i]?+?“>“;
}
MessageBox.Show(tmp);
break;
case?3:
{
int?a?=?3;
int?b?=?4;
Swap(ref?a?ref?b);
}
break;
case?4:
LocalMenu.MenuManager();
break;
}
}
///?
///?Swap?data?of?type?
///?
///?left? ?to?swap
///?right? ?to?swap
///?The?element?type?to?swap
public?void?Swap(ref?T?lhs?ref?T?rhs)
{
T?temp;
temp?=?lhs;
lhs?=?rhs;
rhs?=?temp;
}
void?Form8_Activated(object?sender?System.EventArgs?e)
{
}
#endregion
private?void?button1_Click(object?sender?EventArgs?e)
{
string[]?lines;
bool?lineChanged;
int?activeLine?=?adsNcServer.NcClient.ProgramSection(1?““?out?lines?out?lineChanged);
}
private?void?button2_Click(object?sender?EventArgs?e)
{
adsNcServer.NcClient.ProgramSectionNumberOfLines(1?10);
}
????????private?void?tcFKey4_Load(object?sender?EventArgs?e)
????????{
????????}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1078??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\App.ico
?????文件????????324??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\Databa
?????文件???????3926??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\Databa
?????文件???????1701??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\Databa
?????文件???????4166??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\Databa
?????文件???????2807??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\Form8.cs
?????文件??????13158??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\Form8.Designer.cs
?????文件???????5814??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\Form8.resx
?????文件??????43253??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormCnc.cs
?????文件??????43988??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormCnc.Designer.cs
?????文件???????6599??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormCnc.resx
?????文件???????3090??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormLanguage.cs
?????文件???????4903??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormLanguage.Designer.cs
?????文件???????5814??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormLanguage.resx
?????文件???????7582??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormMain.cs
?????文件???????1989??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormMain.Designer.cs
?????文件???????5814??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormMain.resx
?????文件???????9622??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormManual.cs
?????文件???????5614??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormManual.Designer.cs
?????文件???????6021??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormManual.resx
?????文件??????19243??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormMaschPara.cs
?????文件???????3962??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormMaschPara.Designer.cs
?????文件???????5814??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormMaschPara.resx
?????文件??????15123??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormMessages.cs
?????文件???????8652??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormMessages.Designer.cs
?????文件???????6020??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormMessages.resx
?????文件???????1522??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormOption.cs
?????文件???????1154??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormOption.Designer.cs
?????文件???????7174??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormPlcStatus.cs
?????文件???????3570??2013-04-01?09:32??CNC_HMI(包含原程序)\Backup\TcApplication\FormPlcStatus.Designer.cs
............此處省略1164個文件信息
- 上一篇:C#控件美化(TabControlEx)
- 下一篇:WPF鼠標拖動控件源碼
評論
共有 條評論