Ejemplo n.º 1
0
		internal Attachment Clone()
		{
			Attachment clone = new Attachment();
			clone.node = node;
			clone.percents = percents;
			clone.attData = attData;
			clone.type = type;
			return clone;
		}
Ejemplo n.º 2
0
		private void updateLongestSegmAttachment(Attachment att, InteractionState ist)
		{
			int segment = ((Arrow)mainObj).getLongestHorzSegment();
			int n1 = 0, n2 = 0;

			switch (((Arrow)mainObj).Style)
			{
				case ArrowStyle.Bezier:
					n1 = segment * 3 + 1;
					n2 = n1 + 1;
					break;
				case ArrowStyle.Polyline:
				case ArrowStyle.Cascading:
					n1 = segment;
					n2 = segment + 1;
					break;
			}

			PointF ptCurr = Utilities.midPoint(
				((Arrow)mainObj).Points[n1],
				((Arrow)mainObj).Points[n2]);
			if (!flowChart.DisabledGroups)
			{
				float dx = ptCurr.X - att.node.getCenter().X;
				float dy = ptCurr.Y - att.node.getCenter().Y;
				att.node.modifyTranslate(dx, dy, true);
			}
		}
Ejemplo n.º 3
0
		private bool updateToSegmentAttachment(Attachment att, InteractionState ist)
		{
			int segment = att.attData;
			int n1 = 0, n2 = 0;
			if (((Arrow)mainObj).SegmentCount <= segment)
			{
				cycleProtect = false;
				new RemoveGroupCmd(MainObject, this).Execute();
				return false;
			}

			switch (((Arrow)mainObj).Style)
			{
				case ArrowStyle.Bezier:
					n1 = segment * 3 + 1;
					n2 = n1 + 1;
					break;
				case ArrowStyle.Polyline:
				case ArrowStyle.Cascading:
					n1 = segment;
					n2 = segment + 1;
					break;
			}

			PointF ptPrev = Utilities.midPoint(
				prevPoints[n1], prevPoints[n2]);
			PointF ptCurr = Utilities.midPoint(
				((Arrow)mainObj).Points[n1],
				((Arrow)mainObj).Points[n2]);

			if (flowChart.DisabledGroups)
				ptCurr = ptPrev;
			att.node.modifyTranslate(
				ptCurr.X - ptPrev.X, ptCurr.Y - ptPrev.Y, true);

			return true;
		}
Ejemplo n.º 4
0
		private bool updateToPointAttachment(Attachment att, InteractionState ist)
		{
			int point = att.attData;
			if (((Arrow)mainObj).Points.Count <= point)
			{
				cycleProtect = false;
				new RemoveGroupCmd(MainObject, this).Execute();
				return false;
			}

			PointF ptPrev = prevPoints[point];
			PointF ptCurr = ((Arrow)mainObj).Points[point];

			if(flowChart.DisabledGroups)
				ptCurr = ptPrev;
			att.node.modifyTranslate(
				ptCurr.X - ptPrev.X, ptCurr.Y - ptPrev.Y, true);

			return true;
		}
Ejemplo n.º 5
0
		private void updatePropAttachment(Attachment att, InteractionState ist)
		{
			if (!(mainObj is Node))
				return;

			Node mainNode = mainObj as Node;
			RectangleF rc = followMasterRotation ?
				mainNode.getRotatedBounds() : mainNode.getBoundingRect();
			float w = rc.Right - rc.Left;
			float h = rc.Bottom - rc.Top;

			RectangleF perc = att.percents;
			RectangleF rcNew = RectangleF.FromLTRB(
				rc.Left + w * perc.Left / 100,
				rc.Top + h * perc.Top / 100,
				rc.Left + w * perc.Right / 100,
				rc.Top + h * perc.Bottom / 100);

			if (!flowChart.DisabledGroups)
				att.node.setRect(rcNew);
		}
Ejemplo n.º 6
0
		private void updateSideMiddleAttachment(Attachment att, InteractionState ist)
		{
			int side;
			PointF ptPrev = new PointF(0, 0);
			PointF ptCurr = new PointF(0, 0);
			RectangleF rc;

			side = att.attData;
			switch(side)
			{
				case 0:
					ptPrev.X = prevRect.Left + prevRect.Width / 2;
					ptPrev.Y = prevRect.Top;
					rc = mainObj.getBoundingRect();
					ptCurr.X = rc.Left + rc.Width / 2;
					ptCurr.Y = rc.Top;
					break;
				case 1:
					ptPrev.X = prevRect.Right;
					ptPrev.Y = prevRect.Top + prevRect.Height / 2;
					rc = mainObj.getBoundingRect();
					ptCurr.X = rc.Right;
					ptCurr.Y = rc.Top + rc.Height / 2;
					break;
				case 2:
					ptPrev.X = prevRect.Left + prevRect.Width / 2;
					ptPrev.Y = prevRect.Bottom;
					rc = mainObj.getBoundingRect();
					ptCurr.X = rc.Left + rc.Width / 2;
					ptCurr.Y = rc.Bottom;
					break;
				case 3:
					ptPrev.X = prevRect.Left;
					ptPrev.Y = prevRect.Top + prevRect.Height / 2;
					rc = mainObj.getBoundingRect();
					ptCurr.X = rc.Left;
					ptCurr.Y = rc.Top + rc.Height / 2;
					break;
			}

			if (followMasterRotation && ist.SelectionHandle == 9 && mainObj is Node)
			{
				Node mainNode = mainObj as Node;
				float newAngle = mainNode.rotation();
				if (newAngle != prevRotation)
				{
					PointF pivot = mainNode.getCenter();
					PointF center = att.node.getCenter();
					float a = 0, r = 0;
					Geometry.Geometry2D.Convert.DekartToPolar(
						pivot, center, ref a, ref r);
					a -= newAngle - prevRotation;

					ptPrev = ptCurr = center;
					Geometry.Geometry2D.Convert.PolarToDekart(
						pivot, a,r, ref ptCurr);
				}
			}

			if (flowChart.DisabledGroups)
				ptCurr = ptPrev;
			att.node.modifyTranslate(
				ptCurr.X - ptPrev.X, ptCurr.Y - ptPrev.Y, true);
		}
