Esempio n. 1
0
        private void SubHardwareAdded(IHardware hardware, Node node)
        {
            Node hardwareNode = new HardwareNode(hardware, settings, unitManager);

            node.Nodes.Add(hardwareNode);
            foreach (IHardware subHardware in hardware.SubHardware)
            {
                SubHardwareAdded(subHardware, hardwareNode);
            }
        }
Esempio n. 2
0
        private void HardwareAdded(IHardware hardware)
        {
            Node hardwareNode = new HardwareNode(hardware);

            root.Nodes.Add(hardwareNode);
            foreach (IHardware subHardware in hardware.SubHardware)
            {
                SubHardwareAdded(subHardware, hardwareNode);
            }
        }
Esempio n. 3
0
        private void InsertSorted(Collection <Node> nodes, HardwareNode node)
        {
            int i = 0;

            while (i < nodes.Count && nodes[i] is HardwareNode && ((HardwareNode)nodes[i]).Hardware.HardwareType < node.Hardware.HardwareType)
            {
                i++;
            }
            nodes.Insert(i, node);
        }
        private void SubHardwareAdded(IHardware hardware, Node node)
        {
            HardwareNode hardwareNode = new HardwareNode(hardware, settings, unitManager);

            hardwareNode.PlotSelectionChanged += PlotSelectionChanged;

            InsertSorted(node.Nodes, hardwareNode);

            foreach (IHardware subHardware in hardware.SubHardware)
            {
                SubHardwareAdded(subHardware, hardwareNode);
            }
        }
Esempio n. 5
0
        private void HardwareRemoved(IHardware hardware)
        {
            List <Node> nodesToRemove = new List <Node>();

            foreach (Node node in root.Nodes)
            {
                HardwareNode hardwareNode = node as HardwareNode;
                if (hardwareNode != null && hardwareNode.Hardware == hardware)
                {
                    nodesToRemove.Add(node);
                }
            }
            foreach (Node node in nodesToRemove)
            {
                root.Nodes.Remove(node);
            }
        }
Esempio n. 6
0
        private void HardwareRemoved(IHardware hardware)
        {
            List <HardwareNode> nodesToRemove = new List <HardwareNode>();

            foreach (Node node in root.Nodes)
            {
                HardwareNode hardwareNode = node as HardwareNode;
                if (hardwareNode != null && hardwareNode.Hardware == hardware)
                {
                    nodesToRemove.Add(hardwareNode);
                }
            }
            foreach (HardwareNode hardwareNode in nodesToRemove)
            {
                root.Nodes.Remove(hardwareNode);
                hardwareNode.PlotSelectionChanged -= PlotSelectionChanged;
            }
            PlotSelectionChanged(this, null);
        }
Esempio n. 7
0
        private void UpdateSensorTypeVisible(Node node)
        {
            HardwareNode hardwareNode = node as HardwareNode;

            if (hardwareNode == null)
            {
                return;
            }

            hardwareNode.SetVisible(SensorType.Voltage, voltMenuItem.Checked);
            hardwareNode.SetVisible(SensorType.Clock, clocksMenuItem.Checked);
            hardwareNode.SetVisible(SensorType.Load, loadMenuItem.Checked);
            hardwareNode.SetVisible(SensorType.Temperature, tempMenuItem.Checked);
            hardwareNode.SetVisible(SensorType.Fan, fansMenuItem.Checked);
            hardwareNode.SetVisible(SensorType.Flow, flowsMenuItem.Checked);

            foreach (Node n in node.Nodes)
            {
                UpdateSensorTypeVisible(n);
            }
        }
