private void PaintBackground()
        {
            var backgroundSquare = new GeometryDrawing(Brushes.Black, null, new RectangleGeometry(new Rect(0, 0, 100, 100)));

            var aGeometryGroup = new GeometryGroup();
            aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 50, 50)));
            aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(50, 50, 50, 50)));

            var checkerBrush = new LinearGradientBrush();
            checkerBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0));
            checkerBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 22, 0), 1.0));

            var checkers = new GeometryDrawing(checkerBrush, null, aGeometryGroup);

            var checkersDrawingGroup = new DrawingGroup();
            checkersDrawingGroup.Children.Add(backgroundSquare);
            checkersDrawingGroup.Children.Add(checkers);

            var myBrush = new DrawingBrush
            {
                Drawing = checkersDrawingGroup,
                Viewport = new Rect(0, 0, 0.02, 0.02),
                TileMode = TileMode.Tile,
                Opacity = 0.5
            };

            LayoutRoot.Background = myBrush;
        }
    /// <summary>
    /// Does a one off calculation of the geometry to be rendered
    /// </summary>
    private void CalculateGeometry() {

      if(_recalcGeometry) {
        Func<bool, int, StreamGeometry> buildGeometry = (bool isFilled, int pointIndex) => {
          StreamGeometry childGeometry = new StreamGeometry();
          using(StreamGeometryContext ctx = childGeometry.Open()) {
            // Break up into groups of 4
            ctx.BeginFigure(Points[pointIndex], isFilled, isFilled);
            for(int j = 0; j < 4; ++j) {
              ctx.LineTo(Points[pointIndex + j], !isFilled, true);
            }
            if(!isFilled) {
              ctx.LineTo(Points[pointIndex], !isFilled, true);
            }
          }
          return childGeometry;
        };

        _filledGeometry = _filledGeometry ?? new GeometryGroup();
        _unfilledGeometry = _unfilledGeometry ?? new GeometryGroup();

        _filledGeometry.Children.Clear();
        _unfilledGeometry.Children.Clear();
        if(Points.Count > 0) {
          for(int pointIndex = 0, colorIndex = 0; pointIndex < (Points.Count - 3); pointIndex += 4, colorIndex += 1) {
            _unfilledGeometry.Children.Add(buildGeometry(false, pointIndex));
            _filledGeometry.Children.Add(buildGeometry(true, pointIndex));
          }
        }
        _recalcGeometry = false;
      }
    }
        /// <summary>
        /// Creates a waveform image from a description's audio file. Uses the description.Waveform
        /// property to obtain the data for the waveform.
        /// </summary>
        /// <param name="description">Description to create waveform for.</param>
        /// <param name="bounds">Size of the image to create.</param>
        /// <param name="canvasWidth">The width of the canvas that will contain this image.</param>
        /// <returns>A bitmap of the description's waveform.</returns>
        public static RenderTargetBitmap CreateDescriptionWaveForm(Description description, Rect bounds,
            double canvasWidth)
        {
            if (bounds.Width <= 1 || bounds.Height <= 1)
                return null;

            if (description.Waveform == null)
                description.GenerateWaveForm();

            var drawingVisual = new DrawingVisual();

            using (var dc = drawingVisual.RenderOpen())
            {
                var data = description.Waveform.Data;

                double samplesPerPixel = Math.Max(data.Count / canvasWidth, 1);
                double middle = bounds.Height / 2;
                double yscale = middle;

                double samplesPerSecond = (description.Waveform.Header.SampleRate *
                    (description.Waveform.Header.BlockAlign / (double)description.Waveform.SampleRatio));

                var waveformLineGroup = new GeometryGroup();

                int endPixel = (int)bounds.Width;

                for (int pixel = 0; pixel <= endPixel; pixel++)
                {
                    double offsetTime = (description.Duration / (bounds.Width * Milliseconds.PerSecond))
                        * pixel;
                    double sampleStart = Math.Max(samplesPerSecond * offsetTime, 0);

                    if (sampleStart + samplesPerPixel < data.Count)
                    {
                        var range = data.GetRange((int)sampleStart, (int)samplesPerPixel);

                        double max = (double)range.Max() / short.MaxValue;
                        double min = (double)range.Min() / short.MaxValue;

                        waveformLineGroup.Children.Add(new LineGeometry
                        {
                            StartPoint = new Point(pixel, middle + max * yscale),
                            EndPoint = new Point(pixel, middle + min * yscale),
                        });
                    }
                }

                waveformLineGroup.Freeze();
                dc.DrawGeometry(Brushes.Black, LinePen, waveformLineGroup);
            }

            var bitmap = new RenderTargetBitmap((int)bounds.Width, (int)bounds.Height, DefaultDpi,
                DefaultDpi, PixelFormats.Pbgra32);
            bitmap.Render(drawingVisual);
            bitmap.Freeze();

            description.WaveformImage = bitmap;

            return bitmap;
        }
        public static void OnChartPointsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            WindChartControl charControl = d as WindChartControl;
            GeometryGroup myGeometryGroup = new GeometryGroup();
            var values = e.NewValue as List<IChartPoint>;

            double radius = 0;
            double lineRadius = charControl.DrawCanvas.ActualWidth / 2;
            double radiusStep = lineRadius / values.Count;
            // The center
            double lastX = (double)(charControl.DrawCanvas.ActualWidth / 2.0);
            double lastY = (double)(charControl.DrawCanvas.ActualHeight / 2.0);

            foreach (var value in values)
            {
                radius += radiusStep;

                double pointOffsetX = (charControl.DrawCanvas.ActualWidth - 2.0 * radius) / 2.0;
                double pointOffsetY = (charControl.DrawCanvas.ActualHeight - 2.0 * radius) / 2.0;

                double circleX = Math.Cos(GetAngleInRadian(value)) * radius;
                double circleY = Math.Sin(GetAngleInRadian(value)) * radius;

                float x = (float)(pointOffsetX + radius - circleX);
                float y = (float)(pointOffsetY + radius - circleY);

                myGeometryGroup.Children.Add(new LineGeometry() { StartPoint = new Point(lastX, lastY), EndPoint = new Point(x, y) });

                lastX = x;
                lastY = y;
            }

            (d as WindChartControl).LinePath.Data = myGeometryGroup;
        }
