/// <summary> /// Read shape data from XML stream and return it. /// </summary> /// <param name="reader"></param> /// <param name="parent"></param> /// <param name="umlType"></param> /// <returns></returns> public static UmlNodeShapeViewModel ReadDocument(XmlReader reader, IShapeParent parent, UmlTypes umlType) { UmlNodeShapeViewModel ret = UmlElementDataDef.CreateShape(umlType, new System.Windows.Point(UmlTypeToStringConverter.DefaultX, UmlTypeToStringConverter.DefaultY), parent) as UmlNodeShapeViewModel; reader.ReadToNextSibling(ret.UmlDataTypeString); while (reader.MoveToNextAttribute()) { if (ret.ReadAttributes(reader.Name, reader.Value) == false) { if (reader.Name.Trim().Length > 0 && reader.Name != UmlShapeBaseViewModel.XmlComment) { throw new ArgumentException("XML node:'" + reader.Name + "' as child of '" + ret.XElementName + "' is not supported."); } } } // Read common model information (eg. comments) UmlShapeBaseViewModel.ReadDocument(reader, ret); return(ret); }
/// <summary> /// Method is required by <seealso cref="IDragableCommandModel"/>. It is executed /// when the drag & drop operation on the canvas is infished with its last step /// (the creation of the viewmodel for the new item). /// </summary> /// <param name="dropPoint"></param> public void OnDragDropExecute(Point dropPoint) { IShapeParent parent = this.mViewModel.mWindowViewModel.vm_DocumentViewModel.vm_CanvasViewModel; this.AddShape(this.mViewModel.mWindowViewModel.vm_DocumentViewModel.vm_CanvasViewModel, UmlElementDataDef.CreateShape(this.mUmlType, dropPoint, parent)); }
/// <summary> /// Method is required by <seealso cref="IDragableCommandModel"/>. It is executed /// when the drag & drop operation on the canvas is infished with its last step /// (the creation of the viewmodel for the new item). /// </summary> /// <param name="dropPoint"></param> public void OnDragDropExecute(Point dropPoint) { var model = this.mViewModel.mWindowViewModel.vm_DocumentViewModel; model.v_CanvasView.ForceCursor = true; model.v_CanvasView.Cursor = Cursors.Pen; IShapeParent parent = model.vm_CanvasViewModel; // Tell the canvas view model that we are about to change the mode of 'object selection' // to one which allows us to connect things on the canvas. model.vm_CanvasViewModel.BeginCanvasViewMouseHandler( new CreateAssociationMouseHandler(model, UmlElementDataDef.CreateShape(this.mUmlType, dropPoint, parent) as UmlAssociationShapeViewModel)); }
public static UmlAssociationShapeViewModel ReadDocument(XmlReader reader, IShapeParent parent, UmlTypes umlType) { UmlAssociationShapeViewModel ret = UmlElementDataDef.CreateShape(umlType, new System.Windows.Point(UmlTypeToStringConverter.DefaultX, UmlTypeToStringConverter.DefaultY), parent) as UmlAssociationShapeViewModel; reader.ReadToNextSibling(ret.UmlDataTypeString); while (reader.MoveToNextAttribute()) { if (ret.ReadAttributes(reader.Name, reader.Value) == false) { if (reader.Name.Trim().Length > 0 && reader.Name != XmlComment) { throw new ArgumentException("XML node:'" + reader.Name + "' as child of '" + ret.UmlDataTypeString + "' is not supported."); } } } // Read child elements of this XML node while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Anchor": AnchorViewModel p = new AnchorViewModel(parent) { Left = 0, Top = 0 }; AnchorViewModel.ReadDocument(reader.ReadSubtree(), parent, p); ret.Add(p); break; default: throw new NotImplementedException(string.Format("'{0}' is not a valid sub-node of {1}", reader.Name, ret.XElementName)); } } } return(ret); }
/// <summary> /// Read shape from XML stream and return it. /// </summary> /// <param name="reader"></param> /// <param name="parent"></param> /// <param name="umlType"></param> /// <returns></returns> public static UmlNoteShapeViewModel ReadDocument(XmlReader reader, IShapeParent parent, UmlTypes umlType) { UmlNoteShapeViewModel ret = UmlElementDataDef.CreateShape(umlType, new System.Windows.Point(UmlTypeToStringConverter.DefaultX, UmlTypeToStringConverter.DefaultY), parent) as UmlNoteShapeViewModel; reader.ReadToNextSibling(ret.UmlDataTypeString); while (reader.MoveToNextAttribute()) { if (ret.ReadAttributes(reader.Name, reader.Value) == false) { if (reader.Name.Trim().Length > 0 && reader.Name != UmlShapeBaseViewModel.XmlComment) { throw new ArgumentException("XML node:'" + reader.Name + "' as child of '" + ret.XElementName + "' is not supported."); } } } // Read child elements of this XML node while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { string nodeName = reader.Name; string error; if ((error = ret.ReadXMLNode(nodeName, reader)) != string.Empty) { throw new NotImplementedException(error); } } } return(ret); }