コード例 #1
0
        /// <summary>
        /// 让设计器加载指定的文档对象
        /// </summary>
        /// <param name="designer"></param>
        /// <param name="document"></param>
        public static void BindDocument(this ModelingDesigner designer, ODMLDocument document)
        {
            DocumentBinder.BindDocument(designer, document);

            //绑定新的文档时,需要清空文件路径。
            designer.ClearValue(CurrentOdmlFileProperty);
        }
コード例 #2
0
ファイル: DocumentBinder.cs プロジェクト: 569550384/Rafy
 internal static void BindDocument(ModelingDesigner designer, ODMLDocument document)
 {
     var binder = new DocumentBinder
     {
         _designer = designer,
         _document = document
     };
     binder.BindDocument();
 }
コード例 #3
0
ファイル: DocumentBinder.cs プロジェクト: yungtau/oea
        internal static void BindDocument(ModelingDesigner designer, ODMLDocument document)
        {
            var binder = new DocumentBinder
            {
                _designer = designer,
                _document = document
            };

            binder.BindDocument();
        }
コード例 #4
0
        ///// <summary>
        ///// 让设计器加载指定的文档对象
        ///// </summary>
        ///// <param name="designer"></param>
        ///// <param name="document"></param>
        //public static void LoadDocument(this ModelingDesigner designer, ODMLDocument document)
        //{
        //    DocumentHelper.LoadDocument(designer, document);
        //    designer.ClearValue(CurrentOdmlFileProperty);
        //}
        /// <summary>
        /// 获取目前绑定在设计器中的文档对象
        /// </summary>
        /// <param name="designer"></param>
        /// <returns></returns>
        public static ODMLDocument GetDocument(this ModelingDesigner designer)
        {
            var doc = designer.DataContext as ODMLDocument;
            if (doc == null)
            {
                doc = new ODMLDocument();
                BindDocument(designer, doc);
            }
            return doc;

            //return DocumentHelper.GetDocument(designer);
        }
コード例 #5
0
        /// <summary>
        /// 测试使用 Document 来进行初始化。
        /// </summary>
        private void IntializeByDocument()
        {
            var document = new ODMLDocument
            {
                EntityTypes =
                {
                    new EntityTypeElement("Item"){ Left = 100, Top = 100 },
                    new EntityTypeElement("Role")
                    {
                        IsAggtRoot = true,
                        Left = 300, Top = 100,
                        Properties =
                        {
                            new PropertyElement("Id"){PropertyType = "int"},
                            new PropertyElement("Name"){PropertyType = "string", Name = "名称"},
                        }
                    },
                    new EntityTypeElement("Warehouse"){ Left = 300, Top = 300 },
                },
                EnumTypes =
                {
                    new EnumElement("CategoryType")
                    {
                        Left = 100, Top = 300,
                        Items =
                        {
                            new EnumItemElement("NONE") { Label = "未登记" },
                            new EnumItemElement("REJECTED") { Label = "保留" },
                            new EnumItemElement("IDLE") { Label = "预定" },
                            new EnumItemElement("ACCEPTED") { Label = "已受理" },
                            new EnumItemElement("INSTRUCTING") { Label = "指示中" },
                            new EnumItemElement("INSTRUCTED") { Label = "已指示" },
                            new EnumItemElement("RECEIVING") { Label = "进货中" },
                            new EnumItemElement("RECEIVED") { Label = "已进货" },
                            new EnumItemElement("COMPLETED") { Label = "已认可" },
                        }
                    },
                }
            };

            designer.BindDocument(document);
        }
