Example #1
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);
        }
Example #2
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());
        }