public DTextLabel(DObject parentPar, DrawingLabel label) : base(parentPar, label) { }
internal static DNode CreateDNodeAndSetNodeBoundaryCurve(DrawingGraph drawingGraph, DGraph dGraph, GeometryNode geomNode, DrawingNode drawingNode) { double width = 0; double height = 0; DNode dNode = new DNode(drawingNode); dGraph.AddNode(dNode); Microsoft.Msagl.Drawing.Label label = drawingNode.Label; if (label != null) { CreateDLabel(dNode, label, out width, out height); width += 2 * dNode.DrawingNode.Attr.LabelMargin; height += 2 * dNode.DrawingNode.Attr.LabelMargin; } if (width < drawingGraph.Attr.MinNodeWidth) { width = drawingGraph.Attr.MinNodeWidth; } if (height < drawingGraph.Attr.MinNodeHeight) { height = drawingGraph.Attr.MinNodeHeight; } // Filippo Polo: I'm taking this out because I've modified the drawing of a double circle // so that it can be used with ellipses too. //if (drawingNode.Attr.Shape == Shape.DoubleCircle) //width = height = Math.Max(width, height) * Draw.DoubleCircleOffsetRatio; if (geomNode.BoundaryCurve == null) { geomNode.BoundaryCurve = Microsoft.Msagl.Drawing.NodeBoundaryCurves.GetNodeBoundaryCurve(dNode.DrawingNode, width, height); } return(dNode); }
public DLabel(DObject parentPar, DrawingLabel label, FrameworkElement content) : base(parentPar) { DrawingLabel = label; if (parentPar != null) { label.Owner = parentPar.DrawingObject; if (label.GeometryLabel != null) label.GeometryLabel.GeometryParent = parentPar.DrawingObject.GeometryObject; if (parentPar.DrawingObject.GeometryObject is IGeometryLabeledObject) ((IGeometryLabeledObject)parentPar.DrawingObject.GeometryObject).Label = label.GeometryLabel; } if (ParentObject is IHavingDLabel) ((IHavingDLabel)ParentObject).Label = this; Content = content; if ((label.Owner is Node) && ((label.Owner as DrawingNode).GeometryObject as GeometryNode).BoundaryCurve != null) { Label.GeometryLabel.Center = ((Label.Owner as DrawingNode).GeometryObject as GeometryNode).Center; MakeVisual(); } else if ((label.Owner is Edge) && ((label.Owner as DrawingEdge).GeometryObject as GeometryEdge).Curve != null) { Label.GeometryLabel.Center = ((Label.Owner as DrawingEdge).GeometryObject as GeometryEdge).BoundingBox.Center; MakeVisual(); } }
public DLabel(DObject parentPar, DrawingLabel label, FrameworkElement content) : base(parentPar) { DrawingLabel = label; if (parentPar != null) { label.Owner = parentPar.DrawingObject; if (label.GeometryLabel != null) { label.GeometryLabel.GeometryParent = parentPar.DrawingObject.GeometryObject; } if (parentPar.DrawingObject.GeometryObject is IGeometryLabeledObject) { ((IGeometryLabeledObject)parentPar.DrawingObject.GeometryObject).Label = label.GeometryLabel; } } if (ParentObject is IHavingDLabel) { ((IHavingDLabel)ParentObject).Label = this; } Content = content; if ((label.Owner is Node) && ((label.Owner as DrawingNode).GeometryObject as GeometryNode).BoundaryCurve != null) { Label.GeometryLabel.Center = ((Label.Owner as DrawingNode).GeometryObject as GeometryNode).Center; MakeVisual(); } else if ((label.Owner is Edge) && ((label.Owner as DrawingEdge).GeometryObject as GeometryEdge).Curve != null) { Label.GeometryLabel.Center = ((Label.Owner as DrawingEdge).GeometryObject as GeometryEdge).BoundingBox.Center; MakeVisual(); } }
internal static DGraph CreateDGraphAndGeometryInfo(DrawingGraph drawingGraph, GeometryGraph gleeGraph) { DGraph ret = new DGraph(drawingGraph); //create dnodes and glee node boundary curves foreach (GeometryNode geomNode in gleeGraph.NodeMap.Values) { DrawingNode drawingNode = geomNode.UserData as DrawingNode; CreateDNodeAndSetNodeBoundaryCurve(drawingGraph, ret, geomNode, drawingNode); } foreach (GeometryEdge gleeEdge in gleeGraph.Edges) { DEdge dEdge = new DEdge(ret.GetNode(gleeEdge.Source), ret.GetNode(gleeEdge.Target), gleeEdge.UserData as DrawingEdge, Connection.Connected); ret.AddEdge(dEdge); DrawingEdge drawingEdge = dEdge.Edge; Microsoft.Msagl.Drawing.Label label = drawingEdge.Label; if (label != null) { double width, height; CreateDLabel(dEdge, label, out width, out height); } } return(ret); }
private void WriteConnectorLabel(Microsoft.Msagl.Drawing.Label label) { writer.WriteStartElement("text"); writer.WriteAttribute("x", label.GeometryLabel.Center.X); writer.WriteAttribute("y", label.GeometryLabel.Center.Y); writer.WriteString(label.Text); writer.WriteEndElement(); }
internal static void CreateDLabel(DObject parent, Microsoft.Msagl.Drawing.Label label, out double width, out double height) { DLabel dLabel = new DLabel(parent, label); dLabel.Font = new Font(label.FontName, label.FontSize); StringMeasure.MeasureWithFont(label.Text, dLabel.Font, out width, out height); label.Width = width; label.Height = height; }
void SearchButtonClick(object sender, EventArgs e) { if (GViewer.Graph != null) { string s = searchTextBox.Text.ToLower(); if (searchEnumerator == null) { searchEnumerator = GraphObjects().GetEnumerator(); } bool textFound = false; while (searchEnumerator.MoveNext()) { object t = searchEnumerator.Current; var n = t as Node; Label label = n != null ? n.Label : ((Edge)t).Label; if (label != null && label.Text.ToLower().Contains(s)) { double x = 0.8 * Math.Min(GViewer.Graph.Width / label.Width, GViewer.Graph.Height / label.Size.Height); if (GViewer.ZoomF < x) { GViewer.ZoomF = x; } GViewer.CenterToGroup(t); searchButton.Text = "Next"; textFound = true; break; } } if (searchButton.Text == "Search") { MessageBox.Show(String.Format("'{0}' not found", s)); } else { if (textFound == false) { searchEnumerator = GraphObjects().GetEnumerator(); //resetting searchButton.Text = "Wrap around and Search"; } } } }
public static FormattedText CreateText(Microsoft.Msagl.Drawing.Label label) { if (label == null) { return(null); } var fontFamily = CreateFontFamily(label); var fontSize = label.FontSize; var(fontStyle, fontWeight) = GetFontProps(label.FontStyle); var ftext = new FormattedText { Constraint = new Size(10, 10), Typeface = new Typeface(fontFamily, fontSize, fontStyle, fontWeight), Text = label.Text }; return(ftext); }
DrawingLabel CreateLabel(DrawingEdge edge, string rel) { DrawingLabel label = new DrawingLabel { Text = rel, FontName = "Times-Roman", FontColor = Styles.RELATION_LABEL_COLOR.ToMsAgl(), FontStyle = Microsoft.Msagl.Drawing.FontStyle.Regular, FontSize = 4, Owner = edge, }; double width, height; StringMeasure.MeasureWithFont(rel, new Font(label.FontName, (float)label.FontSize, (System.Drawing.FontStyle)(int) label.FontStyle), out width, out height); label.Width = width; label.Height = height; return(label); }
public DLabel(DObject parentPar, DrawingLabel label) : this(parentPar, label, null) { }
void CreateGraphClustersBig(bool horizontal) { Graph graph = new Graph("clusters big"); void addCluster(string clusterId, params string[] nodeIds) { if (nodeIds.Length == 0) { nodeIds = new string[] { clusterId } } ; var cluster = new Subgraph(clusterId); foreach (var nodeId in nodeIds) { var node = new Node(clusterId + "." + nodeId); node.LabelText = nodeId; graph.AddNode(node); cluster.AddNode(node); } if (horizontal) { cluster.Attr.ClusterLabelMargin = Microsoft.Msagl.Core.Layout.LgNodeInfo.LabelPlacement.Right; } graph.RootSubgraph.AddSubgraph(cluster); } addCluster("Arabinose"); addCluster("Arabinose_control"); addCluster("Arabinose_growth"); addCluster("Auto"); addCluster("Auto_control"); addCluster("Auto_growth"); addCluster("Degrader"); addCluster("Degrader_control"); addCluster("Degrader_growth"); addCluster("Receivers", "Receiver0", "Receiver1", "Receiver2", "Receiver3"); addCluster("Receivers_control", "Receiver0_control", "Receiver1_control", "Receiver2_control", "Receiver3_control"); addCluster("Receivers_growth", "Receiver0_growth", "Receiver1_growth", "Receiver2_growth", "Receiver3_growth"); addCluster("Relays", "Relay1", "Relay2"); addCluster("Relays_control", "Relay1_control", "Relay2_control"); addCluster("Relays_growth", "Relay1_growth", "Relay2_growth"); addCluster("Standard"); addCluster("Standard_control"); addCluster("Standard_growth"); void addEdge(string sourceCluster, string sourceNode, string targetCluster, string targetNode) { graph.AddEdge(sourceNode == null ? sourceCluster : (sourceCluster + "." + sourceNode), targetNode == null ? targetCluster : (targetCluster + "." + targetNode)); } addEdge("Arabinose", "Arabinose", "Degrader", "Degrader"); addEdge("Arabinose_control", "Arabinose_control", "Arabinose", "Arabinose"); addEdge("Arabinose_control", "Arabinose_control", "Degrader_control", "Degrader_control"); addEdge("Arabinose_growth", "Arabinose_growth", "Arabinose_control", "Arabinose_control"); addEdge("Auto", null, "Standard", null); addEdge("Auto_control", "Auto_control", "Auto", "Auto"); addEdge("Auto_control", null, "Standard_control", null); addEdge("Auto_growth", "Auto_growth", "Auto_control", "Auto_control"); addEdge("Degrader_control", "Degrader_control", "Degrader", "Degrader"); addEdge("Degrader_growth", "Degrader_growth", "Degrader_control", "Degrader_control"); addEdge("Receivers", null, "Relays", null); addEdge("Receivers_control", null, "Relays_control", null); addEdge("Receivers_control", "Receiver0_control", "Receivers", "Receiver0"); addEdge("Receivers_control", "Receiver1_control", "Receivers", "Receiver1"); addEdge("Receivers_control", "Receiver2_control", "Receivers", "Receiver2"); addEdge("Receivers_control", "Receiver3_control", "Receivers", "Receiver3"); addEdge("Receivers_growth", "Receiver0_growth", "Receivers_control", "Receiver0_control"); addEdge("Receivers_growth", "Receiver1_growth", "Receivers_control", "Receiver1_control"); addEdge("Receivers_growth", "Receiver2_growth", "Receivers_control", "Receiver2_control"); addEdge("Receivers_growth", "Receiver3_growth", "Receivers_control", "Receiver3_control"); addEdge("Relays", null, "Degrader", null); addEdge("Relays_control", "Relay1_control", "Relays", "Relay1"); addEdge("Relays_control", "Relay2_control", "Relays", "Relay2"); addEdge("Relays_growth", "Relay1_growth", "Relays_control", "Relay1_control"); addEdge("Relays_growth", "Relay2_growth", "Relays_control", "Relay2_control"); addEdge("Standard", null, "Receivers", null); addEdge("Standard_control", null, "Receivers_control", null); addEdge("Standard_control", "Standard_control", "Standard", "Standard"); addEdge("Standard_growth", "Standard_growth", "Standard_control", "Standard_control"); if (horizontal) { (graph.LayoutAlgorithmSettings as SugiyamaLayoutSettings).Transformation = PlaneTransformation.Rotation(Math.PI / 2.0); } gViewer.Graph = graph; this.propertyGrid1.SelectedObject = graph; } void CreateGraph() { #if TEST_MSAGL DisplayGeometryGraph.SetShowFunctions(); #endif //Graph graph = new Graph(); //graph.AddEdge("47", "58"); //graph.AddEdge("70", "71"); //var subgraph = new Subgraph("subgraph1"); //graph.RootSubgraph.AddSubgraph(subgraph); //subgraph.AddNode(graph.FindNode("47")); //subgraph.AddNode(graph.FindNode("58")); //var subgraph2 = new Subgraph("subgraph2"); //subgraph2.Attr.Color = Color.Black; //subgraph2.Attr.FillColor = Color.Yellow; //subgraph2.AddNode(graph.FindNode("70")); //subgraph2.AddNode(graph.FindNode("71")); //subgraph.AddSubgraph(subgraph2); //graph.AddEdge("58", subgraph2.Id); //graph.Attr.LayerDirection = LayerDirection.LR; //gViewer.Graph = graph; Graph graph = new Graph("graph"); //graph.LayoutAlgorithmSettings=new MdsLayoutSettings(); gViewer.BackColor = System.Drawing.Color.FromArgb(10, System.Drawing.Color.Red); /* * 4->5 * 5->7 * 7->8 * 8->22 * 22->24 */ graph.AddEdge("1", "2"); graph.AddEdge("1", "3"); var e = graph.AddEdge("4", "5"); e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; graph.LayerConstraints.AddUpDownVerticalConstraint(graph.FindNode("4"), graph.FindNode("5")); StraightenEdge(e, graph); e = graph.AddEdge("4", "6"); e.LabelText = "Changing label"; this.labelToChange = e.Label; e = graph.AddEdge("7", "8"); e.Attr.LineWidth *= 2; e.Attr.Color = Color.Red; StraightenEdge(e, graph); graph.AddEdge("7", "9"); e = graph.AddEdge("5", "7"); e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; StraightenEdge(e, graph); graph.AddEdge("2", "7"); graph.AddEdge("10", "11"); graph.AddEdge("10", "12"); graph.AddEdge("2", "10"); graph.AddEdge("8", "10"); graph.AddEdge("5", "10"); graph.AddEdge("13", "14"); graph.AddEdge("13", "15"); graph.AddEdge("8", "13"); graph.AddEdge("2", "13"); graph.AddEdge("5", "13"); graph.AddEdge("16", "17"); graph.AddEdge("16", "18"); graph.AddEdge("19", "20"); graph.AddEdge("19", "21"); graph.AddEdge("17", "19"); graph.AddEdge("2", "19"); graph.AddEdge("22", "23"); e = graph.AddEdge("22", "24"); e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; StraightenEdge(e, graph); e = graph.AddEdge("8", "22"); e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; StraightenEdge(e, graph); graph.AddEdge("20", "22"); graph.AddEdge("25", "26"); graph.AddEdge("25", "27"); graph.AddEdge("20", "25"); graph.AddEdge("28", "29"); graph.AddEdge("28", "30"); graph.AddEdge("31", "32"); graph.AddEdge("31", "33"); graph.AddEdge("5", "31"); graph.AddEdge("8", "31"); graph.AddEdge("2", "31"); graph.AddEdge("20", "31"); graph.AddEdge("17", "31"); graph.AddEdge("29", "31"); graph.AddEdge("34", "35"); graph.AddEdge("34", "36"); graph.AddEdge("20", "34"); graph.AddEdge("29", "34"); graph.AddEdge("5", "34"); graph.AddEdge("2", "34"); graph.AddEdge("8", "34"); graph.AddEdge("17", "34"); graph.AddEdge("37", "38"); graph.AddEdge("37", "39"); graph.AddEdge("29", "37"); graph.AddEdge("5", "37"); graph.AddEdge("20", "37"); graph.AddEdge("8", "37"); graph.AddEdge("2", "37"); graph.AddEdge("40", "41"); graph.AddEdge("40", "42"); graph.AddEdge("17", "40"); graph.AddEdge("2", "40"); graph.AddEdge("8", "40"); graph.AddEdge("5", "40"); graph.AddEdge("20", "40"); graph.AddEdge("29", "40"); graph.AddEdge("43", "44"); graph.AddEdge("43", "45"); graph.AddEdge("8", "43"); graph.AddEdge("2", "43"); graph.AddEdge("20", "43"); graph.AddEdge("17", "43"); graph.AddEdge("5", "43"); graph.AddEdge("29", "43"); graph.AddEdge("46", "47"); graph.AddEdge("46", "48"); graph.AddEdge("29", "46"); graph.AddEdge("5", "46"); graph.AddEdge("17", "46"); graph.AddEdge("49", "50"); graph.AddEdge("49", "51"); graph.AddEdge("5", "49"); graph.AddEdge("2", "49"); graph.AddEdge("52", "53"); graph.AddEdge("52", "54"); graph.AddEdge("17", "52"); graph.AddEdge("20", "52"); graph.AddEdge("2", "52"); graph.AddEdge("50", "52"); graph.AddEdge("55", "56"); graph.AddEdge("55", "57"); graph.AddEdge("58", "59"); graph.AddEdge("58", "60"); graph.AddEdge("20", "58"); graph.AddEdge("29", "58"); graph.AddEdge("5", "58"); graph.AddEdge("47", "58"); //ChangeNodeSizes(graph); //var sls = graph.LayoutAlgorithmSettings as SugiyamaLayoutSettings; //if (sls != null) //{ // sls.GridSizeByX = 30; // // sls.GridSizeByY = 0; //} //layout the graph and draw it gViewer.Graph = graph; this.propertyGrid1.SelectedObject = graph; }
/// <summary> /// Setting attribute from values. /// </summary> /// <param name="arrayList"></param> /// <param name="edge"></param> /// <returns></returns> public static void AddEdgeAttrs(ArrayList arrayList, Edge edge) { var label = new Label(); var edgeAttr = new EdgeAttr(); foreach (AttributeValuePair attrVal in arrayList) { if (AddAttributeKeyVal(new CoupleLabelBaseAttr(label, edgeAttr), attrVal)) continue; switch (attrVal.attributeTypeEnum) { case AttributeTypeEnum.LabelLocation: var posData = (PosData) attrVal.val; var cpList = posData.ControlPoints as List<P2>; if (cpList != null) label.GeometryLabel.Center = cpList[0]; break; case AttributeTypeEnum.Arrowhead: edgeAttr.ArrowheadAtTarget = (ArrowStyle) attrVal.val; break; case AttributeTypeEnum.Id: edgeAttr.Id = attrVal.val as String; break; case AttributeTypeEnum.ArrowTail: edgeAttr.ArrowheadAtSource = (ArrowStyle) attrVal.val; break; case AttributeTypeEnum.RGBColor: edgeAttr.Color = StringToMsaglColor((string) attrVal.val); break; case AttributeTypeEnum.Label: label.Text = attrVal.val as String; break; case AttributeTypeEnum.Color: edgeAttr.Color = StringToMsaglColor((string) attrVal.val); break; case AttributeTypeEnum.Fontcolor: label.FontColor = StringToMsaglColor((string) attrVal.val); break; case AttributeTypeEnum.Pos: { posData = (PosData) attrVal.val; //consider creating a Microsoft.Msagl.Splines.ICurve here InitGeomEdge(edge); if (posData.ArrowAtSource) edge.GeometryEdge.EdgeGeometry.SourceArrowhead = new Arrowhead { TipPosition = posData.ArrowAtSourcePosition }; if (posData.ArrowAtTarget) edge.GeometryEdge.EdgeGeometry.TargetArrowhead = new Arrowhead { TipPosition = posData.ArrowAtTargetPosition }; var list = posData.ControlPoints as List<P2>; if (list != null && list.Count%3 == 1) AddBezieSegsToEdgeFromPosData(edge, list); break; } case AttributeTypeEnum.Style: AddStyles(edgeAttr, attrVal.val); break; case AttributeTypeEnum.EdgeDirection: //edgeAttr.Dir=(EdgeDirection) attrVal.val; break; case AttributeTypeEnum.Weight: if(attrVal.val is String) edgeAttr.Weight=Int32.Parse( attrVal.val as String,AttributeBase.USCultureInfo); else edgeAttr.Weight=(int) attrVal.val; break; case AttributeTypeEnum.Ignore: {} break; case AttributeTypeEnum.ArrowSize: //Bug break; case AttributeTypeEnum.SameTail: //edgeAttr.Sametail=attrVal.val as String; break; case AttributeTypeEnum.SameHead: //edgeAttr.Samehead=attrVal.val as String; break; case AttributeTypeEnum.Constraint: //do nothing //edgeAttr.Constraint=(bool)attrVal.val; break; default: throw new Exception(string.Format("The attribute \"{0}\" is not supported for edges", attrVal.attributeTypeEnum)); } } edge.Attr = edge.Attr; if (!String.IsNullOrEmpty(label.Text)) edge.Label = new Label(label.Text) { Owner = edge }; }
void WriteLabel(Label label) { if (!LabelIsValid(label)) return; //need to remove these hecks. TODO const double yScaleAdjustment = 1.5; // const double scaleFromGdiToSvg = 1.5; var x = label.Center.X - label.Width / 2; var y = label.Center.Y + label.Height / (2 * yScaleAdjustment); WriteStartElement("text"); WriteAttribute("x", x); WriteAttribute("y", y); WriteAttribute("font-family", "Arial");//AttrSanitizer(label.FontName)); WriteAttribute("font-size", "16"); //label.FontSize * scaleFromGdiToSvg); WriteAttribute("fill", MsaglColorToSvgColor(label.FontColor)); xmlWriter.WriteRaw(NodeSanitizer(label.Text)); WriteEndElement(); }
public static FontFamily CreateFontFamily(MsaglDrawing.Label label) { return(new FontFamily(label.FontName)); }
void CreateGraph() { #if DEBUG DisplayGeometryGraph.SetShowFunctions(); #endif //Graph graph = new Graph(); //graph.AddEdge("47", "58"); //graph.AddEdge("70", "71"); //var subgraph = new Subgraph("subgraph1"); //graph.RootSubgraph.AddSubgraph(subgraph); //subgraph.AddNode(graph.FindNode("47")); //subgraph.AddNode(graph.FindNode("58")); //var subgraph2 = new Subgraph("subgraph2"); //subgraph2.Attr.Color = Color.Black; //subgraph2.Attr.FillColor = Color.Yellow; //subgraph2.AddNode(graph.FindNode("70")); //subgraph2.AddNode(graph.FindNode("71")); //subgraph.AddSubgraph(subgraph2); //graph.AddEdge("58", subgraph2.Id); //graph.Attr.LayerDirection = LayerDirection.LR; //gViewer.Graph = graph; Graph graph = new Graph("graph"); //graph.LayoutAlgorithmSettings=new MdsLayoutSettings(); gViewer.BackColor = System.Drawing.Color.FromArgb(10, System.Drawing.Color.Red); /* * 4->5 * 5->7 * 7->8 * 8->22 * 22->24 */ graph.AddEdge("1", "2"); graph.AddEdge("1", "3"); var e = graph.AddEdge("4", "5"); e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; graph.LayerConstraints.AddUpDownVerticalConstraint(graph.FindNode("4"), graph.FindNode("5")); StraightenEdge(e, graph); e = graph.AddEdge("4", "6"); e.LabelText = "Changing label"; this.labelToChange = e.Label; e = graph.AddEdge("7", "8"); e.Attr.LineWidth *= 2; e.Attr.Color = Color.Red; StraightenEdge(e, graph); graph.AddEdge("7", "9"); e = graph.AddEdge("5", "7"); e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; StraightenEdge(e, graph); graph.AddEdge("2", "7"); graph.AddEdge("10", "11"); graph.AddEdge("10", "12"); graph.AddEdge("2", "10"); graph.AddEdge("8", "10"); graph.AddEdge("5", "10"); graph.AddEdge("13", "14"); graph.AddEdge("13", "15"); graph.AddEdge("8", "13"); graph.AddEdge("2", "13"); graph.AddEdge("5", "13"); graph.AddEdge("16", "17"); graph.AddEdge("16", "18"); graph.AddEdge("19", "20"); graph.AddEdge("19", "21"); graph.AddEdge("17", "19"); graph.AddEdge("2", "19"); graph.AddEdge("22", "23"); e = graph.AddEdge("22", "24"); e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; StraightenEdge(e, graph); e = graph.AddEdge("8", "22"); e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; StraightenEdge(e, graph); graph.AddEdge("20", "22"); graph.AddEdge("25", "26"); graph.AddEdge("25", "27"); graph.AddEdge("20", "25"); graph.AddEdge("28", "29"); graph.AddEdge("28", "30"); graph.AddEdge("31", "32"); graph.AddEdge("31", "33"); graph.AddEdge("5", "31"); graph.AddEdge("8", "31"); graph.AddEdge("2", "31"); graph.AddEdge("20", "31"); graph.AddEdge("17", "31"); graph.AddEdge("29", "31"); graph.AddEdge("34", "35"); graph.AddEdge("34", "36"); graph.AddEdge("20", "34"); graph.AddEdge("29", "34"); graph.AddEdge("5", "34"); graph.AddEdge("2", "34"); graph.AddEdge("8", "34"); graph.AddEdge("17", "34"); graph.AddEdge("37", "38"); graph.AddEdge("37", "39"); graph.AddEdge("29", "37"); graph.AddEdge("5", "37"); graph.AddEdge("20", "37"); graph.AddEdge("8", "37"); graph.AddEdge("2", "37"); graph.AddEdge("40", "41"); graph.AddEdge("40", "42"); graph.AddEdge("17", "40"); graph.AddEdge("2", "40"); graph.AddEdge("8", "40"); graph.AddEdge("5", "40"); graph.AddEdge("20", "40"); graph.AddEdge("29", "40"); graph.AddEdge("43", "44"); graph.AddEdge("43", "45"); graph.AddEdge("8", "43"); graph.AddEdge("2", "43"); graph.AddEdge("20", "43"); graph.AddEdge("17", "43"); graph.AddEdge("5", "43"); graph.AddEdge("29", "43"); graph.AddEdge("46", "47"); graph.AddEdge("46", "48"); graph.AddEdge("29", "46"); graph.AddEdge("5", "46"); graph.AddEdge("17", "46"); graph.AddEdge("49", "50"); graph.AddEdge("49", "51"); graph.AddEdge("5", "49"); graph.AddEdge("2", "49"); graph.AddEdge("52", "53"); graph.AddEdge("52", "54"); graph.AddEdge("17", "52"); graph.AddEdge("20", "52"); graph.AddEdge("2", "52"); graph.AddEdge("50", "52"); graph.AddEdge("55", "56"); graph.AddEdge("55", "57"); graph.AddEdge("58", "59"); graph.AddEdge("58", "60"); graph.AddEdge("20", "58"); graph.AddEdge("29", "58"); graph.AddEdge("5", "58"); graph.AddEdge("47", "58"); //ChangeNodeSizes(graph); //var sls = graph.LayoutAlgorithmSettings as SugiyamaLayoutSettings; //if (sls != null) //{ // sls.GridSizeByX = 30; // // sls.GridSizeByY = 0; //} //layout the graph and draw it gViewer.Graph = graph; this.propertyGrid1.SelectedObject = graph; }
static bool LabelIsValid(Label label) { if (label == null || String.IsNullOrEmpty(label.Text) || label.Width == 0) return false; return true; }
static TextBlock CreateTextBlock(Label drawingLabel) { var textBlock = new TextBlock { Tag = drawingLabel, Text = drawingLabel.Text, FontFamily = new FontFamily(drawingLabel.FontName), FontSize = drawingLabel.FontSize, Foreground = Common.BrushFromMsaglColor(drawingLabel.FontColor) }; textBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); textBlock.Width = textBlock.DesiredSize.Width; textBlock.Height = textBlock.DesiredSize.Height; textBlock.Background = Brushes.Transparent; textBlock.IsHitTestVisible = true; return textBlock; }
/// <summary> /// constructor /// </summary> /// <param name="parentPar"></param> /// <param name="label"></param> /// <param name="viewer">the viewer containing the label</param> public DLabel(DObject parentPar, Label label, GViewer viewer) : base(viewer) { parent = parentPar; DrawingLabel = label; ((IHavingDLabel) parent).Label = this; Font = new Font(DrawingLabel.FontName, (int)DrawingLabel.FontSize, (System.Drawing.FontStyle)(int)label.FontStyle); }
private void WriteLabel(Label label) { WriteStartElement(Tokens.Label); if (label != null && !String.IsNullOrEmpty(label.Text)) { WriteStringElement(Tokens.Text, label.Text); WriteStringElement(Tokens.FontName, label.FontName); WriteColorElement(Tokens.FontColor, label.FontColor); WriteStringElement(Tokens.FontStyle, (int)label.FontStyle); WriteStringElement(Tokens.FontSize, label.FontSize); WriteStringElement(Tokens.Width, label.Width); WriteStringElement(Tokens.Height, label.Height); } WriteEndElement(); }
static void InitGeomLabel(Label label) { if (label.GeometryLabel == null) label.GeometryLabel = new Microsoft.Msagl.Core.Layout.Label(); }
void CreateGraph() { Graph graph = new Graph("graph"); //graph.LayoutAlgorithmSettings=new MdsLayoutSettings(); gViewer.BackColor = System.Drawing.Color.FromArgb(10, System.Drawing.Color.Red); /* * 4->5 * 5->7 * 7->8 * 8->22 * 22->24 */ //int wm = 80; graph.AddEdge("1", "2"); graph.AddEdge("1", "3"); var e = graph.AddEdge("4", "5"); //e.Attr.Weight *= wm; e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; e = graph.AddEdge("4", "6"); e.LabelText = "Changing label"; this.labelToChange = e.Label; e = graph.AddEdge("7", "8"); //e.Attr.Weight *= wm; e.Attr.LineWidth *= 2; e.Attr.Color = Color.Red; graph.AddEdge("7", "9"); e = graph.AddEdge("5", "7"); //e.Attr.Weight *= wm; e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; graph.AddEdge("2", "7"); graph.AddEdge("10", "11"); graph.AddEdge("10", "12"); graph.AddEdge("2", "10"); graph.AddEdge("8", "10"); graph.AddEdge("5", "10"); graph.AddEdge("13", "14"); graph.AddEdge("13", "15"); graph.AddEdge("8", "13"); graph.AddEdge("2", "13"); graph.AddEdge("5", "13"); graph.AddEdge("16", "17"); graph.AddEdge("16", "18"); graph.AddEdge("19", "20"); graph.AddEdge("19", "21"); graph.AddEdge("17", "19"); graph.AddEdge("2", "19"); graph.AddEdge("22", "23"); e = graph.AddEdge("22", "24"); //e.Attr.Weight *= wm; e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; e = graph.AddEdge("8", "22"); //e.Attr.Weight *= wm; e.Attr.Color = Color.Red; e.Attr.LineWidth *= 2; graph.AddEdge("20", "22"); graph.AddEdge("25", "26"); graph.AddEdge("25", "27"); graph.AddEdge("20", "25"); graph.AddEdge("28", "29"); graph.AddEdge("28", "30"); graph.AddEdge("31", "32"); graph.AddEdge("31", "33"); graph.AddEdge("5", "31"); graph.AddEdge("8", "31"); graph.AddEdge("2", "31"); graph.AddEdge("20", "31"); graph.AddEdge("17", "31"); graph.AddEdge("29", "31"); graph.AddEdge("34", "35"); graph.AddEdge("34", "36"); graph.AddEdge("20", "34"); graph.AddEdge("29", "34"); graph.AddEdge("5", "34"); graph.AddEdge("2", "34"); graph.AddEdge("8", "34"); graph.AddEdge("17", "34"); graph.AddEdge("37", "38"); graph.AddEdge("37", "39"); graph.AddEdge("29", "37"); graph.AddEdge("5", "37"); graph.AddEdge("20", "37"); graph.AddEdge("8", "37"); graph.AddEdge("2", "37"); graph.AddEdge("40", "41"); graph.AddEdge("40", "42"); graph.AddEdge("17", "40"); graph.AddEdge("2", "40"); graph.AddEdge("8", "40"); graph.AddEdge("5", "40"); graph.AddEdge("20", "40"); graph.AddEdge("29", "40"); graph.AddEdge("43", "44"); graph.AddEdge("43", "45"); graph.AddEdge("8", "43"); graph.AddEdge("2", "43"); graph.AddEdge("20", "43"); graph.AddEdge("17", "43"); graph.AddEdge("5", "43"); graph.AddEdge("29", "43"); graph.AddEdge("46", "47"); graph.AddEdge("46", "48"); graph.AddEdge("29", "46"); graph.AddEdge("5", "46"); graph.AddEdge("17", "46"); graph.AddEdge("49", "50"); graph.AddEdge("49", "51"); graph.AddEdge("5", "49"); graph.AddEdge("2", "49"); graph.AddEdge("52", "53"); graph.AddEdge("52", "54"); graph.AddEdge("17", "52"); graph.AddEdge("20", "52"); graph.AddEdge("2", "52"); graph.AddEdge("50", "52"); graph.AddEdge("55", "56"); graph.AddEdge("55", "57"); graph.AddEdge("58", "59"); graph.AddEdge("58", "60"); graph.AddEdge("20", "58"); graph.AddEdge("29", "58"); graph.AddEdge("5", "58"); graph.AddEdge("47", "58"); //ChangeNodeSizes(graph); //var sls = graph.LayoutAlgorithmSettings as SugiyamaLayoutSettings; //if (sls != null) //{ // sls.GridSizeByX = 30; // // sls.GridSizeByY = 0; //} var subgraph = new Subgraph("subgraph label"); graph.RootSubgraph.AddSubgraph(subgraph); subgraph.AddNode(graph.FindNode("47")); subgraph.AddNode(graph.FindNode("58")); //layout the graph and draw it gViewer.Graph = graph; this.propertyGrid1.SelectedObject = graph; }
public TextBlock CreateTextBlockFromDrawingObjectLabel(Microsoft.Msagl.Drawing.Label drawingLabel) { return(VisualsFactory.CreateLabel(drawingLabel)); }
/// <summary> /// sets the edge label /// </summary> /// <param name="edge"></param> /// <param name="label"></param> public void SetEdgeLabel(DrawingEdge edge, Label label) { //find the edge first DEdge de = null; foreach (DEdge dEdge in DGraph.Edges) if (dEdge.DrawingEdge == edge) { de = dEdge; break; } Debug.Assert(de != null); edge.Label = label; double w, h; DGraph.CreateDLabel(de, label, out w, out h, this); edge.GeometryEdge.Label = label.GeometryLabel; ICurve curve = edge.GeometryEdge.Curve; label.GeometryLabel.Center = curve[(curve.ParStart + curve.ParEnd)/2]; label.GeometryLabel.GeometryParent = edge.GeometryEdge; BbNode = DGraph.BbNode = null; Invalidate(); }
static void SetGeomLabelCenter(Label label, P2 point) { InitGeomLabel(label); label.GeometryLabel.Center = point; }