Esempio n. 1
0
 /// <summary>
 /// Standard contructor hidding XElement constructor
 /// </summary>
 public UmlNoteShapeViewModel(IShapeParent parent,
                              UmlTypes umlType)
     : base(parent,
            ShapeViewModelKey.NoteShape, ShapeViewModelSubKeys.None,
            umlType)
 {
 }
Esempio n. 2
0
        /// <summary>
        /// Create a command viewmodel that has the command functionality
        /// to create a corresponding shape viewmodel.
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="umlType"></param>
        /// <returns></returns>
        public CommandModelBase GetShapeCreateCommand(PluginViewModel viewModel, UmlTypes umlType)
        {
            DataDef item;

            if (UmlElementDataDef.mUmlElements.TryGetValue(umlType, out item) == true)
            {
                switch (item.ImplementingViewModel)
                {
                case ShapeViewModelKey.SquareShape:
                case ShapeViewModelKey.DecisionShape:
                case ShapeViewModelKey.PackageShape:
                case ShapeViewModelKey.BoundaryShape:
                case ShapeViewModelKey.NoteShape:
                case ShapeViewModelKey.NodeShape:
                case ShapeViewModelKey.UseCaseShape:
                case ShapeViewModelKey.CanvasShape:
                    return(new CreateShapeCommandModel(viewModel, umlType,
                                                       item.ToolBoxDescription, item.ToolboxName, item.ToolboxImageUrl));

                // Create connector command viewmodels
                case ShapeViewModelKey.AssocationShape:
                    return(new CreateAssociationCommandModel(viewModel,
                                                             item.ToolboxImageUrl,
                                                             umlType,
                                                             item.ToolboxName,
                                                             item.ToolBoxDescription));

                case ShapeViewModelKey.Undefined:
                default:
                    throw new NotImplementedException(umlType.ToString());
                }
            }

            throw new NotImplementedException(string.Format("System error: '{0}' not supported in CreateCommand.", umlType));
        }
Esempio n. 3
0
        /// <summary>
        /// Create a shape viewwmodel that represents a canvas element.
        /// </summary>
        /// <param name="dropPoint"></param>
        /// <returns></returns>
        private static ShapeViewModelBase CreateAssocationShapeViewModel(Point dropPoint,
                                                                         IShapeParent parent,
                                                                         DataDef item,
                                                                         UmlTypes umlType)
        {
            var element = new UmlUseCaseShapeViewModel(parent, umlType);

            switch (umlType)
            {
            case UmlTypes.ConnectorAggregation:
                return(new UmlAssociationShapeViewModel(parent, ConnectorKeys.WhiteDiamond, ConnectorKeys.None, UmlTypes.ConnectorAggregation));

            case UmlTypes.ConnectorAssociation:
                return(new UmlAssociationShapeViewModel(parent, ConnectorKeys.None, ConnectorKeys.None, UmlTypes.ConnectorAssociation));

            case UmlTypes.ConnectorComposition:
                return(new UmlAssociationShapeViewModel(parent, ConnectorKeys.BlackDiamond, ConnectorKeys.None, UmlTypes.ConnectorComposition));

            case UmlTypes.ConnectorInheritance:
                return(new UmlAssociationShapeViewModel(parent, ConnectorKeys.None, ConnectorKeys.Triangle, UmlTypes.ConnectorInheritance));

            default:
                throw new System.NotImplementedException(umlType.ToString());
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 /// <summary>
 /// Standard contructor hidding XElement constructor
 /// </summary>
 public UmlCanvasShapeViewModel(IShapeParent parent,
                                ShapeViewModelSubKeys canvasShape,
                                UmlTypes umlType)
     : base(parent,
            ShapeViewModelKey.CanvasShape, canvasShape, umlType)
 {
     this.mCanvasShape = canvasShape;
 }
Esempio n. 6
0
 /// <summary>
 /// Standard contructor hidding XElement constructor
 /// </summary>
 public UmlUseCaseShapeViewModel(IShapeParent parent,
                                 UmlTypes umlType)
     : base(parent,
            ShapeViewModelKey.UseCaseShape, ShapeViewModelSubKeys.None,
            umlType)
 {
     this.MinHeight = 50;
     this.MinWidth  = 50;
 }
Esempio n. 7
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);
        }
    /// <summary>
    /// Standard cosntructor
    /// </summary>
    public CreateAssociationCommandModel(PluginViewModel viewModel,
                                         string toolboxImageUrl,
                                         UmlTypes umlType,
                                         string toolBoxName,
                                         string toolBoxDescription)
    {
      this.mViewModel = viewModel;

      this.ToolBoxImageUrl = toolboxImageUrl;
      this.mUmlType = umlType;
      this.mToolBoxName = toolBoxName;
      this.mToolBoxDescription = toolBoxDescription;
    }