Ejemplo n.º 5
0
 private GeometryGroup buildGeometryGroup()
 {
     GeometryGroup group = new GeometryGroup();
     group.Children.Add(buildEllipse());
     group.Children.Add(buildText());
     return group;
 }
Ejemplo n.º 6
0
 public static XamlMedia.Geometry ToXaml(this MultiLineString multiLineString)
 {
     var group = new XamlMedia.GeometryGroup();
     foreach (LineString lineString in multiLineString)
         group.Children.Add(ToXaml(lineString));
     return group;
 }
Ejemplo n.º 7
0
 public static XamlMedia.GeometryGroup ToXaml(this MultiPolygon geometry)
 {
     var group = new XamlMedia.GeometryGroup();
     foreach (Polygon polygon in geometry.Polygons)
         group.Children.Add(polygon.ToXaml());
     return group;
 }
Ejemplo n.º 8
0
        GeometryDrawing CreateGeometryDrawing()
        {
            //http://msdn.microsoft.com/en-us/library/system.windows.media.geometrydrawing.aspx

            GeometryGroup ellipses = new GeometryGroup();
            ellipses.Children.Add(
                new EllipseGeometry(new Point(200, 200), 45, 20)
                );
            ellipses.Children.Add(
                new EllipseGeometry(new Point(200, 200), 20, 45)
                );

            GeometryDrawing aGeometryDrawing = new GeometryDrawing();
            aGeometryDrawing.Geometry = ellipses;

            // Paint the drawing with a gradient.
            aGeometryDrawing.Brush =
                new LinearGradientBrush(
                    Colors.Blue,
                    Color.FromRgb(204, 204, 255),
                    new Point(0, 0),
                    new Point(1, 1));

            return aGeometryDrawing;
        }
Ejemplo n.º 9
0
        public static Sm.Drawing ToGeometryDrawing(this Shape input)
        {
            Sm.GeometryDrawing geometryDrawing = new Sm.GeometryDrawing();
            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);
            }

            geometryDrawing.Geometry = drawing;
            geometryDrawing.Pen      = input.Graphic.Stroke.ToMediaPen();
            geometryDrawing.Brush    = input.Graphic.Fill.ToMediaBrush();

            Sm.DrawingGroup drawingGroup = new Sm.DrawingGroup();
            drawingGroup.Children.Add(geometryDrawing);

            return(drawingGroup);
        }
Ejemplo n.º 10
0
        public void Init()
        {
            DrawingGroup dg = new DrawingGroup();
            ImageDrawing id = new ImageDrawing(UnderlayImage, new Rect(0, 0, UnderlayImage.PixelWidth, UnderlayImage.PixelHeight));
            dg.Children.Add(id);

            pointsGeometryGroup = new GeometryGroup();
            linesGeometryGroup = new GeometryGroup();
            middlePointGeoGrp = new GeometryGroup();
            if (points != null)
            {
                SetPointsGeometry();
            }

            GeometryDrawing gd = new GeometryDrawing(Brushes.Blue, null, pointsGeometryGroup);
            dg.Children.Add(gd);

            GeometryDrawing gd2 = new GeometryDrawing(null, new Pen(Brushes.LightGreen,3), linesGeometryGroup);
            dg.Children.Add(gd2);

            GeometryDrawing gd1 = new GeometryDrawing(Brushes.Red, null, middlePointGeoGrp);
            dg.Children.Add(gd1);

            Brush b = new SolidColorBrush(Colors.Red);
            b.Opacity = 0.5;
            mousePointGeometryDrwaing = new GeometryDrawing(b, null, null);
            dg.Children.Add(mousePointGeometryDrwaing);

            DrawingImage di = new DrawingImage(dg);
            this.Source = di;

            chosenPoint = -1;
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        private Brush CreateARectangleWithDrawingBrush()
        {
            // Create a DrawingBrush
            DrawingBrush blackBrush = new DrawingBrush();
            // Create a Geometry with white background
            GeometryDrawing backgroundSquare =
                new GeometryDrawing(
                    Brushes.DarkGray,
                    null,
                    new RectangleGeometry(new Rect(0, 0, 400, 400)));

            // Create a GeometryGroup that will be added to Geometry
            GeometryGroup gGroup = new GeometryGroup();
            gGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 200, 200)));
            gGroup.Children.Add(new RectangleGeometry(new Rect(200, 200, 200, 200)));
            // Create a GeomertyDrawing
            GeometryDrawing checkers = new GeometryDrawing(new SolidColorBrush(Colors.Gray), null, gGroup);

            DrawingGroup checkersDrawingGroup = new DrawingGroup();
            checkersDrawingGroup.Children.Add(backgroundSquare);
            checkersDrawingGroup.Children.Add(checkers);

            blackBrush.Drawing = checkersDrawingGroup;

            // Set Viewport and TimeMode
            blackBrush.Viewport = new Rect(0, 0, 0.1, 0.2);
            blackBrush.TileMode = TileMode.Tile;

            return blackBrush;
        }
