Beispiel #1
0
 private void 添加次级分组ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode != null)
     {
         if (treeView1.SelectedNode.Tag is GroupConfig1)
         {
             var          node = treeView1.Nodes.Add("未命名");
             GroupConfig1 g1   = new GroupConfig1();
             ConfigData.GroupConfigRoot.GroupConfig1s.Add(g1);
             g1.GroupConfigs = new List <GroupConfig2>();
             node.Tag        = g1;
             node.BeginEdit();
         }
         else if (treeView1.SelectedNode.Tag is GroupConfig2)
         {
             var          node = treeView1.SelectedNode.Parent.Nodes.Add("未命名");
             GroupConfig2 g2   = new GroupConfig2();
             g2.GroupConfigs = new List <GroupConfig3>();
             ((GroupConfig1)(treeView1.SelectedNode.Parent.Tag)).GroupConfigs.Add(g2);
             node.Tag = g2;
             node.BeginEdit();
         }
         else if (treeView1.SelectedNode.Tag is GroupConfig3)
         {
             var          node = treeView1.SelectedNode.Parent.Nodes.Add("未命名");
             GroupConfig3 g3   = new GroupConfig3();
             g3.Sensors = new List <Sensor>();
             ((GroupConfig2)(treeView1.SelectedNode.Parent.Tag)).GroupConfigs.Add(g3);
             node.Tag = g3;
             node.BeginEdit();
         }
     }
 }
 private void Tsd_Click(object sender, EventArgs e)
 {
     if (tabControl1.SelectedTab != null)
     {
         if (MessageBox.Show("确定删除[" + tabControl1.SelectedTab.Name + "]?", "提醒", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             GroupConfig1 g1 = tabControl1.SelectedTab.Tag as GroupConfig1;
             tabControl1.TabPages.Remove(tabControl1.SelectedTab);
             ConfigData.GroupConfigRoot.GroupConfig1s.Remove(g1);
         }
     }
 }
        private void Tsc_Click(object sender, EventArgs e)
        {
            InputForm inf = new InputForm();

            if (inf.ShowDialog() == DialogResult.OK)
            {
                string name = inf.StrValue;
                if (!string.IsNullOrWhiteSpace(name))
                {
                    MessageBox.Show(string.Format("确定将[{0}]重命名为[{1}]?", tabControl1.SelectedTab.Text, name), "提醒", MessageBoxButtons.YesNo);
                    GroupConfig1 g1 = tabControl1.SelectedTab.Tag as GroupConfig1;
                    tabControl1.SelectedTab.Text = name;
                    g1.Name = name;
                    return;
                }
            }
        }
Beispiel #4
0
        public void Init()
        {
            BeforeInit();
            toolStripComboBox1.SelectedIndexChanged += (S, E) =>
            {
                GroupConfig1 g1 = toolStripComboBox1.SelectedItem as GroupConfig1;
                toolStripComboBox2.Items.Clear();
                if (g1 != null && g1.GroupConfigs != null)
                {
                    toolStripComboBox2.Items.AddRange(g1.GroupConfigs.ToArray());
                    SetSelect0(toolStripComboBox2);
                }
            };
            toolStripComboBox2.SelectedIndexChanged += (S, E) =>
            {
                GroupConfig2 g2 = toolStripComboBox2.SelectedItem as GroupConfig2;
                toolStripComboBox3.Items.Clear();
                if (g2 != null && g2.GroupConfigs != null)
                {
                    toolStripComboBox3.Items.AddRange(g2.GroupConfigs.ToArray());
                    SetSelect0(toolStripComboBox3);
                }
            };
            toolStripComboBox3.SelectedIndexChanged += (S, E) =>
            {
                GroupConfig3 g3 = toolStripComboBox3.SelectedItem as GroupConfig3;
                toolStripComboBox4.Items.Clear();
                if (g3 != null && g3.Sensors != null)
                {
                    toolStripComboBox4.Items.AddRange(g3.Sensors.ToArray());
                    SetSelect0(toolStripComboBox4);
                }
            };
            toolStripComboBox4.SelectedIndexChanged += (S, E) =>
            {
                Sensor s = toolStripComboBox4.SelectedItem as Sensor;
                userCalendar1.CurrentSensor = s;
            };

            toolStripComboBox1.Items.AddRange(ConfigData.GroupConfigRoot.GroupConfig1s.ToArray());
            SetSelect0(toolStripComboBox1);
            userCalendar1.Init();
        }
        public CustomPASListView(GroupConfig1 g1)
        {
            InitializeComponent();
            G1 = g1;
            this.ContextMenuStrip = contextMenuStrip1;
            //重命名分组
            if (g1.GroupConfigs == null)
            {
                g1.GroupConfigs = new List <GroupConfig2>();
            }
            this.toolStripComboBox3.Items.AddRange(g1.GroupConfigs.ToArray());
            //添加设备
            this.toolStripComboBox1.Items.AddRange(g1.GroupConfigs.ToArray());
            toolStripComboBox1.SelectedIndexChanged += ToolStripComboBox1_SelectedIndexChanged;

            toolStripMenuItem3.Click   += ToolStripMenuItem3_Click;
            确定ToolStripMenuItem.Click  += 确定ToolStripMenuItem_Click;
            确定ToolStripMenuItem1.Click += 确定ToolStripMenuItem1_Click;
            确定ToolStripMenuItem2.Click += 确定ToolStripMenuItem2_Click;
        }
 private void TabControl1_Selected(object sender, TabControlEventArgs e)
 {
     if (e.TabPage == tabControl1.TabPages["tbAdd"])
     {
         InputForm inf = new InputForm();
         if (inf.ShowDialog() == DialogResult.OK)
         {
             string name = inf.StrValue;
             if (!string.IsNullOrWhiteSpace(name))
             {
                 tabControl1.TabPages.Insert(tabControl1.TabPages.Count - 1, name, name);
                 GroupConfig1 gc1 = new GroupConfig1();
                 gc1.Name = name;
                 tabControl1.TabPages[name].Tag = gc1;
                 CustomPASListView cp = new CustomPASListView(gc1);
                 cp.Parent = tabControl1.TabPages[name];
                 return;
             }
         }
         tabControl1.SelectedTab = tabControl1.TabPages[0];
     }
 }
Beispiel #7
0
        public void Init()
        {
            xroot = Utils.FromXMLFile <XRoot>(path);
            foreach (var item in xroot.Pages)
            {
                PictureBox picTop = new PictureBox();
                tip.SetToolTip(picTop, item.Name);
                picTop.ImageLocation = item.Pic;
                picTop.SizeMode      = PictureBoxSizeMode.StretchImage;
                picTop.Tag           = item;
                picTop.Dock          = DockStyle.Left;
                picTop.Click        += PicTop_Click;
                tableLayoutPanel1.ColumnCount++;
                tableLayoutPanel1.Controls.Add(picTop);
                if (item.Sensors.Count > 0)
                {
                    foreach (var ss in item.Sensors)
                    {
                        NewPb(item, ss);
                        ss.Sensor = ConfigData.allSensors.Find(s => s.Uid == ss.Uid && s.NodeId == ss.Node && s.PortId == ss.Port);
                    }
                }
                else
                {
                    //匹配组名取出sensor
                    switch (item.Level)
                    {
                    case "1":
                        GroupConfig1 g1 = ConfigData.GroupConfigRoot.GroupConfig1s.Find(g => g.Name == item.Name);
                        if (g1 != null)
                        {
                            foreach (var g12 in g1.GroupConfigs)
                            {
                                foreach (var g123 in g12.GroupConfigs)
                                {
                                    foreach (var s in g123.Sensors)
                                    {
                                        NewSs(item, s);
                                    }
                                }
                            }
                        }
                        break;

                    case "2":
                        GroupConfig2 g2 = ConfigData.allG2.Find(g => g.Name == item.Name);
                        if (g2 != null)
                        {
                            foreach (var g23 in g2.GroupConfigs)
                            {
                                foreach (var s in g23.Sensors)
                                {
                                    NewSs(item, s);
                                }
                            }
                        }
                        break;

                    case "3":
                        GroupConfig3 g3 = ConfigData.allG3.Find(g => g.Name == item.Name);
                        if (g3 != null)
                        {
                            foreach (var s in g3.Sensors)
                            {
                                NewSs(item, s);
                            }
                        }
                        break;
                    }
                }
            }
            if (xroot.Pages.Count > 0)
            {
                this.BackgroundImage = Image.FromFile(xroot.Pages[0].Pic);
                ShowPb(xroot.Pages[0]);
                label1.Visible = true;
                label1.Text    = xroot.Pages[0].Name;
            }
        }