コード例 #1
1
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            if (item != null)
            {
                var itemRect = new Rect(item.RenderSize);
                Point startPoint;
                Point endPoint;
                if (!showMarkerAfterItem)
                {
                    startPoint = itemRect.TopLeft;
                    endPoint = itemRect.TopRight;
                }
                else
                {
                    startPoint = itemRect.BottomLeft;
                    endPoint = itemRect.BottomRight;
                }

                startPoint = item.TranslatePoint(startPoint, control);
                endPoint = item.TranslatePoint(endPoint, control);

                drawingContext.PushClip(new RectangleGeometry(adornerViewRect));
                drawingContext.DrawLine(new Pen(Brushes.Green, 2), startPoint, endPoint);
            }
        }
コード例 #2
1
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            double segmentStart;
            double segmentEnd;
            if (Edge.Orientation == Orientation.Vertical)
            {
                segmentStart = Math.Min(Edge.Range.SegmentStart, CanvasItem.Top);
                segmentEnd = Math.Max(Edge.Range.SegmentEnd, CanvasItem.Bottom);
            }
            else
            {
                segmentStart = Math.Min(Edge.Range.SegmentStart, CanvasItem.Left);
                segmentEnd = Math.Max(Edge.Range.SegmentEnd, CanvasItem.Right);
            }

            var point1 = new Point(Edge.AxisDistance, segmentStart);
            var point2 = new Point(Edge.AxisDistance, segmentEnd);

            if (Edge.Orientation == Orientation.Horizontal)
            {
                point1 = point1.Swap();
                point2 = point2.Swap();
            }

            drawingContext.DrawLine(Pen, point1, point2);
        }
コード例 #3
0
ファイル: FoldingMarginMarker.cs プロジェクト: Altaxo/Altaxo
		protected override void OnRender(DrawingContext drawingContext)
		{
			FoldingMargin margin = VisualParent as FoldingMargin;
			Pen activePen = new Pen(margin.SelectedFoldingMarkerBrush, 1);
			Pen inactivePen = new Pen(margin.FoldingMarkerBrush, 1);
			activePen.StartLineCap = inactivePen.StartLineCap = PenLineCap.Square;
			activePen.EndLineCap = inactivePen.EndLineCap = PenLineCap.Square;
			Size pixelSize = PixelSnapHelpers.GetPixelSize(this);
			Rect rect = new Rect(pixelSize.Width / 2,
			                     pixelSize.Height / 2,
			                     this.RenderSize.Width - pixelSize.Width,
			                     this.RenderSize.Height - pixelSize.Height);
			drawingContext.DrawRectangle(
				IsMouseDirectlyOver ? margin.SelectedFoldingMarkerBackgroundBrush : margin.FoldingMarkerBackgroundBrush,
				IsMouseDirectlyOver ? activePen : inactivePen, rect);
			double middleX = rect.Left + rect.Width / 2;
			double middleY = rect.Top + rect.Height / 2;
			double space = PixelSnapHelpers.Round(rect.Width / 8, pixelSize.Width) + pixelSize.Width;
			drawingContext.DrawLine(activePen,
			                        new Point(rect.Left + space, middleY),
			                        new Point(rect.Right - space, middleY));
			if (!isExpanded) {
				drawingContext.DrawLine(activePen,
				                        new Point(middleX, rect.Top + space),
				                        new Point(middleX, rect.Bottom - space));
			}
		}
コード例 #4
0
ファイル: TilesetCanvas.cs プロジェクト: chubbyerror/Gibbo2D
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);

            try
            {
                int cx = (int)Width / brushSizeX;
                int cy = (int)Height / brushSizeY;

                // draw vertical lines:
                for (int i = 0; i <= cx; i++)
                {
                    dc.DrawLine(penGrid, new Point(i * brushSizeX, 0), new Point(i * brushSizeX, Height));
                }

                // draw horizontal lines:
                for (int i = 0; i <= cy; i++)
                {
                    dc.DrawLine(penGrid, new Point(0, i * brushSizeY), new Point(Width, i * brushSizeY));
                }

                // draw selection:
                if (selection.Width > 0 && selection.Height > 0)
                {
                    dc.DrawRectangle(Brushes.Transparent, penBlack, selection);
                    dc.DrawRectangle(Brushes.Transparent, penWhite, selection);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #5
0
ファイル: LinesRenderer.cs プロジェクト: GreenDamTan/dnSpy
		protected override void OnRender(DrawingContext dc)
		{
			var indent = NodeView.CalculateIndent(NodeView.Node);
			var p = new Point(indent + 4.5, 0);

			if (!NodeView.Node.IsRoot || NodeView.ParentTreeView.ShowRootExpander) {
				dc.DrawLine(pen, new Point(p.X, ActualHeight / 2), new Point(p.X + 10, ActualHeight / 2));
			}

			if (NodeView.Node.IsRoot) return;

			if (NodeView.Node.IsLast) {
				dc.DrawLine(pen, p, new Point(p.X, ActualHeight / 2));
			}
			else {
				dc.DrawLine(pen, p, new Point(p.X, ActualHeight));
			}

			var current = NodeView.Node;
			while (true) {
				p.X -= 19;
				current = current.Parent;
				if (p.X < 0) break;
				if (!current.IsLast) {
					dc.DrawLine(pen, p, new Point(p.X, ActualHeight));
				}
			}
		}
コード例 #6
0
		protected override void OnRender(DrawingContext drawingContext)
		{
			Pen blackPen = new Pen(Brushes.Black, 1);
			blackPen.StartLineCap = PenLineCap.Square;
			blackPen.EndLineCap = PenLineCap.Square;
			Size pixelSize = PixelSnapHelpers.GetPixelSize(this);
			Rect rect = new Rect(pixelSize.Width / 2,
			                     pixelSize.Height / 2,
			                     this.RenderSize.Width - pixelSize.Width,
			                     this.RenderSize.Height - pixelSize.Height);
			drawingContext.DrawRectangle(Brushes.White,
			                             IsMouseDirectlyOver ? blackPen : new Pen(Brushes.Gray, 1),
			                             rect);
			double middleX = rect.Left + rect.Width / 2;
			double middleY = rect.Top + rect.Height / 2;
			double space = PixelSnapHelpers.Round(rect.Width / 8, pixelSize.Width) + pixelSize.Width;
			drawingContext.DrawLine(blackPen,
			                        new Point(rect.Left + space, middleY),
			                        new Point(rect.Right - space, middleY));
			if (!isExpanded) {
				drawingContext.DrawLine(blackPen,
				                        new Point(middleX, rect.Top + space),
				                        new Point(middleX, rect.Bottom - space));
			}
		}
コード例 #7
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            var element = AdornedElement as FrameworkElement;

            if (element == null)
            {
                return;
            }

            var pen = new Pen(Brushes.Gray, 1);

            for (var x = 0; x < element.ActualWidth; x += 100)
            {
                for (var y = 0; y < element.ActualHeight; y += 100)
                {
                    drawingContext.DrawLine(pen,
                                            new Point(x, 0),
                                            new Point(x, element.ActualHeight));
                    drawingContext.DrawLine(pen,
                                            new Point(0, y),
                                            new Point(element.ActualWidth, y));
                }
            }
        }
コード例 #8
0
ファイル: MainWindow.xaml.cs プロジェクト: kinectNao/bluenao
        private void DrawBone(Joint jointFrom, Joint jointTo, Pen aPen, DrawingContext aContext)
        {
            if (jointFrom.TrackingState == JointTrackingState.NotTracked ||
            jointTo.TrackingState == JointTrackingState.NotTracked)
            {
                return;
            }

            if (jointFrom.TrackingState == JointTrackingState.Inferred ||
            jointTo.TrackingState == JointTrackingState.Inferred)
            {
                ColorImagePoint p1 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointFrom.Position, ColorImageFormat.RgbResolution640x480Fps30);
                ColorImagePoint p2 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointTo.Position, ColorImageFormat.RgbResolution640x480Fps30);
                //Thin line
                aPen.DashStyle = DashStyles.Dash;
                aContext.DrawLine(aPen, new Point(p1.X, p1.Y), new Point(p2.X, p2.Y));

            }
            if (jointFrom.TrackingState == JointTrackingState.Tracked ||
            jointTo.TrackingState == JointTrackingState.Tracked)
            {
                ColorImagePoint p1 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointFrom.Position, ColorImageFormat.RgbResolution640x480Fps30);
                ColorImagePoint p2 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointTo.Position, ColorImageFormat.RgbResolution640x480Fps30);
                //Thick line
                aPen.DashStyle = DashStyles.Solid;
                aContext.DrawLine(aPen, new Point(p1.X, p1.Y), new Point(p2.X, p2.Y));
            }
        }
