コード例 #1
0
        public SystemTray(IComputer computer)
        {
            this.computer             = computer;
            computer.HardwareAdded   += new HardwareEventHandler(HardwareAdded);
            computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);

            this.mainIcon = new NotifyIcon();

            ContextMenuStrip  contextMenuStrip = new ContextMenuStrip();
            ToolStripMenuItem hideShowItem     = new ToolStripMenuItem("Hide/Show");

            hideShowItem.Click += delegate(object obj, EventArgs args) {
                SendHideShowCommand();
            };
            contextMenuStrip.Items.Add(hideShowItem);
            contextMenuStrip.Items.Add(new ToolStripSeparator());
            ToolStripMenuItem exitItem = new ToolStripMenuItem("Exit");

            exitItem.Click += delegate(object obj, EventArgs args) {
                SendExitCommand();
            };
            contextMenuStrip.Items.Add(exitItem);
            this.mainIcon.ContextMenuStrip = contextMenuStrip;
            this.mainIcon.DoubleClick     += delegate(object obj, EventArgs args) {
                SendHideShowCommand();
            };
            this.mainIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico");
        }
コード例 #2
0
        public SystemTray(IComputer computer, PersistentSettings settings, UnitManager unitManager)
        {
            _computer                 = computer;
            _settings                 = settings;
            _unitManager              = unitManager;
            computer.HardwareAdded   += HardwareAdded;
            computer.HardwareRemoved += HardwareRemoved;

            _mainIcon = new NotifyIconAdv();

            ContextMenu contextMenu  = new ContextMenu();
            MenuItem    hideShowItem = new MenuItem("Hide/Show");

            hideShowItem.Click += delegate
            {
                SendHideShowCommand();
            };
            contextMenu.MenuItems.Add(hideShowItem);
            contextMenu.MenuItems.Add(new MenuItem("-"));
            MenuItem exitItem = new MenuItem("Exit");

            exitItem.Click += delegate
            {
                SendExitCommand();
            };
            contextMenu.MenuItems.Add(exitItem);
            _mainIcon.ContextMenu  = contextMenu;
            _mainIcon.DoubleClick += delegate
            {
                SendHideShowCommand();
            };
            _mainIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico");
            _mainIcon.Text = "Libre Hardware Monitor";
        }
コード例 #3
0
        public SystemTray(IComputer computer, PersistentSettings settings,
                          UnitManager unitManager)
        {
            this.computer             = computer;
            this.settings             = settings;
            this.unitManager          = unitManager;
            computer.HardwareAdded   += new HardwareEventHandler(HardwareAdded);
            computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);

            this.mainIcon = new NotifyIconAdv();

            ContextMenu contextMenu  = new ContextMenu();
            MenuItem    hideShowItem = new MenuItem("Hide/Show");

            hideShowItem.Click += delegate(object obj, EventArgs args) {
                SendHideShowCommand();
            };
            contextMenu.MenuItems.Add(hideShowItem);
            contextMenu.MenuItems.Add(new MenuItem("-"));
            MenuItem exitItem = new MenuItem("Exit");

            exitItem.Click += delegate(object obj, EventArgs args) {
                SendExitCommand();
            };
            contextMenu.MenuItems.Add(exitItem);
            this.mainIcon.ContextMenu  = contextMenu;
            this.mainIcon.DoubleClick += delegate(object obj, EventArgs args) {
                SendHideShowCommand();
            };
            this.mainIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico");
            this.mainIcon.Text = "HMonZ";
        }
