コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
        private PageViewModel ReadXML(XmlReader reader,
                                      IShapeParent docDataModel,
                                      PageViewModel root,
                                      out List <ShapeViewModelBase> docRoot)
        {
            docRoot = new List <ShapeViewModelBase>();

            reader.ReadToNextSibling(PageViewModel.XmlElementName);
            while (reader.MoveToNextAttribute())
            {
                if (root.ReadAttribute(reader.Name, reader.Value) == false)
                {
                    return(root);
                }
            }

            // Read child elements of this XML node
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    string nodeName = reader.Name;

                    object o = this.ConvertBack(nodeName, nodeName.GetType(), null, CultureInfo.InvariantCulture);

                    if ((o is UmlTypes) == false)
                    {
                        throw new ArgumentException("Node name: '" + nodeName + "' is not supported.");
                    }

                    UmlTypes umlType = (UmlTypes)o;

                    if (umlType == UmlTypes.Undefined)
                    {
                        throw new ArgumentException("Undefined node name: '" + nodeName + "' in conversion is not supported.");
                    }

                    ShapeViewModelBase s = null;

                    try
                    {
                        s = UmlElementDataDef.ReadShape(reader, umlType, docDataModel);

                        if (s != null)
                        {
                            docRoot.Add(s);
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }

            return(root);
        }
コード例 #4
0
    /// <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));
    }
コード例 #5
0
        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);
        }
コード例 #6
0
        /// <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);
        }