public static List <DataTemplateViewModel> GetModalDiagramTemplate(ModalDiagramViewModel vm) { List <DataTemplateViewModel> templates = new List <DataTemplateViewModel>(); templates.AddRange(GetDiagramClassTemplate(vm)); // bindable properties and important methods string str = "The ViewModel generated for the ModalDiagram contains the following properties and methods: " + "\r\n" + "\r\n"; str += " HostedElementVM:BaseModelElementViewModel (This is the currently hosted element)." + "\r\n"; str += " If the hosted DomainClass has a SpecificViewModel, than instead of the general BaseModelElementViewModel," + "\r\n"; str += " the specific VM is chosen" + "\r\n\r\n"; str += " HostedElement:DomainModelElement (This is the hosted element)." + "\r\n"; str += "\r\n"; str += " TitleExtension:string (This is the extension added to the docking window title after the title of the diagram)." + "\r\n"; str += "\r\n"; str += " NameExtension:string (This is the extension added to the identification name after the name of the diagram)." + "\r\n"; str += "\r\n"; str += " protected virtual void OnModelElementDeleted" + "\r\n"; str += " This method is called if the hosted element is deleted." + "\r\n\r\n"; str += " protected virtual void DragOver" + "\r\n"; str += " This method is called during a drag over operation." + "\r\n\r\n"; str += " protected virtual void Drop" + "\r\n"; str += " This method is called after an element was dropped on the diagram surface (see remarks below on Drag&Drop)." + "\r\n\r\n"; str += " For Drag&Drop to work, the xaml part of the view has to implement specific attributes: " + "\r\n"; str += " dd:DragDrop.IsDropTarget and dd:DragDrop.DropHandler " + "\r\n\r\n"; str += " An example is given below: " + "\r\n"; str += " xmlns:dd=\"clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Controls.Attached.DragDrop\"" + "\r\n"; str += " <Border Grid.Row=\"3\" HorizontalAlignment=\"Stretch\" VerticalAlignment=\"Stretch\"" + "\r\n"; str += " Background=\"Transparent\" dd:DragDrop.IsDropTarget=\"True\" dd:DragDrop.DropHandler=\"{Binding}\"/>" + "\r\n\r\n"; DataTemplateViewModel template = new DataTemplateViewModel(vm.ViewModelStore, "Customization/Visualization", str); template.ImageUri = "/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Class_32.png"; template.Description = "This template provides help on customizing and visualizing the view."; templates.Add(template); return(templates); }
public static List <DataTemplateViewModel> GetSpecificElementsDiagramTemplate(SpecificElementsDiagramViewModel vm) { List <DataTemplateViewModel> templates = new List <DataTemplateViewModel>(); templates.AddRange(GetDiagramClassTemplate(vm)); // bindable properties and important methods string str = "The ViewModel generated for the SpecificElementsDiagram contains the following properties and methods: " + "\r\n" + "\r\n"; str += " HostedElement:BaseModelElementViewModel (This is the currently hosted element)." + "\r\n"; str += " If the DomainClass currently hosted has a SpecificViewModel, than instead of the general BaseModelElementViewModel," + "\r\n"; str += " the specific VM is chosen" + "\r\n"; str += " SelectedElementType:SelectedElementEnum (This is the type of the selected model)." + "\r\n"; str += " The SelectedElementEnum is automatically generated and contains the following values: " + "\r\n"; str += " - ___None___" + "\r\n"; foreach (DomainClass d in (vm.DiagramClassView.DiagramClass as SpecificElementsDiagram).DomainClasses) { str += " - " + d.Name + "\r\n"; } str += "\r\n"; str += " protected virtual void UpdateView()" + "\r\n"; str += " This method is called on every selection change." + "\r\n"; str += " The selection is saved in the 'SelectedItemsCollection' property" + "\r\n\r\n"; str += " protected virtual void OnHostedElementDeleted" + "\r\n"; str += " This method is called if the hosted element is deleted." + "\r\n\r\n"; DataTemplateViewModel template = new DataTemplateViewModel(vm.ViewModelStore, "Customization/Visualization", str); template.ImageUri = "/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Class_32.png"; template.Description = "This template provides help on customizing and visualizing the view."; templates.Add(template); return(templates); }
private static List <DataTemplateViewModel> ParseFile(ViewModelStore store, string embeddedFileName, params string[] customStrings) { List <DataTemplateViewModel> viewModels = new List <DataTemplateViewModel>(); XmlDocument doc = GetFile(embeddedFileName); XmlNodeList list = doc.DocumentElement.GetElementsByTagName("DataTemplate"); foreach (XmlNode node in list) { string displayName = null; string description = null; string imageURI = null; string syntaxHighlighting = "C#"; string template = null; for (int i = 0; i < node.ChildNodes.Count; i++) { switch (node.ChildNodes[i].Name) { case "DisplayName": if (node.ChildNodes[i].HasChildNodes) { displayName = node.ChildNodes[i].ChildNodes[0].Value; } else { displayName = node.ChildNodes[i].Value; } break; case "Description": if (node.ChildNodes[i].HasChildNodes) { description = node.ChildNodes[i].ChildNodes[0].Value; } else { description = node.ChildNodes[i].Value; } break; case "ImageURI": if (node.ChildNodes[i].HasChildNodes) { imageURI = node.ChildNodes[i].ChildNodes[0].Value; } else { imageURI = node.ChildNodes[i].Value; } break; case "SyntaxHighlighting": if (node.ChildNodes[i].HasChildNodes) { syntaxHighlighting = node.ChildNodes[i].ChildNodes[0].Value; } else { syntaxHighlighting = node.ChildNodes[i].Value; } break; case "Template": if (node.ChildNodes[i].HasChildNodes) { if (node.ChildNodes[i].ChildNodes[0] is XmlCDataSection) { template = (node.ChildNodes[i].ChildNodes[0] as XmlCDataSection).Value; break; } } template = node.ChildNodes[i].Value; break; } } if (displayName != null && template != null) { // parse template template = ReplaceFields(template.Trim(), customStrings); // create vm DataTemplateViewModel vm = new DataTemplateViewModel(store, displayName, template); if (description != null) { vm.Description = description; } if (imageURI != null) { vm.ImageUri = imageURI; } if (syntaxHighlighting != null) { vm.SyntaxHighlighting = syntaxHighlighting; } viewModels.Add(vm); } } return(viewModels); }
public static DataTemplateViewModel CreateBindablePropertiesTemplate(BaseModelElementViewModel vm) { ModelElement modelElement = vm.GetHostedElement(); AttributedDomainElement attrDomainElement = null; string specificProperties = ""; if (modelElement is ShapeClass) { attrDomainElement = ((modelElement) as ShapeClass).DomainClass; specificProperties = "*** Specific properties: *** " + "\r\n"; specificProperties += " AbsoluteLeft (double)" + "\r\n"; specificProperties += " AbsoluteTop (double)" + "\r\n"; specificProperties += " AbsoluteLocation (PointD(double, double))" + "\r\n"; specificProperties += " Bounds (RectangleD(double, double, double, double))" + "\r\n"; specificProperties += " CanHaveNestedChildren (bool)" + "\r\n"; specificProperties += " CanHaveRelativeChildren (bool)" + "\r\n"; specificProperties += " Height (double)" + "\r\n"; specificProperties += " IsHeightFixed (bool)" + "\r\n"; specificProperties += " IsRelativeChildShape (bool)" + "\r\n"; specificProperties += " IsWidthFixed (bool)" + "\r\n"; specificProperties += " Left (double)" + "\r\n"; specificProperties += " Location (PointD(double, double))" + "\r\n"; specificProperties += " Size (SizeD(double, double))" + "\r\n"; specificProperties += " TakesPartInRelationship (bool)" + "\r\n"; specificProperties += " Top (double)" + "\r\n"; specificProperties += " Width (double)" + "\r\n"; specificProperties += "\r\n"; } else if (modelElement is RelationshipShapeClass || modelElement is MappingRelationshipShapeClass) { if (modelElement is RelationshipShapeClass) { attrDomainElement = ((modelElement) as RelationshipShapeClass).ReferenceRelationship; } else { attrDomainElement = ((modelElement) as MappingRelationshipShapeClass).DomainClass; } specificProperties = "*** Specific properties: *** " + "\r\n"; specificProperties += " EdgePoints (EdgePointViewModel(X,Y, ...))" + "\r\n"; specificProperties += " StartEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n"; specificProperties += " MiddleEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n"; specificProperties += " EndEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n"; specificProperties += " Geometry (PathGeometry)" + "\r\n"; specificProperties += " FromAnchorAngle (double)" + "\r\n"; specificProperties += " ToAnchorAngle (double)" + "\r\n"; specificProperties += " RoutingMode (RoutingMode(Orthogonal, Straight))" + "\r\n"; specificProperties += "\r\n"; } bool hasSpecificDomainProperties = false; string specificDomainProperties = "*** Specific domain properties: *** " + "\r\n"; if (attrDomainElement != null) { foreach (DomainProperty p in attrDomainElement.Properties) { if (p.Type == null) { continue; } hasSpecificDomainProperties = true; specificDomainProperties += " Element_" + p.Name + "(" + p.Type.Name + ")" + "\r\n"; } } if (!hasSpecificDomainProperties) { specificDomainProperties = ""; } else { specificDomainProperties += "\r\n"; } DataTemplateViewModel template = new DataTemplateViewModel(vm.ViewModelStore, "Bindable Properties", specificProperties + specificDomainProperties + "*** General properties: *** " + "\r\n" + " DomainElementName (string)" + "\r\n" + " DomainElementFullName (string)" + "\r\n" + " DomainElementHasName (bool)" + "\r\n" + " DomainElementType (string)" + "\r\n" + " DomainElementTypeDisplayName (string)" + "\r\n" + " DomainElementParentHasName (bool)" + "\r\n" + " DomainElementParentName (string)" + "\r\n" + " DomainElementParentFullName (string)" + "\r\n" + " DomainElementParentHasFirstExistingName (bool)" + "\r\n" + " DomainElementParentFirstExistingName (string)" + "\r\n" + " DomainElementHasParentFullPath (bool)" + "\r\n" + " DomainElementParentFullPath (string)"); template.ImageUri = "/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Properties-32x32.png"; template.Description = "These are bindable properties you can utilize in your data templates. "; template.SyntaxHighlighting = "C#"; return(template); }
public static List<DataTemplateViewModel> GetSpecificElementsDiagramTemplate(SpecificElementsDiagramViewModel vm) { List<DataTemplateViewModel> templates = new List<DataTemplateViewModel>(); templates.AddRange(GetDiagramClassTemplate(vm)); // bindable properties and important methods string str = "The ViewModel generated for the SpecificElementsDiagram contains the following properties and methods: " + "\r\n" + "\r\n"; str += " HostedElement:BaseModelElementViewModel (This is the currently hosted element)." + "\r\n"; str += " If the DomainClass currently hosted has a SpecificViewModel, than instead of the general BaseModelElementViewModel," + "\r\n"; str += " the specific VM is chosen" + "\r\n"; str += " SelectedElementType:SelectedElementEnum (This is the type of the selected model)." + "\r\n"; str += " The SelectedElementEnum is automatically generated and contains the following values: " + "\r\n"; str += " - ___None___" + "\r\n"; foreach(DomainClass d in (vm.DiagramClassView.DiagramClass as SpecificElementsDiagram).DomainClasses) str += " - " + d.Name + "\r\n"; str += "\r\n"; str += " protected virtual void UpdateView()" + "\r\n"; str += " This method is called on every selection change." + "\r\n"; str += " The selection is saved in the 'SelectedItemsCollection' property" + "\r\n\r\n"; str += " protected virtual void OnHostedElementDeleted" + "\r\n"; str += " This method is called if the hosted element is deleted." + "\r\n\r\n"; DataTemplateViewModel template = new DataTemplateViewModel(vm.ViewModelStore, "Customization/Visualization", str); template.ImageUri = "/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Class_32.png"; template.Description = "This template provides help on customizing and visualizing the view."; templates.Add(template); return templates; }
private static List<DataTemplateViewModel> ParseFile(ViewModelStore store, string embeddedFileName, params string[] customStrings) { List<DataTemplateViewModel> viewModels = new List<DataTemplateViewModel>(); XmlDocument doc = GetFile(embeddedFileName); XmlNodeList list = doc.DocumentElement.GetElementsByTagName("DataTemplate"); foreach (XmlNode node in list) { string displayName = null; string description = null; string imageURI = null; string syntaxHighlighting = "C#"; string template = null; for (int i = 0; i < node.ChildNodes.Count; i++) { switch (node.ChildNodes[i].Name) { case "DisplayName": if (node.ChildNodes[i].HasChildNodes) displayName = node.ChildNodes[i].ChildNodes[0].Value; else displayName = node.ChildNodes[i].Value; break; case "Description": if (node.ChildNodes[i].HasChildNodes) description = node.ChildNodes[i].ChildNodes[0].Value; else description = node.ChildNodes[i].Value; break; case "ImageURI": if (node.ChildNodes[i].HasChildNodes) imageURI = node.ChildNodes[i].ChildNodes[0].Value; else imageURI = node.ChildNodes[i].Value; break; case "SyntaxHighlighting": if (node.ChildNodes[i].HasChildNodes) syntaxHighlighting = node.ChildNodes[i].ChildNodes[0].Value; else syntaxHighlighting = node.ChildNodes[i].Value; break; case "Template": if (node.ChildNodes[i].HasChildNodes) if (node.ChildNodes[i].ChildNodes[0] is XmlCDataSection) { template = (node.ChildNodes[i].ChildNodes[0] as XmlCDataSection).Value; break; } template = node.ChildNodes[i].Value; break; } } if (displayName != null && template != null) { // parse template template = ReplaceFields(template.Trim(), customStrings); // create vm DataTemplateViewModel vm = new DataTemplateViewModel(store, displayName, template); if (description != null) vm.Description = description; if (imageURI != null) vm.ImageUri = imageURI; if (syntaxHighlighting != null) vm.SyntaxHighlighting = syntaxHighlighting; viewModels.Add(vm); } } return viewModels; }
public static DataTemplateViewModel CreateBindablePropertiesTemplate(BaseModelElementViewModel vm) { ModelElement modelElement = vm.GetHostedElement(); AttributedDomainElement attrDomainElement = null; string specificProperties = ""; if (modelElement is ShapeClass) { attrDomainElement = ((modelElement) as ShapeClass).DomainClass; specificProperties = "*** Specific properties: *** " + "\r\n"; specificProperties += " AbsoluteLeft (double)" + "\r\n"; specificProperties += " AbsoluteTop (double)" + "\r\n"; specificProperties += " AbsoluteLocation (PointD(double, double))" + "\r\n"; specificProperties += " Bounds (RectangleD(double, double, double, double))" + "\r\n"; specificProperties += " CanHaveNestedChildren (bool)" + "\r\n"; specificProperties += " CanHaveRelativeChildren (bool)" + "\r\n"; specificProperties += " Height (double)" + "\r\n"; specificProperties += " IsHeightFixed (bool)" + "\r\n"; specificProperties += " IsRelativeChildShape (bool)" + "\r\n"; specificProperties += " IsWidthFixed (bool)" + "\r\n"; specificProperties += " Left (double)" + "\r\n"; specificProperties += " Location (PointD(double, double))" + "\r\n"; specificProperties += " Size (SizeD(double, double))" + "\r\n"; specificProperties += " TakesPartInRelationship (bool)" + "\r\n"; specificProperties += " Top (double)" + "\r\n"; specificProperties += " Width (double)" + "\r\n"; specificProperties += "\r\n"; } else if (modelElement is RelationshipShapeClass || modelElement is MappingRelationshipShapeClass) { if (modelElement is RelationshipShapeClass ) attrDomainElement = ((modelElement) as RelationshipShapeClass).ReferenceRelationship; else attrDomainElement = ((modelElement) as MappingRelationshipShapeClass).DomainClass; specificProperties = "*** Specific properties: *** " + "\r\n"; specificProperties += " EdgePoints (EdgePointViewModel(X,Y, ...))" + "\r\n"; specificProperties += " StartEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n"; specificProperties += " MiddleEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n"; specificProperties += " EndEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n"; specificProperties += " Geometry (PathGeometry)" + "\r\n"; specificProperties += " FromAnchorAngle (double)" + "\r\n"; specificProperties += " ToAnchorAngle (double)" + "\r\n"; specificProperties += " RoutingMode (RoutingMode(Orthogonal, Straight))" + "\r\n"; specificProperties += "\r\n"; } bool hasSpecificDomainProperties = false; string specificDomainProperties = "*** Specific domain properties: *** " + "\r\n"; if (attrDomainElement != null) { foreach (DomainProperty p in attrDomainElement.Properties) { if( p.Type == null ) continue; hasSpecificDomainProperties = true; specificDomainProperties += " Element_" + p.Name + "(" + p.Type.Name + ")" + "\r\n"; } } if (!hasSpecificDomainProperties) specificDomainProperties = ""; else specificDomainProperties += "\r\n"; DataTemplateViewModel template = new DataTemplateViewModel(vm.ViewModelStore, "Bindable Properties", specificProperties + specificDomainProperties + "*** General properties: *** " + "\r\n" + " DomainElementName (string)" + "\r\n" + " DomainElementFullName (string)" + "\r\n" + " DomainElementHasName (bool)" + "\r\n" + " DomainElementType (string)" + "\r\n" + " DomainElementTypeDisplayName (string)" + "\r\n" + " DomainElementParentHasName (bool)" + "\r\n" + " DomainElementParentName (string)" + "\r\n" + " DomainElementParentFullName (string)" + "\r\n" + " DomainElementParentHasFirstExistingName (bool)" + "\r\n" + " DomainElementParentFirstExistingName (string)" + "\r\n" + " DomainElementHasParentFullPath (bool)" + "\r\n" + " DomainElementParentFullPath (string)"); template.ImageUri = "/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Properties-32x32.png"; template.Description = "These are bindable properties you can utilize in your data templates. "; template.SyntaxHighlighting = "C#"; return template; }
public static List<DataTemplateViewModel> GetModalDiagramTemplate(ModalDiagramViewModel vm) { List<DataTemplateViewModel> templates = new List<DataTemplateViewModel>(); templates.AddRange(GetDiagramClassTemplate(vm)); // bindable properties and important methods string str = "The ViewModel generated for the ModalDiagram contains the following properties and methods: " + "\r\n" + "\r\n"; str += " HostedElementVM:BaseModelElementViewModel (This is the currently hosted element)." + "\r\n"; str += " If the hosted DomainClass has a SpecificViewModel, than instead of the general BaseModelElementViewModel," + "\r\n"; str += " the specific VM is chosen" + "\r\n\r\n"; str += " HostedElement:DomainModelElement (This is the hosted element)." + "\r\n"; str += "\r\n"; str += " TitleExtension:string (This is the extension added to the docking window title after the title of the diagram)." + "\r\n"; str += "\r\n"; str += " NameExtension:string (This is the extension added to the identification name after the name of the diagram)." + "\r\n"; str += "\r\n"; str += " protected virtual void OnModelElementDeleted" + "\r\n"; str += " This method is called if the hosted element is deleted." + "\r\n\r\n"; str += " protected virtual void DragOver" + "\r\n"; str += " This method is called during a drag over operation." + "\r\n\r\n"; str += " protected virtual void Drop" + "\r\n"; str += " This method is called after an element was dropped on the diagram surface (see remarks below on Drag&Drop)." + "\r\n\r\n"; str += " For Drag&Drop to work, the xaml part of the view has to implement specific attributes: " + "\r\n"; str += " dd:DragDrop.IsDropTarget and dd:DragDrop.DropHandler " + "\r\n\r\n"; str += " An example is given below: " + "\r\n"; str += " xmlns:dd=\"clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Controls.Attached.DragDrop\"" + "\r\n"; str += " <Border Grid.Row=\"3\" HorizontalAlignment=\"Stretch\" VerticalAlignment=\"Stretch\"" + "\r\n"; str += " Background=\"Transparent\" dd:DragDrop.IsDropTarget=\"True\" dd:DragDrop.DropHandler=\"{Binding}\"/>" + "\r\n\r\n"; DataTemplateViewModel template = new DataTemplateViewModel(vm.ViewModelStore, "Customization/Visualization", str); template.ImageUri = "/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Class_32.png"; template.Description = "This template provides help on customizing and visualizing the view."; templates.Add(template); return templates; }
public static List<DataTemplateViewModel> GetDomainClassPropertyGridViewModelTemplates(BaseAttributeElementViewModel vm) { MetaModel metaModel = vm.Element.GetMetaModel(); DomainClass element = vm.Element as DomainClass; if (element == null ) return null; string examples = ""; bool bReferenceFound = false; foreach (DomainRole role in element.RolesPlayed) { if (role.Relationship is ReferenceRelationship && !bReferenceFound) if (role.IsPropertyGenerator) { bReferenceFound = true; examples += " // EXAMLE: Custom values provider for role editor: " + "\r\n"; examples += " // HINT: Don't forget to set 'Generates Double Derived' to 'True' for " + element.Name + "\r\n"; examples += " protected override void CreateEditorViewModelFor" + role.PropertyName + "Role(System.Collections.Generic.List<PropertyGridEditorViewModel> collection)" + "\r\n"; examples += " {" + "\r\n"; examples += " /*" + "\r\n"; examples += " Copy and paste from the original method " + "\r\n"; examples += " */" + "\r\n\r\n"; examples += " // Change:" + "\r\n"; examples += " editor.DefaultValuesProvider = new LookupListEditorDefaultValuesProvider<object>(GetDefaultElements);" + "\r\n"; examples += " // End of original method:" + "\r\n"; examples += " collection.Add(editor);" + "\r\n" + "\r\n"; examples += " }" + "\r\n"; examples += " // This method returns the default values for a role view model" + "\r\n"; examples += " private List<object> GetDefaultElements(LookupListEditorViewModel viewModel)" + "\r\n"; examples += " {" + "\r\n"; examples += " " + element.Name + " element = this.Element as " + element.Name + ";\r\n"; examples += " // TODO" + "\r\n"; examples += " }" + "\r\n"; } if (bReferenceFound) break; } List<DataTemplateViewModel> retVms = ParseFile(vm.ViewModelStore, "DomainClassPropertyGridTemplate.xml", new string[]{ vm.Element.Name, // CustomString0 metaModel.Namespace, // CustomString1 examples, // CustomString2 }); DataTemplateViewModel specificVM = new DataTemplateViewModel(vm.ViewModelStore, "Specific ViewModel Properties", GetSpecificViewModelString(element, false)); retVms.Add(specificVM); specificVM.Description = "Properties and Roles generated for Specific ViewModels..."; return retVms; }