Ejemplo n.º 1
0
        private void addProcessToWatcher(string procName, string userProcName)
        {
            ProcessWatcher.getInstance().addToWatchedProcesses(procName, userProcName);

            if (procName == "")
            {
                if (MessageBox.Show("You are watching the process \"" + userProcName + "\".\nWould you like to go to the notes for it?",
                                    "Process Added",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    parentMW.addProcessTab(procName, userProcName, true);
                }
                else
                {
                    parentMW.addProcessTab(procName, userProcName, false);
                }
            }
            else
            {
                if (MessageBox.Show("You are watching the process \"" + procName + "\".\nWould you like to go to the notes for it?",
                                    "Process Added",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    parentMW.addProcessTab(procName, userProcName, true);
                }
                else
                {
                    parentMW.addProcessTab(procName, userProcName, false);
                }
            }
        }
Ejemplo n.º 2
0
        private void stopWatchingButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to stop watching and keeping\nnotes on this process?", "Confirm", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
            {
                return;
            }

            ProcessWatcher.getInstance().removeFromWatchedProcesses(procName);
            parentMW.removeProcessTab(this);
        }
Ejemplo n.º 3
0
        private void fontSettingsButton_Click(object sender, EventArgs e)
        {
            fd      = new FontDialog();
            fd.Font = notesRichTextBox.Font;

            if (fd.ShowDialog() == DialogResult.OK)
            {
                notesRichTextBox.Font = fd.Font;
                ProcessWatcher.getInstance().setFont(procName, fd.Font);
            }
        }
Ejemplo n.º 4
0
        public ProcessTab(string procName, string userProcName, MainWindow parentMW)
        {
            InitializeComponent();

            this.procName     = procName;
            this.userProcName = userProcName;
            this.parentMW     = parentMW;

            notesRichTextBox.Text = ProcessWatcher.getInstance().getNotes(procName);
            notesRichTextBox.Font = ProcessWatcher.getInstance().getFont(procName);
        }
Ejemplo n.º 5
0
        private void renameButton_Click(object sender, EventArgs e)
        {
            ChangeUserProcNameDialog cupnd = new ChangeUserProcNameDialog(userProcName);

            cupnd.ShowDialog();

            if (cupnd.Changed)
            {
                userProcName = cupnd.NewName;
                ProcessWatcher.getInstance().setUserProcName(procName, userProcName);
                parentMW.changeProcessTabTitle(procName, userProcName);
            }
        }
Ejemplo n.º 6
0
        private void checkForNewProcesses()
        {
            Process[] currentProcs = Process.GetProcesses();

            for (int i = 0; i < currentProcs.Length; i++)
            {
                if (ProcessWatcher.getInstance().isWatching(currentProcs[i].ProcessName))
                {
                    if (!isTabOpen(currentProcs[i].ProcessName))
                    {
                        addProcessTab(currentProcs[i].ProcessName, ProcessWatcher.getInstance().getUserProcName(currentProcs[i].ProcessName), false);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void clearNotesButton_Click(object sender, EventArgs e)
        {
            if (tabControl1.TabPages.Count <= 1)
            {
                return;
            }

            if (MessageBox.Show("Are you sure you want to clear all notes?\n" +
                                "This will remove all of your notes, even for\n" +
                                "processes not currently listed.",
                                "Confirm", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
            {
                ProcessWatcher.getInstance().clearNotes();
                closeAll();
            }
        }
Ejemplo n.º 8
0
        // used by the child thread to determine if the list has changed,
        // which in turn is used to tell the parent that the list needs
        // to be updated
        private bool processListHasChanged()
        {
            // get a snapshot of the currently running processes
            Process[] procs = Process.GetProcesses();

            // get the snapshots currently being watched in the ProcessWatcher
            Proc[] currentlyWatchedProcs = ProcessWatcher.getInstance().getProcs();

            // the processes we're currently trying to list
            List <string> currentProcesses = new List <string>();

            // loop through the current snapshot list of processes
            for (int i = 0; i < procs.Length; i++)
            {
                if (procs[i].MainWindowTitle == Text)
                {
                    continue;
                }

                // if the MainWindowTitle of the process is not "", that means
                // it should be a visible window
                if (procs[i].MainWindowTitle != "")
                {
                    // return true only if it's not currently listed, and it's not
                    // currently on the currentProcessesListed list
                    if (!isListed(procs[i].ProcessName) && !currentProcessesListed.Contains(procs[i].ProcessName))
                    {
                        return(true);
                    }

                    currentProcesses.Add(procs[i].ProcessName);
                }
            }

            // go through the old list of processes and cull the ones no longer running
            for (int i = 0; i < currentProcessesListed.Count; i++)
            {
                if (!currentProcesses.Contains(currentProcessesListed[i]))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 9
0
        public MainWindow()
        {
            InitializeComponent();

            procListView.Columns[1].Width = 245;
            procListView.Columns[2].Width = 380;

            //listProcesses();

            //checkForNewProcesses();

            ProcessWatcher.getInstance().addProcessListener(this);

            // set the dispatcher to this thread
            dispatcher = Dispatcher.CurrentDispatcher;

            timer1.Start();
        }
Ejemplo n.º 10
0
        private void closeAll()
        {
            keepSearching = false;
            checkerThread.Abort();

            for (int i = 1; i < tabControl1.TabPages.Count; i++)
            {
                for (int j = 0; j < tabControl1.TabPages[i].Controls.Count; j++)
                {
                    if (tabControl1.TabPages[i].Controls[j] is ProcessTab)
                    {
                        ((ProcessTab)tabControl1.TabPages[i].Controls[j]).closeTab();
                        i--;
                    }
                }
            }

            ProcessWatcher.getInstance().saveWatchedProcesses();
        }
Ejemplo n.º 11
0
        private void addProcs()
        {
            // if at least 1 process was selected
            if (procListView.SelectedIndices.Count > 0)
            {
                // loop through all of the selected processes, and go through the AddProcessForm
                // to add them to the Process Watcher
                for (int i = 0; i < procListView.SelectedIndices.Count; i++)
                {
                    string procName = procListView.Items[procListView.SelectedIndices[i]].SubItems[1].Text;

                    if (ProcessWatcher.getInstance().isWatching(procName))
                    {
                        if (!isTabOpen(procName))
                        {
                            Proc p = ProcessWatcher.getInstance().getProc(procName);

                            if (p != null)
                            {
                                addProcessTab(p.procName, p.userProcName, false);
                            }
                        }

                        continue;
                    }

                    string userProcName = procListView.Items[procListView.SelectedIndices[i]].SubItems[2].Text;

                    AddProcessForm newadf = new AddProcessForm(
                        procName,
                        userProcName,
                        this);

                    newadf.ShowDialog(this);
                    newadf.Dispose();
                    newadf.Close();
                }
            }
        }
Ejemplo n.º 12
0
        public void removeProcessTab(ProcessTab pt)
        {
            // loop through the tab pages and find the one with the given ProcessTab;
            // then remove it
            for (int i = 1; i < tabControl1.TabCount; i++)
            {
                if (tabControl1.TabPages[i].Controls.Contains(pt))
                {
                    tabControl1.TabPages.RemoveAt(i);
                    openTabs.Remove(pt);
                }
            }

            if (!ProcessWatcher.getInstance().isWatching(pt.procName))
            {
                for (int i = 0; i < procListView.Items.Count; i++)
                {
                    if (procListView.Items[i].SubItems[1].Text == pt.procName)
                    {
                        procListView.Items[i].SubItems[3].Text = "No";
                    }
                }
            }
        }
Ejemplo n.º 13
0
        void listProcesses()
        {
            // checks a static bool to see if we're already trying to list the processes
            if (!isListing)
            {
                isListing = true;
            }
            else
            {
                return;
            }

            // get a snapshot of the currently running processes
            Process[] procs = Process.GetProcesses();

            // get the snapshots currently being watched in the ProcessWatcher
            Proc[] currentlyWatchedProcs = ProcessWatcher.getInstance().getProcs();

            // the processes we're currently trying to list
            List <string> currentProcesses = new List <string>();

            // loop through the current snapshot list of processes
            for (int i = 0; i < procs.Length; i++)
            {
                if (procs[i].MainWindowTitle == Text)
                {
                    continue;
                }

                // if the MainWindowTitle of the process is not "", that means
                // it should be a visible window
                if (procs[i].MainWindowTitle != "")
                {
                    // this is just a visual representation of whether the
                    // process is being watched to be displayed on the listview
                    string isBeingWatched = "No";

                    // check to see if the process is already being watched
                    if (ProcessWatcher.getInstance().isWatching(procs[i].ProcessName))
                    {
                        // if it is, set isBeingWatched to true/yes
                        isBeingWatched = "Yes";

                        // since it's already being watched, we should have a previous
                        // Proc object for it. Find that and open a new tab with it
                        for (int j = 0; j < currentlyWatchedProcs.Length; j++)
                        {
                            if (currentlyWatchedProcs[j].procName == procs[i].ProcessName)
                            {
                                if (!isTabOpen(currentlyWatchedProcs[j].procName))
                                {
                                    addProcessTab(currentlyWatchedProcs[j].procName, currentlyWatchedProcs[j].userProcName, false);
                                }
                            }
                        }
                    }

                    // add a process to the listView only if it's not currently listed, and it's not
                    // currently on the currentProcessesListed list
                    if (!isListed(procs[i].ProcessName) && !currentProcessesListed.Contains(procs[i].ProcessName))
                    {
                        ListViewItem lvi = new ListViewItem(new string[] { procs[i].Id.ToString(), procs[i].ProcessName, procs[i].MainWindowTitle, isBeingWatched });

                        procListView.Items.Add(lvi);

                        currentProcessesListed.Add(procs[i].ProcessName);
                    }

                    currentProcesses.Add(procs[i].ProcessName);
                }
            }

            // go through the old list of processes and cull the ones no longer running
            for (int i = 0; i < currentProcessesListed.Count; i++)
            {
                if (!currentProcesses.Contains(currentProcessesListed[i]))
                {
                    removeListItem(currentProcessesListed[i]);
                    currentProcessesListed.RemoveAt(i);
                }
            }

            isListing = false;
        }
Ejemplo n.º 14
0
        public void closeTab()
        {
            ProcessWatcher.getInstance().setNotes(procName, notesRichTextBox.Text);

            parentMW.removeProcessTab(this);
        }