Esempio n. 1
0
        public MainWindow()
        {
            ControlsHelper.InitInvokeContext();
            // Make sure setting changes updates UI on the same thread as UI.
            var scheduler = ControlsHelper.MainTaskScheduler;

            SettingsManager.SetSynchronizingObject(scheduler);
            // Disable some functionality in Visual Studio Interface design mode.
            if (!ControlsHelper.IsDesignMode(this))
            {
                PreviewKeyDown += MainWindow_PreviewKeyDown;
                Closing        += MainWindow_Closing;
            }
            InitHelper.InitTimer(this, InitializeComponent);
            if (ControlsHelper.IsDesignMode(this))
            {
                return;
            }
            StartHelper.Initialize();
            InitiInterfaceUpdate();
            // Check if app version changed.
            var o          = SettingsManager.Options;
            var appVersion = new JocysCom.ClassLibrary.Configuration.AssemblyInfo().Version.ToString();

            AppVersionChanged = o.AppVersion != appVersion;
            o.AppVersion      = appVersion;
        }
Esempio n. 2
0
 private void Window_Unloaded(object sender, RoutedEventArgs e)
 {
     // Cleanup references which prevents disposal.
     StartHelper.OnClose   -= StartHelper_OnClose;
     StartHelper.OnRestore -= StartHelper_OnRestore;
     SettingsManager.Current.SettingChanged      -= Current_SettingChanged;
     SettingsManager.Summaries.Items.ListChanged -= Summaries_ListChanged;
     SettingsManager.Current.ConfigLoaded        -= Current_ConfigLoaded;
     Global.DHelper.DevicesUpdated   -= DHelper_DevicesUpdated;
     Global.DHelper.UpdateCompleted  -= DHelper_UpdateCompleted;
     Global.DHelper.FrequencyUpdated -= DHelper_FrequencyUpdated;
     Global.DHelper.StatesRetrieved  -= DHelper_StatesRetrieved;
     Global.DHelper.XInputReloaded   -= DHelper_XInputReloaded;
     SettingsManager.Current.NotifySettingsStatus = null;
     SettingsManager.SetSynchronizingObject(null);
     IssuesPanel.IsSuspended     = null;
     IssuesPanel.CheckCompleted -= IssuesPanel_CheckCompleted;
     UpdateTimer.Elapsed        -= UpdateTimer_Elapsed;
     UpdateTimer.Dispose();
     SettingsTimer.Elapsed -= SettingsTimer_Elapsed;
     SettingsTimer.Dispose();
     CleanStatusTimer.Elapsed -= CleanStatusTimer_Elapsed;
     CleanStatusTimer.Dispose();
     StartHelper.Dispose();
     DisposeUpdateForm();
     DisposeInterfaceUpdate();
     CollectGarbage();
 }
Esempio n. 3
0
 public void Dispose()
 {
     StartHelper.Dispose();
     DisposeUpdateForm();
     DisposeInterfaceUpdate();
     if (Global.DHelper != null)
     {
         Global.DHelper.Dispose();
     }
 }
Esempio n. 4
0
        public MainWindow()
        {
            ControlsHelper.InitInvokeContext();
            // Disable some functionality in Visual Studio Interface design mode.
            if (!ControlsHelper.IsDesignMode(this))
            {
                PreviewKeyDown += MainWindow_PreviewKeyDown;
                Closing        += MainWindow_Closing;
            }
            InitializeComponent();
            if (ControlsHelper.IsDesignMode(this))
            {
                return;
            }
            StartHelper.Initialize();
            InitiInterfaceUpdate();
            // Check if app version changed.
            var o          = SettingsManager.Options;
            var appVersion = new JocysCom.ClassLibrary.Configuration.AssemblyInfo().Version.ToString();

            AppVersionChanged = o.AppVersion != appVersion;
            o.AppVersion      = appVersion;
        }
Esempio n. 5
0
        static void StartApp(string[] args)
        {
            if (!RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully)
            {
                // Failed to enable useLegacyV2RuntimeActivationPolicy at runtime.
            }
            // Requires System.Configuration.Install reference.
            var ic = new System.Configuration.Install.InstallContext(null, args);
            // ------------------------------------------------
            // Administrator commands.
            // ------------------------------------------------
            var executed = ProcessAdminCommands(args);

            // If valid command was executed then...
            if (executed)
            {
                return;
            }
            // ------------------------------------------------
            // If must open all setting folders then...
            if (ic.Parameters.ContainsKey("Settings"))
            {
                OpenSettingsFolder(ApplicationDataPath);
                OpenSettingsFolder(CommonApplicationDataPath);
                OpenSettingsFolder(LocalApplicationDataPath);
                return;
            }
            // If default application settings failed to load then...
            if (!CheckDefaultSettings())
            {
                return;
            }
            // Load all settings.
            SettingsManager.Load();
            var o = SettingsManager.Options;

            // DPI aware property must be set before application window is created.
            if (Environment.OSVersion.Version.Major >= 6 && o.IsProcessDPIAware)
            {
                NativeMethods.SetProcessDPIAware();
            }
            Global.InitializeServices();
            Global.InitializeCloudClient();
            // Initialize DInput Helper.
            Global.DHelper = new DInput.DInputHelper();
            if (ic.Parameters.ContainsKey("Exit"))
            {
                // Close all x360ce apps.
                StartHelper.BroadcastMessage(StartHelper.wParam_Close);
                return;
            }
            // Allow to run if multiple copies allowed or allow to restore window.
            var allowToRun = !o.AllowOnlyOneCopy || !StartHelper.BroadcastMessage(StartHelper.wParam_Restore);

            // If one copy is already opened then...
            if (allowToRun)
            {
                InitializeServices();
                InitializeTrayIcon();
                app = new App();
                //app.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
                app.Startup += App_Startup;
                app.InitializeComponent();
                app.Run();
            }
            Global.DisposeCloudClient();
            Global.DisposeServices();
        }