本文整理汇总了C#中System.Windows.Media.GeometryGroup类的典型用法代码示例。如果您正苦于以下问题:C# GeometryGroup类的具体用法?C# GeometryGroup怎么用?C# GeometryGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeometryGroup类属于System.Windows.Media命名空间,在下文中一共展示了GeometryGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: EnumVisual
/// <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);
}
开发者ID:transformersprimeabcxyz,项目名称:Prism-Samples-Wpf,代码行数:59,代码来源:GeometryOperation.cs
示例17: MainWindow
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);
}
开发者ID:marhor3327,项目名称:SelfDrivingCar,代码行数:53,代码来源:MainWindow.xaml.cs
示例18: GetGridTileBrush
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;
}
开发者ID:sunoru,项目名称:PBO,代码行数:12,代码来源:Brushes.cs
示例19: BuildDrawing
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;
}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:52,代码来源:TestControl.xaml.cs
示例20: FunctionPlotter
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);
}
开发者ID:philipdaubmeier,项目名称:BodyOrientation,代码行数:13,代码来源:FunctionPlotter.cs
注:本文中的System.Windows.Media.GeometryGroup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论