public void TestSerialization() { var ellipse = new EllipseGeometry { Center = new Point(1.1, 3), RadiusX = 1, RadiusY = 4 }; var writer = new StringWriter(); _serializer.Serialize(writer, ellipse); var reader = new StringReader(writer.ToString()); Assert.AreEqual(ellipse, _serializer.Deserialize(reader)); }
protected override void Init() { Title = "Issue 11137"; var grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star }); var instructions = new Label { Padding = 12, BackgroundColor = Color.Black, TextColor = Color.White, Text = "Reduce the Window size to a minimum, without exceptions the test has passed." }; var path = new Path { BackgroundColor = Color.LightGray, Stroke = Brush.Black, Fill = Brush.Blue, StrokeThickness = 4, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(300) }; EllipseGeometry ellipseGeometry = new EllipseGeometry { Center = new Point(50, 50), RadiusX = 50, RadiusY = 50 }; path.Data = ellipseGeometry; grid.Children.Add(instructions); Grid.SetRow(instructions, 0); grid.Children.Add(path); Grid.SetRow(path, 1); Content = grid; }
private void IDepth_MouseMove(object sender, MouseEventArgs e) { if (!MouseManipulation) { return; } if (Mouse.LeftButton == MouseButtonState.Released) { MouseManipulation = false; Mouse.Capture(null); Settings.TurntableEllipse.Value = SelectedEllipse; Settings.TurntableRectangleA.Value = SelectedRectangleA; Settings.TurntableRectangleB.Value = SelectedRectangleB; return; } EndPoint = Mouse.GetPosition(VI); Point start = VI.PointToCanvas(StartPoint); Point end = VI.PointToCanvas(EndPoint); if (Mouse.LeftButton == MouseButtonState.Pressed) { switch (Step) { case 1: { EllipseGeometry eg = SelectionGeometry as EllipseGeometry; eg.Center = new Point((start.X + end.X) / 2d, (start.Y + end.Y) / 2d); eg.RadiusX = Math.Abs(start.X - end.X) / 2d; eg.RadiusY = Math.Abs(start.Y - end.Y) / 2d; SelectedEllipse = new Rect(start, end); } break; case 3: { RectangleGeometry rg = SelectionGeometry as RectangleGeometry; SelectedRectangleA = rg.Rect = new Rect(start, end); } break; case 4: { RectangleGeometry rg = SelectionGeometry as RectangleGeometry; SelectedRectangleB = rg.Rect = new Rect(start, end); } break; } } }
private void Update() { double[] p = new double[SLIDER_VALUE_NUM]; p[0] = slider1.Value; p[1] = slider3.Value; p[2] = slider2.Value; var path = new Path(); path.Stroke = new SolidColorBrush(Colors.Black); var gg = new GeometryGroup(); double prevX = 0; double prevY = p[0]; double actualWidth = canvas1.ActualWidth; double actualHeight = canvas1.ActualHeight; for (int i = 0; i < 100; ++i) { double t = i / 100.0; double y = p[0] * (1 - t * t) + p[2] * 2 * (1 - t) * t + p[1] * t * t; double x = t; double dx0 = prevX * actualWidth; double dx1 = x * actualWidth; double dy0 = (0.5 - prevY * 0.5) * actualHeight; double dy1 = (0.5 - y * 0.5) * actualHeight; var line = new LineGeometry(new Point(dx0, dy0), new Point(dx1, dy1)); gg.Children.Add(line); prevX = x; prevY = y; } for (int i = 0; i < 2; ++i) { var point = new EllipseGeometry(new Point( i * actualWidth, actualHeight * (0.5 - 0.5 * p[i])), 10, 10); gg.Children.Add(point); } path.Data = gg; canvas1.Children.Clear(); canvas1.Children.Add(path); }
/// <summary> /// lightin constructor /// </summary> /// <param name="damage">the damage of skill</param> /// <param name="x">the x cordinate</param> /// <param name="y">the y cordinate</param> /// <param name="map">the map of skill</param> /// <param name="dirX">direction x</param> /// <param name="dirY">direction y</param> /// <param name="dark">the darkmage</param> public Lighting(int damage, double x, double y, Maps map, double dirX, double dirY, DarkMage dark) : base(damage, 15, map) { Geometry = new EllipseGeometry(new Point(x, y), 25, 25); Image = new ImageBrush(new BitmapImage(new Uri(@"images\Lighting.PNG", UriKind.Relative))); Actpoint = new Point(x, y); DirX = dirX; DirY = dirY; Inradiusmonsters = new List <Monsters>(); Removeable = false; this.Map.Skill.Add(this); maxchain = 3 + dark.LightingSkillPoint; rand = new Random(); this.Dark = dark; Prev = new Monsters(0, 0, 0, 0, 0, "nothing", 0, 0, null, null, 0); }
public EllipseGeometry GetInfluenceCircle(int gridSize, double radius) { if (_influenceCircle == null || _gridSizeScreenRect != gridSize || _influenceCircleRadius != radius) { _influenceCircle = new EllipseGeometry(GetScreenRectCenterPoint(gridSize), radius, radius); if (_influenceCircle.CanFreeze) { _influenceCircle.Freeze(); } _influenceCircleRadius = radius; } return(_influenceCircle); }
public UCImageBox() { InitializeComponent(); myEllipseGeometry = new EllipseGeometry() { Center = new Point(0, 0), RadiusX = 0, RadiusY = 0, }; CompositionTarget.Rendering += UpdateGeometry; this.PreviewMouseMove += UpdateLastMousePosition; this.MouseEnter += UCImageBox_MouseEnter; this.MouseLeave += UCImageBox_MouseLeave; }
public Geometry CreateGeometry(SvgCircleElement element) { double _cx = Math.Round(element.Cx.AnimVal.Value, 4); double _cy = Math.Round(element.Cy.AnimVal.Value, 4); double _r = Math.Round(element.R.AnimVal.Value, 4); if (_r <= 0) { return(null); } EllipseGeometry geometry = new EllipseGeometry(new Point(_cx, _cy), _r, _r); return(geometry); }
private void DrawBodyCenter(Point centerPoint) { Path path = new Path(); path.Stroke = this._centerPointBrush; path.StrokeThickness = BodyCenterThickness; EllipseGeometry ellipse = new EllipseGeometry(); ellipse.Center = centerPoint; ellipse.RadiusX = BodyCenterThickness * this._scaleFactor; ellipse.RadiusY = BodyCenterThickness * this._scaleFactor; path.Data = ellipse; this.playField.Children.Add(path); }
public MainWindow() { InitializeComponent(); myEllipseGeometry = new EllipseGeometry(); myEllipseGeometry.Center = new Point(200, 200); myEllipseGeometry.RadiusX = 20; myEllipseGeometry.RadiusY = 20; Path myPath = new Path(); myPath.Fill = Brushes.SkyBlue; myPath.Data = myEllipseGeometry; myCanvas.Children.Add(myPath); }
/// <summary> /// skill sonctructor /// </summary> /// <param name="map">the map</param> /// <param name="x">x cordinate</param> /// <param name="y">y cordinate</param> public Ionshield(Maps map, double x, double y) : base(0, 100, map) { EllipseGeometry eg = new EllipseGeometry(new Point(x, y), 30, 35); Geometry = eg; Image = null; Actpoint = new Point(x, y); hold = 5; Removeable = false; this.Map.Skill.Add(this); time = new DispatcherTimer(); time.Interval = new TimeSpan(0, 0, 0, 1); time.Tick += Time_Tick; time.Start(); }
private void Bindable_SizeChanged(object?sender, EventArgs e) { if (sender is View view) { EllipseGeometry ellipseGeometry = new EllipseGeometry { Center = new Point(view.Width / 2.0, view.Height / 2.0), RadiusX = view.Width / 2.0, RadiusY = view.Height / 2.0 }; view.Clip = ellipseGeometry; } ; }
public override object CreateSymbol(QuantumCircuitElement element) { EllipseGeometry ellipse = new EllipseGeometry() { Center = new Point(Unit / 2, Unit / 2), RadiusX = Unit / 2, RadiusY = Unit / 2, }; Geometry geo = CreateGeometryGroup(ellipse); Path path = CreateGeometryPath(); path.Fill = Brushes.White; path.Data = geo; return(path); }
private static void OnScaleChanged(DependencyObject d) { var percentageRing = (RadialSlider)d; percentageRing.UpdateNormalizedAngles(); if (percentageRing.GetTemplateChild(ScalePartName) is Path scale) { if (percentageRing.NormalizedMaxAngle - percentageRing.NormalizedMinAngle == 360) { // Draw full circle. var eg = new EllipseGeometry { Center = new Point(Radius, Radius), RadiusX = Radius - (percentageRing.ScaleWidth / 2) }; eg.RadiusY = eg.RadiusX; scale.Data = eg; } else { scale.StrokeStartLineCap = percentageRing.ScaleStartCap; scale.StrokeEndLineCap = percentageRing.ScaleEndCap; // Draw arc. var pg = new PathGeometry(); var pf = new PathFigure { IsClosed = false }; var middleOfScale = Radius - (percentageRing.ScaleWidth / 2); pf.StartPoint = percentageRing.ScalePoint(percentageRing.NormalizedMinAngle, middleOfScale); var seg = new ArcSegment { SweepDirection = SweepDirection.Clockwise, IsLargeArc = percentageRing.NormalizedMaxAngle > (percentageRing.NormalizedMinAngle + 180), Size = new Size(middleOfScale, middleOfScale), Point = percentageRing.ScalePoint(percentageRing.NormalizedMaxAngle, middleOfScale) }; pf.Segments.Add(seg); pg.Figures.Add(pf); scale.Data = pg; } } OnValueChanged(percentageRing); }
/// <summary> /// Draws the atom and all associated decorations /// </summary> public override void Render() { Point centre = ParentAtom.Position; SetTextParams(); if (ParentAtom.Element is Element e) { using (DrawingContext dc = RenderOpen()) { //Debug.WriteLine($"AtomVisual.OnRender() SymbolSize: {SymbolSize}"); Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(e.Colour)); AtomSymbol = ParentAtom.SymbolText; Charge = ParentAtom.FormalCharge; ImplicitHydrogenCount = ParentAtom.ImplicitHydrogenCount; Isotope = ParentAtom.IsotopeNumber; Position = ParentAtom.Position; if (ParentAtom.SymbolText != "") { RenderAtom(dc); // Diag: Show the convex hull #if DEBUG #if SHOWHULLS if (AtomSymbol != "") { dc.DrawGeometry(null, new Pen(new SolidColorBrush(Colors.GreenYellow), 1.0), WidenedHullGeometry); } #endif #endif // End Diag dc.Close(); } else //draw an empty circle for hit testing purposes { EllipseGeometry eg = new EllipseGeometry(ParentAtom.Position, Globals.AtomRadius, Globals.AtomRadius); dc.DrawGeometry(Brushes.Transparent, new Pen(Brushes.Transparent, 1.0), eg); //very simple hull definition Hull = new List <Point>(); Hull.AddRange(new[] { eg.Bounds.BottomLeft, eg.Bounds.TopLeft, eg.Bounds.TopRight, eg.Bounds.BottomRight }); dc.Close(); } } } }
private void AddToCanvas(Vector2 pos, float radius, Color color) { pos *= CellSize; Path element = new Path(); element.Fill = new SolidColorBrush(color); EllipseGeometry ellipseGeometry = new EllipseGeometry(); ellipseGeometry.Center = new Point(pos.X, pos.Y); ellipseGeometry.RadiusX = radius * CellSize.X; ellipseGeometry.RadiusY = radius * CellSize.Y; element.Data = ellipseGeometry; //No idea how to make this work on any thread other than the main UI one _canvas.Children.Add(element); }
//圆形展开****************************** private void button1_Click(object sender, System.Windows.RoutedEventArgs e) { EllipseGeometry ellipse = new EllipseGeometry(); //创建椭圆图形,但不显示 double cx = this.image.Width / 2; //image的宽、高不要设为自动 double cy = this.image.Height / 2; ellipse.Center = new Point(cx, cy); //创建中心点,RadiusX默认为0 this.image.Clip = ellipse; //用ellipse对图片剪裁,开始的剪裁区域是0 DoubleAnimation da = new DoubleAnimation(); da.From = 0; //从中心点 da.To = Math.Max(cx * 2, cy * 2); da.Duration = new Duration(TimeSpan.Parse("0:0:6")); //动画时间 ellipse.BeginAnimation(EllipseGeometry.RadiusXProperty, da); ellipse.BeginAnimation(EllipseGeometry.RadiusYProperty, da); }
// TRON'S private List<DependencyObject> FindNearestPorts(System.Windows.Point mouse) { hitResultsList.Clear(); EllipseGeometry expandedHitTestArea = new EllipseGeometry(mouse, 50.0, 7.0); try { VisualTreeHelper.HitTest(this, new HitTestFilterCallback(HitTestFilter), new HitTestResultCallback(VisualCallBack), new GeometryHitTestParameters(expandedHitTestArea)); //if (hitResultsList.Count > 0) //Debug.WriteLine("Number of visual hits: " + hitResultsList.Count); } catch { hitResultsList.Clear(); } return this.hitResultsList; }
public EllipseGeometry ChangeGeometry(Geometry geometry, Point startPoint, Point point) { EllipseGeometry tmp = geometry as EllipseGeometry; tmp.Center = startPoint; double radius = Math.Sqrt(Math.Pow(startPoint.X - point.X, 2) + Math.Pow(startPoint.Y - point.Y, 2)); if (tmp.Center.Y - radius - ((MainWindow)System.Windows.Application.Current.MainWindow).BorderThicknessySlider.Value > 0) { tmp.RadiusX = radius; tmp.RadiusY = radius; } return(tmp); }
private void UpdateCropShape() { _maskAreaGeometryGroup.Children.Clear(); _outerGeometry = new RectangleGeometry(); if (CircularCrop) { _innerGeometry = new EllipseGeometry(); } else { _innerGeometry = new RectangleGeometry(); } _maskAreaGeometryGroup.Children.Add(_outerGeometry); _maskAreaGeometryGroup.Children.Add(_innerGeometry); UpdateMaskArea(); }
public static object CreateNew(Point position, ItemCreateMode createMode) { EllipseGeometry geom; if (createMode == ItemCreateMode.Drop) { geom = new EllipseGeometry(position, 5.0, 5.0); } else { geom = new EllipseGeometry(position, 1.0, 1.0); } return(new GeometryDrawing( null, new Pen(Brushes.Black, 1.0), geom)); }
/// <summary> /// cons of portal skill /// </summary> /// <param name="map">the map</param> /// <param name="x">x cordionate</param> /// <param name="y">y cordinate</param> public Portal(Maps map, double x, double y) : base(0, 0, map) { width = 1; height = 1; Removeable = false; zoomout = false; elip = new EllipseGeometry(new Point(x, y), 1, 1); Geometry = elip; Image = new ImageBrush(new BitmapImage(new Uri(@"images\portal.PNG", UriKind.Relative))); Actpoint = new Point(x, y); timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 2); timer.Tick += Timer_Tick; this.Map.Skill.Add(this); timer.Start(); }
public void Post(EllipseGeometry ellipse, FrameworkElement frameworkElement) { var now = DateTime.UtcNow; if (now - lastTime <= TimeSpan.Zero) { return; } lastTime = now; var raw = ellipse.Center; var relativeX = (float)(raw.X / frameworkElement.ActualWidth); var relativeY = (float)(raw.Y / frameworkElement.ActualHeight); var relative = new Vector2(relativeX, relativeY); Out.Post(relative, now); }
public void Visit(ISvgCircleElement element) { double _cx = Math.Round(element.Cx.AnimVal.Value, 4); double _cy = Math.Round(element.Cy.AnimVal.Value, 4); double _r = Math.Round(element.R.AnimVal.Value, 4); if (_r <= 0) { return; } EllipseGeometry geometry = new EllipseGeometry(new Point(_cx, _cy), _r, _r); var shape = WrapGeometry(geometry, element); DisplayShape(shape, element); }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { Double width = this.ActualWidth; Double height = this.ActualHeight; Double a = width / 2; Double b = height / 2; Point centerPoint = new Point(a, b); Double thickness = this.BorderThickness.Left; EllipseGeometry ellipse = new EllipseGeometry(centerPoint, a, b); drawingContext.PushClip(ellipse); drawingContext.DrawGeometry( this.Background, new Pen(this.BorderBrush, thickness), ellipse); }
private void OnGeometryValueChanged(object sender, EventArgs arg) { Point point; FormattedText formattedText; CombinedGeometry combinedGeometry = new CombinedGeometry(); combinedGeometry.GeometryCombineMode = GeometryCombineMode.Exclude; formattedText = new FormattedText(FormattedRatio, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Arial"), LabelFontSize, Brushes.White); if (ActualRatio == 1) { EllipseGeometry ellipseGeometry = Geometry as EllipseGeometry; point = new Point(ellipseGeometry.Center.X - formattedText.Width / 2, ellipseGeometry.Center.Y - formattedText.Height / 2); } else if (ActualRatio == 0) { TextedGeometry = null; return; } else { Point tangent; Point half; Point origin; PathGeometry pathGeometry = Geometry as PathGeometry; pathGeometry.GetPointAtFractionLength(.5, out half, out tangent); pathGeometry.GetPointAtFractionLength(0, out origin, out tangent); point = new Point(origin.X + ((half.X - origin.X) / 2) - formattedText.Width / 2, origin.Y + ((half.Y - origin.Y) / 2) - formattedText.Height / 2); } combinedGeometry.Geometry1 = Geometry; combinedGeometry.Geometry2 = formattedText.BuildGeometry(point); TextedGeometry = combinedGeometry; }
public virtual void Build(List <Graph> graphs) { if (graphs.Count > 0) { _DrawingGroup.Children.Clear(); foreach (Graph item in graphs) { if (item.Points.Count > 0) { for (int counter = 0; counter < item.Points.Count; counter++) { if (ShowOnlyPoints) { EllipseGeometry point = new EllipseGeometry(item.Points[counter], item.PointRadius, item.PointRadius); Brush brush = item.Color; brush.Freeze(); GeometryDrawing drawing = new GeometryDrawing(brush, null, point); _DrawingGroup.Children.Add(drawing); } else { if (counter > 0) { LineGeometry line = new LineGeometry(); line.StartPoint = new Point(_LastXValue, _LastYValue); line.EndPoint = new Point(item.Points[counter].X, item.Points[counter].Y); Pen pen = new Pen(item.Color, 1); Brush brush = item.Color; brush.Freeze(); GeometryDrawing drawing = new GeometryDrawing(brush, pen, line); _DrawingGroup.Children.Add(drawing); } _LastXValue = item.Points[counter].X; _LastYValue = item.Points[counter].Y; } } } } } }
private static void AddRectanglesToPanel(Panel panel, double width, double height) { Rectangle topLeftRect = CreateRectangle(); topLeftRect.Width = width; topLeftRect.Height = height; topLeftRect.HorizontalAlignment = HorizontalAlignment.Left; topLeftRect.VerticalAlignment = VerticalAlignment.Top; panel.Children.Add(topLeftRect); Rectangle collapsedRect = CreateRectangle(); collapsedRect.Visibility = Visibility.Collapsed; panel.Children.Add(collapsedRect); Rectangle clippedRect = CreateRectangle(); clippedRect.Width = width; clippedRect.Height = height; clippedRect.HorizontalAlignment = HorizontalAlignment.Center; clippedRect.VerticalAlignment = VerticalAlignment.Center; EllipseGeometry clipGeometry = new EllipseGeometry(); clipGeometry.Center = new Point(0.5 * width, 0.5 * height); clipGeometry.RadiusX = 0.25 * width; clipGeometry.RadiusY = 0.4 * height; clippedRect.Clip = clipGeometry; panel.Children.Add(clippedRect); Rectangle bottomRightRect = CreateRectangle(); bottomRightRect.Width = width; bottomRightRect.Height = height; bottomRightRect.HorizontalAlignment = HorizontalAlignment.Right; bottomRightRect.VerticalAlignment = VerticalAlignment.Bottom; panel.Children.Add(bottomRightRect); Rectangle stretchedRect = CreateRectangle(); stretchedRect.Width = Double.NaN; stretchedRect.Height = Double.NaN; stretchedRect.MinWidth = width; stretchedRect.MinHeight = height; stretchedRect.HorizontalAlignment = HorizontalAlignment.Stretch; stretchedRect.VerticalAlignment = VerticalAlignment.Stretch; panel.Children.Add(stretchedRect); }
protected override Size FillToolTipData( object sender, MouseEventArgs e, Path boundingRectElem, Path circleElem) { ChartEventArgs chartEvent = GetChartEvent(sender, e); int i = chartEvent.SeriesIndices[0]; double yValue = chartEvent.YValues[0], xValue = chartEvent.XValues[0]; ChartModel model = Model; string[] seriesLabels = model.SeriesLabels; TextBlock textElem = ToolTip.Children[2] as TextBlock; textElem.Text = seriesLabels[i] + ": (" + xValue.ToString(Format) + ") (" + yValue.ToString() + ")"; double labelWidth = textElem.ActualWidth; double labelHeight = textElem.ActualHeight; //We do not need the next label textElem = ToolTip.Children[3] as TextBlock; textElem.Text = ""; double rectWidth = labelWidth + 2 * _TEXT_MARGIN; RectangleGeometry rg = boundingRectElem.Data as RectangleGeometry; Rect rect = rg.Rect; double rectHeight = rect.Height; if (rectHeight > 2 * labelHeight) { rectHeight -= labelHeight; } rg.Rect = new Rect(rect.X, rect.Y, rectWidth, rectHeight); boundingRectElem.SetValue(Path.StrokeProperty, new SolidColorBrush(Model.SeriesColors[i])); EllipseGeometry eg = circleElem.Data as EllipseGeometry; eg.RadiusX = eg.RadiusY = 0; return(new Size(rectWidth, 2 * (labelHeight + _TEXT_MARGIN))); }
public static Geometry MarkerGeometry(MarkersType markersType, Factory factory, float width, float height) { Geometry geometry = null; switch (markersType) { case MarkersType.None: break; case MarkersType.Square: geometry = new RectangleGeometry(factory, new System.Drawing.RectangleF() { X = 0, Y = 0, Width = width, Height = height }); break; case MarkersType.Circle: geometry = new EllipseGeometry(factory, new Ellipse() { Point = new System.Drawing.PointF(0, 0), RadiusX = width / 2, RadiusY = height / 2, }); break; default: GenericMarker markerSpecification = MarkerGeometries.GenericMarkerLookup[markersType]; geometry = new PathGeometry(factory); using (GeometrySink sink = (geometry as PathGeometry).Open()) { PointF p0 = new PointF((float)markerSpecification.X[0] * width, (float)markerSpecification.Y[0] * height); sink.BeginFigure(p0, FigureBegin.Hollow); int n = markerSpecification.X.Length; for (int i = 1; i < n; ++i) { sink.AddLine(new PointF((float)markerSpecification.X[i] * width, (float)markerSpecification.Y[i] * height)); } sink.EndFigure(FigureEnd.Closed); sink.Close(); } break; } return(geometry); }
public CompositeShapeExample() { // <SnippetCompositeShapeCodeExampleInline1> // Create a Path to be drawn to the screen. Path myPath = new Path(); myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 1; SolidColorBrush mySolidColorBrush = new SolidColorBrush(); mySolidColorBrush.Color = Color.FromArgb(255, 204, 204, 255); myPath.Fill = mySolidColorBrush; // Create the line geometry to add to the Path LineGeometry myLineGeometry = new LineGeometry(); myLineGeometry.StartPoint = new Point(10, 10); myLineGeometry.EndPoint = new Point(50, 30); // Create the ellipse geometry to add to the Path EllipseGeometry myEllipseGeometry = new EllipseGeometry(); myEllipseGeometry.Center = new Point(40, 70); myEllipseGeometry.RadiusX = 30; myEllipseGeometry.RadiusY = 30; // Create a rectangle geometry to add to the Path RectangleGeometry myRectGeometry = new RectangleGeometry(); myRectGeometry.Rect = new Rect(30, 55, 100, 30); // Add all the geometries to a GeometryGroup. GeometryGroup myGeometryGroup = new GeometryGroup(); myGeometryGroup.Children.Add(myLineGeometry); myGeometryGroup.Children.Add(myEllipseGeometry); myGeometryGroup.Children.Add(myRectGeometry); myPath.Data = myGeometryGroup; // Add path shape to the UI. StackPanel mainPanel = new StackPanel(); mainPanel.Children.Add(myPath); this.Content = mainPanel; // </SnippetCompositeShapeCodeExampleInline1> }
private void CreateGeometries(Direct2DFactory factory) { Ellipse circle1 = new Ellipse(75, 75, 50, 50); this._circleGeometry1 = factory.CreateEllipseGeometry(circle1); Ellipse circle2 = new Ellipse(125, 75, 50, 50); this._circleGeometry2 = factory.CreateEllipseGeometry(circle2); // Union this._geometryUnion = factory.CreatePathGeometry(); using (GeometrySink sink = this._geometryUnion.Open()) { this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Union, Matrix3x2.Identity, 0.25f, sink); sink.Close(); } // Intersect this._geometryIntersect = factory.CreatePathGeometry(); using (GeometrySink sink = this._geometryIntersect.Open()) { this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Intersect, Matrix3x2.Identity, 0.25f, sink); sink.Close(); } // Xor this._geometryXor = factory.CreatePathGeometry(); using (GeometrySink sink = this._geometryXor.Open()) { this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Xor, Matrix3x2.Identity, 0.25f, sink); sink.Close(); } // Exclude this._geometryExclude = factory.CreatePathGeometry(); using (GeometrySink sink = this._geometryExclude.Open()) { this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Exclude, Matrix3x2.Identity, 0.25f, sink); sink.Close(); } }