Exemple #1
0
        void addFolderClick(object sender, RoutedEventArgs e)
        {
            var inputbox = new Dialogs.InputBox("请输入文件夹名称", "添加文件夹");

            inputbox.Owner = MainWindow.Instance;
            if (inputbox.ShowDialog() == true && !inputbox.Value.IsBlank())
            {
                SunRizServer.DevicePointFolder folder = new DevicePointFolder();
                folder.ParentId = this.FolderModel.id;
                folder.Type     = this.FolderType;
                folder.Name     = inputbox.Value.Trim();
                folder.DeviceId = GetDevice().id;

                MainWindow.Instance.Cursor = Cursors.Hand;
                Helper.Remote.Invoke <int>("UpdateDevicePointFolder", (ret, err) =>
                {
                    MainWindow.Instance.Cursor = null;
                    if (err != null)
                    {
                        MessageBox.Show(MainWindow.Instance, err);
                    }
                    else
                    {
                        folder.id = ret;
                        folder.ChangedProperties.Clear();

                        //添加node对象
                        AnalogNode newNode = null;
                        if (this.FolderType == DevicePointFolder_TypeEnum.Analog)
                        {
                            newNode = new AnalogNode(folder);
                        }
                        else
                        {
                            newNode = new DigitalNode(folder);
                        }
                        newNode.Text = folder.Name;
                        this.Nodes.Insert(0, newNode);
                        this.IsExpanded = true;
                    }
                }, folder);
            }
        }
Exemple #2
0
        /// <summary>
        /// 异步加载子节点
        /// </summary>
        protected override void LoadChildrenAsync()
        {
            base.LoadChildrenAsync();

            //获取Device对象
            SunRizServer.Device device = this.GetDevice();

            Helper.Remote.Invoke <DevicePointFolder[]>("GetDevicePointFolders", (ret, err) =>
            {
                if (err != null)
                {
                    MessageBox.Show(MainWindow.Instance, err);
                }
                else
                {
                    this.Nodes.Clear();
                    //加载子节点
                    foreach (var folder in ret)
                    {
                        AnalogNode newNode = null;
                        if (FolderType == DevicePointFolder_TypeEnum.Analog)
                        {
                            newNode = new AnalogNode(folder);
                        }
                        else
                        {
                            newNode = new DigitalNode(folder);
                        }
                        newNode.Text = folder.Name;
                        this.Nodes.Add(newNode);
                    }

                    //加载点
                    loadPoints(device);
                }
            }, device.id, FolderType, this.FolderModel.id);
        }