public ConnectionCreator(Diagram diagram, Shape first, RelationshipType type)
 {
     this.diagram = diagram;
     this.type = type;
     this.first = first;
     firstSelected = true;
 }
Exemple #2
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="relativeShape"/> is null.
		/// </exception>
		public BendPoint(Shape relativeShape, bool relativeToStartShape)
		{
			if (relativeShape == null)
				throw new ArgumentNullException("relativeShape");

			this.relativeShape = relativeShape;
			this.relativeToStartShape = relativeToStartShape;
		}
		protected override bool CloneRelationship(Diagram diagram, Shape first, Shape second)
		{
			Comment comment = first.Entity as Comment;
			if (comment != null)
			{
				CommentRelationship clone = relationship.Clone(comment, second.Entity);
				return diagram.InsertCommentRelationship(clone);
			}
			else
			{
				return false;
			}
		}
		protected override bool CloneRelationship(Diagram diagram, Shape first, Shape second)
		{
			TypeBase firstType = first.Entity as TypeBase;
			InterfaceType secondType = second.Entity as InterfaceType;

			if (firstType != null && secondType != null)
			{
				RealizationRelationship clone = realization.Clone(firstType, secondType);
				return diagram.InsertRealization(clone);
			}
			else
			{
				return false;
			}
		}
Exemple #5
0
		protected override bool CloneRelationship(Diagram diagram, Shape first, Shape second)
		{
			CompositeType firstType = first.Entity as CompositeType;
			TypeBase secondType = second.Entity as TypeBase;
			
			if (firstType != null && secondType != null)
			{
				NestingRelationship clone = nesting.Clone(firstType, secondType);
				return diagram.InsertNesting(clone);
			}
			else
			{
				return false;
			}
		}
		protected override bool CloneRelationship(Diagram diagram, Shape first, Shape second)
		{
			TypeBase firstType = first.Entity as TypeBase;
			TypeBase secondType = second.Entity as TypeBase;

			if (firstType != null && secondType != null)
			{
				DependencyRelationship clone = dependency.Clone(firstType, secondType);
				return diagram.InsertDependency(clone);
			}
			else
			{
				return false;
			}
		}
		public void MouseMove(AbsoluteMouseEventArgs e)
		{
			Point mouseLocation = new Point((int) e.X, (int) e.Y);
			
			foreach (Shape shape in diagram.Shapes)
			{
				if (shape.BorderRectangle.Contains(mouseLocation))
				{
					if (!firstSelected)
					{
						if (first != shape)
						{
							first = shape;
							diagram.Redraw();
						}
					}
					else
					{
						if (second != shape)
						{
							second = shape;
							diagram.Redraw();
						}
					}
					return;
				}
			}

			if (!firstSelected)
			{
				if (first != null)
				{
					first = null;
					diagram.Redraw();
				}
			}
			else
			{
				if (second != null)
				{
					second = null;
					diagram.Redraw();
				}
			}
		}
		/// <exception cref="ArgumentNullException">
		/// <paramref name="relationship"/> is null.-or-
		/// <paramref name="startShape"/> is null.-or-
		/// <paramref name="endShape"/> is null.
		/// </exception>
		protected Connection(Relationship relationship, Shape startShape, Shape endShape)
		{
			if (relationship == null)
				throw new ArgumentNullException("relationship");
			if (startShape == null)
				throw new ArgumentNullException("startShape");
			if (endShape == null)
				throw new ArgumentNullException("endShape");

			this.startShape = startShape;
			this.endShape = endShape;
			InitOrientations();
			bendPoints.Add(new BendPoint(startShape, true));
			bendPoints.Add(new BendPoint(endShape, false));

			startShape.Move += ShapeMoving;
			startShape.Resize += StartShapeResizing;
			endShape.Move += ShapeMoving;
			endShape.Resize += EndShapeResizing;

			relationship.Modified += delegate { OnModified(EventArgs.Empty); };

			relationship.Detaching += delegate
			{
				startShape.Move -= ShapeMoving;
				startShape.Resize -= StartShapeResizing;
				endShape.Move -= ShapeMoving;
				endShape.Resize -= EndShapeResizing;
			};
			relationship.Serializing += delegate(object sender, SerializeEventArgs e)
			{
				OnSerializing(e);
			};
			relationship.Deserializing += delegate(object sender, SerializeEventArgs e)
			{
				OnDeserializing(e);
			};
			Reroute();
		}
		protected abstract bool CloneRelationship(Diagram diagram, Shape first, Shape second);
