Beispiel #1
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () =>
            {
                Logger.LogInfo("Runner exited");
                Environment.Exit(0);
            });

            _themeManager = new ThemeManager(this);

            if (!FancyZonesEditorIO.ParseParams().Result)
            {
                FancyZonesEditorIO.ParseCommandLineArguments();
            }

            var parseResult = FancyZonesEditorIO.ParseZoneSettings();

            // 10ms retry loop with 1 second timeout
            if (!parseResult.Result)
            {
                CancellationTokenSource ts = new CancellationTokenSource();
                Task t = Task.Run(() =>
                {
                    while (!parseResult.Result && !ts.IsCancellationRequested)
                    {
                        Task.Delay(10).Wait();
                        parseResult = FancyZonesEditorIO.ParseZoneSettings();
                    }
                });

                try
                {
                    bool result = t.Wait(1000, ts.Token);
                    ts.Cancel();
                }
                catch (OperationCanceledException)
                {
                    ts.Dispose();
                }
            }

            // Error message if parsing failed
            if (!parseResult.Result)
            {
                Logger.LogError(ParsingErrorReportTag + ": " + parseResult.Message + "; " + ParsingErrorDataTag + ": " + parseResult.MalformedData);
                MessageBox.Show(parseResult.Message, FancyZonesEditor.Properties.Resources.Error_Parsing_Zones_Settings_Title, MessageBoxButton.OK);
            }

            MainWindowSettingsModel settings = ((App)Current).MainWindowSettings;

            settings.UpdateSelectedLayoutModel();

            Overlay.Show();
        }
        private void OnStartup(object sender, StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () =>
            {
                Logger.LogInfo("Runner exited");
                Environment.Exit(0);
            });

            _themeManager = new ThemeManager(this);

            if (!FancyZonesEditorIO.ParseParams().Result)
            {
                FancyZonesEditorIO.ParseCommandLineArguments();
            }

            var parseResult = FancyZonesEditorIO.ParseAppliedLayouts();

            if (!parseResult.Result)
            {
                Logger.LogError(ParsingErrorReportTag + ": " + parseResult.Message + "; " + ParsingErrorDataTag + ": " + parseResult.MalformedData);
                MessageBox.Show(parseResult.Message, FancyZonesEditor.Properties.Resources.Error_Parsing_Data_Title, MessageBoxButton.OK);
            }

            parseResult = FancyZonesEditorIO.ParseCustomLayouts();
            if (!parseResult.Result)
            {
                Logger.LogError(ParsingErrorReportTag + ": " + parseResult.Message + "; " + ParsingErrorDataTag + ": " + parseResult.MalformedData);
                MessageBox.Show(parseResult.Message, FancyZonesEditor.Properties.Resources.Error_Parsing_Data_Title, MessageBoxButton.OK);
            }

            parseResult = FancyZonesEditorIO.ParseLayoutHotkeys();
            if (!parseResult.Result)
            {
                Logger.LogError(ParsingErrorReportTag + ": " + parseResult.Message + "; " + ParsingErrorDataTag + ": " + parseResult.MalformedData);
                MessageBox.Show(parseResult.Message, FancyZonesEditor.Properties.Resources.Error_Parsing_Data_Title, MessageBoxButton.OK);
            }

            parseResult = FancyZonesEditorIO.ParseLayoutTemplates();
            if (!parseResult.Result)
            {
                Logger.LogError(ParsingErrorReportTag + ": " + parseResult.Message + "; " + ParsingErrorDataTag + ": " + parseResult.MalformedData);
                MessageBox.Show(parseResult.Message, FancyZonesEditor.Properties.Resources.Error_Parsing_Data_Title, MessageBoxButton.OK);
            }

            MainWindowSettingsModel settings = ((App)Current).MainWindowSettings;

            settings.UpdateSelectedLayoutModel();

            Overlay.Show();
        }
Beispiel #3
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () =>
            {
                Environment.Exit(0);
            });

            FancyZonesEditorIO.ParseCommandLineArguments();
            FancyZonesEditorIO.ParseDeviceInfoData();

            MainWindowSettingsModel settings = ((App)Current).MainWindowSettings;

            settings.UpdateSelectedLayoutModel();

            Overlay.Show();
        }
Beispiel #4
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () =>
            {
                Environment.Exit(0);
            });

            _themeManager = new ThemeManager(this);

            if (!FancyZonesEditorIO.ParseParams().Result)
            {
                FancyZonesEditorIO.ParseCommandLineArguments();
            }

            var parseResult = FancyZonesEditorIO.ParseZoneSettings();

            // 10ms retry loop with 1 second timeout
            if (!parseResult.Result)
            {
                CancellationTokenSource ts = new CancellationTokenSource();
                Task t = Task.Run(() =>
                {
                    while (!parseResult.Result && !ts.IsCancellationRequested)
                    {
                        Task.Delay(10).Wait();
                        parseResult = FancyZonesEditorIO.ParseZoneSettings();
                    }
                });

                try
                {
                    bool result = t.Wait(1000, ts.Token);
                    ts.Cancel();
                }
                catch (OperationCanceledException)
                {
                    ts.Dispose();
                }
            }

            // Error message if parsing failed
            if (!parseResult.Result)
            {
                var sb = new StringBuilder();
                sb.AppendLine();
                sb.AppendLine("## " + ParsingErrorReportTag);
                sb.AppendLine();
                sb.AppendLine(parseResult.Message);
                sb.AppendLine();
                sb.AppendLine(ParsingErrorDataTag);
                sb.AppendLine(parseResult.MalformedData);

                string message = parseResult.Message + Environment.NewLine + Environment.NewLine + FancyZonesEditor.Properties.Resources.Error_Parsing_Zones_Settings_User_Choice;
                if (MessageBox.Show(message, FancyZonesEditor.Properties.Resources.Error_Parsing_Zones_Settings_Title, MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    // TODO: log error
                    ShowExceptionReportMessageBox(sb.ToString());
                    Environment.Exit(0);
                }

                ShowExceptionReportMessageBox(sb.ToString());
            }

            MainWindowSettingsModel settings = ((App)Current).MainWindowSettings;

            settings.UpdateSelectedLayoutModel();

            Overlay.Show();
        }