internal static DNode CreateDNodeAndSetNodeBoundaryCurveForSubgraph(Graph drawingGraph, DGraph dGraph, GeometryNode geomNode, DrawingNode drawingNode, GViewer viewer) { double width = 0; double height = 0; var dNode = new DNode(drawingNode, viewer); dGraph.AddNode(dNode); Drawing.Label label = drawingNode.Label; if (label != null) { CreateDLabel(dNode, label, out width, out height, viewer); } if (width < drawingGraph.Attr.MinNodeWidth) { width = drawingGraph.Attr.MinNodeWidth; } if (height < drawingGraph.Attr.MinNodeHeight) { height = drawingGraph.Attr.MinNodeHeight; } var cluster = (Cluster)geomNode; var margin = dNode.DrawingNode.Attr.LabelMargin; if (label != null) { CreateDLabel(dNode, label, out width, out height, viewer); width += 2 * dNode.DrawingNode.Attr.LabelMargin + 2 * drawingNode.Attr.LineWidth; height += 2 * dNode.DrawingNode.Attr.LabelMargin + 2 * drawingNode.Attr.LineWidth; } cluster.RectangularBoundary = new RectangularClusterBoundary() { BottomMargin = margin, LeftMargin = margin, RightMargin = margin, TopMargin = height, MinWidth = width }; // 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; ICurve curve; if (drawingNode.NodeBoundaryDelegate != null && (curve = drawingNode.NodeBoundaryDelegate(drawingNode)) != null) { geomNode.BoundaryCurve = curve; } else if (geomNode.BoundaryCurve == null) { geomNode.BoundaryCurve = NodeBoundaryCurves.GetNodeBoundaryCurve(dNode.DrawingNode, width, height); } return(dNode); }
internal static void CreateDLabel(DObject parent, Drawing.Label label, out double width, out double height, GViewer viewer) { var dLabel = new DLabel(parent, label, viewer) { Font = new Font(label.FontName, (int)label.FontSize, (System.Drawing.FontStyle)(int) label.FontStyle) }; StringMeasure.MeasureWithFont(label.Text, dLabel.Font, out width, out height); if (width <= 0) { //this is a temporary fix for win7 where Measure fonts return negative lenght for the string " " StringMeasure.MeasureWithFont("a", dLabel.Font, out width, out height); } label.Width = width; label.Height = height; }
internal static DGraph CreateDGraphAndGeometryInfo(Graph drawingGraph, GeometryGraph geometryGraph, GViewer viewer) { var dGraph = new DGraph(drawingGraph, viewer); //create dnodes and glee node boundary curves var nodeMapping = new Dictionary <GeometryNode, DNode>(); if (geometryGraph.RootCluster != null) { foreach (var geomCluster in geometryGraph.RootCluster.AllClustersDepthFirstExcludingSelf()) { var drawingNode = (Drawing.Node)geomCluster.UserData; DNode dNode = CreateDNodeAndSetNodeBoundaryCurveForSubgraph(drawingGraph, dGraph, geomCluster, drawingNode, viewer); nodeMapping[geomCluster] = dNode; } } foreach (GeometryNode geomNode in geometryGraph.Nodes) { var drawingNode = (Drawing.Node)geomNode.UserData; DNode dNode = CreateDNodeAndSetNodeBoundaryCurve(drawingGraph, dGraph, geomNode, drawingNode, viewer); nodeMapping[geomNode] = dNode; } foreach (GeometryEdge gleeEdge in geometryGraph.Edges) { var dEdge = new DEdge(nodeMapping[gleeEdge.Source], nodeMapping[gleeEdge.Target], gleeEdge.UserData as DrawingEdge, ConnectionToGraph.Connected, viewer); dGraph.AddEdge(dEdge); DrawingEdge drawingEdge = dEdge.Edge; Drawing.Label label = drawingEdge.Label; if (label != null) { double width, height; CreateDLabel(dEdge, label, out width, out height, viewer); } } return(dGraph); }
/// <summary> /// Main Constructor for the StartUpMenu. /// </summary> /// <param name="window">Window that displays the graphics</param> public StartUpMenu(GameWindow window) : base(new Arena(new Position(1000, 1000), 1000, 1000)) { _win = window; const string SpacetaxiLine = " Press 't' for SpaceTaxi\n"; const string GalagaLine = " Press 'g' for Galaga\n"; const string quitLine = " Press 'q' to quit"; _pickGameLabel = new Drawing.Label( _win.Area, 12, SpacetaxiLine + GalagaLine + quitLine); int maxX = Drawing.Scaler.MaxX; int maxY = Drawing.Scaler.MaxY; var scnPic = ImageStream(@"GameEngine.Resources.Images.SpaceBackground.png"); _SpaceBackground = new Drawing.Image(scnPic, maxX, maxY); }
public static Size MeasureLabel(Drawing.Label label) { return(MeasureText(label.Text, new FontFamily(label.FontName), label.FontSize)); }
private void DrawLabelCentered(Drawing.Label label, int y) { label.DrawAligned(_win.Area.Pixmap, Drawing.TextAlignment.Center, y); }