Ejemplo n.º 1
0
        public override void MakeVisual()
        {
            if (GeometryNode.BoundaryCurve == null)
            {
                return;
            }
            SetValue(Canvas.LeftProperty, Node.BoundingBox.Left);
            SetValue(Canvas.TopProperty, Node.BoundingBox.Bottom);

            // Note that Draw.CreateGraphicsPath returns a curve with coordinates in graph space.
            var pathFigure = Draw.CreateGraphicsPath((DrawingNode.GeometryNode).BoundaryCurve);

            pathFigure.IsFilled = Node.Attr.FillColor != Drawing.Color.Transparent;
            var pathGeometry = new PathGeometry();

            pathGeometry.Figures.Add(pathFigure);
            // Apply a translation to bring the coordinates in node space (i.e. top left corner is 0,0).
            pathGeometry.Transform = new TranslateTransform()
            {
                X = -Node.BoundingBox.Left, Y = -Node.BoundingBox.Bottom
            };

            // I'm using the max of my LineWidth and MSAGL's LineWidth; this way, when the MSAGL bug is fixed (see below), my workaround shouldn't
            // interfere with the fix.
            var path = new Path()
            {
                Data            = pathGeometry,
                StrokeThickness = Math.Max(LineWidth, Node.Attr.LineWidth),
                Stroke          = BoundaryBrush,
                Fill            = new SolidColorBrush(Draw.MsaglColorToDrawingColor(Node.Attr.FillColor))
            };

            Content = path;
        }
Ejemplo n.º 2
0
        public override void MeasureLabel()
        {
            if (Label.Text != null && Label.Text.Length > 0)
            {
                TextBlock tb = new TextBlock();
                tb.FontFamily        = new FontFamily(Label.FontName);
                tb.FontSize          = Label.FontSize;
                tb.Foreground        = Label.FontColor == Microsoft.Msagl.Drawing.Color.Black ? DGraph.BlackBrush : new SolidColorBrush(Draw.MsaglColorToDrawingColor(Label.FontColor));
                tb.Text              = Label.Text;
                tb.TextAlignment     = TextAlignment.Center;
                tb.VerticalAlignment = VerticalAlignment.Center;
                Content              = tb;
            }

            base.MeasureLabel();
        }
Ejemplo n.º 3
0
        public override void MakeVisual()
        {
            if (Label.Text != null && Label.Text.Length > 0)
            {
                TextBlock tb = new TextBlock();
                tb.FontFamily        = new FontFamily(Label.FontName);
                tb.FontSize          = Label.FontSize;
                tb.Foreground        = Label.FontColor == Microsoft.Msagl.Drawing.Color.Black ? DGraph.BlackBrush : new SolidColorBrush(Draw.MsaglColorToDrawingColor(Label.FontColor));
                tb.Text              = Label.Text;
                tb.TextAlignment     = TextAlignment.Center;
                tb.VerticalAlignment = VerticalAlignment.Center;
                Content              = tb;
                Label.Width          = Width = tb.ActualWidth;
                Label.Height         = Height = tb.ActualHeight;
            }
            else
            {
                Label.Width  = Width = 0.0;
                Label.Height = Height = 0.0;
            }
            if (Label.GeometryLabel != null)
            {
                Label.GeometryLabel.Width  = Math.Max(1.0, Label.Width);
                Label.GeometryLabel.Height = Math.Max(1.0, Label.Height);
            }

            CenterLabel();
        }