/// <summary> /// 获取模型的注释。 /// </summary> /// <param name="comment"></param> /// <returns></returns> private static void TryParseDomainName(EOMObject type, string comment) { if (!string.IsNullOrEmpty(comment)) { var xmlDoc = XDocument.Parse(comment); var summary = xmlDoc.Root.Element("summary"); if (summary != null) { var value = summary.Value.Trim(); //只获取非空的第一行。 var reader = new StringReader(value); while (true) { value = reader.ReadLine(); if (value == null) { break; } value = value.Trim(); if (value.Length > 1) { break; } } if (value != null) { ODMLDocumentHelper.SetDomainName(type, value); } } } }
private void btnAddClasses_Click(object sender, RoutedEventArgs e) { if (_eom == null) { //注意:从 CommonModel 中获取的实体类,是没有继承关系的。 CommonModel.Entities.EnsureAllLoaded(); var converter = new MetaToEOM(CommonModel.Entities.Where(m => m.EntityCategory != EntityCategory.QueryObject)); _eom = converter.Read(); } var content = new ChooseClassesControl(_eom); var res = App.Windows.ShowDialog(content, w => { w.Title = "添加实体类".Translate(); w.Width = 400; }); if (res == WindowButton.Yes) { var typeList = content.SelectedEntities; if (typeList.Count > 0) { var document = modelViewer.GetDocument(); ODMLDocumentHelper.AddToDocument(new AddToDocumentArgs { Docment = document, TypeList = typeList, AllTypes = _eom.EntityTypes }); modelViewer.BindDocument(document); } } }
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); }
private void AddTypesInDocument(IList <EntityType> list) { var document = designer.GetDocument(); ODMLDocumentHelper.AddToDocument(new AddToDocumentArgs { Docment = document, TypeList = list, AllTypes = EOM.EntityTypes }); //使用双向绑定,不再需要手动调用文档加载。 //designer.LoadDocument(document); }