Esempio n. 9
0
        /// <summary>
        /// Standard constructor
        /// </summary>
        /// <param name="viewModel"></param>
        public CreateShapeCommandModel(PluginViewModel viewModel,
                                       UmlTypes umlType,
                                       string description,
                                       string displayName,
                                       string toolboxImageUrl)
        {
            this.mViewModel = viewModel;
            this.mUmlType   = umlType;

            this.mDescription    = description;
            this.mDisplayName    = displayName;
            this.ToolBoxImageUrl = toolboxImageUrl;
        }
        /// <summary>
        /// Standard contructor hidding XElement constructor
        /// </summary>
        public UmlAssociationShapeViewModel(IShapeParent parent,
                                            ConnectorKeys fromConnectorKey,
                                            ConnectorKeys toConnectorKey,
                                            UmlTypes umlType)
            : base(parent)
        {
            this.mUmlType          = umlType;
            this.mFromConnectorKey = fromConnectorKey;
            this.mToConnectorKey   = toConnectorKey;

            this.mElementName = UmlTypeToStringConverter.Instance.Convert(umlType, umlType.GetType(), null,
                                                                          System.Globalization.CultureInfo.InvariantCulture) as string;
        }
Esempio n. 11
0
        /// <summary>
        /// Create a shape viewwmodel that represents a canvas element.
        /// </summary>
        /// <param name="dropPoint"></param>
        /// <returns></returns>
        private static ShapeViewModelBase CreateCanvasShapeViewModel(Point dropPoint,
                                                                     IShapeParent parent,
                                                                     DataDef item,
                                                                     UmlTypes umlType)
        {
            var element = new UmlCanvasShapeViewModel(parent, item.ShapeViewModelSubKey, umlType);

            element.Name   = item.ShapeName;
            element.Top    = dropPoint.Y;
            element.Left   = dropPoint.X;
            element.Width  = item.DefaultWidth;
            element.Height = item.DefaultHeight;

            return(element);
        }
Esempio n. 12
0
        /// <summary>
        /// Standard constructor
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="ElementName"></param>
        /// <param name="shapeKey"></param>
        /// <param name="shapeViewModelSubKeys"></param>
        public UmlShapeBaseViewModel(IShapeParent parent,
                                     ShapeViewModelKey shapeKey,
                                     ShapeViewModelSubKeys shapeViewModelSubKeys,
                                     UmlTypes umlType)
            : base(parent)
        {
            this.mShapeKey = shapeKey;
            this.mShapeViewModelSubKeys = shapeViewModelSubKeys;
            this.mUmlType = umlType;

            this.mComments = new ObservableCollection <CommentViewModel>();

            this.mElementName = UmlTypeToStringConverter.Instance.Convert(umlType, umlType.GetType(), null,
                                                                          CultureInfo.InvariantCulture) as string;
        }
Esempio n. 13
0
        /// <summary>
        /// Create a shape viewwmodel that represents a canvas element.
        /// </summary>
        /// <param name="dropPoint"></param>
        /// <returns></returns>
        private static ShapeViewModelBase CreateNoteShapeViewModel(Point dropPoint,
                                                                   IShapeParent parent,
                                                                   DataDef item,
                                                                   UmlTypes umlType)
        {
            var element = new UmlNoteShapeViewModel(parent, umlType);

            element.Text   = item.ToolboxName;
            element.Top    = dropPoint.Y;
            element.Left   = dropPoint.X;
            element.Width  = item.DefaultWidth;
            element.Height = item.DefaultHeight;

            return(element);
        }
        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);
        }