コード例 #9
0
ファイル: CoreDraw.cs プロジェクト: SAM33/2016-OOP-UMLEditor
        public static void DrawLine(DrawingContext dc, Point _Start, Point _End, double LineWidth, Brush LineColor, int LineStyle)
        {
            Pen lp = new Pen(LineColor, LineWidth);

            switch (LineStyle)
            {
                case LineStyle_StraightLine :
                    dc.DrawLine(lp, _Start, _End);
                    break;
                case LineStyle_MultipleSegment :
                    double dx = Math.Abs(_Start.X - _End.X);
                    double dy = Math.Abs(_Start.Y - _End.Y);
                    double d1 = Math.Pow(dx * dx + dy * dy, 0.5);
                    double d2 = Math.Pow(5 * 5 + 5 * 5, 0.5);
                    Vector v1 = new Vector(_End.X - _Start.X, _End.Y - _Start.Y);
                    Vector v2 = v1 / (d1 / d2);
                    int count = (int)(d1 / d2);
                    List<Point> S = new List<Point>();
                    List<Point> E = new List<Point>();
                    for (int i = 0; i < count; i += 2)
                    {
                        S.Add(_Start + v2 * i);
                        E.Add(_Start + v2 * i + v2);
                    }
                    for (int i = 0; i < S.Count; i++)
                    {
                        dc.DrawLine(lp, S.ElementAt(i), E.ElementAt(i));
                    }
                    break;
            }
        }
コード例 #10
0
        protected override void OnRender(DrawingContext dc)
        {

            var lightBrush = new SolidColorBrush(Colors.LightGray);
            var darkBrush = new SolidColorBrush(Colors.Black);
            lightBrush.Opacity = 0.4;
            darkBrush.Opacity = 0.1;

            double t1 = 6; // thickness of dark circle pen
            double t2 = 2; // thickness of light pen (circle, arcs, segments)
            double d = 0; // distance from light circle to segments
            double l = 10; // length of segments
            double r = 20.0; // radius of light circle

            double r1 = r - (t1 + t2) / 2;
            double r2 = r + l;
            double r3 = r + t2 / 2 + d;
            double r4 = (r + r2) / 2;

            var darkPen = new Pen(darkBrush, t1);
            var lightPen = new Pen(lightBrush, t2);

            dc.DrawEllipse(null, lightPen, Position, r, r);
            dc.DrawEllipse(null, darkPen, Position, r1, r1);
            dc.DrawArc(null, lightPen, Position, 10, 80, r4, r4);
            dc.DrawArc(null, lightPen, Position, 100, 170, r4, r4);
            dc.DrawArc(null, lightPen, Position, 190, 260, r4, r4);
            dc.DrawArc(null, lightPen, Position, 280, 350, r4, r4);

            dc.DrawLine(lightPen, new Point(Position.X, Position.Y - r2), new Point(Position.X, Position.Y - r3));
            dc.DrawLine(lightPen, new Point(Position.X, Position.Y + r2), new Point(Position.X, Position.Y + r3));
            dc.DrawLine(lightPen, new Point(Position.X - r2, Position.Y), new Point(Position.X - r3, Position.Y));
            dc.DrawLine(lightPen, new Point(Position.X + r2, Position.Y), new Point(Position.X + r3, Position.Y));
        }
コード例 #11
0
        void RenderSelectedScopes(System.Windows.Media.DrawingContext drawingContext)
        {
            foreach (SelectedScope scope in selectedScopes)
            {
                if (Math.Abs(scope.Start - scope.Finish) < 1e-6)
                {
                    continue;
                }

                double pos0 = Math.Min(scope.Start, scope.Finish);
                double pos1 = Math.Max(scope.Start, scope.Finish);

                double posStart  = TimeLineToDrawSpace(pos0);
                double posFinish = TimeLineToDrawSpace(pos1);

                //drawingContext.DrawRectangle(Brushes.Gray, selectionScopePen, new Rect(new Point(posStart, HeaderHeight), new Point(posFinish, Extent.Height)));

                double midHeight = Extent.Height / 2;

                Rect area = new Rect(new Point(posStart, HeaderHeight), new Point(posFinish, Extent.Height));
                drawingContext.DrawRectangle(selectionScopeBackground, null, area);

                drawingContext.DrawLine(selectionScopePen, new Point(posStart, HeaderHeight), new Point(posStart, Extent.Height));
                drawingContext.DrawLine(selectionScopePen, new Point(posFinish, HeaderHeight), new Point(posFinish, Extent.Height));

                FormattedText durationText = new FormattedText(String.Format("{0:0.000}ms", pos1 - pos0).Replace(',', '.'), culture, FlowDirection.LeftToRight, fontDuration, 18, Brushes.White);
                durationText.MaxTextWidth = area.Width;
                durationText.Trimming     = TextTrimming.None;
                durationText.MaxLineCount = 1;
                drawingContext.DrawText(durationText, new Point((posStart + posFinish) / 2 - durationText.Width / 2, (Extent.Height + HeaderHeight) / 2 - durationText.Height / 2));
            }
        }
コード例 #12
0
ファイル: drawLT.cs プロジェクト: sonicrang/Train_TS
        public void Init_DrawLT(int running_train)
        {
            int i;
            int temp;
            int late_time_range;
            late_time_range = 1000;
            temp = 0;
            x1 = 30;
            y1 = 10;
            x2 = 700;
            y2 = 580;
            narrow_x = (double)running_train / (x2 - x1);
            narrow_y = (double)late_time_range / (y2 - y1);
            drawingVisual = new DrawingVisual();
            dc = drawingVisual.RenderOpen();
            dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, x1), new Point(x1, y2));
            dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2), new Point(x2, y2));
            dc.DrawText(new FormattedText("N",
                    CultureInfo.GetCultureInfo("en-us"),
                    FlowDirection.LeftToRight,
                    new Typeface("Verdana"),
                    12, System.Windows.Media.Brushes.Black),
                    new System.Windows.Point(x2 - 30, y2 + 6));
            dc.DrawText(new FormattedText("T",
                      CultureInfo.GetCultureInfo("en-us"),
                      FlowDirection.LeftToRight,
                      new Typeface("Verdana"),
                      12, System.Windows.Media.Brushes.Black),
                      new System.Windows.Point(x1 - 10, y1 - 8));

            for (i = 0; i < (x2 - x1); i++)
            {
                if (i % ((x2 - x1) / 5) == 0)
                {
                    dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1 + i, y2), new Point(x1 + i, y2 - 3));
                    dc.DrawText(new FormattedText((temp * running_train / 5).ToString(),
                      CultureInfo.GetCultureInfo("en-us"),
                      FlowDirection.LeftToRight,
                      new Typeface("Verdana"),
                      12, System.Windows.Media.Brushes.Black),
                      new System.Windows.Point(i + x1 - 5, y2 + 7));
                    temp++;
                }
            }
            temp = 0;
            for (i = 0; i < (y2 - y1); i++)
            {
                if (i % ((y2 - y1) / 5) == 0)
                {
                    dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2 - i), new Point(x1 + 3, y2 - i));
                    dc.DrawText(new FormattedText((temp * late_time_range / 5).ToString(),
                      CultureInfo.GetCultureInfo("en-us"),
                      FlowDirection.LeftToRight,
                      new Typeface("Verdana"),
                      12, System.Windows.Media.Brushes.Black),
                      new System.Windows.Point(x1 - 28, y2 - i - 9));
                    temp++;
                }
            }
        }
