Program.cs 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using DevExpress.LookAndFeel;
  2. using DevExpress.XtraEditors;
  3. using Microsoft.Win32;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.IO;
  8. using System.Reflection;
  9. using System.Security.Principal;
  10. using System.Windows.Forms;
  11. using DW5S.UI.Lib;
  12. using DW5S.WebApi;
  13. namespace DW5S
  14. {
  15. internal static class Program
  16. {
  17. static Program()
  18. {
  19. //设置私有路径
  20. //Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
  21. //AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", "AddIns;");
  22. //var m = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static);
  23. //var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance);
  24. //m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", "AddIns;" });
  25. ////c++dll加入环境变量
  26. //string paths = Environment.GetEnvironmentVariable("PATH");
  27. //var dirs = Directory.EnumerateDirectories("AddIns", "*", SearchOption.AllDirectories);
  28. //List<string> list = new List<string>
  29. //{
  30. // Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AddIns")
  31. //};
  32. //foreach (var item in dirs)
  33. //{
  34. // list.Add(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, item));
  35. //}
  36. //Environment.SetEnvironmentVariable("PATH", $"{paths};{string.Join(";", list)}");
  37. //AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
  38. //{
  39. // var ex = e.ExceptionObject as Exception;
  40. // while (ex.InnerException != null)
  41. // ex = ex.InnerException;
  42. // DW5S.Framework.LogHelper.Error("出现未处理的异常,程序即将退出!", ex);
  43. // DxHelper.MsgBoxHelper.ShowError("出现未处理的异常,程序即将退出!");
  44. //};
  45. //Application.ThreadException += (sender, e) =>
  46. //{
  47. // var ex = e.Exception;
  48. // while (ex.InnerException != null)
  49. // ex = ex.InnerException;
  50. // DxHelper.MsgBoxHelper.ShowError($"出现未处理的线程异常!{e.Exception.Message}");
  51. // LogUI.Error("出现未处理的线程异常", e.Exception).Wait(5000);
  52. //};
  53. }
  54. /// <summary>
  55. /// 应用程序的主入口点。
  56. /// </summary>
  57. [STAThread]
  58. static void Main()
  59. {
  60. WebApiHelper.Start(AppConfigHelper.Get("HttpPort", 8090));
  61. //WindowsFormsSettings.AllowDpiScale = true;
  62. //WindowsFormsSettings.AllowHoverAnimation = DevExpress.Utils.DefaultBoolean.True;
  63. //WindowsFormsSettings.AllowDefaultSvgImages = DevExpress.Utils.DefaultBoolean.True;
  64. //WindowsFormsSettings.AllowRoundedWindowCorners = DevExpress.Utils.DefaultBoolean.True;
  65. //WindowsFormsSettings.AnimationMode = AnimationMode.EnableAll;
  66. //WindowsFormsSettings.BackgroundSkinningMode = BackgroundSkinningMode.AllColors;
  67. //WindowsFormsSettings.DefaultAllowHtmlDraw = true;
  68. //WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinStyle.WXICompact);
  69. //WindowsFormsSettings.DefaultFont = new System.Drawing.Font("微软雅黑", 10f);
  70. //WindowsFormsSettings.SetPerMonitorDpiAware();
  71. //if (Debugger.IsAttached)
  72. //{
  73. // //DevExpress23.2以上版本查看未本地化的资源
  74. // DevExpress.Utils.Localization.XtraLocalizer.EnableTraceSource();
  75. //}
  76. //string screenTitle = AppConfigHelper.Get("SystemName", "");
  77. //string screenCompany = AppConfigHelper.Get("Company", "");
  78. //DxHelper.WaitHelper.SetSplashTips("Tips.txt");
  79. //ChsLocalizer.UseChs();
  80. //DxHelper.WaitHelper.ShowSplashScreen(screenTitle, screenCompany);
  81. //DxHelper.WaitHelper.UpdateSplashMessage("正在加载程序资源文件...");
  82. //MainForm mainForm = new MainForm() { Text = screenTitle };
  83. //DxHelper.WaitHelper.UpdateSplashMessage("正在初始化...");
  84. //System.Windows.Forms.Application.Run(mainForm);
  85. }
  86. }
  87. }