private void updateNSARect(ChartObject obj) { RectangleF rcObj = obj.getRepaintRect(true); if (obj.getType() == ItemType.Arrow) { Arrow arrow = (Arrow)obj; arrow.updatePosFromOrgAndDest(false); } }
private void updateNSARect(ChartObject obj) { RectangleF rcObj = obj.getRepaintRect(true); if (obj.getType() == ItemType.Arrow) { Arrow arrow = (Arrow)obj; arrow.updatePosFromOrgAndDest(false); } }
public void BringIntoView(ChartObject obj) { if (obj != null) { // get the currently visible document area Graphics g = CreateGraphics(); setTransforms(g); RectangleF rcClient = Utilities.deviceToDoc(g, this.ClientRectangle); // check if the objects is entirely in the visible area RectangleF rcObj = obj.getRepaintRect(false); if (rcObj.Left < rcClient.Left || rcObj.Right > rcClient.Right || rcObj.Top < rcClient.Top || rcObj.Bottom > rcClient.Bottom) { // scroll to center the object in the visible area float cx = (rcObj.Left + rcObj.Right - rcClient.Width) / 2; float cy = (rcObj.Top + rcObj.Bottom - rcClient.Height) / 2; if (cx < docExtents.Left) cx = docExtents.Left; else if (cx > docExtents.Right - rcClient.Width) cx = docExtents.Right - rcClient.Width; if (cy < docExtents.Top) cy = docExtents.Top; else if (cy > docExtents.Bottom - rcClient.Height) cy = docExtents.Bottom - rcClient.Height; ScrollTo(cx, cy); } } }
/// <summary> /// Adds the specified item to the flowchart. /// </summary> /// <param name="item">A new item that should be added to the flowchart.</param> /// <param name="select">Specifies whether the item should be selected /// after adding it to the flowchart.</param> public void Add(ChartObject item, bool select) { // validity checks can be disabled to save processing time, but beware, // evil things can happen if the item collections are left in invalild state if (validityChecks) { // do not allow adding an item more than once if (zOrder.Contains(item)) return; if (item.getType() == ItemType.Arrow) { Arrow arrow = item as Arrow; // links origin and destination nodes must be in the same diagram if (!zOrder.Contains(arrow.Origin) && (arrow.Origin == null || !(arrow.Origin is DummyNode))) return; if (!zOrder.Contains(arrow.Destination) && (arrow.Destination == null || !(arrow.Destination is DummyNode))) return; } } if (item.getType() == ItemType.ControlHost) { // add the hosted control to the flowchart ControlHost host = item as ControlHost; if (host.Control != null) { this.Controls.Add(host.Control); bringContainedControlToFront(host.Control); } } item.setParent(this); item.setConstructed(); // add to the diagram AddItemCmd cmd = new AddItemCmd(item); cmd.Execute(); RectangleF rc = item.getRepaintRect(false); if (select) { selection.Change(item); rc = Utilities.unionNonEmptyRects(rc, selection.getRepaintRect(true)); } if (undoManager.UndoEnabled) cmd.saveSelState(); // repaint the diagram area covered by the new item if (!LayoutSuspended) invalidate(rc); setDirty(); }
private void sizeDocForItem(ChartObject item) { if (item == null) { sizeDocForItems(); return; } bool changed = false; float docLeft = docExtents.Left; float docTop = docExtents.Top; float docRight = docExtents.Right; float docBottom = docExtents.Bottom; RectangleF rcItem = item.getRepaintRect(true); float hinch = Constants.getHalfInch(measureUnit); // if auto-sizing to the left and top too... if (autoSizeDoc == MindFusion.FlowChartX.AutoSize.AllDirections) { if (rcItem.Left < docLeft + hinch) { docLeft = rcItem.Left - hinch; changed = true; } if (rcItem.Top < docTop + hinch) { docTop = rcItem.Top - hinch; changed = true; } } if (rcItem.Right > docRight - hinch) { docRight = rcItem.Right + hinch; changed = true; } if (rcItem.Bottom > docBottom - hinch) { docBottom = rcItem.Bottom + hinch; changed = true; } if (changed) { docExtents = RectangleF.FromLTRB(docLeft, docTop, docRight, docBottom); resetDocSize(); } }