Ejemplo n.º 7
0
		/// <summary>
		/// Adds an item to the group, attaching it to the middle point of a side of the master node
		/// </summary>
		/// <param name="node">The object to attach to the current group.</param>
		/// <param name="side">The corner to attach to.</param>
		public bool AttachToSideMiddle(Node node, int side)
		{
			if (!objAttachable(node)) return false;
			if (mainObj.getType() == ItemType.Arrow) return false;
			if (side < 0 || side > 3) return false;

			Attachment a = new Attachment();
			a.node = node;
			a.type = AttachTo.SideMiddle;
			a.attData = side;

			new GroupAttachCmd(this, a).Execute();

			return true;
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Attaches an item so its size maintains a constant ratio to master's size
		/// </summary>
		/// <param name="obj">The object to attach to the current group.</param>
		/// <param name="left"></param>
		/// <param name="top"></param>
		/// <param name="right"></param>
		/// <param name="bottom"></param>
		public bool AttachProportional(Node node,
			float left, float top, float right, float bottom)
		{
			if (!objAttachable(node)) return false;
			if (mainObj.getType() == ItemType.Arrow) return false;

			Attachment a = new Attachment();
			a.node = node;
			a.type = AttachTo.Proportional;
			a.percents = RectangleF.FromLTRB(
				left, top, right, bottom);

			new GroupAttachCmd(this, a).Execute();

			return true;
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Adds an item to the group, attaching it to a corner of the master node
		/// </summary>
		/// <param name="node">The object to attach to the current group.</param>
		/// <param name="corner">The corner to attach to.</param>
		public bool AttachToCorner(Node node, int corner)
		{
			if (!objAttachable(node)) return false;
			if (mainObj.getType() == ItemType.Arrow) return false;
			if (corner < 0 || corner > 3) return false;

			Attachment a = new Attachment();
			a.node = node;
			a.type = AttachTo.FixedCorner;
			a.attData = corner;

			new GroupAttachCmd(this, a).Execute();

			return true;
		}
Ejemplo n.º 10
0
		/// <summary>
		/// Adds an item to the group, maintaining its relative positions
		/// to master arrow's longest horizontal segment
		/// </summary>
		/// <param name="node">The object to attach to the current group.</param>
		public bool AttachToLongestHSegment(Node node)
		{
			if (!objAttachable(node)) return false;
			if (mainObj.getType() != ItemType.Arrow) return false;

			Attachment a = new Attachment();
			a.node = node;
			a.type = AttachTo.LongestHSegment;

			new GroupAttachCmd(this, a).Execute();

			return true;
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Adds an item to the group, attaching it to a segment of the master arrow
		/// </summary>
		/// <param name="node">The object to attach to the current group.</param>
		/// <param name="segment">The segment to attach to.</param>
		public bool AttachToArrowSegment(Node node, int segment)
		{
			if (!objAttachable(node)) return false;
			if (mainObj.getType() != ItemType.Arrow) return false;
			if (((Arrow)mainObj).SegmentCount <= segment) return false;

			Attachment a = new Attachment();
			a.node = node;
			a.type = AttachTo.ArrowSegment;
			a.attData = segment;

			new GroupAttachCmd(this, a).Execute();

			return true;
		}
Ejemplo n.º 12
0
		/// <summary>
		/// Used for undo/redo. Removes an Attachment instance from the internal list of attachments.
		/// </summary>
		internal void removeAttachment(Attachment attachment)
		{
			attachments.Remove(attachment);
			attachment.node.putInGroup(null);
			attachedObjects.Remove(attachment.node);
		}
Ejemplo n.º 13
0
		/// <summary>
		/// Used for undo/redo. Adds an existing Attachment instance to the internal list of attachments.
		/// </summary>
		internal void addAttachment(Attachment attachment, bool undoOp)
		{
			if (attachments == null)
				attachments = new ArrayList();

			attachments.Add(attachment);
			attachment.node.putInGroup(this);
			if (!undoOp)
				attachment.node.Visible = visible;
			attachedObjects.Add(attachment.node);
		}