Program.cs 4.2 KB

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