Esempio n. 15
0
        /// <summary>
        /// Create a shape viewwmodel that represents a canvas element.
        /// </summary>
        /// <param name="dropPoint"></param>
        /// <returns></returns>
        private static ShapeViewModelBase CreateUseCaseShapeViewModel(Point dropPoint,
                                                                      IShapeParent parent,
                                                                      DataDef item,
                                                                      UmlTypes umlType)
        {
            var element = new UmlUseCaseShapeViewModel(parent, umlType);

            element.Name            = item.ShapeName;
            element.Top             = dropPoint.Y;
            element.Left            = dropPoint.X;
            element.Width           = item.DefaultWidth;
            element.Height          = item.DefaultHeight;
            element.StrokeDashArray = (item.StrokeDashArray == null ? string.Empty : item.StrokeDashArray);

            return(element);
        }
Esempio n. 16
0
        /// <summary>
        /// Create a shape viewwmodel that represents a canvas element.
        /// </summary>
        /// <param name="dropPoint"></param>
        /// <returns></returns>
        private static ShapeViewModelBase CreateNodeShapeViewModel(Point dropPoint,
                                                                   IShapeParent parent,
                                                                   DataDef item,
                                                                   UmlTypes umlType)
        {
            var element = new UmlNodeShapeViewModel(parent, umlType);

            element.Stereotype    = item.ShapeStereotype == null ? string.Empty : item.ShapeStereotype;
            element.Name          = item.ShapeName;
            element.ShapeImageUrl = item.ShapeImageUrl == null ? string.Empty : item.ShapeImageUrl;
            element.Top           = dropPoint.Y;
            element.Left          = dropPoint.X;
            element.Width         = item.DefaultWidth;
            element.Height        = item.DefaultHeight;

            return(element);
        }
Esempio n. 17
0
        /// <summary>
        /// Create a shape viewmodel and return it.
        /// </summary>
        /// <param name="umlType"></param>
        /// <param name="dropPoint"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static ShapeViewModelBase CreateShape(UmlTypes umlType, Point dropPoint, IShapeParent parent)
        {
            DataDef item;

            if (UmlElementDataDef.mUmlElements.TryGetValue(umlType, out item) == true)
            {
                switch (item.ImplementingViewModel)
                {
                case ShapeViewModelKey.SquareShape:
                    return(CreateSquareShapeViewModel(dropPoint, parent, item, umlType));

                case ShapeViewModelKey.DecisionShape:
                    return(CreateDecisionShapeViewModel(dropPoint, parent, item, umlType));

                case ShapeViewModelKey.PackageShape:
                    return(CreatePackageShapeViewModel(dropPoint, parent, item, umlType));

                case ShapeViewModelKey.BoundaryShape:
                    return(CreateBoundaryShapeViewModel(dropPoint, parent, item, umlType));

                case ShapeViewModelKey.NoteShape:
                    return(CreateNoteShapeViewModel(dropPoint, parent, item, umlType));

                case ShapeViewModelKey.NodeShape:
                    return(CreateNodeShapeViewModel(dropPoint, parent, item, umlType));

                case ShapeViewModelKey.UseCaseShape:
                    return(CreateUseCaseShapeViewModel(dropPoint, parent, item, umlType));

                case ShapeViewModelKey.CanvasShape:
                    return(CreateCanvasShapeViewModel(dropPoint, parent, item, umlType));

                case ShapeViewModelKey.AssocationShape:
                    return(CreateAssocationShapeViewModel(dropPoint, parent, item, umlType));

                case ShapeViewModelKey.Undefined:
                default:
                    throw new NotImplementedException(string.Format("System error: '{0}' not supported in CreateShape.", umlType));
                }
            }

            throw new NotImplementedException(umlType.ToString());
        }