Ejemplo n.º 13
0
        //==========================================================================
        public Geometry GetClipGeometry()
        {
            GeometryGroup geometry_group = new GeometryGroup();

              foreach(SvgBaseElement child_element in Children)
              {
            SvgBaseElement element = child_element;
            if(element is SvgUseElement)
              element = (element as SvgUseElement).GetElement();

            if(element is SvgDrawableBaseElement)
            {
              Geometry geometry = (element as SvgDrawableBaseElement).GetGeometry();
              if(geometry != null)
            geometry_group.Children.Add(geometry);
            }
            else if(element is SvgDrawableContainerBaseElement)
            {
              Geometry geometry = (element as SvgDrawableContainerBaseElement).GetGeometry();
              if(geometry != null)
            geometry_group.Children.Add(geometry);
            }
              }

              return geometry_group;
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Returns the flattened geometry for the argument vertex. It does not take the transforms on the vertex into account.
 /// </summary>
 /// <param name="v"></param>
 /// <returns></returns>
 private static PathGeometry BuildVertexGeometry(Visual v)
 {
     GeometryGroup fromGeometry = new GeometryGroup();
     fromGeometry.FillRule = FillRule.Nonzero;
     WalkChildren((Visual)v, fromGeometry);
     PathGeometry fromGeometryFlat = fromGeometry.GetFlattenedPathGeometry();
     return fromGeometryFlat;
 }
Ejemplo n.º 15
0
 public GoodShapesCollection(Bound b, GoodShape[] shapes )
     : base(b)
 {
     this.shapes.AddRange(shapes);
     geometry = new GeometryGroup();
     foreach (GoodShape s in shapes)
         ((GeometryGroup)geometry).Children.Add(s.geometry);
 }
Ejemplo n.º 16
0
		protected override Geometry CreateGeometry()
		{
			GeometryGroup group = new GeometryGroup();
			group.Children.Add(new LineGeometry(new Point(0, 0), new Point(1, 1)));
			group.Children.Add(new LineGeometry(new Point(0, 1), new Point(1, 0)));

			return group;
		}
Ejemplo n.º 17
0
 public static XamlMedia.GeometryGroup ToXaml(this Polygon polygon)
 {
     var group = new XamlMedia.GeometryGroup();
     group.FillRule = XamlMedia.FillRule.EvenOdd;
     group.Children.Add(polygon.ExteriorRing.ToXaml());
     group.Children.Add(polygon.InteriorRings.ToXaml());
     return group;
 }
Ejemplo n.º 18
0
        public static XamlMedia.GeometryGroup ToXaml(this Polygon polygon)
        {
            var group = new XamlMedia.GeometryGroup();

            group.FillRule = XamlMedia.FillRule.EvenOdd;
            group.Children.Add(polygon.ExteriorRing.ToXaml());
            group.Children.Add(polygon.InteriorRings.ToXaml());
            return(group);
        }
Ejemplo n.º 19
0
 public static GeometryGroup GetProviderVector()
 {
     if (_geometryGroup == null)
     {
         _geometryGroup = new GeometryGroup();
         _geometryGroup.Children.Add((Geometry)Application.Current.Resources["VectorGrooveshark"]);
     }
     return _geometryGroup;
 }
Ejemplo n.º 20
0
        protected override void HandleDragOver(sw.DragEventArgs e, DragEventArgs args)
        {
            var lastRow = LastDragRow;

            base.HandleDragOver(e, args);
            var info = LastDragInfo = GetDragInfo(args);

            if (args.Effects != DragEffects.None)
            {
                // show drag indicator!
                var row = GetDataGridRow(GetItemAtRow(info.Index));
                if (row != null)
                {
                    // same position, just return
                    if (lastRow != null && lastRow.IsEqual(row, info.InsertIndex))
                    {
                        return;
                    }

                    lastRow?.Revert();
                    LastDragRow = new GridDragRowState(row, info.InsertIndex);

                    if (info.InsertIndex == -1)
                    {
                        row.Background = sw.SystemColors.HighlightBrush;
                        row.Foreground = sw.SystemColors.HighlightTextBrush;
                    }
                    else
                    {
                        var d  = new swm.GeometryDrawing();
                        var gg = new swm.GeometryGroup();
                        gg.Children.Add(new swm.LineGeometry(new sw.Point(0, 0), new sw.Point(row.ActualWidth, 0)));
                        d.Geometry = gg;
                        d.Brush    = sw.SystemColors.HighlightBrush;
                        d.Pen      = new swm.Pen(sw.SystemColors.HighlightBrush, 1);
                        var b = new swm.DrawingBrush {
                            Drawing = d, TileMode = swm.TileMode.None, Stretch = swm.Stretch.None, AlignmentX = swm.AlignmentX.Left
                        };
                        if (info.InsertIndex == row.GetIndex())
                        {
                            b.AlignmentY        = swm.AlignmentY.Top;
                            row.BorderThickness = new sw.Thickness(0, 1, 0, 0);
                        }
                        else
                        {
                            b.AlignmentY        = swm.AlignmentY.Bottom;
                            row.BorderThickness = new sw.Thickness(0, 0, 0, 1);
                        }

                        row.BorderBrush = b;
                    }
                    return;
                }
            }

            ResetDrag();
        }
Ejemplo n.º 21
0
        private static XamlMedia.GeometryGroup ConvertMultiPoint(MultiPoint multiPoint, SymbolStyle style, IViewport viewport)
        {
            var group = new XamlMedia.GeometryGroup();

            foreach (Point point in multiPoint)
            {
                group.Children.Add(ConvertSymbol(point, style, viewport));
            }
            return(group);
        }
Ejemplo n.º 22
0
        public static XamlMedia.Geometry ToXaml(this MultiLineString multiLineString)
        {
            var group = new XamlMedia.GeometryGroup();

            foreach (LineString lineString in multiLineString)
            {
                group.Children.Add(ToXaml(lineString));
            }
            return(group);
        }
Ejemplo n.º 23
0
        public static XamlMedia.GeometryGroup ToXaml(this MultiPolygon geometry)
        {
            var group = new XamlMedia.GeometryGroup();

            foreach (Polygon polygon in geometry.Polygons)
            {
                group.Children.Add(polygon.ToXaml());
            }
            return(group);
        }
        /// <summary>
        /// Builds a geometry group for the given visual taking into account the transform, clip and enumerating the drawings.
        /// </summary>
        /// <param name="myVisual"></param>
        /// <param name="g"></param>
        private static void EnumVisual(Visual myVisual, GeometryGroup g)
        {
            GeometryGroup currentParent = g;
            Matrix m = GetVisualTransform(myVisual);
            MatrixTransform mt = new MatrixTransform();
            mt.Matrix = m;
            currentParent.Transform = mt;

            Geometry clip = VisualTreeHelper.GetClip(myVisual);
            if (clip != null)
            {
                CombinedGeometry combinedGeometry = new CombinedGeometry();
                combinedGeometry.GeometryCombineMode = GeometryCombineMode.Intersect;
                combinedGeometry.Geometry1 = clip;
                GeometryGroup child = new GeometryGroup();
                child.FillRule = FillRule.Nonzero;
                combinedGeometry.Geometry2 = child;
                currentParent.Children.Add(combinedGeometry);
                currentParent = (GeometryGroup)combinedGeometry.Geometry2;
            }

            DrawingGroup dg = VisualTreeHelper.GetDrawing(myVisual);
            if (dg != null)
            {
                if (dg.Transform != null)
                {
                    if (currentParent.Transform != null)
                    {
                        Matrix compositeTransform = new Matrix();
                        compositeTransform = Matrix.Multiply(currentParent.Transform.Value, dg.Transform.Value);
                        MatrixTransform matrixtransform = new MatrixTransform(compositeTransform);
                        currentParent.Transform = matrixtransform;
                    }
                    else
                    {
                        currentParent.Transform = dg.Transform;
                    }
                }

                if (dg.ClipGeometry != null)
                {
                    CombinedGeometry combinedGeometry = new CombinedGeometry();
                    combinedGeometry.GeometryCombineMode = GeometryCombineMode.Intersect;
                    combinedGeometry.Geometry1 = dg.ClipGeometry;
                    GeometryGroup child = new GeometryGroup();
                    child.FillRule = FillRule.Nonzero;
                    combinedGeometry.Geometry2 = child;
                    currentParent.Children.Add(combinedGeometry);
                    currentParent = (GeometryGroup)combinedGeometry.Geometry2;
                }
                EnumerateDrawingGroup(dg, currentParent);
            }
            WalkChildren(myVisual, currentParent);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Walks the children of a visual to build a geometry tree. Ignores the transform and clip on the visual.
 /// </summary>
 /// <param name="v"></param>
 /// <param name="g"></param>
 private static void WalkChildren(Visual v, GeometryGroup g)
 {
     for (int i = 0; i < VisualTreeHelper.GetChildrenCount(v); i++)
     {
         Visual visualChild = (Visual)VisualTreeHelper.GetChild(v, i);
         GeometryGroup child = new GeometryGroup();
         child.FillRule = FillRule.Nonzero;
         g.Children.Add(child);
         EnumVisual(visualChild, child);
     }
 }
Ejemplo n.º 26
0
 public static Brush GetGridTileBrush(double size, Brush Color)
 {
     DrawingBrush b = new DrawingBrush();
       GeometryGroup gg = new GeometryGroup();
       gg.Children.Add(new LineGeometry(new Point(0.5, 0), new Point(0.5, size)));
       gg.Children.Add(new LineGeometry(new Point(1, 0.5), new Point(size, 0.5)));
       b.Drawing = new GeometryDrawing(null, new Pen(Color, 1), gg);
       b.Viewport = new Rect(0, 0, size, size);
       b.ViewportUnits = BrushMappingMode.Absolute;
       b.TileMode = TileMode.Tile;
       return b;
 }
Ejemplo n.º 27
0
        public MainWindow()
        {
            InitializeComponent();

            string[] ports = System.IO.Ports.SerialPort.GetPortNames();
            for (int i = 0; i < ports.Length; i++)
                comboBox.Items.Add(ports[i]);
            comboBox.Text = ports[0];

            serial.BaudRate = 115200;
            serial.Handshake = System.IO.Ports.Handshake.None;
            serial.Parity = Parity.None;
            serial.DataBits = 8;
            serial.StopBits = StopBits.One;
            serial.ReadTimeout = 200;
            serial.WriteTimeout = 50;
            serial.DataReceived += new SerialDataReceivedEventHandler(Recieve);

            const double xmin = 10;
            const double step = 10;
            xmax = canvas.Width - xmin;
            ymax = canvas.Height - xmin;
            
            // Make the X axis.
            GeometryGroup xaxis_geom = new GeometryGroup();
            xaxis_geom.Children.Add(new LineGeometry(new Point(0, ymax/2), new Point(canvas.Width, ymax/2)));
            for (double x = step; x <= canvas.Width - step; x += step)
            {
                xaxis_geom.Children.Add(new LineGeometry(new Point(x, ymax / 2 - xmin / 2), new Point(x, ymax / 2 + xmin / 2)));
            }
            Path xaxis_path = new Path();
            xaxis_path.StrokeThickness = 1;
            xaxis_path.Stroke = Brushes.Black;
            xaxis_path.Data = xaxis_geom;
            canvas.Children.Add(xaxis_path);

            // Make the Y axis.
            GeometryGroup yaxis_geom = new GeometryGroup();
            yaxis_geom.Children.Add(new LineGeometry(new Point(xmax/2, 0), new Point(xmax/2, canvas.Height)));
            for (double y = step; y <= canvas.Height - step; y += step)
            {
                yaxis_geom.Children.Add(new LineGeometry(new Point(xmax/2 - xmin / 2, y), new Point(xmax/2 + xmin / 2, y)));
            }
            Path yaxis_path = new Path();
            yaxis_path.StrokeThickness = 1;
            yaxis_path.Stroke = Brushes.Black;
            yaxis_path.Data = yaxis_geom;
            canvas.Children.Add(yaxis_path);

            polyline.StrokeThickness = 1;
            polyline.Stroke = Brushes.Green;
            canvas.Children.Add(polyline);
        }
Ejemplo n.º 28
0
    void BuildDrawing()
    {
      this.drawing = new GeometryDrawing();

      // Use geometries to describe two overlapping ellipses.
      EllipseGeometry ellipse1 = new EllipseGeometry();
      ellipse1.RadiusX = 20;
      ellipse1.RadiusY = 45;
      ellipse1.Center = new Point(50, 50);
      EllipseGeometry ellipse2 = new EllipseGeometry();
      ellipse2.RadiusX = 45;
      ellipse2.RadiusY = 20;
      ellipse2.Center = new Point(50, 50);
      GeometryGroup ellipses = new GeometryGroup();
      ellipses.Children.Add(ellipse1);
      ellipses.Children.Add(ellipse2);

      // Add the geometry to the drawing.
      this.drawing.Geometry = ellipses;

      // Specify the drawing's fill.
      this.drawing.Brush = Brushes.Blue;

      // Specify the drawing's stroke.
      Pen stroke = new Pen();
      stroke.Thickness = 10.0;
      stroke.Brush = new LinearGradientBrush(
          Colors.Black, Colors.Gray, new Point(0, 0), new Point(1, 1));
      this.drawing.Pen = stroke;

      // Create a DrawingBrush
      DrawingBrush myDrawingBrush = new DrawingBrush();
      myDrawingBrush.Drawing = this.drawing;

      // Create a Rectangle element.
      Rectangle aRectangle = new Rectangle();
      aRectangle.Width = 150;
      aRectangle.Height = 150;
      aRectangle.Stroke = Brushes.Black;
      aRectangle.StrokeThickness = 1.0;

      // Use the DrawingBrush to paint the rectangle's
      // background.
      aRectangle.Fill = myDrawingBrush;

      StackPanel mainPanel = new StackPanel();
      mainPanel.Children.Add(aRectangle);

      mainPanel.Arrange(new Rect(100, 100, 500, 500));
      //this.drawing2 = mainPanel;
      //this.Content = mainPanel;
    }
Ejemplo n.º 29
0
        int[,] tableIndex; //存储每个点对应的表和序号 0是表 1是序号

        #endregion Fields

        #region Constructors

        /// <summary>
        /// 未初始化严禁使用
        /// </summary>
        public DataGraphGeometry()
        {
            graphID = -1;
            nodeNo = tableNo = 0;
            graphName = null;
            edges = new GeometryGroup();
            tables = new ArrayList();
            dataGraphShape = new PathGeometry();
            dataGraphLine = new PathGeometry();
            steinertreeShape = new PathGeometry();
            steinertreeLine = new PathGeometry();
            tableIndex = null;
        }
Ejemplo n.º 30
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            EllipseGeometry ellipse = new EllipseGeometry(new Point(350, 50), 50, 20);
            RectangleGeometry rect = new RectangleGeometry(new Rect(350, 50, 50, 20), 5, 5);

            GeometryGroup group = new GeometryGroup();
            group.Children.Add(ellipse);
            group.Children.Add(rect);
            group.FillRule = FillRule.EvenOdd;
            drawingContext.DrawGeometry(Brushes.Black, new Pen(Brushes.Aqua, 3), group);
        }
 public FunctionPlotter()
 {
     // Initialize the path and its geometry. It will be filled
     // with the data to be plotted
     _geometry = new GeometryGroup();
     _path = new Path()
     {
         Data = _geometry,
         Stroke = WhiteBrush,
         StrokeThickness = 1
     };
     Children.Add(_path);
 }
Ejemplo n.º 32
0
        public Drawing Teken_jezelf()
        {
            var lijnen = new GeometryGroup();

            lijnen.Children.Add(Tekening);

            var drawing = new GeometryDrawing
                {
                    Geometry = lijnen,
                    Pen = new Pen(_brush, 1),
                    Brush = _brush
                };

            return drawing;
        }
Ejemplo n.º 33
0
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();

			linesPath = (Path)Template.FindName("PART_LinesPath", this);
			GeometryGroup linesGroup = new GeometryGroup();
			linesGroup.Children.Add(lineGeometry1);
			linesGroup.Children.Add(lineGeometry2);
			linesPath.Data = linesGroup;

			rectPath = (Path)Template.FindName("PART_RectPath", this);
			rectPath.Data = rectGeometry;

			partsLoaded = true;
		}
        static void OnDataChanged(DependencyObject source, DependencyPropertyChangedEventArgs args)
        {
            var path = source as Path;
            GeometryGroup pathGeometry = source as GeometryGroup;
            if(path != null)
            {
                pathGeometry = new GeometryGroup();
                path.Data = pathGeometry;
            }

            if(pathGeometry != null)
            {
                var processing = new ProcessingContext(pathGeometry);
                processing.Execute(args.NewValue as string);
            }
        }
