コード例 #1
1
        /// <summary>
        /// Draw some helpful text.
        /// </summary>
        /// <param name="dc"></param>
        protected virtual void DrawHelpText(DrawingContext dc)
        {
            System.Windows.Media.Typeface backType =
                new System.Windows.Media.Typeface(new System.Windows.Media.FontFamily("sans courier"),
                                                  FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
            System.Windows.Media.FormattedText formatted = new System.Windows.Media.FormattedText(
                                                            "Click & move the mouse to select a capture area.\nENTER/F10: Capture\nBACKSPACE/DEL: Start over\nESC: Exit",
                                                            System.Globalization.CultureInfo.CurrentCulture,
                                                            FlowDirection.LeftToRight,
                                                            backType,
                                                            32.0f,
                                                            new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White));
            // Make sure the text shows at 0,0 on the primary screen
            System.Drawing.Point primScreen = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Location;
            Point clientBase = PointFromScreen(new Point(primScreen.X + 5, primScreen.Y + 5));
            Geometry textGeo = formatted.BuildGeometry(clientBase);
            dc.DrawGeometry(
                System.Windows.Media.Brushes.White,
                null,
                textGeo);

            dc.DrawGeometry(
                null,
                new System.Windows.Media.Pen(System.Windows.Media.Brushes.White, 1),
                textGeo);
        }
コード例 #2
1
 protected override void OnRender(DrawingContext drawingContext)
 {
     base.OnRender(drawingContext);
     drawingContext.PushTransform(new TranslateTransform(AdornedElement.RenderSize.Width - 14, (AdornedElement.RenderSize.Height - 18) / 2.0));
     drawingContext.DrawGeometry(ArrowBrush, null, sda_render_geometry);
     drawingContext.Pop();
 }
コード例 #3
1
ファイル: OutlinedText.cs プロジェクト: step4u/CallService
        /// <summary>
        /// OnRender override draws the geometry of the text and optional highlight.
        /// </summary>
        /// <param name="drawingContext">Drawing context of the OutlineText control.</param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            CreateText();
            // Draw the outline based on the properties that are set.
            drawingContext.DrawGeometry(Fill, new Pen(Stroke, StrokeThickness), _textGeometry);

        }
コード例 #4
0
            public void Draw(TextView textView, System.Windows.Media.DrawingContext drawingContext)
            {
                ISegment s = element.Segment;

                if (s != null)
                {
                    BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
                    geoBuilder.AlignToMiddleOfPixels = true;
                    if (Layer == KnownLayer.Background)
                    {
                        geoBuilder.AddSegment(textView, s);
                        drawingContext.DrawGeometry(backgroundBrush, null, geoBuilder.CreateGeometry());
                    }
                    else
                    {
                        // draw foreground only if active
                        if (element.isCaretInside)
                        {
                            geoBuilder.AddSegment(textView, s);
                            foreach (BoundActiveElement boundElement in element.context.ActiveElements.OfType <BoundActiveElement>())
                            {
                                if (boundElement.targetElement == element)
                                {
                                    geoBuilder.AddSegment(textView, boundElement.Segment);
                                    geoBuilder.CloseFigure();
                                }
                            }
                            drawingContext.DrawGeometry(null, activeBorderPen, geoBuilder.CreateGeometry());
                        }
                    }
                }
            }
コード例 #5
0
        protected override void OnRender(DrawingContext dc)
        {
            Point pos, tangent;
            double angleInRadians;
            double angleInDegrees;
            TransformGroup tg;
            Pen pen = new Pen(Stroke, StrokeThickness);
            //dc.DrawGeometry(null, pen, LinePath);
            if (BeginCap != null)
            {

                LinePath.GetPointAtFractionLength(0.01d, out pos, out tangent);
                angleInRadians = Math.Atan2(tangent.Y, tangent.X) + Math.PI;
                angleInDegrees = angleInRadians * 180 / Math.PI + 180;
                tg = new TransformGroup();
                tg.Children.Add(new RotateTransform(angleInDegrees));
                LinePath.GetPointAtFractionLength(0.0d, out pos, out tangent);
                tg.Children.Add(new TranslateTransform(pos.X, pos.Y));
                dc.PushTransform(tg);
                dc.DrawGeometry(Brushes.DeepPink, pen, BeginCap);
                dc.Pop();
            }
            if (EndCap != null)
            {
                LinePath.GetPointAtFractionLength(0.99, out pos, out tangent);
                angleInRadians = Math.Atan2(tangent.Y, tangent.X) + Math.PI;
                angleInDegrees = angleInRadians * 180 / Math.PI;
                tg = new TransformGroup();
                tg.Children.Add(new RotateTransform(angleInDegrees));
                LinePath.GetPointAtFractionLength(1, out pos, out tangent);
                tg.Children.Add(new TranslateTransform(pos.X, pos.Y));
                dc.PushTransform(tg);
                dc.DrawGeometry(Brushes.DeepPink, pen, EndCap);
            }
        }
コード例 #6
0
ファイル: TaskPriorityAdorner.cs プロジェクト: ArildF/PTB
        private void RenderImportanceArrow(DrawingContext dc, FrameworkElement mostImportant, FrameworkElement leastImportant)
        {
            var startPoint = FindPoint(mostImportant, new Point(mostImportant.ActualWidth/2, mostImportant.ActualHeight));
            var endPoint = FindPoint(leastImportant, new Point(leastImportant.ActualWidth/2, 0));

            var vector = Point.Subtract(endPoint, startPoint);

            var midPoint = Point.Add(startPoint, Vector.Multiply(vector, 0.66));

            Transform arrowTransform = Transform.Identity;
            double angle;
            if (Math.Abs((angle = Vector.AngleBetween(vector, new Vector(0, -1))) - 0) > double.Epsilon)
            {
                arrowTransform = new RotateTransform(angle, midPoint.X, midPoint.Y);
            }

            var line = BuildPath.From(startPoint).LineTo(endPoint.X, endPoint.Y).Build();
            var arrow = BuildPath.From(midPoint.X - 3, midPoint.Y - 3).LineTo(midPoint.X, midPoint.Y)
                .LineTo(midPoint.X + 3, midPoint.Y - 3).Build();

            dc.DrawGeometry(null, _pen, line);

            dc.PushTransform(arrowTransform);

            dc.DrawGeometry(null, _pen, arrow);

            dc.Pop();
        }
コード例 #7
0
ファイル: SortAdorner.cs プロジェクト: Altaxo/Altaxo
		protected override void OnRender(DrawingContext drawingContext)
		{
			base.OnRender(drawingContext);

			if (AdornedElement.RenderSize.Width < 20)
				return;

			drawingContext.PushTransform(
					 new TranslateTransform(
						 AdornedElement.RenderSize.Width - 15,
						(AdornedElement.RenderSize.Height - 5) / 2));

			if (IsSecondaryAdorner)
			{
				drawingContext.DrawGeometry(null, new Pen(Brushes.Black, 0.5),
						Direction == ListSortDirection.Ascending ?
							_AscGeometry : _DescGeometry);
			}
			else
			{
				drawingContext.DrawGeometry(Brushes.Black, null,
						Direction == ListSortDirection.Ascending ?
							_AscGeometry : _DescGeometry);
			}

			drawingContext.Pop();
		}
コード例 #8
0
ファイル: SelectionLayer.cs プロジェクト: kjk/kjkpub
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
            geoBuilder.CornerRadius = textArea.SelectionCornerRadius;
            foreach (var segment in textArea.Selection.Segments) {
                geoBuilder.AddSegment(textView, segment);
            }
            Geometry geometry = geoBuilder.CreateGeometry();
            if (geometry != null)
            {
                if (textArea.Selection.IsFindOnPageSelection())
                {
                    drawingContext.DrawGeometry(textArea.FindOnPageBrush, textArea.FindOnPageBorder, geometry);
                    textView.findOnPageSelectionGeometry = geometry;
                }
                else
                {
                    drawingContext.DrawGeometry(textArea.SelectionBrush, textArea.SelectionBorder, geometry);
                    textView.findOnPageSelectionGeometry = null;
                }
            }
            else
            {
                textView.findOnPageSelectionGeometry = null;
            }
        }
コード例 #9
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci);

            for (int i = 1; i <= m_nThickness; ++i)
            {
                SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline);

                Pen pen = new Pen(solidbrush, i);
                pen.LineJoin = PenLineJoin.Round;
                if (m_bClrText)
                {
                    SolidColorBrush brush = new SolidColorBrush(m_clrText);
                    graphics.DrawGeometry(brush, pen, path);
                }
                else
                {
                    graphics.DrawGeometry(m_brushText, pen, path);
                }
            }

            return(true);
        }
コード例 #10
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci);

            if (m_bClrText)
            {
                SolidColorBrush brush = new SolidColorBrush(m_clrText);
                Pen             pen   = new Pen(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), 1.0);
                graphics.DrawGeometry(brush, pen, path);
            }
            else
            {
                Pen pen = new Pen(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), 1.0);
                graphics.DrawGeometry(m_brushText, pen, path);
            }
            return(true);
        }
コード例 #11
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            drawingContext.DrawGeometry(null, new Pen(Stroke, StrokeThickness), GetArcGeometry());

            for (int i = Convert.ToInt32(StartPoint); i < Convert.ToInt32(EndPoint) + 1; i++)
            {
                if (Convert.ToInt32(EndPoint) < 1)
                {
                    return;
                }
                drawingContext.DrawGeometry(null, new Pen(Fill, StrokeThickness), GetArcBarsGeometry(i * 12));
            }
        }
コード例 #12
0
ファイル: LineChartPanel.cs プロジェクト: eslahi/prism
 protected override void OnRender(DrawingContext dc)
 {
     base.OnRender(dc);
     if (_childrenPositions.Count == 0)
         return;
     if (!IsSmoothOutline)
     {
         dc.DrawGeometry(AreaBrush, LinePen, CreateLineCurveGeometry());
     }
     else
     {
         dc.DrawGeometry(AreaBrush, LinePen, CreateAreaCurveGeometry());
     }
 }