コード例 #13
0
        public double Hor(DrawingContext dc, Target TargetA, Target TargetB ,bool show)
        {          
            //3D
            Vector3D vectorA = new Vector3D(TargetA.point3D().X - TargetB.point3D().X, TargetA.point3D().Y - TargetB.point3D().Y, TargetA.point3D().Z - TargetB.point3D().Z);
            Vector3D vectorB = new Vector3D(0, 1, 0);
            
            //2D
            //Vector3D vectorA = new Vector3D(TargetA.point2D().X - TargetB.point2D().X, TargetA.point2D().Y - TargetB.point2D().Y, 0);
            //Vector3D vectorB = new Vector3D(1, 0, 0);

            double theta = Math.Abs(Vector3D.AngleBetween(vectorA, vectorB));
            theta = 90 - theta;
            //if (TargetA.point3D().Y < TargetB.point3D().Y) theta = -theta;

            if (show)       //show angle text
            {
                dc.DrawText(new FormattedText(theta.ToString("f0"),
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface("Verdana"),
                25, brushDeepSkyBlue),
                new Point(TargetB.point2D().X - 35, TargetB.point2D().Y - 35));

                dc.DrawLine(PenDeepSkyBlue, TargetA.point2D(), TargetB.point2D());    //show angle line 
                dc.DrawLine(PenDeepSkyBlue, new Point(TargetA.point2D().X, TargetB.point2D().Y), TargetB.point2D());
            }
            return theta;
        }
コード例 #14
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            RotarySwitch rotarySwitch = Visual as RotarySwitch;

            if (rotarySwitch != null)
            {
                if (rotarySwitch.DrawLines)
                {
                    drawingContext.DrawDrawing(_lines);
                }
                foreach (SwitchPositionLabel label in _labels)
                {
                    drawingContext.DrawText(label.Text, label.Location);
                }

                drawingContext.PushTransform(new RotateTransform(rotarySwitch.KnobRotation, _center.X, _center.Y));
                drawingContext.DrawRectangle(_imageBrush, null, _imageRect);
                if (rotarySwitch.VisualizeDragging)
                {
                    double length = (rotarySwitch.DragPoint - _center).Length;
                    drawingContext.DrawLine(HeadingPen, _center, _center + new Vector(0d, -length));
                }
                drawingContext.Pop();

                if (rotarySwitch.VisualizeDragging)
                {
                    drawingContext.DrawLine(DragPen, _center, rotarySwitch.DragPoint);
                }
            }
        }
コード例 #15
0
ファイル: GridAdorner.cs プロジェクト: bdurrani/WPF-Inspector
        protected override void OnRender(DrawingContext drawingContext)
        {
            var dashPen = new Pen(Brushes.Red, 1) { DashStyle = new DashStyle(new double[] { 1, 6 }, 0) };
            dashPen.Freeze();

            if( _grid  != null )
            {
                if (_grid.ColumnDefinitions != null)
                {
                    double xPos = 0;
                    foreach (var column in _grid.ColumnDefinitions)
                    {
                        xPos += column.ActualWidth;
                        drawingContext.DrawLine(dashPen, new Point(xPos, 0), new Point(xPos,ActualHeight));
                    }
                }
                if (_grid.RowDefinitions != null)
                {
                    double yPos = 0;
                    foreach (var column in _grid.RowDefinitions)
                    {
                        yPos += column.ActualHeight;
                        drawingContext.DrawLine(dashPen, new Point(0, yPos), new Point(ActualWidth, yPos));
                    }
                }
            }
            base.OnRender(drawingContext);
        }
コード例 #16
0
            protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
            {
                base.OnRender(drawingContext);

                Rect Size = VisualTreeHelper.GetDescendantBounds(this.tablePanelRoot);

                double Offset = 0;

                foreach (double Width in this.tablePanelRoot.columnWidths)
                {
                    drawingContext.DrawLine(
                        new Pen(Brushes.Yellow, 1)
                    {
                        DashStyle = new DashStyle(new double[] { 6, 4 }, 4)
                    },
                        new Point(Offset, 0),
                        new Point(Offset, Size.Height)
                        );
                    drawingContext.DrawLine(
                        new Pen(Brushes.Blue, 1)
                    {
                        DashStyle = new DashStyle(new double[] { 4, 6 }, 0)
                    },
                        new Point(Offset, 0),
                        new Point(Offset, Size.Height)
                        );
                    Offset += Width;
                }
            }
コード例 #17
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);
            m_lineInPoints  = new Collection <Point>();
            m_lineOutPoints = new Collection <Point>();
            var children = InternalChildren;

            foreach (var child in children)
            {
                findRungPoints(child as UIElement);
            }
            double minY    = ActualHeight;
            double maxInY  = 0;
            double maxOutY = 0;

            foreach (var pt in m_lineInPoints)
            {
                minY   = Math.Min(minY, pt.Y);
                maxInY = Math.Max(maxInY, pt.Y);
            }
            foreach (var pt in m_lineOutPoints)
            {
                //minY = Math.Min(minY, pt.Y);
                maxOutY = Math.Max(maxOutY, pt.Y);
            }

            Pen renderPen = new Pen(new SolidColorBrush(Colors.Black), 1.5);

            dc.DrawLine(renderPen, new Point(0, minY), new Point(0, maxInY));
            dc.DrawLine(renderPen, new Point(ActualWidth, minY), new Point(ActualWidth, maxOutY));
        }
コード例 #18
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (ParentMap != null)
            {
                var bounds = ParentMap.ViewportTransform.Inverse.TransformBounds(new Rect(ParentMap.RenderSize));
                var start = ParentMap.MapTransform.Transform(new Point(bounds.X, bounds.Y));
                var end = ParentMap.MapTransform.Transform(new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height));
                var minSpacing = MinLineSpacing * 360d / (Math.Pow(2d, ParentMap.ZoomLevel) * TileSource.TileSize);
                var spacing = LineSpacings[LineSpacings.Length - 1];

                if (spacing >= minSpacing)
                {
                    spacing = LineSpacings.FirstOrDefault(s => s >= minSpacing);
                }

                var latLabelStart = Math.Ceiling(start.Latitude / spacing) * spacing;
                var lonLabelStart = Math.Ceiling(start.Longitude / spacing) * spacing;
                var latLabels = new List<Label>((int)((end.Latitude - latLabelStart) / spacing) + 1);
                var lonLabels = new List<Label>((int)((end.Longitude - lonLabelStart) / spacing) + 1);
                var labelFormat = spacing < 1d ? "{0} {1}°{2:00}'" : "{0} {1}°";

                for (var lat = latLabelStart; lat <= end.Latitude; lat += spacing)
                {
                    latLabels.Add(new Label(lat, new FormattedText(
                        CoordinateString(lat, labelFormat, "NS"),
                        CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Typeface, FontSize, Foreground)));

                    drawingContext.DrawLine(Pen,
                        ParentMap.LocationToViewportPoint(new Location(lat, start.Longitude)),
                        ParentMap.LocationToViewportPoint(new Location(lat, end.Longitude)));
                }

                for (var lon = lonLabelStart; lon <= end.Longitude; lon += spacing)
                {
                    lonLabels.Add(new Label(lon, new FormattedText(
                        CoordinateString(Location.NormalizeLongitude(lon), labelFormat, "EW"),
                        CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Typeface, FontSize, Foreground)));

                    drawingContext.DrawLine(Pen,
                        ParentMap.LocationToViewportPoint(new Location(start.Latitude, lon)),
                        ParentMap.LocationToViewportPoint(new Location(end.Latitude, lon)));
                }

                foreach (var latLabel in latLabels)
                {
                    foreach (var lonLabel in lonLabels)
                    {
                        var position = ParentMap.LocationToViewportPoint(new Location(latLabel.Position, lonLabel.Position));

                        drawingContext.PushTransform(new RotateTransform(ParentMap.Heading, position.X, position.Y));
                        drawingContext.DrawText(latLabel.Text,
                            new Point(position.X + StrokeThickness / 2d + 2d, position.Y - StrokeThickness / 2d - latLabel.Text.Height));
                        drawingContext.DrawText(lonLabel.Text,
                            new Point(position.X + StrokeThickness / 2d + 2d, position.Y + StrokeThickness / 2d));
                        drawingContext.Pop();
                    }
                }
            }
        }
