Esempio n. 1
0
 public BendPointEventArgs(BendPoint point)
 {
     this.point = point;
 }
Esempio n. 2
0
		protected override void OnMouseUp(AbsoluteMouseEventArgs e)
		{
			base.OnMouseUp(e);
			selectedBendPoint = null;
		}
Esempio n. 3
0
		protected virtual void OnDeserializing(SerializeEventArgs e)
		{
			// Old file format
			XmlElement oldStartNode = e.Node["StartNode"];
			XmlElement oldEndNode = e.Node["EndNode"];
			if (oldStartNode != null && oldEndNode != null)
			{
				bool isHorizontal;
				bool.TryParse(oldStartNode.GetAttribute("isHorizontal"), out isHorizontal);
				startOrientation = (isHorizontal) ? LineOrientation.Horizontal : LineOrientation.Vertical;
				bool.TryParse(oldEndNode.GetAttribute("isHorizontal"), out isHorizontal);
				endOrientation = (isHorizontal) ? LineOrientation.Horizontal : LineOrientation.Vertical;

				int startLocation, endLocation;
				int.TryParse(oldStartNode.GetAttribute("location"), out startLocation);
				int.TryParse(oldEndNode.GetAttribute("location"), out endLocation);

				Reroute();
				if (startOrientation == LineOrientation.Vertical)
					FirstBendPoint.X = startShape.Left + startLocation;
				else
					FirstBendPoint.Y = startShape.Top + startLocation;

				if (endOrientation == LineOrientation.Vertical)
					LastBendPoint.X = endShape.Left + endLocation;
				else
					LastBendPoint.Y = endShape.Top + endLocation;

				FirstBendPoint.AutoPosition = false;
				LastBendPoint.AutoPosition = false;
				Reroute();
			}
			else
			{
				// New file format
				XmlElement startNode = e.Node["StartOrientation"];
				if (startNode != null)
				{
					if (startNode.InnerText == "Horizontal")
						startOrientation = LineOrientation.Horizontal;
					else
						startOrientation = LineOrientation.Vertical;
				}
				XmlElement endNode = e.Node["EndOrientation"];
				if (endNode != null)
				{
					if (endNode.InnerText == "Horizontal")
						endOrientation = LineOrientation.Horizontal;
					else
						endOrientation = LineOrientation.Vertical;
				}

				if (startNode != null && endNode != null) // To be sure it's the new file format
				{
					bendPoints.Clear();

					XmlNodeList nodes = e.Node.SelectNodes("child::BendPoint");
					foreach (XmlElement node in nodes)
					{
						bool relativeToStartShape;
						bool.TryParse(node.GetAttribute("relativeToStartShape"), out relativeToStartShape);
						Shape relativeShape = relativeToStartShape ? startShape : endShape;

						BendPoint point = new BendPoint(relativeShape, relativeToStartShape, false);
						point.Deserialize(node);
						bendPoints.Add(point);
					}
					if (bendPoints.Count == 0 || !FirstBendPoint.RelativeToStartShape)
						bendPoints.AddFirst(new BendPoint(startShape, true));
					if (LastBendPoint.RelativeToStartShape)
						bendPoints.Add(new BendPoint(endShape, false));
				}
				Reroute();
			}
		}
Esempio n. 4
0
		protected internal Connection Paste(IDiagram diagram, Size offset,
			Shape first, Shape second)
		{
			if (CloneRelationship(diagram, first, second))
			{
			    var connectionList = (ElementList<Connection>) diagram.Connections;
				Connection connection = 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;
			}
		}
Esempio n. 5
0
		protected override void OnMouseMove(AbsoluteMouseEventArgs e)
		{
			base.OnMouseMove(e);

			//TODO: szebb lenne külön eljárásba tenni
			if (e.Button == MouseButtons.Left && selectedBendPoint != null)
			{
				Point newLocation = Point.Truncate(e.Location);

				if (selectedBendPoint.Location != newLocation)
				{
					if (!copied && Control.ModifierKeys == Keys.Control)
					{
						BendPoint newPoint = (BendPoint) selectedBendPoint.Clone();
						newPoint.Location = newLocation;
						if (selectedBendPoint.RelativeToStartShape)
							bendPoints.AddAfter(bendPoints.Find(selectedBendPoint), newPoint);
						else
							bendPoints.AddBefore(bendPoints.Find(selectedBendPoint), newPoint);
						selectedBendPoint = newPoint;
						copied = true;
						OnBendPointMove(new BendPointEventArgs(selectedBendPoint));
					}
					else
					{
						selectedBendPoint.Location = newLocation;
						OnBendPointMove(new BendPointEventArgs(selectedBendPoint));
					}

					Reroute();
					OnRouteChanged(EventArgs.Empty);
					OnModified(EventArgs.Empty);
				}
			}
		}
Esempio n. 6
0
		private bool BendPointPressed(AbsoluteMouseEventArgs e)
		{
			BendPoint point = GetBendPoint(e);

			selectedBendPoint = point;
			if (point != null)
			{
				if (point.AutoPosition)
				{
					point.AutoPosition = false;
					Reroute();
					OnRouteChanged(EventArgs.Empty);
					OnModified(EventArgs.Empty);
				}
				return true;
			}
			else
			{
				return false;
			}
		}
Esempio n. 7
0
 public BendPointEventArgs(BendPoint point)
 {
     BendPoint = point;
 }
Esempio n. 8
0
		public BendPointEventArgs(BendPoint point)
		{
			this.point = point;
		}