Program.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. WebApiHelper.Start(AppConfigHelper.Get("HttpPort", 8090));
  60. //WindowsFormsSettings.AllowDpiScale = true;
  61. //WindowsFormsSettings.AllowHoverAnimation = DevExpress.Utils.DefaultBoolean.True;
  62. //WindowsFormsSettings.AllowDefaultSvgImages = DevExpress.Utils.DefaultBoolean.True;
  63. //WindowsFormsSettings.AllowRoundedWindowCorners = DevExpress.Utils.DefaultBoolean.True;
  64. //WindowsFormsSettings.AnimationMode = AnimationMode.EnableAll;
  65. //WindowsFormsSettings.BackgroundSkinningMode = BackgroundSkinningMode.AllColors;
  66. //WindowsFormsSettings.DefaultAllowHtmlDraw = true;
  67. //WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinStyle.WXICompact);
  68. //WindowsFormsSettings.DefaultFont = new System.Drawing.Font("微软雅黑", 10f);
  69. //WindowsFormsSettings.SetPerMonitorDpiAware();
  70. //if (Debugger.IsAttached)
  71. //{
  72. // //DevExpress23.2以上版本查看未本地化的资源
  73. // DevExpress.Utils.Localization.XtraLocalizer.EnableTraceSource();
  74. //}
  75. //string screenTitle = AppConfigHelper.Get("SystemName", "");
  76. //string screenCompany = AppConfigHelper.Get("Company", "");
  77. //DxHelper.WaitHelper.SetSplashTips("Tips.txt");
  78. //ChsLocalizer.UseChs();
  79. //DxHelper.WaitHelper.ShowSplashScreen(screenTitle, screenCompany);
  80. //DxHelper.WaitHelper.UpdateSplashMessage("正在加载程序资源文件...");
  81. //MainForm mainForm = new MainForm() { Text = screenTitle };
  82. //DxHelper.WaitHelper.UpdateSplashMessage("正在初始化...");
  83. //System.Windows.Forms.Application.Run(mainForm);
  84. }
  85. }
  86. }