コード例 #19
0
ファイル: drawSP.cs プロジェクト: sonicrang/Train_TS
 public void Init_DrawSP(ArrayList sp, int track_len, int v_max)
 {
     int i;
     int temp;
     mysp = sp;
     temp = 0;
     x1 = 30;
     y1 = 10;
     x2 = 700;
     y2 = 580;
     narrow_x = (double)track_len / (x2-x1);
     narrow_y = (double)v_max / ((y2 - y1) / 2);
     drawingVisual = new DrawingVisual();
     dc = drawingVisual.RenderOpen();
     dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, x1), new Point(x1, y2));
     dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2), new Point(x2, y2));
     dc.DrawText(new FormattedText("T",
               CultureInfo.GetCultureInfo("en-us"),
               FlowDirection.LeftToRight,
               new Typeface("Verdana"),
               12, System.Windows.Media.Brushes.Black),
               new System.Windows.Point(x2 - 30, y2 + 6));
     dc.DrawText(new FormattedText("V",
               CultureInfo.GetCultureInfo("en-us"),
               FlowDirection.LeftToRight,
               new Typeface("Verdana"),
               12, System.Windows.Media.Brushes.Black),
               new System.Windows.Point(x1 - 10, y1 - 8));
     for (i = 0; i < (x2 - x1); i++)
     {
         if (i % ((x2 - x1) / 5) == 0)
         {
             dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1 + i, y2), new Point(x1 + i, y2 - 3));
             dc.DrawText(new FormattedText((temp * track_len / 5).ToString(),
               CultureInfo.GetCultureInfo("en-us"),
               FlowDirection.LeftToRight,
               new Typeface("Verdana"),
               12, System.Windows.Media.Brushes.Black),
               new System.Windows.Point(i + x1 - 5, y2 + 7));
             temp++;
         }
     }
     temp = 0;
     for (i = 0; i < (y2 - y1)/2; i++)
     {
         if (i % ((y2 - y1) / 10) == 0)
         {
             dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2 - i), new Point(x1 + 3, y2 - i));
             dc.DrawText(new FormattedText((temp * v_max / 5).ToString(),
               CultureInfo.GetCultureInfo("en-us"),
               FlowDirection.LeftToRight,
               new Typeface("Verdana"),
               12, System.Windows.Media.Brushes.Black),
               new System.Windows.Point(x1 - 28, y2 - i - 9));
             temp++;
         }
     }
 }
コード例 #20
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            if (Sequence != null)
            {
                FormattedText seqText = new FormattedText(Sequence.ToString(), CultureInfo.CurrentUICulture,
                                                          FlowDirection.LeftToRight, new Typeface("Courier New"), 12.0,
                                                          new SolidColorBrush(Colors.Black));

                // If we can't fit the sequence, we need to come up with a compressed representation
                if (seqText.Width > ActualWidth)
                {
                    double marginX    = 10.0;
                    double marginY    = 3.0;
                    double barMarginY = marginY + seqText.Height + 2.0;
                    double barWidth   = ActualWidth - (marginX * 2.0);
                    double vertHeight = 5.0;
                    Pen    seqLinePen = new Pen(new SolidColorBrush(Colors.Black), 1.0);

                    // Draw the horizontal bar
                    drawingContext.DrawLine(seqLinePen, new Point(marginX, barMarginY), new Point(ActualWidth - marginX, barMarginY));

                    // Determine the number of verticals
                    int spaceLength = 100;
                    if (Sequence.Count > 1000)
                    {
                        spaceLength = 250;
                    }
                    if (Sequence.Count > 5000)
                    {
                        spaceLength = 1000;
                    }
                    if (Sequence.Count > 10000)
                    {
                        spaceLength = 2500;
                    }
                    int    vertCount   = (int)(Sequence.Count / spaceLength) + 1;
                    double vertSpacing = barWidth / (double)vertCount;

                    // Draw the vertical bars and annotation
                    for (int i = 0; i <= vertCount; i++)
                    {
                        double x = (vertSpacing * (double)i) + marginX;
                        drawingContext.DrawLine(seqLinePen, new Point(x, barMarginY), new Point(x, barMarginY + vertHeight));

                        FormattedText annotation = new FormattedText((spaceLength * i).ToString(), CultureInfo.CurrentUICulture,
                                                                     FlowDirection.LeftToRight, new Typeface("Courier New"), 10.0,
                                                                     new SolidColorBrush(Colors.DarkGray));
                        double textX = x - (annotation.Width / (i == vertCount ? 1.0 : 2.0));
                        drawingContext.DrawText(annotation, new Point(textX, marginY));
                    }
                } // Otherwise just draw the text sequence in there
                else
                {
                    drawingContext.DrawText(seqText, new Point(10.0, 10.0));
                }
            }
            base.OnRender(drawingContext);
        }
コード例 #21
0
        protected void DrawBorder(DrawingContext drawingContext, Pen bdrPen)
        {
            int width = (int)Width;
            int height = (int)Height;

            // draw border
            drawingContext.DrawLine(bdrPen, new Point(width - 0.5, 0.5), new Point(width - 0.5, height - 0.5));
            drawingContext.DrawLine(bdrPen, new Point(0.5, height - 0.5), new Point(width - 0.5, height - 0.5));
        }
コード例 #22
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);


            if (this.playground == null)
            {
                return;
            }

            var xlength = this.playground.GetLength(1);
            var ylength = this.playground.GetLength(0);


            if (ylength == 0 || xlength == 0)
            {
                return;
            }

            double cellHeight = ActualHeight / xlength;
            double cellWidth  = ActualWidth / ylength;


            cellHeight = Math.Floor(cellHeight);
            cellWidth  = Math.Floor(cellWidth);

            if (cellHeight == 0 || cellWidth == 0)
            {
                FormattedText text = new FormattedText("Auflösung falsch gewählt", CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Arial"), 12, Brushes.Black);
                dc.DrawText(text, new Point(25, 25));
                return;
            }

            for (int x = 0; x < ylength; x++)
            {
                for (int y = 0; y < xlength; y++)
                {
                    var rect = new Rect(x * cellWidth, y * cellHeight, cellWidth, cellHeight);
                    if (this.playground[x, y] == true)
                    {
                        dc.DrawRectangle(Brushes.Blue, new Pen(), rect);
                    }
                }
            }

            for (int x = 0; x <= ylength; x++)
            {
                var drawingWidth = ylength * cellWidth;
                dc.DrawLine(new Pen(Brushes.LightGray, 1), new Point(0, x * cellHeight), new Point(drawingWidth, x * cellHeight));
            }

            for (int y = 0; y <= xlength; y++)
            {
                var drawingLength = xlength * cellHeight;
                dc.DrawLine(new Pen(Brushes.LightGray, 1), new Point(y * cellWidth, 0), new Point(y * cellWidth, drawingLength));
            }
        }
コード例 #23
0
        private static void DrawTriangle(DrawingContext drawingContext, Pen pen, Point a, Point b, Point c, double width, double height)
        {
            Point ta = new Point(a.X * width, a.Y * height);
            Point tb = new Point(b.X * width, b.Y * height);
            Point tc = new Point(c.X * width, c.Y * height);

            drawingContext.DrawLine(pen, ta, tb);
            drawingContext.DrawLine(pen, tb, tc);
            drawingContext.DrawLine(pen, tc, ta);
        }
