终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

75 lines
2.6 KiB

  1. using BeDesignerSCADA.Helper;
  2. using BeDesignerSCADA.View;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Configuration;
  6. using System.Data;
  7. using System.Diagnostics;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Runtime.InteropServices;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. namespace BPASmart.MenuLoad
  15. {
  16. /// <summary>
  17. /// Interaction logic for App.xaml
  18. /// </summary>
  19. public partial class App : Application
  20. {
  21. bool isShow = false;
  22. [DllImport("kernel32.dll")]
  23. private static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max);
  24. string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf";
  25. private void FlushMemory()
  26. {
  27. GC.Collect();
  28. GC.WaitForPendingFinalizers();
  29. if (Environment.OSVersion.Platform == PlatformID.Win32NT)
  30. SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
  31. }
  32. protected override void OnStartup(StartupEventArgs e)
  33. {
  34. base.OnStartup(e);
  35. RunWindows run = new RunWindows();
  36. _ = Task.Factory.StartNew(delegate
  37. {
  38. while (true)
  39. {
  40. try
  41. {
  42. if (!isShow)
  43. {
  44. this.Dispatcher.Invoke(() => {
  45. if (File.Exists(_path))
  46. {
  47. SystemHelperNew.GetInstance.CreateShortcutOnDesktop();
  48. SystemHelperNew.GetInstance.CreateShortcutOnDesktop("可视化配置工具");
  49. //SystemHelperNew.GetInstance.CreateDesktopShortcut();
  50. run.LoadingData(_path);
  51. run.Show();
  52. isShow = true;
  53. }
  54. else
  55. {
  56. MessageBox.Show("未布局应用程序!");
  57. System.Windows.Application.Current.Shutdown(0);
  58. }
  59. });
  60. }
  61. FlushMemory();
  62. Thread.Sleep(TimeSpan.FromSeconds((double)1000));
  63. }
  64. catch { }
  65. }
  66. });
  67. }
  68. }
  69. }