예제 #1
0
        protected override void Deserialize(XmlElement e)
        {
            // New file format
            XmlElement startNode = e["StartOrientation"];
            if (startNode != null)
            {
                if (startNode.InnerText == "Horizontal")
                    startOrientation = LineOrientation.Horizontal;
                else
                    startOrientation = LineOrientation.Vertical;
            }
            XmlElement endNode = e["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.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();
        }
예제 #2
0
		protected override void OnMouseUp(AbsoluteMouseEventArgs e)
		{
			base.OnMouseUp(e);
			selectedBendPoint = null;
		}
예제 #3
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;
			}
		}
예제 #4
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);
				}
			}
		}
예제 #5
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;
			}
		}
예제 #6
0
		public BendPointEventArgs(BendPoint point)
		{
			this.point = point;
		}