Ejemplo n.º 1
0
        public void RemoveProcess(ProcessButton button)
        {
            var butInList = isButtonInList(button);

            if (butInList != null)
            {
                runningProcs.Remove(butInList);
            }
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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());
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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");
            }
        }
Ejemplo n.º 8
0
 private void btnRunningProcs_Click(object sender, EventArgs e)
 {
     ProcessButton.OpenRunningProcesses();
 }
Ejemplo n.º 9
0
 private void form_Resize(object sender, EventArgs e)
 {
     SortButtons(ProcessButton.GetAllButtons());
 }
Ejemplo n.º 10
0
 public void RemoveProgramButton(ProcessButton button)
 {
     Controls.Remove(button);
     button.RemoveButton();
 }
Ejemplo n.º 11
0
 private void btnCloseAll_Click(object sender, EventArgs e)
 {
     ProcessButton.CloseAll();
 }
Ejemplo n.º 12
0
 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();
 }
Ejemplo n.º 13
0
        public void StopProcess(ProcessButton button)
        {
            var toKill = isButtonInList(button);

            toKill.Item1.Kill();
        }