コード例 #24
0
ファイル: RenderTileData.cs プロジェクト: Fulborg/dwarrowdelf
        public void OnRender(DrawingContext dc, bool renderDetails)
        {
            var renderSize = new Size(1, 1);

            dc.DrawRectangle(this.Brush, s_edgePen, new Rect(renderSize));

            if (this.Stairs == Stairs.Down)
            {
                double tri = renderSize.Width / 3;
                dc.DrawLine(new Pen(Brushes.White, 0.05), new Point(tri, tri), new Point(tri * 2, renderSize.Height / 2));
                dc.DrawLine(new Pen(Brushes.White, 0.05), new Point(tri * 2, renderSize.Height / 2), new Point(tri, tri * 2));
            }
            else if (this.Stairs == Stairs.Up)
            {
                double tri = renderSize.Width / 3;
                dc.DrawLine(new Pen(Brushes.White, 0.05), new Point(tri * 2, tri), new Point(tri, renderSize.Height / 2));
                dc.DrawLine(new Pen(Brushes.White, 0.05), new Point(tri, renderSize.Height / 2), new Point(tri * 2, tri * 2));
            }

            if (!renderDetails)
                return;

            if (From != Direction.None)
            {
                var iv = IntVector2.FromDirection(From);
                var v = new Vector(iv.X, iv.Y);
                v *= renderSize.Width / 4;
                Point mp = new Point(renderSize.Width / 2, renderSize.Height / 2);
                dc.DrawEllipse(Brushes.White, null, mp, 0.1, 0.1);
                dc.DrawLine(new Pen(Brushes.White, 0.05), mp, mp + new Vector(v.X, v.Y));
            }

            if (this.Weight != 0)
            {
                var ft = new FormattedText(this.Weight.ToString(), System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("Verdana"), 0.2, Brushes.White);
                dc.DrawText(ft, new Point(renderSize.Width - ft.Width - 0.02, 0));
            }

            if (G != 0 || H != 0)
            {
                var ft = new FormattedText(G.ToString(), System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("Verdana"), 0.2, Brushes.White);
                dc.DrawText(ft, new Point(0.02, renderSize.Height - ft.Height - 0.02));

                ft = new FormattedText(H.ToString(), System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("Verdana"), 0.2, Brushes.White);
                dc.DrawText(ft, new Point(renderSize.Width - ft.Width - 0.02, renderSize.Height - ft.Height - 0.02));

                ft = new FormattedText((G + H).ToString(), System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("Verdana"), 0.2, Brushes.White);
                dc.DrawText(ft, new Point(0.02, 0.02));
            }
        }
コード例 #25
0
 protected override void OnRender(DrawingContext drawingContext)
 {
     if (_type.HasFlag(DataSourceDropType.ArrangeTop))
     {
         drawingContext.DrawLine(_pen, new Point(0, 0), new Point(ActualWidth, 0));
     }
     else if (_type.HasFlag(DataSourceDropType.ArrangeBottom))
     {
         drawingContext.DrawLine(_pen, new Point(0, ActualHeight), new Point(ActualWidth, ActualHeight));
     }
 }
コード例 #26
0
		public static void PaintBackground(this Altaxo.Worksheet.ColumnStyle thiss, DrawingContext dc, RectangleD2D cellRectangle, bool bSelected)
		{
			var cellRect = cellRectangle.ToWpf();
			if (bSelected)
				dc.DrawRectangle(thiss.DefaultSelectedBackgroundBrush.ToWpf(), null, cellRect);
			else
				dc.DrawRectangle(thiss.BackgroundBrush.ToWpf(), null, cellRect);

			dc.DrawLine(thiss.CellBorder.ToWpf(), cellRect.BottomLeft, cellRect.BottomRight);
			dc.DrawLine(thiss.CellBorder.ToWpf(), cellRect.BottomRight, cellRect.TopRight);
		}
コード例 #27
0
ファイル: Renderer.cs プロジェクト: tomba/dwarrowdelf
        void RenderTile(DrawingContext dc, int x, int y)
        {
            var data = m_renderData.Grid[y, x];

            var renderSize = new Size(1, 1);

            dc.DrawRectangle(data.Brush, s_edgePen, new Rect(renderSize));

            if (data.Stairs == Stairs.Down)
            {
                double tri = renderSize.Width / 3;
                dc.DrawLine(new Pen(Brushes.White, 0.05), new Point(tri, tri), new Point(tri * 2, renderSize.Height / 2));
                dc.DrawLine(new Pen(Brushes.White, 0.05), new Point(tri * 2, renderSize.Height / 2), new Point(tri, tri * 2));
            }
            else if (data.Stairs == Stairs.Up)
            {
                double tri = renderSize.Width / 3;
                dc.DrawLine(new Pen(Brushes.White, 0.05), new Point(tri * 2, tri), new Point(tri, renderSize.Height / 2));
                dc.DrawLine(new Pen(Brushes.White, 0.05), new Point(tri, renderSize.Height / 2), new Point(tri * 2, tri * 2));
            }

            if (m_renderDirection && data.From != Direction.None)
            {
                var iv = data.From.ToIntVector2();
                var v = new Vector(iv.X, iv.Y);
                v *= renderSize.Width / 4;
                Point mp = new Point(renderSize.Width / 2, renderSize.Height / 2);
                dc.DrawEllipse(Brushes.White, null, mp, 0.1, 0.1);
                dc.DrawLine(new Pen(Brushes.White, 0.05), mp, mp + new Vector(v.X, v.Y));
            }

            if (data.Weight != 0)
            {
                var ft = new FormattedText(data.Weight.ToString(), System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("Verdana"), 0.2, Brushes.White);
                dc.DrawText(ft, new Point(renderSize.Width - ft.Width - 0.02, 0));
            }

            if (m_renderTexts && (data.G != 0 || data.H != 0))
            {
                var ft = new FormattedText(data.G.ToString(), System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("Verdana"), 0.2, Brushes.White);
                dc.DrawText(ft, new Point(0.02, renderSize.Height - ft.Height - 0.02));

                ft = new FormattedText(data.H.ToString(), System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("Verdana"), 0.2, Brushes.White);
                dc.DrawText(ft, new Point(renderSize.Width - ft.Width - 0.02, renderSize.Height - ft.Height - 0.02));

                ft = new FormattedText((data.G + data.H).ToString(), System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("Verdana"), 0.2, Brushes.White);
                dc.DrawText(ft, new Point(0.02, 0.02));
            }
        }
コード例 #28
0
 private void DrawLines(DrawingContext dc) {
     Pen pen = new Pen(Brushes.WhiteSmoke,1);
     double dx = this.ActualWidth / 30;
     double dy = this.ActualHeight / 30;
     for (int i = 0; i < 31;i++ ) {
         dc.DrawLine(pen, new Point(dx * i, 0), new Point(dx * i, this.ActualHeight));
     }
     for (int i = 0; i < 31;i++ )
     {
         dc.DrawLine(pen, new Point(0, dy * i), new Point(this.ActualWidth, dy * i));
     }
 }
コード例 #29
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);
            var bgColor = Color.FromRgb(0xF9, 0xF9, 0xF9);

            dc.DrawRectangle(new SolidColorBrush(bgColor), null, new Rect(0, 0, ActualWidth, ActualHeight));
            var text = new FormattedText("ABC l 123 Gfijdr", CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Arial"), 12, Brushes.Black);

            dc.DrawText(text, new Point(0, 0));
            dc.DrawLine(new Pen(Brushes.Black, 1), new Point(0.5, 10.5), new Point(50.5, 10.5));
            dc.DrawLine(new Pen(Brushes.Black, 1), new Point(30.5, 0.5), new Point(30.5, 40.5));
        }
コード例 #30
0
ファイル: Map.cs プロジェクト: hanigamal/rb-vms
      /// <summary>
      /// any custom drawing here
      /// </summary>
      /// <param name="drawingContext"></param>
      protected override void OnRender(DrawingContext drawingContext)
      {
         base.OnRender(drawingContext);

#if DEBUG
         FormattedText text = new FormattedText("render: " + counter++ + ", load: " + ElapsedMilliseconds + "ms", CultureInfo.CurrentUICulture, fd, tf, 36, Brushes.Blue);
         drawingContext.DrawText(text, new Point(text.Height, text.Height));
         text = null;
#endif

         drawingContext.DrawLine(cross, new Point((ActualWidth/2) - 10, ActualHeight/2), new Point((ActualWidth/2) + 10, ActualHeight/2));
         drawingContext.DrawLine(cross, new Point(ActualWidth/2, (ActualHeight/2) - 10), new Point(ActualWidth/2, (ActualHeight/2) + 10));
      }
