public void RemoveProcess(ProcessButton button) { var butInList = isButtonInList(button); if (butInList != null) { runningProcs.Remove(butInList); } }
private Tuple <Process, ProcessButton> isButtonInList(ProcessButton button) //returns null if not found { foreach (var rBut in runningProcs.ToList()) { if (rBut.Item2 == button) { return(rBut); } } return(null); }
public Form1() { InitializeComponent(); if (Properties.Settings.Default.btnStringList == null) { Properties.Settings.Default.btnStringList = new System.Collections.Specialized.StringCollection(); } LoadSavedButtons(); timerCheckRunning.Start(); this.Controls.Add(new ProcessButton()); SortButtons(ProcessButton.GetAllButtons()); }
private void CreateProgramButton(ProcessButton button, string filePath) { if (IsAlreadyLoaded(filePath)) { return; } button.SetProgram(filePath); button.Click -= new EventHandler(AddProgramButton_Click); button.Click += new EventHandler(RunProgramButton_Click); button.DragDrop -= NewButton_DragDrop; button.DragDrop += ChangeButton_DragDrop; CreateNewButton(); }
private void LoadSavedButtons() { var btnStringList = Properties.Settings.Default.btnStringList.Cast <string>().ToList(); Properties.Settings.Default.btnStringList = new System.Collections.Specialized.StringCollection(); foreach (var filePath in btnStringList) { var button = new ProcessButton(); button.LoadProgramButton(filePath); Controls.Add(button); } ProcessButton.CheckRunning(); }
private void AddProgramButton_Click(object sender, EventArgs e) { ProcessButton button = sender as ProcessButton; Debug.WriteLine(button.NameLabel); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = "c:\\"; openFileDialog.Filter = "Executable Programs (*.exe) | *.exe"; openFileDialog.FilterIndex = 0; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { CreateProgramButton(button, openFileDialog.FileName); } }
private void ChangeButton_DragDrop(object sender, DragEventArgs e) { ProcessButton button = sender as ProcessButton; var files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files.Length > 1) { MessageBox.Show("Too many files selected"); return; } if (Path.GetExtension(files[0]).Equals(".exe", StringComparison.InvariantCultureIgnoreCase)) { this.SetProgram(Path.GetFullPath(files[0])); } else { MessageBox.Show("Not an executable"); } }
private void btnRunningProcs_Click(object sender, EventArgs e) { ProcessButton.OpenRunningProcesses(); }
private void form_Resize(object sender, EventArgs e) { SortButtons(ProcessButton.GetAllButtons()); }
public void RemoveProgramButton(ProcessButton button) { Controls.Remove(button); button.RemoveButton(); }
private void btnCloseAll_Click(object sender, EventArgs e) { ProcessButton.CloseAll(); }
private void timerCheckRunning_Tick(object sender, EventArgs e) //hooking a driver function to tell when a process launched seemed like too much work, though i hate this way of checking if the process is running { ProcessButton.CheckRunning(); }
public void StopProcess(ProcessButton button) { var toKill = isButtonInList(button); toKill.Item1.Kill(); }