MapSuiteGisEditor/GisEditorInfrastructure/Shares/SelectionAdorner.cs
/// <summary>
/// When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
/// </summary>
/// <param name="drawingContext">The drawing instructions for a specific element. This context is provided to the layout system.</param>
When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
When overridden in a derived class participates in rendering operations that are directed by the layout system . The rendering instructions for this element are not used directly when this method is invoked and are instead preserved for later asynchronous use by layout and drawing .
protected override void OnRender(DrawingContext drawingContext)
        {
            var fe = AdornedElement as FrameworkElement;
            if (fe == null)
            {
                return;
            }
            var rect = new Rect(1, 1, Math.Max(0, fe.ActualWidth - 2), Math.Max(0, fe.ActualHeight - 2));
            var color = Colors.Red;
            var brush = new SolidColorBrush(color);
            var pen = new Pen(brush, 1);
            pen.Freeze();
            var dashPen = new Pen(brush, 1) { DashStyle = new DashStyle(new double[] { 1, 6 }, 0) };
            dashPen.Freeze();
            var guidelineSet = new GuidelineSet();
            guidelineSet.GuidelinesX.Add(0.5);
            guidelineSet.GuidelinesY.Add(0.5);
            drawingContext.PushGuidelineSet(guidelineSet);
            drawingContext.DrawRectangle(null, pen, rect);
            var formattedHeight = new FormattedText(string.Format("{0:0}", fe.ActualHeight), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, TypeFace, 10, brush);
            var formattedWidth = new FormattedText(string.Format("{0:0}", fe.ActualWidth), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, TypeFace, 10, brush);
            drawingContext.Pop();
        }
protected override void OnRender ( DrawingContext drawingContext ) { var fe = AdornedElement as FrameworkElement ; if ( fe == null ) { return ; } var rect = new Rect ( 1 , 1 , Math . Max ( 0 , fe . ActualWidth - 2 ) , Math . Max ( 0 , fe . ActualHeight - 2 ) ) ; var color = Colors . Red ; var brush = new SolidColorBrush ( color ) ; var pen = new Pen ( brush , 1 ) ; pen . Freeze ( ) ; var dashPen = new Pen ( brush , 1 ) { DashStyle = new DashStyle ( new double [ ] { 1 , 6 } , 0 ) } ; dashPen . Freeze ( ) ; var guidelineSet = new GuidelineSet ( ) ; guidelineSet . GuidelinesX . Add ( 0.5 ) ; guidelineSet . GuidelinesY . Add ( 0.5 ) ; drawingContext . PushGuidelineSet ( guidelineSet ) ; drawingContext . DrawRectangle ( null , pen , rect ) ; var formattedHeight = new FormattedText ( string . Format ( " " , fe . ActualHeight ) , CultureInfo . InvariantCulture , FlowDirection . LeftToRight , TypeFace , 10 , brush ) ; var formattedWidth = new FormattedText ( string . Format ( " " , fe . ActualWidth ) , CultureInfo . InvariantCulture , FlowDirection . LeftToRight , TypeFace , 10 , brush ) ; drawingContext . Pop ( ) ; }
When overridden in a derived class, participates in rendering operations that are directed by the layout system.
When overridden in a derived class participates in rendering operations that are directed by the layout system .
//var outlinePen = new Pen(new SolidColorBrush(Color.FromArgb(0x70, 0xFF, 0xFF, 0xFF)), 5); //outlinePen.Freeze(); //drawingContext.DrawRectangle(null, outlinePen, rect); //drawingContext.DrawText(formattedHeight, new Point(rect.Width + 5, (rect.Height / 2) - (formattedHeight.Height / 2))); //drawingContext.DrawText(formattedWidth, new Point(rect.Width / 2 - formattedWidth.Width / 2, rect.Height + 5));
drawingContext
DrawingContext
The drawing instructions for a specific element. This context is provided to the layout system.
The drawing instructions for a specific element . This context is provided to the layout system .