|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using BeDesignerSCADA.Helper;
- using BeDesignerSCADA.View;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
-
- namespace BPASmart.MenuLoad
- {
- /// <summary>
- /// Interaction logic for App.xaml
- /// </summary>
- public partial class App : Application
- {
- bool isShow = false;
- [DllImport("kernel32.dll")]
- private static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max);
- string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf";
- private void FlushMemory()
- {
- GC.Collect();
- GC.WaitForPendingFinalizers();
- if (Environment.OSVersion.Platform == PlatformID.Win32NT)
- SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
- }
-
- protected override void OnStartup(StartupEventArgs e)
- {
- base.OnStartup(e);
-
- RunWindows run = new RunWindows();
- _ = Task.Factory.StartNew(delegate
- {
- while (true)
- {
- try
- {
- if (!isShow)
- {
- this.Dispatcher.Invoke(() => {
- if (File.Exists(_path))
- {
- SystemHelperNew.GetInstance.CreateShortcutOnDesktop();
- SystemHelperNew.GetInstance.CreateShortcutOnDesktop("可视化配置工具");
- //SystemHelperNew.GetInstance.CreateDesktopShortcut();
- run.LoadingData(_path);
- run.Show();
- isShow = true;
- }
- else
- {
- MessageBox.Show("未布局应用程序!");
- System.Windows.Application.Current.Shutdown(0);
- }
- });
-
- }
- FlushMemory();
- Thread.Sleep(TimeSpan.FromSeconds((double)1000));
- }
- catch { }
- }
- });
-
- }
- }
- }
|