本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例10: buildGeometryGroup
private GeometryGroup buildGeometryGroup()
{
GeometryGroup group = new GeometryGroup();
group.Children.Add(buildEllipse());
group.Children.Add(buildText());
return group;
}
示例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);
}
示例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;
}
示例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;
}
示例14: GetProviderVector
public static GeometryGroup GetProviderVector()
{
if (_geometryGroup == null)
{
_geometryGroup = new GeometryGroup();
_geometryGroup.Children.Add((Geometry)Application.Current.Resources["VectorGrooveshark"]);
}
return _geometryGroup;
}
示例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);
}
}