コード例 #13
0
		protected override void OnRender(DrawingContext drawingContext)
		{
			Size renderSize = this.RenderSize;
			TextView textView = this.TextView;
			
			if (textView != null && textView.VisualLinesValid) {
				foreach (VisualLine line in textView.VisualLines) {
					Rect rect = new Rect(0, line.VisualTop - textView.ScrollOffset.Y, 5, line.Height);
					
					LineChangeInfo info = changeWatcher.GetChange(line.FirstDocumentLine.LineNumber);
					
					switch (info.Change) {
						case ChangeType.None:
							break;
						case ChangeType.Added:
							drawingContext.DrawRectangle(Brushes.LightGreen, null, rect);
							break;
						case ChangeType.Modified:
							drawingContext.DrawRectangle(Brushes.LightBlue, null, rect);
							break;
						case ChangeType.Unsaved:
							drawingContext.DrawRectangle(Brushes.Yellow, null, rect);
							break;
						default:
							throw new Exception("Invalid value for ChangeType");
					}
					
					if (!string.IsNullOrEmpty(info.DeletedLinesAfterThisLine)) {
						Point pt1 = new Point(5,  line.VisualTop + line.Height - textView.ScrollOffset.Y - 4);
						Point pt2 = new Point(10, line.VisualTop + line.Height - textView.ScrollOffset.Y);
						Point pt3 = new Point(5,  line.VisualTop + line.Height - textView.ScrollOffset.Y + 4);
						
						drawingContext.DrawGeometry(Brushes.Red, null, new PathGeometry(new List<PathFigure>() { CreateNAngle(pt1, pt2, pt3) }));
					}
					
					// special case for line 0
					if (line.FirstDocumentLine.LineNumber == 1) {
						info = changeWatcher.GetChange(0);
						
						if (!string.IsNullOrEmpty(info.DeletedLinesAfterThisLine)) {
							Point pt1 = new Point(5,  line.VisualTop - textView.ScrollOffset.Y - 4);
							Point pt2 = new Point(10, line.VisualTop - textView.ScrollOffset.Y);
							Point pt3 = new Point(5,  line.VisualTop - textView.ScrollOffset.Y + 4);
							
							drawingContext.DrawGeometry(Brushes.Red, null, new PathGeometry(new List<PathFigure>() { CreateNAngle(pt1, pt2, pt3) }));
						}
					}
				}
			}
		}
コード例 #14
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            int nOffset = Math.Abs(m_nOffsetX);

            if (Math.Abs(m_nOffsetX) == Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }
            else if (Math.Abs(m_nOffsetX) > Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetY);
            }
            else if (Math.Abs(m_nOffsetX) < Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }

            for (int i = 0; i < nOffset; ++i)
            {
                Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize,
                                                           new Point(ptDraw.X + ((i * (-m_nOffsetX)) / nOffset), ptDraw.Y + ((i * (-m_nOffsetY)) / nOffset)), ci);

                SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline);

                Pen pen = new Pen(solidbrush, m_nThickness);
                pen.LineJoin = PenLineJoin.Round;

                if (m_bClrText)
                {
                    SolidColorBrush brush = new SolidColorBrush(m_clrText);
                    graphics.DrawGeometry(brush, pen, path);
                }
                else
                {
                    graphics.DrawGeometry(m_brushText, pen, path);
                }
            }

            return(true);
        }
コード例 #15
0
        public void Render(DrawingContext context, IElement element)
        {
            var pathElement = element as CurvedPathElement;

            if (pathElement != null)
            {
                var pen = new Pen(new SolidColorBrush(pathElement.LineColor), pathElement.LineWidth);
                var brush = new SolidColorBrush(pathElement.FillColor);
                var topCurveRadius = pathElement.Radius +(pathElement.PathWidth/2);
                var bottomCurveRadius = pathElement.Radius -(pathElement.PathWidth/2);
                var geometry = new StreamGeometry();
                using (var gc = geometry.Open())
                {

                    gc.BeginFigure(pathElement.BottomLeft, false, true);
                    gc.LineTo(pathElement.TopLeft, true, true);
                    gc.ArcTo(pathElement.TopRight,
                             new Size(topCurveRadius, topCurveRadius),
                             1, false, SweepDirection.Clockwise, true, true);
                    gc.LineTo(pathElement.BottomRight, true, true);
                    gc.ArcTo(pathElement.BottomLeft,
                             new Size(bottomCurveRadius, bottomCurveRadius),
                             1, false, SweepDirection.Counterclockwise, true, true);
                }
                context.DrawGeometry(brush, pen, geometry);
                //var topPen = new Pen(Brushes.Red, 1);
                //var bottomPen = new Pen(Brushes.Blue, 1);
                //context.DrawEllipse(brush, topPen, pathElement.Origin, topCurveRadius, topCurveRadius);
                //context.DrawEllipse(brush, bottomPen, pathElement.Origin, bottomCurveRadius, bottomCurveRadius);

                //context.DrawEllipse(brush, pen, pathElement.Origin, pathElement.Radius, pathElement.Radius);
            }
        }
コード例 #16
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            PushButton pushButton = Visual as PushButton;
            if (pushButton.Pushed && _pushedImage != null)
            {
                drawingContext.DrawImage(_pushedImage, _imageRect);
            }
            else if (_image != null)
            {
                drawingContext.DrawImage(_image, _imageRect);
            }

            if (pushButton.Pushed)
            {
                drawingContext.PushTransform(new TranslateTransform(pushButton.TextPushOffset.X, pushButton.TextPushOffset.Y));
            }

            if (pushButton.Glyph != PushButtonGlyph.None)
            {
                drawingContext.DrawGeometry(_glyphBrush, _glyphPen, _glyphPath);
            }
            pushButton.TextFormat.RenderText(drawingContext, _textBrush, pushButton.Text, _imageRect);

            if (pushButton.Pushed)
            {
                drawingContext.Pop();
            }
        }
コード例 #17
0
        public static Sm.DrawingVisual ToVisualDrawing(this Shape input)
        {
            Sm.DrawingVisual  drawingVisual  = new Sm.DrawingVisual();
            Sm.DrawingContext drawingContext = drawingVisual.RenderOpen();
            Sm.GeometryGroup  drawing        = new Sm.GeometryGroup();

            if (input.IsCompound)
            {
                foreach (Geometry geo in input.Geometries)
                {
                    Sm.Geometry geometry = geo.ToGeometry();
                    drawing.Children.Add(geometry);
                }
            }
            else
            {
                Sm.Geometry geometry = input.ToGeometry();
                drawing.Children.Add(geometry);
            }

            drawingContext.DrawGeometry(input.Graphic.Fill.ToMediaBrush(), input.Graphic.Stroke.ToMediaPen(), drawing);
            drawingContext.Close();

            if (input.Graphic.Effects.HasBlurEffect)
            {
                drawingVisual.Effect = input.Graphic.Effects.Blur.ToMediaEffect();
            }
            if (input.Graphic.Effects.HasShadowEffect)
            {
                drawingVisual.Effect = input.Graphic.Effects.Shadow.ToMediaEffect();
            }

            return(drawingVisual);
        }
コード例 #18
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (this.adornedBuilding.ShowSpawnShieldLayer)
            {
                Rect adornedBuildingRect = new Rect(this.AdornedElement.RenderSize);

                double gridCellSize = (adornedBuildingRect.Width / (double)this.adornedBuilding.GridWidth);

                Rect spawnShieldRect = new Rect(
                    adornedBuildingRect.X - gridCellSize,
                    adornedBuildingRect.Y - gridCellSize,
                    adornedBuildingRect.Width + (2 * gridCellSize),
                    adornedBuildingRect.Height + (2 * gridCellSize));

                Geometry spawnShieldGeometry = Geometry.Combine(
                    new RectangleGeometry(spawnShieldRect),
                    new RectangleGeometry(adornedBuildingRect),
                    GeometryCombineMode.Exclude,
                    null);

                drawingContext.DrawGeometry(
                    this.spawnShieldBrush,
                    null,
                    spawnShieldGeometry);
            }

            base.OnRender(drawingContext);
        }
コード例 #19
0
        protected override void DrawCore(System.Windows.Media.DrawingContext context, DrawingAttributes overrides)
        {
            SolidColorBrush strokeBrush = new SolidColorBrush(overrides.Color);

            // If strokeMode it set to Solid, draw the strokes regularly.
            // Otherwise, draw the stylus points.
            if (strokeMode == DrawingMode.Solid)
            {
                Geometry geometry = GetGeometry(overrides);
                context.DrawGeometry(strokeBrush, null, geometry);
            }
            else // strokeMode == DrawingMode.StylusPoints
            {
                StylusPointCollection points;

                // Get the stylus points used to draw the stroke.  The points used depends on
                // the value of FitToCurve.
                if (this.DrawingAttributes.FitToCurve)
                {
                    points = this.GetBezierStylusPoints();
                }
                else
                {
                    points = this.StylusPoints;
                }

                // Draw a circle at each stylus point.
                foreach (StylusPoint p in points)
                {
                    context.DrawEllipse(null, new Pen(strokeBrush, 1), (Point)p, 5, 5);
                }
            }
        }
コード例 #20
0
ファイル: RectBorder.cs プロジェクト: targeton/WPF
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);

            Pen pen     = new Pen(this.RectCornerBrush, RectCornerThickness);
            var figures = new List <PathFigure>()
            {
                new PathFigure(new Point(0.0, RectCornerLength), new List <LineSegment>()
                {
                    new LineSegment(new Point(0.0, 0.0), true),
                    new LineSegment(new Point(RectCornerLength, 0.0), true)
                }, false),
                new PathFigure(new Point(ActualWidth - RectCornerLength, 0.0), new List <LineSegment>()
                {
                    new LineSegment(new Point(ActualWidth, 0.0), true),
                    new LineSegment(new Point(ActualWidth, RectCornerLength), true)
                }, false),
                new PathFigure(new Point(ActualWidth, ActualHeight - RectCornerLength), new List <LineSegment>()
                {
                    new LineSegment(new Point(ActualWidth, ActualHeight), true),
                    new LineSegment(new Point(ActualWidth - RectCornerLength, ActualHeight), true)
                }, false),
                new PathFigure(new Point(RectCornerLength, ActualHeight), new List <LineSegment>()
                {
                    new LineSegment(new Point(0.0, ActualHeight), true),
                    new LineSegment(new Point(0.0, ActualHeight - RectCornerLength), true)
                }, false)
            };
            PathGeometry geometry = new PathGeometry(figures);

            dc.DrawGeometry(Brushes.Transparent, pen, geometry);
        }
コード例 #21
0
		public void Draw(TextView textView, DrawingContext drawingContext)
		{
			if (textView == null)
				throw new ArgumentNullException("textView");
			if (drawingContext == null)
				throw new ArgumentNullException("drawingContext");
			
			if (currentResults == null || !textView.VisualLinesValid)
				return;
			
			var visualLines = textView.VisualLines;
			if (visualLines.Count == 0)
				return;
			
			int viewStart = visualLines.First().FirstDocumentLine.Offset;
			int viewEnd = visualLines.Last().LastDocumentLine.EndOffset;
			
			foreach (SearchResult result in currentResults.FindOverlappingSegments(viewStart, viewEnd - viewStart)) {
				BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
				geoBuilder.AlignToMiddleOfPixels = true;
				geoBuilder.CornerRadius = 3;
				geoBuilder.AddSegment(textView, result);
				Geometry geometry = geoBuilder.CreateGeometry();
				if (geometry != null) {
					drawingContext.DrawGeometry(markerBrush, markerPen, geometry);
				}
			}
		}
