internal bool setMainObject(ChartObject main) { if (main == null) { return(false); } if (main.getType() != ItemType.Arrow && main.getType() != ItemType.Box && main.getType() != ItemType.Table && main.getType() != ItemType.ControlHost) { return(false); } if (!main.setGroup(this)) { return(false); } mainObj = main; if (mainObj.getType() == ItemType.Arrow) { prevPoints = ((Arrow)mainObj).Points.Clone(); } else { prevRect = mainObj.getBoundingRect(); prevRotation = (mainObj as Node).rotation(); } return(true); }
/// <summary> /// Adds an item to the group, attaching it to a control point of an arrow /// </summary> /// <param name="obj">The object to attach to the current group.</param> /// <param name="point">The point to attach to.</param> public bool AttachToArrowPoint(Node node, int point) { if (!objAttachable(node)) { return(false); } if (mainObj.getType() != ItemType.Arrow) { return(false); } if (((Arrow)mainObj).Points.Count <= point) { return(false); } Attachment a = new Attachment(); a.node = node; a.type = AttachTo.ArrowPoint; a.attData = point; new GroupAttachCmd(this, a).Execute(); return(true); }
internal bool removeObject(ChartObject obj) { bool objExists = ObjectInSelection(obj); if (objExists) { selectedItems.Remove(obj); switch (obj.getType()) { case ItemType.Box: selectedBoxes.Remove((Box)obj); break; case ItemType.ControlHost: selectedHosts.Remove((ControlHost)obj); break; case ItemType.Table: selectedTables.Remove((Table)obj); break; case ItemType.Arrow: selectedArrows.Remove((Arrow)obj); break; } obj.setSelected(false); recalcRect(); } return(objExists); }
internal void addObjToSelection(ChartObject obj) { if (obj.getSelected()) { return; } selectedItems.Add(obj); obj.setSelected(true); switch (obj.getType()) { case ItemType.Box: selectedBoxes.Add((Box)obj); break; case ItemType.ControlHost: selectedHosts.Add((ControlHost)obj); break; case ItemType.Table: selectedTables.Add((Table)obj); break; case ItemType.Arrow: selectedArrows.Add((Arrow)obj); break; } rect = Utilities.unionNonEmptyRects(rect, obj.getRotatedBounds()); }
private void updateNSARect(ChartObject obj) { RectangleF rcObj = obj.getRepaintRect(true); if (obj.getType() == ItemType.Arrow) { Arrow arrow = (Arrow)obj; arrow.updatePosFromOrgAndDest(false); } }
private bool parentSelected(ChartObject obj, bool checkCycles) { // for arrows check if the objects they are linked to are selected if (obj.getType() == ItemType.Arrow) { Arrow arrow = (Arrow)obj; if (arrow.getOrgnLink().getNode().Selected) { return(true); } if (arrow.getDestLink().getNode().Selected) { return(true); } } // doesn't have parent at all if (!obj.isAttached()) { return(false); } // has a parent, but it is not selected if (!obj.getContainingGroup().MainObject.Selected) { return(false); } // is the group master in a cycle if (!checkCycles) { if (obj.getGroupMaster() == obj) { return(false); } } else { if (obj.getGroupMasterCC() == obj) { return(false); } } // true in all other cases return(true); }
void HV_TranslateArrow(ChartObject obj) { if (obj.getType() == ItemType.Arrow) { Arrow arrow = (Arrow)obj; if (arrow.bothEndsSelected() && !arrowsToMove.Contains(arrow) && arrow.Origin.canModify(8) && arrow.Destination.canModify(8)) { arrowsToMove.Add(arrow); return; } if (arrow.Origin.getModifying() && arrow.Destination.getModifying() && !arrowsToMove.Contains(arrow) && relatedInteraction != null && !relatedInteraction.affectedArrows.Contains(arrow)) { arrowsToMove.Add(arrow); return; } } }
internal bool confirmModify(ChartObject item) { PointF point = AlignPointToGrid(interaction.CurrentPoint); int selHandle = interaction.SelectionHandle; bool validated = true; switch (item.getType()) { case ItemType.Box: if (BoxModifying != null) { Box box = (Box)item; BoxConfirmArgs args = new BoxConfirmArgs(box, point, selHandle); BoxModifying(this, args); validated = args.Confirm; } break; case ItemType.ControlHost: if (ControlHostModifying != null) { ControlHost host = (ControlHost)item; ControlHostConfirmArgs args = new ControlHostConfirmArgs(host, point, selHandle); ControlHostModifying(this, args); validated = args.Confirm; } break; case ItemType.Table: if (TableModifying != null) { Table table = (Table)item; TableConfirmArgs args = new TableConfirmArgs(table, point, selHandle); TableModifying(this, args); validated = args.Confirm; } break; case ItemType.Arrow: if (ArrowModifying != null) { Arrow arrow = (Arrow)item; ArrowConfirmArgs args = new ArrowConfirmArgs(arrow, point, selHandle); ArrowModifying(this, args); validated = args.Confirm; } break; } return validated; }
internal void fireObjModified(ChartObject obj, PointF pt, int mnpHandle) { switch (obj.getType()) { case ItemType.Box: if (BoxModified != null) { Box box = (Box)obj; BoxMouseArgs args = new BoxMouseArgs( box, pt.X, pt.Y, mnpHandle); BoxModified(this, args); } break; case ItemType.ControlHost: if (ControlHostModified != null) { ControlHost host = (ControlHost)obj; ControlHostMouseArgs args = new ControlHostMouseArgs( host, pt.X, pt.Y, mnpHandle); ControlHostModified(this, args); } break; case ItemType.Table: if (TableModified != null) { Table table = (Table)obj; TableMouseArgs args = new TableMouseArgs( table, pt.X, pt.Y, mnpHandle); TableModified(this, args); } break; case ItemType.Arrow: if (ArrowModified != null) { Arrow arrow = (Arrow)obj; ArrowMouseArgs args = new ArrowMouseArgs( arrow, pt.X, pt.Y, mnpHandle); ArrowModified(this, args); } break; } }
private bool parentSelected(ChartObject obj, bool checkCycles) { // for arrows check if the objects they are linked to are selected if (obj.getType() == ItemType.Arrow) { Arrow arrow = (Arrow)obj; if (arrow.getOrgnLink().getNode().Selected) return true; if (arrow.getDestLink().getNode().Selected) return true; } // doesn't have parent at all if (!obj.isAttached()) return false; // has a parent, but it is not selected if (!obj.getContainingGroup().MainObject.Selected) return false; // is the group master in a cycle if (!checkCycles) { if (obj.getGroupMaster() == obj) return false; } else { if (obj.getGroupMasterCC() == obj) return false; } // true in all other cases return true; }
internal bool removeObject(ChartObject obj) { bool objExists = ObjectInSelection(obj); if (objExists) { selectedItems.Remove(obj); switch (obj.getType()) { case ItemType.Box: selectedBoxes.Remove((Box)obj); break; case ItemType.ControlHost: selectedHosts.Remove((ControlHost)obj); break; case ItemType.Table: selectedTables.Remove((Table)obj); break; case ItemType.Arrow: selectedArrows.Remove((Arrow)obj); break; } obj.setSelected(false); recalcRect(); } return objExists; }
private void fireDblClickedEvent(ChartObject obj, PointF pt, MouseButtons mb) { RectangleF rc = obj.getBoundingRect(); float dx = pt.X - rc.X; float dy = pt.Y - rc.Y; int row = 0, col = 0; switch (obj.getType()) { case ItemType.Box: Box box = (Box)obj; if (inplaceEditAllowed && Enabled && !box.notInteractive() && confirmBoxInplaceEdit(box)) startInplaceEdit(new NodeInplaceEditable(box), box.getEditRect()); if (BoxDblClicked != null) BoxDblClicked(this, new BoxMouseArgs(box, mb, dx, dy, pt)); break; case ItemType.ControlHost: ControlHost host = (ControlHost)obj; if (ControlHostDblClicked != null) ControlHostDblClicked(this, new ControlHostMouseArgs(host, mb, dx, dy, pt)); break; case ItemType.Table: Table table = (Table)obj; if (table.cellFromPt(pt, ref row, ref col)) { if (inplaceEditAllowed && Enabled && !table.notInteractive() && confirmTableInplaceEdit(table, row, col)) { startInplaceEdit(table[col, row], table[col, row].getEditRect()); lastClickedCol = col; lastClickedRow = row; } if (TableCellDblClicked != null) { TableCellDblClicked(this, new TableMouseArgs( table, mb, dx, dy, col, row)); } } else { if (inplaceEditAllowed && Enabled && !table.notInteractive() && confirmTableInplaceEdit(table, -1, -1)) startInplaceEdit(new NodeInplaceEditable(table), table.getEditRect()); if (TableDblClicked != null) TableDblClicked(this, new TableMouseArgs(table, mb, dx, dy, pt)); } break; case ItemType.Arrow: if (ArrowDblClicked != null) ArrowDblClicked(this, new ArrowMouseArgs((Arrow)obj, mb, dx, dy, pt)); break; } }
internal void fireObjCreated(ChartObject obj) { if (obj.getType() == ItemType.Box && BoxCreated != null) BoxCreated(this, new BoxEventArgs((Box)obj)); if (obj.getType() == ItemType.ControlHost && ControlHostCreated != null) ControlHostCreated(this, new ControlHostEventArgs((ControlHost)obj)); if (obj.getType() == ItemType.Table && TableCreated != null) TableCreated(this, new TableEventArgs((Table)obj)); if (obj.getType() == ItemType.Arrow && ArrowCreated != null) ArrowCreated(this, new ArrowEventArgs((Arrow)obj)); }
/// <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(); }
internal bool setMainObject(ChartObject main) { if (main == null) return false; if (main.getType() != ItemType.Arrow && main.getType() != ItemType.Box && main.getType() != ItemType.Table && main.getType() != ItemType.ControlHost) return false; if (!main.setGroup(this)) return false; mainObj = main; if (mainObj.getType() == ItemType.Arrow) { prevPoints = ((Arrow)mainObj).Points.Clone(); } else { prevRect = mainObj.getBoundingRect(); prevRotation = (mainObj as Node).rotation(); } return true; }
internal void fireItemPasted(ChartObject item) { switch (item.getType()) { case ItemType.Box: if (BoxPasted != null) { Box box = item as Box; BoxEventArgs args = new BoxEventArgs(box); BoxPasted(this, args); } break; case ItemType.ControlHost: if (ControlHostPasted != null) { ControlHost host = item as ControlHost; ControlHostEventArgs args = new ControlHostEventArgs(host); ControlHostPasted(this, args); } break; case ItemType.Table: if (TablePasted != null) { Table table = item as Table; TableEventArgs args = new TableEventArgs(table); TablePasted(this, args); } break; case ItemType.Arrow: if (ArrowPasted != null) { Arrow arrow = item as Arrow; ArrowEventArgs args = new ArrowEventArgs(arrow); ArrowPasted(this, args); } break; } }
internal void objectDeselected(ChartObject obj) { if (!userAction) return; switch (obj.getType()) { case ItemType.Box: if (BoxDeselected != null) BoxDeselected(this, new BoxEventArgs((Box)obj)); break; case ItemType.ControlHost: if (ControlHostDeselected != null) ControlHostDeselected(this, new ControlHostEventArgs((ControlHost)obj)); break; case ItemType.Table: if (TableDeselected != null) TableDeselected(this, new TableEventArgs((Table)obj)); break; case ItemType.Arrow: if (ArrowDeselected != null) ArrowDeselected(this, new ArrowEventArgs((Arrow)obj)); break; } }
private void addToObjColl(ChartObject obj) { switch (obj.getType()) { case ItemType.Box: boxes.Add((Box)obj); break; case ItemType.ControlHost: controlHosts.Add((ControlHost)obj); break; case ItemType.Table: tables.Add((Table)obj); break; case ItemType.Arrow: arrows.Add((Arrow)obj); break; } }
internal void fireClickedEvent(ChartObject obj, PointF pt, MouseButtons mb) { RectangleF rc = obj.getBoundingRect(); float dx = pt.X - rc.X; float dy = pt.Y - rc.Y; int row = 0, col = 0; bool cellClicked; switch (obj.getType()) { case ItemType.Box: if (BoxClicked != null) BoxClicked(this, new BoxMouseArgs((Box)obj, mb, dx, dy, pt)); break; case ItemType.ControlHost: if (ControlHostClicked != null) ControlHostClicked(this, new ControlHostMouseArgs((ControlHost)obj, mb, dx, dy, pt)); break; case ItemType.Table: // raise TableCellClicked if a cell has been clicked and // an event handler is registered for the event cellClicked = ((Table)obj).cellFromPt(pt, ref row, ref col); if (cellClicked && TableCellClicked != null) { TableCellClicked(this, new TableMouseArgs( (Table)obj, mb, dx, dy, col, row)); } // otherwise raise TableClicked else { TableMouseArgs args = new TableMouseArgs((Table)obj, mb, dx, dy, pt); if (cellClicked) { args.col = col; args.row = row; } if (TableClicked != null) TableClicked(this, args); } break; case ItemType.Arrow: if (ArrowClicked != null) ArrowClicked(this, new ArrowMouseArgs((Arrow)obj, mb, dx, dy, pt)); break; } }
internal void removeItem(ChartObject item) { selection.RemoveObject(item); if (item == autoHandlesObj) autoHandlesObj = null; if (item == autoAnchorsObj) autoAnchorsObj = null; switch (item.getType()) { case ItemType.Box: boxes.Remove((Box)item); break; case ItemType.ControlHost: controlHosts.Remove((ControlHost)item); break; case ItemType.Table: tables.Remove((Table)item); break; case ItemType.Arrow: arrows.Remove((Arrow)item); break; } removeFromZOrder(item); MethodCallVisitor visitor = new MethodCallVisitor(new VisitOperation(removeFromSelection)); switch (item.getType()) { case ItemType.ControlHost: { ControlHost host = (ControlHost)item; host.visitArrows(visitor); host.deleteArrows(); } break; case ItemType.Box: { Box box = (Box)item; box.visitArrows(visitor); box.deleteArrows(); } break; case ItemType.Table: { Table table = (Table)item; table.visitArrows(visitor); table.deleteArrows(); } break; case ItemType.Arrow: { Arrow arrow = (Arrow)item; arrow.resetCrossings(); arrow.getDestLink().removeArrowFromObj(); arrow.getOrgnLink().removeArrowFromObj(); } break; } item.onRemove(); // update document size if needed if (autoSizeDoc != MindFusion.FlowChartX.AutoSize.None) sizeDocForItems(); }
internal void addObjToSelection(ChartObject obj) { if (obj.getSelected()) return; selectedItems.Add(obj); obj.setSelected(true); switch (obj.getType()) { case ItemType.Box: selectedBoxes.Add((Box)obj); break; case ItemType.ControlHost: selectedHosts.Add((ControlHost)obj); break; case ItemType.Table: selectedTables.Add((Table)obj); break; case ItemType.Arrow: selectedArrows.Add((Arrow)obj); break; } rect = Utilities.unionNonEmptyRects(rect, obj.getRotatedBounds()); }
internal void raiseInitEvent(ChartObject item) { switch (item.getType()) { case ItemType.Box: if (InitializeBox != null) { BoxEventArgs args = new BoxEventArgs(item as Box); InitializeBox(this, args); } break; case ItemType.ControlHost: if (InitializeControlHost != null) { ControlHostEventArgs args = new ControlHostEventArgs(item as ControlHost); InitializeControlHost(this, args); } break; case ItemType.Table: if (InitializeTable != null) { TableEventArgs args = new TableEventArgs(item as Table); InitializeTable(this, args); } break; case ItemType.Arrow: if (InitializeArrow != null) { ArrowEventArgs args = new ArrowEventArgs(item as Arrow); InitializeArrow(this, args); } break; } }
private void updateNSARect(ChartObject obj) { RectangleF rcObj = obj.getRepaintRect(true); if (obj.getType() == ItemType.Arrow) { Arrow arrow = (Arrow)obj; arrow.updatePosFromOrgAndDest(false); } }
internal bool confirmSelect(ChartObject obj) { bool res = true; switch (obj.getType()) { case ItemType.Box: if (BoxSelecting != null) { BoxConfirmArgs args = new BoxConfirmArgs((Box)obj); BoxSelecting(this, args); res = args.Confirm; } break; case ItemType.ControlHost: if (ControlHostSelecting != null) { ControlHostConfirmArgs args = new ControlHostConfirmArgs((ControlHost)obj); ControlHostSelecting(this, args); res = args.Confirm; } break; case ItemType.Table: if (TableSelecting != null) { TableConfirmArgs args = new TableConfirmArgs((Table)obj); TableSelecting(this, args); res = args.Confirm; } break; case ItemType.Arrow: if (ArrowSelecting != null) { ArrowConfirmArgs args = new ArrowConfirmArgs((Arrow)obj); ArrowSelecting(this, args); res = args.Confirm; } break; } return res; }
void HV_TranslateArrow(ChartObject obj) { if (obj.getType() == ItemType.Arrow) { Arrow arrow = (Arrow)obj; if (arrow.bothEndsSelected() && !arrowsToMove.Contains(arrow) && arrow.Origin.canModify(8) && arrow.Destination.canModify(8)) { arrowsToMove.Add(arrow); return; } if (arrow.Origin.getModifying() && arrow.Destination.getModifying() && !arrowsToMove.Contains(arrow) && relatedInteraction != null && !relatedInteraction.affectedArrows.Contains(arrow)) { arrowsToMove.Add(arrow); return; } } }
internal bool confirmCreate(ChartObject item) { PointF point = AlignPointToGrid(interaction.CurrentPoint); bool validated = true; switch (item.getType()) { case ItemType.Box: if (BoxCreating != null) { BoxConfirmArgs args = new BoxConfirmArgs((Box)item, point, -1); BoxCreating(this, args); validated = args.Confirm; } break; case ItemType.ControlHost: if (ControlHostCreating != null) { ControlHostConfirmArgs args = new ControlHostConfirmArgs((ControlHost)item, point, -1); ControlHostCreating(this, args); validated = args.Confirm; } break; case ItemType.Table: if (TableCreating != null) { TableConfirmArgs args = new TableConfirmArgs((Table)item, point, -1); TableCreating(this, args); validated = args.Confirm; } break; case ItemType.Arrow: if (ArrowCreating != null) { Arrow arrow = (Arrow)item; PointF endPt = arrow.Points[arrow.Points.Count - 1]; int id = 0; int row = -1; arrow.NewDest.getAnchor(endPt, arrow, true, ref id); if (arrow.NewDest is Table) row = ((Table)arrow.NewDest).rowFromPt(endPt); AttachConfirmArgs args = new AttachConfirmArgs( arrow, arrow.NewDest, false, id, row); ArrowCreating(this, args); validated = args.Confirm; } break; } return validated; }