예제 #1
0
        private void LoadNotificationIcons()
        {
            using (Bitmap b = new Bitmap(16, 16))
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.FillRectangle(new SolidBrush(Color.Black), 0, 0, b.Width, b.Height);
                    blackIcon = Icon.FromHandle(b.GetHicon());
                }
            }

            dummyIcon = new UsageIcon();
            notifyIcons.Add(cpuHistoryIcon = new CpuHistoryIcon() { Parent = this });
            notifyIcons.Add(cpuUsageIcon = new CpuUsageIcon() { Parent = this });
            notifyIcons.Add(ioHistoryIcon = new IoHistoryIcon() { Parent = this });
            notifyIcons.Add(commitHistoryIcon = new CommitHistoryIcon() { Parent = this });
            notifyIcons.Add(physMemHistoryIcon = new PhysMemHistoryIcon() { Parent = this });

            foreach (var icon in notifyIcons)
                icon.Icon = (Icon)blackIcon.Clone();

            this.ExecuteOnIcons((icon) => icon.ContextMenu = menuIcon);
            this.ExecuteOnIcons((icon) => icon.MouseDoubleClick += notifyIcon_MouseDoubleClick);
            cpuHistoryMenuItem.Checked = Properties.Settings.Default.CpuHistoryIconVisible;
            cpuUsageMenuItem.Checked = Properties.Settings.Default.CpuUsageIconVisible;
            ioHistoryMenuItem.Checked = Properties.Settings.Default.IoHistoryIconVisible;
            commitHistoryMenuItem.Checked = Properties.Settings.Default.CommitHistoryIconVisible;
            physMemHistoryMenuItem.Checked = Properties.Settings.Default.PhysMemHistoryIconVisible;
            this.ApplyIconVisibilities();

            NPMenuItem.Checked = Properties.Settings.Default.NewProcesses;
            TPMenuItem.Checked = Properties.Settings.Default.TerminatedProcesses;
            NSMenuItem.Checked = Properties.Settings.Default.NewServices;
            startedSMenuItem.Checked = Properties.Settings.Default.StartedServices;
            stoppedSMenuItem.Checked = Properties.Settings.Default.StoppedServices;
            DSMenuItem.Checked = Properties.Settings.Default.DeletedServices;

            NPMenuItem.Click += new EventHandler(CheckedMenuItem_Click);
            TPMenuItem.Click += new EventHandler(CheckedMenuItem_Click);
            NSMenuItem.Click += new EventHandler(CheckedMenuItem_Click);
            startedSMenuItem.Click += new EventHandler(CheckedMenuItem_Click);
            stoppedSMenuItem.Click += new EventHandler(CheckedMenuItem_Click);
            DSMenuItem.Click += new EventHandler(CheckedMenuItem_Click);
        }
예제 #2
0
        private void LoadNotificationIcons()
        {
            using (Bitmap b = new Bitmap(16, 16))
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.FillRectangle(new SolidBrush(Color.Black), 0, 0, b.Width, b.Height);
                    blackIcon = Icon.FromHandle(b.GetHicon());
                }
            }

            dummyIcon = new UsageIcon();
            notifyIcons.Add(cpuHistoryIcon = new CpuHistoryIcon() { Parent = this });
            notifyIcons.Add(cpuUsageIcon = new CpuUsageIcon() { Parent = this });
            notifyIcons.Add(ioHistoryIcon = new IoHistoryIcon() { Parent = this });
            notifyIcons.Add(commitHistoryIcon = new CommitHistoryIcon() { Parent = this });
            notifyIcons.Add(physMemHistoryIcon = new PhysMemHistoryIcon() { Parent = this });

            foreach (var icon in notifyIcons)
                icon.Icon = (Icon)blackIcon.Clone();

            this.ExecuteOnIcons(icon => icon.ContextMenu = contextMenuStripTray);
            this.ExecuteOnIcons(icon => icon.MouseDoubleClick += notifyIcon_MouseDoubleClick);

            this.cpuHistoryMenuItem.Checked = Settings.Instance.CpuHistoryIconVisible;
            this.cpuUsageMenuItem.Checked = Settings.Instance.CpuUsageIconVisible;
            this.ioHistoryMenuItem.Checked = Settings.Instance.IoHistoryIconVisible;
            this.commitHistoryMenuItem.Checked = Settings.Instance.CommitHistoryIconVisible;
            this.physMemHistoryMenuItem.Checked = Settings.Instance.PhysMemHistoryIconVisible;
            this.ApplyIconVisibilities();

            this.newProcessesToolStripMenuItem.Checked = Settings.Instance.NewProcesses;
            this.terminatedProcessesToolStripMenuItem.Checked = Settings.Instance.TerminatedProcesses;
            this.newServicesToolStripMenuItem.Checked = Settings.Instance.NewServices;
            this.startedServicesToolStripMenuItem.Checked = Settings.Instance.StartedServices;
            this.stoppedServicesToolStripMenuItem.Checked = Settings.Instance.StoppedServices;
            this.deletedServicesToolStripMenuItem.Checked = Settings.Instance.DeletedServices;

            this.newProcessesToolStripMenuItem.Click += this.CheckedMenuItem_Click;
            this.terminatedProcessesToolStripMenuItem.Click += this.CheckedMenuItem_Click;
            this.newServicesToolStripMenuItem.Click += this.CheckedMenuItem_Click;
            this.startedServicesToolStripMenuItem.Click += this.CheckedMenuItem_Click;
            this.stoppedServicesToolStripMenuItem.Click += this.CheckedMenuItem_Click;
            this.deletedServicesToolStripMenuItem.Click += this.CheckedMenuItem_Click;
        }