예제 #1
0
        void GViewerOnMouseMove(object sender, MouseEventArgs mouseEventArgs)
        {
            if (labelToChange == null)
            {
                return;
            }
            labelToChange.Text = MousePosition.ToString();
            if (viewerEntityCorrespondingToLabelToChange == null)
            {
                foreach (var e in gViewer.Entities)
                {
                    if (e.DrawingObject == labelToChange)
                    {
                        viewerEntityCorrespondingToLabelToChange = e;
                        break;
                    }
                }
            }
            if (viewerEntityCorrespondingToLabelToChange == null)
            {
                return;
            }
            var    rect = labelToChange.BoundingBox;
            var    font = new Font(labelToChange.FontName, (int)labelToChange.FontSize);
            double width;
            double height;

            StringMeasure.MeasureWithFont(labelToChange.Text, 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", font, out width, out height);
            }

            labelToChange.Width  = width;
            labelToChange.Height = height;
            rect.Add(labelToChange.BoundingBox);
            gViewer.Invalidate(gViewer.MapSourceRectangleToScreenRectangle(rect));
        }
예제 #2
0
        void GViewerOnMouseMove(Edge edge, string value)
        {
            if (edge.Label == null)
            {
                return;
            }
            edge.Label.Text = value;

            var rect = edge.Label.BoundingBox;
            var font = new Font(edge.Label.FontName, (int)edge.Label.FontSize);

            StringMeasure.MeasureWithFont(edge.Label.Text, font, out double width, out double height);

            if (width <= 0)
            {
                StringMeasure.MeasureWithFont("a", font, out width, out height);
            }

            edge.Label.Width  = width;
            edge.Label.Height = height;
            rect.Add(edge.Label.BoundingBox);
            gViewer.Invalidate(gViewer.MapSourceRectangleToScreenRectangle(rect));
        }