コード例 #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            contextMenuStrip1.Hide();
            notifyIcon1.ContextMenuStrip = contextMenuStrip1;

            if (string.Empty != Properties.Settings.Default.MonitorProcessName)
            {
                AppManager.SetTargetMonitorProcessInfo("none",
                                                       Properties.Settings.Default.MonitorProcessName,
                                                       Properties.Settings.Default.MonitorProcessFullName);

                AppManager.ExistPrevMonitorProcess = true;
                AppManager.StartMonitorProcessWorkerThread();

                tempText = String.Format("Exist the Previously Monitored Process! [{0}]", AppManager.TargetProcessInfo.Name);
                PrintAndWriteFileWithTime(tempText);
            }
            else
            {
                AppManager.ExistPrevMonitorProcess = false;
            }
        }
コード例 #2
0
        private void listView1_MouseClick(object sender, MouseEventArgs e)
        {
            ListViewHitTestInfo hitTestInfo = listView1.HitTest(e.X, e.Y);

            if ("" != hitTestInfo.Item.Text)
            {
                if (true == _AppManager.RunningMonitorProcess)
                {
                    tempText = String.Format("Already Monitor Process [{0}], Change to this Process [{1}] ?",
                                             _AppManager.TargetProcessInfo.Name, hitTestInfo.Item.Text);

                    DialogResult DlgResult = MessageBox.Show(tempText, "Question ?", MessageBoxButtons.YesNo);

                    if (DialogResult.Yes == DlgResult)
                    {
                        PrintAndWriteFileWithTime(tempText);

                        tempText = String.Format("Start Process Monitor [{0}]!!!!!!", hitTestInfo.Item.Text);
                        PrintAndWriteFileWithTime(tempText);

                        // save process info to Settings.
                        _AppManager.SaveMonitorProcessInfo();

                        SetTargetMonitorProcessInfo(hitTestInfo.Item.SubItems);
                        _AppManager.PrintTargetMonitorProcessInfo();

                        PrintAndWriteFileWithTime("Try to Start MonitorProcessWorker");
                        if (true == _AppManager._runningMonitorThread)
                        {
                            PrintAndWriteFileWithTime("Already Running MonitorProcessWorker Thread!");
                        }
                        else
                        {
                            _AppManager.StartMonitorProcessWorkerThread();
                            PrintAndWriteFileWithTime("Success to Start MonitorProcessWorker");
                        }

                        tempText = String.Format("{0}|{1}", hitTestInfo.Item.SubItems[0].Text,
                                                 hitTestInfo.Item.SubItems[3].Text);

                        MinimizeWindow();
                    }
                    else if (DialogResult.No == DlgResult)
                    {
                    }
                }
                else
                {
                    tempText = String.Format("Start Monitor [{0}] ?", hitTestInfo.Item.Text);
                    DialogResult DlgResult = MessageBox.Show(tempText, "Question ?", MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == DlgResult)
                    {
                        tempText = String.Format("Start Process Monitor [{0}]", hitTestInfo.Item.Text);
                        PrintAndWriteFileWithTime(tempText);

                        string [] curMonitorProcessInfo = { hitTestInfo.Item.SubItems[2].Text,
                                                            hitTestInfo.Item.SubItems[0].Text,
                                                            hitTestInfo.Item.SubItems[3].Text };

                        _AppManager.SetTargetMonitorProcessInfo(ref curMonitorProcessInfo);

                        PrintAndWriteFileWithTime("Try to Start MonitorProcessWorker");
                        _AppManager.StartMonitorProcessWorkerThread();
                        PrintAndWriteFileWithTime("Success to Start MonitorProcessWorker");

                        MinimizeWindow();
                    }
                    else if (DialogResult.No == DlgResult)
                    {
                    }
                }
            }
        }