コード例 #22
0
ファイル: SubtasksAdorner.cs プロジェクト: ArildF/PTB
        protected override void DoRender(DrawingContext dc)
        {
            foreach (var tuple in FindSuperTasks())
            {
                FrameworkElement parentTaskElement = tuple.Item1;
                var startPoint = FindPoint(parentTaskElement, new Point(0, parentTaskElement.ActualHeight/2));

                startPoint.Offset(0, tuple.Item2.IndentLevel * 3);

                var endpoints = (from vm in tuple.Item2.ChildVMs()
                                 let element = FindElement(vm)
                                 let border = FindBorder(element)
                                 select FindPoint(border, new Point(0, border.ActualHeight/2))).OrderBy(pt => pt.Y).ToArray();

                var leftMost = endpoints.Concat(new[]{startPoint}).Min(point => point.X);
                var bottomMost = endpoints.Last();

                var builder = BuildPath.From(startPoint)
                    .LineTo(leftMost - 3, startPoint.Y)
                    .CurveTo(leftMost - 8, startPoint.Y + 5, SweepDirection.Counterclockwise)
                    .LineTo(leftMost - 8, bottomMost.Y - 5)
                    .CurveTo(leftMost - 3, bottomMost.Y, SweepDirection.Counterclockwise)
                    .LineTo(bottomMost.X, bottomMost.Y);

                foreach (var endpoint in endpoints.Take(endpoints.Count() - 1))
                {
                    builder.NewFigureFrom(leftMost - 8, endpoint.Y).LineTo(endpoint.X, endpoint.Y);
                }

                var path = builder.Build();

                dc.DrawGeometry(null, _pen, path);
            }
        }
コード例 #23
0
ファイル: SortAdorner.cs プロジェクト: RomanHodulak/WPFClient
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (AdornedElement.RenderSize.Width < 20)
                return;

            TranslateTransform transform = new TranslateTransform
                    (
                            AdornedElement.RenderSize.Width - 15,
                            (AdornedElement.RenderSize.Height - 5) / 2
                    );
            transform = new TranslateTransform
                    (
                            AdornedElement.RenderSize.Width / 2 - 3.5,
                            AdornedElement.RenderSize.Height / 2 - 10
                    );
            drawingContext.PushTransform(transform);

            Geometry geometry = ascGeometry;
            if (this.Direction == ListSortDirection.Descending)
                geometry = descGeometry;
            drawingContext.DrawGeometry(Brushes.LightGray, null, geometry);

            drawingContext.Pop();
        }
コード例 #24
0
        /// <summary>
        /// Participates in rendering operations.
        /// </summary>
        /// <param name="drawingContext">The drawing instructions for a specific element. This context is provided to the layout system.</param>
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            // Border
            Rect r = new Rect(0, 0, ColumnCount * CellLength, RowCount * CellLength);

            drawingContext.DrawRectangle(LightFill, _darkPen, r);

            StreamGeometry darkGeometry = new StreamGeometry();

            // StreamGeometry lightGeometry = new StreamGeometry();
            using (StreamGeometryContext darkContext = darkGeometry.Open())
            {
                // using (StreamGeometryContext lightContext = lightGeometry.Open())
                for (int i = 0; i < ColumnCount; i++)
                {
                    for (int j = 0; j < RowCount; j++)
                    {
                        if (((i % 2 == 0) && (j % 2 == 0)) ||
                            ((i % 2 == 1) && (j % 2 == 1)))
                        {
                            CreateFigure(i * CellLength, j * CellLength, darkContext);
                        }
                        //else
                        //{
                        //    CreateFigure(i * CellLength, j * CellLength, lightContext);
                        //}
                    }
                }
            }
            darkGeometry.Freeze();
            drawingContext.DrawGeometry(DarkFill, null, darkGeometry);
        }
コード例 #25
0
ファイル: Content.cs プロジェクト: HammerZhao/Chart
 public void Render(DrawingContext dc)
 {
     if (_datasource != null && _datasource.Count > 0)
     {
         dc.DrawGeometry(null, new Pen(Brushes.White, 2), _geo);
     }
 }
コード例 #26
0
		public void Draw(TextView textView, DrawingContext drawingContext)
		{
			if (textView == null)
			{
				throw new ArgumentNullException("textView");
			}
			if (drawingContext == null)
			{
				throw new ArgumentNullException("drawingContext");
			}
			if (this.currentResults == null || !textView.VisualLinesValid)
			{
				return;
			}
			ReadOnlyCollection<VisualLine> visualLines = textView.VisualLines;
			if (visualLines.Count == 0)
			{
				return;
			}
			int offset = visualLines.First<VisualLine>().FirstDocumentLine.Offset;
			int endOffset = visualLines.Last<VisualLine>().LastDocumentLine.EndOffset;
			foreach (var current in this.currentResults.FindOverlappingSegments(offset, endOffset - offset))
			{
				BackgroundGeometryBuilder backgroundGeometryBuilder = new BackgroundGeometryBuilder();
				backgroundGeometryBuilder.AlignToMiddleOfPixels = true;
				backgroundGeometryBuilder.CornerRadius = 3.0;
				backgroundGeometryBuilder.AddSegment(textView, current);
				Geometry geometry = backgroundGeometryBuilder.CreateGeometry();
				if (geometry != null)
				{
					drawingContext.DrawGeometry(this.markerBrush, this.markerPen, geometry);
				}
			}
		}
コード例 #27
0
 public void Draw(TextView textview, DrawingContext drawingContext)
 {
     if (_result != null)
     {
         var backgroundGeometryBuilder = new BackgroundGeometryBuilder
         {
             CornerRadius = 1.0,
             AlignToMiddleOfPixels = true
         };
         backgroundGeometryBuilder.AddSegment(textview, new TextSegment
         {
             StartOffset = _result.OpeningBracketOffset,
             Length = _result.OpeningBracketLength
         });
         backgroundGeometryBuilder.CloseFigure();
         backgroundGeometryBuilder.AddSegment(textview, new TextSegment
         {
             StartOffset = _result.ClosingBracketOffset,
             Length = _result.ClosingBracketLength
         });
         var geometry = backgroundGeometryBuilder.CreateGeometry();
         if (_borderPen == null)
         {
             UpdateColors(DefaultBackground, DefaultBackground);
         }
         if (geometry != null)
         {
             drawingContext.DrawGeometry(_backgroundBrush, _borderPen, geometry);
         }
     }
 }
コード例 #28
0
 public void Draw(TextView textView, DrawingContext drawingContext)
 {
     foreach (TextSegment current in this.SearchHitsSegments)
     {
         foreach (Rect current2 in BackgroundGeometryBuilder.GetRectsForSegment(textView, current))
         {
             Point bottomLeft = current2.BottomLeft;
             Point bottomRight = current2.BottomRight;
             Pen pen = new Pen(new SolidColorBrush(Colors.OrangeRed), 1);
             pen.Freeze();
             double num = 2.5;
             int count = System.Math.Max((int)((bottomRight.X - bottomLeft.X) / num) + 1, 4);
             StreamGeometry streamGeometry = new StreamGeometry();
             using (StreamGeometryContext streamGeometryContext = streamGeometry.Open())
             {
                 streamGeometryContext.BeginFigure(bottomLeft, true, true);
                 streamGeometryContext.LineTo(current2.TopLeft, true, false);
                 streamGeometryContext.LineTo(current2.TopRight, true, false);
                 streamGeometryContext.LineTo(current2.BottomRight, true, false);
             }
             streamGeometry.Freeze();
             drawingContext.DrawGeometry(Brushes.Transparent, pen, streamGeometry);
         }
     }
 }
コード例 #29
0
        private void RenderPolygon(DrawingContext drawingContext)
        {
            var fillBrush = Brushes.LawnGreen;
            var borderPen = new Pen(Brushes.Black,1.0);

            PathFigure myPathFigure = new PathFigure();
            myPathFigure.StartPoint = maxPoints[0];

            //PolyLineSegment seg = new PolyLineSegment(

            PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();

            for (int i = 1; i < maxPoints.Count; i++)
            {
                myPathSegmentCollection.Add(new LineSegment(maxPoints[i], true));
            }
            for (int i = minPoints.Count - 1; i >= 0; i--)
            {
                myPathSegmentCollection.Add(new LineSegment(minPoints[i], true));
            }

            myPathFigure.Segments = myPathSegmentCollection;
            PathGeometry myPathGeometry = new PathGeometry();
            
            myPathGeometry.Figures.Add(myPathFigure);

            drawingContext.DrawGeometry(fillBrush, borderPen, myPathGeometry);
        }
コード例 #30
0
        /*  将相邻两点连线
        protected override void OnRender(DrawingContext dc)
        {
            if (InternalChildren.Count < 2)
            {
                base.OnRender(dc);
                return;
            }

            Point? StartPoint = null;
            Point? EndPoint = null;

            for (int index = 0; index < InternalChildren.Count; index++)
            {
                UIElement CurChhild = this.Children[index];
                Vector CurV = VisualTreeHelper.GetOffset(CurChhild);

                if (index == 0)
                    StartPoint = new Point(CurV.X + CurChhild.RenderSize.Width / 2, CurV.Y + CurChhild.RenderSize.Height / 2);
                else
                    EndPoint = new Point(CurV.X + CurChhild.RenderSize.Width / 2, CurV.Y + CurChhild.RenderSize.Height / 2);

                if (StartPoint != null && EndPoint != null)
                {
                    dc.DrawLine(new Pen(LineBrush, 1.0), StartPoint.Value, EndPoint.Value);
                    StartPoint = EndPoint;
                }
            } 
        }
        */

        // 由LineSegment连接相邻两点并最终构成Path
        protected override void OnRender(DrawingContext dc)
        {
            if (InternalChildren.Count < 2)
            {
                base.OnRender(dc);
                return;
            }

            PathSegmentCollection segmentCollection = new PathSegmentCollection();
            PathFigure pathFigure = new PathFigure() { Segments = segmentCollection }; 

            for (int index = 0; index < InternalChildren.Count; index++)
            {
                UIElement CurChhild = this.Children[index];
                Vector CurV = VisualTreeHelper.GetOffset(CurChhild);

                if (index == 0)
                    pathFigure.StartPoint = new Point(CurV.X + CurChhild.RenderSize.Width / 2, CurV.Y + CurChhild.RenderSize.Height / 2);
                else
                    segmentCollection.Add(new LineSegment() { Point = new Point(CurV.X + CurChhild.RenderSize.Width / 2, CurV.Y + CurChhild.RenderSize.Height / 2) });
            }
 
            PathGeometry pathGeometry = new PathGeometry() { Figures = new PathFigureCollection() { pathFigure } };
            dc.DrawGeometry(Brushes.Transparent, new Pen(LineBrush, 1.0), pathGeometry);
        }
