Exemplo n.º 1
0
        /// <summary>
        /// 绑定子节点
        /// </summary>
        void bindChildren()
        {
            var settingNode = new SolutionNode()
            {
                Text = "单元配置",
            };

            if (true)
            {
                settingNode.Nodes.Add(new SolutionNode()
                {
                    Text = "报警",
                    DoublicClickHandler = alarmSetting_doubleClick,
                });
                settingNode.Nodes.Add(new SolutionNode()
                {
                    Text = "趋势",
                    DoublicClickHandler = trendSetting_doubleClick,
                });
                settingNode.Nodes.Add(new SolutionNode()
                {
                    Text = "MMI",
                    DoublicClickHandler = mmiSetting_doubleClick,
                });
            }
            this.Nodes.Add(settingNode);

            this.Nodes.Add(new ControlWindowContainerNode(this.Data.id.Value, null)
            {
                Text = "监视画面",
            });

            this.Text = this.Data.Name + " Loading...";
            Helper.Remote.Invoke <SunRizServer.Device[]>("GetDeviceList", (ret, err) => {
                this.Text = this.Data.Name;
                if (err != null)
                {
                    MessageBox.Show(MainWindow.Instance, err);
                }
                else
                {
                    foreach (var data in ret)
                    {
                        var node = new DeviceNode(data);
                        node.ContextMenuItems.Add(new ContextMenuItem()
                        {
                            Text         = "重命名",
                            ClickHandler = editDeviceClick,
                            Tag          = node,
                        });
                        this.Nodes.Add(node);
                    }
                }
            }, this.Data.id);
        }
Exemplo n.º 2
0
 void addDeviceClick(object sender, RoutedEventArgs e)
 {
     Dialogs.InputBox frm = new Dialogs.InputBox("请输入控制器编号,如01、02等数字编号形式", "添加控制器");
     frm.Owner = MainWindow.Instance;
     if (frm.ShowDialog() == true && !string.IsNullOrEmpty(frm.Value))
     {
         var match = System.Text.RegularExpressions.Regex.Match(frm.Value, @"[0-9]+");
         if (match.Value != frm.Value)
         {
             MessageBox.Show(MainWindow.Instance, "必须是01、02等数字编号形式");
             addDeviceClick(sender, e);
             return;
         }
         var device = new SunRizServer.Device();
         device.Name   = "DROP" + frm.Value;
         device.UnitId = this.Data.id;
         Helper.Remote.Invoke <int>("UpdateDevice", (ret, err) => {
             if (err != null)
             {
                 MessageBox.Show(MainWindow.Instance, err);
             }
             else
             {
                 device.id = ret;
                 device.ChangedProperties.Clear();
                 this.IsExpanded = true;
                 var node        = new DeviceNode(device);
                 node.ContextMenuItems.Add(new ContextMenuItem()
                 {
                     Text         = "重命名",
                     ClickHandler = editDeviceClick,
                     Tag          = node,
                 });
                 this.Nodes.Add(node);
             }
         }, device);
     }
 }