Ejemplo n.º 35
0
        private void DrawHorisontalLines(Point leftTop, Point rightBottom, double step, Path path)
        {
            double y = leftTop.Y;
            var geometryGroup = new GeometryGroup();

            while (y <= rightBottom.Y)
            {
                var geom = new LineGeometry(new Point(leftTop.X, rightBottom.Y - y), new Point(rightBottom.X, rightBottom.Y - y));
                geometryGroup.Children.Add(geom);
                y += step;
            }
            if (path.Data != null)
                geometryGroup.Children.Add(path.Data);

            path.Data = geometryGroup;
        }
Ejemplo n.º 36
0
        private void DrawVerticalLines(Point leftTop, Point rightBottom, double step, Path path)
        {
            double x = leftTop.X;
            var geometryGroup = new GeometryGroup();

            while (x <= rightBottom.X)
            {
                var geom = new LineGeometry(new Point(x, leftTop.Y), new Point(x, rightBottom.Y));
                geometryGroup.Children.Add(geom);
                x += step;
            }
            if (path.Data != null)
                geometryGroup.Children.Add(path.Data);

            path.Data = geometryGroup;
        }
Ejemplo n.º 37
0
 /// <summary>
 /// Construct an HapticPolyline
 /// </summary>
 /// <param name="points"></param>
 public HapticPolyline(List<System.Windows.Point> points)
 {
     _points = new List<Point>();
     // Use Input_API points
     foreach (System.Windows.Point point in points)
     {
         _points.Add(new Point(point.X, point.Y));
     }
     GeometryGroup group = new GeometryGroup();
     for (int i = 0; i < _points.Count() - 1; i++)
     {
         group.Children.Add(new LineGeometry(_points[i].toSysWinPoint(),
            _points[i + 1].toSysWinPoint()));
     }
     this.geometry = group;
 }