コード例 #31
0
        //public bool SoftwareRendering {
        //    get { return ((System.Windows.Interop.RenderMode)GetValue(RenderOptions.ProcessRenderMode)) == System.Windows.Interop.RenderMode.SoftwareOnly; }
        //    set { SetValue(RenderOptions.ProcessRenderMode, value ? System.Windows.Interop.RenderMode.SoftwareOnly : System.Windows.Interop.RenderMode.Default); }
        //}

        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            SineRenderMode renderMode = SineRenderMode;

            drawingContext.DrawText(
                new FormattedText(
                    "ViewportHOffset: " + ViewportHorizontalOffset + " ViewportWidth: " + ViewportWidth + ", RenderMode: " + renderMode,
                    CultureInfo.CurrentUICulture,
                    System.Windows.FlowDirection.LeftToRight,
                    new Typeface("Tahoma"),
                    8,
                    Brushes.Black),
                new Point(ViewportHorizontalOffset, ActualHeight) + new Vector(0, -10));

            // generate samples
            double        scale   = 0.1;
            List <double> samples = new List <double>();

            for (double x = ViewportHorizontalOffset; x < ViewportHorizontalOffset + ViewportWidth; x++)
            {
                samples.Add(Math.Sin(x * scale));
            }
            Debug.WriteLine("Samples: " + samples.Count);

            if (!samples.Any())
            {
                return;
            }

            switch (renderMode)
            {
            case SineRenderMode.DirectTransformless:
                drawingContext.DrawGeometry(null, new Pen(Brushes.BlueViolet, 1), CreateGeometryTransformless(samples));
                break;

            case SineRenderMode.Direct:
                drawingContext.DrawGeometry(null, new Pen(Brushes.BlueViolet, 1), CreateGeometry(samples));
                break;

            case SineRenderMode.BitmapTransformless:
                BitmapSource bmp  = RenderBitmapTransformless(samples);
                Rect         rect = new Rect(ViewportHorizontalOffset, 0, bmp.PixelWidth, bmp.PixelHeight);
                drawingContext.DrawImage(bmp, rect);
                break;
            }
        }
コード例 #32
0
		protected override void OnRender(DrawingContext drawingContext)
		{
			base.OnRender(drawingContext);
			if ((base.Visibility == Visibility.Visible) && (_highlightGeometry != null))
			{
				drawingContext.DrawGeometry(_useBlinkBrush ? _blinkBrush : _baseBrush, null, _highlightGeometry);
			}
		}
コード例 #33
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (this.textBoxHasSelection)
            {
                // up button
                drawingContext.PushTransform(new TranslateTransform(this.x, this.top));
                drawingContext.PushTransform(new ScaleTransform(1, -1));
                drawingContext.DrawGeometry(TextBoxUpDownAdorner.Fill, TextBoxUpDownAdorner.Outline, this.triangle);
                drawingContext.Pop();
                drawingContext.Pop();

                // down button
                drawingContext.PushTransform(new TranslateTransform(this.x, this.bottom));
                drawingContext.DrawGeometry(TextBoxUpDownAdorner.Fill, TextBoxUpDownAdorner.Outline, this.triangle);
                drawingContext.Pop();
            }
        }
コード例 #34
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            double penThickness = Math.Min(ActualHeight, ActualWidth) * (1 - InnerRadiusPortion) / 2;
            var rect = new Rect(new Point(penThickness / 2, penThickness / 2), new Size(ActualWidth - penThickness, ActualHeight - penThickness));
            GeometryDrawing arc = CreateArcDrawing(rect, 360.0 * StartPortion - 90, 359.99 * SegmentPortion);

            drawingContext.DrawGeometry(Background, new Pen(Background, penThickness), arc.Geometry);
        }
コード例 #35
0
ファイル: DarkLayer.xaml.cs プロジェクト: Deiwos3/IMS
 protected override void OnRender(DrawingContext drawingContext)
 {
     if (this.Clip != null)
     {
         drawingContext.DrawGeometry(new SolidColorBrush(Color.FromArgb(90,0,0,0)), new Pen(this.BorderBrush, 1), this.Clip);
     }
     base.OnRender(drawingContext);
 }
コード例 #36
0
        public void DrawLines(Point[] points, int start, int length, SolidColor color, double width, LineStyles style)
        {
            if (!color.IsTransparent && length > 1)
            {
                var p = this.resourceManager.GetPen(color, width, ToWPFDashStyle(style));

                if (p != null)
                {
                    var geo = new PathGeometry();
                    for (int i = 1, k = start + 1; i < length; i++, k++)
                    {
                        geo.AddGeometry(new LineGeometry(points[k - 1], points[k]));
                    }
                    g.DrawGeometry(null, p, geo);
                }
            }
        }
コード例 #37
0
		public void Render(DrawingContext drawingContext)
		{
			if (IsVisible)
			{
				drawingContext.PushClip(_clipGeometry);
				drawingContext.DrawGeometry(null, PainterCache.GridLinePen, _geometry);
				drawingContext.Pop();
			}
		}
コード例 #38
0
 private void Draw(DrawingContext dc)
 {
     StreamGeometry sg = new StreamGeometry();
     StreamGeometryContext sgc = sg.Open();
     sgc.BeginFigure(points[0], false, false);
     sgc.PolyLineTo(points, true, true);
     sgc.Close();
     dc.DrawGeometry(null, pen, sg);
 }
コード例 #39
0
ファイル: LineChartPanel.cs プロジェクト: eslahi/prism
        protected override void OnRender(DrawingContext dc)
        {
            if (dc == null)
            {
                throw new ArgumentNullException("dc");
            }

            base.OnRender(dc);
            if (_childrenPositions.Count == 0)
                return;
            if (!IsSmoothOutline)
            {
                dc.DrawGeometry(AreaBrush, LinePen, CreateLineCurveGeometry());
            }
            else
            {
                dc.DrawGeometry(AreaBrush, LinePen, CreateAreaCurveGeometry());
            }
        }
コード例 #40
0
    private void DrawTriangle(DrawingContext drawingContext, Point origin, double rotation)
    {
      drawingContext.PushTransform(new TranslateTransform(origin.X, origin.Y));
      drawingContext.PushTransform(new RotateTransform(rotation));

      drawingContext.DrawGeometry(m_Pen.Brush, null, m_Triangle);

      drawingContext.Pop();
      drawingContext.Pop();
    }
コード例 #41
0
ファイル: ErrorMarker.cs プロジェクト: osmedile/TypeCobol
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (markers == null || !textView.VisualLinesValid)
            {
                return;
            }
            var visualLines = textView.VisualLines;
            if (visualLines.Count == 0)
            {
                return;
            }
            int viewStart = visualLines.First().FirstDocumentLine.Offset;
            int viewEnd = visualLines.Last().LastDocumentLine.EndOffset;
            foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart))
            {
                if (marker.BackgroundColor != null)
                {
                    var geoBuilder = new BackgroundGeometryBuilder { AlignToWholePixels = true, CornerRadius = 3 };
                    geoBuilder.AddSegment(textView, marker);
                    Geometry geometry = geoBuilder.CreateGeometry();
                    if (geometry != null)
                    {
                        Color color = marker.BackgroundColor.Value;
                        var brush = new SolidColorBrush(color);
                        brush.Freeze();
                        drawingContext.DrawGeometry(brush, null, geometry);
                    }
                }
                foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker))
                {
                    Point startPoint = r.BottomLeft;
                    Point endPoint = r.BottomRight;

                    var usedPen = new Pen(new SolidColorBrush(marker.MarkerColor), 1);
                    usedPen.Freeze();
                    const double offset = 2.5;

                    int count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4);

                    var geometry = new StreamGeometry();

                    using (StreamGeometryContext ctx = geometry.Open())
                    {
                        ctx.BeginFigure(startPoint, false, false);
                        ctx.PolyLineTo(CreatePoints(startPoint, endPoint, offset, count).ToArray(), true, false);
                    }

                    geometry.Freeze();

                    drawingContext.DrawGeometry(Brushes.Transparent, usedPen, geometry);
                    break;
                }
            }
        }
コード例 #42
0
ファイル: AngleBorder.cs プロジェクト: thbin/TraceLab
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            var    childRect    = GetChildRect();
            double childMiddleY = childRect.Top + (childRect.Height / 2);
            double childMiddleX = childRect.Left + (childRect.Width / 2);

            var strokePen = new Pen(BorderBrush, BorderStrokeThickness);

            drawingContext.DrawGeometry(Background, strokePen, GetCombinedSides(childMiddleX, childMiddleY));
        }
コード例 #43
0
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     if (m_CurrentAOI != null)
     {
         Point             startPoint = PointToWindowCoordinates(m_CurrentAOI.StartPoint);
         Point             endPoint   = PointToWindowCoordinates(m_CurrentAOI.EndPoint);
         RectangleGeometry rectGeo    = new RectangleGeometry(new Rect(startPoint, endPoint), m_CurrentAOI.Marking.RadiusX, m_CurrentAOI.Marking.RadiusY);
         Brush             fill       = (Enabled) ? Brushes.Transparent : null;
         drawingContext.DrawGeometry(fill, m_CurrentAOI.Pen, rectGeo);
     }
     base.OnRender(drawingContext);
 }
コード例 #44
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            double x = AdornedElement.RenderSize.Width - 20;
            double y = (AdornedElement.RenderSize.Height - 5) / 2;

            if (x >= 20)
            {
                // Right order of the statements is important
                drawingContext.PushTransform(new TranslateTransform(x, y));
                drawingContext.DrawGeometry(Brushes.Black, null, _sortDirection);
                drawingContext.Pop();
            }
        }
コード例 #45
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci);

            List <Color> list = new List <Color>();

            CalculateGradient(
                m_clrOutline1,
                m_clrOutline2,
                m_nThickness,
                list);

            for (int i = m_nThickness; i >= 1; --i)
            {
                SolidColorBrush solidbrush = new SolidColorBrush(list[i - 1]);

                Pen pen1 = new Pen(solidbrush, i);
                pen1.LineJoin = PenLineJoin.Round;
                if (m_bClrText)
                {
                    SolidColorBrush brush = new SolidColorBrush(m_clrText);
                    graphics.DrawGeometry(brush, pen1, path);
                }
                else
                {
                    graphics.DrawGeometry(m_brushText, pen1, path);
                }
            }

            return(true);
        }
コード例 #46
0
ファイル: SortAdorner.cs プロジェクト: dfgs/ViewLib_old
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            double x = AdornedElement.RenderSize.Width - 12;
            double y = (AdornedElement.RenderSize.Height - 8) / 2;

            if (x >= 10)
            {
                // Right order of the statements is important
                drawingContext.PushTransform(new TranslateTransform(x, y));
                drawingContext.DrawGeometry(brush, pen, direction);
                drawingContext.Pop();
            }
        }
コード例 #47
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            Double          width       = this.ActualWidth;
            Double          height      = this.ActualHeight;
            Double          a           = width / 2;
            Double          b           = height / 2;
            Point           centerPoint = new Point(a, b);
            Double          thickness   = this.BorderThickness.Left;
            EllipseGeometry ellipse     = new EllipseGeometry(centerPoint, a, b);

            drawingContext.PushClip(ellipse);
            drawingContext.DrawGeometry(
                this.Background,
                new Pen(this.BorderBrush, thickness),
                ellipse);
        }
