示例#1
0
        public void CreateChild(bool isFolder)
        {
            UI.InputBox inputbox = new UI.InputBox("请输入目录名称", "新建目录");
            inputbox.Owner = MainWindow.instance;
            if (inputbox.ShowDialog() == true && inputbox.Value.Trim().Length > 0)
            {
                if (this.Children.Count(m => m.Name.ToLower() == inputbox.Value.Trim().ToLower()) > 0)
                {
                    MessageBox.Show(MainWindow.instance, "名称重复");
                    return;
                }

                EJ.InterfaceModule module = new EJ.InterfaceModule()
                {
                    ProjectID = Module.ProjectID,
                    Name      = inputbox.Value.Trim(),
                    ParentID  = Module.id,
                    IsFolder  = isFolder,
                };
                try
                {
                    module.id = Helper.Client.InvokeSync <int>("UpdateInterfaceModule", module);
                    module.ChangedProperties.Clear();

                    this.Children.Add(new InterfaceItemNode(module, this));
                    this.IsExpanded = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(MainWindow.instance, ex.Message);
                }
            }
        }
示例#2
0
        public void Rename()
        {
            UI.InputBox inputbox = new UI.InputBox("请输入新的名称", "重命名");
            inputbox.Owner = MainWindow.instance;
            inputbox.Value = this.Module.Name;
            if (inputbox.ShowDialog() == true)
            {
                string newName = inputbox.Value.Trim();

                if (this.Parent.Children.Count(m => m != this && m.Name.ToLower() == newName.ToLower()) > 0)
                {
                    MessageBox.Show(MainWindow.instance, "名称重复");
                    return;
                }
                string oldname = this.Module.Name;
                this.Module.ChangedProperties.Clear();
                this.Module.Name = newName;
                try
                {
                    Helper.Client.InvokeSync <string>("UpdateDBModule", this.Module);
                }
                catch (Exception ex)
                {
                    this.Module.Name = oldname;
                    MessageBox.Show(MainWindow.instance, ex.Message);
                }
            }
        }