Ejemplo n.º 38
0
        public void DrawWave(Path form)
        {
            var w       = (int)form.ActualWidth;
            var h       = (int)form.ActualHeight;
            var columns = GetColumns(w, h);
            var group   = new System.Windows.Media.GeometryGroup();

            var mid = h / 2;

            for (var i = 0; i < columns.Length; i++)
            {
                var start = new Point(i, mid - columns[i] / 2);
                var end   = new Point(i, mid + columns[i] / 2);
                var line  = new System.Windows.Media.LineGeometry(start, end);
                group.Children.Add(line);
            }

            form.Data = group;
        }
Ejemplo n.º 39
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.mywindow = ((Wpf_ge.MainWindow)(target));

            #line 6 "..\..\MainWindow.xaml"
                this.mywindow.Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.panels = ((System.Windows.Controls.DockPanel)(target));
                return;

            case 3:

            #line 10 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.NewForm);

            #line default
            #line hidden
                return;

            case 4:

            #line 11 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.openxml);

            #line default
            #line hidden
                return;

            case 5:

            #line 12 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.saveasxml);

            #line default
            #line hidden
                return;

            case 6:

            #line 13 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.saveasimagedialog);

            #line default
            #line hidden
                return;

            case 7:

            #line 15 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.ExportToFigaro);

            #line default
            #line hidden
                return;

            case 8:

            #line 17 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.ExitWindow);

            #line default
            #line hidden
                return;

            case 9:

            #line 20 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.IsDirectMode);

            #line default
            #line hidden
                return;

            case 10:

            #line 21 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Add_Node);

            #line default
            #line hidden
                return;

            case 11:

            #line 22 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Add_Edge);

            #line default
            #line hidden
                return;

            case 12:
                this.canvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 13:

            #line 28 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Add_Node);

            #line default
            #line hidden
                return;

            case 14:
                this.connectors = ((System.Windows.Media.GeometryGroup)(target));
                return;

            case 15:
                this.Node1 = ((Wpf_ge.Node)(target));
                return;

            case 16:

            #line 42 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Add_Edge);

            #line default
            #line hidden
                return;

            case 17:

            #line 43 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Edit_Dialog);

            #line default
            #line hidden
                return;

            case 18:

            #line 44 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Delete_Node);

            #line default
            #line hidden
                return;

            case 19:
                this.Node2 = ((Wpf_ge.Node)(target));
                return;

            case 20:

            #line 51 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Add_Edge);

            #line default
            #line hidden
                return;

            case 21:

            #line 52 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Edit_Dialog);

            #line default
            #line hidden
                return;

            case 22:

            #line 53 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Delete_Node);

            #line default
            #line hidden
                return;

            case 23:
                this.Node3 = ((Wpf_ge.Node)(target));
                return;

            case 24:

            #line 61 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Add_Edge);

            #line default
            #line hidden
                return;

            case 25:

            #line 62 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Edit_Dialog);

            #line default
            #line hidden
                return;

            case 26:

            #line 63 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Delete_Node);

            #line default
            #line hidden
                return;

            case 27:
                this.Node4 = ((Wpf_ge.Node)(target));
                return;

            case 28:

            #line 71 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Add_Edge);

            #line default
            #line hidden
                return;

            case 29:

            #line 72 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Edit_Dialog);

            #line default
            #line hidden
                return;

            case 30:

            #line 73 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.Delete_Node);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 40
