Esempio n. 1
0
        //private TreeItem CreateReleationItem(object relation)
        //{
        //    return CreateReleationItem((TableReleation)relation);
        //}

        //private ConfigTreeItem<TableReleation> CreateReleationItem(TableReleation relation)
        //{
        //    var colItem = new ConfigTreeItem<TableReleation>(relation)
        //    {
        //        //Header = relation.Friend,
        //        HeaderFieldExpression = p => p.Caption,
        //        SoruceTypeIcon = Application.Current.Resources["tree_Child2"] as BitmapImage
        //    };
        //    colItem.Commands.Add(new CommandItem
        //    {
        //        Command = new DelegateCommand<TableReleation>(p => p.Parent.Releations.Remove(p)),
        //        Parameter = relation,
        //        Name = "删除",
        //        Image = Application.Current.Resources["img_del"] as ImageSource
        //    });
        //    return colItem;
        //}

        #endregion

        #region 类型与枚举

        private void AddCustomTypeNode(ConfigTreeItem <SolutionConfig> node)
        {
            var item = new ConfigTreeItem <SolutionConfig>(Context.Solution)
            {
                IsAssist       = true,
                IsExpanded     = true,
                Header         = "类型",
                HeaderField    = null,
                SoruceTypeIcon = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            node.Items.Add(item);
            var mitem = new ConfigTreeItem <SolutionConfig>(Context.Solution)
            {
                IsAssist = true,
                //IsExpanded = true,
                Header                = "枚举",
                HeaderField           = null,
                CreateChildFunc       = CreateEnumTreeItem,
                SoruceItemsExpression = () => Context.Solution.Enums,
                SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            item.Items.Add(mitem);

            //Model.CppModel.AddTypedefItem(item);
        }
Esempio n. 2
0
        private TreeItem CreateClassifyItemNode(object arg)
        {
            var pro  = (PropertyUpgradeConfig)arg;
            var node = new ConfigTreeItem <PropertyUpgradeConfig>(pro)
            {
                IsAssist               = true,
                IsExpanded             = true,
                Header                 = $"{pro.Caption}〖{pro.Name}〗",
                HeaderField            = "Caption,Name",
                HeaderExtendExpression = m => $"{m.Caption}〖{m.Name}〗",
                SoruceTypeIcon         = Application.Current.Resources["tree_item"] as BitmapImage
            };

            if (pro.Field != null)
            {
                node.Items.Add(new ConfigTreeItem <FieldUpgradeConfig>(pro.Field)
                {
                    IsAssist               = true,
                    IsExpanded             = true,
                    Header                 = $"{pro.Field.Caption}〖{pro.Field.Name}〗",
                    HeaderField            = "Caption,Name",
                    HeaderExtendExpression = m => $"{m.Caption}〖{m.Name}〗",
                    SoruceTypeIcon         = Application.Current.Resources["tree_File"] as BitmapImage
                });
            }
            return(node);
        }
Esempio n. 3
0
 public void DeleteEnum(ConfigTreeItem <PropertyConfig> p)
 {
     if (p.Model.EnumConfig != null)
     {
         p.Model.EnumConfig.Option.IsDelete = true;
     }
     p.Model.CustomType = null;
     p.ReShow();
 }
Esempio n. 4
0
 public void DeleteEnum(ConfigTreeItem <PropertyConfig> p)
 {
     p.Model.CustomType = null;
     if (p.Model.EnumConfig == null)
     {
         return;
     }
     p.Model.EnumConfig.IsDelete = true;
     p.Model.EnumConfig          = null;
     p.ReShow();
 }
Esempio n. 5
0
        internal TreeItem CreateEntityTreeItem(object arg)
        {
            var entity = (EntityConfig)arg;

            foreach (var col in entity.Properties)
            {
                col.Parent = entity;
            }
            foreach (var relation in entity.Releations)
            {
                relation.Parent = entity;
            }
            var icon      = Application.Current.Resources[entity.IsClass ? "tree_Type" : "tree_Child4"] as BitmapImage;
            var tableItem = new ConfigTreeItem <EntityConfig>(entity)
            {
                SoruceTypeIcon = icon
            };
            var propertiesItem = new ConfigTreeItem <EntityConfig>(entity)
            {
                IsAssist              = true,
                IsExpanded            = true,
                Header                = "字段",
                Catalog               = "字段",
                HeaderField           = null,
                CreateChildFunc       = CreatePropertyTreeItem,
                SoruceItemsExpression = () => entity.Properties,
                SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            tableItem.Items.Add(propertiesItem);
            var cmdItem = new ConfigTreeItem <EntityConfig>(entity)
            {
                IsAssist              = true,
                IsExpanded            = true,
                Header                = "命令",
                Catalog               = "命令",
                HeaderField           = null,
                CreateChildFunc       = CreateCommandTreeItem,
                SoruceItemsExpression = () => entity.Commands,
                SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            tableItem.Items.Add(cmdItem);
            //var releations = new ConfigTreeItem<TableSchema>(entity)
            //{
            //    //Header = "关联",
            //    CreateChildFunc = CreateReleationItem,
            //    SoruceItemsExpression = () => entity.Releations,
            //    SoruceTypeIcon = Application.Current.Resources["tree_Folder"] as BitmapImage
            //};
            //tableItem.Items.Add(releations);
            return(tableItem);
        }
Esempio n. 6
0
        private TreeItem CreateCommandTreeItem(object arg)
        {
            var cmd     = (UserCommandConfig)arg;
            var colItem = new ConfigTreeItem <UserCommandConfig>(cmd)
            {
                IsExpanded             = true,
                HeaderField            = "Caption",
                HeaderExtendExpression = p => p.Caption,
                SoruceTypeIcon         = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            return(colItem);
        }
Esempio n. 7
0
        private void AddProjectNode(ConfigTreeItem <SolutionConfig> node)
        {
            var item = new ConfigTreeItem <SolutionConfig>(Context.Solution)
            {
                IsAssist              = true,
                IsExpanded            = true,
                Header                = "项目",
                HeaderField           = null,
                CreateChildFunc       = CreateProjectTreeItem,
                SoruceItemsExpression = () => Context.Solution.Projects,
                SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            node.Items.Add(item);
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        public void CreateTree()
        {
            TreeRoot.Items.Clear();
            var node = new ConfigTreeItem <SolutionConfig>(Context.Solution)
            {
                IsExpanded             = true,
                HeaderField            = "Caption",
                HeaderExtendExpression = p => p.Caption,
                SoruceTypeIcon         = Application.Current.Resources["tree_Solution"] as BitmapImage
            };

            AddProjectNode(node);
            //Model.CppModel.AddCppApiNode(node);
            AddCustomTypeNode(node);
            TreeRoot.Items.Add(node);
            SelectItem = TreeRoot.Items[0];
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        public void CreateTree()
        {
            TreeRoot.SelectItemChanged -= OnTreeSelectItemChanged;
            TreeRoot.Items.Clear();
            var node = new ConfigTreeItem <SolutionConfig>(Context.Solution)
            {
                IsExpanded             = true,
                Header                 = Context.Solution.Caption,
                HeaderField            = "Caption,Name",
                HeaderExtendExpression = p => p.Caption ?? p.Name,
                CreateChildFunc        = CreateProjectTreeItem,
                SoruceItemsExpression  = () => Context.Solution.ProjectList,
                SoruceTypeIcon         = Application.Current.Resources["tree_Solution"] as BitmapImage
            };

            TreeRoot.Items.Add(node);
            TreeRoot.SelectItemChanged += OnTreeSelectItemChanged;
        }
Esempio n. 10
0
        public TreeItem CreateApiItemTreeItem(object arg)
        {
            var child = (ApiItem)arg;
            var item  = new ConfigTreeItem <ApiItem>(child)
            {
                Header                 = child.Name,
                HeaderField            = "Name,Caption,CallArg",
                HeaderExtendExpression = m => $"{m.Caption}〖{m.Name}({m.CallArg})〗",
                SoruceTypeIcon         = Application.Current.Resources["tree_item"] as BitmapImage
            };
            var item2 = new ConfigTreeItem <ApiItem>(child)
            {
                IsAssist       = true,
                Header         = "参数",
                HeaderField    = null,
                SoruceTypeIcon = Application.Current.Resources["tree_item"] as BitmapImage
            };

            if (child.Argument != null)
            {
                item2.Items.Add(Model.Tree.CreateEntityTreeItem(child.Argument));
                item2.ModelPropertyChanged += ApiPropertyChangedBy;
            }
            item.Items.Add(item2);
            var item3 = new ConfigTreeItem <ApiItem>(child)
            {
                IsAssist       = true,
                Header         = "返回",
                HeaderField    = null,
                SoruceTypeIcon = Application.Current.Resources["tree_item"] as BitmapImage
            };

            if (child.Result != null)
            {
                item3.Items.Add(Model.Tree.CreateEntityTreeItem(child.Result));
                item3.ModelPropertyChanged += ApiPropertyChangedBy;
            }
            item.Items.Add(item3);
            CheckApiColor(item);
            item.ModelPropertyChanged += TreeModelPropertyChangedByApiItem;
            return(item);
        }
Esempio n. 11
0
        private TreeItem CreateProjectTreeItem(object arg)
        {
            var      project = (ProjectConfig)arg;
            TreeItem node    = new ConfigTreeItem <ProjectConfig>(project)
            {
                IsAssist       = true,
                IsExpanded     = true,
                SoruceTypeIcon = Application.Current.Resources["tree_Folder"] as BitmapImage
            };
            var group = new ClassifyGroupConfig <EntityConfig>(project.Entities, p => p.Classify,
                                                               (name, cfg) => cfg.Classify = name, project.Classifies);

            var eitem = new ConfigTreeItem <ProjectConfig>(project)
            {
                IsAssist              = true,
                Header                = "实体",
                HeaderField           = null,
                CreateChildFunc       = CreateEntityClassifiesTreeItem,
                SoruceItemsExpression = () => group.Classifies,
                SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            node.Items.Add(eitem);
            //Model.CppModel.AddCppApiNode(node);
            AddCustomTypeNode(node, project);

            var citem = new ConfigTreeItem <ProjectConfig>(project)
            {
                IsAssist              = true,
                Header                = "API",
                Tag                   = "API",
                HeaderField           = null,
                CreateChildFunc       = CreateApiItemTreeItem,
                SoruceItemsExpression = () => project.ApiItems,
                SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            node.Items.Add(citem);
            return(node);
        }
Esempio n. 12
0
        internal TreeItem CreateEntityTreeItem(object arg)
        {
            if (!(arg is EntityConfig entity))
            {
                return(null);
            }
            foreach (var col in entity.Properties)
            {
                col.Parent = entity;
            }
            foreach (var relation in entity.Releations)
            {
                relation.Parent = entity;
            }
            var tableItem = new ConfigTreeItem <EntityConfig>(entity)
            {
                Catalog               = "字段",
                CreateChildFunc       = CreatePropertyTreeItem,
                SoruceItemsExpression = () => entity.Properties,
                CustomPropertyChanged = Entity_PropertyChanged
            };

            return(tableItem);
        }
Esempio n. 13
0
        private TreeItem CreateEnumTreeItem(object arg)
        {
            var enumConfig = (EnumConfig)arg;
            var node       = new ConfigTreeItem <EnumConfig>(enumConfig)
            {
                IsExpanded     = true,
                SoruceTypeIcon = Application.Current.Resources["tree_Type"] as BitmapImage
            };
            var icon = Application.Current.Resources["tree_Child4"] as BitmapImage;

            if (enumConfig.Items != null && enumConfig.Items.Count > 0)
            {
                foreach (var item in enumConfig.Items)
                {
                    node.Items.Add(new ConfigTreeItem <EnumItem>(item)
                    {
                        HeaderField            = "Name,Value,Caption",
                        HeaderExtendExpression = p => $"{p.Name}:{p.Value}〖{p.Caption}〗",
                        SoruceTypeIcon         = icon
                    });
                }
            }
            return(node);
        }
Esempio n. 14
0
        private TreeItem CreateProjectTreeItem(object arg)
        {
            var      project = (ProjectConfig)arg;
            TreeItem item;

            if (project.Entities.Count > 15)
            {
                var group = new ClassifyGroupConfig <EntityConfig>(project.Entities, p => p.Classify,
                                                                   (name, cfg) => cfg.Classify = name, project.Classifies);

                if (SolutionConfig.Current.SolutionType == SolutionType.Cpp)
                {
                    item = new ConfigTreeItem <ProjectConfig>(project)
                    {
                        IsExpanded     = !project.ReadOnly,
                        SoruceTypeIcon = Application.Current.Resources["tree_Folder"] as BitmapImage
                    };
                    item.Items.Add(new ConfigTreeItem <ProjectConfig>(project)
                    {
                        IsAssist              = true,
                        IsExpanded            = true,
                        Header                = "实体",
                        HeaderField           = null,
                        CreateChildFunc       = CreateEntityClassifiesTreeItem,
                        SoruceItemsExpression = () => group.Classifies,
                        SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
                    });
                }
                else
                {
                    item = new ConfigTreeItem <ProjectConfig>(project)
                    {
                        IsAssist              = true,
                        IsExpanded            = true,
                        CreateChildFunc       = CreateEntityClassifiesTreeItem,
                        SoruceItemsExpression = () => group.Classifies,
                        SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
                    };
                }
            }
            else
            {
                item = new ConfigTreeItem <ProjectConfig>(project)
                {
                    CreateChildFunc       = CreateEntityTreeItem,
                    SoruceItemsExpression = () => project.Entities,
                    SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
                };
            }
            //if (SolutionConfig.Current.SolutionType != SolutionType.Cpp)
            //    return item;
            //var citem = new ConfigTreeItem<ProjectConfig>(project)
            //{
            //    IsAssist = true,
            //    Header = "API",
            //    HeaderField = null,
            //    CreateChildFunc = Model.CppModel.CreateApiItemTreeItem,
            //    SoruceItemsExpression = () => project.ApiItems,
            //    SoruceTypeIcon = Application.Current.Resources["tree_Folder"] as BitmapImage
            //};
            //Model.CppModel.AddProjectTypedefCommand(citem, project);
            //item.Items.Add(citem);
            return(item);
        }
Esempio n. 15
0
        private TreeItem CreatePropertyTreeItem(object arg)
        {
            var         property = (PropertyConfig)arg;
            BitmapImage icon;

            if (property.IsPrimaryKey)
            {
                icon = Application.Current.Resources["tree_default"] as BitmapImage;
            }
            else if (property.Discard)
            {
                icon = Application.Current.Resources["img_clear"] as BitmapImage;
            }
            else if (property.DbInnerField)
            {
                icon = Application.Current.Resources["img_lock"] as BitmapImage;
            }
            else if (property.IsInterfaceField)
            {
                icon = Application.Current.Resources["img_face"] as BitmapImage;
            }
            else if (!string.IsNullOrWhiteSpace(property.CustomType))
            {
                icon = Application.Current.Resources["img_man"] as BitmapImage;
            }
            else if (property.CustomWrite)
            {
                icon = Application.Current.Resources["tree_item"] as BitmapImage;
            }
            else if (!string.IsNullOrWhiteSpace(property.ComputeGetCode) ||
                     !string.IsNullOrWhiteSpace(property.ComputeSetCode))
            {
                icon = Application.Current.Resources["img_code"] as BitmapImage;
            }
            else if (property.IsCompute)
            {
                icon = Application.Current.Resources["img_sum"] as BitmapImage;
            }
            else
            {
                icon = Application.Current.Resources["tree_File"] as BitmapImage;
            }

            var colItem = new ConfigTreeItem <PropertyConfig>(property)
            {
                //IsExpanded = true,
                Color          = property.IsSystemField ? Brushes.Blue : Brushes.Black,
                FontWeight     = property.IsCompute ? FontWeights.Thin : FontWeights.DemiBold,
                SoruceTypeIcon = icon
            };

            //if (property.FieldType != null)
            //{
            //    colItem.Items.Add(new ConfigTreeItem<ColumnType>(property.FieldType)
            //    {
            //        //Header = "存储设置",
            //        SoruceTypeIcon = Application.Current.Resources["tree_default"] as BitmapImage
            //    });
            //}
            //if (property.PropertyType != null)
            //{
            //    colItem.Items.Add(new ConfigTreeItem<ColumnType>(property.PropertyType)
            //    {
            //        //Header = "代码设置",
            //        SoruceTypeIcon = Application.Current.Resources["tree_default"] as BitmapImage
            //    });
            //}
            //colItem.Commands.Add(new CommandItem
            //{
            //    Command = new DelegateCommand<PropertyConfig>(AddRelation, this, CanAddRelation),
            //    Name = "新增关联",
            //    Parameter = property,
            //    Image = Application.Current.Resources["tree_Open"] as ImageSource
            //});
            //PropertyChildTreeItem(colItem, property);

            return(colItem);
        }
Esempio n. 16
0
        private TreeItem CreateClassItem(object arg)
        {
            var config = (ClassUpgradeConfig)arg;

            var configItem = new ConfigTreeItem <ClassUpgradeConfig>(config)
            {
                SoruceTypeIcon = Application.Current.Resources["tree_Type"] as BitmapImage
            };

            var fields     = config.Fields.Values.ToDictionary(p => p.Name);
            var properties = new ConfigCollection <PropertyUpgradeConfig>();

            properties.AddRange(config.Properties.Values);
            config.ClassifyGroup = new ClassifyGroupConfig <PropertyUpgradeConfig>(properties, p => p.Category,
                                                                                   (c, cfg) => cfg.Category = c);
            var propertiesItem = new ConfigTreeItem <ClassUpgradeConfig>(config)
            {
                IsAssist              = true,
                IsExpanded            = true,
                Header                = "普通属性",
                HeaderField           = null,
                CreateChildFunc       = CreateClassifyNode,
                SoruceItemsExpression = () => config.ClassifyGroup.Classifies,
                SoruceTypeIcon        = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            foreach (var pro in config.Properties.Values)
            {
                if (string.IsNullOrWhiteSpace(pro.PairField) || !fields.ContainsKey(pro.PairField))
                {
                    continue;
                }
                pro.Field = fields[pro.PairField];
                fields.Remove(pro.PairField);
                pro.IsJsonAttribute = pro.Field.IsJsonAttribute;
                pro.IsDataAttribute = pro.Field.IsDataAttribute;
            }
            configItem.Items.Add(propertiesItem);
            var fieldItem = new ConfigTreeItem <ClassUpgradeConfig>(config)
            {
                IsAssist       = true,
                IsExpanded     = true,
                Header         = "落单字段",
                HeaderField    = null,
                SoruceTypeIcon = Application.Current.Resources["tree_Folder"] as BitmapImage
            };

            foreach (var field in fields.Values)
            {
                fieldItem.Items.Add(new ConfigTreeItem <FieldUpgradeConfig>(field)
                {
                    IsAssist               = true,
                    IsExpanded             = true,
                    Header                 = $"{field.Caption}〖{field.Name}〗",
                    HeaderField            = "Caption,Name",
                    HeaderExtendExpression = m => $"{m.Caption}〖{m.Name}〗",
                    SoruceTypeIcon         = Application.Current.Resources["tree_File"] as BitmapImage
                });
            }
            if (fieldItem.Items.Count > 0)
            {
                configItem.Items.Add(fieldItem);
            }
            return(configItem);
        }