public Node(Node prototype) : base(prototype) { incomingArrows = new ArrowCollection(); outgoingArrows = new ArrowCollection(); AnchorPattern = prototype.AnchorPattern; obstacle = prototype.obstacle; constraints = (NodeConstraints)prototype.constraints.Clone(); enabledHandles = prototype.enabledHandles; boolValues = prototype.boolValues; }
private TreeEnumerator(Node root, bool enumArrows, bool strict, bool reversedDir) { objects = new ChartObjectCollection(); this.enumArrows = enumArrows; this.reversedDir = reversedDir; this.strict = strict; buildTree(root); internalEnum = objects.GetEnumerator(); }
internal bool allowArrowsDir(bool outgoing, Node node) { if (points == null) return false; for (int i = 0; i < points.Count; ++i) { AnchorPoint pt = points[i]; if (outgoing) { if (pt.AllowOutgoing && node.Parent.validateAnchor(null, true, node, i)) return true; } else { if (pt.AllowIncoming && node.Parent.validateAnchor(null, false, node, i)) return true; } } return false; }
private void buildTree(Node node) { if (objects.Contains(node)) { if (!strict) return; throw new NotATreeException(); } objects.Add(node); // get the appropriate arrows ArrowCollection arrows = new ArrowCollection(); if (reversedDir) node.getAllIncomingArrows(arrows); else node.getAllOutgoingArrows(arrows); // build subtrees recursively foreach (Arrow a in arrows) { if (enumArrows) objects.Add(a); buildTree(reversedDir ? a.Origin : a.Destination); } }
public bool Intersects(Node node) { return Node.nodesIntersect(this, node); }
internal bool validateAnchor(Arrow arrow, bool outgoing, Node node, int pointIndex) { if (ValidateAnchorPoint != null) { AttachConfirmArgs args = new AttachConfirmArgs(arrow, node, outgoing, pointIndex, 0); ValidateAnchorPoint(this, args); return args.Confirm; } return true; }
public virtual void setReference(int refId, IPersists obj) { this.node = (Node)obj; }
internal override bool alreadyLinked(Node node) { if (base.alreadyLinked(node)) return true; if (rowsList != null) { foreach (Row row in rowsList) { foreach (Arrow arrow in row.OutgoingArrows) { if (arrow.getDestLink().getNode() == node) return true; } } } return false; }
/// <summary> /// Adds text to speciafied Flowchart.NET node /// </summary> /// <param name="ActiveNode">Node reference</param> /// <param name="Text2Render">String text to be added</param> /// <param name="Font2Render">Font to be used for text drawing</param> /// <param name="Rect2Render">Rectangle of the text area</param> /// <param name="Color2Render">Color for text rendering</param> /// <param name="TextFormat2Render">Text format for text renedering</param> /// <param name="IsStyled">If TRUE the text is styled</param> /// <returns>Returns recently added to SVG XML "text" node</returns> public XmlNode AddText( Node ActiveNode, string Text2Render, Font Font2Render, RectangleF Rect2Render, Color Color2Render, StringFormat TextFormat2Render , bool IsStyled , float angle) { Layout tl = null; LayoutOptions lo; DrawTextHint dhint = null; StyledText stext = null; PlainText text = null; System.Drawing.SolidBrush br = null; GraphicsPath path = null; PointF[] pF = null; string sPath = ""; double OffsetY = 0; double OffsetX = 0; int tlen = 0; try { if (( Text2Render == null ) || ( Text2Render=="")) return null; m_InnerNode = m_InnerRoot.InsertAfter(m_InnerDoc.CreateNode(XmlNodeType.Element,"text", sNsDefault), m_InnerRoot.LastChild); if ( m_InnerNode ==null ) return m_InnerNode; if ( TextFormat2Render.Alignment == StringAlignment.Near ) Rect2Render.Width+=15; path = new GraphicsPath(FillMode.Winding); IsTransparent = false; IsTable = false; if ( ActiveNode == null ) { sPath = Rect2Path(Rect2Render, ref path); } else if ( ActiveNode is Box ) { IsTransparent = ((Box) ActiveNode).Transparent; if ( ((Box) ActiveNode).Shape == null ) { sPath = Shape2Path((Box) ActiveNode, ref path , null); } else sPath = Complex2Path(Rect2Render, ( ((Box) ActiveNode).Shape.TextArea == null )? ((Box) ActiveNode).Shape.Outline : ((Box) ActiveNode).Shape.TextArea, ref path ); } else if ( ActiveNode is Table ) { sPath = Rect2Path(Rect2Render, ref path); IsTable = true; OffsetX = -Rect2Render.Width/2; } else { return null; } m_InnerNode.Attributes.Append(m_InnerDoc.CreateAttribute("x")); m_InnerNode.Attributes["x"].Value = String.Format("{0}px",Unit2Pix(Rect2Render.X+Rect2Render.Width/2)); m_InnerNode.Attributes.Append(m_InnerDoc.CreateAttribute("y")); m_InnerNode.Attributes["y"].Value = String.Format("{0}px",Unit2Pix(Rect2Render.Y + Rect2Render.Height/2)); m_InnerNode.Attributes.Append(m_InnerDoc.CreateAttribute("dx")); m_InnerNode.Attributes["dx"].Value = String.Format("{0}px",Unit2Pix(OffsetX)); m_InnerNode.Attributes.Append(m_InnerDoc.CreateAttribute("dy")); m_InnerNode.Attributes["dy"].Value = String.Format("{0}px",Unit2Pix(OffsetY)); m_InnerNode.Attributes.Append(m_InnerDoc.CreateAttribute("font-family")); m_InnerNode.Attributes["font-family"].Value = Font2Render.FontFamily.Name.ToString(); m_InnerNode.Attributes.Append(m_InnerDoc.CreateAttribute("font-size")); m_InnerNode.Attributes["font-size"].Value = Unit2Pix(Font2Render.Size, Font2Render.Unit).ToString(); m_InnerNode.Attributes.Append(m_InnerDoc.CreateAttribute("fill")); m_InnerNode.Attributes["fill"].Value = SvgManager.Color2Str(Color2Render); m_InnerNode.Attributes.Append(m_InnerDoc.CreateAttribute("style")); m_InnerNode.Attributes["style"].Value = SvgManager.Align2Str(TextFormat2Render.Alignment); IntPtr hWnd = GetActiveWindow(); if ( IsStyled ) { stext = new StyledText(); stext.Setup(Text2Render, System.Drawing.Graphics.FromHwnd(hWnd) ,Font2Render); tlen = stext.PlainText.Length; } else { text = new PlainText(); text.Setup(Text2Render, System.Drawing.Graphics.FromHwnd(hWnd) ,Font2Render); tlen = text.PlainText.Length; } path.Flatten(); pF = (PointF[])path.PathPoints.Clone(); path.Dispose(); tl = new Layout(); br = new System.Drawing.SolidBrush(Color2Render); lo = new LayoutOptions(); dhint = new DrawTextHint(System.Drawing.Graphics.FromHwnd(hWnd), Font2Render, br ,TextFormat2Render, false , m_InnerNode, Rect2Render ); m_lastY = 0; m_lastX = 0; sTextLine = ""; lo.Alignment = TextFormat2Render.Alignment; lo.LineAlignment = TextFormat2Render.LineAlignment; tl.LayoutInPolygon((IsStyled ? (Text) stext : (Text) text), docToLocal(pF, Rect2Render),lo); tl.Draw(0,0,new RenderTextCallback(___TextCallback),dhint); AddRotation(m_InnerNode, Rect2Render , angle ); } catch (Exception ex) { Trace.WriteLine(String.Format("{0} error {1}\n","SvgManager.AddText)",ex.Message)); } return m_InnerNode; }
public void AttachTo(Node node, float percentX1, float percentY1, float percentX2, float percentY2) { // that returns the active composite if somebody has already created one CompositeCmd composite = flowChart.UndoManager.StartComposite("_fcnet_"); Detach(); Group masterGroup = getSubordinateGroup(node); masterGroup.AttachProportional(this, percentX1, percentY1, percentX2, percentY2); if (composite != null && composite.Title == "_fcnet_") { // this is our own composite cmd composite.Title = "Attach"; composite.Execute(); } }
internal virtual bool alreadyLinked(Node node) { foreach (Arrow arrow in outgoingArrows) { if (arrow.getDestLink().getNode() == node) return true; } return false; }
/// <summary> /// Creates a new Arrow instance and adds it to the flowchart. /// </summary> /// <param name="src">Specifies the origin point.</param> /// <param name="dest">Specifies the destination node.</param> /// <returns>A reference to the new arrow.</returns> public Arrow CreateArrow(PointF src, Node dest) { if (dest == null) return null; // create the arrow instance and add it to the chart Arrow newArrow = new Arrow(this, src, dest); Add(newArrow, SelectAfterCreate); return newArrow; }
internal void setAutoAnchors(Node node) { if (node != autoAnchorsObj) { RectangleF rcInv = new RectangleF(0, 0, 0, 0); if (autoAnchorsObj != null) rcInv = autoAnchorsObj.getRepaintRect(false); if (node != null) { rcInv = Utilities.unionNonEmptyRects(rcInv, node.getRepaintRect(false)); } rcInv.Inflate(Constants.getMarkSize(measureUnit), Constants.getMarkSize(measureUnit)); autoAnchorsObj = node; Graphics g = CreateGraphics(); setTransforms(g); Rectangle rcInvDev = Utilities.docToDevice(g, rcInv); g.Dispose(); Invalidate(rcInvDev); } }
/// <summary> /// Creates a new Arrow instance and adds it to the flowchart. /// </summary> /// <param name="srcNode">Specifies the origin node.</param> /// <param name="destTable">Specifies the destination table.</param> /// <param name="destRow">Specifies the destination row.</param> /// <returns>A reference to the new arrow.</returns> public Arrow CreateArrow(Node srcNode, Table destTable, int destRow) { if (srcNode == null || destTable == null) return null; if (!destTable.canHaveArrows(false) && destRow != -1) return null; if (destRow < -1 || destRow >= destTable.RowCount) return null; // create the arrow object and store it in the collection Arrow newArrow = new Arrow(this); newArrow.setOrgAndDest( srcNode.createLink(newArrow, srcNode.getCenter(), false), destTable.createLink(newArrow, true, destRow)); Add(newArrow, SelectAfterCreate); return newArrow; }
/// <summary> /// Creates a new Arrow instance and adds it to the flowchart. /// </summary> /// <param name="srcTable">Specifies the origin table.</param> /// <param name="srcRow">Specifies the origin row.</param> /// <param name="dstNode">Specifies the destination node.</param> /// <returns>A reference to the new arrow.</returns> public Arrow CreateArrow(Table srcTable, int srcRow, Node dstNode) { if (srcTable == null || dstNode == null) return null; if (!srcTable.canHaveArrows(true) && srcRow != -1) return null; if (srcRow < -1 || srcRow >= srcTable.RowCount) return null; // create the arrow object and store it in the item array Arrow newArrow = new Arrow(this); newArrow.setOrgAndDest( srcTable.createLink(newArrow, false, srcRow), dstNode.createLink(newArrow, dstNode.getCenter(), true)); Add(newArrow, SelectAfterCreate); return newArrow; }
/// <summary> /// Creates a new Arrow instance and adds it to the flowchart. /// </summary> /// <param name="srcNode">Specifies the arrow origin.</param> /// <param name="dstNode">Specifies the arrow destination.</param> /// <returns>A reference to the new arrow.</returns> public Arrow CreateArrow(Node srcNode, Node dstNode) { if (srcNode == null || dstNode == null) return null; // create the arrow object and store it in the collection Arrow newArrow = new Arrow(this); newArrow.setOrgAndDest( srcNode.createLink(newArrow, srcNode.getCenter(), false), dstNode.createLink(newArrow, dstNode.getCenter(), true)); Add(newArrow, SelectAfterCreate); return newArrow; }
private void WriteConstraints( System.Xml.XmlWriter writer, Node node) { writer.WriteStartElement("Constraints"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(NodeConstraints.Count)); writer.WriteStartElement("Constraint"); writer.WriteAttributeString("Type", "0"); writer.WriteElementString("Value", XmlConvert.FromInt32((int)node.Constraints.MoveDirection)); writer.WriteEndElement(); writer.WriteStartElement("Constraint"); writer.WriteAttributeString("Type", "1"); writer.WriteElementString("Value", XmlConvert.FromSingle(node.Constraints.MinWidth)); writer.WriteEndElement(); writer.WriteStartElement("Constraint"); writer.WriteAttributeString("Type", "2"); writer.WriteElementString("Value", XmlConvert.FromSingle(node.Constraints.MinHeight)); writer.WriteEndElement(); writer.WriteStartElement("Constraint"); writer.WriteAttributeString("Type", "3"); writer.WriteElementString("Value", XmlConvert.FromSingle(node.Constraints.MaxWidth)); writer.WriteEndElement(); writer.WriteStartElement("Constraint"); writer.WriteAttributeString("Type", "4"); writer.WriteElementString("Value", XmlConvert.FromSingle(node.Constraints.MaxHeight)); writer.WriteEndElement(); writer.WriteStartElement("Constraint"); writer.WriteAttributeString("Type", "5"); writer.WriteElementString("Value", XmlConvert.FromBoolean(node.Constraints.KeepInsideParent)); writer.WriteEndElement(); writer.WriteStartElement("Constraint"); writer.WriteAttributeString("Type", "6"); writer.WriteElementString("Value", XmlConvert.FromBoolean(node.Constraints.KeepRatio)); writer.WriteEndElement(); writer.WriteEndElement(); }
private string createExpBtnArea(Node node) { Expander exp = node.getExpander(); if (exp == null) return ""; string link = String.Format(expandBtnHyperLink, node.ZIndex, node.Tag); string html = ""; html += TAB + TAB + "<AREA SHAPE="; html += createRectArea(exp.getBounds()); html += "\r\n"; html += TAB + TAB + TAB + "HREF=\"" + link + "\" "; html += "TARGET=\"" + linkTarget + "\">\r\n"; return html; }
internal static bool nodesIntersect(Node n1, Node n2) { RectangleF bounds1 = n1.BoundingRect; RectangleF bounds2 = n2.BoundingRect; if (!bounds1.IntersectsWith(bounds2)) return false; bool res = true; Region r1 = n1.getRegion(); Region r2 = n2.getRegion(); if (r1 != null && r2 != null) { Graphics g = n1.Parent.CreateGraphics(); n1.Parent.setTransforms(g); r1.Intersect(r2); if (r1.IsEmpty(g)) res = false; g.Dispose(); } else { res = false; } if (r2 != null) r2.Dispose(); if (r1 != null) r1.Dispose(); return res; }
private void drawAutoAnchors(Graphics g, PointF ptCurr) { // get the object the mouse is pointing to Node node = GetBoxAt(ptCurr); if (node == null) node = GetTableAt(ptCurr); // if it's different than the last pointed redraw the old one // and draw the anchors of the new one if (node != autoAnchorsObj) { RectangleF rcInv = new RectangleF(0, 0, 0, 0); if (autoAnchorsObj != null) rcInv = autoAnchorsObj.getRepaintRect(false); if (node != null) { rcInv = Utilities.unionNonEmptyRects(rcInv, node.getRepaintRect(false)); } rcInv.Inflate(Constants.getMarkSize(measureUnit), Constants.getMarkSize(measureUnit)); autoAnchorsObj = node; Rectangle rcInvDev = Utilities.docToDevice(g, rcInv); Invalidate(rcInvDev); } }
public void AttachTo(Node node, AttachToNode attType) { // that returns the active composite if somebody has already created one CompositeCmd composite = flowChart.UndoManager.StartComposite("_fcnet_"); Detach(); Group masterGroup = getSubordinateGroup(node); switch (attType) { case AttachToNode.TopLeft: masterGroup.AttachToCorner(this, 0); break; case AttachToNode.TopRight: masterGroup.AttachToCorner(this, 1); break; case AttachToNode.BottomLeft: masterGroup.AttachToCorner(this, 3); break; case AttachToNode.BottomRight: masterGroup.AttachToCorner(this, 2); break; case AttachToNode.TopCenter: masterGroup.AttachToSideMiddle(this, 0); break; case AttachToNode.MiddleRight: masterGroup.AttachToSideMiddle(this, 1); break; case AttachToNode.BottomCenter: masterGroup.AttachToSideMiddle(this, 2); break; case AttachToNode.MiddleLeft: masterGroup.AttachToSideMiddle(this, 3); break; } if (composite != null && composite.Title == "_fcnet_") { // this is our own composite cmd composite.Title = "Attach"; composite.Execute(); } }
public TreeEnumerator(Node root, bool enumArrows, bool strict) : this(root, enumArrows, strict, false) { }
/// <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; }
/// <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; }
private void ReadNodeConstraints( System.Xml.XmlReader reader, Node node) { int count = XmlConvert.ToInt32(reader.GetAttribute("Count")); NodeConstraints c = node.Constraints; for (int i = 0; i < count; i++) { // Read <constraint> reader.Read(); int type = XmlConvert.ToInt32(reader.GetAttribute("Type")); string prop = _constraints[type]; PropertyInfo pd = c.GetType().GetProperty(prop); // Read <value> reader.Read(); // Read value reader.Read(); // Set the value if (pd.PropertyType.Equals(typeof(DirectionConstraint))) pd.SetValue(c, XmlConvert.ToEnum(pd.PropertyType, reader.Value), null); else if (pd.PropertyType.Equals(typeof(Single))) pd.SetValue(c, XmlConvert.ToSingle(reader.Value), null); else if (pd.PropertyType.Equals(typeof(Boolean))) pd.SetValue(c, XmlConvert.ToBoolean(reader.Value), null); // Read </value> reader.Read(); // Read </constraint> reader.Read(); } // Read </constraints> reader.Read(); }
internal bool requestAttach(Arrow arrow, bool changingOrg, Node node) { if (ArrowAttaching != null) { PointF endPt = changingOrg ? arrow.Points[0] : arrow.Points[arrow.Points.Count - 1]; int id = 0; int row = -1; node.getAnchor(endPt, arrow, !changingOrg, ref id); // get the row if attaching to table Table table = node as Table; if (table != null) row = table.rowFromPt(endPt); AttachConfirmArgs args = new AttachConfirmArgs(arrow, node, changingOrg, id, row); ArrowAttaching(this, args); return args.Confirm; } return true; }
internal void raiseExpandBtnClicked(Node node) { if (ExpandButtonClicked != null) ExpandButtonClicked(this, new NodeEventArgs(node)); }
/// <summary> /// Adds text to speciafied Flowchart.NET node /// </summary> /// <param name="ActiveNode">Node reference</param> /// <param name="Text2Render">String text to be added</param> /// <param name="Font2Render">Font to be used for text drawing</param> /// <param name="Rect2Render">Rectangle of the text area</param> /// <param name="Color2Render">Color for text rendering</param> /// <param name="TextFormat2Render">Text format for text renedering</param> /// <param name="IsStyled">If TRUE the text is styled</param> /// <returns>Returns recently added to SVG XML "text" node</returns> public XmlNode AddText( Node ActiveNode, string Text2Render, Font Font2Render, RectangleF Rect2Render, Color Color2Render, StringFormat TextFormat2Render , bool IsStyled ) { return AddText( ActiveNode, Text2Render, Font2Render, Rect2Render, Color2Render, TextFormat2Render , IsStyled , 0 ); }
internal void fireTreeCollapsed(Node root) { if (TreeCollapsed != null) TreeCollapsed(this, new NodeEventArgs(root)); }
/// <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; }