コード例 #6
0
ファイル: ODMLDocumentHelper.cs プロジェクト: 569550384/Rafy
        private static void AddTypeElements(ODMLDocument doc, IList<EntityType> typeList)
        {
            int row = 0, column = 0;
            for (int i = 0, c = typeList.Count; i < c; i++)
            {
                var type = typeList[i];

                var typeFullName = type.FullName;
                //如果这个实体还没有加进来,就创建一个元素并加入到列表中。
                if (doc.EntityTypes.All(e => e.FullName != typeFullName))
                {
                    var entityTypeEl = new EntityTypeElement(typeFullName);
                    entityTypeEl.FullName = typeFullName;
                    entityTypeEl.Left = column * 300;
                    entityTypeEl.Top = row * 200;
                    entityTypeEl.IsAggtRoot = type.IsAggtRoot;
                    entityTypeEl.HideProperties = true;
                    entityTypeEl.Label = GetDomainName(type);

                    foreach (var vp in type.ValueProperties)
                    {
                        var propertyEl = new PropertyElement(vp.Name);
                        propertyEl.Label = GetDomainName(vp);

                        if (vp.PropertyType == ValuePropertyType.Enum)
                        {
                            propertyEl.PropertyType = vp.EnumType.Name;
                        }
                        else
                        {
                            propertyEl.PropertyType = vp.PropertyType.ToString();
                        }

                        //可空类型,显示在属性上时,需要添加"?" 号。
                        if (vp.Nullable)
                        {
                            propertyEl.PropertyType += "?";
                        }

                        entityTypeEl.Properties.Add(propertyEl);
                    }

                    doc.EntityTypes.Add(entityTypeEl);

                    column++;
                    //一排四个。
                    if (column == 3)
                    {
                        row++;
                        column = 0;
                    }
                }
            }
        }
コード例 #7
0
ファイル: ODMLDocumentHelper.cs プロジェクト: 569550384/Rafy
        private static void TryAddConnection(ODMLDocument document, ConnectionElement connectionEl)
        {
            //目前,暂时不支持自关联的线。
            if (connectionEl.From == connectionEl.To) return;

            //要判断是否之前已经添加了这个连接,才继续添加连接。
            if (document.Connections.All(c => c.From != connectionEl.From || c.To != connectionEl.To || c.Label != connectionEl.Label))
            {
                document.Connections.Add(connectionEl);
            }
        }
コード例 #8
0
ファイル: ModelingEditor.xaml.cs プロジェクト: 569550384/Rafy
        private void btnRefreshClasses_Click(object sender, EventArgs e)
        {
            if (_owner.Project == null) return;
            ResetEOM();

            var oldDocument = designer.GetDocument();

            //创建一个新文档对象,使用它来描述最新的文档结构。
            var document = new ODMLDocument();

            //把原来显示的所有实体类型,加入到新文档对象中。
            var eom = EOM;
            var types = oldDocument.EntityTypes.Select(el => eom.EntityTypes.Find(el.FullName))
                .Where(t => t != null).ToArray();
            ODMLDocumentHelper.AddToDocument(new AddToDocumentArgs
            {
                Docment = document,
                TypeList = types,
                AllTypes = eom.EntityTypes
            });

            //新的元素的位置,还原为所有旧元素的位置
            foreach (var el in document.EntityTypes)
            {
                var oldTypeEl = oldDocument.FindEntityType(el.FullName);
                el.Left = oldTypeEl.Left;
                el.Top = oldTypeEl.Top;
                el.Width = oldTypeEl.Width;
                el.Height = oldTypeEl.Height;
            }
            foreach (var el in document.EnumTypes)
            {
                var oldTypeEl = oldDocument.FindEnumType(el.FullName);
                el.Left = oldTypeEl.Left;
                el.Top = oldTypeEl.Top;
                el.Width = oldTypeEl.Width;
                el.Height = oldTypeEl.Height;
            }
            foreach (var el in document.Connections)
            {
                var old = oldDocument.FindConnection(el);
                if (old != null)
                {
                    el.Hidden = old.Hidden;
                    el.ConnectionType = old.ConnectionType;
                    el.FromPointPos = old.FromPointPos;
                    el.ToPointPos = old.ToPointPos;
                }
            }

            //绑定新文档对象到设计器中,丢弃旧对象。
            designer.BindDocument(document);
        }