Esempio n. 8
0
        private void treeView_Click(object sender, EventArgs e)
        {
            MouseEventArgs m = e as MouseEventArgs;

            if (m == null || m.Button != MouseButtons.Right)
            {
                return;
            }

            NodeControlInfo info = treeView.GetNodeControlInfoAt(
                new Point(m.X, m.Y)
                );

            treeView.SelectedNode = info.Node;
            if (info.Node != null)
            {
                SensorNode node = info.Node.Tag as SensorNode;
                if (node != null && node.Sensor != null)
                {
                    treeContextMenu.MenuItems.Clear();
                    if (node.Sensor.Parameters.Count > 0)
                    {
                        MenuItem item = new MenuItem("Parameters...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ShowParameterForm(node.Sensor);
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.IsVisible)
                    {
                        MenuItem item = new MenuItem("Hide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = false;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    else
                    {
                        MenuItem item = new MenuItem("Unhide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = true;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("Pen Color...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ColorDialog dialog = new ColorDialog();
                            dialog.Color = node.PenColor.GetValueOrDefault();
                            if (dialog.ShowDialog() == DialogResult.OK)
                            {
                                node.PenColor = dialog.Color;
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    {
                        MenuItem item = new MenuItem("Reset Pen Color");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.PenColor = null;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("Show in Tray");
                        item.Checked = systemTray.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args) {
                            if (item.Checked)
                            {
                                systemTray.Remove(node.Sensor);
                            }
                            else
                            {
                                systemTray.Add(node.Sensor, true);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (gadget != null)
                    {
                        MenuItem item = new MenuItem("Show in Gadget");
                        item.Checked = gadget.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args) {
                            if (item.Checked)
                            {
                                gadget.Remove(node.Sensor);
                            }
                            else
                            {
                                gadget.Add(node.Sensor);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.Sensor.Control != null)
                    {
                        treeContextMenu.MenuItems.Add(new MenuItem("-"));
                        IControl control     = node.Sensor.Control;
                        MenuItem controlItem = new MenuItem("Control");
                        MenuItem defaultItem = new MenuItem("Default");
                        defaultItem.Checked = control.ControlMode == ControlMode.Default;
                        controlItem.MenuItems.Add(defaultItem);
                        defaultItem.Click += delegate(object obj, EventArgs args) {
                            control.SetDefault();
                        };
                        MenuItem manualItem = new MenuItem("Manual");
                        controlItem.MenuItems.Add(manualItem);
                        manualItem.Checked = control.ControlMode == ControlMode.Software;
                        for (int i = 0; i <= 100; i += 5)
                        {
                            if (i <= control.MaxSoftwareValue &&
                                i >= control.MinSoftwareValue)
                            {
                                MenuItem item = new MenuItem(i + " %");
                                item.RadioCheck = true;
                                manualItem.MenuItems.Add(item);
                                item.Checked = control.ControlMode == ControlMode.Software &&
                                               Math.Round(control.SoftwareValue) == i;
                                int softwareValue = i;
                                item.Click += delegate(object obj, EventArgs args) {
                                    control.SetSoftware(softwareValue);
                                };
                            }
                        }
                        treeContextMenu.MenuItems.Add(controlItem);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }

                HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
                if (hardwareNode != null && hardwareNode.Hardware != null)
                {
                    treeContextMenu.MenuItems.Clear();

                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }
            }
        }
        private void SubHardwareAdded(IHardware hardware, Node node)
        {
            HardwareNode hardwareNode =
            new HardwareNode(hardware, settings, unitManager);
              hardwareNode.PlotSelectionChanged += PlotSelectionChanged;

              InsertSorted(node.Nodes, hardwareNode);

              foreach (IHardware subHardware in hardware.SubHardware)
            SubHardwareAdded(subHardware, hardwareNode);
        }
Esempio n. 10
0
 private void InsertSorted(Collection<Node> nodes, HardwareNode node)
 {
     int i = 0;
       while (i < nodes.Count && nodes[i] is HardwareNode &&
     ((HardwareNode)nodes[i]).Hardware.HardwareType <
       node.Hardware.HardwareType)
     i++;
       nodes.Insert(i, node);
 }
Esempio n. 11
0
        private void treeView_Click(object sender, EventArgs e)
        {
            // timer = System.Timers.Timer(DoubleClickTime);
            int clicks = 0;

            int            totalHarddriveCount = 0;
            MouseEventArgs m = e as MouseEventArgs;

            if (m == null || m.Button != MouseButtons.Right) // this means left-mouseclick
            {
                clicks++;



                System.Windows.Forms.MessageBox.Show("Left mouse clicked");
            }

            else
            {
                NodeControlInfo info = treeView.GetNodeControlInfoAt(
                    new Point(m.X, m.Y)
                    );
                treeView.SelectedNode = info.Node;
                if (info.Node != null)
                {
                    SensorNode node = info.Node.Tag as SensorNode;
                    if (node != null && node.Sensor != null)
                    {
                        treeContextMenu.MenuItems.Clear();
                        if (node.Sensor.Parameters.Length > 0)
                        {
                            MenuItem item = new MenuItem("Parameters...");
                            item.Click += delegate(object obj, EventArgs args)
                            {
                                ShowParameterForm(node.Sensor);
                            };
                            treeContextMenu.MenuItems.Add(item);
                        }
                        if (nodeTextBoxText.EditEnabled)
                        {
                            MenuItem item = new MenuItem("Rename");
                            item.Click += delegate(object obj, EventArgs args)
                            {
                                nodeTextBoxText.BeginEdit();
                            };
                            treeContextMenu.MenuItems.Add(item);
                        }
                        if (node.IsVisible)
                        {
                            MenuItem item = new MenuItem("Hide");
                            item.Click += delegate(object obj, EventArgs args)
                            {
                                node.IsVisible = false;
                            };
                            treeContextMenu.MenuItems.Add(item);
                        }
                        else
                        {
                            MenuItem item = new MenuItem("Unhide");
                            item.Click += delegate(object obj, EventArgs args)
                            {
                                node.IsVisible = true;
                            };
                            treeContextMenu.MenuItems.Add(item);
                        }
                        treeContextMenu.MenuItems.Add(new MenuItem("-"));
                        {
                            MenuItem item = new MenuItem("Show in Tray");
                            item.Checked = systemTray.Contains(node.Sensor);
                            item.Click  += delegate(object obj, EventArgs args)
                            {
                                if (item.Checked)
                                {
                                    systemTray.Remove(node.Sensor);
                                }
                                else
                                {
                                    systemTray.Add(node.Sensor, true);
                                }
                            };
                            treeContextMenu.MenuItems.Add(item);
                        }
                        if (gadget != null)
                        {
                            MenuItem item = new MenuItem("Show in Gadget");
                            item.Checked = gadget.Contains(node.Sensor);
                            item.Click  += delegate(object obj, EventArgs args)
                            {
                                if (item.Checked)
                                {
                                    gadget.Remove(node.Sensor);
                                }
                                else
                                {
                                    gadget.Add(node.Sensor);
                                }
                            };
                            treeContextMenu.MenuItems.Add(item);
                        }
                        if (node.Sensor.Control != null)
                        {
                            treeContextMenu.MenuItems.Add(new MenuItem("-"));
                            IControl control     = node.Sensor.Control;
                            MenuItem controlItem = new MenuItem("Control");
                            MenuItem defaultItem = new MenuItem("Default");
                            defaultItem.Checked = control.ControlMode == ControlMode.Default;
                            controlItem.MenuItems.Add(defaultItem);
                            defaultItem.Click += delegate(object obj, EventArgs args)
                            {
                                control.SetDefault();
                            };
                            MenuItem manualItem = new MenuItem("Manual");
                            controlItem.MenuItems.Add(manualItem);
                            manualItem.Checked = control.ControlMode == ControlMode.Software;
                            for (int i = 0; i <= 100; i += 5)
                            {
                                if (i <= control.MaxSoftwareValue &&
                                    i >= control.MinSoftwareValue)
                                {
                                    MenuItem item = new MenuItem(i + " %");
                                    item.RadioCheck = true;
                                    manualItem.MenuItems.Add(item);
                                    item.Checked = control.ControlMode == ControlMode.Software &&
                                                   Math.Round(control.SoftwareValue) == i;
                                    int softwareValue = i;
                                    item.Click += delegate(object obj, EventArgs args)
                                    {
                                        control.SetSoftware(softwareValue);
                                    };
                                }
                            }
                            treeContextMenu.MenuItems.Add(controlItem);
                        }

                        treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                    }

                    HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
                    if (hardwareNode != null && hardwareNode.Hardware != null)
                    {
                        treeContextMenu.MenuItems.Clear();

                        if (nodeTextBoxText.EditEnabled)
                        {
                            MenuItem item = new MenuItem("Rename");
                            item.Click += delegate(object obj, EventArgs args)
                            {
                                nodeTextBoxText.BeginEdit();
                            };
                            treeContextMenu.MenuItems.Add(item);
                        }

                        if (hardwareNode.Hardware.HardwareType.ToString() == hardwareNode.HDDType()) // For the HDD's in the system
                        {
                            MenuItem item = new MenuItem("Properties");
                            item.Click += delegate(object obj, EventArgs args)
                            {
                                // Harddrive with Identifier /hdd/7 is at the top of the list and harddrive with identifier /hdd/0 is at the bottom of the list!!!


                                string[]            hddInfo       = { };
                                List <HardwareNode> hardWareNodes = new List <HardwareNode>();
                                foreach (Node n in root.Nodes)
                                {
                                    HardwareNode HN = n as HardwareNode;

                                    if (HN.Hardware.HardwareType.ToString() == hardwareNode.HDDType())
                                    {
                                        totalHarddriveCount++;
                                    }
                                }

                                HDDDialog = new HDDForm();
                                int    driveIndex       = Convert.ToInt32(hardwareNode.Hardware.Identifier.ToString().Replace("/hdd/", ""));
                                string harddriveAddress = @"\\.\PhysicalDrive" + driveIndex;
                                //  IntPtr deviceHandle = smart.OpenDrive(driveIndex);


                                HDDDialog.SelectRequestedHardDisk(hardwareNode.Hardware.Name);
                                HDDDialog.Show();
                            };
                            treeContextMenu.MenuItems.Add(item);
                        }
                        ;

                        if (hardwareNode.Hardware.HardwareType.ToString() == hardwareNode.RAMType()) // For the RAM memory
                        {
                            MenuItem item = new MenuItem("Properties");
                            item.Click += delegate(object obj, EventArgs args)
                            {
                                RAMDialog = new RAMForm();
                                RAMDialog.Show();
                            };
                            treeContextMenu.MenuItems.Add(item);
                        }

                        treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                    }
                }


                return;
            }
        }
Esempio n. 12
0
        private void treeView_Click(object sender, EventArgs e)
        {
            MouseEventArgs m = e as MouseEventArgs;

            if (m == null || m.Button != MouseButtons.Right)
            {
                return;
            }

            NodeControlInfo info = treeView.GetNodeControlInfoAt(
                new Point(m.X, m.Y)
                );

            treeView.SelectedNode = info.Node;
            if (info.Node != null)
            {
                SensorNode node = info.Node.Tag as SensorNode;
                if (node != null && node.Sensor != null)
                {
                    treeContextMenu.MenuItems.Clear();
                    if (node.Sensor.Parameters.Length > 0)
                    {
                        MenuItem item = new MenuItem("Parameters...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ShowParameterForm(node.Sensor);
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.IsVisible)
                    {
                        MenuItem item = new MenuItem("Hide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = false;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    else
                    {
                        MenuItem item = new MenuItem("Unhide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = true;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("Pen Color...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ColorDialog dialog = new ColorDialog();
                            dialog.Color = node.PenColor.GetValueOrDefault();
                            if (dialog.ShowDialog() == DialogResult.OK)
                            {
                                node.PenColor = dialog.Color;
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    {
                        MenuItem item = new MenuItem("Reset Pen Color");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.PenColor = null;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("Show in Tray");
                        item.Checked = systemTray.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args) {
                            if (item.Checked)
                            {
                                systemTray.Remove(node.Sensor);
                            }
                            else
                            {
                                systemTray.Add(node.Sensor, true);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (gadget != null)
                    {
                        MenuItem item = new MenuItem("Show in Gadget");
                        item.Checked = gadget.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args) {
                            if (item.Checked)
                            {
                                gadget.Remove(node.Sensor);
                            }
                            else
                            {
                                gadget.Add(node.Sensor);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.Sensor.Control != null)
                    {
                        treeContextMenu.MenuItems.Add(new MenuItem("-"));
                        IControl control     = node.Sensor.Control;
                        MenuItem controlItem = new MenuItem("Control");
                        MenuItem defaultItem = new MenuItem("Default");
                        defaultItem.Checked = control.ActualControlMode == ControlMode.Default;
                        controlItem.MenuItems.Add(defaultItem);
                        defaultItem.Click += delegate(object obj, EventArgs args) {
                            control.SetDefault();
                        };
                        MenuItem manualItem = new MenuItem("Manual");
                        controlItem.MenuItems.Add(manualItem);
                        manualItem.Checked = control.ActualControlMode == ControlMode.Software;
                        for (int i = 0; i <= 100; i += 5)
                        {
                            if (i <= control.MaxSoftwareValue &&
                                i >= control.MinSoftwareValue)
                            {
                                MenuItem item = new MenuItem(i + " %");
                                item.RadioCheck = true;
                                manualItem.MenuItems.Add(item);
                                item.Checked = control.ActualControlMode == ControlMode.Software &&
                                               Math.Round(control.SoftwareValue) == i;
                                int softwareValue = i;
                                item.Click += delegate(object obj, EventArgs args) {
                                    control.SetSoftware(softwareValue);
                                };
                            }
                        }
                        MenuItem curveItem = new MenuItem("Manual Curve");
                        controlItem.MenuItems.Add(curveItem);
                        curveItem.Checked = control.ActualControlMode == ControlMode.SoftwareCurve;
                        MenuItem newCurveItem = new MenuItem("New");
                        newCurveItem.Click += delegate(object obj, EventArgs args) {
                            var confirmSensorselect = MessageBox.Show("Select the other sensor after clicking OK.", "New Manual Curve", MessageBoxButtons.OKCancel);
                            if (confirmSensorselect == DialogResult.OK)
                            {
                                // Listen for user click on sensor
                                EventHandler selectorListener = null;
                                selectorListener = (curveselect_sender, curveselect_e) => {
                                    MouseEventArgs curveselect_m = curveselect_e as MouseEventArgs;
                                    if (curveselect_m == null || curveselect_m.Button != MouseButtons.Left)
                                    {
                                        this.treeView.Click -= selectorListener;
                                        return;
                                    }
                                    // Try find sensor user clicked
                                    NodeControlInfo curveselect_info = treeView.GetNodeControlInfoAt(new Point(curveselect_m.X, curveselect_m.Y));
                                    if (curveselect_info.Node != null)
                                    {
                                        SensorNode curveselect_node = curveselect_info.Node.Tag as SensorNode;
                                        if (curveselect_node != null && curveselect_node.Sensor != null)
                                        {
                                            new SensorControlForm(node.Sensor, curveselect_node.Sensor, null).ShowDialog();
                                            return;
                                        }
                                    }

                                    var tryagainSensorselect = MessageBox.Show("Could not find sensor. Try again?", "Manual Curve", MessageBoxButtons.RetryCancel);
                                    if (tryagainSensorselect != DialogResult.Retry)
                                    {
                                        this.treeView.Click -= selectorListener;
                                    }
                                };
                                this.treeView.Click += selectorListener;
                            }
                        };
                        curveItem.MenuItems.Add(newCurveItem);
                        var softwareCurve = node.Sensor.Control.GetSoftwareCurve();
                        if (softwareCurve != null)
                        {
                            // edit curve
                            MenuItem editCurveItem = new MenuItem("Edit");
                            curveItem.MenuItems.Add(editCurveItem);
                            editCurveItem.Click += delegate(object obj, EventArgs args) {
                                new SensorControlForm(node.Sensor, softwareCurve.Sensor, softwareCurve.Points).ShowDialog();
                            };

                            if (control.ActualControlMode != ControlMode.SoftwareCurve)
                            {
                                // enable curve
                                MenuItem enableCurveItem = new MenuItem("Enable");
                                curveItem.MenuItems.Add(enableCurveItem);
                                enableCurveItem.Click += delegate(object obj, EventArgs args) {
                                    node.Sensor.Control.SetSoftwareCurve(softwareCurve.Points, softwareCurve.Sensor);
                                };
                            }
                        }
                        treeContextMenu.MenuItems.Add(controlItem);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }

                HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
                if (hardwareNode != null && hardwareNode.Hardware != null)
                {
                    treeContextMenu.MenuItems.Clear();

                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }
            }
        }
Esempio n. 13
0
    private static string GetHardwareImageFile(HardwareNode hn) {

      switch (hn.Hardware.HardwareType) {
        case HardwareType.CPU:
          return "cpu.png";
        case HardwareType.GpuNvidia:
          return "nvidia.png";
        case HardwareType.GpuAti:
          return "ati.png";
        case HardwareType.HDD:
          return "hdd.png";
        case HardwareType.Heatmaster:
          return "bigng.png";
        case HardwareType.Mainboard:
          return "mainboard.png";
        case HardwareType.SuperIO:
          return "chip.png";
        case HardwareType.TBalancer:
          return "bigng.png";
        case HardwareType.RAM:
          return "ram.png";
        default:
          return "cpu.png";
      }

    }
Esempio n. 14
0
        private void treeView_Click(object sender, EventArgs e)
        {
            MouseEventArgs m = e as MouseEventArgs;

            if (m == null || m.Button != MouseButtons.Right)
            {
                return;
            }

            NodeControlInfo info = treeView.GetNodeControlInfoAt(
                new Point(m.X, m.Y)
                );

            treeView.SelectedNode = info.Node;
            if (info.Node != null)
            {
                SensorNode node = info.Node.Tag as SensorNode;
                if (node != null && node.Sensor != null)
                {
                    treeContextMenu.MenuItems.Clear();
                    if (node.Sensor.Parameters.Length > 0)
                    {
                        MenuItem item = new MenuItem("Parameters...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ShowParameterForm(node.Sensor);
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.IsVisible)
                    {
                        MenuItem item = new MenuItem("Hide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = false;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    else
                    {
                        MenuItem item = new MenuItem("Unhide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = true;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("Show in Tray");
                        item.Checked = systemTray.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args) {
                            if (item.Checked)
                            {
                                systemTray.Remove(node.Sensor);
                            }
                            else
                            {
                                systemTray.Add(node.Sensor, true);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (gadget != null)
                    {
                        MenuItem item = new MenuItem("Show in Gadget");
                        item.Checked = gadget.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args) {
                            if (item.Checked)
                            {
                                gadget.Remove(node.Sensor);
                            }
                            else
                            {
                                gadget.Add(node.Sensor);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.Sensor.Control != null)
                    {
                        treeContextMenu.MenuItems.Add(new MenuItem("-"));
                        IControl control     = node.Sensor.Control;
                        MenuItem controlItem = new MenuItem("控制");
                        MenuItem defaultItem = new MenuItem("默认");
                        defaultItem.Checked = control.ControlMode == ControlMode.Default;
                        controlItem.MenuItems.Add(defaultItem);
                        defaultItem.Click += delegate(object obj, EventArgs args) {
                            control.SetDefault();
                        };
                        MenuItem manualItem = new MenuItem("手动");
                        controlItem.MenuItems.Add(manualItem);
                        manualItem.Checked = control.ControlMode == ControlMode.Software;
                        for (int i = 0; i <= 100; i += 5)
                        {
                            if (i <= control.MaxSoftwareValue &&
                                i >= control.MinSoftwareValue)
                            {
                                MenuItem item = new MenuItem(i + " %");
                                manualItem.MenuItems.Add(item);
                                item.Checked = control.ControlMode == ControlMode.Software &&
                                               Math.Round(control.SoftwareValue) == i;
                                int softwareValue = i;
                                item.Click += delegate(object obj, EventArgs args) {
                                    control.SetSoftware(softwareValue);
                                };
                            }
                        }
                        treeContextMenu.MenuItems.Add(controlItem);
                        //fan add
                        if (node.Sensor.SensorType.Equals(SensorType.TinyFanControl))
                        {
                            MenuItem controlModeItem = new MenuItem("风扇类型");
                            treeContextMenu.MenuItems.Add(controlModeItem);
                            MenuItem Pin3 = new MenuItem("3针");
                            Pin3.Checked = control.FanMode == FanMode.Pin3;
                            Pin3.Click  += delegate(object obj, EventArgs args){
                                control.SetTheFanMode(FanMode.Pin3);
                            };
                            MenuItem Pin4 = new MenuItem("4针 (PWM)");
                            Pin4.Checked = control.FanMode == FanMode.Pin4;
                            Pin4.Click  += delegate(object obj, EventArgs args){
                                control.SetTheFanMode(FanMode.Pin4);
                            };
                            controlModeItem.MenuItems.Add(Pin3);
                            controlModeItem.MenuItems.Add(Pin4);
                            //add fan-follow. should all fan support this feature. TODO
                            MenuItem controlFanFollow = new MenuItem("自动跟随");
                            treeContextMenu.MenuItems.Add(controlFanFollow);
                            MenuItem followGPU = new MenuItem("显卡");
                            followGPU.Checked = control.FanFollow == FanFollow.GPU;
                            followGPU.Click  += delegate(object obj, EventArgs args)
                            {
                                control.SetTheFanFollow(FanFollow.GPU);
                            };
                            MenuItem followCPU = new MenuItem("CPU");
                            followCPU.Checked = control.FanFollow == FanFollow.CPU;
                            followCPU.Click  += delegate(object obj, EventArgs args)
                            {
                                control.SetTheFanFollow(FanFollow.CPU);
                            };
                            MenuItem followNONE = new MenuItem("关闭");
                            followNONE.Checked = control.FanFollow == FanFollow.NONE;
                            followNONE.Click  += delegate(object obj, EventArgs args)
                            {
                                control.SetTheFanFollow(FanFollow.NONE);
                            };
                            controlFanFollow.MenuItems.Add(followNONE);
                            controlFanFollow.MenuItems.Add(followGPU);
                            controlFanFollow.MenuItems.Add(followCPU);
                        }
                        //fan extend
                    }
                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }

                HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
                if (hardwareNode != null && hardwareNode.Hardware != null)
                {
                    treeContextMenu.MenuItems.Clear();

                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }
            }
        }
Esempio n. 15
0
        private void treeView_Click(object sender, EventArgs e)
        {
            MouseEventArgs m = e as MouseEventArgs;

            if (m == null || m.Button != MouseButtons.Right)
            {
                return;
            }

            NodeControlInfo info = treeView.GetNodeControlInfoAt(new Point(m.X, m.Y));

            treeView.SelectedNode = info.Node;
            if (info.Node != null)
            {
                SensorNode node = info.Node.Tag as SensorNode;
                if (node != null && node.Sensor != null)
                {
                    treeContextMenu.MenuItems.Clear();
                    if (node.Sensor.Parameters.Length > 0)
                    {
                        MenuItem item = new MenuItem("参数...");
                        item.Click += delegate(object obj, EventArgs args)
                        {
                            ShowParameterForm(node.Sensor);
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("重命名");
                        item.Click += delegate(object obj, EventArgs args)
                        {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.IsVisible)
                    {
                        MenuItem item = new MenuItem("隐藏");
                        item.Click += delegate(object obj, EventArgs args)
                        {
                            node.IsVisible = false;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    else
                    {
                        MenuItem item = new MenuItem("取消隐藏");
                        item.Click += delegate(object obj, EventArgs args)
                        {
                            node.IsVisible = true;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("在托盘中显示");
                        item.Checked = systemTray.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args)
                        {
                            if (item.Checked)
                            {
                                systemTray.Remove(node.Sensor);
                            }
                            else
                            {
                                systemTray.Add(node.Sensor, true);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (gadget != null)
                    {
                        MenuItem item = new MenuItem("显示小工具");
                        item.Checked = gadget.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args)
                        {
                            if (item.Checked)
                            {
                                gadget.Remove(node.Sensor);
                            }
                            else
                            {
                                gadget.Add(node.Sensor);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.Sensor.Control != null)
                    {
                        treeContextMenu.MenuItems.Add(new MenuItem("-"));
                        IControl control     = node.Sensor.Control;
                        MenuItem controlItem = new MenuItem("控制");
                        MenuItem defaultItem = new MenuItem("默认");
                        defaultItem.Checked = control.ControlMode == ControlMode.Default;
                        controlItem.MenuItems.Add(defaultItem);
                        defaultItem.Click += delegate(object obj, EventArgs args)
                        {
                            control.SetDefault();
                        };
                        MenuItem manualItem = new MenuItem("手动");
                        controlItem.MenuItems.Add(manualItem);
                        manualItem.Checked = control.ControlMode == ControlMode.Software;
                        for (int i = 0; i <= 100; i += 5)
                        {
                            if (i <= control.MaxSoftwareValue &&
                                i >= control.MinSoftwareValue)
                            {
                                MenuItem item = new MenuItem(i + " %");
                                item.RadioCheck = true;
                                manualItem.MenuItems.Add(item);
                                item.Checked = control.ControlMode == ControlMode.Software && Math.Round(control.SoftwareValue) == i;
                                int softwareValue = i;
                                item.Click += delegate(object obj, EventArgs args)
                                {
                                    control.SetSoftware(softwareValue);
                                };
                            }
                        }
                        treeContextMenu.MenuItems.Add(controlItem);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }

                HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
                if (hardwareNode != null && hardwareNode.Hardware != null)
                {
                    treeContextMenu.MenuItems.Clear();

                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("重命名");
                        item.Click += delegate(object obj, EventArgs args)
                        {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }
            }
        }