コード例 #48
0
        void RenderFPSLines(System.Windows.Media.DrawingContext drawingContext, List <EventFrame> frames, KeyValuePair <int, int> interval)
        {
            double scale = AdornedElement.RenderSize.Width / Range;

            if (scale < RenderFPSLineLimit)
            {
                return;
            }

            double height = Extent.Height;

            StreamGeometry geometry = new StreamGeometry();

            using (StreamGeometryContext geometryContext = geometry.Open())
            {
                for (int i = interval.Key; i <= interval.Value; ++i)
                {
                    EventFrame frame = frames[i];

                    double posX  = (frame.Header.StartMS - timeRange.StartMS - Position) * scale;
                    Point  point = new Point(posX, fpsTriangleSize);
                    geometryContext.BeginFigure(point, true, true);
                    geometryContext.LineTo(new Point(posX - fpsTriangleSize / 2, 0), false, false);
                    geometryContext.LineTo(new Point(posX + fpsTriangleSize / 2, 0), false, false);

                    drawingContext.DrawLine(fpsPen, new Point(posX, 0), new Point(posX, height - SpaceHeight));

                    double maxTextWidth = Math.Max(frame.Duration * scale - 8, 0.0);

                    if (MaxDrawTextThreshold > maxTextWidth && maxTextWidth > MinDrawTextThreshold)
                    {
                        FormattedText text = new FormattedText(String.Format("{0:0.###}ms", frame.Duration).Replace(',', '.'), culture, FlowDirection.LeftToRight, fontDuration, 12, fpsBrush);
                        text.MaxLineCount = 1;
                        text.MaxTextWidth = maxTextWidth;
                        text.Trimming     = TextTrimming.None;
                        drawingContext.DrawText(text, new Point(posX + maxTextWidth / 2 - text.Width / 2, -2));
                    }
                }
            }

            drawingContext.DrawGeometry(fpsBrush, null, geometry);
        }
コード例 #49
0
 protected override void DrawCore(System.Windows.Media.DrawingContext context, DrawingAttributes overrides)
 {
     // create a drop shadow
     //
     if (this.Shadowed)
     {
         Geometry pathGeometry = this.GetGeometry(overrides).Clone();
         pathGeometry.Transform = new TranslateTransform(5, 0);
         try
         {
             context.PushOpacity(0.5);
             context.DrawGeometry(Brushes.DarkGray, null, pathGeometry);
         }
         finally
         {
             context.Pop();
         }
     }
     base.DrawCore(context, overrides);
 }
コード例 #50
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            double R  = Math.Min(this.Width / 2, this.Height / 2);
            double r  = R / 2;
            double da = 2 * Math.PI / EdgeCount;
            var    f  = new PathFigure {
                StartPoint = new Point(Width / 2 + R, Height / 2)
            };
            double a = 0;

            for (int i = 0; i < EdgeCount; i++)
            {
                f.Segments.Add(new LineSegment(new Point(Width / 2 + r * Math.Cos(a + da / 2), Height / 2 + r * Math.Sin(a + da / 2)), true));
                f.Segments.Add(new LineSegment(new Point(Width / 2 + R * Math.Cos(a + da), Height / 2 + R * Math.Sin(a + da)), true));
                a += da;
            }
            drawingContext.DrawGeometry(Fill, new Pen(Stroke, 1), new PathGeometry {
                Figures = new PathFigureCollection {
                    f
                }
            });
        }
コード例 #51
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            Rect bounds = new Rect(0, 0, Width, Height);
            Pen  pen    = new Pen(Brushes.Green, 4);

            drawingContext.DrawRoundedRectangle(Brushes.Yellow, pen, bounds, 5, 5);


            string   ImagePawnString = ("M35.54,35.2H14.46A.64.64,0,0,1,14,35a.66.66,0,0,1-.13-.51,11.4,11.4,0,0,1,5.27-7.72,7.43,7.43,0,1,1,11.76,0,11.4,11.4,0,0,1,5.27,7.72A.66.66,0,0,1,36,35,.64.64,0,0,1,35.54,35.2ZM15.23,34H34.77a10.13,10.13,0,0,0-5.15-6.47A.62.62,0,0,1,29.3,27a.61.61,0,0,1,.16-.53,6.18,6.18,0,1,0-8.92,0,.61.61,0,0,1,.16.53.62.62,0,0,1-.32.46A10.13,10.13,0,0,0,15.23,34Z");
            Geometry ImagePawn       = Geometry.Parse(ImagePawnString);


            //Rect boundsGeometry = new Rect(100, 100, 80, 80);
            Pen penGeometry = new Pen(Brushes.Orange, 2);

            drawingContext.DrawGeometry(Brushes.Pink, pen, ImagePawn);



            this.Height = 100;
            this.Width  = 80;
        }
コード例 #52
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci);

            SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline);
            Pen             pen        = new Pen(solidbrush, m_nThickness);

            pen.LineJoin = PenLineJoin.Round;
            SolidColorBrush transbrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

            graphics.DrawGeometry(transbrush, pen, path);

            return(true);
        }
コード例 #53
0
        public static void UserDrawRasterWPFScreenCoordinate(System.Windows.Media.DrawingContext dc, System.Windows.Media.ImageSource ImageSource,
                                                             int PixelX, int PixelY, int Width, int Height, double angle = 0.0, System.Windows.Media.ImageBrush pImageBrush = null)
        {
            System.Windows.Size  sz       = new System.Windows.Size(Width, Height);
            System.Windows.Point pnt      = new System.Windows.Point(PixelX - sz.Width / 2, PixelY - sz.Height / 2);
            System.Windows.Rect  rectBack = new System.Windows.Rect(pnt, sz);
            //if (angle == 0.0)
            //{
            //    dc.DrawImage(ImageSource, rectBack);
            //}
            //else
            //{
            System.Windows.Media.RotateTransform rotRect = new System.Windows.Media.RotateTransform(angle, PixelX, PixelY);

            System.Windows.Media.RectangleGeometry RectGeo = new System.Windows.Media.RectangleGeometry(rectBack);
            RectGeo.Transform = rotRect;
            System.Windows.Media.ImageBrush imbrush = null;
            if (pImageBrush != null)
            {
                imbrush = pImageBrush;
            }
            else if (ImageSource != null)
            {
                imbrush = new System.Windows.Media.ImageBrush(ImageSource);
            }
            // imbrush.Viewport = imbrush.Viewport = new Rect(0, 0, 16, 16);
            //dc.DrawImage(_ImageSource, rectBack);

            if (imbrush != null)
            {
                imbrush.Transform = rotRect;
                dc.DrawGeometry(imbrush, null, RectGeo);
            }


            // }
        }
コード例 #54
0
ファイル: Timeline.cs プロジェクト: jokalee/Tuto
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            if (editorModel == null)
            {
                return;
            }


            foreach (var c in model.Chunks)
            {
                foreach (var r in GetRects(c))
                {
                    drawingContext.DrawRectangle(fills[(int)c.Mode], borderPen, r);
                    if (c.StartsNewEpisode)
                    {
                        var p = GetCoordinate(c.StartTime);
                        drawingContext.DrawLine(episode, p, new Point(p.X, p.Y + RowHeight));
                    }
                }
            }



            if (model.SoundIntervals != null)
            {
                var    points   = new List <Point>();
                double baseline = 0;
                foreach (var e in GetSoundPoints(model.SoundIntervals))
                {
                    var c = GetCoordinate(e.Item1);
                    if (points.Count == 0)
                    {
                        baseline = c.Y;
                    }
                    if (Math.Abs(c.Y - baseline) > 0.001)
                    {
                        FlushSoundLine(drawingContext, points, baseline);
                        points.Clear();
                        continue;
                    }
                    points.Add(new Point(c.X, c.Y + RowHeight - RowHeight * ((0.5 * e.Item2 / 100) + (e.Item3?0.2:0))));
                }
                if (points.Count != 0)
                {
                    FlushSoundLine(drawingContext, points, baseline);
                }
            }

            var            ps             = GetCoordinate(model.SynchronizationShift);
            StreamGeometry streamGeometry = new StreamGeometry();

            using (StreamGeometryContext geometryContext = streamGeometry.Open())
            {
                geometryContext.BeginFigure(new Point(ps.X - 5, ps.Y), true, true);
                geometryContext.LineTo(new Point(ps.X + 5, ps.Y), false, false);
                geometryContext.LineTo(new Point(ps.X, ps.Y + RowHeight / 2), false, false);
            }
            drawingContext.DrawGeometry(Brushes.Red, soundpen, streamGeometry);

            //if (editorModel.WindowState.CurrentMode == EditorModes.Border && model.Borders!=null)
            //	foreach (var e in model.Borders)
            //	{
            //		DrawLine(drawingContext, border, e.StartTime, e.EndTime, 3);
            //	}
        }
コード例 #55
0
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     drawingContext.DrawGeometry(null, new Pen(Stroke, StrokeThickness), GetArcGeometry());
 }
コード例 #56
0
        protected override void OnRender(
            System.Windows.Media.DrawingContext drawingContext)
        {
            if (drawingContext != null)
            {
                //Only use either:
                // End coordinates
                //or
                // use start angle, end angle, radius

                //random range used in either case.

                // TODO: auto clear of contrary settings needed.

                if (radius == 0)
                {
                    //draw two half-circles, with a rectangle in the middle.

                    //drawingContext.DrawRectangle(null, new Pen(Brushes.AliceBlue, 1),
                    //        new Rect(new Point(0, 0), DesiredSize));

                    PathGeometry pathGeometry = new PathGeometry();

                    //TODO: Adjust angle based on destination.  below assumes 45 degree angle.

                    //End point will be at exactly 180 degrees from start point (.5 radians).
                    //point 0,0 == upper left corner of object?


                    double x1  = 0; //startX
                    double y1  = 0; //startY
                    double x2  = endX - startX;
                    double y2  = endY - startY;
                    double x1a = x1 + Math.Cos(0.5 * Math.PI + x2) * randomRange;

                    double x2a = x1a + x2;


                    double y1a = y1 + Math.Sin(0.5 * Math.PI + y2) * randomRange;
                    //double y1a = ??2 * randomRange;
                    double y2a = y1a + y2;


                    double x1b = -x1a;
                    double y1b = -y1a;

                    double x2b = -x2a;
                    double y2b = -y2a;



                    // Center point found--now adjust for range and angle.
                    //rectangle does not work--due to strange angles.
                    LineSegment ls = new LineSegment(new Point(x2a, y2a), true);

                    PathFigure figure = new PathFigure();
                    figure.StartPoint = new Point(x1a, y1a);

                    figure.Segments.Add(ls);
                    pathGeometry.Figures.Add(figure);


                    ls                = new LineSegment(new Point(x2b, y2b), true);
                    figure            = new PathFigure();
                    figure.StartPoint = new Point(x1b, y1b);
                    figure.Segments.Add(ls);
                    pathGeometry.Figures.Add(figure);

                    //figure.Segments.Add(
                    ArcSegment arc = new ArcSegment(new Point(x1b, y1b),
                                                    new Size(randomRange, randomRange),
                                                    Math.Acos(y1a / randomRange), false, SweepDirection.Clockwise, true);


                    figure = new PathFigure();

                    figure.StartPoint = new Point(x1a, y1a);
                    figure.Segments.Add(arc);
                    pathGeometry.Figures.Add(figure);

                    arc = new ArcSegment(new Point(x2b, y2b),
                                         new Size(randomRange, randomRange),
                                         Math.Acos(y1a / randomRange), false, SweepDirection.Counterclockwise, true);

                    figure = new PathFigure();

                    figure.StartPoint = new Point(x2a, y2a);
                    figure.Segments.Add(arc);


                    pathGeometry.Figures.Add(figure);


                    drawingContext.DrawGeometry(null, new Pen(Brushes.AliceBlue, 1), pathGeometry);
                }
                else
                {
                }

                base.OnRender(drawingContext);
            }
        }
