예제 #1
0
        private static void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            if (delayCountdown == -1)
            {
                delayCountdown = 5;
                Log("Waiting 5 seconds before processing first app...");
            }

            // Stop before executing the next app
            delayCountdown--;
            if (delayCountdown > 0)
            {
                return;
            }

            // Ready to execute the next app
            MashApp app = schedule.Apps[appIndex];

            Log("Launching: " + app.Name);

            // Launch it!
            ProcessStartInfo startInfo = new ProcessStartInfo()
            {
                FileName  = app.Command,
                Arguments = app.Params,
            };

            Log("Command: " + app.Command);
            Log("Parameters: " + app.Params);
            if (!testMode || Debugger.IsAttached)
            {
                try
                {
                    var proc = Process.Start(startInfo);
                    Log("New PID: " + proc.Id);
                }
                catch (Exception ex)
                {
                    Log("ERROR: " + ex.Message);
                }
            }

            // Next app...
            appIndex++;
            if (appIndex >= schedule.Apps.Count)
            {
                // Schedule is finished
                Finished();
            }
            else
            {
                // Set delay then loop again
                Log("Sleeping for " + app.Delay + " seconds before next app...");
                delayCountdown = app.Delay;
            }
        }
예제 #2
0
 private void btnDown_Click(object sender, RoutedEventArgs e)
 {
     if (listApps.SelectedIndex > -1 && listApps.SelectedIndex < (listApps.Items.Count - 1))
     {
         MashApp app = (MashApp)listApps.SelectedItem;
         mashSchedule.Apps.MoveDown(app);
         listApps.SelectedIndex = listApps.Items.IndexOf(app);
         SaveAndReloadSchedule();
     }
 }
예제 #3
0
 private void btnUp_Click(object sender, RoutedEventArgs e)
 {
     if (listApps.SelectedIndex > 0)
     {
         MashApp app = (MashApp)listApps.SelectedItem;
         mashSchedule.Apps.MoveUp(app);
         listApps.SelectedIndex = listApps.Items.IndexOf(app);
         SaveAndReloadSchedule();
     }
 }
예제 #4
0
 private void listApps_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
 {
     if (listApps.SelectedIndex > -1)
     {
         ClearEditorControls();
         MashApp app = (MashApp)listApps.SelectedItem;
         txtAppName.Text    = app.Name;
         txtAppCommand.Text = app.Command;
         txtAppParams.Text  = app.Params;
         txtAppDelay.Text   = app.Delay.ToString();
     }
 }
예제 #5
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            // Validation
            if (txtAppName.Text.Trim().Length < 1)
            {
                MessageBox.Show("You must enter an application name", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            else if (txtAppCommand.Text.Trim().Length < 1)
            {
                MessageBox.Show("You must enter an application command", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (!IsDigitsOnly(txtAppDelay.Text.Trim()))
            {
                MessageBox.Show("You must enter only digits for the delay seconds (default is 1)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (Convert.ToInt32(txtAppDelay.Text.Trim()) < 1 || Convert.ToInt32(txtAppDelay.Text.Trim()) > 120)
            {
                MessageBox.Show("Delay seconds should be between 1 and 120 seconds", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // Save the changes
            if (editingIndex == -1)
            {
                // Add
                MashApp app = new MashApp()
                {
                    Name    = txtAppName.Text.Trim(),
                    Command = txtAppCommand.Text.Trim(),
                    Params  = txtAppParams.Text.Trim(),
                    Delay   = Convert.ToInt32(txtAppDelay.Text.Trim()),
                };
                mashSchedule.Apps.Add(app);
            }
            else
            {
                // Edit
                mashSchedule.Apps[editingIndex].Name    = txtAppName.Text.Trim();
                mashSchedule.Apps[editingIndex].Command = txtAppCommand.Text.Trim();
                mashSchedule.Apps[editingIndex].Params  = txtAppParams.Text.Trim();
                mashSchedule.Apps[editingIndex].Delay   = Convert.ToInt32(txtAppDelay.Text.Trim());
            }

            // Save and Reload
            SaveAndReloadSchedule();
        }
예제 #6
0
 private void HandleEdit()
 {
     if (listApps.SelectedIndex > -1)
     {
         editingIndex = listApps.SelectedIndex;
         ClearEditorControls();
         MashApp app = (MashApp)listApps.SelectedItem;
         txtAppName.Text    = app.Name;
         txtAppCommand.Text = app.Command;
         txtAppParams.Text  = app.Params;
         txtAppDelay.Text   = app.Delay.ToString();
         EnableDisableScheduleControls(false);
         EnableDisableEditorControls(true);
         txtAppName.Focus();
     }
 }