コード例 #31
0
ファイル: Tile.cs プロジェクト: MarkPflug/UwpExperiment
        protected override void OnRender(DrawingContext drawingContext)
        {
            var c = 32;
            for (int i = 0; i < c; i++) {

                var f = Dim / c;
                var p = f * i;

                drawingContext.DrawLine(pen, new Point(0, p), new Point(Dim - p, Dim));
                if (i == 0) continue;

                drawingContext.DrawLine(pen, new Point(p, 0), new Point(Dim, Dim - p));

            }
        }
コード例 #32
0
		protected override void OnRender(DrawingContext drawingContext)
		{
			var h = this.ActualHeight;
			var w = this.ActualWidth;

			for (int i = 0; i * gridY < h ; i++) {
				var y = (int) (i * gridY) + .5;
				drawingContext.DrawLine(gridPen, new Point(0, y), new Point(w, y));
			}

			for (int i = 0; i * gridX < w; i++) {
				var x = (int) (i * gridX) + .5;
				drawingContext.DrawLine(gridPen, new Point(x, 0), new Point(x, h));
			}
		}
コード例 #33
0
ファイル: DrawUtil.cs プロジェクト: kunukn/single-detect
        public static void DrawGrid(DrawingContext dc, bool showGrid, Rectangle rect, Pen color = null)
        {
            if (!IsDrawEnabled) return;

            var pen = showGrid ? (color ?? Pens.PenGrid) : Pens.PenBackground;
            double dw = rect.Width / rect.XGrid; // delta w
            for (var i = 0; i <= rect.XGrid; i++)
            {
                dc.DrawLine(pen, new Point(M.Round(i * dw), 0), new Point(M.Round(i * dw), rect.Height));
            }
            var dh = rect.Height / rect.YGrid; // delta h
            for (var i = 0; i <= rect.YGrid; i++)
            {
                dc.DrawLine(pen, new Point(0, M.Round(i * dh)), new Point(rect.Width, M.Round(i * dh)));
            }
        }
コード例 #34
0
        protected override void DrawPointElement(DrawingContext dc, int Zoom)
        {
            dc.DrawLine(new Pen(Brushes.Black, 2), new Point(), new Point(0, -BodyOffset));

            dc.PushTransform(new TranslateTransform(0, - 0.5 * BodyHeight - BodyOffset));

            dc.DrawRectangle(Brushes.Black, null,
                             new Rect(-0.5 * BodyWidth, -0.5 * BodyHeight, BodyWidth, BodyHeight));

            for (int i = 0; i < Lights.Length; i++)
                dc.DrawEllipse(Lights[i], null, new Point(0, (2 + LightRadius + 1) * (i - 1)), LightRadius, LightRadius);

            dc.PushTransform(new TranslateTransform(0.5 * BodyWidth + 2, -0.5 * BodyHeight));

            if (Zoom > 11)
            {
                PrintStack(dc,
                           new FormattedText(Target.Name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.Black),
                           new FormattedText(OrdinateString, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 8, Brushes.Blue));
            }

            dc.Pop();

            dc.Pop();
        }
コード例 #35
0
ファイル: CursorPresenter.cs プロジェクト: faboo/Agent
 private void DrawBar(DrawingContext drawingContext, int row, int column, FormattedText font)
 {
     drawingContext.DrawLine(
         new Pen(Foreground, 2),
         new Point(column * font.Width, row * font.Height),
         new Point(column * font.Width, (row + 1) * font.Height));
 }
コード例 #36
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            #region Highlight Error Tokens

            var errorsToVisualize = _solution.ErrorService.GetErrorsFromDocument(_codeitem);

            foreach(var err in errorsToVisualize) {
                if(err.Range != null) {
                    foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, err.Range)) {
                        //drawingContext.DrawRectangle(null, _errorPen, r);
                        drawingContext.DrawLine(_errorPen, r.BottomLeft, r.BottomRight);
                    }
                } else {

                    var line = _editor.Document.GetLineByNumber(err.StartLine);
                    if(line != null) {
                        var segment = new TextSegment { StartOffset = line.Offset, EndOffset = line.EndOffset };

                        foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment)) {
                            drawingContext.DrawRectangle(_errorBrush, _errorPen, r);
                        }
                    }
                }
            }

            #endregion
        }
コード例 #37
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            double center = CalculateCenter(size.Height);
            
            drawingContext.DrawLine(
                new Pen(Brushes.Black, Thickness),
                new Point(size.Width, 0),
                new Point(size.Width, size.Height));

            drawingContext.DrawLine(
                new Pen(Brushes.Black, Thickness),
                new Point(0, center),
                new Point(ScaleLineLength, center));
        }
コード例 #38
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);
            if (Connections != null)
            {
                SolidColorBrush brsh = new SolidColorBrush(Colors.White);
                brsh.Opacity = 0.5;
                Pen   pen            = new Pen(brsh, 1.0);
                Point ptLast         = new Point(0, 0);
                bool  fHaveLastPoint = false;

                foreach (TreeConnection tcn in Connections)
                {
                    fHaveLastPoint = false;
                    foreach (DPoint dpt in tcn.LstPt)
                    {
                        if (!fHaveLastPoint)
                        {
                            ptLast         = PtFromDPoint(tcn.LstPt[0]);
                            fHaveLastPoint = true;
                            continue;
                        }
                        dc.DrawLine(pen, PtFromDPoint(dpt), ptLast);
                        ptLast = PtFromDPoint(dpt);
                    }
                }
            }
        }
コード例 #39
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            double center = CalculateCenter(size.Width);

            drawingContext.DrawLine(
                new Pen(Brushes.Black, Thickness),
                new Point(0, 0),
                new Point(size.Width * Math.Exp(Scale / 10d), 0));

            drawingContext.DrawLine(
                new Pen(Brushes.Black, Thickness),
                new Point(center, -ScaleLineLength),
                new Point(center, 0));
        }
コード例 #40
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);
            if (Connections != null)
            {
                //连接线是否反锯齿显示(斜线需要反锯齿显示,横竖线则不需要)
                //RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);

                SolidColorBrush brsh = new SolidColorBrush(Colors.Black);
                brsh.Opacity = 0.5;
                Pen   pen            = new Pen(brsh, 1.0);
                Point ptLast         = new Point(0, 0);
                bool  fHaveLastPoint = false;

                foreach (TreeConnection tcn in Connections)
                {
                    fHaveLastPoint = false;
                    foreach (DPoint dpt in tcn.LstPt)
                    {
                        if (!fHaveLastPoint)
                        {
                            ptLast         = PtFromDPoint(tcn.LstPt[0]);
                            fHaveLastPoint = true;
                            continue;
                        }
                        dc.DrawLine(pen, PtFromDPoint(dpt), ptLast);
                        ptLast = PtFromDPoint(dpt);
                    }
                }
            }
        }
コード例 #41
0
 protected override void Draw(object sender, DrawingContext g)
 {
     if (this.drawing)
     {
         g.DrawLine(new Pen(Brushes.Black, 1), new Point(startPos.X, startPos.Y), new Point(actualPos.X, actualPos.Y));
     }
 }
コード例 #42
0
ファイル: ImageTools.cs プロジェクト: wpftool/ECGViewer
        public static void DrawGrid(System.Windows.Media.DrawingContext dc, float square,
                                    System.Windows.Media.Pen pen, double maxWidth, double maxHeight)
        {
            float x = -square; float y = -square;

            while ((x += square) < maxWidth)
            {
                dc.DrawLine(pen, new System.Windows.Point(x, 0),
                            new System.Windows.Point(x, maxHeight));
            }

            while ((y += square) < maxHeight)
            {
                dc.DrawLine(pen, new System.Windows.Point(0, y),
                            new System.Windows.Point(maxWidth, y));
            }
        }
