コード例 #1
0
        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
        {
            foreach (Visual child in visualChildren)
            {
                DrawingVisualPlus drawingVisual = child as DrawingVisualPlus;

                if (drawingVisual != null)
                {
                    TranslateTransform xform = drawingVisual.Transform as TranslateTransform;

                    if (xform != null)
                    {
                        if (sizeInfo.WidthChanged)
                        {
                            xform.X = sizeInfo.NewSize.Width * (drawingVisual.DataPoint.Coordinate.X / ContourScale + XOffset);
                        }

                        if (sizeInfo.HeightChanged)
                        {
                            xform.Y = sizeInfo.NewSize.Height * (drawingVisual.DataPoint.Coordinate.Y / ContourScale + YOffset);
                        }
                    }
                }
            }
            base.OnRenderSizeChanged(sizeInfo);
        }
コード例 #2
0
        protected void CreateVisualChild(CoordinateFeaturePoint point)
        {
            RebuildHighlightBrush();

            DrawingVisualPlus drawingVisual = new DrawingVisualPlus();

            drawingVisual.DataPoint = point;
            DrawingContext dc = drawingVisual.RenderOpen();

            if (point.IsEmpty || point.Coordinate.IsEmpty)
            {
                return;
            }

            switch (point.Coordinate.Type)
            {
            //    case PointType.Chopping:
            //        dc.DrawEllipse(Brushes[1], null, new System.Windows.Point(point.Coordinate.X / ContourScale + XOffset, point.Y / ContourScale + YOffset), PointSize, PointSize);
            //        break;

            //    case PointType.Feature:
            //        dc.DrawEllipse(Brushes[2], null, new System.Windows.Point(point.Coordinate.X / ContourScale + XOffset, point.Y / ContourScale + YOffset), FeaturePointSize, FeaturePointSize);
            //        break;

            case PointType.FeatureMoving:
                dc.DrawEllipse(Brushes[1], null, new System.Windows.Point(point.Coordinate.X / ContourScale + XOffset, point.Coordinate.Y / ContourScale + YOffset), PointSize, PointSize);
                break;

            case PointType.Normal:
            default:
                dc.DrawEllipse(Brushes[2], null, new System.Windows.Point(point.Coordinate.X / ContourScale + XOffset, point.Coordinate.Y / ContourScale + YOffset), FeaturePointSize, FeaturePointSize);
                dc.DrawEllipse(HighlightBrush, null, new System.Windows.Point(point.Coordinate.X / ContourScale + XOffset, point.Coordinate.Y / ContourScale + YOffset), HighlightPointSize, HighlightPointSize);

                if (!string.IsNullOrEmpty(point.Name))
                {
                    FormattedText formattedText = new FormattedText(
                        point.Name,
                        CultureInfo.GetCultureInfo("en-us"),
                        FlowDirection.LeftToRight,
                        new Typeface("Arial"),
                        TextSize,
                        Brushes[0]);

                    dc.DrawText(formattedText,
                                new System.Windows.Point(point.Coordinate.X / ContourScale + XOffset - formattedText.Width / 2, point.Coordinate.Y / ContourScale + YOffset + formattedText.Height + HighlightPointSize / 2 + 1));
                }
                break;
            }

            dc.Close();

            visualChildren.Add(drawingVisual);
        }
コード例 #3
0
        //private void DrawMovingLines(CoordinateFeaturePoint dataPoint, DrawingContext dc)
        //{
        //    var pointIndex = ItemsSource.IndexOf(dataPoint);

        //    if (pointIndex >= 0)
        //    {
        //        if (pointIndex >= 1)
        //        {
        //            dc.DrawLine(Pens[0],
        //                new System.Windows.Point(ItemsSource[pointIndex - 1].X / ContourScale + XOffset, ItemsSource[pointIndex - 1].Y / ContourScale + YOffset),
        //                new System.Windows.Point(dataPoint.X / ContourScale + XOffset, dataPoint.Y / ContourScale));
        //        }

        //        if (pointIndex < ItemsSource.Count - 1)
        //        {
        //            dc.DrawLine(Pens[0],
        //                new System.Windows.Point(ItemsSource[pointIndex + 1].X / ContourScale + XOffset, ItemsSource[pointIndex + 1].Y / ContourScale + YOffset),
        //                new System.Windows.Point(dataPoint.X / ContourScale + XOffset, dataPoint.Y / ContourScale + YOffset));
        //        }
        //    }
        //}

        protected void RemoveVisualChildren(ICollection coll)
        {
LoopTop:
            foreach (object obj in coll)
            {
                DrawingVisualPlus point = obj as DrawingVisualPlus;

                if (point != null && point.DataPoint != null)
                {
                    RemoveVisualChild(point.DataPoint);
                    // Collection gets modified, so the foreach will throw an exception if we keep going like this
                    goto LoopTop;
                }
            }
        }
