Esempio n. 1
0
        internal DEdge(DNode source, DNode target, DrawingEdge drawingEdgeParam, ConnectionToGraph connection,
                       GViewer gviewer) : base(gviewer)
        {
            DrawingEdge = drawingEdgeParam;
            Source      = source;
            Target      = target;

            if (connection == ConnectionToGraph.Connected)
            {
                if (source == target)
                {
                    source.AddSelfEdge(this);
                }
                else
                {
                    source.AddOutEdge(this);
                    target.AddInEdge(this);
                }
            }

            if (drawingEdgeParam.Label != null)
            {
                Label = new DLabel(this, drawingEdge.Label, gviewer);
            }
        }
Esempio n. 2
0
        static BBNode BuildBBHierarchyUnderDObject(DObject dObject)
        {
            DNode dNode = dObject as DNode;

            if (dNode != null)
            {
                return(BuildBBHierarchyUnderDNode(dNode));
            }
            DEdge dedge = dObject as DEdge;

            if (dedge != null)
            {
                return(BuildBBHierarchyUnderDEdge(dedge));
            }
            DLabel dLabel = dObject as DLabel;

            if (dLabel != null)
            {
                return(BuildBBHierarchyUnderDLabel(dLabel));
            }

            DGraph dGraph = dObject as DGraph;

            if (dGraph != null)
            {
                dGraph.BbNode.bBox = dGraph.DrawingGraph.BoundingBox;
                return(dGraph.BbNode);
            }

            throw new InvalidOperationException();
        }
Esempio n. 3
0
        internal static bool DLabelIsValid(DLabel dLabel)
        {
            var drawingObj = dLabel.DrawingObject;
            var edge       = drawingObj.GeometryObject.GeometryParent as GeometryEdge;

            return(edge == null || edge.Label != null);
        }
Esempio n. 4
0
        static BBNode BuildBBHierarchyUnderDLabel(DLabel dLabel)
        {
            var bbNode = new BBNode();

            bbNode.geometry = new Geometry(dLabel);
            bbNode.bBox     = dLabel.DrawingLabel.BoundingBox;
            return(bbNode);
        }
Esempio n. 5
0
        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;
        }
        internal DEdge(DNode source, DNode target, DrawingEdge drawingEdgeParam, ConnectionToGraph connection,
                       GViewer gviewer) : base(gviewer) {
            DrawingEdge = drawingEdgeParam;
            Source = source;
            Target = target;

            if (connection == ConnectionToGraph.Connected) {
                if (source == target)
                    source.AddSelfEdge(this);
                else {
                    source.AddOutEdge(this);
                    target.AddInEdge(this);
                }
            }

            if (drawingEdgeParam.Label != null)
                Label = new DLabel(this, drawingEdge.Label, gviewer);
        }
Esempio n. 7
0
        internal Geometry(DObject tag)
        {
            this.tag = tag;

            DNode dNode = tag as DNode;

            if (dNode != null)
            {
                bBox = dNode.DrawingNode.BoundingBox;
            }
            else
            {
                DLabel dLabel = tag as DLabel;
                if (dLabel != null)
                {
                    bBox = dLabel.DrawingLabel.BoundingBox;
                }
            }
        }
Esempio n. 8
0
        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 Geometry(DObject dObject)
        {
            this.dObject = dObject;

            DNode dNode = dObject as DNode;

            if (dNode != null)
            {
                bBox = dNode.DrawingNode.BoundingBox;
            }
            else
            {
                DLabel dLabel = dObject as DLabel;
                if (dLabel != null)
                {
                    bBox = dLabel.DrawingLabel.BoundingBox;
                }
            }
        }
Esempio n. 10
0
        static internal void DrawLabel(Graphics g, DLabel label)
        {
            if (label == null)
            {
                return;
            }

            try {
                using (SolidBrush sb = new SolidBrush(MsaglColorToDrawingColor(label.DrawingLabel.FontColor))) {
                    DrawStringInRectCenter(g, sb,
                                           label.Font, label.DrawingLabel.Text,
                                           new RectangleF((float)label.DrawingLabel.Left, (float)label.DrawingLabel.Bottom,
                                                          (float)label.DrawingLabel.Size.Width, (float)label.DrawingLabel.Size.Height));
                }
            } catch { }

            if (label.MarkedForDragging)
            {
                Pen pen = new Pen(MsaglColorToDrawingColor(label.DrawingLabel.FontColor));
                pen.DashStyle = DashStyle.Dot;
                DrawLine(g, pen, label.DrawingLabel.GeometryLabel.AttachmentSegmentStart,
                         label.DrawingLabel.GeometryLabel.AttachmentSegmentEnd);
            }
        }
Esempio n. 11
0
        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)};
            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;
        }
Esempio n. 12
0
 static BBNode BuildBBHierarchyUnderDLabel(DLabel dLabel){
     var bbNode = new BBNode();
     bbNode.geometry = new Geometry(dLabel);
     bbNode.bBox = dLabel.DrawingLabel.BoundingBox;
     return bbNode;
 }
Esempio n. 13
0
 internal static bool DLabelIsValid(DLabel dLabel) {
     var drawingObj = dLabel.DrawingObject;
     var edge = drawingObj.GeometryObject.GeometryParent as GeometryEdge;
     return edge == null || edge.Label != null;
 }
 private static RectangleF GetLabelRect(DLabel label)
 {
     var subgraph = label.DrawingLabel.Owner as Subgraph;
     if (subgraph != null)
     {
         var cluster = (Cluster) subgraph.GeometryNode;
         var rb = cluster.RectangularBoundary;
         var cx = rb.Rect.Left + rb.Rect.Width/2;
         var cy = cluster.BoundingBox.Top - rb.TopMargin/2;
         var size = label.DrawingLabel.Size;
         return new RectangleF(
             (float) (cx - size.Width/2),
             (float) (cy - size.Height/2),
             (float) size.Width,
             (float) size.Height);
     }
     else
     {
         var rectF = new RectangleF((float) label.DrawingLabel.Left, (float) label.DrawingLabel.Bottom,
             (float) label.DrawingLabel.Size.Width,
             (float) label.DrawingLabel.Size.Height);
         return rectF;
     }
 }
        internal static void DrawLabel(Graphics g, DLabel label){
            if (label == null || label.DrawingLabel.Width == 0)
                return;

            var rectF = GetLabelRect(label);
            
            try{
                DrawStringInRectCenter(g, new SolidBrush(MsaglColorToDrawingColor(label.DrawingLabel.FontColor)),
                                       label.Font, label.DrawingLabel.Text, rectF);
            }
            catch{
            }
            if(label.MarkedForDragging){
                var pen = new Pen(MsaglColorToDrawingColor(label.DrawingLabel.FontColor));
                pen.DashStyle = DashStyle.Dot;
                DrawLine(g, pen, label.DrawingLabel.GeometryLabel.AttachmentSegmentStart,
                         label.DrawingLabel.GeometryLabel.AttachmentSegmentEnd);
            }
        }