Geometry CreateGeometryTailAtRight() { CombinedGeometry result = new CombinedGeometry(); Point arcPoint1 = new Point(this.ActualWidth - 9, this.ActualHeight - 18); Point arcPoint2 = new Point(this.ActualWidth, this.ActualHeight - 3); Point arcPoint3 = new Point(this.ActualWidth - 20, this.ActualHeight - 6); ArcSegment as1_2 = new ArcSegment(arcPoint2, new Size(15, 20), 0, false, SweepDirection.Counterclockwise, true); ArcSegment as2_3 = new ArcSegment(arcPoint3, new Size(18, 10), 0, false, SweepDirection.Clockwise, true); PathFigure pf1 = new PathFigure(); pf1.IsClosed = false; pf1.StartPoint = arcPoint1; pf1.Segments.Add(as1_2); pf1.Segments.Add(as2_3); PathGeometry pg1 = new PathGeometry(); pg1.Figures.Add(pf1); RectangleGeometry rg2 = new RectangleGeometry(new Rect(9, 0, this.ActualWidth - 18, this.ActualHeight), 20, 20); result.Geometry1 = pg1; result.Geometry2 = rg2; result.GeometryCombineMode = GeometryCombineMode.Union; return(result); }
// Token: 0x06002AC1 RID: 10945 RVA: 0x000C37D4 File Offset: 0x000C19D4 private CombinedGeometry GetClipGeometry(Visual element, Adorner adorner) { Visual visual = null; Visual visual2 = VisualTreeHelper.GetParent(this) as Visual; if (visual2 == null) { return(null); } CombinedGeometry combinedGeometry = null; if (!visual2.IsAncestorOf(element)) { return(null); } while (element != visual2 && element != null) { Geometry clip = VisualTreeHelper.GetClip(element); if (clip != null) { if (combinedGeometry == null) { combinedGeometry = new CombinedGeometry(clip, null); } else { GeneralTransform generalTransform = visual.TransformToAncestor(element); combinedGeometry.Transform = generalTransform.AffineTransform; combinedGeometry = new CombinedGeometry(combinedGeometry, clip); combinedGeometry.GeometryCombineMode = GeometryCombineMode.Intersect; } visual = element; } element = (Visual)VisualTreeHelper.GetParent(element); } if (combinedGeometry != null) { GeneralTransform generalTransform2 = visual.TransformToAncestor(visual2); if (generalTransform2 == null) { combinedGeometry = null; } else { TransformGroup transformGroup = new TransformGroup(); transformGroup.Children.Add(generalTransform2.AffineTransform); generalTransform2 = visual2.TransformToDescendant(adorner); if (generalTransform2 == null) { combinedGeometry = null; } else { transformGroup.Children.Add(generalTransform2.AffineTransform); combinedGeometry.Transform = transformGroup; } } } return(combinedGeometry); }
public Path GeometryDrawingExample() { RectangleGeometry myRectangleGeometry = new RectangleGeometry(); myRectangleGeometry.Rect = new Rect(120, 120, 25, 25); CombinedGeometry combinedGeometry = new CombinedGeometry(); EllipseGeometry outterEllipse = new EllipseGeometry(new Rect(0, 0, 120, 120)); EllipseGeometry innerEllipse = new EllipseGeometry(new Rect(10, 10, 100, 100)); combinedGeometry.Geometry1 = outterEllipse; combinedGeometry.Geometry2 = innerEllipse; combinedGeometry.GeometryCombineMode = GeometryCombineMode.Xor; GeometryGroup shapes = new GeometryGroup(); shapes.Children.Add(combinedGeometry); shapes.Children.Add(myRectangleGeometry); Path myPath = new Path(); myPath.Fill = Brushes.LemonChiffon; myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 1; myPath.Data = shapes; return(myPath); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Length == 3 && values[0] is double && values[1] is double && values[2] is CornerRadius) { var width = (double)values[0]; var height = (double)values[1]; Path myPath = new Path(); if (width < Double.Epsilon || height < Double.Epsilon) { return(Geometry.Empty); } var radius = (CornerRadius)values[2]; var radiusHeight = radius.TopLeft; // Drawing Round box for bottom round, and rect for top area of listbox. var corner = new RectangleGeometry(new Rect(0, 0, width, height), radius.TopLeft, radius.TopLeft); var box = new RectangleGeometry(new Rect(0, 0, width, radiusHeight), 0, 0); GeometryGroup myGeometryGroup = new GeometryGroup(); myGeometryGroup.Children.Add(corner); myGeometryGroup.Children.Add(box); CombinedGeometry c1 = new CombinedGeometry(GeometryCombineMode.Union, corner, box); myPath.Data = c1; myPath.Data.Freeze(); return(myPath.Data); } return(DependencyProperty.UnsetValue); }
private Geometry LoadGeometry() { var step = 360d / SegmentCount; var radius = SpinnerRadius; var innerRatio = Math.Max(0f, Math.Min(1f, 1f - SegmentLength)); var center = new Point(radius / 2d, radius / 2d); var points = new List <Point>(); for (var a = 0d; a < 360d; a += step) { points.Add(center.Plot(a, radius)); points.Add(center.Plot(a + SegmentWidth, radius)); points.Add(new Point(center.X, center.Y)); } var anglesFigure = new PathFigure(center, new[] { new PolyLineSegment(points, true) }, true); var angles = new PathGeometry(new[] { anglesFigure }); var outerEllipse = new EllipseGeometry(new Rect(0, 0, radius, radius)); var innerRadius = radius * innerRatio; var innerleft = (radius - innerRadius) / 2; var innerTop = (radius - innerRadius) / 2; var innerEllipse = new EllipseGeometry(new Rect(innerleft, innerTop, innerRadius, innerRadius)); var geometry = new CombinedGeometry(GeometryCombineMode.Intersect, outerEllipse, angles); geometry = new CombinedGeometry(GeometryCombineMode.Exclude, geometry, innerEllipse); return(geometry); }
private bool BeginCrop(PathGeometry path) { TouchableImage image = this._selectedImage; if (image != null) { //이 이미지 위치정보 A+ 저장 double outerImage_x = InkCanvas.GetLeft(image); double outerImage_y = InkCanvas.GetTop(image); double outerImage_width = image.Width; double outerImage_height = image.Height; Rect outerImageRect = new Rect(0, 0, outerImage_width, outerImage_height); //입력받은 패스를 가지고 이미지의 좌표에 맞게 좌표수정 path.Transform = new TranslateTransform(-outerImage_x, -outerImage_y); //화면 영역에 맞게 combine 된 clipping path를 구함 RectangleGeometry imageRectGeo = new RectangleGeometry(outerImageRect); CombinedGeometry combinedGeoIntersect = new CombinedGeometry(GeometryCombineMode.Intersect, imageRectGeo, path); //이미지에 적용, 패스로 크로핑 image.Clip = combinedGeoIntersect; //새 이미지를 만든다. TouchableImage cloneImg = new TouchableImage(); //cloneImg.RenderTransform = image.RenderTransform.Clone(); cloneImg.Source = image.Source.Clone(); cloneImg.Width = image.ActualWidth; cloneImg.Height = image.ActualHeight; //이미지의 영역과 클리핑 데이터로 새로운 클리핑 영역을 만듦 CombinedGeometry combinedGeoXor = new CombinedGeometry(GeometryCombineMode.Xor, imageRectGeo, path); cloneImg.Clip = combinedGeoXor; //새로 만들어진 이미지를 넣고 배치한다. this._inkCanvas.Children.Add(cloneImg); //cloneImg.RenderTransform = new RotateTransform(); InkCanvas.SetLeft(cloneImg, outerImage_x); InkCanvas.SetTop(cloneImg, outerImage_y); //원본 이미지에 재적용 //클리핑된 이미지 B 완성 (선택한 영역만 남은 그림) //이 이미지 위치정보 B+ 저장 //원본 이미지의 인덱스 위치에 //이미지 A 를 A+ 위치에 배치 //이미지 B 를 B+ 위치에 배치 //원본 이미지 캔버스에서 제거 if (this.ImageCropped != null) { ImageCropped(this, null); } } return(true); }
public CombinedGeometry GetOct(int i, int j, int radius) { int standX = i; int standY = j; StreamGeometry g = new StreamGeometry(); g.FillRule = FillRule.EvenOdd; StreamGeometryContext ctx = g.Open(); ctx.BeginFigure(new Point(standX - radius, standY), true, true); ctx.LineTo(new Point(standX, standY - radius), true, false); ctx.LineTo(new Point(standX + radius, standY), true, false); ctx.LineTo(new Point(standX, standY + radius), true, false); ctx.Close(); StreamGeometry h = new StreamGeometry(); h.FillRule = FillRule.EvenOdd; ctx = h.Open(); ctx.BeginFigure(new Point(standX - radius / 1.414, standY - radius / 1.414), true, true); ctx.LineTo(new Point(standX + radius / 1.414, standY - radius / 1.414), true, false); ctx.LineTo(new Point(standX + radius / 1.414, standY + radius / 1.414), true, false); ctx.LineTo(new Point(standX - radius / 1.414, standY + radius / 1.414), true, false); ctx.Close(); CombinedGeometry cg = new CombinedGeometry(g, h); return(cg); }
private void UpdateFigure() { if (ActualHeight == 0 || ActualWidth == 0) { return; } if (tailStaffing == null || tail == null) { return; } RadiusY = ActualHeight / 2; RadiusX = RadiusY * Curveness; PipeTailWidth = RadiusX * 2; if (ActualWidth < RadiusX * 2) { if (tail.Fill != null) { if (tail.Fill.Opacity > 0) { tempTailColorOpacity = tail.Fill.Opacity; } UpdateTailColorOpacity(0); tailStaffing.Data = null; isTailDisappeared = true; return; } } if (isTailDisappeared) { UpdateTailColorOpacity(tempTailColorOpacity); isTailDisappeared = false; } var pathLength = (RadiusX / 6) * 7; tailStaffing.Margin = new Thickness(-pathLength, 0, 0, 0); tailStaffing.Width = pathLength; var tempCenterX = (RadiusX / 3) * 4; var tempRectangleWidth = RadiusX * 3; var ellipseGeometry = new EllipseGeometry(new Point(tempCenterX, RadiusY), RadiusX, RadiusY); var rectangleGeometry = new RectangleGeometry(new Rect(0, 0, tempRectangleWidth, ActualHeight)); if (tailStaffing.Data == null) { var combinedGeometry = new CombinedGeometry(GeometryCombineMode.Xor, ellipseGeometry, rectangleGeometry); tailStaffing.Data = combinedGeometry; } else { var combinedGeometry = (CombinedGeometry)tailStaffing.Data; combinedGeometry.Geometry1 = ellipseGeometry; combinedGeometry.Geometry2 = rectangleGeometry; } }
public static Geometry TargetPath(this Rect rect, double borderWidth) { double diff = borderWidth / 2.0; double fullRadius = rect.CircleSize() - diff; double bigRadius = fullRadius * .8; double smallRadius = bigRadius * .7; Rect diffRect = rect; diffRect.Inflate(-diff, -diff); EllipseGeometry ellipseOut = new EllipseGeometry(rect.Center(), bigRadius, bigRadius); EllipseGeometry ellipseIn = new EllipseGeometry(rect.Center(), smallRadius, smallRadius); CombinedGeometry cg = new CombinedGeometry(GeometryCombineMode.Xor, ellipseOut, ellipseIn); Rect wRect = diffRect.ScaleCenter(1, .1); Rect hRect = diffRect.ScaleCenter(.1, 1); cg = new CombinedGeometry(GeometryCombineMode.Union, new RectangleGeometry(wRect), cg); cg = new CombinedGeometry(GeometryCombineMode.Union, new RectangleGeometry(hRect), cg); Rect cRect = diffRect.ScaleCenter(.3, .3); cg = new CombinedGeometry(GeometryCombineMode.Exclude, cg, new RectangleGeometry(cRect)); return(cg); }
private void CombineShapes(Path p1, Path p2, string s) { Path myPath = new Path(); myPath.Fill = fillColor; myPath.Stroke = borderColor; CombinedGeometry cg = new CombinedGeometry(); if (s == "Union") { cg.GeometryCombineMode = GeometryCombineMode.Union; } else if (s == "Xor") { cg.GeometryCombineMode = GeometryCombineMode.Xor; } else if (s == "Intersect") { cg.GeometryCombineMode = GeometryCombineMode.Intersect; } else if (s == "Exclude") { cg.GeometryCombineMode = GeometryCombineMode.Exclude; } cg.Geometry1 = p1.Data; cg.Geometry2 = p2.Data; myPath.Data = cg; paths.Add(myPath); canvas1.Children.Add(paths[paths.Count - 1]); canvas1.Children.Remove(p1); canvas1.Children.Remove(p2); }
private void button2_Click(object sender, System.Windows.RoutedEventArgs e) { Path path = new Path(); Canvas.SetLeft(path, 290); //设置和canvas1的相对位置 Canvas.SetTop(path, 0); RectangleGeometry rectanglegeometry = new RectangleGeometry(); //矩形宽100,高160,在path中的坐标为0,60 rectanglegeometry.Rect = new Rect(0, 60, 100, 160); EllipseGeometry ellipsegeometry = new EllipseGeometry(); //path中的坐标 ellipsegeometry.Center = new Point(50, 110); ellipsegeometry.RadiusX = 40; ellipsegeometry.RadiusY = 100; path.Fill = Brushes.Blue; path.Stroke = Brushes.DarkOrange; path.StrokeThickness = 6; //2个图形组合,相交模式,即取相交部分(还有相减Exclude,相加Union,异或Xor) CombinedGeometry combinedgeometry = new CombinedGeometry(GeometryCombineMode.Intersect, rectanglegeometry, ellipsegeometry); path.Data = combinedgeometry; this.canvas1.Children.Add(path); //canvas1是path的容器 }
public WallRender(AntRunner.Models.Map map, Item wallType) { _map = map; _wallType = wallType; if (wallType == Item.SteelWall) { _path = new Path { StrokeThickness = 1, Fill = Brushes.DimGray, Stroke = Brushes.Black }; } else { _path = new Path { StrokeThickness = 1, Fill = Brushes.Brown, Stroke = Brushes.Black }; } _geometry = new CombinedGeometry { GeometryCombineMode = GeometryCombineMode.Exclude, Geometry2 = new GeometryGroup() }; _path.Data = _geometry; }
private void AddGeometry(DrawingGroup group, Geometry g) { if (group.ClipGeometry != null && !group.ClipGeometry.FillContains(g)) { var cg = new CombinedGeometry(); cg.Geometry1 = group.ClipGeometry; cg.Geometry2 = g; cg.GeometryCombineMode = GeometryCombineMode.Intersect; g = cg.GetOutlinedPathGeometry(Flatness, ToleranceType.Relative); } var intersections = Geometries.Where(gg => gg.FillContainsWithDetail(g) != IntersectionDetail.Empty); foreach (var ig in intersections) { Geometries.Remove(ig); var cg = new CombinedGeometry(); cg.Geometry1 = g; cg.Geometry2 = ig; cg.GeometryCombineMode = GeometryCombineMode.Union; g = cg.GetOutlinedPathGeometry(Flatness, ToleranceType.Relative); } ApplyTransform(group.Transform, g); //ApplyTransform(Transform, g); Geometries.Add(g); }
public ShadowChrome() { InnerClipGeometry = new RectangleGeometry(); OuterClipGeometry = new RectangleGeometry(); Clip = new CombinedGeometry(GeometryCombineMode.Exclude, OuterClipGeometry, InnerClipGeometry); ShadowEffect = new DropShadowEffect { Opacity = 1.0, BlurRadius = 0, Direction = 0, ShadowDepth = 0 }; ShadowBorder = new Border { Background = new SolidColorBrush(ShadowColor), Effect = ShadowEffect }; Popup.SetHitTestVisible(this, false); Popup.SetHitTestVisible(ShadowBorder, false); this.OverrideStyleKey <ShadowChrome>(); #if !SILVERLIGHT Focusable = false; #endif IsTabStop = false; }
public Calculate(string _formula, Dictionary <Char, CombinedGeometry> simpleShapes) { formula = new List <Char>(_formula); PrepareFormulaToCalculations(); DictionarySet(simpleShapes); result = CalculateResult(); }
protected virtual Geometry CreateGeometry(Geometry box, Geometry connector) { var ballonGeometry = new CombinedGeometry(GeometryCombineMode.Union, box, connector); //ballonGeometry.Freeze(); return(ballonGeometry); }
private void Button_Click_1(object sender, RoutedEventArgs e) { Path objPath = new Path { Stroke = new SolidColorBrush(Colors.Blue) }; ImageBrush imgToFill = new ImageBrush { ImageSource = new BitmapImage(new Uri("pack://application:,,,/Resources/BackgroundImage.jpg", UriKind.Absolute)) }; objPath.Fill = imgToFill; CombinedGeometry objGeometry = new CombinedGeometry(); objGeometry.Geometry1 = new RectangleGeometry(new Rect(10, 20, 80, 70)); objGeometry.Geometry2 = new EllipseGeometry(new Point(100, 90), 40, 40); objPath.Data = objGeometry; objCanvasCombindedGeo.Children.Add(objPath); // change location on canvas Canvas.SetLeft(objPath, 150 * objCanvasCombindedGeo.Children.Count); Canvas.SetTop(objPath, 25); }
/// <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); }
private Geometry CreateGeometryTailAtBottom() { CombinedGeometry result = new CombinedGeometry(); double vert = 0; switch (this.Placement) { case EnumPlacement.BottomLeft: vert = this.TailHorizontalOffset - this.TailWidth / 2; break; case EnumPlacement.BottomCenter: this.TailHorizontalOffset = (this.ActualWidth - this.TailWidth) / 2; vert = this.TailHorizontalOffset + this.TailWidth / 2; break; case EnumPlacement.BottomRight: this.TailHorizontalOffset = this.ActualWidth - this.TailWidth - this.TailHorizontalOffset; vert = this.TailHorizontalOffset + 1.5 * this.TailWidth; break; } #region 绘制三角形 Point anglePoint1 = new Point(this.TailHorizontalOffset, this.ActualHeight - this.TailHeight); Point anglePoint2 = new Point(vert, this.ActualHeight); Point anglePoint3 = new Point(this.TailHorizontalOffset + this.TailWidth, this.ActualHeight - this.TailHeight); LineSegment as1_2 = new LineSegment(anglePoint2, true); LineSegment as2_3 = new LineSegment(anglePoint3, true); PathFigure pf = new PathFigure(); pf.IsClosed = false; pf.StartPoint = anglePoint1; pf.Segments.Add(as1_2); pf.Segments.Add(as2_3); PathGeometry g1 = new PathGeometry(); g1.Figures.Add(pf); #endregion #region 绘制矩形边框 RectangleGeometry g2 = new RectangleGeometry(new Rect(0, 0, this.ActualWidth, this.ActualHeight - this.TailHeight) , CornerRadius.TopLeft, CornerRadius.BottomRight); #endregion #region 合并 result.Geometry1 = g1; result.Geometry2 = g2; result.GeometryCombineMode = GeometryCombineMode.Union; #endregion return(result); }
public void NextFrame(object sender, EventArgs e) { if (this._numberOfFrames != 0) { if (this._frameList[this._frameCounter].disposalMethod == 2) { for (int i = 0; i < this._frameCounter; i++) { if (this._frameList[i].Visibility == Visibility.Visible) { GifFrame frame = this._frameList[this._frameCounter]; RectangleGeometry geometry = new RectangleGeometry(new Rect((double)frame.left, (double)frame.top, (double)frame.width, (double)frame.height)); this.totalTransparentGeometry = new CombinedGeometry(GeometryCombineMode.Union, this.totalTransparentGeometry, geometry); GifFrame frame2 = this._frameList[i]; RectangleGeometry geometry2 = new RectangleGeometry(new Rect((double)frame2.left, (double)frame2.top, (double)frame2.width, (double)frame2.height)); CombinedGeometry geometry3 = new CombinedGeometry(GeometryCombineMode.Exclude, geometry2, this.totalTransparentGeometry); GeometryDrawing drawing = new GeometryDrawing(Brushes.Black, new Pen(Brushes.Black, 0.0), geometry3); DrawingBrush brush = new DrawingBrush(drawing); this._frameList[i].OpacityMask = brush; } } this._frameList[this._frameCounter].Visibility = Visibility.Hidden; } if (this._frameList[this._frameCounter].disposalMethod >= 3) { this._frameList[this._frameCounter].Visibility = Visibility.Hidden; } this._frameCounter++; if (this._frameCounter < this._numberOfFrames) { this._frameList[this._frameCounter].Visibility = Visibility.Visible; this.SetTimer(this._frameList[this._frameCounter].delayTime * 10); } else { if (this._numberOfLoops != 0) { this._currentLoop++; } if ((this._currentLoop < this._numberOfLoops) || (this._numberOfLoops == 0)) { for (int j = 0; j < this._frameList.Count; j++) { this._frameList[j].Visibility = Visibility.Hidden; this._frameList[j].OpacityMask = null; } this.totalTransparentGeometry = null; this._frameCounter = 0; this._frameList[this._frameCounter].Visibility = Visibility.Visible; this.SetTimer(this._frameList[this._frameCounter].delayTime * 10); } } base.InvalidateVisual(); } }
protected override void OnRender(DrawingContext drawingContext) { drawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(0, 0, ActualWidth, ActualHeight)); if (_layout == null) { return; } var blob = _parent.Data; if (blob == null) { return; } var firstLine = (int)Math.Floor(_verticalOffset / _layout.CellHeight); var lastLine = Math.Min((int)Math.Ceiling((_verticalOffset + _viewportHeight) / _layout.CellHeight), (blob.ByteCount - 1) >> 4); var lines = GetLines(firstLine, (int)(lastLine - firstLine + 1)); drawingContext.PushTransform(new TranslateTransform(-_horizontalOffset, -(_verticalOffset % _layout.CellHeight))); PaintLineSet(drawingContext, TextBlock.GetForeground(_parent), lines); var selectionStart = _parent.SelectionStart; var selectionEnd = selectionStart + _parent.SelectionLength - 1; var firstByte = firstLine << 4; var lastByte = Math.Min(blob.ByteCount - 1, lastLine << 4 + 15); if (selectionStart < firstByte) { selectionStart = firstByte; } if (selectionEnd > lastByte) { selectionEnd = lastByte; } if (selectionStart <= selectionEnd) { var from = selectionStart - firstByte; var to = selectionEnd - firstByte; var selectionGeometry = new CombinedGeometry( GeometryCombineMode.Union, _layout.CreateSelectionGeometryFromByteRange(from, to, HexBoxDisplaySection.Byte), _layout.CreateSelectionGeometryFromByteRange(from, to, HexBoxDisplaySection.Char)); drawingContext.PushOpacity(_parent.SelectionOpacity); drawingContext.DrawGeometry(_parent.SelectionBrush, null, selectionGeometry); drawingContext.Pop(); } drawingContext.Pop(); }
private void GenerateMask() { var pendingPolygonClip = new CombinedGeometry( GeometryCombineMode.Exclude, new EllipseGeometry(Origin, Radius, Radius), new EllipseGeometry(Origin, InnerRadius, InnerRadius)); PendingPolygon.Clip = pendingPolygonClip; SuccessPolygon.Clip = pendingPolygonClip; ErrorPolygon.Clip = pendingPolygonClip; }
/// <summary> /// gets the geometry of the bounding box of the atom label /// </summary> /// <param name="parentAtom">Atom to get the geometry for</param> /// <returns></returns> public static System.Windows.Media.Geometry GetWidenedGeometry(Atom parentAtom) { Point startingPoint = parentAtom.Position, currentPos; var pen = new Pen(Brushes.Black, 2.0); var formattedText = BuildSymbolLabel(parentAtom.SymbolText, ref startingPoint, out currentPos); var initialGeo = formattedText.BuildGeometry(startingPoint); var borderGeo = initialGeo.GetWidenedPathGeometry(pen); var finalgeo = new CombinedGeometry(initialGeo, borderGeo); return(finalgeo); }
/// <summary> /// 获取g的反向图形 /// </summary> /// <param name="g"></param> /// <returns></returns> public Geometry GetReverse(Geometry g) { var converter = TypeDescriptor.GetConverter(typeof(Geometry)); Geometry Mask = new RectangleGeometry(new Rect(0, 0, 24, 24)); CombinedGeometry combinedGeometry = new CombinedGeometry(g, Mask); combinedGeometry.GeometryCombineMode = GeometryCombineMode.Xor; return(combinedGeometry); }
private Geometry CreateGeometryTailAtRight() { CombinedGeometry result = new CombinedGeometry(); //三角形默认居中 // this.TailVerticalOffset = (this.ActualHeight - this.TailHeight) / 2; switch (this.Placement) { case EnumPlacement.RightTop: //不做任何处理 break; case EnumPlacement.RightBottom: this.TailVerticalOffset = this.ActualHeight - this.TailHeight - this.TailVerticalOffset; break; case EnumPlacement.RightCenter: this.TailVerticalOffset = (this.ActualHeight - this.TailHeight) / 2; break; } #region 绘制三角形 Point arcPoint1 = new Point(this.ActualWidth - TailWidth, TailVerticalOffset); Point arcPoint2 = new Point(this.ActualWidth, TailVerticalOffset + TailHeight / 2); Point arcPoint3 = new Point(this.ActualWidth - TailWidth, TailVerticalOffset + TailHeight); LineSegment as1_2 = new LineSegment(arcPoint2, false); LineSegment as2_3 = new LineSegment(arcPoint3, false); PathFigure pf1 = new PathFigure(); pf1.IsClosed = false; pf1.StartPoint = arcPoint1; pf1.Segments.Add(as1_2); pf1.Segments.Add(as2_3); PathGeometry pg1 = new PathGeometry(); pg1.Figures.Add(pf1); #endregion #region 绘制矩形边框 RectangleGeometry rg2 = new RectangleGeometry(new Rect(0, 0, this.ActualWidth - TailWidth, this.ActualHeight) , CornerRadius.TopLeft, CornerRadius.BottomRight, new TranslateTransform(0.5, 0.5)); #endregion #region 合并两个图形 result.Geometry1 = pg1; result.Geometry2 = rg2; result.GeometryCombineMode = GeometryCombineMode.Union; #endregion return(result); }
private Geometry Reverse(Geometry RegionToReverse) { CombinedGeometry Reversed = new CombinedGeometry(GeometryCombineMode.Exclude, FPageRect, RegionToReverse); Geometry Result = Reversed.GetFlattenedPathGeometry(); if (Result.CanFreeze) { Result.Freeze(); } return(Result); }
public override void PushClipExclude(RRect rect) { var geometry = new CombinedGeometry(); geometry.Geometry1 = new RectangleGeometry(Utils.Convert(_clipStack.Peek())); geometry.Geometry2 = new RectangleGeometry(Utils.Convert(rect)); geometry.GeometryCombineMode = GeometryCombineMode.Exclude; _clipStack.Push(_clipStack.Peek()); _g.PushClip(geometry); }
protected override IEnumerable <LowerTileInfo> GetLoadedLowerTiles(IEnumerable <VisibleTileInfo> visibleTiles) { var memoryCache = (LRUMemoryCache)TileSystem.MemoryServer; var sourceServer = TileSystem.SourceServer; var actualVisibleTiles = visibleTiles.Where(tile => sourceServer.Contains(tile.Tile)).ToList(); var currLevel = TileProvider.Level; var upperLevel = GetAvailableUpperLevel(currLevel); var cache = (ICollection <TileIndex>)memoryCache.GetCachedIndexes(); var region = GetRegion(actualVisibleTiles); var server = TileSystem; var lowerTiles = TileProvider.GetTilesForRegion(region, upperLevel).Where(tile => server.IsLoaded(tile)); var plotterTransform = Plotter.Transform; var lowerTileList = new List <LowerTileInfo>(); foreach (var lowerTile in lowerTiles) { bool addToLowerTiles = false; var bounds = TileProvider.GetTileBounds(lowerTile); var shiftedScreenBounds = bounds.ViewportToScreen(plotterTransform); Geometry clip = new RectangleGeometry(shiftedScreenBounds); foreach (var tile in actualVisibleTiles) { if (tile.VisibleBounds.IntersectsWith(bounds)) { if (!cache.Contains(tile.Tile)) { addToLowerTiles = true; } else { var screenBounds = tile.VisibleBounds.ViewportToScreen(plotterTransform); clip = new CombinedGeometry(GeometryCombineMode.Exclude, clip, new RectangleGeometry(screenBounds)); } } } if (addToLowerTiles) { lowerTileList.Add(new LowerTileInfo { Id = lowerTile, Clip = clip }); } } return(lowerTileList); }
static Minimap() { s_cross = new CombinedGeometry(GeometryCombineMode.Union, new RectangleGeometry(new Rect(-7.5, -1.5, 15, 3)), new RectangleGeometry(new Rect(-1.5, -7.5, 3, 15)), new RotateTransform(45)); if (s_cross.CanFreeze) { s_cross.Freeze(); } }
private Geometry CreateGeometryTailAtLeft() { CombinedGeometry result = new CombinedGeometry(); this.TailHeight = 12; this.TailWidth = 6; switch (this.Placement) { case EnumPlacement.LeftTop: //不做任何处理 break; case EnumPlacement.LeftBottom: this.TailVerticalOffset = this.ActualHeight - this.TailHeight - this.TailVerticalOffset; break; case EnumPlacement.LeftCenter: this.TailVerticalOffset = (this.ActualHeight - this.TailHeight) / 2; break; } #region 绘制三角形 Point arcPoint1 = new Point(TailWidth, TailVerticalOffset); Point arcPoint2 = new Point(0, TailVerticalOffset + TailHeight / 2); Point arcPoint3 = new Point(TailWidth, TailVerticalOffset + TailHeight); LineSegment as1_2 = new LineSegment(arcPoint2, false); LineSegment as2_3 = new LineSegment(arcPoint3, false); PathFigure pf = new PathFigure(); pf.IsClosed = false; pf.StartPoint = arcPoint1; pf.Segments.Add(as1_2); pf.Segments.Add(as2_3); PathGeometry g1 = new PathGeometry(); g1.Figures.Add(pf); #endregion #region 绘制矩形边框 RectangleGeometry g2 = new RectangleGeometry(new Rect(TailWidth, 0, this.ActualWidth - this.TailWidth, this.ActualHeight) , CornerRadius.TopLeft, CornerRadius.BottomRight); #endregion #region 合并两个图形 result.Geometry1 = g1; result.Geometry2 = g2; result.GeometryCombineMode = GeometryCombineMode.Union; #endregion return(result); }