コード例 #4
0
ファイル: PointVisuals.cs プロジェクト: darwin-ec/darwin
        protected void CreateVisualChild(Darwin.Point point)
        {
            DrawingVisualPlus drawingVisual = new DrawingVisualPlus();

            drawingVisual.DataPoint = point;
            DrawingContext dc = drawingVisual.RenderOpen();

            switch (point.Type)
            {
            case PointType.Chopping:
                dc.DrawEllipse(Brushes[1], null, new System.Windows.Point(point.X / ContourScale + XOffset, point.Y / ContourScale + YOffset), PointSize, PointSize);
                break;

            case PointType.Feature:
                dc.DrawEllipse(Brushes[2], null, new System.Windows.Point(point.X / ContourScale + XOffset, point.Y / ContourScale + YOffset), FeaturePointSize, FeaturePointSize);
                break;

            case PointType.FeatureMoving:
                dc.DrawEllipse(Brushes[1], null, new System.Windows.Point(point.X / ContourScale + XOffset, point.Y / ContourScale + YOffset), FeaturePointSize, FeaturePointSize);
                break;

            case PointType.Normal:
            default:
                dc.DrawEllipse(Brushes[0], null, new System.Windows.Point(point.X / ContourScale + XOffset, point.Y / ContourScale + YOffset), PointSize, PointSize);
                break;
            }

            if (point.Type == PointType.Moving && Pens != null)
            {
                DrawMovingLines(point, dc);
            }

            //drawingVisual.Transform = new TranslateTransform(RenderSize.Width * dataPoint.X,
            //                                                 RenderSize.Height * dataPoint.Y);

            dc.Close();

            // If it's a feature point, add it, otherwise insert so the Feature points have
            // the highest ZIndex
            if (point.Type == PointType.Feature || point.Type == PointType.FeatureMoving)
            {
                visualChildren.Add(drawingVisual);
            }
            else
            {
                visualChildren.Insert(0, drawingVisual);
            }
        }
コード例 #5
0
        protected void RemoveVisualChild(CoordinateFeaturePoint point)
        {
            List <DrawingVisualPlus> removeList = new List <DrawingVisualPlus>();

            foreach (Visual child in visualChildren)
            {
                DrawingVisualPlus drawingVisual = child as DrawingVisualPlus;
                if (drawingVisual.DataPoint == point)
                {
                    removeList.Add(drawingVisual);
                    break;
                }
            }
            foreach (DrawingVisualPlus drawingVisual in removeList)
            {
                visualChildren.Remove(drawingVisual);
            }
        }
コード例 #6
0
        void CreateVisualChildren(ICollection coll)
        {
            foreach (object obj in coll)
            {
                Line line = obj as Line;

                DrawingVisualPlus drawingVisual = new DrawingVisualPlus();
                drawingVisual.Line = line;
                DrawingContext dc = drawingVisual.RenderOpen();

                PathGeometry geometry = new PathGeometry();
                PathFigure figure = new PathFigure();

                geometry.Figures.Add(figure);

                double dist = GetDistance(line.Start.X, line.End.X, line.Start.Y, line.End.Y);

                double scalar = 1;
                if (dist > MaxRange)
                    scalar = dist / MaxRange;

                figure.StartPoint = new System.Windows.Point(
                    (RenderSize.Width / 2) + (RenderSize.Width / 2) * line.Start.X/MaxRange,
                    (RenderSize.Height) - (RenderSize.Height) * line.Start.Y/MaxRange);

                figure.Segments.Add(new LineSegment(new System.Windows.Point(
                    (RenderSize.Width / 2) + (RenderSize.Width / 2) * line.End.X/MaxRange,
                    (RenderSize.Height) - (RenderSize.Height) * line.End.Y/MaxRange), true));

                dc.DrawGeometry(new SolidColorBrush(Color.FromArgb(255, 69, 255, 0)), new Pen(new SolidColorBrush(Color.FromArgb(255, 69, 255, 0)), 3), geometry);

                dc.Close();
                visualChildren.Add(drawingVisual);
            }
        }
コード例 #7
0
        /*Creates DrawingVisual to place point on plot*/
        void CreateVisualChildren(ICollection coll)
        {
            foreach (object obj in coll)
            {
                Models.Point dataPoint = obj as Models.Point;

                DrawingVisualPlus drawingVisual = new DrawingVisualPlus();
                drawingVisual.DataPoint = dataPoint;
                DrawingContext dc = drawingVisual.RenderOpen();

                dc.DrawEllipse(new SolidColorBrush(Color.FromArgb(255, 127, 255, 0)), null,
                    new System.Windows.Point(0, 0), 2, 2);

                drawingVisual.Transform = new TranslateTransform(
                    ((RenderSize.Width / 2) + (RenderSize.Width / 2) * dataPoint.X / MaxRange),
                    ((RenderSize.Height) - (RenderSize.Height) * dataPoint.Y / MaxRange));

                dc.Close();
                visualChildren.Add(drawingVisual);
            }
        }