You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
4.7 KiB
C#
110 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using ICSharpCode.Core;
|
|
using ICSharpCode.Core.Services;
|
|
using Host;
|
|
|
|
namespace MCEdit
|
|
{
|
|
using Mesnac.Core.Service;
|
|
using Mesnac.Gui.Workbench;
|
|
class Program
|
|
{
|
|
[STAThread]
|
|
static void Main(string[] args)
|
|
{
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
#region 授权处理
|
|
|
|
#if (!DEBUG)
|
|
//MesnacServiceManager.Instance.LoggingService.Info("软件授权...");
|
|
//if (!Mesnac.Basic.Register.IsExist("MCEdit") || Mesnac.Basic.Register.GetRegData("MCEdit") != Mesnac.Basic.Register.GetRegCode())
|
|
//{
|
|
// Mesnac.Gui.Edit.FrmRegister frmRegister = new Mesnac.Gui.Edit.FrmRegister();
|
|
// frmRegister.ShowDialog();
|
|
// if (frmRegister.DialogResult == DialogResult.Cancel)
|
|
// {
|
|
// Application.Exit();
|
|
// return;
|
|
// }
|
|
//}
|
|
#endif
|
|
|
|
#endregion
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("启动应用程序...");
|
|
Assembly exe = typeof(Program).Assembly;
|
|
FileUtility.ApplicationRootPath = Path.GetDirectoryName(exe.Location);
|
|
|
|
CoreStartup cs = new CoreStartup("MCEdit");
|
|
//设备配置文件目录
|
|
cs.ConfigDirectory = Path.Combine(FileUtility.ApplicationRootPath, "Data", "Config");
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("启动核心服务...");
|
|
cs.StartCoreServices();
|
|
//注册资源文件,文本和图片
|
|
ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("MCEdit.Properties.SDRes", exe));
|
|
ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("MCEdit.Properties.SDRes", exe));
|
|
|
|
ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("MCEdit.Properties.MesnacResource", exe));
|
|
ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("MCEdit.Properties.MesnacResource", exe));
|
|
|
|
//设置初始语言区域
|
|
string cultureName = ICSharpCode.Core.PropertyService.Get<string>("cultureName", "zh-CN");
|
|
if (!String.IsNullOrEmpty(cultureName))
|
|
{
|
|
System.Globalization.CultureInfo currentUICulture = new System.Globalization.CultureInfo(cultureName);
|
|
System.Threading.Thread.CurrentThread.CurrentUICulture = currentUICulture;
|
|
}
|
|
|
|
AddInTree.Doozers.TryAdd("Pad", new Mesnac.PlugIn.Pad.PadDoozer());
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Debug("搜索插件...");
|
|
cs.AddAddInsFromDirectory(Path.Combine(FileUtility.ApplicationRootPath, "Data\\SharpPlugIn"));
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Debug("加载插件...");
|
|
cs.RunInitialization();
|
|
|
|
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Debug("初始化工作台...");
|
|
WorkbenchSingleton.InitFinished += delegate(object sender, EventArgs e) { Mesnac.Gui.Edit.Common.FormDesignerHelper.Init(); };
|
|
|
|
WorkbenchSingleton.InitializeWorkbench();
|
|
MesnacServiceManager.Instance.LoggingService.Debug("启动工作台...");
|
|
//Mesnac.Communication.TcpService.StartService(); //启动通信服务器
|
|
Mesnac.Communication.SocketClient.Instance.Connect();
|
|
|
|
Mesnac.Basic.UserInfo.Instance.RoleID = "2"; //设置用户角色
|
|
Mesnac.Basic.UserInfo.Instance.UserID = "1";
|
|
Mesnac.Basic.UserInfo.Instance.UserName = "lix";
|
|
|
|
//退出系统之前,关闭相关文档
|
|
WorkbenchSingleton.Workbench.ShutDown += delegate(object sender, EventArgs e) { Mesnac.Gui.Edit.ViewContent.DisplayUtil<Mesnac.Gui.Edit.Pad.ProjectWindow>.ClearProject(); };
|
|
|
|
Form frmMain = WorkbenchSingleton.Workbench as Form;
|
|
Application.Run(frmMain);
|
|
|
|
PropertyService.Save();
|
|
//Mesnac.Communication.TcpService.StopService(); //停止通信服务器
|
|
Mesnac.Communication.SocketClient.Instance.StopListenThread();
|
|
|
|
//退出系统之前,关闭组态工程
|
|
Mesnac.Gui.Edit.ViewContent.DisplayUtil<Mesnac.Gui.Edit.Pad.ProjectWindow>.ClearProject();
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("关闭了应用程序。");
|
|
//关闭当前线程
|
|
|
|
Application.ExitThread();
|
|
Application.Exit();
|
|
System.Environment.Exit(System.Environment.ExitCode);
|
|
}
|
|
}
|
|
}
|