コード例 #43
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);

            if (IsRulerEnabled)
            {
                Pen pen = new Pen(RulerColor, RulerThickness);
                for (int x = RulerX; x < this.ActualWidth; x += RulerX)
                {
                    dc.DrawLine(pen, new Point(x, 0), new Point(x, this.ActualHeight));
                }

                for (int y = RulerY; y < this.ActualHeight; y += RulerY)
                {
                    dc.DrawLine(pen, new Point(0, y), new Point(this.ActualWidth, y));
                }
            }
        }
コード例 #44
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);
            dc.DrawRectangle(null, line, new Rect(0, 0, this.ActualWidth, this.ActualHeight));
            double height = 0;

            foreach (var r in this.RowDefinitions)
            {
                height += r.ActualHeight;
                dc.DrawLine(line, new Point(0, height), new Point(this.ActualWidth, height));
            }
            double width = 0;

            foreach (var c in this.ColumnDefinitions)
            {
                width += c.ActualWidth;
                dc.DrawLine(line, new Point(width, this.ActualHeight), new Point(width, 0));
            }
        }
コード例 #45
0
        /// <summary>
        /// Draw the legend item
        /// </summary>
        /// <param name="dc">DrawingContext on which to draw</param>
        /// <param name="position">The position on the drawing context to draw relative to.</param>
        public override void Draw(System.Windows.Media.DrawingContext dc, System.Windows.Point position)
        {
            Pen linePen = new Pen(_stroke, _strokeThickness);

            dc.DrawLine(
                linePen,
                new Point(position.X + 2, (int)(position.Y + Dimensions.Height / 2.0)),
                new Point(position.X + 2 + 28, (int)(position.Y + Dimensions.Height / 2.0)));
            dc.DrawText(_formattedText, new Point(38 + position.X, 2 + position.Y));
        }
コード例 #46
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            double textMaxWidth = 0;
            double textX        = ActualWidth;

            switch (TextAlignment)
            {
            case TextAlignment.Left:
                textX = 0;
                break;

            case TextAlignment.Center:
                textX = ActualWidth / 2;
                break;

            case TextAlignment.Right:
                textX = ActualWidth;
                break;
            }

            if (TickRenderMode == TickRenderMode.Text || TickRenderMode == TickRenderMode.Both)
            {
                foreach (double value in Ticks)
                {
                    double y = CalculateY(value);

                    FormattedText text = new FormattedText(value.ToString(), CultureInfo.CurrentUICulture,
                                                           FlowDirection.LeftToRight, new Typeface("Tahoma"), 8.0d, Fill)
                    {
                        TextAlignment = TextAlignment
                    };
                    drawingContext.DrawText(text, new Point(textX, y - text.Height / 2));
                    textMaxWidth = Math.Max(textMaxWidth, text.Width);
                }

                textMaxWidth += 3;
            }

            if (TickRenderMode == TickRenderMode.Tick || TickRenderMode == TickRenderMode.Both)
            {
                Pen pen = new Pen(Fill, 1.0d);

                GuidelineSet guidelineSet = new GuidelineSet();
                drawingContext.PushGuidelineSet(guidelineSet);

                foreach (double value in Ticks)
                {
                    double y = CalculateY(value) + 1;
                    drawingContext.DrawLine(pen, new Point(0, y), new Point(ActualWidth - textMaxWidth, y));
                    guidelineSet.GuidelinesY.Add(y - 0.5);
                }

                drawingContext.Pop();
            }
        }
コード例 #47
0
        public void DrawLine(Pen p, Point startPoint, Point endPoint)
        {
#if !GRID_GUIDELINE
            double halfPenWidth = p.Thickness / 2;

            // Create a guidelines set
            System.Windows.Media.GuidelineSet guidelines = new System.Windows.Media.GuidelineSet();

            guidelines.GuidelinesX.Add(startPoint.X + halfPenWidth);
            guidelines.GuidelinesY.Add(startPoint.Y + halfPenWidth);

            g.PushGuidelineSet(guidelines);
#endif // GRID_GUIDELINE

            g.DrawLine(p, (System.Windows.Point)startPoint, (System.Windows.Point)endPoint);

#if !GRID_GUIDELINE
            g.Pop();
#endif // GRID_GUIDELINE
        }
コード例 #48
0
ファイル: Section.cs プロジェクト: QingqingLin/Lianda
 protected override void OnRender(System.Windows.Media.DrawingContext dc)
 {
     foreach (Graphic graphic in graphics_)
     {
         if (graphic is Line)
         {
             Line line = graphic as Line;
             dc.DrawLine(RedPen_, line.Points[0], line.Points[1]);
         }
     }
 }
コード例 #49
0
        public void Draw(System.Windows.Media.DrawingContext context, Point mid, double factor, double radius)
        {
            var tg1 = Math.Tan((this.F1) / 180.0 * Math.PI);

            var p1 = new Point(mid.X + radius, tg1 * radius + mid.Y);
            var p2 = new Point(mid.X - radius, mid.Y - tg1 * radius);


            var tg2 = Math.Tan((this.F2) / 180.0 * Math.PI);
            var p3  = new Point(tg2 * radius + mid.X, mid.Y + radius);
            var p4  = new Point(mid.X - tg2 * radius, mid.Y - radius);

            var midPoint = new Point(mid.X, mid.Y);

            context.DrawLine(DarkVioletPen, p1, midPoint);
            context.DrawLine(GoldPen, midPoint, p2);

            context.DrawLine(GoldPen, p3, midPoint);
            context.DrawLine(DarkVioletPen, midPoint, p4);
        }
コード例 #50
0
ファイル: TimelineTickbar.cs プロジェクト: kishoredbn/svcperf
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            if (this.TickFrequency <= 1)
            {
                return;
            }

            dc.DrawLine(Timelineborder, new Point(0, 0), new Point(this.ActualWidth, 0));
            double             totalCount    = this.Maximum - this.Minimum;
            double             y             = this.ReservedSpace * 0.5;
            FormattedText      formattedText = null;
            double             x             = 0;
            double             pixelDelta    = this.ActualWidth / (totalCount / this.TickFrequency);
            double             innerDelta    = pixelDelta / 10;
            TimelineResolution resolution    = this.GetMinResolution(totalCount);

            for (double i = 0; i <= totalCount; i += this.TickFrequency, x += pixelDelta)
            {
                string time = i == 0 ? this.GetDateTimeString(this.Minimum) : "+" + this.GetTimeString(resolution, i);
                formattedText = new FormattedText(time,
                                                  CultureInfo.CurrentUICulture,
                                                  System.Windows.FlowDirection.LeftToRight,
                                                  Verdana,
                                                  8,
                                                  Brushes.Black);

                dc.DrawText(formattedText, new Point(x, 10));
                //base.OnRender(dc);
                dc.DrawLine(Timelineborder, new Point(x, 0), new Point(x, 10));


                //Draw innter intervals;
                if (i < this.Maximum)
                {
                    for (double k = innerDelta; k < pixelDelta; k += innerDelta)
                    {
                        dc.DrawLine(Timelineborder, new Point(x + k, 0), new Point(x + k, 5));
                    }
                }
            }
        }
コード例 #51
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            List <int> sectionIndexs = this.SectionIndexList[0];
            List <int> normalIndexs  = SectionIndexList[1];
            List <int> reverseIndexs = SectionIndexList[2];

            foreach (int index in sectionIndexs)
            {
                Line line = graphics_[index] as Line;
                dc.DrawLine(RedPen_, line.Points[0], line.Points[1]);
            }

            if (IsPositionNormal)
            {
                foreach (int index in normalIndexs)
                {
                    Line line = graphics_[index] as Line;
                    dc.DrawLine(RedPen_, line.Points[0], line.Points[1]);
                }

                foreach (int index in reverseIndexs)
                {
                    Line line = graphics_[index] as Line;
                    dc.DrawLine(DefaultPen_, line.Points[0], line.Points[1]);
                }
            }
            else
            {
                foreach (int index in reverseIndexs)
                {
                    Line line = graphics_[index] as Line;
                    dc.DrawLine(RedPen_, line.Points[0], line.Points[1]);
                }

                foreach (int index in normalIndexs)
                {
                    Line line = graphics_[index] as Line;
                    dc.DrawLine(DefaultPen_, line.Points[0], line.Points[1]);
                }
            }
        }