コード例 #57
0
ファイル: ModelControl.cs プロジェクト: virovets64/Hadronium
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            if (model == null)
            {
                return;
            }

            renderStopwatch.Restart();
            Pen forwardPen  = new Pen(Brushes.Silver, 1);
            Pen backwardPen = new Pen(Brushes.Pink, 1);
            Pen fixedPen    = new Pen(Brushes.Black, 1);

            foreach (var link in model.Links)
            {
                drawingContext.DrawLine(link.A.Position[0] < link.B.Position[0] ? forwardPen : backwardPen,
                                        transform.ToScreen(link.A.Position),
                                        transform.ToScreen(link.B.Position));
            }
            foreach (var particle in model.Particles)
            {
                DrawData drawData = particle.Tag as DrawData;
                if (drawData == null)
                {
                    drawData = new DrawData();
                    if (particle.FillColor.A != 0)
                    {
                        drawData.Brush = new SolidColorBrush(particle.FillColor);
                    }
                    if (particle.StrokeColor.A != 0)
                    {
                        drawData.Pen = new Pen(new SolidColorBrush(particle.StrokeColor), 1);
                    }
                    drawData.Pinned = particle.Fixed;
                    if (particle.Name != null)
                    {
                        drawData.Text = new FormattedText(particle.Name, CultureInfo.CurrentCulture,
                                                          FlowDirection.LeftToRight, textTypeface, textSize, Brushes.Black);
                    }
                    particle.Tag = drawData;
                }

                Point p = transform.ToScreen(particle.Position);
                drawingContext.DrawEllipse(drawData.Brush, drawData.Pen,
                                           p,
                                           ParticleSize,
                                           ParticleSize);
                if (drawData.Selected)
                {
                    drawingContext.DrawEllipse(null, fixedPen,
                                               p,
                                               ParticleSize * 1.3,
                                               ParticleSize * 1.3);
                }


                if (drawData.Text != null)
                {
                    drawingContext.DrawText(drawData.Text, p);
                }
                if (drawData.Pinned)
                {
                    //                    drawingContext.DrawRectangle(Brushes.Black, fixedPen, new Rect(0, 0, 8, 8));
                    drawingContext.PushTransform(new TranslateTransform(p.X, p.Y));
                    drawingContext.PushTransform(new ScaleTransform(ParticleSize / 8, ParticleSize / 8));
                    drawingContext.DrawGeometry(Brushes.LightCoral, fixedPen, pinImage);
                    drawingContext.Pop();
                    drawingContext.Pop();
                }
            }

            RenderElapsedTime = renderStopwatch.Elapsed.TotalSeconds;
            renderStopwatch.Restart();
        }
