using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Reflection; using RemoteControlLib.Common; namespace RemoteServer { /// /// INCU服务端 /// public partial class frm_Server : Form { //服务端 private Servers.Servers server; public frm_Server() { InitializeComponent(); Run(); } /// /// 程序标题 /// public string AssemblyTitle { get { // 获取此程序集上的所有 Title 属性 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); // 如果至少有一个 Title 属性 if (attributes.Length > 0) { // 请选择第一个属性 AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; // 如果该属性为非空字符串,则将其返回 if (titleAttribute.Title != "") return titleAttribute.Title; } // 如果没有 Title 属性,或者 Title 属性为一个空字符串,则返回 .exe 的名称 return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); } } /// /// 程序版本 /// public string AssemblyVersion { get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); } } /// /// 程序产品名 /// public string AssemblyProduct { get { // 获取此程序集上的所有 Product 属性 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); // 如果 Product 属性不存在,则返回一个空字符串 if (attributes.Length == 0) return ""; // 如果有 Product 属性,则返回该属性的值 return ((AssemblyProductAttribute)attributes[0]).Product; } } /// /// 运行 /// private void Run() { this.WindowState=FormWindowState.Minimized; server = new Servers.Servers(Constant.Port_Main, Constant.Port_File, Constant.Port_Screen); server.ltv_Log = ltv_Log; server.lbl_Message = lbl_Message; server.Version = AssemblyVersion; server.ProductName = AssemblyProduct; try { server.Run(); } catch { CloseServer(); } } /// /// 关闭程序 /// private void CloseServer() { try { if (server != null) server.Close(); System.Environment.Exit(System.Environment.ExitCode); Application.ExitThread(); Application.Exit(); } catch { } } private void frm_server_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; 退出EToolStripMenuItem1_Click(sender, e); } private void 退出EToolStripMenuItem1_Click(object sender, EventArgs e) { CloseServer(); } private void 打开OToolStripMenuItem3_Click(object sender, EventArgs e) { this.Visible = true; this.WindowState = FormWindowState.Normal; } private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e) { this.Visible = true; if (this.Visible) this.WindowState = FormWindowState.Normal; } private void frm_server_Resize(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) this.Visible = false; } private void grb_Log_Enter(object sender, EventArgs e) { } } }