示例#1
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));

            if (info.Control == null)
            {
                columnsContextMenuStrip.Show(treeView, m.X, m.Y);
            }
        }
示例#2
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));

            if (info.Control == null)
            {
                columnsContextMenuStrip.Show(treeView, m.X, m.Y);
            }
            else
            {
                SensorNode node = info.Node.Tag as SensorNode;
                if (node != null && node.Sensor != null)
                {
                    sensorContextMenuStrip.Items.Clear();
                    if (sensorSystemTray.Contains(node.Sensor))
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Remove From Tray");
                        item.Click += delegate(object obj, EventArgs args) {
                            sensorSystemTray.Remove(node.Sensor);
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    else
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Add To Tray");
                        item.Click += delegate(object obj, EventArgs args) {
                            sensorSystemTray.Add(node.Sensor);
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    sensorContextMenuStrip.Show(treeView, m.X, m.Y);
                }
            }
        }
示例#3
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));
                }
            }
        }
示例#4
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));

            if (info.Control != null)
            {
                SensorNode node = info.Node.Tag as SensorNode;
                if (node != null && node.Sensor != null)
                {
                    sensorContextMenuStrip.Items.Clear();
                    if (node.Sensor.Parameters.Length > 0)
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Parameters...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ShowParameterForm(node.Sensor);
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    EditableControl control = info.Control as EditableControl;
                    if (control != null)
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            control.BeginEdit();
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    if (node.IsVisible)
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Hide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = false;
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    else
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Unhide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = true;
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    if (systemTray.Contains(node.Sensor))
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Remove From Tray");
                        item.Click += delegate(object obj, EventArgs args) {
                            systemTray.Remove(node.Sensor);
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    else
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Add To Tray");
                        item.Click += delegate(object obj, EventArgs args) {
                            systemTray.Add(node.Sensor, true);
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    sensorContextMenuStrip.Show(treeView, m.X, m.Y);
                }
            }
        }
        private void TreeView_Click(object sender, EventArgs e)
        {
            if (!(e is MouseEventArgs m) || (m.Button != MouseButtons.Left && m.Button != MouseButtons.Right))
            {
                return;
            }

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

            if (m.Button == MouseButtons.Left && info.Node != null)
            {
                if (info.Node.Tag is IExpandPersistNode expandPersistNode)
                {
                    expandPersistNode.Expanded = info.Node.IsExpanded;
                }

                return;
            }

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

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

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

                    if (nodeTextBoxText.EditEnabled)
                    {
                        ToolStripItem item = new ToolStripMenuItem("Rename");
                        item.Click += delegate
                        {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.Items.Add(item);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }
            }
        }
示例#6
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;
            }
        }
示例#7
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));
                }
            }
        }
        private void StoreSelectedPolicies()
        {
            //tvaPolicies.AllNodes.ToList().ForEach(
            //    (x) =>
            foreach (var x in tvaPolicies.AllNodes)
            {
                var nodeControl = tvaPolicies.GetNodeControls(x);
                var checkbox    = nodeControl.FirstOrDefault(y => (y.Control is NodeCheckBox));

                //checkbox found
                var dCheckBox = (NodeCheckBox)checkbox.Control;
                if (dCheckBox != null)
                {
                    object value = dCheckBox.GetValue(x);

                    if ((bool)value)
                    {
                        NodeControlInfo policyClass =
                            nodeControl.FirstOrDefault(
                                y =>
                                (y.Control is NodeTextBox && y.Control.ParentColumn.Header == @"Policy Class"));
                        object policyClassValue = ((NodeTextBox)policyClass.Control).GetValue(x);

                        NodeControlInfo currentInsurer =
                            nodeControl.FirstOrDefault(
                                y =>
                                (y.Control is NodeTextBox && y.Control.ParentColumn.Header == @"Insurer/s"));
                        object currentInsurerValue = ((NodeTextBox)currentInsurer.Control).GetValue(x);


                        NodeControlInfo currentId =
                            nodeControl.FirstOrDefault(
                                y => (y.Control is NodeTextBox && y.Control.ParentColumn.Header == @"InsurerId"));
                        object currentIdValue = ((NodeTextBox)currentId.Control).GetValue(x);

                        NodeControlInfo order =
                            nodeControl.FirstOrDefault(
                                y => (y.Control is NodeTextBox && y.Control.ParentColumn.Header == @"Order"));
                        object orderValue = ((NodeTextBox)order.Control).GetValue(x);


                        NodeControlInfo policyNumber =
                            nodeControl.FirstOrDefault(
                                y => (y.Control is NodeTextBox && y.Control.ParentColumn.Header == @"Policy Number"));
                        object policyNumberValue = ((NodeTextBox)policyNumber.Control).GetValue(x);

                        //var item = MinorItems.Find(i => i.Title == policyClassValue.ToString());
                        var item = MinorItems.Find(i => i.Title == policyClassValue.ToString() && i.MajorClass == x.Parent.Tag.ToString());

                        if (item != null)
                        {
                            if (currentInsurerValue != null)
                            {
                                item.CurrentInsurer = currentInsurerValue.ToString();
                            }
                        }

                        var outOrder = 0;
                        int.TryParse(orderValue.ToString(), out outOrder);
                        //if (!String.IsNullOrEmpty(orderValue.ToString()) && int.TryParse(orderValue.ToString(), out outOrder))
                        //{

                        //}

                        if (item != null)
                        {
                            item.Order = outOrder;

                            if (policyNumberValue != null)
                            {
                                item.PolicyNumber = policyNumberValue.ToString();
                            }

                            if (currentIdValue != null)
                            {
                                item.CurrentInsurerId = currentIdValue.ToString();
                            }


                            //todo update listname to settings
                            if (policyClassValue != null)
                            {
                                var ps = LoadClaimsProcedure(Settings.Default.SharePointContextUrl, "Insurance Manual Claims Procedures", policyClassValue.ToString());
                                if (ps != null && ps.Url != null)
                                {
                                    item.FragmentPolicyUrl = ps.Url;
                                }
                            }
                            _selectedPolicyClasses.Add(item);
                        }
                    }
                }
            }

            if (_selectedPolicyClasses != null)
            {
                _selectedPolicyClasses.Sort((x, y) => x.Order.CompareTo(y.Order));
            }
        }
示例#9
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));
                }
            }
        }
示例#10
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));
                }
            }
        }
示例#11
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)
                {
                    sensorContextMenu.MenuItems.Clear();
                    if (node.Sensor.Parameters.Length > 0)
                    {
                        MenuItem item = new MenuItem("Parameters...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ShowParameterForm(node.Sensor);
                        };
                        sensorContextMenu.MenuItems.Add(item);
                    }
                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            nodeTextBoxText.BeginEdit();
                        };
                        sensorContextMenu.MenuItems.Add(item);
                    }
                    if (node.IsVisible)
                    {
                        MenuItem item = new MenuItem("Hide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = false;
                        };
                        sensorContextMenu.MenuItems.Add(item);
                    }
                    else
                    {
                        MenuItem item = new MenuItem("Unhide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = true;
                        };
                        sensorContextMenu.MenuItems.Add(item);
                    }
                    sensorContextMenu.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);
                            }
                        };
                        sensorContextMenu.MenuItems.Add(item);
                    }
                    {
                        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);
                            }
                        };
                        sensorContextMenu.MenuItems.Add(item);
                    }

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