Esempio n. 18
0
        /// <summary>
        /// Create a shape viewwmodel that represents a canvas element.
        /// </summary>
        /// <param name="dropPoint"></param>
        /// <returns></returns>
        private static ShapeViewModelBase CreateDecisionShapeViewModel(Point dropPoint,
                                                                       IShapeParent parent,
                                                                       DataDef item,
                                                                       UmlTypes umlType)
        {
            var element = new UmlDecisionShapeViewModel(parent, umlType);

            element.Name = item.ShapeName;

            if (dropPoint == null)
            {
                dropPoint = new Point(100, 100);
            }

            element.Top  = dropPoint.Y;
            element.Left = dropPoint.X;

            element.Width  = item.DefaultWidth;
            element.Height = item.DefaultHeight;

            return(element);
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        /// <summary>
        /// Get a create commandmodel instance for the matching <seealso cref="UmlTypes"/> parameter.
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="umlType"></param>
        /// <returns></returns>
        public CommandModelBase GetCreateUmlShapeCommandModel(PluginViewModel viewModel, UmlTypes umlType)
        {
            if (this.mUmlElementFactory == null)
            {
                this.mUmlElementFactory = new UmlElementDataDef();
            }

            return(this.mUmlElementFactory.GetShapeCreateCommand(viewModel, umlType));
        }
Esempio n. 21
0
        /// <summary>
        /// Read a shapes configiration information from persistence and return the new shape view model.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="umlType"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static ShapeViewModelBase ReadShape(XmlReader reader, UmlTypes umlType, IShapeParent parent)
        {
            switch (umlType)
            {
            case UmlTypes.Primitive:
            case UmlTypes.DataType:
            case UmlTypes.Signal:
            case UmlTypes.Class:
            case UmlTypes.Interface:
            case UmlTypes.Table:
            case UmlTypes.Enumeration:
            case UmlTypes.Component:
                return(UmlSquareShapeViewModel.ReadDocument(reader.ReadSubtree(), parent, umlType));

            case UmlTypes.Decision:
                return(UmlDecisionShapeViewModel.ReadDocument(reader.ReadSubtree(), parent, umlType));

            case UmlTypes.Package:
                return(UmlPackageShapeViewModel.ReadDocument(reader.ReadSubtree(), parent, umlType));

            case UmlTypes.Boundary:
                return(UmlBoundaryShapeViewModel.ReadDocument(reader.ReadSubtree(), parent, umlType));

            case UmlTypes.Note:
                return(UmlNoteShapeViewModel.ReadDocument(reader.ReadSubtree(), parent, umlType));

            case UmlTypes.Node:
            case UmlTypes.Device:
            case UmlTypes.DeploymentSpec:
                return(UmlNodeShapeViewModel.ReadDocument(reader.ReadSubtree(), parent, umlType));

            case UmlTypes.Collaboration:
            case UmlTypes.UseCase:
                return(UmlUseCaseShapeViewModel.ReadDocument(reader.ReadSubtree(), parent, umlType));

            case UmlTypes.CanvasShape:
            case UmlTypes.Actor:
            case UmlTypes.Actor1:
            case UmlTypes.ActivityInitial:
            case UmlTypes.ActivityFinal:
            case UmlTypes.ActivityFlowFinal:
            case UmlTypes.ActivitySync:
            case UmlTypes.Event1:
            case UmlTypes.Event2:
            case UmlTypes.Action1:
            case UmlTypes.Action2:
            case UmlTypes.ExecutionEnvironment:
                return(UmlCanvasShapeViewModel.ReadDocument(reader.ReadSubtree(), parent, umlType));

            case UmlTypes.ConnectorAggregation:
            case UmlTypes.ConnectorAssociation:
            case UmlTypes.ConnectorComposition:
            case UmlTypes.ConnectorInheritance:
                return(UmlAssociationShapeViewModel.ReadDocument(reader.ReadSubtree(), parent, umlType));

            case UmlTypes.Undefined:
            default:
                throw new NotImplementedException(string.Format("System error: '{0}' not supported in ReadShape.", umlType));
            }

            throw new NotImplementedException(umlType.ToString());
        }