コード例 #4
0
        public MainForm()
        {
            InitializeComponent();
            this.Font      = SystemFonts.MessageBoxFont;
            treeView.Font  = SystemFonts.MessageBoxFont;
            plotPanel.Font = SystemFonts.MessageBoxFont;

            nodeCheckBox.IsVisibleValueNeeded +=
                new EventHandler <NodeControlValueEventArgs>(
                    nodeCheckBox_IsVisibleValueNeeded);
            nodeCheckBox.CheckStateChanged +=
                new EventHandler <TreePathEventArgs>(UpdatePlotSelection);
            nodeTextBoxText.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText);
            nodeTextBoxValue.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText);
            nodeTextBoxMin.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText);
            nodeTextBoxMax.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText);
            nodeTextBoxLimit.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxLimit_DrawText);

            if (Utilities.Config.Contains("mainForm.Location.X"))
            {
                int x = Utilities.Config.Get("mainForm.Location.X", Location.X);
                x = x < 0 ? 0 : x;
                int y = Utilities.Config.Get("mainForm.Location.Y", Location.Y);
                y             = y < 0 ? 0 : y;
                this.Location = new Point(x, y);
            }
            else
            {
                StartPosition = FormStartPosition.CenterScreen;
            }

            Width  = Utilities.Config.Get("mainForm.Width", Width);
            Height = Utilities.Config.Get("mainForm.Height", Height);

            treeModel  = new TreeModel();
            root       = new Node(System.Environment.MachineName);
            root.Image = Utilities.EmbeddedResources.GetImage("computer.png");

            treeModel.Nodes.Add(root);
            treeView.Model = treeModel;

            notifyIcon = new NotifyIcon();
            notifyIcon.ContextMenuStrip = this.notifyContextMenuStrip;
            notifyIcon.Icon             = EmbeddedResources.GetIcon("smallicon.ico");
            notifyIcon.Text             = "Open Hardware Monitor";
            notifyIcon.DoubleClick     += new EventHandler(this.restoreClick);

            sensorSystemTray = new SensorSystemTray(computer);

            computer.HardwareAdded   += new HardwareEventHandler(HardwareAdded);
            computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
            computer.Open();

            plotColorPalette     = new Color[14];
            plotColorPalette[0]  = Color.Blue;
            plotColorPalette[1]  = Color.OrangeRed;
            plotColorPalette[2]  = Color.Green;
            plotColorPalette[3]  = Color.LightSeaGreen;
            plotColorPalette[4]  = Color.Goldenrod;
            plotColorPalette[5]  = Color.DarkViolet;
            plotColorPalette[6]  = Color.YellowGreen;
            plotColorPalette[7]  = Color.SaddleBrown;
            plotColorPalette[8]  = Color.Gray;
            plotColorPalette[9]  = Color.RoyalBlue;
            plotColorPalette[10] = Color.DeepPink;
            plotColorPalette[11] = Color.MediumSeaGreen;
            plotColorPalette[12] = Color.Olive;
            plotColorPalette[13] = Color.Firebrick;

            plotMenuItem.Checked  = Config.Get(plotMenuItem.Name, false);
            minMenuItem.Checked   = Config.Get(minMenuItem.Name, false);
            maxMenuItem.Checked   = Config.Get(maxMenuItem.Name, true);
            limitMenuItem.Checked = Config.Get(limitMenuItem.Name, false);

            minTrayMenuItem.Checked = Config.Get(minTrayMenuItem.Name, true);
            hddMenuItem.Checked     = Config.Get(hddMenuItem.Name, true);

            voltMenuItem.Checked   = Config.Get(voltMenuItem.Name, true);
            clocksMenuItem.Checked = Config.Get(clocksMenuItem.Name, true);
            loadMenuItem.Checked   = Config.Get(loadMenuItem.Name, true);
            tempMenuItem.Checked   = Config.Get(tempMenuItem.Name, true);
            fansMenuItem.Checked   = Config.Get(fansMenuItem.Name, true);

            timer.Enabled = true;
        }
