コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: tip2tail/MaSH
        private void frmMain_Loaded(object sender, RoutedEventArgs e)
        {
            // Upgrade settings
            if (Settings.Default.UpdateSettings)
            {
                Settings.Default.Upgrade();
                Settings.Default.UpdateSettings = false;
                Settings.Default.Save();
            }

            // Load the schedule
            if (!IsValidJson(Settings.Default.Schedule))
            {
                mashSchedule              = new MashSchedule();
                mashSchedule.Updated      = DateTimeOffset.Now;
                mashSchedule.Apps         = new List <MashApp>();
                Settings.Default.Schedule = mashSchedule.ToJson();
                Settings.Default.Enabled  = false;
                Settings.Default.Save();
            }
            ReloadSchedule();

            // Populate the version information
            string[] versionParts = Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.');
            labVersion.Content = string.Format("{0}.{1}.{2}", versionParts[0], versionParts[1], versionParts[2]);

            Stream       stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MaSH.Resources.BuildDate.txt");
            StreamReader sr     = new StreamReader(stream);

            labBuildDate.Content = Convert.ToDateTime(sr.ReadToEnd()).ToLongDateString();

            radYes.IsChecked = Settings.Default.Enabled;
            radNo.IsChecked  = !Settings.Default.Enabled;
            StartupWithWindows();
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: tip2tail/MaSH
        private void ReloadSchedule()
        {
            EnableDisableEditorControls(false);
            EnableDisableScheduleControls(true);
            listApps.Items.Clear();

            mashSchedule = MashSchedule.FromJson(Settings.Default.Schedule);

            // Populate the grid
            if (mashSchedule.Apps != null && mashSchedule.Apps.Count > 0)
            {
                foreach (var app in mashSchedule.Apps)
                {
                    listApps.Items.Add(app);
                }
            }
        }
コード例 #3
0
        public static void Go(bool isTestMode = false)
        {
            // Test mode?
            testMode = isTestMode;

            // Setup a timer to tick every second
            timer          = new DispatcherTimer();
            timer.Tick    += dispatcherTimer_Tick;
            timer.Interval = new TimeSpan(0, 0, 1);

            // Initial delay is five seconds (set to -1 here to indicate initial delay)
            delayCountdown = -1;

            // This will execute the schedule from settings
            schedule = MashSchedule.FromJson(Settings.Default.Schedule);
            appIndex = 0;

            logWin = new LogWindow(testMode);
            logWin.Show();

            Log("Schedule starting...");
            if (testMode)
            {
                Log("=== This is TEST MODE ===");
            }

            if (schedule.Apps.Count < 1)
            {
                Log("ERROR: No apps in schedule...");
                Finished();
            }
            else
            {
                // Start the timer
                timer.Start();
            }
        }
コード例 #4
0
ファイル: MashSchedule.cs プロジェクト: tip2tail/MaSH
 public static string ToJson(this MashSchedule self) => JsonConvert.SerializeObject(self, Converter.Settings);