当前位置: 首页>>代码示例>>C#>>正文


C# Media.GeometryGroup类代码示例

本文整理汇总了C#中System.Windows.Media.GeometryGroup的典型用法代码示例。如果您正苦于以下问题:C# GeometryGroup类的具体用法?C# GeometryGroup怎么用?C# GeometryGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GeometryGroup类属于System.Windows.Media命名空间,在下文中一共展示了GeometryGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToXaml

 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;
 }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:7,代码来源:GeometryExtensions.cs

示例2: CalculateGeometry

    /// <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;
      }
    }
开发者ID:jrc60752,项目名称:iRacingAdminSync,代码行数:35,代码来源:ChartPrimitiveHBar.cs

示例3: OnChartPointsChanged

        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;
        }
开发者ID:epyx-src,项目名称:WindMobile-WP7,代码行数:34,代码来源:WindChartControl.xaml.cs

示例4: PaintBackground

        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;
        }
开发者ID:estromsnes,项目名称:CodeNinjaSpy,代码行数:28,代码来源:CodeNinjaSpyShell.xaml.cs

示例5: CreateGeometryDrawing

        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;
        }
开发者ID:nanomouse,项目名称:stratasys,代码行数:25,代码来源:MainWindow.xaml.cs

示例6: CreateDescriptionWaveForm

        /// <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;
        }
开发者ID:vserrago,项目名称:LiveDescribe-Desktop,代码行数:68,代码来源:RenderTargetBitmapFactory.cs

示例7: Init

        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;
        }
开发者ID:gp1313,项目名称:morethantechnical,代码行数:33,代码来源:Window1.xaml.cs

示例8: GetClipGeometry

        //==========================================================================
        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;
        }
开发者ID:jogibear9988,项目名称:svg2xaml,代码行数:27,代码来源:SvgClipPathElement.cs

示例9: CreateARectangleWithDrawingBrush

        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;
        }
开发者ID:riezebosch,项目名称:Glitter,代码行数:30,代码来源:ColorConverter.cs

示例10: buildGeometryGroup

 private GeometryGroup buildGeometryGroup()
 {
     GeometryGroup group = new GeometryGroup();
     group.Children.Add(buildEllipse());
     group.Children.Add(buildText());
     return group;
 }
开发者ID:davidbedok,项目名称:oeprogvep,代码行数:7,代码来源:MainWindow.xaml.cs

示例11: GoodShapesCollection

 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);
 }
开发者ID:goodmaker,项目名称:gooddrawer,代码行数:8,代码来源:GoodShapes.cs

示例12: CreateGeometry

		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;
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:8,代码来源:CrossMarker.cs

示例13: BuildVertexGeometry

 /// <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;
 }
开发者ID:CarlosVV,项目名称:mediavf,代码行数:13,代码来源:GeometryOperation.cs

示例14: GetProviderVector

 public static GeometryGroup GetProviderVector()
 {
     if (_geometryGroup == null)
     {
         _geometryGroup = new GeometryGroup();
         _geometryGroup.Children.Add((Geometry)Application.Current.Resources["VectorGrooveshark"]);
     }
     return _geometryGroup;
 }
开发者ID:WELL-E,项目名称:Hurricane,代码行数:9,代码来源:GroovesharkTrack.cs

示例15: WalkChildren

 /// <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);
     }
 }
开发者ID:CarlosVV,项目名称:mediavf,代码行数:16,代码来源:GeometryOperation.cs


注:本文中的System.Windows.Media.GeometryGroup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。