Пример #1
0
        void Button6Click(object sender, EventArgs e)
        {
            if (_addAction == AddActions.Interface)
            {
                AddEditInterfaceDialog d = new AddEditInterfaceDialog(Configuration, null);
                if (d.ShowDialog(this) == DialogResult.OK)
                {
                    // dodanie interfejsu
                    List <RS232Configuration> rss = new List <RS232Configuration>(Configuration.Interfaces);
                    rss.Add(d.Interface);
                    Configuration.Interfaces = rss.ToArray();
                    InterfaceTreeNode node = new InterfaceTreeNode(d.Interface);
                    _root.Nodes.Add(node);
                    treeView1.SelectedNode = node;
                }
                return;
            }

            if (_addAction == AddActions.Device)
            {
                contextMenuStrip2.Show(button6, new Point(0, 0));
            }
        }
Пример #2
0
        void Button4Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null || treeView1.SelectedNode == _root)
            {
                return;
            }

            if (treeView1.SelectedNode is InterfaceTreeNode)
            {
                RS232Configuration     rs = ((InterfaceTreeNode)treeView1.SelectedNode).Interface;
                AddEditInterfaceDialog d  = new AddEditInterfaceDialog(Configuration, rs);
                if (d.ShowDialog(this) == DialogResult.OK)
                {
                    ((InterfaceTreeNode)treeView1.SelectedNode).RefreshText();
                    ShowInfo();
                }
            }

            if (treeView1.SelectedNode.Tag is LCDDevice)
            {
                LCDDevice        dev = (LCDDevice)treeView1.SelectedNode.Tag;
                AddEditLCDDevice d   = new AddEditLCDDevice(Configuration, Array.IndexOf(Configuration.LCDDevices, dev), dev.Interface);
                if (d.ShowDialog(this) == DialogResult.OK)
                {
                    treeView1.SelectedNode.Text = dev.Name2;
                    ShowInfo();
                    if (d.LCDReduction)
                    {
                        ShowLCDAreas();
                    }
                }
            }

            if (treeView1.SelectedNode.Tag is LEDDevice)
            {
                LEDDevice        dev = (LEDDevice)treeView1.SelectedNode.Tag;
                AddEditLEDDevice d   = new AddEditLEDDevice(Configuration, Array.IndexOf(Configuration.LEDDevices, dev), dev.Interface);
                if (d.ShowDialog(this) == DialogResult.OK)
                {
                    treeView1.SelectedNode.Text = dev.Name2;
                    ShowInfo();
                    ShowLEDs();
                }
            }

            if (treeView1.SelectedNode.Tag is LEDDisplayDevice)
            {
                LEDDisplayDevice dev            = (LEDDisplayDevice)treeView1.SelectedNode.Tag;
                AddEditLEDDisplayDeviceDialog d = new AddEditLEDDisplayDeviceDialog(Configuration, Array.IndexOf(Configuration.LEDDisplayDevices, dev), dev.Interface);
                if (d.ShowDialog(this) == DialogResult.OK)
                {
                    treeView1.SelectedNode.Text = dev.Name2;
                    ShowInfo();
                    ShowLEDDisplays();
                }
            }

            if (treeView1.SelectedNode.Tag is Steppers.StepperDevice)
            {
                Steppers.StepperDevice        dev = (Steppers.StepperDevice)treeView1.SelectedNode.Tag;
                Steppers.AddEditStepperDevice d   = new Steppers.AddEditStepperDevice(Configuration, dev, dev.Interface);
                if (d.ShowDialog(this) == DialogResult.OK)
                {
                    treeView1.SelectedNode.Text = dev.Name2;
                    ShowInfo();
                    ShowSteppers();
                }
            }

            if (treeView1.SelectedNode.Tag is Servos.ServoDevice)
            {
                Servos.ServoDevice        dev = (Servos.ServoDevice)treeView1.SelectedNode.Tag;
                Servos.AddEditServoDevice d   = new Servos.AddEditServoDevice(Configuration, Array.IndexOf(Configuration.ServoDevices, dev), dev.Interface);
                if (d.ShowDialog(this) == DialogResult.OK)
                {
                    treeView1.SelectedNode.Text = dev.Name2;
                    ShowInfo();
                    ShowServos();
                }
            }

            if (treeView1.SelectedNode.Tag is KeysDevice)
            {
                KeysDevice       dev = (KeysDevice)treeView1.SelectedNode.Tag;
                AddEditKeyDevice d   = new AddEditKeyDevice(Configuration, Array.IndexOf(Configuration.KeysDevices, dev), dev.Interface);
                if (d.ShowDialog(this) == DialogResult.OK)
                {
                    treeView1.SelectedNode.Text = dev.Name2;
                    ShowInfo();
                    ShowKeys();
                }
            }
        }