internal Path(MindFusion.LayoutSystem.Path path) { _nodes = new ChartObjectCollection(); _links = new ArrowCollection(); _items = new ChartObjectCollection(); foreach (FCNode node in path.Nodes) _nodes.Add(node.Node); foreach (FCLink link in path.Links) _links.Add(link.Arrow); foreach (object item in path.Items) { if (item is FCLink) _items.Add((item as FCLink).Arrow); else _items.Add((item as FCNode).Node); } }
/// <summary> /// Add Flowchart.Net box as a XML node into VDX /// </summary> /// <param name="newBox">Flowchart.NET box node</param> /// <param name="mainGroup">Flowchart.NET group if the box is attached to the group, set to [null] otherwise </param> /// <param name="IsGroup">Bool flag: set to [true] if the box is main group frame</param> /// <returns>[true] if successfull [false] otherwise</returns> private bool AddBox(MindFusion.FlowChartX.Box newBox, MindFusion.FlowChartX.Group mainGroup, bool IsGroup) { return AddBox(newBox.BoundingRect, getID(newBox), newBox.RotationAngle, newBox.ShapeOrientation, newBox.Image, newBox.FillColor, newBox.FrameColor, newBox.TextColor, newBox.Font, newBox.Transparent, newBox.Pen, newBox.Brush, newBox.EnableStyledText,newBox.Text, newBox.Style, newBox.Shape, (mainGroup == null) ? RectangleF.Empty : ( mainGroup.MainObject as Node ).BoundingRect , IsGroup, newBox.TextFormat.Alignment); }
private void FraimDiagram_NodeCreated(object sender, MindFusion.Diagramming.NodeEventArgs e) { ShapeNode node = e.Node as ShapeNode; if (node != null) { AddFrameFrm frm = new AddFrameFrm(); if (frm.ShowDialog()== DialogResult.OK) { Frame frame = new Frame { FrameId = ClassFactory.kBase.GetMaxNodeId(), FrameName = frm.TextBox }; node.Id = frame.FrameId; node.Text = frame.FrameName; ClassFactory.kBase.AddFrame(frame); TreeNode frameitem = new TreeNode { Text = frame.FrameName }; FrameTreeView.Nodes.Add(frameitem); } } }
public Pen(MindFusion.FlowChartX.Brush brush) { Brush = brush; _color = Color.Black; _compoundArray = null; _dashStyle = DashStyle.Solid; _dashPattern = null; _dashOffset = 0.0f; _width = 0.0f; _lineJoin = LineJoin.Miter; _miterLimit = 10.0f; }
/// <summary> /// 'BoxImported' Event handler /// </summary> /// <param name="Box">Flowchart.NET Box object</param> /// <param name="VisioShapeName">Source Visio's shape name</param> /// <param name="VisioExtraData">Some extra data</param> protected virtual void OnBoxImported(MindFusion.FlowChartX.Box Box, string VisioShapeName, string VisioExtraData) { if (BoxImported != null) BoxImported(this, new BoxImportedArgs(Box, VisioShapeName)); }
/// <summary> /// Get styled text from Visio shape /// </summary> /// <param name="shape">XML node of the shape</param> /// <param name="Arrow">Arrow object to apply text to</param> /// <param name="Box">Box object to apply text to</param> /// <returns>Styled text of the Visio shape</returns> private string GetShapeText(XmlNode shape , MindFusion.FlowChartX.Arrow Arrow , MindFusion.FlowChartX.Box Box) { string sText = "", sPrefix = "", sSuffix = "", sTextAttr = "", sWholeText ="", sStyle = "", sPara = "", sAlign = "", sTemp = ""; int lStyle = 0, attr_count = 0, LineCount = 0; XmlNodeList attr_list = null; XmlNodeList text_list = null; XmlNode attr_node = null; StringAlignment TextAlignment = StringAlignment.Center; bool IsRight = false; try { attr_list = shape.SelectNodes("vdx:Text/vdx:cp", ns); text_list = shape.SelectNodes("vdx:Text/text()", ns); sPara = GetShapeAttr("vdx:Text/vdx:pp","IX", shape); if ( sPara!=null ) { sTemp = GetShapeAttr(String.Format("vdx:Para[@IX='{0}']/vdx:HorzAlign", sPara),"", shape); if ( sTemp!=null ) { sAlign = sTemp; } } LineCount = text_list.Count; foreach ( XmlNode text_node in text_list ) { if ( text_node == null ) { attr_count++; continue; } sPrefix = ""; sText = ""; sSuffix = ""; sText = text_node.InnerText.ToString(); sText = sText.Replace("«", "\""); sText = sText.Replace("»", "\""); attr_node = attr_list[attr_count]; if ( attr_node != null) { sTextAttr = attr_node.Attributes["IX"].Value.ToString(); sStyle = GetShapeAttr(String.Format("vdx:Char[@IX='{0}']/vdx:Style", sTextAttr),"",shape); if ( sStyle == null ) lStyle = 0; else lStyle = System.Convert.ToInt16(sStyle); if (( lStyle & 0x1 ) == 0x1 ) { sPrefix+=" <b>"; sSuffix+=" </b> "; if (Box != null && Box.Font != null && Box.Font.Bold) Box.Font = new Font(Box.Font, Box.Font.Style & ~FontStyle.Bold); } if (( lStyle & 0x2 ) == 0x2) { sPrefix+=" <i>"; sSuffix+=" </i> "; if (Box != null && Box.Font != null && Box.Font.Italic) Box.Font = new Font(Box.Font, Box.Font.Style & ~FontStyle.Italic); } if (( lStyle & 0x4 ) == 0x4) { sPrefix+=" <u>"; sSuffix+=" </u> "; if (Box != null && Box.Font != null && Box.Font.Underline) Box.Font = new Font(Box.Font, Box.Font.Style & ~FontStyle.Underline); } } sWholeText+=sPrefix + sText + sSuffix; attr_count++; } if ( sAlign == "0") TextAlignment = StringAlignment.Far; else if ( sAlign == "1") TextAlignment = StringAlignment.Center; else if ( sAlign == "2") { TextAlignment = StringAlignment.Far; IsRight = true; } else TextAlignment = StringAlignment.Center; if ( LineCount >1 ) TextAlignment = StringAlignment.Center; if ( sAlign!=null ) { if ( Box!=null ) { if (IsRight) { Box.TextFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft; } Box.TextFormat.Alignment = TextAlignment; } } } catch ( Exception ex) { sWholeText = null; Trace.WriteLine(String.Format("{0} error {1}\n","GetShapeText",ex.Message)); } return sWholeText; }
/// <summary> /// Get styled text from Visio shape /// </summary> /// <param name="shape">XML node of the shape</param> /// <param name="Arrow">Arrow object to apply text to</param> /// <returns>Styled text of the Visio shape</returns> private string GetShapeText(XmlNode shape , MindFusion.FlowChartX.Arrow Arrow ) { return GetShapeText( shape , Arrow , null); }
/// <summary> /// 'ArrowImported' Event handler /// </summary> /// <param name="Arrow">Flowchart.NET Arrow object</param> /// <param name="VisioLinkData">Some extra data/param> protected virtual void OnArrowImported(MindFusion.FlowChartX.Arrow Arrow, string shapeName) { if (ArrowImported != null) ArrowImported(this, new ArrowImportedArgs(Arrow, shapeName)); }
public void Remove(MindFusion.FlowChartX.Path p) { List.Remove(p); }
/// <summary> /// Converts Flowchart.NET box into SVG /// </summary> /// <param name="newArrow">Box reference</param> /// <returns>TRUE if successfull otherwise FALSE</returns> private bool CreateBox(MindFusion.FlowChartX.Box newBox) { bool bOk = false; float fX = 0, fY = 0, fW = 0, fH = 0, fLine = 0; long lLine = 0; XmlNode last_node = null; try { if ( newBox == null ) throw new Exception("Empty box reference passed"); if (( !newBox.Visible ) && ( !InvisibleItems)) return true; if (( newBox.Transparent ) && (newBox.Image == null)) { sMan.AddText(newBox); return true; } fX = newBox.BoundingRect.X; fY = newBox.BoundingRect.Y; fW = newBox.BoundingRect.Width; fH = newBox.BoundingRect.Height; fLine = newBox.Pen.Width; if (( newBox.ShapeOrientation == 90 )|| (newBox.ShapeOrientation == 270 )) { float lTemp = fW; fW = fH; fH = lTemp; } lLine = Unit2Pix(fLine); if ( lLine == 0 ) lLine = 1; //Color boxFillColor = newBox.Locked ? Color.Transparent : newBox.FillColor; Color boxFillColor = newBox.FillColor; switch ( GetBoxStyle(newBox)) { case BoxStyle.Rhombus: last_node = sMan.AddPath(sMan.Shape2Path(newBox), String.Format("{0}px",lLine), newBox.Pen.Color, boxFillColor); break; case BoxStyle.Ellipse: last_node = sMan.AddEllipse(String.Format("{0}px",Unit2Pix(fX + fW/2)), String.Format("{0}px",Unit2Pix(fY + fH/2)), String.Format("{0}px",Unit2Pix(fW/2)), String.Format("{0}px",Unit2Pix(fH/2)), String.Format("{0}px", lLine), boxFillColor, newBox.Pen.Color); break; case BoxStyle.Rectangle: last_node = sMan.AddRect(String.Format("{0}px",Unit2Pix(fX)), String.Format("{0}px",Unit2Pix(fY)), String.Format("{0}px",Unit2Pix(fW)), String.Format("{0}px",Unit2Pix(fH)), String.Format("{0}px",lLine), boxFillColor, newBox.Pen.Color, null, null, newBox.Image, newBox.Transparent ? pChart.BackColor : Color.Empty); break; case BoxStyle.RoundedRectangle: last_node = sMan.AddRect(String.Format("{0}px",Unit2Pix(fX)), String.Format("{0}px",Unit2Pix(fY)), String.Format("{0}px",Unit2Pix(fW)), String.Format("{0}px",Unit2Pix(fH)), String.Format("{0}px",lLine), boxFillColor, newBox.Pen.Color, "10px", "10px", newBox.Image, newBox.Transparent ? pChart.BackColor : Color.Empty); break; case BoxStyle.Shape: case BoxStyle.Delay: default: last_node = sMan.AddPath(sMan.Shape2Path(newBox), String.Format("{0}px",lLine), newBox.Pen.Color, boxFillColor); break; } sMan.AddGradient(last_node,newBox.Brush); sMan.AddRotation(last_node,newBox); sMan.AddText(newBox); bOk = true; } catch ( Exception ex ) { Trace.WriteLine(String.Format("{0} error {1}\n","CreateBox",ex.Message)); bOk = false; } return bOk; }
/// <summary> /// Converts Flowchart.NET table into SVG /// </summary> /// <param name="newTable">Table reference</param> /// <returns>TRUE if successfull otherwise FALSE</returns> private bool CreateTable(MindFusion.FlowChartX.Table newTable) { bool bOk = false; float fX = 0, fY = 0, fW = 0, fH = 0, fLine = 0; long lLine = 0; XmlNode last_node = null; ArrayList spannedCells = new ArrayList(); try { fX = newTable.BoundingRect.X; fY = newTable.BoundingRect.Y; fW = newTable.BoundingRect.Width; fH = newTable.BoundingRect.Height; fLine = newTable.Pen.Width; lLine = Unit2Pix(fLine); if ( lLine == 0 ) lLine = 1; last_node = sMan.AddRect(String.Format("{0}px",Unit2Pix(fX)), String.Format("{0}px",Unit2Pix(fY)), String.Format("{0}px",Unit2Pix(fW)), String.Format("{0}px",Unit2Pix(newTable.CaptionHeight)), String.Format("{0}px",lLine), newTable.FillColor, newTable.FrameColor, null, null, newTable.Image); sMan.AddGradient(last_node, newTable.Brush); sMan.AddText(null, newTable.Caption, newTable.Font, new RectangleF(fX, fY,fW,newTable.CaptionHeight), newTable.CaptionColor ,pChart.TextFormat, newTable.EnableStyledText); last_node = sMan.AddRect(String.Format("{0}px",Unit2Pix(fX)), String.Format("{0}px",Unit2Pix(fY + newTable.CaptionHeight)), String.Format("{0}px",Unit2Pix(fW)), String.Format("{0}px",Unit2Pix(fH - newTable.CaptionHeight)), String.Format("{0}px",lLine), newTable.FillColor, newTable.FrameColor, null, null, newTable.Image); sMan.AddGradient(last_node, newTable.Brush); fW = 0; fH = 0; int RowCount = newTable.CurrScrollRow , ColCount = 0, AutoColls = 0; float fCellW = 0, fCellH = 0, fCellX = 0, fCellY = 0 , rh =0, fStepW = 0, fSumW =0; bool CellIsSpanned = false; fCellX = fX; fCellY = fY + newTable.CaptionHeight; AutoColls = 0; fSumW =0; foreach ( Table.Column col in newTable.Columns) { if (col.ColumnStyle == MindFusion.FlowChartX.ColumnStyle.AutoWidth ) AutoColls++; else fSumW+=col.Width; } while (RowCount<newTable.Rows.Count) { if ( RowCount!=newTable.CurrScrollRow ) rh = newTable.Rows[RowCount-1].Height; else rh = 0; fCellY+=rh; if ( fCellY > newTable.BoundingRect.Bottom - rh) break; while (ColCount<newTable.Columns.Count ) { if ( ColCount!=0) fCellX+= newTable.Columns[ColCount-1].Width; Table.Cell cell = newTable[ColCount, RowCount]; if (!spannedCells.Contains(cell)) { fCellH = 0; for (int i = RowCount; i <RowCount + cell.RowSpan; i++) { fCellH+= newTable.Rows[i].Height; fCellW = 0; bool bPass = true; for (int j = ColCount; j < ColCount + cell.ColumnSpan; j++) { if ((newTable.Columns[ColCount].ColumnStyle == MindFusion.FlowChartX.ColumnStyle.AutoWidth) && bPass) { fStepW = ( newTable.BoundingRect.Width - fSumW ) / AutoColls; bPass = false; } else fStepW = newTable.Columns[j].Width; fCellW+=fStepW; spannedCells.Add(newTable[j,i]); //Trace.WriteLine(String.Format("Pos ({0}, {1} ) Spanned ({2},{3})", RowCount, ColCount, i,j)); } } if ( AutoColls == 0 ) { if ( ColCount == ( newTable.Columns.Count -1) ) fCellW += ( newTable.BoundingRect.Width - fSumW); //fCellW = newTable.BoundingRect.Right - fCellX + ( cell.Text == "" ? 0 : 15) ; } RectangleF cellRect = new RectangleF(fCellX, fCellY, fCellW, fCellH); CellIsSpanned = ((cell.ColumnSpan>1) || ( cell.RowSpan>1)); sMan.AddText( CellIsSpanned ? null : newTable , cell.Text, newTable.Font, cellRect, newTable.TextColor , cell.TextFormat, newTable.EnableStyledText); sMan.AddRect(Unit2PixStr(cellRect.X), Unit2PixStr(cellRect.Y), Unit2PixStr(cellRect.Width), Unit2PixStr(cellRect.Height), "1px", Color.Transparent,Color.Transparent,null,null,cell.Image, newTable.FillColor, cell.ImageAlign, cellRect); if ( newTable.CellFrameStyle!= CellFrameStyle.None) sMan.AddRect(Unit2PixStr(cellRect.X), Unit2PixStr(cellRect.Y), Unit2PixStr(cellRect.Width), Unit2PixStr(cellRect.Height), "1px", Color.Transparent,newTable.FrameColor); } ColCount++; } fCellX = fX; ColCount = 0; RowCount++; } bOk = true; } catch ( Exception ex ) { Trace.WriteLine(String.Format("{0} error {1}\n","CreateTable",ex.Message)); bOk = false; } return bOk; }
/// <summary> /// Gets Flowchart.NET box's style /// </summary> /// <param name="newBox">Box reference</param> /// <returns>Returned BoxStyle</returns> private BoxStyle GetBoxStyle (MindFusion.FlowChartX.Box newBox) { BoxStyle retStyle= BoxStyle.Shape; if ( newBox.Shape == null ) return newBox.Style; if (newBox.Style != BoxStyle.Shape) return newBox.Style; switch ( newBox.Shape.ToString()) { case "Rectangle": retStyle = BoxStyle.Rectangle; break; case "Ellipse": retStyle = BoxStyle.Ellipse; break; case "RoundRect": retStyle = BoxStyle.RoundedRectangle; break; default: retStyle = newBox.Style; break; }; return retStyle; }
/// <summary> /// Converts Flowchart.NET arrow into SVG /// </summary> /// <param name="newArrow">Arrow reference</param> /// <returns>TRUE if successfull otherwise FALSE</returns> private bool CreateArrow(MindFusion.FlowChartX.Arrow newArrow) { bool bOk = false; string sPath = "", sPathPart = ""; int iCount = 0; try { if ( newArrow.Origin!=null ) { if ((!newArrow.Origin.Visible) && (!InvisibleItems)) return true; } if ( newArrow.Destination!=null ) { if ((!newArrow.Destination.Visible) && (!InvisibleItems)) return true; } if ( newArrow.Style == ArrowStyle.Bezier ) { sPath = String.Format("M{0},{1} C{2},{3} {4},{5} {6},{7} " , Unit2Pix(newArrow.ControlPoints[0].X), Unit2Pix(newArrow.ControlPoints[0].Y), Unit2Pix(newArrow.ControlPoints[1].X), Unit2Pix(newArrow.ControlPoints[1].Y), Unit2Pix(newArrow.ControlPoints[newArrow.ControlPoints.Count -2].X), Unit2Pix(newArrow.ControlPoints[newArrow.ControlPoints.Count -2].Y), Unit2Pix(newArrow.ControlPoints[newArrow.ControlPoints.Count -1].X), Unit2Pix(newArrow.ControlPoints[newArrow.ControlPoints.Count -1].Y)); } else { sPath = String.Format("M{0},{1} ", Unit2Pix(newArrow.ControlPoints[0].X), Unit2Pix(newArrow.ControlPoints[0].Y) ); for ( iCount = 1; iCount<newArrow.ControlPoints.Count ; iCount++) { sPathPart = String.Format("L{0},{1} ", Unit2Pix(newArrow.ControlPoints[iCount].X), Unit2Pix(newArrow.ControlPoints[iCount].Y)); sPath+=sPathPart; } } if ( sPath=="" ) return false; sPath = sPath.TrimEnd(); string sWidth = "1px"; if ( newArrow.Pen.Width != 0 ) String.Format("{0}px", Unit2Pix(newArrow.Pen.Width)); sMan.AddPath(sPath , sWidth , newArrow.PenColor,Color.Transparent); sPath = ""; sPath = sMan.GetArrowHead(newArrow.HeadShape); XmlNode last_node = sMan.AddPath(sPath , sWidth , newArrow.PenColor,newArrow.PenColor); sPath = ""; sPath = sMan.GetArrowHead(newArrow.BaseShape); last_node = sMan.AddPath(sPath , sWidth , newArrow.PenColor,newArrow.PenColor); RectangleF rect = RectangleF.Empty; float angle = 0; rect = getTextRect(System.Drawing.Graphics.FromHwnd(SvgManager.GetActiveWindow()), newArrow.Style , newArrow.TextStyle, newArrow.ControlPoints, newArrow.TextColor,newArrow.SegmentCount, newArrow.Text, newArrow.Font, RectangleF.Empty, ref angle); if (!rect.Equals(RectangleF.Empty)) { StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; XmlNode text_added = sMan.AddText( null ,newArrow.Text, newArrow.Font, rect, newArrow.TextColor , sf , false, angle); } bOk = true; } catch ( Exception ex ) { Trace.WriteLine(String.Format("{0} error {1}\n","CreateArrow",ex.Message)); bOk = false; } return bOk; }
/// <summary> /// Add Flowchart.Net table as a XML node into VDX /// </summary> /// <param name="newTable">Flowchart.NET table node</param> /// <returns>[true] if successfull [false] otherwise</returns> private bool AddTable(MindFusion.FlowChartX.Table newTable) { if (m_ExportTablesAsGroups) return AddTable2(newTable); bool bOk = false; double lLeft = 0, lTop = 0, lW = 0, lH = 0, lWG = 0, lHG =0, lLeftG = 0, lRightG = 0, lTopG = 0, lBottomG =0; string sTemp = null, sTemp2 = null; XmlNode table_shapes = null, shapeCaption = null, shapeBody = null; int RowCount = 0, ColCount = 0; long ID = 0; try { // Inserting new <shape> node shapeNew = shapeRoot.InsertAfter( shapeTemplate.Clone(), shapeLast); if ( shapeNew == null ) return false; ID = (long) getID(newTable); sTemp = GetGUID(); // Setting entity - like shape parameters as 'group' shapeLast = shapeNew; shapeNew.Attributes["ID"].Value = ID.ToString(); //Trace.WriteLine(String.Format("Table {0}\t{1}", ID.ToString(), sTemp)); shapeNew.Attributes["Name"].Value = String.Format("Entity 2.{0}",ID); shapeNew.Attributes["Master"].Value = "3"; //"47";//"3"; shapeNew.Attributes.RemoveNamedItem("NameU"); RemoveNode(shapeNew, "vdx:LayerMem", true); RemoveNode(shapeNew, "vdx:Event", true); RemoveNode(shapeNew, "vdx:Text", true); RemoveNode(shapeNew, "vdx:Line", true); RemoveNode(shapeNew, "vdx:Fill", true); SetShapeAttr("vdx:Misc/vdx:ObjType","", shapeNew, "8"); SetShapeAttr("","Type", shapeNew, "Group"); if ( sTemp != null ) { shapeNew.Attributes["UniqueID"].Value = sTemp; } // Getting table dimensions lLeftG = newTable.BoundingRect.Left; lRightG = newTable.BoundingRect.Right; lTopG = newTable.BoundingRect.Top; lBottomG = newTable.BoundingRect.Bottom; lWG = newTable.BoundingRect.Width; lHG = newTable.BoundingRect.Height; // Setting entity frame's dimensions SetShapeDim(shapeNew, "vdx:XForm/vdx:PinX", lLeftG + lWG/2, true); SetShapeDim(shapeNew, "vdx:XForm/vdx:PinY", lDocY - ( lTopG + lHG/2), true); SetShapeDim(shapeNew, "vdx:XForm/vdx:Width", lWG , true); SetShapeDim(shapeNew, "vdx:XForm/vdx:Height", lHG, true) ; SetShapeDim(shapeNew, "vdx:XForm/vdx:LocPinX", lWG/2 , true ); SetShapeDim(shapeNew, "vdx:XForm/vdx:LocPinY", lHG/2 , true); // Getting & setting font's parameters Font ShapeFont = null; ShapeFont = newTable.Font; if (ShapeFont == null) ShapeFont = pChart.Font; SetShapeFont(shapeNew, ShapeFont); // Creating <Shapes> tree table_shapes = shapeNew.InsertAfter(doc.CreateNode(XmlNodeType.Element,"Shapes","http://schemas.microsoft.com/visio/2003/core"), shapeNew.LastChild); if ( table_shapes == null ) return false; // Inserting <shape> node for table's caption shapeCaption = table_shapes.InsertAfter(shapeTemplate.Clone(), table_shapes.LastChild); if ( shapeCaption == null ) return false; lW = lWG; lH = newTable.CaptionHeight; lLeft = lWG/2; // 0 lTop = lHG - newTable.CaptionHeight;//0 ID = NextID(); sTemp = GetGUID(); // Setting enity caption's attributes shapeCaption.Attributes["ID"].Value = ID.ToString(); SetShapeAttr("","MasterShape",shapeCaption,"6");//"9");//"6"); //Trace.WriteLine(String.Format("Caption {0}\t{1}", ID.ToString(), sTemp)); RemoveNode(shapeCaption,"Master",false); RemoveNode(shapeCaption,"Name",false); RemoveNode(shapeCaption,"NameU",false); RemoveNode(shapeCaption, "vdx:Group", true); if ( sTemp != null ) { shapeCaption.Attributes["UniqueID"].Value = sTemp; } // Setting enity caption's dimensions SetShapeDim(shapeCaption, "vdx:XForm/vdx:PinX",lLeft, true); SetShapeDim(shapeCaption, "vdx:XForm/vdx:PinY", lTop, true); SetShapeDim(shapeCaption, "vdx:XForm/vdx:Width", lW , true); SetShapeDim(shapeCaption, "vdx:XForm/vdx:Height", lH, true) ; SetShapeDim(shapeCaption, "vdx:XForm/vdx:LocPinX", lLeft , true ); //0 SetShapeDim(shapeCaption, "vdx:XForm/vdx:LocPinY", 0 , true); // Getting & setting caption's font SetShapeFont(shapeCaption, ShapeFont); SetText(shapeCaption, newTable.Caption, newTable.EnableStyledText, ShapeFont); // Getting & setting caption's colors SetShapeColor(shapeCaption, "vdx:Fill/vdx:FillForegnd", newTable.FillColor); SetShapeColor(shapeCaption, "vdx:Char/vdx:Color", newTable.CaptionColor); SetShapeColor(shapeCaption, "vdx:Line/vdx:LineColor",newTable.Pen.Color); // Inserting <shape> node for table's body shapeBody = table_shapes.InsertAfter(shapeTemplate.Clone(), table_shapes.LastChild); if ( shapeBody == null ) return false; lW = lWG; lH = lHG - newTable.CaptionHeight; lLeft = lWG/2; // 0 lTop = lHG - newTable.CaptionHeight;//0 // Setting enity body's attributes ID = NextID(); sTemp = GetGUID(); shapeBody.Attributes["ID"].Value = ID.ToString(); SetShapeAttr("","MasterShape",shapeBody,"7");//"10");//"7"); //Trace.WriteLine(String.Format("Body {0}\t{1}", ID.ToString(), sTemp)); RemoveNode(shapeBody,"Master",false); RemoveNode(shapeBody,"Name",false); RemoveNode(shapeBody,"NameU",false); RemoveNode(shapeBody, "vdx:Group", true); if ( sTemp != null ) { shapeBody.Attributes["UniqueID"].Value = sTemp; } // Setting enity body's dimensions SetShapeDim(shapeBody, "vdx:XForm/vdx:PinX",lLeft, true); SetShapeDim(shapeBody, "vdx:XForm/vdx:PinY", lTop, true); SetShapeDim(shapeBody, "vdx:XForm/vdx:Width", lW , true); SetShapeDim(shapeBody, "vdx:XForm/vdx:Height", lH, true) ; SetShapeDim(shapeBody, "vdx:XForm/vdx:LocPinX", lLeft , true ); SetShapeDim(shapeBody, "vdx:XForm/vdx:LocPinY", lTop , true); SetShapeColor(shapeBody, "vdx:Fill/vdx:FillForegnd", newTable.FillColor); SetShapeColor(shapeBody, "vdx:Char/vdx:Color", newTable.TextColor); SetShapeColor(shapeBody, "vdx:Line/vdx:LineColor",newTable.Pen.Color); // Collecting text from all table rows sTemp = ""; for ( RowCount =1; RowCount<=newTable.Rows.Count; RowCount++ ) { for ( ColCount =1; ColCount<=newTable.Columns.Count; ColCount++ ) { sTemp2+=newTable[ColCount -1 ,RowCount -1 ].Text + " "; } sTemp2 = sTemp2.Trim(); sTemp+=sTemp2 + "\n"; sTemp2 = ""; } // Setting collected text into tanle's body SetShapeFont(shapeBody, ShapeFont); SetText(shapeBody, sTemp, newTable.EnableStyledText, ShapeFont); bOk = true; } catch ( Exception ex ) { Trace.WriteLine(String.Format("{0} error {1}\n","AddTable",ex.Message)); bOk = false; } return bOk; }
private bool AddTable2(MindFusion.FlowChartX.Table newTable) { bool IsAdded = false; if (AddBox(newTable.BoundingRect, getID(newTable), 0, 0, newTable.Image, Color.Transparent, newTable.FrameColor, newTable.TextColor, newTable.Font, false, newTable.Pen, newTable.Brush, newTable.EnableStyledText, "", BoxStyle.Rectangle, null, RectangleF.Empty, true, StringAlignment.Center)) { AddBox(newTable.BoundingRect, NextID(), 0, 0 , null, newTable.FillColor , newTable.FrameColor, newTable.TextColor, newTable.Font, false , newTable.Pen, newTable.Brush, newTable.EnableStyledText, "" , BoxStyle.Rectangle, null , newTable.BoundingRect, false, StringAlignment.Center); String sTag = ""; float fX = newTable.BoundingRect.Left, fY = newTable.BoundingRect.Top + newTable.CaptionHeight, fW = (float) Math.Abs(newTable.BoundingRect.Right - newTable.BoundingRect.Left), fH = (float) Math.Abs(newTable.BoundingRect.Top - newTable.BoundingRect.Bottom), fCellH = 0, fCellX = 0, fCellY = 0 , rh =0, fStepW = 0, fSumW =0, fCellW = 0; int ColCount = 0, RowCount = 0, AutoColls = 0; bool CellIsSpanned = false; RowCount = newTable.CurrScrollRow; ColCount = 0; AutoColls = 0; fCellX = fX; fCellY = fY;//+ newTable.CaptionHeight; AutoColls = 0; fSumW =0; foreach ( Table.Column col in newTable.Columns) { if (col.ColumnStyle == MindFusion.FlowChartX.ColumnStyle.AutoWidth ) AutoColls++; else fSumW+=col.Width; } while (RowCount<newTable.Rows.Count) { if ( RowCount!=newTable.CurrScrollRow ) rh = newTable.Rows[RowCount-1].Height; else rh = 0; fCellY+=rh; if ( fCellY > newTable.BoundingRect.Bottom - rh) break; while (ColCount<newTable.Columns.Count ) { if ( ColCount!=0) fCellX+= newTable.Columns[ColCount-1].Width; Table.Cell cell = newTable[ColCount, RowCount]; if ( cell.Tag is string) sTag = cell.Tag.ToString(); else sTag = ""; if (sTag != "span") { fCellH = 0; for (int i = RowCount; i <RowCount + cell.RowSpan; i++) { fCellH+= newTable.Rows[i].Height; fCellW = 0; bool bPass = true; for (int j = ColCount; j < ColCount + cell.ColumnSpan; j++) { if ((newTable.Columns[ColCount].ColumnStyle == MindFusion.FlowChartX.ColumnStyle.AutoWidth) && bPass) { fStepW = ( newTable.BoundingRect.Width - fSumW ) / AutoColls; bPass = false; } else fStepW = newTable.Columns[j].Width; fCellW+=fStepW; newTable[j,i].Tag = "span"; //Trace.WriteLine(String.Format("Pos ({0}, {1} ) Spanned ({2},{3})", RowCount, ColCount, i,j)); } } if ( AutoColls == 0 ) { if ( ColCount == ( newTable.Columns.Count -1) ) fCellW += ( newTable.BoundingRect.Width - fSumW); //fCellW = newTable.BoundingRect.Right - fCellX + ( cell.Text == "" ? 0 : 15) ; } RectangleF cellRect = new RectangleF(fCellX, fCellY, fCellW, fCellH); CellIsSpanned = ((cell.ColumnSpan>1) || ( cell.RowSpan>1)); IsAdded = AddBox(cellRect, NextID(), 0, 0 , null, Color.Transparent , (( newTable.CellFrameStyle == CellFrameStyle.None ) ? Color.Transparent : newTable.FrameColor), cell.TextColor, (newTable.Font == null) ? pChart.Font : newTable.Font , false , newTable.Pen, newTable.Brush, newTable.EnableStyledText, cell.Text , BoxStyle.Rectangle, null , newTable.BoundingRect , false, ( cell.TextFormat == null ) ? StringAlignment.Center : cell.TextFormat.Alignment ); if (cell.Image != null) { float fiX = 0, fiY = 0, fiW = 0, fiH = 0; if (GetImageDim(cell.Image, cellRect, cell.ImageAlign, ref fiW, ref fiH, ref fiX, ref fiY)) { RectangleF cellImageRect = new RectangleF(fiX, fiY, fiW, fiH); IsAdded = AddBox(cellImageRect, NextID(), 0, 0, cell.Image, Color.Transparent, Color.Transparent, Color.Transparent, (newTable.Font == null) ? pChart.Font : newTable.Font, true, newTable.Pen, newTable.Brush, false, "" , BoxStyle.Rectangle, null , newTable.BoundingRect , false, StringAlignment.Center); } } } ColCount++; } fCellX = fX; ColCount = 0; RowCount++; } if ( newTable.CaptionHeight!=0 ) { RectangleF captionRect = new RectangleF(newTable.BoundingRect.Left, newTable.BoundingRect.Top, newTable.BoundingRect.Width, newTable.CaptionHeight); IsAdded = AddBox(captionRect, NextID(), 0, 0 , null, newTable.FillColor, newTable.FrameColor, newTable.CaptionColor , (newTable.Font == null) ? pChart.Font : newTable.Font , false , newTable.Pen, newTable.Brush, newTable.EnableStyledText, newTable.Caption , BoxStyle.Rectangle, null , newTable.BoundingRect , false, ( newTable.CaptionFormat == null ) ? StringAlignment.Center : newTable.CaptionFormat.Alignment ); } } return true; }
/// <summary> /// Adds text to speciafied Flowchart.NET box /// </summary> /// <param name="newBox">Box reference</param> /// <returns>Returns recently added to SVG XML "text" node</returns> public XmlNode AddText(MindFusion.FlowChartX.Box newBox) { RectangleF cloneRect = new RectangleF(newBox.BoundingRect.X, newBox.BoundingRect.Y, newBox.BoundingRect.Width ,newBox.BoundingRect.Height); XmlNode nd = AddText(newBox, newBox.Text,newBox.Font,cloneRect,newBox.TextColor, newBox.TextFormat, newBox.EnableStyledText); AddRotation(nd,newBox); return nd; }
/// <summary> /// Modifies SVG node fill color by adding gradient fill /// </summary> /// <param name="ShapeNode">XML node of the SVG that reuires to change its filling</param> /// <param name="ShapeBrush">Flowchart.NET shape brush</param> /// <returns>TRUE is successfull otherwise FALSE</returns> public bool AddGradient(XmlNode ShapeNode, MindFusion.FlowChartX.Brush ShapeBrush) { bool bOk = false; XmlNode m_InnerGradient = null , m_XmlTemp = null; string sType = "" , sGradientName = "" , sFore = "", sBack = ""; try { if (!IsValid()) return true; if ( ShapeNode == null ) return true; sType = ShapeBrush.GetType().ToString(); if ( sType.IndexOf("LinearGradientBrush")<0) return true; MindFusion.FlowChartX.LinearGradientBrush grBrush = null; grBrush = (MindFusion.FlowChartX.LinearGradientBrush) ShapeBrush; if ( grBrush == null ) return true; m_InnerGradient = m_InnerDefs.InsertAfter(m_InnerDoc.CreateNode(XmlNodeType.Element,"linearGradient", sNsDefault), m_InnerDefs.LastChild); if ( m_InnerGradient == null ) return false; sFore = SvgManager.Color2Str(grBrush.LinearColors[0]); sBack = SvgManager.Color2Str(grBrush.LinearColors[1]); if ( sFore == "none" ) return true; if ( sBack == "none" ) return true; sGradientName = String.Format("Gradient{0}", iGradientCount); m_InnerGradient.Attributes.Append(m_InnerDoc.CreateAttribute("id")); m_InnerGradient.Attributes["id"].Value = sGradientName; iGradientCount++; m_XmlTemp = m_InnerGradient.InsertAfter(m_InnerDoc.CreateNode(XmlNodeType.Element,"stop", sNsDefault), m_InnerGradient.LastChild); if ( m_XmlTemp == null ) return false; m_XmlTemp.Attributes.Append(m_InnerDoc.CreateAttribute("offset")); m_XmlTemp.Attributes["offset"].Value = "5%"; m_XmlTemp.Attributes.Append(m_InnerDoc.CreateAttribute("stop-color")); m_XmlTemp.Attributes["stop-color"].Value = sBack; m_XmlTemp = m_InnerGradient.InsertAfter(m_InnerDoc.CreateNode(XmlNodeType.Element,"stop", sNsDefault), m_InnerGradient.LastChild); if ( m_XmlTemp == null ) return false; m_XmlTemp.Attributes.Append(m_InnerDoc.CreateAttribute("offset")); m_XmlTemp.Attributes["offset"].Value = "95%"; m_XmlTemp.Attributes.Append(m_InnerDoc.CreateAttribute("stop-color")); m_XmlTemp.Attributes["stop-color"].Value = sFore; if ( ShapeNode.Attributes["fill"] == null ) return false; ShapeNode.Attributes["fill"].Value = String.Format("url(#{0})", sGradientName); bOk = true; } catch (Exception ex) { Trace.WriteLine(String.Format("{0} error {1}\n","SvgManager.AddGradient",ex.Message)); bOk = false; } return bOk; }
internal PathCollection(MindFusion.LayoutSystem.PathList paths) { foreach (MindFusion.LayoutSystem.Path path in paths) Add(new Path(path)); }
/// <summary> /// 'GroupImported' Event handler /// </summary> /// <param name="Group">Flowchart.NET Group object</param> /// protected virtual void OnGroupImported( MindFusion.FlowChartX.Group Group) { if (GroupImported != null) GroupImported(this, new GroupImportedArgs(Group)); }
public void Add(MindFusion.FlowChartX.Path p) { List.Add(p); }
/// <summary> /// Get styled text from Visio shape /// </summary> /// <param name="shape">XML node of the shape</param> /// <param name="Box">Box object to apply text to</param> /// <returns>Styled text of the Visio shape</returns> private string GetShapeText(XmlNode shape , MindFusion.FlowChartX.Box Box ) { return GetShapeText( shape , null , Box); }
public void Insert(int i, MindFusion.FlowChartX.Path p) { List.Insert(i, p); }
/// <summary> /// Processing Visio shape converting it into Flowchart.NET node /// </summary> /// <param name="shape">Visio shape's XML node</param> /// <param name="ShapeType">String value of the shape type</param> /// <param name="group">Reference to parent group ( if any exists) </param> /// <returns>Returns [true] if successfull [false] otherwise</returns> private bool GetShapeRef(XmlNode shape, string ShapeType,MindFusion.FlowChartX.Group group) { string sShapeName, sUID = "", sType = "", sNameU= "", sPath="", sTemp = "", sStepX = "", sStepY = ""; long lShapeType = 0, lX = 0, lY =0, lWidth = 0, lHeight = 0, lPinY = 0, lPinX = 0, lLineWith = 0,lCount = 1, lPtX = 0, lPtY = 0 , lStepX = 0, lStepY = 0, lStartX =0 , lStartY = 0,lEndX = 0, lEndY = 0, lBeginX = 0, lBeginY = 0, lBoxX = 0, lBoxY = 0, lTemp = 0, lAdjustX = 0, lAdjustY = 0; double fAngle2 = 0; XmlNode node_temp = null; XmlNode xform1d_node = null; bool DontHideGroup = false; // Incrementing shape's count lShapesCount++; sUID = shape.Attributes["ID"].Value.ToString(); sType = shape.Attributes["Type"].Value.ToString(); sType = sType.ToLower(); // Getting 'XForm' node root XmlNode xform_node = shape.SelectSingleNode("vdx:XForm", ns); if ( xform_node == null) return false; // Getting Master shape's ID if any exist sMasterID = ""; if ( shape.Attributes["Master"] == null ) { if ( shape.Attributes["MasterShape"] != null ) { sMasterID = shape.Attributes["MasterShape"].Value.ToString(); } } else sMasterID = shape.Attributes["Master"].Value.ToString(); // Getting shape's 'NameU' tag if any exist sNameU = ""; if ( shape.Attributes["NameU"] != null ) sNameU = shape.Attributes["NameU"].Value.ToString(); sShapeName = sNameU; sNameU = sNameU.Trim(); sNameU = sNameU.ToLower(); if ( sNameU == "" ) { lShapeType |= (long) ShapeTypeEnum.ST_NO_NAMEU; } if (( sNameU == "") && (sMasterID!="")) { sPath = String.Format("vdx:Master[@ID='{0}']",sMasterID); sNameU = GetShapeAttr(sPath,"NameU", mastersRoot); sShapeName = sNameU; } if ( sNameU == null ) sNameU = ""; sNameU = sNameU.Trim(); sNameU = sNameU.ToLower(); // Shape is GROUP #if _POST_FIX_2_1 if (( sType.IndexOf("group")>=0 ) && ( sNameU.IndexOf("connector")<0)) #else if ( sType.IndexOf("group")>=0 ) #endif { lShapeType |= (long) ShapeTypeEnum.ST_GROUP; } // Shape is 'arrow - like' if (( sNameU.IndexOf("connector") >= 0 ) || ( sNameU.IndexOf("link") >= 0 ) || ( sNameU.IndexOf("generalization") >= 0 ) || ( sNameU.IndexOf("association") >= 0 ) || ( sNameU.IndexOf("composition")>=0) || ( sNameU == "relationship") || ( sNameU.IndexOf("parent to category") >= 0 ) || ( sNameU.IndexOf("categorytochild ") >= 0 ) || (sNameU.IndexOf("object flow")>=0) || (sNameU.IndexOf("control flow")>=0) || (sNameU.IndexOf("2-element constraint")>=0) || (sNameU.IndexOf("or constraint")>=0)) // (sNameU.IndexOf("shared navigable")>=0)) { lShapeType |= (long) ShapeTypeEnum.ST_CONNECTOR; } else { xform1d_node = shape.SelectSingleNode("vdx:XForm1D", ns); if ( xform1d_node != null) { //return true; // ??? REMOVED ??? lShapeType |= (long) ShapeTypeEnum.ST_CONNECTOR; } } // Shape is 'entity - like' if ( ( sNameU == "entity 1" ) || ( sNameU.IndexOf("entity." )>=0) || ( sNameU == "entity 2" ) || ( sNameU == "entity" ) || ( sNameU =="view")) { lShapeType |= (long) ShapeTypeEnum.ST_ENTITY; } // Shape is 'entity2 - like' if ( sNameU == "entity 2" ) { lShapeType |= (long) ShapeTypeEnum.ST_ENTITY2; } // Shape is part of 'entity - like' group if ( ShapeType == "entity" ) { lShapeType |= (long) ShapeTypeEnum.ST_PART_OF_ENTITY; lShapeType |= (long) ShapeTypeEnum.ST_SHAPE; } // Shape is part of 'entity2 - like' group if ( ShapeType == "entity 2" ) { lShapeType |= (long) ShapeTypeEnum.ST_PART_OF_ENTITY; lShapeType |= (long) ShapeTypeEnum.ST_PART_OF_ENTITY2; lShapeType |= (long) ShapeTypeEnum.ST_SHAPE; } // Shape is part of 'arrow - like' group if ( ShapeType == "arrow" ) { lShapeType |= (long) ShapeTypeEnum.ST_PART_OF_ARROW; lShapeType |= (long) ShapeTypeEnum.ST_SHAPE; } if (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_PART_OF_ENTITY) == ShapeTypeEnum.ST_PART_OF_ENTITY) { lShapeType |= (long) ShapeTypeEnum.ST_OVAL_PROCESS; lShapeType |= (long) ShapeTypeEnum.ST_SHAPE; } if ( sNameU == "parameters" ) { lShapeType |= (long) ShapeTypeEnum.ST_HIDDEN; lShapeType |= (long) ShapeTypeEnum.ST_SHAPE; } if (( lShapeType == (long) ShapeTypeEnum.ST_NONE ) || ( lShapeType == (long) ShapeTypeEnum.ST_NO_NAMEU)) lShapeType |= (long) ShapeTypeEnum.ST_SHAPE; // Getting shape's dimensions and converting it to 'Pixels' lWidth = Measure2Pix(xform_node, "Width"); lHeight = Measure2Pix(xform_node, "Height"); lX = Measure2Pix(xform_node, "PinX"); lY = Measure2Pix(xform_node, "PinY"); lPinX = Measure2Pix(xform_node, "LocPinX"); lPinY = Measure2Pix(xform_node, "LocPinY"); if ((( lWidth == 0 ) || ( lHeight == 0 )) && (((ShapeTypeEnum)lShapeType & ShapeTypeEnum.ST_SHAPE) == ShapeTypeEnum.ST_SHAPE) && (((ShapeTypeEnum)lShapeType & ShapeTypeEnum.ST_CONNECTOR)!=ShapeTypeEnum.ST_CONNECTOR)) { return false; } if ( sNameU == "separator") { return false; } // Getting shape's styles IDs #if _POST_FIX_2_1 sLineStyle = GetStyle2(shape, "LineStyle", "vdx:Line/vdx:LineColor"); sTextStyle = GetStyle2(shape, "TextStyle", "vdx:Char/vdx:Color"); sFillStyle = GetStyle2(shape, "FillStyle", "vdx:Fill/vdx:FillForegnd"); #else sLineStyle = GetStyle(shape, "LineStyle", ref sLineStyle2); sTextStyle = GetStyle(shape, "TextStyle", ref sTextStyle2); sFillStyle = GetStyle(shape, "FillStyle", ref sFillStyle2); #endif // Getting colors crLineColor = Color.Empty; crLineColor = GetColor(shape,sLineStyle,"vdx:Line/vdx:LineColor",null,null,sLineStyle2); crFillColor = Color.Empty; crFillColor = GetColor(shape,sFillStyle,"vdx:Fill/vdx:FillForegnd","vdx:Fill/vdx:FillForegndTrans",null,sFillStyle2); crFillColor2 = Color.Empty; crFillColor2 = GetColor(shape,sFillStyle,"vdx:Fill/vdx:FillBkgnd",null,null,sFillStyle2); crTextColor = Color.Empty; crTextColor = GetColor(shape,sTextStyle,"vdx:Char/vdx:Color",null,null,sTextStyle2); // Getting fill patterns sFillPattern = ""; sFillPattern = GetShapeAttr("vdx:Fill/vdx:FillPattern","", shape); if ( sFillPattern == null) { sFillPattern = GetShapeAttr(String.Format("vdx:StyleSheet[@ID='{0}']/vdx:Fill/vdx:FillPattern", sFillStyle),"",stylesRoot); } sTemp = GetShapeAttr("vdx:Line/vdx:LineWeight","",shape); if ( sTemp == null) { sTemp = GetShapeAttr(String.Format("vdx:StyleSheet[@ID='{0}']/vdx:Line/vdx:LineWeight", sLineStyle),"",stylesRoot); } // Getting line width if ( sTemp!=null ) lLineWith = (long) this.Unit2Pix(sDL,sDL,sTemp); else lLineWith = 0; // Getting rotaton angle string sAngle = "0", sAngleUnit = ""; sAngle = GetShapeAttr("vdx:Angle", "", xform_node); sAngleUnit = GetShapeAttr("vdx:Angle", "Unit", xform_node); fAngle2 = Angle2Deg(sAngleUnit, sAngle); /* if (( sAngle != "0") && ( sAngle!=null)) { sAngle = sAngle.Replace(".",sSeparator); fAngle = Convert.ToDouble(sAngle); if ( fAngle!=0 ) { fAngle2 = (fAngle/Math.PI)*180; if ( fAngle2>0 ) fAngle2 = 360 - Math.Abs(fAngle2); else fAngle2 = Math.Abs(fAngle2); } } else { lAngle = 0; } */ sPenStyle = ""; sPenStyle = GetShapeAttr("vdx:Line/vdx:LinePattern","", shape); if ( sPenStyle == null ) { sPenStyle = GetShapeAttr(String.Format("vdx:StyleSheet[@ID='{0}']/vdx:Line/vdx:LinePattern", sLineStyle),"", stylesRoot); } if ((((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_SHAPE ) == ShapeTypeEnum.ST_SHAPE)|| (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_GROUP ) == ShapeTypeEnum.ST_GROUP)|| (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_PART_OF_ARROW ) == ShapeTypeEnum.ST_PART_OF_ARROW)) { if (group != null) { // Getting coordinates of the upper left corner of the group lBoxX = lOffsetX + lGroupX - lGroupPinX; lBoxY = lOffsetY + lBasedY - ( lGroupY + lGroupPinY ); // Getting coordinates of the grouped shape if (( (ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_ENTITY ) == ShapeTypeEnum.ST_ENTITY ) lPinY = 0; lBoxX = lBoxX + lX - lPinX; // Aplying coordinates adustment is shape is part of 'entity-like' group if ((((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_ENTITY )!=ShapeTypeEnum.ST_ENTITY ) && (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_PART_OF_ENTITY ) == ShapeTypeEnum.ST_PART_OF_ENTITY) && (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_NO_NAMEU)== ShapeTypeEnum.ST_NO_NAMEU)) { if (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_PART_OF_ENTITY2 ) == ShapeTypeEnum.ST_PART_OF_ENTITY2) lBoxY = lBoxY + lGroupPinY*2 - lY; } else { lBoxY = lBoxY + lGroupPinY*2 - lY - lPinY ; } } else // If shape is NOT a part of group { lBoxX = lOffsetX + lX - lPinX; lBoxY = lOffsetY + lBasedY - ( lY + lPinY ); } if (( bImportEntitiesAsTables ) && ( (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_ENTITY ) == ShapeTypeEnum.ST_ENTITY) )) { // If 'entity - like' shape and 'ImportEnitiesAsTables' mode ON // then creating group & table instead of group's content oTable = pChart.CreateTable( lBoxX , lBoxY ,lWidth,lHeight); if ( oTable == null ) return false; int lRowCount = 0, lCol = 0, lRow = 0; bool IsCaption = true; XmlNodeList entity_items = shape.SelectNodes("vdx:Shapes/vdx:Shape",ns); foreach ( XmlNode entity_node in entity_items ) { if ( entity_node == null) continue; if ( IsCaption ) { sTemp = GetShapeAttr("vdx:Text", "", entity_node); if ( sTemp!=null ) oTable.Caption = sTemp; sTemp = GetShapeAttr("vdx:Fill/vdx:FillForegnd", "", entity_node); crFillColor = GetColor(entity_node,"","vdx:Fill/vdx:FillForegnd", null, sTemp, null); IsCaption = false; } else { // Processing Flowchart Table object sTemp = GetShapeAttr("vdx:User[@NameU='LineCount']/vdx:Value", "", entity_node ); if ( sTemp!=null ) { lRowCount = Convert.ToInt16(sTemp); oTable.RowCount = lRowCount; } if ( lRowCount == 0 ) lRowCount = 1; oTable.RowHeight = lHeight /( lRowCount); oTable.CaptionHeight = lHeight /( lRowCount ); oTable.RedimTable(2, lRowCount ); XmlNodeList table_list = null; table_list = entity_node.SelectNodes("vdx:Text/text()", ns); foreach ( XmlNode text_node in table_list ) { // Parsing text using '\n' as separator sTemp = text_node.InnerText.ToString(); sTemp = sTemp.Trim(); string [] split = sTemp.Split(new Char [] {'\n'}); foreach ( string text_piece in split ) { if (text_piece!=null) { if ( oTable.RowCount <= lRow ) oTable.RowCount++; oTable[lCol,lRow].Text = text_piece; } lRow++; } lRow--; lRow++; if (( lRow == 1 ) && (lCol == 0)) { lCol = 1; lRow = 0; } } } } // Applying table parameters //oTable.CaptionColor = crFillColor; oTable.Brush = new MindFusion.FlowChartX.SolidBrush(Color.White); oTable.FillColor = Color.White; oTable.CellFrameStyle = CellFrameStyle.Simple; oTable.Tag = sPageID + "_" + sUID; return true; } else oBox = pChart.CreateBox( lBoxX , lBoxY ,lWidth,lHeight); if ( oBox.Equals(null) ) return false; oBox.Tag = sPageID + "_" + sUID; Trace.WriteLine(String.Format("Box: {0}",sUID)); if ( sNameU == "" ) sTemp = sType; else { sTemp = sNameU; } ShapeTemplate templ1 = null; if ( ((ShapeTypeEnum)lShapeType & ShapeTypeEnum.ST_PART_OF_ENTITY) == ShapeTypeEnum.ST_PART_OF_ENTITY ) templ1 = VisioShape2PredefinedShape("Process", ref oBox, ref DontHideGroup, ref crFillColor); else templ1 = VisioShape2PredefinedShape(sTemp, ref oBox, ref DontHideGroup, ref crFillColor); if ( templ1 == null ) return false; oBox.Style = BoxStyle.Shape; oBox.Shape = templ1; if ( lHeight == 0 ) { // Getting shape's begin & end coordinates lBeginX = Measure2Pix(xform1d_node, "BeginX"); lBeginY = Measure2Pix(xform1d_node, "BeginY"); lEndX = Measure2Pix(xform1d_node, "EndX"); lEndY = Measure2Pix(xform1d_node, "EndY"); if ( lEndX != lBeginX) lHeight = System.Math.Abs(lEndX - lBeginX); else if ( lEndY != lBeginY) lHeight = System.Math.Abs(lEndY - lBeginY); else lHeight = 0; } /* * * * ROTATION // If shape has some rotattion then correct Width & Heigh if ((lAngle == 90) || ( lAngle == 270)) { long lH =lHeight, lW = lWidth, lDx = Math.Abs(lW-lH); lHeight = lW; lWidth = lH; lBoxX+= lDx/2; lBoxY-= lDx/2; } */ // Processing controls & bitmaps if ( sType.IndexOf("foreign") >= 0 ) ProcessForeign(shape); // Applying shape's colors, pens etc. if ( sFillPattern == "" ) sFillPattern = "0"; if ( System.Convert.ToInt16(sFillPattern) > 1 ) oBox.Brush = new MindFusion.FlowChartX.LinearGradientBrush(crFillColor, crFillColor2, 90); else oBox.Brush = new MindFusion.FlowChartX.SolidBrush(crFillColor); oBox.Pen = new MindFusion.FlowChartX.Pen(crLineColor,lLineWith); /* * * ROTATION if ( lAngle!=0 ) oBox.ShapeOrientation = lAngle; */ if ( fAngle2!=0) { oBox.RotateContents = true; oBox.RotationAngle = (float) fAngle2; } #if _POST_FIX_2_1 if (group != null) { oBox.RotateContents = (group.MainObject as Box).RotateContents; oBox.RotationAngle = (group.MainObject as Box).RotationAngle; } #endif // set the shape's text Font ff = GetFont(shape); if ( ff == null ) oBox.Font = (Font)pChart.Font.Clone(); else oBox.Font = ff; sTemp = GetShapeText(shape, oBox); if (sTemp != null) { oBox.PolyTextLayout = true; oBox.EnableStyledText = true; oBox.Text = sTemp; oBox.TextColor = crTextColor; } if (group!=null) { if ( ((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_PART_OF_ARROW ) == ShapeTypeEnum.ST_PART_OF_ARROW) //if ( lShapeType & ST_PART_OF_ARROW) { group.AttachToArrowPoint(oBox,1); oBox.Transparent = true; } else { group.AttachToCorner(oBox,0); } oBox.Locked = true; } if ( sPenStyle!=null ) oBox.Pen.DashStyle = String2DashStyle(sPenStyle); // Raising 'BoxImported' event OnBoxImported(oBox, sShapeName, ""); } // If the shape is connector then creating the arrow else if ( ((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_CONNECTOR ) == ShapeTypeEnum.ST_CONNECTOR) { if ( connectRoot == null ) return false; sPath = String.Format("vdx:Connect[@FromSheet='{0}']", sUID); XmlNodeList connected_list = connectRoot.SelectNodes(sPath, ns); if (connected_list == null) return false; lTemp = 0; string sFrom = "", sTo = ""; foreach ( XmlNode EachConnection in connected_list) { if ( EachConnection == null ) break; if ( EachConnection.Attributes["ToSheet"]!=null) if ( lTemp == 0 ) sFrom = EachConnection.Attributes["ToSheet"].Value.ToString(); else sTo = EachConnection.Attributes["ToSheet"].Value.ToString(); if ( lTemp>0 ) break; lTemp++; } Trace.WriteLine(String.Format("Arrow: {0} - {1}",sFrom,sTo)); oArrow = CreateFcxLink(sPageID + "_" + sFrom, sPageID + "_" + sTo); if ( oArrow == null ) return false; // Setting Arrow's ID oArrow.Tag = sPageID + "_" + sUID; xform1d_node = shape.SelectSingleNode("vdx:XForm1D", ns); if ( xform1d_node == null) return false; // Getting arrow's begin & end coordinates lBeginX = Measure2Pix(xform1d_node, "BeginX"); lBeginY = Measure2Pix(xform1d_node, "BeginY"); lEndX = Measure2Pix(xform1d_node, "EndX"); lEndY = Measure2Pix(xform1d_node, "EndY"); // Detecting arrow style ArrowStyle stArrow = ArrowStyle.Cascading; sTemp = GetShapeAttr("vdx:Layout/vdx:ConLineRouteExt", "", shape); if ( sTemp == "2") stArrow = ArrowStyle.Bezier; else if ( sTemp == "1") stArrow = ArrowStyle.Polyline; // If arrow is 'line curved' then set 'asBezier' type if ( sNameU == "line-curve connector" ) stArrow = ArrowStyle.Bezier; // Counting segments arrow consists in XmlNodeList segments_list = shape.SelectNodes("vdx:Geom/vdx:LineTo", ns); lTemp = segments_list.Count; if (( stArrow == ArrowStyle.Cascading) || ( stArrow == ArrowStyle.Polyline)) { if (lTemp>1) stArrow = ArrowStyle.Cascading; else { stArrow = ArrowStyle.Polyline; } } //Setting arrow style oArrow.Style = stArrow; if (stArrow == ArrowStyle.Cascading) { // If the arrow has more than one segment than // setting 'asPerpendicular' style for arrow oArrow.SegmentCount = (short) lTemp; // Setting coordinates of the arrow's origin lStartX = lOffsetX + lBeginX ; lStartY = lOffsetY + lBasedY - ( lBeginY ); oArrow.ControlPoints[0]= new PointF(lStartX, lStartX); lPtX = lStartX; lPtY = lStartY; Trace.WriteLine(String.Format("Arrow {0}\tPt:{1}\tX:{2}\tY:{3}",sUID,0,lPtX, lPtY)); // TODO: If source shape ( pBoxFrom) is non-symmetric ( triangle, pentagon, etc ) // arrow base's coordinates need to be adjusted to be source shape's part // such as follows: // pArrow->CtrlPtX[0] = ????; // pArrow->CtrlPtY[0] = ????; // Getting arrow segments 'one-by-one' using 'LineTo' XML nodes foreach ( XmlNode segment in segments_list ) { if ( segment == null ) continue; // Getting X-coordinate node_temp = segment.SelectSingleNode("vdx:X", ns); if ( node_temp == null ) { oArrow.Style = ArrowStyle.Polyline; break; } sStepX = node_temp.InnerText; lStepX = (long) Unit2Pix(sDL, sDL, sStepX); lPtX = lStartX + lStepX; // Getting Y-coordinate node_temp = segment.SelectSingleNode("vdx:Y", ns); if ( node_temp == null ) { oArrow.Style = ArrowStyle.Polyline; break; } sStepY = node_temp.InnerText; lStepY = (long) Unit2Pix(sDL, sDL, sStepY); lPtY = lStartY - lStepY; // Setting new segment for FloChartX arrow if ( lCount <= lTemp) { oArrow.ControlPoints[(int) lCount]= new PointF(lPtX, lPtY); Trace.WriteLine(String.Format("Arrow {0}\tPt:{1}\tX:{2}\tY:{3}",sUID,lCount,lPtX, lPtY)); } lCount++; } } else { // Setting coordinates of the arrow's origin & destination lAdjustX = 0; lAdjustY = 0; if ( stArrow == ArrowStyle.Bezier ) { // If curved shape has control points then reflecting adustments oArrow.SegmentCount = 1; if ( sNameU == "line-curve connector" ) { node_temp = shape.SelectSingleNode("vdx:Control/vdx:X", ns); if ( node_temp != null ) { sTemp = node_temp.InnerText; lAdjustX = (long) Unit2Pix(sDL, sDL,sTemp); } node_temp = shape.SelectSingleNode("vdx:Control/vdx:Y", ns); if ( node_temp != null ) { sTemp = node_temp.InnerText; lAdjustY = (long) Unit2Pix(sDL, sDL,sTemp); } } PointF cpt = oArrow.ControlPoints[0]; oArrow.ControlPoints[1]= new PointF(cpt.X + lAdjustX , cpt.Y -lAdjustY/2 ); oArrow.ControlPoints[2]= new PointF(cpt.X + lAdjustX , cpt.Y -lAdjustY/2 ); oArrow.ControlPoints[3]= new PointF(lOffsetX + lEndX , lOffsetY + lBasedY - ( lEndY )); } else { oArrow.SegmentCount = 1; } } // Setting Begin/End point of the arrow oArrow.ControlPoints[0]= new PointF(lOffsetX + lBeginX, lOffsetY + lBasedY - ( lBeginY )); oArrow.ControlPoints[oArrow.SegmentCount]= new PointF(lOffsetX + lEndX, lOffsetY + lBasedY - ( lEndY )); // Updating arrow oArrow.UpdateFromPoints(); // Settiing ArrowBase property sTemp = null; sTemp = GetShapeAttr("vdx:Line/vdx:BeginArrow","",shape); if (( sTemp == null ) && ( sLineStyle!=null)) { sTemp = GetShapeAttr(String.Format("vdx:StyleSheet[@ID='{0}']/vdx:Line/vdx:BeginArrow",sLineStyle), "",stylesRoot); } if ( sTemp!=null ) { oArrow.ArrowBase = String2ArrowType( sTemp, ref crLineColor); } // Settiing ArrowBaseSize property sTemp = null; sTemp = GetShapeAttr("vdx:Line/vdx:BeginArrowSize","",shape); if (( sTemp == null ) && ( sLineStyle!=null)) { sTemp = GetShapeAttr(String.Format("vdx:StyleSheet[@ID='{0}']/vdx:Line/vdx:BeginArrowSize",sLineStyle), "",stylesRoot); } if ( sTemp!=null ) { oArrow.ArrowBaseSize = System.Convert.ToInt16(sTemp) * 5; } // Setting ArrowHead sTemp = GetShapeAttr("vdx:Line/vdx:EndArrow","",shape); if (( sTemp == null ) && ( sLineStyle!=null)) { sTemp = GetShapeAttr(String.Format("vdx:StyleSheet[@ID='{0}']/vdx:Line/vdx:EndArrow",sLineStyle), "",stylesRoot); } if ( sTemp!=null ) { oArrow.ArrowHead = String2ArrowType( sTemp, ref crLineColor); } // Settiing ArrowHeadSize property sTemp = null; sTemp = GetShapeAttr("vdx:Line/vdx:EndArrowSize","",shape); if (( sTemp == null ) && ( sLineStyle!=null)) { sTemp = GetShapeAttr(String.Format("vdx:StyleSheet[@ID='{0}']/vdx:Line/vdx:EndArrowSize",sLineStyle), "",stylesRoot); } if ( sTemp!=null ) { oArrow.ArrowHeadSize = System.Convert.ToInt16(sTemp) * 5; } // [???] Setting arrow's color oArrow.Pen = new MindFusion.FlowChartX.Pen(crLineColor,lLineWith); oArrow.HeadPen = oArrow.Pen; oArrow.Brush = new MindFusion.FlowChartX.SolidBrush(crFillColor); if ( sPenStyle!=null ) oArrow.Pen.DashStyle = String2DashStyle(sPenStyle); // Performing post-processing for special arrow types if ( sNameU == "composition") { oArrow.ArrowBase = ArrowHead.Rhombus; oArrow.ArrowHead = ArrowHead.None; } else if ( sNameU == "generalization") { oArrow.ArrowBase = ArrowHead.Triangle; oArrow.ArrowHead = ArrowHead.None; oArrow.FillColor = Color.FromArgb(255,255,255); } else if ( sNameU == "object flow") { oArrow.ArrowBase = ArrowHead.None; oArrow.ArrowHead = ArrowHead.Arrow; oArrow.Pen.DashStyle = DashStyle.Dash; } else if ( sNameU == "control flow") { oArrow.ArrowBase = ArrowHead.None; oArrow.ArrowHead = ArrowHead.Arrow; oArrow.Pen.DashStyle = DashStyle.Solid; } else if ( sNameU.IndexOf("association")>=0) { oArrow.ArrowBase = ArrowHead.None; oArrow.ArrowHead = ArrowHead.Arrow; //oArrow.FillColor = Color.FromArgb(255,255,255); oArrow.Pen.DashStyle = DashStyle.Solid; } else if ( sNameU == "2-element constraint") { oArrow.ArrowBase = ArrowHead.Arrow; oArrow.ArrowHead = ArrowHead.None; //oArrow.FillColor = Color.FromArgb(255,255,255); oArrow.Pen.DashStyle = DashStyle.Dot; } else if ( sNameU == "or constraint") { oArrow.ArrowBase = ArrowHead.Arrow; oArrow.ArrowHead = ArrowHead.None; //oArrow.FillColor = Color.FromArgb(255,255,255); oArrow.Pen.DashStyle = DashStyle.Dot; } // Setting arrow's text sTemp = GetShapeText(shape, oArrow); if (sTemp != null) { Font ff = GetFont(shape); if ( ff == null ) oArrow.Font = pChart.Font; else oArrow.Font = ff; oArrow.Text = sTemp; oArrow.TextColor = crTextColor; } fnShape = null; fnShape = GetFont(shape); // Raising 'ArrowImported' event OnArrowImported(oArrow, sShapeName); } // if the shape is GROUP if (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_GROUP ) == ShapeTypeEnum.ST_GROUP) { if ((((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_ENTITY ) != ShapeTypeEnum.ST_ENTITY) && (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_OVAL_PROCESS ) != ShapeTypeEnum.ST_OVAL_PROCESS)) { if (!DontHideGroup) { oBox.Transparent = true; oBox.FillColor = Color.FromArgb(255,255,255); } } oGroup = null; if ( oArrow != null ) oGroup = pChart.CreateGroup(oArrow); else oGroup = pChart.CreateGroup(oBox); // Saving group's measures for future use lGroupY = lY; lGroupX = lX; lGroupPinY = lPinY; lGroupPinX = lPinX; // Scanning for group members and creating it using recursive call XmlNodeList grshape_list = null; grshape_list = shape.SelectNodes("vdx:Shapes/vdx:Shape", ns); foreach ( XmlNode grshape in grshape_list) { sTemp = String.Format("{0}",ShapeType); if (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_ENTITY ) == ShapeTypeEnum.ST_ENTITY) // if ( lShapeType & ST_ENTITY ) sTemp = "entity"; if (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_ENTITY2 ) == ShapeTypeEnum.ST_ENTITY2) //if ( lShapeType & ST_ENTITY2 ) sTemp = "entity 2"; if (((ShapeTypeEnum) lShapeType & ShapeTypeEnum.ST_CONNECTOR ) == ShapeTypeEnum.ST_CONNECTOR) // if ( lShapeType & ST_CONNECTOR ) sTemp = "arrow"; GetShapeRef(grshape,sTemp,oGroup); } #if _POST_FIX_2_1 if (DontHideGroup) { foreach ( Box grBox in oGroup.AttachedObjects ) { grBox.Transparent = true; } } #endif // Raising 'GroupImported' event OnGroupImported(oGroup); } oBox = null; oArrow = null; return true; }
public static MindFusion.Diagramming.Wpf.ShapeNode FindMfNode(MindFusion.Diagramming.Wpf.Diagram mfDiagram, string p) { foreach (MindFusion.Diagramming.Wpf.ShapeNode node in mfDiagram.Nodes) { if (node.Uid == p) { return node; } } return null; }
private void DrawText(string text, RectangleF dest, MindFusion.FlowChartX.Text.DrawTextHint hint) { // Render formatted text hint.Graphics.DrawString( text, hint.Font, hint.Brush, dest, hint.Format); }
internal static List<SysCAD.Protocol.Point> GetControlPoints(MindFusion.FlowChartX.PointCollection pointCollection) { List<SysCAD.Protocol.Point> list = new List<SysCAD.Protocol.Point>(pointCollection.Capacity); foreach (PointF point in pointCollection) { list.Add(new SysCAD.Protocol.Point(point)); } return list; }
/// <summary> /// React to the select note dimensions being changed. /// </summary> public void NodeModifiedHandler(object sender, MindFusion.Diagramming.NodeEventArgs e) { // Reload the property grid. propertyGrid1.Refresh(); }
/// <summary> /// SvgManager constructor /// </summary> /// <param name="DimX">Chart X dimension</param> /// <param name="DimY">Chart Y demension</param> /// <param name="newPixPerInch">PixelsPerInch rate</param> /// <param name="UnitDefault">Default measure unit</param> public SvgManager( string DimX, string DimY , long newPixPerInch , GraphicsUnit UnitDefault , bool p_GlueLines , MindFusion.FlowChartX.FlowChart ChartRef) { try { iPixPerInch = newPixPerInch; iUnitDef = UnitDefault; m_GlueLines = p_GlueLines; sXML = String.Format(sXMLDefault, sNsDefault, DimX, DimY); m_InnerDoc = new XmlDocument(); pChart = ChartRef; m_InnerDoc.LoadXml(sXML); m_nsManager = new XmlNamespaceManager(m_InnerDoc.NameTable); m_nsManager.AddNamespace("svg", sNsDefault); m_nsManager.AddNamespace("xlink", "http://www.w3.org/1999/xlink"); m_InnerRoot = m_InnerDoc.SelectSingleNode("svg:svg",m_nsManager); m_InnerDefs = m_InnerDoc.SelectSingleNode("svg:svg//svg:defs",m_nsManager); m_ObjectValid = true; } catch (Exception ex) { Trace.WriteLine(String.Format("{0} error {1}\n","SvgManager.SvgManager()",ex.Message)); m_ObjectValid = false; } }
private void SerializePen(CodeStatementCollection code, string property, FlowChart chart, MindFusion.FlowChartX.Pen pen) { string representation; CodeExpression left = null; CodeExpression right = null; CodeStatement line = null; representation = Pen.Serialize(pen); left = new CodePropertyReferenceExpression( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), chart.Name), property); right = new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeTypeReferenceExpression("MindFusion.FlowChartX.Pen"), "Deserialize"), new CodeExpression[] { new CodePrimitiveExpression(representation) }); line = new CodeAssignStatement(left, right); code.Add(line); }
/// <summary> /// Add Flowchart.Net arrow as a XML node into VDX /// </summary> /// <param name="newArrow">Flowchart.Net arrow</param> /// <returns>[true] if successfull [false] otherwise</returns> private bool AddArrow(MindFusion.FlowChartX.Arrow newArrow) { bool bOk = false; XmlNode xform_node, geom_node, xform1d_node, node_temp, node_temp2; string sTemp = "" , sNURBS = "" , sNURBS1 = ""; long GeomCount = 0, PointCount = 0 , EveryCount = 0; double fTemp = 0, fTemp2 = 0, lW = 0, lW2 =0, lH = 0, lH2 = 0 , lBX = 0, lBY = 0 , lX1 = 0, lX2 = 0, lY1 = 0 , lY2 = 0, lStepX = 0, lStepY = 0; try { if ( newArrow == null ) return false; shapeNew = shapeRoot.InsertAfter( shapeTemplate.Clone(), shapeRoot.LastChild) ;//shapeLast); if ( shapeNew == null ) return false; // Setting arrow's ID & unique GUID shapeLast = shapeNew; shapeNew.Attributes["Master"].Value = "2"; shapeNew.Attributes["ID"].Value = getID(newArrow).ToString(); shapeNew.Attributes["Name"].Value = String.Format("Dynamic connector.{0}", getID(newArrow).ToString()); shapeNew.Attributes["NameU"].Value = String.Format("Dynamic connector.{0}", getID(newArrow).ToString()); sTemp = GetGUID(); if ( sTemp != null ) { shapeNew.Attributes["UniqueID"].Value = sTemp; } // Getting arrow start & end point coordinates lX1 = newArrow.ControlPoints[0].X; lY1 = newArrow.ControlPoints[0].Y; lX2 = newArrow.ControlPoints[newArrow.ControlPoints.Count - 1].X; lY2 = newArrow.ControlPoints[newArrow.ControlPoints.Count - 1].Y; lW2 = lX2 - lX1; lW = ( lW2 == 0 ) ? ( 0.25 * PixPerInch ): lW2; lH2 = lY1 - lY2; lH = ( lH2 == 0 ) ? ( 0.25 * PixPerInch ): lH2; lBX = lX1 + ( ( lW2 == 0 ) ? 0 : lW/2 ); lBY = lDocY - ( lY1 - (( lH2 == 0 ) ? 0 : lH/2)) ; // Setting arrow's dimensions for Visio XML nodes SetShapeDim(shapeNew, "vdx:XForm/vdx:PinX", lBX, false); SetShapeDim(shapeNew, "vdx:XForm/vdx:PinY",lBY, false); SetShapeDim(shapeNew, "vdx:XForm/vdx:Width", lW , true); SetShapeDim(shapeNew, "vdx:XForm/vdx:Height", lH, true) ; SetShapeDim(shapeNew, "vdx:XForm/vdx:LocPinX", lW/2 , true ); SetShapeDim(shapeNew, "vdx:XForm/vdx:LocPinY", lH/2 , true); RemoveNode(shapeNew, "vdx:Group", true); // Reflecting arrow's geometry xform_node = shapeNew.SelectSingleNode("vdx:XForm", ns); if ( xform_node == null ) return false; xform1d_node = shapeNew.InsertAfter(doc.CreateNode(XmlNodeType.Element,"XForm1D","http://schemas.microsoft.com/visio/2003/core"), xform_node); if ( xform1d_node == null ) return false; node_temp = xform1d_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"BeginX","http://schemas.microsoft.com/visio/2003/core"), xform1d_node.LastChild); if ( node_temp == null ) return false; node_temp = xform1d_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"BeginY","http://schemas.microsoft.com/visio/2003/core"), xform1d_node.LastChild); if ( node_temp == null ) return false; node_temp = xform1d_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"EndX","http://schemas.microsoft.com/visio/2003/core"), xform1d_node.LastChild); if ( node_temp == null ) return false; node_temp = xform1d_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"EndY","http://schemas.microsoft.com/visio/2003/core"), xform1d_node.LastChild); if ( node_temp == null ) return false; SetShapeDim(shapeNew, "vdx:XForm1D/vdx:BeginX", lX1 , true); SetShapeDim(shapeNew, "vdx:XForm1D/vdx:BeginY", lDocY - lY1, true) ; SetShapeDim(shapeNew, "vdx:XForm1D/vdx:EndX", lX2 , true ); SetShapeDim(shapeNew, "vdx:XForm1D/vdx:EndY", lDocY - lY2 , true); geom_node = shapeNew.InsertBefore(doc.CreateNode(XmlNodeType.Element,"Geom","http://schemas.microsoft.com/visio/2003/core"), shapeNew.SelectSingleNode("vdx:Text",ns)); if ( geom_node == null ) return false; SetShapeAttr("","IX",geom_node,"0"); node_temp = geom_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"NoFill","http://schemas.microsoft.com/visio/2003/core"), geom_node.LastChild); if ( node_temp == null ) return false; SetShapeAttr("","",node_temp,"1"); node_temp = geom_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"NoLine","http://schemas.microsoft.com/visio/2003/core"), geom_node.LastChild); if ( node_temp == null ) return false; SetShapeAttr("","",node_temp,"0"); node_temp = geom_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"NoShow","http://schemas.microsoft.com/visio/2003/core"), geom_node.LastChild); if ( node_temp == null ) return false; SetShapeAttr("","",node_temp,"0"); node_temp = geom_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"NoSnap","http://schemas.microsoft.com/visio/2003/core"), geom_node.LastChild); if ( node_temp == null ) return false; SetShapeAttr("","",node_temp,"0"); node_temp = geom_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"MoveTo","http://schemas.microsoft.com/visio/2003/core"), geom_node.LastChild); if ( node_temp == null ) return false; GeomCount++; SetShapeAttr("","IX",node_temp,String.Format("{0}",GeomCount)); node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"X","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2 == null ) return false; SetShapeDim(node_temp,"vdx:X", 0, false); node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"Y","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2 == null ) return false; SetShapeDim(node_temp,"vdx:Y", 0, false); SetShapeAttr("vdx:Misc/vdx:GlueType","",shapeNew, "2"); SetShapeAttr("vdx:Misc/vdx:NoAlignBox","",shapeNew, "1"); SetShapeAttr("vdx:Misc/vdx:ObjType","",shapeNew, "2"); SetShapeAttr("vdx:Misc/vdx:BegTrigger","",shapeNew, "2"); SetShapeAttr("vdx:Misc/vdx:EndTrigger","",shapeNew, "2"); GeomCount++; PointCount = newArrow.ControlPoints.Count; if ( lW2 == 0 ) sNURBS = "NURBS(0.55, 3, 1, 1"; else sNURBS = "NURBS(0.75, 3, 1, 1"; foreach ( PointF EveryPoint in newArrow.ControlPoints ) { if ( EveryPoint.Equals( null ) ) continue; if ( EveryCount == 0 ) { EveryCount++; continue; } lStepX = EveryPoint.X - newArrow.ControlPoints[0].X; lStepY = newArrow.ControlPoints[0].Y - EveryPoint.Y; if ((newArrow.Style == ArrowStyle.Bezier) && (EveryCount!=1)) { fTemp = lStepX/PixPerInch; fTemp2 = lStepY/PixPerInch; sNURBS1 = String.Format(",{0},{1}, 0,1", fTemp, fTemp2); sNURBS+=sNURBS1; } else { if ( newArrow.Style == ArrowStyle.Bezier) { sTemp = "NURBSTo"; lStepX = (lW2 == 0) ? lW/2 : lW ; lStepY = (lH2 == 0) ? lH/2 : lH; } else sTemp = "LineTo"; node_temp = geom_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,sTemp ,"http://schemas.microsoft.com/visio/2003/core"), geom_node.LastChild); if ( node_temp != null ) { SetShapeAttr("","IX",node_temp,String.Format("{0}",GeomCount)); node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"X","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2 != null ) SetShapeDim(node_temp,"vdx:X", lStepX, false); node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"Y","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2 != null ) SetShapeDim(node_temp,"vdx:Y", lStepY, false); } GeomCount++; EveryCount++; } } if (newArrow.Style == ArrowStyle.Bezier) { node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"A","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2 != null ) //SetShapeDim(node_temp,"vdx:A", 0*PixPerInch, false); SetShapeAttr("vdx:A","",node_temp, "0"); node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"B","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2 != null ) SetShapeAttr("vdx:B","",node_temp, "1"); //SetShapeDim(node_temp,"vdx:B", 1 *PixPerInch, false); node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"C","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2 != null ) //SetShapeDim(node_temp,"vdx:C", 0*PixPerInch, false); SetShapeAttr("vdx:C","",node_temp, "0"); node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"D","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2 != null ) //SetShapeDim(node_temp,"vdx:D", 1*PixPerInch, false); SetShapeAttr("vdx:D","",node_temp, "1"); node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"E","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2 != null ) { sNURBS+=")"; SetShapeAttr("","Unit", node_temp2,"NURBS"); double fX1 =0, fX2 = 0, fY1 =0, fY2 =0; fTemp = newArrow.ControlPoints[1].X - newArrow.ControlPoints[0].X; //fX1 = fTemp/PixPerInch; fX1 = Unit2Inch(pChart.MeasureUnit, fTemp); fTemp = newArrow.ControlPoints[0].Y - newArrow.ControlPoints[1].Y; //fY1 = fTemp/PixPerInch; fY1 = Unit2Inch(pChart.MeasureUnit, fTemp); fTemp = newArrow.ControlPoints[2].X - newArrow.ControlPoints[0].X; //fX2 = fTemp/PixPerInch; fX2 = Unit2Inch(pChart.MeasureUnit, fTemp); fTemp = newArrow.ControlPoints[0].Y - newArrow.ControlPoints[2].Y; //fY2 = fTemp/PixPerInch; fY2 = Unit2Inch(pChart.MeasureUnit, fTemp); sNURBS = String.Format("NURBS({0}, 3, 1, 1, {1}, {2} ,0,1, {3}, {4} ,0,1)", "0.75", fX1.ToString().Replace(sSeparator, "."), fY1.ToString().Replace(sSeparator, "."), fX2.ToString().Replace(sSeparator, "."), fY2.ToString().Replace(sSeparator, ".")); SetShapeAttr("","F", node_temp2,sNURBS); SetShapeAttr("","", node_temp2,sNURBS); } if (( GeomCount == 3 ) && (newArrow.Style == ArrowStyle.Cascading)) { node_temp2 = geom_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"LineTo","http://schemas.microsoft.com/visio/2003/core"), geom_node.LastChild); if ( node_temp2!=null) { SetShapeAttr("","IX",node_temp2,String.Format("{0}", GeomCount )); SetShapeAttr("","Del",node_temp2,"1"); } } } // Getting font's parameters Font ShapeFont = null; ShapeFont = newArrow.Font; if (ShapeFont == null) ShapeFont = pChart.Font; SetShapeFont(shapeNew, ShapeFont); // Setting shape elements colors SetShapeColor(shapeNew, "vdx:Fill/vdx:FillForegnd", newArrow.FillColor); SetShapeColor(shapeNew, "vdx:Char/vdx:Color", newArrow.TextColor); SetShapeColor(shapeNew, "vdx:Line/vdx:LineColor",newArrow.FrameColor); // Setting shape's text SetText(shapeNew, newArrow.Text,false , ShapeFont); // Getting line width & pattern fTemp = newArrow.Pen.Width / PixPerInch; sTemp = String.Format("{0}", fTemp); sTemp = sTemp.Replace(sSeparator, "."); SetShapeAttr("vdx:Line/vdx:LineWeight","",shapeNew, sTemp); SetShapeAttr("vdx:Line/vdx:LinePattern","",shapeNew, DashStyle2String(newArrow.Pen.DashStyle)); SetShapeAttr("vdx:Line/vdx:EndArrow","",shapeNew, ArrowType2String(newArrow.ArrowHead)); SetShapeAttr("vdx:Line/vdx:BeginArrow","",shapeNew, ArrowType2String(newArrow.ArrowBase)); if (newArrow.Origin is Box || newArrow.Origin is Table) { node_temp = connectRoot.InsertAfter(doc.CreateNode(XmlNodeType.Element,"Connect","http://schemas.microsoft.com/visio/2003/core"), connectRoot.LastChild); if ( node_temp!=null) { SetShapeAttr("","FromSheet",node_temp, getID(newArrow).ToString()); SetShapeAttr("","FromCell",node_temp, "BeginX"); SetShapeAttr("","FromPart",node_temp, "9"); SetShapeAttr("","ToSheet",node_temp, getID(newArrow.Origin).ToString()); SetShapeAttr("","ToCell",node_temp, "PinX"); SetShapeAttr("","ToPart",node_temp, "3"); } } if (newArrow.Destination is Box || newArrow.Destination is Table) { node_temp = connectRoot.InsertAfter(doc.CreateNode(XmlNodeType.Element,"Connect","http://schemas.microsoft.com/visio/2003/core"), connectRoot.LastChild); if ( node_temp!=null) { SetShapeAttr("","FromSheet",node_temp, getID(newArrow).ToString()); SetShapeAttr("","FromCell",node_temp, "EndX"); SetShapeAttr("","FromPart",node_temp, "12"); SetShapeAttr("","ToSheet",node_temp, getID(newArrow.Destination).ToString()); SetShapeAttr("","ToCell",node_temp, "PinX"); SetShapeAttr("","ToPart",node_temp, "3"); } } // Setting Visio connector style switch (newArrow.Style) { case ArrowStyle.Polyline: sTemp = "1"; break; case ArrowStyle.Bezier: sTemp = "2"; break; default: sTemp = ""; break; } if ( sTemp!="" ) { node_temp = shapeNew.InsertAfter(doc.CreateNode(XmlNodeType.Element,"Layout","http://schemas.microsoft.com/visio/2003/core"), geom_node); if ( node_temp!=null ) { node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"ConLineRouteExt","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2!=null ) node_temp2.InnerText = sTemp; if ( newArrow.Style == ArrowStyle.Polyline ) { node_temp2 = node_temp.InsertAfter(doc.CreateNode(XmlNodeType.Element,"ShapeRouteStyle","http://schemas.microsoft.com/visio/2003/core"), node_temp.LastChild); if ( node_temp2!=null ) node_temp2.InnerText = "16"; } } } } catch ( Exception ex ) { Trace.WriteLine(String.Format("{0} error {1}\n","AddArrow",ex.Message)); bOk = false; } return bOk; }