コード例 #58
0
ファイル: CodeBox.cs プロジェクト: GregorJ101/Symulator3
        protected override void OnRender(System.Windows.Media.DrawingContext dcRendering)
        {
            if (m_bSuspendRendering)
            {
                return;
            }

            while (m_bPauseOutput)
            {
                Thread.Sleep(250);
            }

            if (this.Text.Length > 0)
            {
                int    iStartVisibleLine = -1;
                int    iEndVisibleLine   = -1;
                int    iOffset           = -1;
                int    iOffsetNext       = -1;
                string strLine           = "";

                EnsureScrolling();
                FormattedText ftDisplayedLines = new FormattedText(
                    this.Text,
                    CultureInfo.GetCultureInfo("en-us"),
                    FlowDirection.LeftToRight,
                    new Typeface(this.FontFamily.Source),
                    this.FontSize,
                    BaseForeground);  // Text that matches the textbox's
                double dLeftMargin  = 4.0 + this.BorderThickness.Left;
                double dTopMargin   = 2.0 + this.BorderThickness.Top;
                double dRightMargin = this.ActualWidth - 5.0;                                                                    // Fix to long lines writing over right edge when horizontal scrollbar is preset

                ftDisplayedLines.MaxTextHeight = Math.Max(this.ActualHeight + this.VerticalOffset, 0);                           // Adjust for scrolling
                dcRendering.PushClip(new RectangleGeometry(new Rect(dLeftMargin, dTopMargin, dRightMargin, this.ActualHeight))); // Restrict text to textbox

                #region Text Coloring and Shading
                ftDisplayedLines.SetForegroundBrush(m_brBlack);  // Default text color for any text not colored by offset / length

                if (m_eSyntaxColoringMode == SyntaxColoringMode.Dasm)
                #region DASM Output
                {
                    #region Comments
                    // Label:                0       Orange
                    // Instruction Address: 14       Red
                    // Mnemonic:            20       Blue
                    // Data Address:        43       Purple
                    // Annotation:          51       Date green
                    // Data1                26 / 25
                    // Data2                52
                    // Data3                62 / 4
                    // Data4                75
                    //           1         2         3         4         5         6         7         8         9         0         1
                    // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
                    // Loop_02_0A0F  0A0F: SIO   F3 10 28                 5475 Keyboard  Set Error Indicator  Restore Data Key
                    //               0A12: SNS   70 12 FF,1       0x0B0C  5475 Keyboard  2 sense bytes
                    //               0A20: data  F1 6B F1 F2  6B F1 F3 40  <.k.. k..@>  <1,12 ,13 >

                    // Background for breakpoints (R:253 G:207 B:207)                             #FDCFCF
                    // Background for disabled breakpoints (R:248 G:226 B:226)                    #F8E2E2
                    // Background for active bookmark (R:0 G:198 B:255)                           #00C6FF
                    // Background for disabled bookmark (R:0 G:239 B:255)                         #00EFFF
                    // Background for current active line (R:236 G:254 B:85)                      #ECFE55

                    // Mnemonics: blue (R:0 G:0 B:255)                                                            #0000FF
                    // Operand addresses & command codes: black (R:0 G:0 B:0)                                     #000000
                    // Instruction addresses & command codes: dark red (R:128 G:0 B:0)                            #800000
                    // Annotation: dark green (R:0 G:128 B:0) (same as comments in Visual Studio)                 #008000
                    // Register labels: purple (R:139 G:0 B:164)                                                  #8B00A4
                    // Register values: light purple (R:212 G:0 B:250)                                            #D400FA
                    // Changed register values: red (R:255 G:0 B:0)                                               #FF0000
                    // Operand labels: purple (R:139 G:0 B:164)                                                   #8B00A4
                    // Operand memory: magenta (R:255 G:0 B:255)                                                  #FF00FF
                    // Changed memory: red (R:255 G:0 B:0)                                                        #FF0000
                    // Reset condition register flags: gray (R:128 G:128 B:128)                                   #808080
                    #endregion
                    iStartVisibleLine = GetFirstVisibleLineIndex();
                    iEndVisibleLine   = GetLastVisibleLineIndex();

                    for (int iIdx = iStartVisibleLine; iIdx <= iEndVisibleLine; ++iIdx)
                    {
                        try
                        {
                            // Text coloring
                            try
                            {
                                iOffset     = GetCharacterIndexFromLineIndex(iIdx);
                                iOffsetNext = GetCharacterIndexFromLineIndex(iIdx + 1);
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                // Fail silently
                            }

                            strLine = Text.Substring(iOffset, iOffsetNext - iOffset);

                            if (strLine.Length >= 101 &&
                                IsHexColon(strLine.Substring(0, 5)) &&
                                strLine[58] == '<')
                            {
                                //          1         2         3         4         5         6         7         8         9         0         1         2
                                //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //0300: 7C 00 52 75  02 CE 71 F5  CE F3 F9 07  D1 F9 0C 6D  <|.Ru ..q. .... ...m>  <@... ...5 .39. J9._>
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset, 5);           // Data address
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 6, 50);     // Hex data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 58, 1);     // Lead Op1 angle bracket
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 59, 42);    // Op1 hex ascii data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 78, 4);     // Middle Op1 angle brackets
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 101, 1);    // Trail Op1 angle bracket
                            }
                            //else if (strLine.Length >= 75 &&
                            //         strLine.Substring (0, 4) == "XOXO")
                            //{
                            //    ftDisplayedLines.SetForegroundBrush (m_brPurple,    iOffset,      9);
                            //    ftDisplayedLines.SetForegroundBrush (m_brFuchsia,   iOffset + 18, 9);
                            //    ftDisplayedLines.SetForegroundBrush (m_brDkGreen,   iOffset + 45, 9);
                            //    ftDisplayedLines.SetForegroundBrush (m_brCoral,     iOffset + 63, 5);
                            //}
                            else if (strLine.Length >= 5 &&
                                     IsHexColon(strLine.Substring(14, 5)))
                            {
                                ftDisplayedLines.SetForegroundBrush(m_brBlack, iOffset, strLine.Length); // Background text
                                ftDisplayedLines.SetForegroundBrush(m_brRoyalBlue, iOffset, 12);         // Loop / Jump label
                                ftDisplayedLines.SetForegroundBrush(m_brCoral, iOffset + 14, 5);         // Hex address

                                string strTest1 = strLine.Substring(14, 5);                              // Hex/Colon test
                                string strTest2 = strLine.Substring(20, 4);                              // "data" label test
                                if (strTest2 == "data")
                                {
                                    //          1         2         3         4         5         6         7         8         9         0         1         2
                                    //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                    //              002E: data  7C 3C 40 40  40 40 40 40  <|<@@ @@@@>  <@.       >  <EF__ ____>  <H.'' ''''>
                                    //              001E: data  01 00 6F 03  76 57 1B 5D  <..o. vW.]>  <..?. ...)>  <..01 2345>  <.... ....>
                                    ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 26, 25);    // Hex data string
                                    ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 52, 1);     // Lead data angle bracket
                                    ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 53, 48);    // Hex, ascii, HPL & 5475 data values
                                    ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 62, 4);     // First pair angle brackets
                                    ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 75, 4);     // Second pair angle brackets
                                    ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 88, 4);     // Third pair angle brackets
                                    ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 101, 1);    // Trail data angle bracket
                                }
                                else// if (IsHexColon (strTest1))
                                {
                                    ftDisplayedLines.SetForegroundBrush(m_brMedSeaGrn, iOffset + 20, 5);                                  // Mnemonic
                                    if (strLine.Length >= 26)
                                    {
                                        ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 26, Math.Min(strLine.Length, 15));    // Instruction code
                                    }
                                    if (strLine.Length >= 49)
                                    {
                                        ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 43, 6);                                // Data address
                                    }
                                    if (strLine.Length >= 51)
                                    {
                                        ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 51, strLine.Length - 51);             // Annotation
                                    }
                                }
                            }
                            else if (strLine.Length >= 52 &&
                                     IsBlank(strLine.Substring(0, 51)))
                            {
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 51, strLine.Length - 51);       // Annotation
                            }

                            iOffset = GetCharacterIndexFromLineIndex(iIdx);

                            #region Test code for breakpoint and bookmark buttons
                            ////drawingContext.PushClip (new RectangleGeometry (new Rect (0, 0, leftMargin, topMargin))); // Restrict text to textbox
                            //double dLeft = leftMargin - this.HorizontalOffset - 13;
                            //double dTop  = topMargin + (iIdx * 13.55) + 7 - this.VerticalOffset;
                            ////Console.WriteLine ("Left: {0:###.#}  Top: {1:###.#}", dLeft, dTop);
                            //if (iIdx % 3 == 0)
                            //{
                            //    drawingContext.DrawEllipse (new SolidColorBrush (Colors.Red), null,
                            //                                new Point (dLeft, dTop), 5, 5);
                            //}
                            //else if (iIdx % 3 == 1)
                            //{
                            //    drawingContext.DrawEllipse (new SolidColorBrush (Colors.Transparent), new Pen (new SolidColorBrush (Colors.Red), 1.0),
                            //                                new Point (dLeft, dTop), 5, 5);
                            //}

                            //if (iIdx % 4 == 0)
                            //{
                            //    drawingContext.DrawRectangle (new SolidColorBrush (Colors.Blue), null, new Rect (new Point (3, dTop),
                            //                                                                                     new Point (dLeft + 5, dTop + 7)));
                            //}
                            //else if (iIdx % 4 == 1)
                            //{
                            //    drawingContext.DrawRectangle (new SolidColorBrush (Colors.Transparent), new Pen (new SolidColorBrush (Colors.Blue), 1.0),
                            //                                                                           new Rect (new Point (3, dTop),
                            //                                                                                     new Point (dLeft + 5, dTop + 7)));
                            //}
                            ////drawingContext.PushClip (new RectangleGeometry (new Rect (leftMargin, topMargin, this.ActualWidth, this.ActualHeight))); // Restrict text to textbox
                            #endregion

                            #region Highlighting
                            //0         1
                            //01234567890123456789
                            //Entry_0000    0000:
                            if (m_bEnableHighlightLine)
                            {
                                if (iIdx == m_iCurrentLineIdx)
                                {
                                    Geometry geomCurrentLine = ftDisplayedLines.BuildHighlightGeometry(new Point(dLeftMargin, dTopMargin - this.VerticalOffset),
                                                                                                       iOffset + 14, strLine.Length - 14);
                                    if (geomCurrentLine != null)
                                    {
                                        dcRendering.DrawGeometry(m_brYellow, null, geomCurrentLine);
                                    }
                                }
                                else if (m_liGrayedCode.Contains(iIdx) &&
                                         strLine.Substring(20, 4) != "data" &&
                                         strLine.Substring(0, 5) != "Entry")
                                {
                                    Geometry geomCurrentLine = ftDisplayedLines.BuildHighlightGeometry(new Point(dLeftMargin, dTopMargin - this.VerticalOffset),
                                                                                                       iOffset + 14, 5);
                                    if (geomCurrentLine != null)
                                    {
                                        dcRendering.DrawGeometry(m_brLtGray, null, geomCurrentLine);
                                    }
                                }
                            }
                            #region Old highlighting for breakpoints and bookmarks
                            //if (iIdx == 0)
                            //{
                            //    // TODO: Replace magic numbers with variable
                            //    Geometry geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 12, 2);
                            //    if (geom != null)
                            //    {
                            //        dcRendering.DrawGeometry (m_brBrkPt, null, geom);
                            //    }
                            //}
                            //else if (iIdx == 2)
                            //{
                            //    // TODO: Replace magic numbers with variable
                            //    Geometry geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 12, 2);
                            //    if (geom != null)
                            //    {
                            //        dcRendering.DrawGeometry (m_brDisBrkPt, null, geom);
                            //    }
                            ////}
                            ////else if (iIdx == 2)
                            ////{
                            //    // TODO: Replace magic numbers with variable
                            //    geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset, 4);
                            //    if (geom != null)
                            //    {
                            //        dcRendering.DrawGeometry (m_brBkMrk, null, geom);
                            //    }
                            //    //geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 4, 4);
                            //    //if (geom != null)
                            //    //{
                            //    //    dcRendering.DrawGeometry (m_brBkMrk, null, geom);
                            //    //}
                            //}
                            //else if (iIdx == 3)
                            //{
                            //    // TODO: Replace magic numbers with variable
                            //    Geometry geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 26, 11);
                            //    if (geom != null)
                            //    {
                            //        dcRendering.DrawGeometry (m_brDisBkMrk, null, geom);
                            //    }
                            //}
                            #endregion
                            #endregion
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            if (strLine.Length > 0)
                            {
                                Console.WriteLine("ArgumentOutOfRangeException: [" + iIdx.ToString() + "] " + strLine);
                            }
                            // Fail silently
                        }
                    }
                }
                #endregion
                else if (m_eSyntaxColoringMode == SyntaxColoringMode.Trace)
                #region Trace Output
                {
                    iStartVisibleLine = GetFirstVisibleLineIndex();
                    iEndVisibleLine   = GetLastVisibleLineIndex();

                    for (int iIdx = iStartVisibleLine; iIdx <= iEndVisibleLine - 1; ++iIdx)
                    {
                        try
                        {
                            try
                            {
                                iOffset     = GetCharacterIndexFromLineIndex(iIdx);
                                iOffsetNext = GetCharacterIndexFromLineIndex(iIdx + 1);
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                // Fail silently
                            }

                            strLine = Text.Substring(iOffset, iOffsetNext - iOffset);

                            if (strLine.Length >= 15 &&
                                strLine.Substring(0, 5) == "Step:")
                            {
                                //          1         2         3         4         5         6         7         8         9         0
                                //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //Step: 1,       Timing: 608  608.00µs (6 08)
                                ftDisplayedLines.SetForegroundBrush(m_brTeal, iOffset, 14);                             // Step Count
                                ftDisplayedLines.SetForegroundBrush(m_brRoyalBlue, iOffset + 15, strLine.Length - 15);  // Timing
                            }
                            else if (strLine.Length >= 22 &&
                                     strLine.Substring(0, 3) == "IL:")
                            {
                                //          1         2         3         4         5         6         7         8         9         0
                                //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //IL: M LA    C2 01 0000       0x0000  XR1
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length);    // Default for string
                                ftDisplayedLines.SetForegroundBrush(m_brMedSeaGrn, iOffset + 6, 5);           // Mnemonic
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 12, 15);           // Instruction code
                            }
                            else if (strLine.Length >= 20 &&
                                     strLine.Substring(0, 20) == "         1         2")
                            {
                                //          1         2         3         4         5         6         7         8         9         0
                                //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //         1         2         3         4         5         6         7         8         9
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length);
                            }
                            else if (strLine.Length >= 20 &&
                                     strLine.Substring(0, 20) == "12345678901234567890")
                            {
                                //          1         2         3         4         5         6         7         8         9         0
                                //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length);
                            }
                            else if (strLine.Length >= 126 &&
                                     IsHexColon(strLine.Substring(25, 5)) &&
                                     strLine[83] == '<')
                            {
                                //          1         2         3         4         5         6         7         8         9         0         1         2
                                //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //                         0080: 40 40 40 40  40 40 40 40  40 40 40 40  40 40 40 40  <@@@@ @@@@ @@@@ @@@@>  <                   >
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, 24);
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 25, 5);      // Data address
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 31, 50);    // Hex data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 83, 1);     // Lead Op1 angle bracket
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 84, 42);    // Op1 hex ascii data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 103, 4);    // Middle Op1 angle brackets
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 126, 1);    // Trail Op1 angle bracket
                            }
                            else if (strLine.Length >= 9 &&
                                     strLine.Substring(0, 9) == "   >>>   ")
                            {
                                //          1         2         3         4         5         6         7         8         9         0
                                //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //   >>>   MFCU Read Buffer (0x0000):
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length);
                            }
                            else if (strLine.Length >= 17 &&
                                     strLine.Substring(0, 17) == "            MFCU ")
                            {
                                //          1         2         3         4         5         6         7         8         9         0
                                //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //            MFCU Read DAR after LIO: 0x0000
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length);
                            }
                            else if (strLine.Length >= 106 &&
                                     IsHexColon(strLine.Substring(5, 5)) &&
                                     strLine[63] == '<')
                            {
                                //          1         2         3         4         5         6         7         8         9         0
                                //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //Op2: 0020: 71 F5 FF F3  F1 40 F1 F1  00 D0 00 00               <q... .@.. ....     >  <.5.3 1 11 .}..     >
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset, 4);           // "Op1:" label
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 5, 57);     // Hex data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 63, 1);     // Lead Op1 angle bracket
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 64, 42);    // Op1 hex ascii data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 83, 4);     // Middle Op1 angle brackets
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 106, 1);    // Trail Op1 angle bracket
                            }
                            else if (strLine.Length >= 102 &&
                                     IsHexColon(strLine.Substring(0, 5)) &&
                                     strLine[58] == '<')
                            {
                                //          1         2         3         4         5         6         7         8         9         0
                                //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //0000: 5C 09 71 14  5C 14 86 34  D0 00 F4 5F  88 F2 04 03  <\\.q. \\..4 ..._ ....>  <*... *.f. }.4^ h2..>
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset, 5);           // Hex data address
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 6, 51);     // Hex data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 58, 1);     // Lead Op1 angle bracket
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 59, 42);    // Op1 hex ascii data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 78, 4);     // Middle Op1 angle brackets
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 101, 1);    // Trail Op1 angle bracket
                            }
                            else if (strLine.Length >= 61 &&
                                     strLine.Substring(0, 4) == "Op1:")
                            {
                                //          1         2         3         4         5         6         7         8         9         0         1         2
                                //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //Op1: 0060: 00 00 00 00  00 00 00 00  <.... ....>  <.... ....>  Op2: 002C: F0 7C 6C D0  87 60 57 20  <.|l. .`W >  <0@%} g-..>
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset, 4);          // "Op1:" label
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 5, 31);    // Hex data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 37, 1);    // Lead Op1 angle bracket
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 38, 22);   // Op1 hex ascii data values
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 47, 4);    // Middle Op1 angle brackets
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 60, 1);    // Trail Op1 angle bracket
                                if (strLine.Contains("Op2:"))
                                {
                                    ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 63, 4);      // "Op2:" label
                                    ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 100, 1);    // Lead Op2 angle bracket
                                    ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 68, 31);    // Op2 hex data values
                                    ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 101, 22);   // Op2 ascii data values
                                    ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 110, 4);    // Middle Op2 angle brackets
                                    ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 123, 1);    // Trail Op2 angle bracket
                                }
                            }
                            else if (strLine.Length >= 118 &&
                                     IsHexColon(strLine.Substring(0, 5)) &&
                                     strLine.Substring(43, 4) == "IAR:")
                            {
                                //          1         2         3         4         5         6         7         8         9         0         1         2
                                //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                                //0000: LA    C2 01 0000       00 00         IAR: 0004  XR1: 0000  XR2: 0000  ARR: 0000  CR: EQ            Timing: 6.08µs
                                //00D5: A     76 02 FA,1       00 FA         IAR: 00D8  XR1: 0000  XR2: 0053  ARR: 00A6  CR: HI       BO XR2: 0x0057 --> 0x0053
                                ftDisplayedLines.SetForegroundBrush(m_brCoral, iOffset, 5);             // Instruction address
                                ftDisplayedLines.SetForegroundBrush(m_brMedSeaGrn, iOffset + 6, 5);     // Mnemonic
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 12, 15);     // Instruction code
                                ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 29, 13);     // Annotation
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 43, 4);       // IAR label
                                ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 48, 55);     // Register values
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 54, 4);       // XR1 label
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 65, 4);       // XR2 label
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 76, 4);       // ARR label
                                ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 87, 3);       // CR label
                                if (strLine.Substring(105, 8) == "Timing: ")
                                {
                                    ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 105, 15);  // Timing
                                }
                                else
                                {
                                    ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 103, 4);    // Register label
                                    ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 108, 6);   // Old register value
                                    ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 115, 3);   // "-->"
                                    ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 119, 6);   // New register value
                                }
                            }
                            else if (strLine.Length >= 7 &&
                                     strLine.Substring(0, 7) == "- - - -")
                            {
                                ftDisplayedLines.SetForegroundBrush(m_brFirebrick, iOffset, strLine.Length);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            //Console.WriteLine ("ArgumentOutOfRangeException: [" + iIdx.ToString () + "] " + strLine);
                            // Fail silently
                        }
                    }
                }
                #endregion // Trace Output

                dcRendering.DrawText(ftDisplayedLines, new Point(dLeftMargin - this.HorizontalOffset, dTopMargin - this.VerticalOffset));
                #endregion // Text Coloring and Shading
            }
        }