コード例 #5
0
        public MainForm()
        {
            InitializeComponent();
            this.Font      = SystemFonts.MessageBoxFont;
            treeView.Font  = SystemFonts.MessageBoxFont;
            plotPanel.Font = SystemFonts.MessageBoxFont;

            nodeCheckBox.IsVisibleValueNeeded +=
                new EventHandler <NodeControlValueEventArgs>(
                    nodeCheckBox_IsVisibleValueNeeded);
            nodeCheckBox.CheckStateChanged +=
                new EventHandler <TreePathEventArgs>(UpdatePlotSelection);
            nodeTextBoxText.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText);
            nodeTextBoxValue.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText);
            nodeTextBoxMin.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText);
            nodeTextBoxMax.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText);
            nodeTextBoxLimit.DrawText +=
                new EventHandler <DrawEventArgs>(nodeTextBoxLimit_DrawText);

            if (Utilities.Config.Contains("mainForm.Location.X"))
            {
                int x = Utilities.Config.Get("mainForm.Location.X", Location.X);
                x = x < 0 ? 0 : x;
                int y = Utilities.Config.Get("mainForm.Location.Y", Location.Y);
                y             = y < 0 ? 0 : y;
                this.Location = new Point(x, y);
            }
            else
            {
                StartPosition = FormStartPosition.CenterScreen;
            }

            Width  = Utilities.Config.Get("mainForm.Width", Width);
            Height = Utilities.Config.Get("mainForm.Height", Height);

            foreach (TreeColumn column in treeView.Columns)
            {
                column.Width = Math.Max(20, Math.Min(400,
                                                     Config.Get("treeView.Columns." + column.Header + ".Width",
                                                                column.Width)));
            }

            treeModel  = new TreeModel();
            root       = new Node(System.Environment.MachineName);
            root.Image = Utilities.EmbeddedResources.GetImage("computer.png");

            treeModel.Nodes.Add(root);
            treeView.Model = treeModel;

            notifyIcon = new NotifyIcon();
            notifyIcon.ContextMenuStrip = this.notifyContextMenuStrip;
            notifyIcon.Icon             = EmbeddedResources.GetIcon("smallicon.ico");
            notifyIcon.Text             = "Open Hardware Monitor";
            notifyIcon.DoubleClick     += new EventHandler(this.hideShowClick);

            sensorSystemTray = new SensorSystemTray(computer);

            computer.HardwareAdded   += new HardwareEventHandler(HardwareAdded);
            computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
            computer.Open();

            timer.Enabled = true;

            plotColorPalette     = new Color[13];
            plotColorPalette[0]  = Color.Blue;
            plotColorPalette[1]  = Color.OrangeRed;
            plotColorPalette[2]  = Color.Green;
            plotColorPalette[3]  = Color.LightSeaGreen;
            plotColorPalette[4]  = Color.Goldenrod;
            plotColorPalette[5]  = Color.DarkViolet;
            plotColorPalette[6]  = Color.YellowGreen;
            plotColorPalette[7]  = Color.SaddleBrown;
            plotColorPalette[8]  = Color.RoyalBlue;
            plotColorPalette[9]  = Color.DeepPink;
            plotColorPalette[10] = Color.MediumSeaGreen;
            plotColorPalette[11] = Color.Olive;
            plotColorPalette[12] = Color.Firebrick;

            hiddenMenuItem.Checked = Config.Get(hiddenMenuItem.Name, false);
            plotMenuItem.Checked   = Config.Get(plotMenuItem.Name, false);

            valueMenuItem.Checked = Config.Get(valueMenuItem.Name, true);
            minMenuItem.Checked   = Config.Get(minMenuItem.Name, false);
            maxMenuItem.Checked   = Config.Get(maxMenuItem.Name, true);
            limitMenuItem.Checked = Config.Get(limitMenuItem.Name, false);

            startMinMenuItem.Checked = Config.Get(startMinMenuItem.Name, false);
            minTrayMenuItem.Checked  = Config.Get(minTrayMenuItem.Name, true);
            startupMenuItem.Checked  = startupManager.Startup;
            hddMenuItem.Checked      = Config.Get(hddMenuItem.Name, true);

            celciusToolStripMenuItem.Checked =
                UnitManager.TemperatureUnit == TemperatureUnit.Celcius;
            fahrenheitToolStripMenuItem.Checked = !celciusToolStripMenuItem.Checked;

            // Hide the system tray and auto startup menu items on Unix
            int p = (int)System.Environment.OSVersion.Platform;

            if ((p == 4) || (p == 128))
            {
                minTrayMenuItem.Visible = false;
                startupMenuItem.Visible = false;
            }

            if (startMinMenuItem.Checked)
            {
                if (!minTrayMenuItem.Checked)
                {
                    WindowState = FormWindowState.Minimized;
                    Show();
                }
            }
            else
            {
                Show();
            }

            // Create a handle, otherwise calling Close() does not fire FormClosed
            IntPtr handle = Handle;
        }