Example #1
0
        private void SettingsModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            SettingsModel model = (SettingsModel)sender;

            List <string> properties = new List <string>()
            {
                "Enabled", "LightThemeTime", "DarkThemeTime"
            };

            if (properties.Contains(e.PropertyName))
            {
                Content.IsEnabled = false;

                try
                {
                    if (!model.Enabled)
                    {
                        TaskSchedulerHandler.DeleteAllTasks();
                    }
                    else
                    {
                        TaskSchedulerHandler.UpdateAllTasks(model.LightThemeTime, model.DarkThemeTime);
                    }
                }
                catch
                {
                    new MessageWindow(this, "An error occurred", "There was an error while writing to TaskScheduler. Please check logs for more info.", null, "Close").ShowDialog();
                }
                finally
                {
                    Content.IsEnabled = true;
                }
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            if (args.Length > 0)
            {
                Logger.Info("Starting app with command line arguments: {0}", string.Join(", ", args));

                AutoFileSaver <SettingsModel> autoFileSaver = new AutoFileSaver <SettingsModel>("settings.xml", true);
                AppearanceHandler             handler       = new AppearanceHandler(autoFileSaver.Model);

                foreach (string arg in args)
                {
                    switch (arg)
                    {
                    case "/light":
                        handler.SwitchToLightTheme();
                        break;

                    case "/dark":
                        handler.SwitchToDarkTheme();
                        break;

                    case "/update":
                        AutoUpdater autoUpdater = new AutoUpdater(true, true);
                        autoUpdater.CheckForUpdates(true).Wait();
                        break;

                    case "/clean":
                        TaskSchedulerHandler.DeleteAllTasks();
                        break;

                    default:
                        Logger.Error("Command line argument is not accepted: {0}", arg);
                        break;
                    }
                }
            }
            else
            {
                App app = new App();
                app.InitializeComponent();
                app.Run();
            }
        }