0
        private static void ChildrenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // The first change to the default value of a mutable collection property (e.g. GeometryGroup.Children)
            // will promote the property value from a default value to a local value. This is technically a sub-property
            // change because the collection was changed and not a new collection set (GeometryGroup.Children.
            // Add versus GeometryGroup.Children = myNewChildrenCollection). However, we never marshalled
            // the default value to the compositor. If the property changes from a default value, the new local value
            // needs to be marshalled to the compositor. We detect this scenario with the second condition
            // e.OldValueSource != e.NewValueSource. Specifically in this scenario the OldValueSource will be
            // Default and the NewValueSource will be Local.
            if (e.IsASubPropertyChange &&
                (e.OldValueSource == e.NewValueSource))
            {
                return;
            }


            GeometryGroup target = ((GeometryGroup)d);


            // If this is both non-null and mutable, we need to unhook the Changed event.
            GeometryCollection oldCollection = null;
            GeometryCollection newCollection = null;

            if ((e.OldValueSource != BaseValueSourceInternal.Default) || e.IsOldValueModified)
            {
                oldCollection = (GeometryCollection)e.OldValue;
                if ((oldCollection != null) && !oldCollection.IsFrozen)
                {
                    oldCollection.ItemRemoved  -= target.ChildrenItemRemoved;
                    oldCollection.ItemInserted -= target.ChildrenItemInserted;
                }
            }

            // If this is both non-null and mutable, we need to hook the Changed event.
            if ((e.NewValueSource != BaseValueSourceInternal.Default) || e.IsNewValueModified)
            {
                newCollection = (GeometryCollection)e.NewValue;
                if ((newCollection != null) && !newCollection.IsFrozen)
                {
                    newCollection.ItemInserted += target.ChildrenItemInserted;
                    newCollection.ItemRemoved  += target.ChildrenItemRemoved;
                }
            }
            if (oldCollection != newCollection && target.Dispatcher != null)
            {
                using (CompositionEngineLock.Acquire())
                {
                    DUCE.IResource targetResource = (DUCE.IResource)target;
                    int            channelCount   = targetResource.GetChannelCount();

                    for (int channelIndex = 0; channelIndex < channelCount; channelIndex++)
                    {
                        DUCE.Channel channel = targetResource.GetChannel(channelIndex);
                        Debug.Assert(!channel.IsOutOfBandChannel);
                        Debug.Assert(!targetResource.GetHandle(channel).IsNull);
                        // resource shouldn't be null because
                        // 1) If the field is one of our collections, we don't allow null elements
                        // 2) Codegen already made sure the collection contains DUCE.IResources
                        // ... so we'll Assert it

                        if (newCollection != null)
                        {
                            int count = newCollection.Count;
                            for (int i = 0; i < count; i++)
                            {
                                DUCE.IResource resource = newCollection.Internal_GetItem(i) as DUCE.IResource;
                                Debug.Assert(resource != null);
                                resource.AddRefOnChannel(channel);
                            }
                        }

                        if (oldCollection != null)
                        {
                            int count = oldCollection.Count;
                            for (int i = 0; i < count; i++)
                            {
                                DUCE.IResource resource = oldCollection.Internal_GetItem(i) as DUCE.IResource;
                                Debug.Assert(resource != null);
                                resource.ReleaseOnChannel(channel);
                            }
                        }
                    }
                }
            }
            target.PropertyChanged(ChildrenProperty);
        }