コード例 #52
0
ファイル: RotaryKnobRenderer.cs プロジェクト: appsou/Helios
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            RotaryKnob rotary = Visual as RotaryKnob;

            if (rotary != null)
            {
                drawingContext.PushTransform(new RotateTransform(rotary.KnobRotation, _center.X, _center.Y));
                drawingContext.DrawImage(_image, _imageRect);
                if (rotary.VisualizeDragging)
                {
                    double length = (rotary.DragPoint - _center).Length;
                    drawingContext.DrawLine(HeadingPen, _center, _center + new Vector(0d, -length));
                }
                drawingContext.Pop();

                if (rotary.VisualizeDragging)
                {
                    drawingContext.DrawLine(DragPen, _center, rotary.DragPoint);
                }
            }
        }
コード例 #53
0
ファイル: DragHelper.cs プロジェクト: daviddw/oss-public
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            Rect adornedElementRect = new Rect(this.AdornedElement.RenderSize);
            Pen  drawingPen         = new Pen(Application.Current.FindResource("SolidBorderBrush") as Brush, 3);

            Point left  = iRenderTop ? adornedElementRect.TopLeft : adornedElementRect.BottomLeft;
            Point right = iRenderTop ? adornedElementRect.TopRight : adornedElementRect.BottomRight;

            drawingContext.DrawLine(drawingPen, left, right);
        }
コード例 #54
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);

            if (this.IsGridVisible)
            {
                // Draw GridLines
                Pen pen = new Pen(new SolidColorBrush(System.Windows.Media.Colors.Brown), 1 / this.ZoomValue);
                pen.DashStyle = DashStyles.Dash;

                for (double x = 0; x < this.ActualWidth; x += this.GridWidth)
                {
                    dc.DrawLine(pen, new Point(x, 0), new Point(x, this.ActualHeight));
                }

                for (double y = 0; y < this.ActualHeight; y += this.GridHeight)
                {
                    dc.DrawLine(pen, new Point(0, y), new Point(this.ActualWidth, y));
                }
            }
        }
コード例 #55
0
ファイル: Section.cs プロジェクト: xiaomailong/LianDa
 protected override void OnRender(System.Windows.Media.DrawingContext dc)
 {
     foreach (Line line in graphics_)
     {
         if (HasNonComTrain.Count != 0)
         {
             dc.DrawLine(NonComTrainOccupy_, line.Points[0], line.Points[1]);
         }
         else
         {
             System.Windows.Point Middle = new System.Windows.Point((line.Points[0].X + line.Points[1].X) / 2, (line.Points[0].Y + line.Points[1].Y) / 2);
             if (AxleOccupy == 0)
             {
                 dc.DrawLine(AxleOccupyPen_, line.Points[0], line.Points[1]);
             }
             else
             {
                 dc.DrawLine(DefaultPen_, line.Points[0], line.Points[1]);
             }
             if (IsFrontLogicOccupy && IsLastLogicOccupy)
             {
                 dc.DrawLine(TrainOccpyPen_, line.Points[0], line.Points[1]);
             }
             else if (IsFrontLogicOccupy && !IsLastLogicOccupy)
             {
                 dc.DrawLine(TrainOccpyPen_, line.Points[0], Middle);
             }
             else if (!IsFrontLogicOccupy && IsLastLogicOccupy)
             {
                 dc.DrawLine(TrainOccpyPen_, Middle, line.Points[1]);
             }
         }
     }
     dc.DrawText(formattedName_, namePoint_);
 }
コード例 #56
0
        public void Draw(TextView textView, System.Windows.Media.DrawingContext drawingContext)
        {
            if (column < 1)
            {
                return;
            }
            double offset     = textView.WideSpaceWidth * column;
            Size   pixelSize  = PixelSnapHelpers.GetPixelSize(textView);
            double markerXPos = PixelSnapHelpers.PixelAlign(offset, pixelSize.Width);
            Point  start      = new Point(markerXPos, 0);
            Point  end        = new Point(markerXPos, Math.Max(textView.DocumentHeight, textView.ActualHeight));

            drawingContext.DrawLine(pen, start, end);
        }
コード例 #57
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            Pen pen = new Pen(Stroke, Thickness)
            {
                StartLineCap = PenLineCap.Round,
                EndLineCap   = PenLineCap.Round
            };

            Point start = new Point(X1, Y1);
            Point end   = new Point(X2, Y2);

            double alpha = Math.Atan2(start.Y - end.Y, end.X - start.X);
            double theta = Math.PI - alpha;
            double zet   = theta - Math.PI / 2;
            //double headWidthY = Math.Sin(zet) * (2 + InvertedThickness);
            //double headWidthX = Math.Cos(zet) * (2 + InvertedThickness);
            double headHeightY = Math.Cos(zet) * (InvertedThickness + Thickness / 2);
            double headHeightX = Math.Sin(zet) * (InvertedThickness + Thickness / 2);

            if (IsStartInverted)
            {
                Point startCenter = new Point(start.X, start.Y);

                startCenter.X += headHeightX;
                startCenter.Y -= headHeightY;

                start.X += 2 * headHeightX;
                start.Y -= 2 * headHeightY;

                drawingContext.DrawEllipse(null, pen, new Point(startCenter.X, startCenter.Y), InvertedThickness, InvertedThickness);
            }

            if (IsEndInverted)
            {
                Point endCenter = new Point(end.X, end.Y);

                endCenter.X -= headHeightX;
                endCenter.Y += headHeightY;

                end.X -= 2 * headHeightX;
                end.Y += 2 * headHeightY;

                drawingContext.DrawEllipse(null, pen, new Point(endCenter.X, endCenter.Y), InvertedThickness, InvertedThickness);
            }

            drawingContext.DrawLine(pen, start, end);

            //System.Diagnostics.Debug.Print("[{0}] CustomLineElement OnRender", DateTime.Now);
        }
コード例 #58
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            Point startPoint;
            Point endPoint;

            if (_drawHorizontal)
            {
                DetermineHorizontalLinePoints(out startPoint, out endPoint);
            }
            else
            {
                DetermineVerticalLinePoints(out startPoint, out endPoint);
            }

            drawingContext.DrawLine(_pen, startPoint, endPoint);
        }
コード例 #59
0
        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)
            {
                foreach (var i in model.SoundIntervals)
                {
                    if (!i.HasVoice)
                    {
                        DrawLine(drawingContext, border, i.StartTime, i.EndTime, RowHeight - 3);
                    }
                }
            }

            if (editorModel.WindowState.CurrentMode == EditorModes.Border && model.Borders != null)
            {
                foreach (var e in model.Borders)
                {
                    DrawLine(drawingContext, border, e.StartTime, e.EndTime, 3);
                }
            }

            if (editorModel.WindowState.CurrentMode == EditorModes.Fixes)
            {
                foreach (var e in model.SubtitleFixes)
                {
                    DrawLine(drawingContext, fixes, e.StartTime, e.StartTime + e.Length, RowHeight / 2);
                }
            }
        }
コード例 #60
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            _scopeBrush = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            Pen _scopePen = new Pen(_scopeBrush, 1d);


            CustomNeedle customNeedle = Visual as CustomNeedle;

            if (customNeedle != null)
            {
                drawingContext.DrawImage(_bgplate_image, _bgplate_imageRect);

                drawingContext.PushTransform(new RotateTransform(customNeedle.KnobRotation, _center.X, _center.Y));
                drawingContext.DrawImage(_image, _imageRect);
                drawingContext.DrawLine(_scopePen, _center, _punto); //draw rotation point for reference
                drawingContext.Pop();
            }
        }