コード例 #59
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            //base.OnRender(drawingContext);
            if (this.Text != "")
            {
                FormattedText formattedText = null;
                double        leftMargin    = 4.0 + this.BorderThickness.Left;
                double        topMargin     = 2 + this.BorderThickness.Top;

                if (IsAllowFormatSqlContent)
                {
                    #region MyRendering
                    EnsureScrolling();
                    formattedText = new FormattedText(
                        this.Text,
                        CultureInfo.GetCultureInfo("en-us"),
                        FlowDirection.LeftToRight,
                        new Typeface(this.FontFamily.Source),
                        this.FontSize,
                        BaseForeground);                                                                                 //Text that matches the textbox's

                    formattedText.MaxTextWidth  = this.ViewportWidth;                                                    // space for scrollbar
                    formattedText.MaxTextHeight = Math.Max(this.ActualHeight + this.VerticalOffset, 0);                  //Adjust for scrolling
                    drawingContext.PushClip(new RectangleGeometry(new Rect(0, 0, this.ActualWidth, this.ActualHeight))); //restrict text to textbox

                    //Background hilight
                    foreach (Decoration dec in mDecorations)
                    {
                        if (dec.DecorationType == EDecorationType.Hilight)
                        {
                            List <Pair> ranges = dec.Ranges(this.Text);
                            foreach (Pair p in ranges)
                            {
                                Geometry geom = formattedText.BuildHighlightGeometry(new Point(leftMargin, topMargin - this.VerticalOffset), p.Start, p.Length);
                                if (geom != null)
                                {
#if DEBUG
                                    Debug.WriteLine("Draw geometry");
#endif
                                    drawingContext.DrawGeometry(dec.Brush, null, geom);
                                }
                            }
                        }
                    }

                    //Underline
                    foreach (Decoration dec in mDecorations)
                    {
                        if (dec.DecorationType == EDecorationType.Underline)
                        {
                            List <Pair> ranges = dec.Ranges(this.Text);
                            foreach (Pair p in ranges)
                            {
                                Geometry geom = formattedText.BuildHighlightGeometry(new Point(leftMargin, topMargin - this.VerticalOffset), p.Start, p.Length);
                                if (geom != null)
                                {
                                    StackedRectangleGeometryHelper srgh = new StackedRectangleGeometryHelper(geom);

                                    foreach (Geometry g in srgh.BottomEdgeRectangleGeometries())
                                    {
#if DEBUG
                                        Debug.WriteLine("Draw geometry2");
#endif
                                        drawingContext.DrawGeometry(dec.Brush, null, g);
                                    }
                                }
                            }
                        }
                    }


                    //Strikethrough
                    foreach (Decoration dec in mDecorations)
                    {
                        if (dec.DecorationType == EDecorationType.Strikethrough)
                        {
                            List <Pair> ranges = dec.Ranges(this.Text);
                            foreach (Pair p in ranges)
                            {
                                Geometry geom = formattedText.BuildHighlightGeometry(new Point(leftMargin, topMargin - this.VerticalOffset), p.Start, p.Length);
                                if (geom != null)
                                {
                                    StackedRectangleGeometryHelper srgh = new StackedRectangleGeometryHelper(geom);

                                    foreach (Geometry g in srgh.CenterLineRectangleGeometries())
                                    {
#if DEBUG
                                        Debug.WriteLine("Draw geometry3");
#endif
                                        drawingContext.DrawGeometry(dec.Brush, null, g);
                                    }
                                }
                            }
                        }
                    }


                    #region TextColor
                    foreach (Decoration dec in mDecorations)
                    {
                        if (dec.DecorationType == EDecorationType.TextColor)
                        {
                            List <Pair> ranges = dec.Ranges(this.Text);
                            foreach (Pair p in ranges)
                            {
#if DEBUG
                                Debug.WriteLine("Set background brush" + p.Start.ToString());
#endif
                                //this method will paint the text ,it will cost many ,many times,
                                //if the sql script large enough (more than 100k)
                                //So I'd rather use simplest textbox with no formatted sql text replace this control.
                                formattedText.SetForegroundBrush(dec.Brush, p.Start, p.Length);
                            }
                        }
                    }
                    #endregion

#if DEBUG
                    Debug.WriteLine("End drawing");
#endif

                    #endregion
                }

                if (formattedText == null)
                {
                    this.Foreground = new SolidColorBrush(Colors.Black);
                }
                drawingContext.DrawText(formattedText, new Point(leftMargin, topMargin - this.VerticalOffset));
            }
        }
コード例 #60
0
ファイル: RoundScroller.cs プロジェクト: atminatana/SoundMap
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            var b = new Rect(Padding.Left, Padding.Top, ActualWidth - Padding.Left - Padding.Right, ActualHeight - Padding.Top - Padding.Bottom);

            drawingContext.DrawRectangle(Background, null, b);

            var ft = CreateFormattedText("1", Brushes.Transparent);

            var    textHeight = ft.Height;
            double titleTab   = string.IsNullOrEmpty(Title)? 0: (textHeight + 2);

            var bigRadiusH = (b.Height - textHeight - titleTab) / 2 - ValueWidth;
            var bigRadiusW = b.Width / 2 - ValueWidth;
            var bigRadius  = Math.Min(bigRadiusH, bigRadiusW);

            var smallRadius  = bigRadius - ValueWidth;
            var middleRadius = (bigRadius + smallRadius) / 2;

            FLeftRightTab2 = 180 * Math.Acos(1 - 3 * ValueWidth / middleRadius / middleRadius) / Math.PI;
            FCenter        = new Point(b.Left + b.Width / 2, b.Top + titleTab + ValueWidth + bigRadius);

            var    maxminDelta = MaxValue - MinValue;
            double valuePct    = (maxminDelta == 0)? 0: (Value - MinValue) / maxminDelta;

            if (valuePct > 1)
            {
                valuePct = 1;
            }
            if (valuePct < 0)
            {
                valuePct = 0;
            }

            Func <double, double, Point> getArcPoint = (double APct, double ARadius) =>
            {
                var angle = PercentToAngle(APct);
                return(new Point(
                           FCenter.X + ARadius * Math.Cos(angle),
                           FCenter.Y - ARadius * Math.Sin(angle)));
            };

            var bigStart = getArcPoint(0, bigRadius);
            var smallEnd = getArcPoint(0, smallRadius);

            Action <double, Brush> drawArc = (double AEndPct, Brush AFillBrush) =>
            {
                var smallStart = getArcPoint(AEndPct, smallRadius);
                var bigEnd     = getArcPoint(AEndPct, bigRadius);

                bool       isBigArc = Math.Abs(PercentToAngle(0) - PercentToAngle(AEndPct)) > Math.PI;
                PathFigure pf       = new PathFigure();
                pf.StartPoint = bigStart;
                pf.Segments.Add(new ArcSegment(bigEnd, new Size(bigRadius, bigRadius), 0, isBigArc, SweepDirection.Clockwise, true));
                pf.Segments.Add(new LineSegment(smallStart, true));
                pf.Segments.Add(new ArcSegment(smallEnd, new Size(smallRadius, smallRadius), 0, isBigArc, SweepDirection.Counterclockwise, true));
                pf.Segments.Add(new LineSegment(bigStart, true));
                pf.Freeze();

                PathGeometry g = new PathGeometry();
                g.FillRule = FillRule.Nonzero;
                g.Figures.Add(pf);
                g.Freeze();

                drawingContext.DrawGeometry(AFillBrush, null, g);
            };

            drawArc(1, ValueBackground);
            drawArc(valuePct, ValueForeground);

            var holderRadius = ValueWidth * 1.5;

            drawingContext.DrawEllipse((IsFocused)? FocusForeground: ValueForeground, null, getArcPoint(valuePct, middleRadius), holderRadius, holderRadius);

            if (!string.IsNullOrEmpty(Title))
            {
                ft = CreateFormattedText(Title, this.Foreground);
                ft.MaxTextWidth  = b.Width;
                ft.Trimming      = TextTrimming.CharacterEllipsis;
                ft.MaxTextHeight = textHeight + 2;
                ft.TextAlignment = TextAlignment.Center;
                drawingContext.DrawText(ft, new Point(b.Left, b.Top));
            }

            string vStr;

            if (ValueDigitCount > -1)
            {
                vStr = Value.ToString("F" + ValueDigitCount);
            }
            else
            {
                vStr = string.IsNullOrEmpty(ValueStringFormat)? Value.ToString(): string.Format(ValueStringFormat, Value);
            }

            ft = CreateFormattedText(vStr, (IsFocused)? FocusForeground: FocusForeground);
            ft.MaxTextWidth = 2 * smallRadius;
            ft.Trimming     = TextTrimming.CharacterEllipsis;
            drawingContext.DrawText(ft, new Point(FCenter.X - ft.Width / 2, FCenter.Y - ft.Height / 2));

            var pt = getArcPoint(0, bigRadius);

            ft = CreateFormattedText(MinValue.ToString(), Foreground);
            drawingContext.DrawText(ft, new Point(pt.X - ft.Width, pt.Y));

            pt = getArcPoint(1, bigRadius);
            ft = CreateFormattedText(MaxValue.ToString(), Foreground);
            drawingContext.DrawText(ft, pt);
        }