Example #1
0
        /// <summary>
        /// Copies all properties and fields from the source template to this template.
        /// The shape and the model obejcts will be cloned.
        /// </summary>
        public void CopyFrom(Template source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.name        = source.name;
            this.title       = source.title;
            this.description = source.description;

            // Clone or copy shape
            if (this.shape == null)
            {
                this.shape = ShapeDuplicator.CloneShapeAndModelObject(source.shape);
            }
            else
            {
                this.shape.CopyFrom(source.shape);              // Template will be copied although this is not desirable
            }
            // copy connection point mapping
            this.connectionPointMappings.Clear();
            foreach (KeyValuePair <ControlPointId, TerminalId> item in source.connectionPointMappings)
            {
                this.connectionPointMappings.Add(item.Key, item.Value);
            }

            // copy property mapping
            this.propertyMappings.Clear();
            foreach (KeyValuePair <int, IModelMapping> item in source.propertyMappings)
            {
                this.propertyMappings.Add(item.Key, item.Value.Clone());
            }
        }
Example #2
0
        /// <summary>
        /// Creates a new shape from this template.
        /// </summary>
        /// <returns></returns>
        public Shape CreateShape()
        {
            Shape result = shape.Type.CreateInstance(this);

            if (shape.ModelObject != null)
            {
                ShapeDuplicator.CloneModelObjectOnly(result);
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// Creates a new shape from this template.
        /// </summary>
        public TShape CreateShape <TShape>() where TShape : Shape
        {
            TShape result = (TShape)_shape.Type.CreateInstance(this);

            if (_shape.ModelObject != null)
            {
                ShapeDuplicator.CloneModelObjectOnly(result);
            }
            return(result);
        }