Exemple #10
0
		protected void Reverse()
		{
			Shape shape = startShape;
			startShape = endShape;
			endShape = shape;

			LineOrientation orientation = startOrientation;
			startOrientation = endOrientation;
			endOrientation = orientation;

			bendPoints.Reverse();
			RouteCache.Reverse();
			foreach (BendPoint point in BendPoints)
			{
				point.RelativeToStartShape = !point.RelativeToStartShape;
			}

			NeedsRedraw = true;
		}
		/// <exception cref="ArgumentNullException">
		/// <paramref name="generalization"/> is null.-or-
		/// <paramref name="startShape"/> is null.-or-
		/// <paramref name="endShape"/> is null.
		/// </exception>
		public Generalization(GeneralizationRelationship generalization, Shape startShape, Shape endShape)
			: base(generalization, startShape, endShape)
		{
			this.generalization = generalization;
		}
Exemple #12
0
		protected internal Connection Paste(Diagram diagram, Size offset,
			Shape first, Shape second)
		{
			if (CloneRelationship(diagram, first, second))
			{
				Connection connection = diagram.ConnectionList.FirstValue;
				connection.IsSelected = true;

				connection.startOrientation = this.startOrientation;
				connection.endOrientation = this.endOrientation;
				connection.bendPoints.Clear();
				foreach (BendPoint point in this.bendPoints)
				{
					Shape relativeShape = point.RelativeToStartShape ? first : second;
					BendPoint newPoint = new BendPoint(relativeShape,
						point.RelativeToStartShape, point.AutoPosition);
					newPoint.Location = point.Location + offset;
					connection.bendPoints.Add(newPoint);
				}
				connection.Reroute();

				return connection;
			}
			else
			{
				return null;
			}
		}
		/// <exception cref="ArgumentNullException">
		/// <paramref name="relationship"/> is null.-or-
		/// <paramref name="startShape"/> is null.-or-
		/// <paramref name="endShape"/> is null.
		/// </exception>
		public CommentConnection(CommentRelationship relationship, Shape startShape, Shape endShape)
			: base(relationship, startShape, endShape)
		{
			this.relationship = relationship;
		}
		protected override bool CloneRelationship(Diagram diagram, Shape first, Shape second)
		{
			CompositeType firstType = first.Entity as CompositeType;
			CompositeType secondType = second.Entity as CompositeType;

			if (firstType != null && secondType != null)
			{
				GeneralizationRelationship clone = generalization.Clone(firstType, secondType);
				return diagram.InsertGeneralization(clone);
			}
			else
			{
				return false;
			}
        }
		/// <exception cref="ArgumentNullException">
		/// <paramref name="realization"/> is null.-or-
		/// <paramref name="startShape"/> is null.-or-
		/// <paramref name="endShape"/> is null.
		/// </exception>
		public Realization(RealizationRelationship realization, Shape startShape, Shape endShape)
			: base(realization, startShape, endShape)
		{
			this.realization = realization;
		}
Exemple #16
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="nesting"/> is null.-or-
		/// <paramref name="startShape"/> is null.-or-
		/// <paramref name="endShape"/> is null.
		/// </exception>
		public Nesting(NestingRelationship nesting, Shape startShape, Shape endShape)
			: base(nesting, startShape, endShape)
		{
			this.nesting = nesting;
		}
Exemple #17
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="dependency"/> is null.-or-
		/// <paramref name="startShape"/> is null.-or-
		/// <paramref name="endShape"/> is null.
		/// </exception>
		public Dependency(DependencyRelationship dependency, Shape startShape, Shape endShape)
			: base(dependency, startShape, endShape)
		{
			this.dependency = dependency;
		}
		/// <exception cref="ArgumentNullException">
		/// <paramref name="association"/> is null.-or-
		/// <paramref name="startShape"/> is null.-or-
		/// <paramref name="endShape"/> is null.
		/// </exception>
		public Association(AssociationRelationship association, Shape startShape, Shape endShape)
			: base(association, startShape, endShape)
		{
			this.association = association;
			association.Reversed += new EventHandler(association_Reversed);
		}
Exemple #19
0
 protected virtual void CopyFrom(Shape shape)
 {
     location = shape.location;
     size = shape.size;
 }
Exemple #20
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="relativeShape"/> is null.
		/// </exception>
		public BendPoint(Shape relativeShape, bool relativeToStartShape, bool autoPosition)
			: this(relativeShape, relativeToStartShape)
		{
			this.autoPosition = autoPosition;
		}
		public void AddShape(Shape shape)
		{
			shapes.Add(shape);
			pastedShapes.Add(shape, null);
		}