예제 #1
0
        private void ProcessWatchTimer_Tick(object sender, EventArgs e) {

            while (qadd.Count > 0) {
                PolProcess pol = new PolProcess(qadd.Dequeue());
                ToolStripMenuItem menuItem = new ToolStripMenuItem(pol.Title);
                menuItem.Tag = pol;
                WindowerMenuItemProcess.DropDownItems.Add(menuItem);
            }

            while (qdel.Count > 0) {
                Process p = qdel.Dequeue();
                foreach (ToolStripMenuItem menuItem in WindowerMenuItemProcess.DropDownItems) {
                    PolProcess pol = (PolProcess) menuItem.Tag;
                    if (pol != null && pol.Pid == p.Id) {
                        WindowerMenuItemProcess.DropDownItems.Remove(menuItem);
                        break;
                    }
                }
            }

            if (WindowerMenuItemProcess.DropDownItems.Count == 1) {
                ToolStripMenuItem menuItem = (ToolStripMenuItem) WindowerMenuItemProcess.DropDownItems[0];
                if (_windower == null || !menuItem.Checked)
                    WindowerMenuItemProcess_DropDownItemClicked(this, new ToolStripItemClickedEventArgs(menuItem));
            }

            if (_windower != null && WindowerMenuItemProcess.DropDownItems.Count == 0) {
                _windower = null;
                WindowerInstanceChanged.Invoke(this, new EventArgs());
            }

            ProcessWatchTimerTick.Invoke(this, new EventArgs());
        }
예제 #2
0
 private void InitProcessHandler() {
     _windower = null;
     qadd = new Queue<Process>();
     qdel = new Queue<Process>();
     ppw = new PolProcessWatcher();
     ppw.ProcessAdded += new EventHandler<PolProcessWatcherEventArgs>(ProcessAddedEventHandler);
     ppw.ProcessRemoved += new EventHandler<PolProcessWatcherEventArgs>(ProcessRemovedEventHandler);
     ppw.Start();
 }
예제 #3
0
        private void WindowerMenuItemProcess_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) {

            foreach (ToolStripMenuItem item in WindowerMenuItemProcess.DropDownItems)
                item.Checked = false;

            ToolStripMenuItem menuItem = (ToolStripMenuItem) e.ClickedItem;
            menuItem.Checked = true;

            PolProcess pol = (PolProcess) menuItem.Tag;

            if (pol == null || (_windower != null && _windower.Pid == pol.Pid))
                return;

            _windower = new XIWindower(pol.Pid);

            WindowerInstanceChanged.Invoke(this, new EventArgs());
        }