示例#1
0
 public void addToWatchedProcesses(Proc newProc)
 {
     addToWatchedProcesses(newProc.procName, newProc.userProcName, newProc.notes, newProc.font);
 }
示例#2
0
        // basic plan: get the string of notes, parse notes into processes
        // sample process note in settings:
        // <ProcessWatcherNote ProcName="notepad.exe" UserProcName="Notepad" Font="Microsoft Sans Serif, 8, Regular">All of the notes go here</ProcessWatcherNote>
        private void loadWatchedProcesses()
        {
            string notes = Properties.Settings.Default.notes;

            //MessageBox.Show(notes);

            while (notes != "")
            {
                // returns the index of the space after
                int startIndex = notes.IndexOf("<ProcessWatcherNote") + 20;
                int stopIndex  = notes.IndexOf("</ProcessWatcherNote>");

                // get the process info without the tags
                string procInfo = notes.Substring(startIndex, stopIndex - startIndex);

                startIndex = procInfo.IndexOf('"') + 1;
                stopIndex  = procInfo.Substring(startIndex).IndexOf('"');

                // save the system defined procName
                string procName = procInfo.Substring(startIndex, stopIndex);

                // save the rest of the process info minus the procName
                procInfo = procInfo.Substring(startIndex + stopIndex + 2);

                startIndex = procInfo.IndexOf('"') + 1;
                stopIndex  = procInfo.Substring(startIndex).IndexOf('"');

                string userProcName = procInfo.Substring(startIndex, stopIndex);

                // save the rest of the process info minus the userProcName
                procInfo = procInfo.Substring(startIndex + stopIndex + 2);

                startIndex = procInfo.IndexOf('"') + 1;
                stopIndex  = procInfo.Substring(startIndex).IndexOf('"');

                string fontInfo = procInfo.Substring(startIndex, stopIndex);

                string fontName = fontInfo.Substring(0, fontInfo.IndexOf(','));

                fontInfo = fontInfo.Substring(fontInfo.IndexOf(',') + 1);

                float fontSize = float.Parse(fontInfo.Substring(0, fontInfo.IndexOf(',')));

                fontInfo = fontInfo.Substring(fontInfo.IndexOf(',') + 1);

                FontStyle fontStyle = FontStyle.Regular;

                switch (fontInfo)
                {
                case "Bold":
                    fontStyle = FontStyle.Bold;
                    break;

                case "Italic":
                    fontStyle = FontStyle.Italic;
                    break;

                case "Underline":
                    fontStyle = FontStyle.Underline;
                    break;
                }

                Font procFont = new Font(fontName, fontSize, fontStyle);

                // this info should be the notes
                procInfo = procInfo.Substring(startIndex + stopIndex + 2);

                Proc np = new Proc(procName, userProcName, procInfo, procFont);

                addToWatchedProcesses(np);

                // remove the latest retrieved notes and move on
                notes = notes.Substring(notes.IndexOf("</ProcessWatcherNote>") + 21);
            }
        }
示例#3
0
 public Proc[] getProcs()
 {
     Proc[] procs = new Proc[watchedProcs.Count];
     watchedProcs.Values.CopyTo(procs, 0);
     return(procs);
 }