Ejemplo n.º 41
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.imgPhoto = ((System.Windows.Controls.Image)(target));
                return;

            case 2:
                this.geometryGroepFull = ((System.Windows.Media.GeometryGroup)(target));
                return;

            case 3:
                this.croppedImg = ((System.Windows.Controls.Image)(target));
                return;

            case 4:
                this.geometryGroepCrop = ((System.Windows.Media.GeometryGroup)(target));
                return;

            case 5:
                this.raidLevelsBox = ((System.Windows.Controls.ComboBox)(target));

            #line 44 "..\..\MainWindow.xaml"
                this.raidLevelsBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.RaidLevelsBox_SelectionChanged);

            #line default
            #line hidden
                return;

            case 6:
                this.gymColorsBox = ((System.Windows.Controls.ComboBox)(target));

            #line 49 "..\..\MainWindow.xaml"
                this.gymColorsBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.GymColorsBox_SelectionChanged);

            #line default
            #line hidden
                return;

            case 7:
                this.btnLoad = ((System.Windows.Controls.Button)(target));

            #line 53 "..\..\MainWindow.xaml"
                this.btnLoad.Click += new System.Windows.RoutedEventHandler(this.btnLoad_Click);

            #line default
            #line hidden
                return;

            case 8:
                this.btnGuess = ((System.Windows.Controls.Button)(target));

            #line 56 "..\..\MainWindow.xaml"
                this.btnGuess.Click += new System.Windows.RoutedEventHandler(this.btnGuess_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 42
0
        public static WMedia.Geometry ToWindows(this Geometry geometry)
        {
            WMedia.Geometry wGeometry = null;

            if (geometry is LineGeometry)
            {
                LineGeometry lineGeometry = geometry as LineGeometry;
                wGeometry = new WMedia.LineGeometry
                {
                    StartPoint = lineGeometry.StartPoint.ToWindows(),
                    EndPoint   = lineGeometry.EndPoint.ToWindows()
                };
            }
            else if (geometry is RectangleGeometry)
            {
                var rect = (geometry as RectangleGeometry).Rect;
                wGeometry = new WMedia.RectangleGeometry
                {
                    Rect = new WFoundation.Rect(rect.X, rect.Y, rect.Width, rect.Height)
                };
            }
            else if (geometry is EllipseGeometry)
            {
                EllipseGeometry ellipseGeometry = geometry as EllipseGeometry;
                wGeometry = new WMedia.EllipseGeometry
                {
                    Center  = ellipseGeometry.Center.ToWindows(),
                    RadiusX = ellipseGeometry.RadiusX,
                    RadiusY = ellipseGeometry.RadiusY
                };
            }
            else if (geometry is GeometryGroup)
            {
                GeometryGroup geometryGroup = geometry as GeometryGroup;
                wGeometry = new WMedia.GeometryGroup
                {
                    FillRule = ConvertFillRule(geometryGroup.FillRule)
                };

                foreach (Geometry children in geometryGroup.Children)
                {
                    WMedia.Geometry winChild = children.ToWindows();
                    (wGeometry as WMedia.GeometryGroup).Children.Add(winChild);
                }
            }
            else if (geometry is PathGeometry)
            {
                PathGeometry pathGeometry = geometry as PathGeometry;

                WMedia.PathGeometry wPathGeometry = new WMedia.PathGeometry
                {
                    FillRule = ConvertFillRule(pathGeometry.FillRule)
                };

                foreach (PathFigure xamPathFigure in pathGeometry.Figures)
                {
                    WMedia.PathFigure wPathFigure = new WMedia.PathFigure
                    {
                        StartPoint = xamPathFigure.StartPoint.ToWindows(),
                        IsFilled   = xamPathFigure.IsFilled,
                        IsClosed   = xamPathFigure.IsClosed
                    };
                    wPathGeometry.Figures.Add(wPathFigure);

                    foreach (PathSegment pathSegment in xamPathFigure.Segments)
                    {
                        // LineSegment
                        if (pathSegment is LineSegment)
                        {
                            LineSegment lineSegment = pathSegment as LineSegment;

                            WMedia.LineSegment winSegment = new WMedia.LineSegment
                            {
                                Point = lineSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(winSegment);
                        }

                        // PolylineSegment
                        if (pathSegment is PolyLineSegment)
                        {
                            PolyLineSegment        polyLineSegment = pathSegment as PolyLineSegment;
                            WMedia.PolyLineSegment wSegment        = new WMedia.PolyLineSegment();

                            foreach (var point in polyLineSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // BezierSegment
                        if (pathSegment is BezierSegment)
                        {
                            BezierSegment bezierSegment = pathSegment as BezierSegment;

                            WMedia.BezierSegment wSegment = new WMedia.BezierSegment
                            {
                                Point1 = bezierSegment.Point1.ToWindows(),
                                Point2 = bezierSegment.Point2.ToWindows(),
                                Point3 = bezierSegment.Point3.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyBezierSegment
                        else if (pathSegment is PolyBezierSegment)
                        {
                            PolyBezierSegment        polyBezierSegment = pathSegment as PolyBezierSegment;
                            WMedia.PolyBezierSegment wSegment          = new WMedia.PolyBezierSegment();

                            foreach (var point in polyBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // QuadraticBezierSegment
                        if (pathSegment is QuadraticBezierSegment)
                        {
                            QuadraticBezierSegment quadraticBezierSegment = pathSegment as QuadraticBezierSegment;

                            WMedia.QuadraticBezierSegment wSegment = new WMedia.QuadraticBezierSegment
                            {
                                Point1 = quadraticBezierSegment.Point1.ToWindows(),
                                Point2 = quadraticBezierSegment.Point2.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyQuadraticBezierSegment
                        else if (pathSegment is PolyQuadraticBezierSegment)
                        {
                            PolyQuadraticBezierSegment        polyQuadraticBezierSegment = pathSegment as PolyQuadraticBezierSegment;
                            WMedia.PolyQuadraticBezierSegment wSegment = new WMedia.PolyQuadraticBezierSegment();

                            foreach (var point in polyQuadraticBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // ArcSegment
                        else if (pathSegment is ArcSegment)
                        {
                            ArcSegment arcSegment = pathSegment as ArcSegment;

                            WMedia.ArcSegment wSegment = new WMedia.ArcSegment
                            {
                                Size           = new WFoundation.Size(arcSegment.Size.Width, arcSegment.Size.Height),
                                RotationAngle  = arcSegment.RotationAngle,
                                IsLargeArc     = arcSegment.IsLargeArc,
                                SweepDirection = arcSegment.SweepDirection == SweepDirection.Clockwise ? WMedia.SweepDirection.Clockwise : WMedia.SweepDirection.Counterclockwise,
                                Point          = arcSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                    }
                }

                wGeometry = wPathGeometry;
            }

            return(wGeometry);
        }
Ejemplo n.º 43
0
        protected override void HandleDragOver(sw.DragEventArgs e, DragEventArgs args)
        {
            var lastRow = LastDragRow;

            base.HandleDragOver(e, args);
            var info = LastDragInfo = GetDragInfo(args);

            if (args.Effects != DragEffects.None)
            {
                // show drag indicator!
                var row = GetDataGridRow(info.Item ?? info.Parent);
                if (row != null)
                {
                    // same position, just return
                    if (lastRow != null && lastRow.IsEqual(row, info.InsertIndex))
                    {
                        return;
                    }

                    lastRow?.Revert();
                    LastDragRow = new GridDragRowState(row, info.InsertIndex);

                    if (info.InsertIndex == -1)
                    {
                        row.Background = sw.SystemColors.HighlightBrush;
                        row.Foreground = sw.SystemColors.HighlightTextBrush;
                    }
                    else
                    {
                        var node = controller.GetNodeAtRow(row.GetIndex());

                        var level = node.Level + 1;                         // indicator to the right of the expanders to align with text
                        var i     = info.Parent as ITreeGridItem;
                        if (info.Position == GridDragPosition.After && ReferenceEquals(info.Item, null))
                        {
                            level++;
                        }

                        level *= 16;
                        var d  = new swm.GeometryDrawing();
                        var gg = new swm.GeometryGroup();
                        gg.Children.Add(new swm.EllipseGeometry(new sw.Point(0, 0), 2, 2));
                        gg.Children.Add(new swm.LineGeometry(new sw.Point(2, 0), new sw.Point(row.ActualWidth - level - 16, 0)));
                        d.Geometry = gg;
                        d.Brush    = sw.SystemColors.HighlightBrush;
                        d.Pen      = new swm.Pen(sw.SystemColors.HighlightBrush, 1);
                        var b = new swm.DrawingBrush {
                            Drawing = d, TileMode = swm.TileMode.None, Stretch = swm.Stretch.None, AlignmentX = swm.AlignmentX.Left
                        };
                        if (info.InsertIndex == node.Index)
                        {
                            b.AlignmentY        = swm.AlignmentY.Top;
                            row.BorderThickness = new sw.Thickness(0, 5, 0, 0);
                        }
                        else
                        {
                            b.AlignmentY        = swm.AlignmentY.Bottom;
                            row.BorderThickness = new sw.Thickness(0, 0, 0, 5);
                        }

                        b.Transform     = new swm.TranslateTransform(level, 0);
                        row.BorderBrush = b;
                    }
                    return;
                }
            }

            ResetDrag();
        }