Example #1
0
		private bool pasteSelection(FlowChart doc, ItemsAndGroups data,
			CompositeCmd cmd, float dx, float dy)
		{
			if (data.items.Count == 0) return false;
			doc.Selection.Clear();

			// add nodes
			foreach (ChartObject item in data.items)
			{
				if (item is Node)
				{
					doc.Add(item);
					doc.Selection.AddObject(item);
				}
			}

			Hashtable arrowPoints = null;
			if (dx != 0 || dy != 0)
				arrowPoints = new Hashtable();

			foreach (ChartObject item in data.items)
			{
				if (item is Arrow)
				{
					Arrow arrow = item as Arrow;

					doc.Add(arrow);
					doc.Selection.AddObject(arrow);

					if (arrowPoints != null)
						arrowPoints.Add(arrow, arrow.ControlPoints.Clone());
				}
			}

			// add groups
			foreach (Group group in data.groups)
				doc.Add(group);

			if (dx != 0 || dy != 0)
			{
				// offset nodes
				foreach (ChartObject item in data.items)
				{
					if (item is Node && item.MasterGroup == null)
					{
						ModifyItemCmd mc = (cmd == null) ? null : new ModifyItemCmd(item);

						Node node = item as Node;
						RectangleF rect = node.BoundingRect;
						rect.Offset(dx, dy);
						node.BoundingRect = rect;

						if (mc != null)
						{
							mc.Execute(true);
							cmd.AddSubCmd(mc);
						}
					}
				}

				// offset arrows
				foreach (ChartObject item in data.items)
				{
					if (item is Arrow)
					{
						ModifyItemCmd mc = (cmd == null) ? null : new ModifyItemCmd(item);

						Arrow arrow = item as Arrow;
						arrow.Points = arrowPoints[arrow] as PointCollection;
						for (int i = 0; i < arrow.ControlPoints.Count; ++i)
						{
							PointF pt = arrow.ControlPoints[i];
							arrow.ControlPoints[i] = new PointF(pt.X + dx, pt.Y + dy);
						}
						arrow.UpdateFromPoints();

						if (mc != null)
						{
							mc.Execute(true);
							cmd.AddSubCmd(mc);
						}
					}
				}
			}

			return true;
		}
Example #2
0
			protected override void OnMouseDown(MouseEventArgs e)
			{
				base.OnMouseDown(e);

				if (!_enableGuides)
					return;

				if (e.Button != MouseButtons.Left)
					return;

				if (_parent.Document == null)
					return;

				FlowChart doc = _parent.Document;

				// Record undo operation
				_command = null;
				if (doc.UndoManager.UndoEnabled)
				{
					_command = new CompositeCmd(doc, "Align");
					foreach (ChartObject obj in doc.Objects)
						_command.AddSubCmd(new ModifyItemCmd(obj));
				}

				// Begin align action
				Capture = true;
				_aligning = true;
				_alignedNodes.Clear();
				_ptInitial = doc.ClientToDoc(new Point(e.X, e.Y));
				_ptCurrent = _ptInitial;
				_align = AlignStart.Undetermined;
			}
Example #3
0
		public CompositeCmd StartComposite(string title, bool saveZOrder)
		{
			if (!undoEnabled) return null;

			if (currCompositeCmd != null)
				return currCompositeCmd;

			currCompositeCmd = new CompositeCmd(document, title, saveZOrder);
			currCompositeCmd.setContext(defaultCmdContext);
			return currCompositeCmd;
		}
Example #4
0
		// tree collapse or expand

		internal void onStartExpand()
		{
			if (!undoEnabled) return;

			currExpandCmd = new CompositeCmd(document, "Expand");
		}
Example #5
0
		// save positions of all items on layout

		internal void onStartLayout(string title)
		{
			if (!undoEnabled) return;

			currLayoutCmd = new CompositeCmd(document, title);
			foreach (ChartObject item in document.Objects)
				currLayoutCmd.AddSubCmd(new ModifyItemCmd(item));
		}
Example #6
0
		// arrow routing - just create a composite of arrow modifications

		internal void onStartRoute()
		{
			if (!undoEnabled) return;
			currRouteCmd = new CompositeCmd(document, "Route");
		}