static DpiHelper() { var dC = InteropMethods.GetDC(IntPtr.Zero); if (dC != IntPtr.Zero) { DeviceDpiX = InteropMethods.GetDeviceCaps(dC, 88); DeviceDpiY = InteropMethods.GetDeviceCaps(dC, 90); InteropMethods.ReleaseDC(IntPtr.Zero, dC); } else { DeviceDpiX = LogicalDpi; DeviceDpiY = LogicalDpi; } var identity = Matrix.Identity; var identity2 = Matrix.Identity; identity.Scale(DeviceDpiX / LogicalDpi, DeviceDpiY / LogicalDpi); identity2.Scale(LogicalDpi / DeviceDpiX, LogicalDpi / DeviceDpiY); TransformFromDevice = new MatrixTransform(identity2); TransformFromDevice.Freeze(); TransformToDevice = new MatrixTransform(identity); TransformToDevice.Freeze(); }
public System.Windows.Media.Geometry GetTransformedGeometry(SceneView view, SceneElement element, System.Windows.Media.Geometry renderedGeometry, Matrix matrix) { if (Adorner.NonAffineTransformInParentStack(element)) { PathGeometry pathGeometry = renderedGeometry.GetFlattenedPathGeometry().Clone(); Transform transform = view.Artboard.CalculateTransformFromContentToArtboard(); foreach (PathFigure pathFigure in pathGeometry.Figures) { Point startPoint = pathFigure.StartPoint; Point point1 = view.TransformPoint(element.Visual, (IViewObject)view.HitTestRoot, startPoint); pathFigure.StartPoint = transform.Transform(point1); foreach (PathSegment pathSegment in pathFigure.Segments) { LineSegment lineSegment; if ((lineSegment = pathSegment as LineSegment) != null) { Point point2 = lineSegment.Point; Point point3 = view.TransformPoint(element.Visual, (IViewObject)view.HitTestRoot, point2); lineSegment.Point = transform.Transform(point3); } else { PolyLineSegment polyLineSegment; if ((polyLineSegment = pathSegment as PolyLineSegment) != null) { for (int index = 0; index < polyLineSegment.Points.Count; ++index) { Point point2 = polyLineSegment.Points[index]; Point point3 = view.TransformPoint(element.Visual, (IViewObject)view.HitTestRoot, point2); polyLineSegment.Points[index] = transform.Transform(point3); } } } } } return((System.Windows.Media.Geometry)pathGeometry); } Transform transform1 = renderedGeometry.Transform; if (transform1 != null) { matrix = transform1.Value * matrix; } MatrixTransform matrixTransform = new MatrixTransform(matrix); matrixTransform.Freeze(); if (renderedGeometry.IsFrozen) { GeometryCollection geometryCollection = new GeometryCollection(1); geometryCollection.Add(renderedGeometry); geometryCollection.Freeze(); renderedGeometry = (System.Windows.Media.Geometry) new GeometryGroup() { Children = geometryCollection }; } renderedGeometry.Transform = (Transform)matrixTransform; renderedGeometry.Freeze(); return(renderedGeometry); }
public EventRenderSlice(Renderer renderer, int channel, string name, int imagewidth, int imageheight, string unit, XElement unisensnode) : base(renderer, channel, name, imagewidth, imageheight, unit, unisensnode) { Rect rect = new Rect(0.0, 0.0, imagewidth, imageheight); ImageDrawing imagedrawing = new ImageDrawing(WBmp, rect); this.geometrygroup = new GeometryGroup(); MatrixTransform mt = new MatrixTransform(0.0, 1.0, -1.0, 0.0, imagewidth, 0.0); // die -90° rotation vom signalstacker wieder rückgängig machen mt.Freeze(); this.geometrygroup.Transform = mt; GeometryDrawing geometrydrawing = new GeometryDrawing( new SolidColorBrush(System.Windows.Media.Color.FromArgb((byte)(color >> 24), (byte)(color >> 16), (byte)(color >> 8), (byte)color)), null, this.geometrygroup); this.geometrydrawing = geometrydrawing; DrawingGroup drawinggroup = new DrawingGroup(); drawinggroup.Children.Add(imagedrawing); drawinggroup.Children.Add(geometrydrawing); drawinggroup.ClipGeometry = new RectangleGeometry(rect); this.imagesource = new DrawingImage(drawinggroup); }
public override void Draw(DrawingContext drawingContext, Matrix matrix) { bool flag; if (this.IsX) { GridColumnSelectionSet columnSelectionSet = ((GridRowColumnAdornerSet)this.AdornerSet).GridColumnSelectionSet; flag = columnSelectionSet.GridLineMode && columnSelectionSet.IsSelected(this.Grid.ColumnDefinitions[this.Index]); } else { GridRowSelectionSet gridRowSelectionSet = ((GridRowColumnAdornerSet)this.AdornerSet).GridRowSelectionSet; flag = gridRowSelectionSet.GridLineMode && gridRowSelectionSet.IsSelected(this.Grid.RowDefinitions[this.Index]); } Brush brush = flag ? this.ActiveBrush : this.InactiveBrush; Matrix matrix1 = this.TruncateMatrix(matrix); Point center = this.GetCenter(matrix, matrix1); matrix1.Translate(center.X, center.Y); if (!this.IsX) { matrix1.RotatePrepend(-90.0); } MatrixTransform matrixTransform = new MatrixTransform(matrix1); matrixTransform.Freeze(); drawingContext.PushTransform((Transform)matrixTransform); drawingContext.DrawGeometry(brush, this.ThinPen, LayoutAdorner.TriangleGeometry); drawingContext.Pop(); }
internal void SetMatrix(Matrix matrix) { MatrixTransform matrixTransform = new MatrixTransform(matrix); matrixTransform.Freeze(); this.VisualTransform = (Transform)matrixTransform; }
public override void Draw(DrawingContext ctx, Matrix matrix) { bool flag = false; Point pointBegin; Point pointEnd; this.GetPoints(out pointBegin, out pointEnd); if (this.IsX) { GridColumnSelectionSet columnSelectionSet = ((GridRowColumnAdornerSet)this.AdornerSet).GridColumnSelectionSet; if (columnSelectionSet != null) { flag = !columnSelectionSet.GridLineMode && columnSelectionSet.IsSelected(this.Grid.ColumnDefinitions[this.Index]); } } else { GridRowSelectionSet gridRowSelectionSet = ((GridRowColumnAdornerSet)this.AdornerSet).GridRowSelectionSet; if (gridRowSelectionSet != null) { flag = !gridRowSelectionSet.GridLineMode && gridRowSelectionSet.IsSelected(this.Grid.RowDefinitions[this.Index]); } } MatrixTransform matrixTransform = new MatrixTransform(matrix); matrixTransform.Freeze(); ctx.PushTransform((Transform)matrixTransform); ctx.DrawRectangle(flag ? (Brush)LayoutBackgroundAdorner.SelectedBrush : (Brush)LayoutBackgroundAdorner.UnselectedBrush, (Pen)null, new Rect(pointBegin, pointEnd)); ctx.Pop(); }
static DpiHelper() { var dC = InteropMethods.GetDC(IntPtr.Zero); if (dC != IntPtr.Zero) { // 沿着屏幕宽度每逻辑英寸的像素数。在具有多个显示器的系统中,这个值对所有显示器都是相同的 const int logicPixelsX = 88; // 沿着屏幕高度每逻辑英寸的像素数 const int logicPixelsY = 90; DeviceDpiX = InteropMethods.GetDeviceCaps(dC, logicPixelsX); DeviceDpiY = InteropMethods.GetDeviceCaps(dC, logicPixelsY); InteropMethods.ReleaseDC(IntPtr.Zero, dC); } else { DeviceDpiX = LogicalDpi; DeviceDpiY = LogicalDpi; } var identity = Matrix.Identity; var identity2 = Matrix.Identity; identity.Scale(DeviceDpiX / LogicalDpi, DeviceDpiY / LogicalDpi); identity2.Scale(LogicalDpi / DeviceDpiX, LogicalDpi / DeviceDpiY); TransformFromDevice = new MatrixTransform(identity2); TransformFromDevice.Freeze(); TransformToDevice = new MatrixTransform(identity); TransformToDevice.Freeze(); }
static DpiHelper() { var dc = NativeMethods.NativeMethods.GetDC(IntPtr.Zero); if (dc != IntPtr.Zero) { DeviceDpiX = NativeMethods.NativeMethods.GetDeviceCaps(dc, 88); DeviceDpiY = NativeMethods.NativeMethods.GetDeviceCaps(dc, 90); NativeMethods.NativeMethods.ReleaseDC(IntPtr.Zero, dc); } else { DeviceDpiX = 96.0; DeviceDpiY = 96.0; } var identity1 = Matrix.Identity; var identity2 = Matrix.Identity; identity1.Scale(DeviceDpiX / 96.0, DeviceDpiY / 96.0); identity2.Scale(96.0 / DeviceDpiX, 96.0 / DeviceDpiY); transformFromDevice = new MatrixTransform(identity2); transformFromDevice.Freeze(); transformToDevice = new MatrixTransform(identity1); transformToDevice.Freeze(); }
protected DpiHelper(double logicalDpi) { LogicalDpiX = logicalDpi; LogicalDpiY = logicalDpi; IntPtr dc = NativeMethods.User32.GetDC(IntPtr.Zero); if (dc != IntPtr.Zero) { DeviceDpiX = NativeMethods.Gdi32.GetDeviceCaps(dc, 88); DeviceDpiY = NativeMethods.Gdi32.GetDeviceCaps(dc, 90); NativeMethods.User32.ReleaseDC(IntPtr.Zero, dc); } else { DeviceDpiX = LogicalDpiX; DeviceDpiY = LogicalDpiY; } System.Windows.Media.Matrix identity1 = System.Windows.Media.Matrix.Identity; System.Windows.Media.Matrix identity2 = System.Windows.Media.Matrix.Identity; identity1.Scale(DeviceDpiX / LogicalDpiX, DeviceDpiY / LogicalDpiY); identity2.Scale(LogicalDpiX / DeviceDpiX, LogicalDpiY / DeviceDpiY); _transformFromDevice = new MatrixTransform(identity2); _transformFromDevice.Freeze(); _transformToDevice = new MatrixTransform(identity1); _transformToDevice.Freeze(); }
void UpdateVisualTransform() { if (drawingVisual is null) { return; } var t = new MatrixTransform(1, 0, 0, lineTransform.VerticalScale, 0, TextTop); t.Freeze(); drawingVisual.Transform = t; }
public override void Draw(DrawingContext ctx, Matrix matrix) { if (!this.IsValid) { return; } PathFigureEditor pathFigureEditor = new PathFigureEditor(this.PathGeometry.Figures[this.FigureIndex]); StreamGeometry streamGeometry = new StreamGeometry(); StreamGeometryContext streamGeometryContext = streamGeometry.Open(); switch (this.PathPointKind) { case PathPointKind.Start: throw new InvalidOperationException(ExceptionStringTable.PathSegmentAdornerIsolatedPointSegment); case PathPointKind.Arc: ArcSegment arcSegment = (ArcSegment)pathFigureEditor.PathFigure.Segments[this.SegmentIndex]; streamGeometryContext.BeginFigure(this.GetPoint(pathFigureEditor, -1), false, false); streamGeometryContext.ArcTo(arcSegment.Point, arcSegment.Size, arcSegment.RotationAngle, arcSegment.IsLargeArc, arcSegment.SweepDirection, true, false); break; case PathPointKind.Line: streamGeometryContext.BeginFigure(this.GetPoint(pathFigureEditor, -1), false, false); streamGeometryContext.LineTo(this.GetPoint(pathFigureEditor, 0), true, false); break; case PathPointKind.Quadratic: streamGeometryContext.BeginFigure(this.GetPoint(pathFigureEditor, -2), false, false); streamGeometryContext.QuadraticBezierTo(this.GetPoint(pathFigureEditor, -1), this.GetPoint(pathFigureEditor, 0), true, false); break; case PathPointKind.Cubic: streamGeometryContext.BeginFigure(this.GetPoint(pathFigureEditor, -3), false, false); streamGeometryContext.BezierTo(this.GetPoint(pathFigureEditor, -2), this.GetPoint(pathFigureEditor, -1), this.GetPoint(pathFigureEditor, 0), true, false); break; case PathPointKind.BezierHandle: throw new InvalidOperationException(ExceptionStringTable.PathSegmentAdornerLastPointIsBezier); default: throw new NotImplementedException(ExceptionStringTable.PathSegmentAdornerUnknownPathPoint); } streamGeometryContext.Close(); MatrixTransform matrixTransform = new MatrixTransform(matrix); matrixTransform.Freeze(); streamGeometry.Transform = (Transform)matrixTransform; streamGeometry.Freeze(); Pen pen = this.IsActive ? this.ThickPathSegmentPen : this.ThinPathSegmentPen; ctx.DrawGeometry((Brush)null, pen, (System.Windows.Media.Geometry)streamGeometry); ctx.DrawGeometry((Brush)null, PathSegmentAdorner.HitTestPen, (System.Windows.Media.Geometry)streamGeometry); }
public override void Draw(DrawingContext drawingContext, Matrix matrix) { Point pointBegin; Point pointEnd; this.GetPoints(out pointBegin, out pointEnd, matrix); MatrixTransform matrixTransform = new MatrixTransform(matrix); matrixTransform.Freeze(); drawingContext.PushTransform((Transform)matrixTransform); drawingContext.DrawRectangle((Brush)LayoutBackgroundAdorner.UnselectedBrush, (Pen)null, new Rect(pointBegin, pointEnd)); drawingContext.Pop(); }
private void SourceChanged(ImageSource image) { var transform = new MatrixTransform { Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d) }; transform.Freeze(); Fill = new ImageBrush { ImageSource = image, RelativeTransform = transform }; }
Brush MakeBrushFromVisual(Visual visual, Rect bounds) { var viewport = visual as Viewport3D; if (viewport == null) { Drawing drawing = VisualTreeHelper.GetDrawing(visual); if (drawOutlines) { bounds.Inflate(OutlinePen.Thickness / 2, OutlinePen.Thickness / 2); } var offsetMatrix = new Matrix(1, 0, 0, 1, -bounds.Left, -bounds.Top); var offsetMatrixTransform = new MatrixTransform(offsetMatrix); offsetMatrixTransform.Freeze(); var drawingVisual = new DrawingVisual(); var drawingContext = drawingVisual.RenderOpen(); drawingContext.PushTransform(offsetMatrixTransform); if (drawOutlines) { drawingContext.DrawRectangle(null, OutlinePen, bounds); } drawingContext.DrawDrawing(drawing); drawingContext.Pop(); drawingContext.Close(); visual = drawingVisual; } var renderTargetBitmap = new RenderTargetBitmap((int)Math.Ceiling(bounds.Width), (int)Math.Ceiling(bounds.Height), 96, 96, PixelFormats.Default); if (viewport != null) { typeof(RenderTargetBitmap).GetMethod("RenderForBitmapEffect", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(renderTargetBitmap, new object[] { visual, Matrix.Identity, Rect.Empty }); } else { renderTargetBitmap.Render(visual); } renderTargetBitmap.Freeze(); var imageBrush = new ImageBrush(renderTargetBitmap); imageBrush.Freeze(); return(imageBrush); }
private void DrawEndpoint(DrawingContext drawingContext, Brush brush, Pen pen, Point point, Matrix matrix) { Matrix matrix1 = this.TruncateMatrix(matrix); matrix1.Translate(point.X, point.Y); if (!this.IsX) { matrix1.RotatePrepend(-90.0); } MatrixTransform matrixTransform = new MatrixTransform(matrix1); matrixTransform.Freeze(); drawingContext.PushTransform((Transform)matrixTransform); drawingContext.DrawGeometry(brush, pen, LayoutAdorner.TriangleGeometry); drawingContext.Pop(); }
public override void Perform() { MatrixTransform matrixTransform = (MatrixTransform)Border.RenderTransform; Matrix matrix = matrixTransform.Matrix; if (matrixTransform.CanFreeze) { matrixTransform.Freeze(); } MatrixTransform matrixTransformClone = matrixTransform.Clone(); matrix.Scale(10, 10); matrixTransformClone = new MatrixTransform(matrix); if (matrixTransformClone.CanFreeze) { matrixTransformClone.Freeze(); } }
public RasterRenderSlice(Renderer renderer, int channel, string name, int imagewidth, int imageheight, string unit, XElement unisensnode) : base(renderer, channel, name, ColorRelaxed.GetNextColor(), unit, unisensnode) { this.ImageWidth = imagewidth; this.ImageHeight = imageheight; this.yTemp = new double[channel + 1]; this.xlastplot = 0; this.Scale = 0.05f; this.Offset = (float)(imagewidth >> 1); // PixelFormats.Indexed8 wäre super, aber das wird laut Doku konvertiert bevor // es ins GPU-RAM geschoben wird, also kein Performancegewinn hier. // Wenn man direkten Zugriff auf DirectX hätte, könnte man durchaus eine 8Bit Surface // mit ColorKey machen. this.WBmp = new WriteableBitmap(imagewidth, this.ImageHeight, 96, 96, PixelFormats.Pbgra32, null); this.argb = (uint *)this.WBmp.BackBuffer; this.strideUInt32 = this.WBmp.BackBufferStride >> 2; this.geometrygroup = new GeometryGroup(); MatrixTransform mt = new MatrixTransform(0.0, 1.0, -1.0, 0.0, imagewidth, 0.0); mt.Freeze(); this.geometrygroup.Transform = mt; GeometryDrawing geometrydrawing = new GeometryDrawing( new SolidColorBrush(System.Windows.Media.Color.FromArgb((byte)(color >> 24), (byte)(color >> 16), (byte)(color >> 8), (byte)color)), null, this.geometrygroup); geometrydrawing.Pen = new Pen(new SolidColorBrush(System.Windows.Media.Color.FromArgb((byte)(color >> 24), (byte)(color >> 16), (byte)(color >> 8), (byte)color)), 1); this.geometrydrawing = geometrydrawing; DrawingGroup drawinggroup = new DrawingGroup(); drawinggroup.Children.Add(geometrydrawing); Rect rect = new Rect(0.0, 0.0, imagewidth, this.ImageHeight); ImageDrawing imagedrawing = new ImageDrawing(WBmp, rect); drawinggroup.Children.Add(imagedrawing); //this.imagesource = this.WBmp; this.imagesource = new DrawingImage(drawinggroup); }
public override void Draw(DrawingContext drawingContext, Matrix matrix) { if (this.ParentRelative && this.Element.ParentElement == null || this.Element.Visual == null) { return; } ImageSource imageSource = (ImageSource)null; switch (this.LayoutLockState) { case LayoutLockState.Locked: imageSource = this.LockImage; break; case LayoutLockState.Unlocked: imageSource = this.UnlockImage; break; case LayoutLockState.Neither: imageSource = this.AutoImage; break; } Point point = this.GetCenter(matrix); if (PresentationSource.FromVisual((Visual)this) != null) { point = this.PointFromScreen(this.PointToScreen(point)); } if (this.ParentRelative) { matrix = this.Element.GetComputedTransformFromVisualParent() * matrix; } Matrix matrix1 = this.TruncateMatrix(matrix); matrix1.OffsetX = point.X; matrix1.OffsetY = point.Y; MatrixTransform matrixTransform = new MatrixTransform(matrix1); matrixTransform.Freeze(); drawingContext.PushTransform((Transform)matrixTransform); drawingContext.DrawImage(imageSource, new Rect(-imageSource.Width / 2.0, -imageSource.Height / 2.0, imageSource.Width, imageSource.Height)); drawingContext.Pop(); }
protected void DrawAdorner(DrawingContext context, Matrix matrix, SceneElement adornedElement, Brush borderBrush, DrawingImage icon, string message) { Rect actualBounds = adornedElement.ViewModel.DefaultView.GetActualBounds(adornedElement.ViewTargetElement); if (actualBounds.IsEmpty) { return; } MatrixTransform matrixTransform = new MatrixTransform(matrix); matrixTransform.Freeze(); System.Windows.Media.Geometry clipGeometry = (System.Windows.Media.Geometry) new RectangleGeometry(actualBounds); clipGeometry.Freeze(); context.PushOpacity(0.5); System.Windows.Media.Geometry rectangleGeometry = Adorner.GetTransformedRectangleGeometry(actualBounds, matrix, 4.0); context.DrawGeometry((Brush)Brushes.White, (Pen)null, rectangleGeometry); context.Pop(); context.PushTransform((Transform)matrixTransform); context.PushClip(clipGeometry); double num1 = 1.0 / this.DesignerContext.ActiveView.Zoom; double num2 = num1 * 12.0; double num3 = num1 * 24.0; Rect rectangle = new Rect(actualBounds.Left + num2, actualBounds.Top + num2, num3, num3); context.DrawImage((ImageSource)icon, rectangle); FontFamily fontFamily = (FontFamily)Application.Current.FindResource((object)SystemFonts.IconFontFamilyKey); double num4 = (double)Application.Current.FindResource((object)SystemFonts.IconFontSizeKey); Typeface typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); FormattedText formattedText = new FormattedText(message, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, num4 * num1, (Brush)Brushes.Black); formattedText.MaxTextWidth = Math.Min(3579139.0, Math.Max(0.0, actualBounds.Width - num3 - 3.0 * num2)); Point origin = new Point(actualBounds.Left + num3 + 2.0 * num2, actualBounds.Top + num2 + Math.Max(0.0, (num3 - formattedText.Height) / 2.0)); context.DrawText(formattedText, origin); context.Pop(); context.Pop(); context.PushOpacity(0.5); Pen pen = new Pen(borderBrush, 4.0); pen.Freeze(); context.DrawGeometry((Brush)null, pen, rectangleGeometry); context.Pop(); }
public override void Draw(DrawingContext ctx, Matrix matrix) { Point pointBegin; Point pointEnd; this.GetPoints(out pointBegin, out pointEnd, matrix); MatrixTransform matrixTransform = new MatrixTransform(matrix); matrixTransform.Freeze(); ctx.PushTransform((Transform)matrixTransform); ctx.PushOpacity(0.25); ctx.DrawRectangle(this.ActiveBrush, (Pen)null, new Rect(pointBegin, pointEnd)); ctx.Pop(); ctx.Pop(); if (!this.isMouseOver || double.IsNaN(this.position)) { return; } this.GetLinePoints(matrix, out pointBegin, out pointEnd); ctx.DrawLine(NewGridlineAdorner.NewGridlinePen, pointBegin, pointEnd); this.DrawEndpoint(ctx, NewGridlineAdorner.NewGridlineBrush, NewGridlineAdorner.NewGridlinePen, pointBegin, matrix); }
public void DrawAdorner(DrawingContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (this.formattedText == null) { return; } context.PushTransform((Transform)this.translateToPosition); Matrix matrix = new Matrix(); matrix.ScaleAt(1.0 / this.view.Zoom, 1.0 / this.view.Zoom, 0.0, 0.0); MatrixTransform matrixTransform = new MatrixTransform(matrix); matrixTransform.Freeze(); context.PushTransform((Transform)matrixTransform); TranslateTransform translateTransform = new TranslateTransform(this.offset.X, this.offset.Y); translateTransform.Freeze(); context.PushTransform((Transform)translateTransform); Rect rectangle = new Rect(0.0, 0.0, this.formattedText.Width + 8.0, this.formattedText.Height + 2.0); context.DrawRoundedRectangle(this.backgroundBrush, (Pen)null, rectangle, 3.0, 3.0); context.DrawText(this.formattedText, new Point(4.0, 0.0)); context.Pop(); context.Pop(); context.Pop(); if (!(this.closeDelay != TimeSpan.MaxValue) || !(this.closeDelay != TimeSpan.MinValue) || !(this.closeDelay != TimeSpan.Zero)) { return; } this.closeTimer = new DispatcherTimer(DispatcherPriority.Normal); this.closeTimer.Interval = this.closeDelay; this.closeTimer.Tick += new EventHandler(this.CloseAdornerTimer_Tick); this.closeTimer.Start(); }
protected override void OnRender(DrawingContext dc) { // Draw background dc.DrawRectangle(Brushes.White, null, new Rect(RenderSize)); Transform t = new MatrixTransform(TheModel.GetTikzToScreenTransform().ToWpfMatrix()); t.Freeze(); Pen pen = new Pen(Brushes.WhiteSmoke, 1); pen.Freeze(); TheModel.DrawRaster( (p1, p2) => dc.DrawLine(pen, t.Transform(p1), t.Transform(p2)), (r1, r2) => { EllipseGeometry eg = new EllipseGeometry(new Point(0, 0), r1, r2); eg.Transform = t; eg.Freeze(); dc.DrawGeometry(null, pen, eg); }); }
/// <summary> /// Updates a RenderSlice with a new width and new height. /// Width and height are mixed up, because the bitmap is rendered in rotation of 90°. /// This method changes all information of the RenderSlice. /// </summary> /// <param name="rs">Change the dimensions of this RenderSlice</param> /// <param name="imageWidth">New image width in pixels (width is the unit or y axis)</param> /// <param name="imageHeight">New image height in pixels (height is the time or x axis)</param> public unsafe static void RenderSlice_Update(RenderSlice rs, int imageWidth, double imageHeight) { DrawingGroup drawinggroup = new DrawingGroup(); ((RasterRenderSlice)rs).ImageHeight = (int)imageHeight; ((RasterRenderSlice)rs).ImageWidth = imageWidth; ((RasterRenderSlice)rs).WBmp = new WriteableBitmap(imageWidth, (int)imageHeight, 96, 96, PixelFormats.Pbgra32, null); ((RasterRenderSlice)rs).argb = (uint *)((RasterRenderSlice)rs).WBmp.BackBuffer; ((RasterRenderSlice)rs).strideUInt32 = ((RasterRenderSlice)rs).WBmp.BackBufferStride >> 2; Rect rect = new Rect(0.0, 0.0, imageWidth, ((RasterRenderSlice)rs).ImageHeight); ImageDrawing imagedrawing = new ImageDrawing(((RasterRenderSlice)rs).WBmp, rect); MatrixTransform mt = new MatrixTransform(0.0, 1.0, -1.0, 0.0, imageWidth, 0); mt.Freeze(); drawinggroup.Children.Add(imagedrawing); switch (rs.Renderer.ToString()) { case "UnisensViewer.EventStringRenderer": ((EventRenderSlice)rs).geometrygroup.Transform = mt; drawinggroup.Children.Add(((EventRenderSlice)rs).geometrydrawing); break; case "UnisensViewer.EventValueRenderer": ((RasterRenderSlice)rs).geometrygroup.Transform = mt; drawinggroup.Children.Add(((RasterRenderSlice)rs).geometrydrawing); break; default: break; } drawinggroup.ClipGeometry = new RectangleGeometry(rect); ((RasterRenderSlice)rs).imagesource = new DrawingImage(drawinggroup); }
private void RenderTheme(DrawingContext dc) { Size size = RenderSize; bool horizontal = Orientation == Orientation.Horizontal; bool isClickable = IsClickable && IsEnabled; bool isHovered = isClickable && IsHovered; bool isPressed = isClickable && IsPressed; ListSortDirection?sortDirection = SortDirection; bool isSorted = sortDirection != null; bool isSelected = IsSelected; EnsureCache((int)AeroLiteFreezables.NumFreezables); if (horizontal) { // When horizontal, rotate the rendering by -90 degrees Matrix m1 = new Matrix(); m1.RotateAt(-90.0, 0.0, 0.0); Matrix m2 = new Matrix(); m2.Translate(0.0, size.Height); MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2); horizontalRotate.Freeze(); dc.PushTransform(horizontalRotate); double temp = size.Width; size.Width = size.Height; size.Height = temp; } // Fill the background AeroLiteFreezables backgroundType = AeroLiteFreezables.NormalBackground; if (isPressed) { backgroundType = AeroLiteFreezables.PressedBackground; } else if (isHovered) { backgroundType = AeroLiteFreezables.HoveredBackground; } SolidColorBrush background = (SolidColorBrush)GetCachedFreezable((int)backgroundType); if (background == null) { background = new SolidColorBrush(); switch (backgroundType) { case AeroLiteFreezables.NormalBackground: background.Color = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF); break; case AeroLiteFreezables.PressedBackground: background.Color = Color.FromArgb(0xFF, 0x85, 0xD2, 0xF5); break; case AeroLiteFreezables.HoveredBackground: background.Color = Color.FromArgb(0xFF, 0xBC, 0xEC, 0xFC); break; } background.Freeze(); CacheFreezable(background, (int)backgroundType); } dc.DrawRectangle(background, null, new Rect(0.0, 0.0, size.Width, size.Height)); if (size.Width >= 2.0 || size.Height >= 2.0) { // Draw the borders on the sides AeroLiteFreezables sideType = AeroLiteFreezables.NormalSides; if (isPressed) { sideType = AeroLiteFreezables.PressedSides; } else if (isHovered) { sideType = AeroLiteFreezables.HoveredSides; } if (SeparatorVisibility == Visibility.Visible) { Brush sideBrush; if (SeparatorBrush != null) { sideBrush = SeparatorBrush; } else { sideBrush = (Brush)GetCachedFreezable((int)sideType); if (sideBrush == null) { switch (sideType) { case AeroLiteFreezables.NormalSides: sideBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xDE, 0xDF, 0xE1)); break; case AeroLiteFreezables.PressedSides: sideBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x4F, 0x90, 0xAE)); break; case AeroLiteFreezables.HoveredSides: sideBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x69, 0xBB, 0xE3)); break; } sideBrush.Freeze(); CacheFreezable(sideBrush, (int)sideType); } } if (size.Width >= 2.0) { if (horizontal) { dc.DrawRectangle(sideBrush, null, new Rect(0.0, 0.0, 1.0, size.Height)); // left if (sideType != AeroLiteFreezables.NormalSides) { dc.DrawRectangle(sideBrush, null, new Rect(size.Width - 0.0, 0.0, 1.0, size.Height)); // right } } else { if (sideType != AeroLiteFreezables.NormalSides) { dc.DrawRectangle(sideBrush, null, new Rect(-1.0, 0.0, 1.0, size.Height)); // left } dc.DrawRectangle(sideBrush, null, new Rect(size.Width - 1.0, 0.0, 1.0, size.Height)); // right } } if (size.Height >= 2.0) { dc.DrawRectangle(sideBrush, null, new Rect(0.0, 0.0, size.Width, 1.0)); // top dc.DrawRectangle(sideBrush, null, new Rect(0.0, size.Height - 1.0, size.Width, 1.0)); // bottom } } } if (isSorted && (size.Width > 14.0) && (size.Height > 10.0)) { // Draw the sort arrow TranslateTransform positionTransform = new TranslateTransform((size.Width - 8.0) * 0.5, 1.0); positionTransform.Freeze(); dc.PushTransform(positionTransform); bool ascending = (sortDirection == ListSortDirection.Ascending); PathGeometry arrowGeometry = (PathGeometry)GetCachedFreezable(ascending ? (int)AeroLiteFreezables.ArrowUpGeometry : (int)AeroLiteFreezables.ArrowDownGeometry); if (arrowGeometry == null) { arrowGeometry = new PathGeometry(); PathFigure arrowFigure = new PathFigure(); if (ascending) { arrowFigure.StartPoint = new Point(0.0, 4.0); LineSegment line = new LineSegment(new Point(4.0, 0.0), false); line.Freeze(); arrowFigure.Segments.Add(line); line = new LineSegment(new Point(8.0, 4.0), false); line.Freeze(); arrowFigure.Segments.Add(line); } else { arrowFigure.StartPoint = new Point(0.0, 0.0); LineSegment line = new LineSegment(new Point(8.0, 0.0), false); line.Freeze(); arrowFigure.Segments.Add(line); line = new LineSegment(new Point(4.0, 4.0), false); line.Freeze(); arrowFigure.Segments.Add(line); } arrowFigure.IsClosed = true; arrowFigure.Freeze(); arrowGeometry.Figures.Add(arrowFigure); arrowGeometry.Freeze(); CacheFreezable(arrowGeometry, ascending ? (int)AeroLiteFreezables.ArrowUpGeometry : (int)AeroLiteFreezables.ArrowDownGeometry); } // Draw two arrows, one inset in the other. This is to achieve a double gradient over both the border and the fill. SolidColorBrush arrowFill = (SolidColorBrush)GetCachedFreezable((int)AeroLiteFreezables.ArrowFill); if (arrowFill == null) { arrowFill = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)); arrowFill.Freeze(); CacheFreezable(arrowFill, (int)AeroLiteFreezables.ArrowFill); } dc.DrawGeometry(arrowFill, null, arrowGeometry); dc.Pop(); // Position Transform } if (horizontal) { dc.Pop(); // Horizontal Rotate } }
private void RenderTheme(DrawingContext dc) { Size size = RenderSize; bool horizontal = Orientation == Orientation.Horizontal; bool isClickable = IsClickable && IsEnabled; bool isHovered = isClickable && IsHovered; bool isPressed = isClickable && IsPressed; ListSortDirection?sortDirection = SortDirection; bool isSorted = sortDirection != null; bool isSelected = IsSelected; bool hasBevel = (!isHovered && !isPressed && !isSorted && !isSelected); EnsureCache((int)AeroFreezables.NumFreezables); if (horizontal) { // When horizontal, rotate the rendering by -90 degrees Matrix m1 = new Matrix(); m1.RotateAt(-90.0, 0.0, 0.0); Matrix m2 = new Matrix(); m2.Translate(0.0, size.Height); MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2); horizontalRotate.Freeze(); dc.PushTransform(horizontalRotate); double temp = size.Width; size.Width = size.Height; size.Height = temp; } if (hasBevel) { // This is a highlight that can be drawn by just filling the background with the color. // It will be seen through the gab between the border and the background. LinearGradientBrush bevel = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.NormalBevel); if (bevel == null) { bevel = new LinearGradientBrush(); bevel.StartPoint = new Point(); bevel.EndPoint = new Point(0.0, 1.0); bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0)); bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4)); bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFD), 0.4)); bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFB, 0xFC, 0xFC), 1.0)); bevel.Freeze(); CacheFreezable(bevel, (int)AeroFreezables.NormalBevel); } dc.DrawRectangle(bevel, null, new Rect(0.0, 0.0, size.Width, size.Height)); } // Fill the background AeroFreezables backgroundType = AeroFreezables.NormalBackground; if (isPressed) { backgroundType = AeroFreezables.PressedBackground; } else if (isHovered) { backgroundType = AeroFreezables.HoveredBackground; } else if (isSorted || isSelected) { backgroundType = AeroFreezables.SortedBackground; } LinearGradientBrush background = (LinearGradientBrush)GetCachedFreezable((int)backgroundType); if (background == null) { background = new LinearGradientBrush(); background.StartPoint = new Point(); background.EndPoint = new Point(0.0, 1.0); switch (backgroundType) { case AeroFreezables.NormalBackground: background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF7, 0xF8, 0xFA), 0.4)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF1, 0xF2, 0xF4), 1.0)); break; case AeroFreezables.PressedBackground: background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.0)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.4)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8D, 0xD6, 0xF7), 0.4)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8A, 0xD1, 0xF5), 1.0)); break; case AeroFreezables.HoveredBackground: background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.0)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.4)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xED, 0xFF), 0.4)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB7, 0xE7, 0xFB), 1.0)); break; case AeroFreezables.SortedBackground: background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF9, 0xFC), 0.0)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF9, 0xFC), 0.4)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE1, 0xF1, 0xF9), 0.4)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xD8, 0xEC, 0xF6), 1.0)); break; } background.Freeze(); CacheFreezable(background, (int)backgroundType); } dc.DrawRectangle(background, null, new Rect(0.0, 0.0, size.Width, size.Height)); if (size.Width >= 2.0) { // Draw the borders on the sides AeroFreezables sideType = AeroFreezables.NormalSides; if (isPressed) { sideType = AeroFreezables.PressedSides; } else if (isHovered) { sideType = AeroFreezables.HoveredSides; } else if (isSorted || isSelected) { sideType = AeroFreezables.SortedSides; } if (SeparatorVisibility == Visibility.Visible) { Brush sideBrush; if (SeparatorBrush != null) { sideBrush = SeparatorBrush; } else { sideBrush = (Brush)GetCachedFreezable((int)sideType); if (sideBrush == null) { LinearGradientBrush lgBrush = null; if (sideType != AeroFreezables.SortedSides) { lgBrush = new LinearGradientBrush(); lgBrush.StartPoint = new Point(); lgBrush.EndPoint = new Point(0.0, 1.0); sideBrush = lgBrush; } switch (sideType) { case AeroFreezables.NormalSides: lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF2, 0xF2), 0.0)); lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEF, 0xEF, 0xEF), 0.4)); lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE7, 0xE8, 0xEA), 0.4)); lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xDE, 0xDF, 0xE1), 1.0)); break; case AeroFreezables.PressedSides: lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x7A, 0x9E, 0xB1), 0.0)); lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x7A, 0x9E, 0xB1), 0.4)); lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x50, 0x91, 0xAF), 0.4)); lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x4D, 0x8D, 0xAD), 1.0)); break; case AeroFreezables.HoveredSides: lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x88, 0xCB, 0xEB), 0.0)); lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x88, 0xCB, 0xEB), 0.4)); lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x69, 0xBB, 0xE3), 0.4)); lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x69, 0xBB, 0xE3), 1.0)); break; case AeroFreezables.SortedSides: sideBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x96, 0xD9, 0xF9)); break; } sideBrush.Freeze(); CacheFreezable(sideBrush, (int)sideType); } } dc.DrawRectangle(sideBrush, null, new Rect(0.0, 0.0, 1.0, Max0(size.Height - 0.95))); dc.DrawRectangle(sideBrush, null, new Rect(size.Width - 1.0, 0.0, 1.0, Max0(size.Height - 0.95))); } } if (isPressed && (size.Width >= 4.0) && (size.Height >= 4.0)) { // When pressed, there are added borders on the left and top LinearGradientBrush topBrush = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.PressedTop); if (topBrush == null) { topBrush = new LinearGradientBrush(); topBrush.StartPoint = new Point(); topBrush.EndPoint = new Point(0.0, 1.0); topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x86, 0xA3, 0xB2), 0.0)); topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x86, 0xA3, 0xB2), 0.1)); topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xAA, 0xCE, 0xE1), 0.9)); topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xAA, 0xCE, 0xE1), 1.0)); topBrush.Freeze(); CacheFreezable(topBrush, (int)AeroFreezables.PressedTop); } dc.DrawRectangle(topBrush, null, new Rect(0.0, 0.0, size.Width, 2.0)); LinearGradientBrush pressedBevel = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.PressedBevel); if (pressedBevel == null) { pressedBevel = new LinearGradientBrush(); pressedBevel.StartPoint = new Point(); pressedBevel.EndPoint = new Point(0.0, 1.0); pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA2, 0xCB, 0xE0), 0.0)); pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA2, 0xCB, 0xE0), 0.4)); pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x72, 0xBC, 0xDF), 0.4)); pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x6E, 0xB8, 0xDC), 1.0)); pressedBevel.Freeze(); CacheFreezable(pressedBevel, (int)AeroFreezables.PressedBevel); } dc.DrawRectangle(pressedBevel, null, new Rect(1.0, 0.0, 1.0, size.Height - 0.95)); dc.DrawRectangle(pressedBevel, null, new Rect(size.Width - 2.0, 0.0, 1.0, size.Height - 0.95)); } if (size.Height >= 2.0) { // Draw the bottom border AeroFreezables bottomType = AeroFreezables.NormalBottom; if (isPressed) { bottomType = AeroFreezables.PressedOrHoveredBottom; } else if (isHovered) { bottomType = AeroFreezables.PressedOrHoveredBottom; } else if (isSorted || isSelected) { bottomType = AeroFreezables.SortedBottom; } SolidColorBrush bottomBrush = (SolidColorBrush)GetCachedFreezable((int)bottomType); if (bottomBrush == null) { switch (bottomType) { case AeroFreezables.NormalBottom: bottomBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xD5, 0xD5, 0xD5)); break; case AeroFreezables.PressedOrHoveredBottom: bottomBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x93, 0xC9, 0xE3)); break; case AeroFreezables.SortedBottom: bottomBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x96, 0xD9, 0xF9)); break; } bottomBrush.Freeze(); CacheFreezable(bottomBrush, (int)bottomType); } dc.DrawRectangle(bottomBrush, null, new Rect(0.0, size.Height - 1.0, size.Width, 1.0)); } if (isSorted && (size.Width > 14.0) && (size.Height > 10.0)) { // Draw the sort arrow TranslateTransform positionTransform = new TranslateTransform((size.Width - 8.0) * 0.5, 1.0); positionTransform.Freeze(); dc.PushTransform(positionTransform); bool ascending = (sortDirection == ListSortDirection.Ascending); PathGeometry arrowGeometry = (PathGeometry)GetCachedFreezable(ascending ? (int)AeroFreezables.ArrowUpGeometry : (int)AeroFreezables.ArrowDownGeometry); if (arrowGeometry == null) { arrowGeometry = new PathGeometry(); PathFigure arrowFigure = new PathFigure(); if (ascending) { arrowFigure.StartPoint = new Point(0.0, 4.0); LineSegment line = new LineSegment(new Point(4.0, 0.0), false); line.Freeze(); arrowFigure.Segments.Add(line); line = new LineSegment(new Point(8.0, 4.0), false); line.Freeze(); arrowFigure.Segments.Add(line); } else { arrowFigure.StartPoint = new Point(0.0, 0.0); LineSegment line = new LineSegment(new Point(8.0, 0.0), false); line.Freeze(); arrowFigure.Segments.Add(line); line = new LineSegment(new Point(4.0, 4.0), false); line.Freeze(); arrowFigure.Segments.Add(line); } arrowFigure.IsClosed = true; arrowFigure.Freeze(); arrowGeometry.Figures.Add(arrowFigure); arrowGeometry.Freeze(); CacheFreezable(arrowGeometry, ascending ? (int)AeroFreezables.ArrowUpGeometry : (int)AeroFreezables.ArrowDownGeometry); } // Draw two arrows, one inset in the other. This is to achieve a double gradient over both the border and the fill. LinearGradientBrush arrowBorder = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.ArrowBorder); if (arrowBorder == null) { arrowBorder = new LinearGradientBrush(); arrowBorder.StartPoint = new Point(); arrowBorder.EndPoint = new Point(1.0, 1.0); arrowBorder.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3C, 0x5E, 0x72), 0.0)); arrowBorder.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3C, 0x5E, 0x72), 0.1)); arrowBorder.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xC3, 0xE4, 0xF5), 1.0)); arrowBorder.Freeze(); CacheFreezable(arrowBorder, (int)AeroFreezables.ArrowBorder); } dc.DrawGeometry(arrowBorder, null, arrowGeometry); LinearGradientBrush arrowFill = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.ArrowFill); if (arrowFill == null) { arrowFill = new LinearGradientBrush(); arrowFill.StartPoint = new Point(); arrowFill.EndPoint = new Point(1.0, 1.0); arrowFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x61, 0x96, 0xB6), 0.0)); arrowFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x61, 0x96, 0xB6), 0.1)); arrowFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xCA, 0xE6, 0xF5), 1.0)); arrowFill.Freeze(); CacheFreezable(arrowFill, (int)AeroFreezables.ArrowFill); } // Inset the fill arrow inside the border arrow ScaleTransform arrowScale = (ScaleTransform)GetCachedFreezable((int)AeroFreezables.ArrowFillScale); if (arrowScale == null) { arrowScale = new ScaleTransform(0.75, 0.75, 3.5, 4.0); arrowScale.Freeze(); CacheFreezable(arrowScale, (int)AeroFreezables.ArrowFillScale); } dc.PushTransform(arrowScale); dc.DrawGeometry(arrowFill, null, arrowGeometry); dc.Pop(); // Scale Transform dc.Pop(); // Position Transform } if (horizontal) { dc.Pop(); // Horizontal Rotate } }
private void RenderTheme(DrawingContext dc) { Size size = RenderSize; bool horizontal = Orientation == Orientation.Horizontal; bool isClickable = IsClickable && IsEnabled; bool isHovered = isClickable && IsHovered; bool isPressed = isClickable && IsPressed; ListSortDirection?sortDirection = SortDirection; bool isSorted = sortDirection != null; bool isSelected = IsSelected; EnsureCache((int)RoyaleFreezables.NumFreezables); if (horizontal) { // When horizontal, rotate the rendering by -90 degrees Matrix m1 = new Matrix(); m1.RotateAt(-90.0, 0.0, 0.0); Matrix m2 = new Matrix(); m2.Translate(0.0, size.Height); MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2); horizontalRotate.Freeze(); dc.PushTransform(horizontalRotate); double temp = size.Width; size.Width = size.Height; size.Height = temp; } // Draw the background RoyaleFreezables backgroundType = isPressed ? RoyaleFreezables.PressedBackground : isHovered ? RoyaleFreezables.HoveredBackground : RoyaleFreezables.NormalBackground; LinearGradientBrush background = (LinearGradientBrush)GetCachedFreezable((int)backgroundType); if (background == null) { background = new LinearGradientBrush(); background.StartPoint = new Point(); background.EndPoint = new Point(0.0, 1.0); if (isPressed) { background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB9, 0xB9, 0xC8), 0.0)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEC, 0xEC, 0xF3), 0.1)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEC, 0xEC, 0xF3), 1.0)); } else if (isHovered || isSelected) { background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFE, 0xFE, 0xFE), 0.0)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFE, 0xFE, 0xFE), 0.85)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xBE, 0xCE), 1.0)); } else { background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF9, 0xFA, 0xFD), 0.0)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF9, 0xFA, 0xFD), 0.85)); background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xBE, 0xCE), 1.0)); } background.Freeze(); CacheFreezable(background, (int)backgroundType); } dc.DrawRectangle(background, null, new Rect(0.0, 0.0, size.Width, size.Height)); if (isHovered && !isPressed && (size.Width >= 6.0) && (size.Height >= 4.0)) { // When hovered, there is a colored tab at the bottom TranslateTransform positionTransform = new TranslateTransform(0.0, size.Height - 3.0); positionTransform.Freeze(); dc.PushTransform(positionTransform); PathGeometry tabGeometry = new PathGeometry(); PathFigure tabFigure = new PathFigure(); tabFigure.StartPoint = new Point(0.5, 0.5); LineSegment line = new LineSegment(new Point(size.Width - 0.5, 0.5), true); line.Freeze(); tabFigure.Segments.Add(line); ArcSegment arc = new ArcSegment(new Point(size.Width - 2.5, 2.5), new Size(2.0, 2.0), 90.0, false, SweepDirection.Clockwise, true); arc.Freeze(); tabFigure.Segments.Add(arc); line = new LineSegment(new Point(2.5, 2.5), true); line.Freeze(); tabFigure.Segments.Add(line); arc = new ArcSegment(new Point(0.5, 0.5), new Size(2.0, 2.0), 90.0, false, SweepDirection.Clockwise, true); arc.Freeze(); tabFigure.Segments.Add(arc); tabFigure.IsClosed = true; tabFigure.Freeze(); tabGeometry.Figures.Add(tabFigure); tabGeometry.Freeze(); Pen tabStroke = (Pen)GetCachedFreezable((int)RoyaleFreezables.TabStroke); if (tabStroke == null) { SolidColorBrush tabStrokeBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xF8, 0xA9, 0x00)); tabStrokeBrush.Freeze(); tabStroke = new Pen(tabStrokeBrush, 1.0); tabStroke.Freeze(); CacheFreezable(tabStroke, (int)RoyaleFreezables.TabStroke); } LinearGradientBrush tabFill = (LinearGradientBrush)GetCachedFreezable((int)RoyaleFreezables.TabFill); if (tabFill == null) { tabFill = new LinearGradientBrush(); tabFill.StartPoint = new Point(); tabFill.EndPoint = new Point(1.0, 0.0); tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFC, 0xE0, 0xA6), 0.0)); tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF6, 0xC4, 0x56), 0.1)); tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF6, 0xC4, 0x56), 0.9)); tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xDF, 0x97, 0x00), 1.0)); tabFill.Freeze(); CacheFreezable(tabFill, (int)RoyaleFreezables.TabFill); } dc.DrawGeometry(tabFill, tabStroke, tabGeometry); dc.Pop(); // Translate Transform } if (isPressed && (size.Width >= 2.0) && (size.Height >= 2.0)) { // When pressed, there is a border on the left and bottom SolidColorBrush border = (SolidColorBrush)GetCachedFreezable((int)RoyaleFreezables.PressedBorder); if (border == null) { border = new SolidColorBrush(Color.FromArgb(0xFF, 0x80, 0x80, 0x99)); border.Freeze(); CacheFreezable(border, (int)RoyaleFreezables.PressedBorder); } dc.DrawRectangle(border, null, new Rect(0.0, 0.0, 1.0, size.Height)); dc.DrawRectangle(border, null, new Rect(0.0, Max0(size.Height - 1.0), size.Width, 1.0)); } if (!isPressed && !isHovered && (size.Width >= 4.0)) { if (SeparatorVisibility == Visibility.Visible) { Brush sideBrush; if (SeparatorBrush != null) { sideBrush = SeparatorBrush; } else { // When not pressed or hovered, draw the resize gripper LinearGradientBrush gripper = (LinearGradientBrush)GetCachedFreezable((int)(horizontal ? RoyaleFreezables.HorizontalGripper : RoyaleFreezables.VerticalGripper)); if (gripper == null) { gripper = new LinearGradientBrush(); gripper.StartPoint = new Point(); gripper.EndPoint = new Point(1.0, 0.0); Color highlight = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF); Color shadow = Color.FromArgb(0xFF, 0xC7, 0xC5, 0xB2); if (horizontal) { gripper.GradientStops.Add(new GradientStop(highlight, 0.0)); gripper.GradientStops.Add(new GradientStop(highlight, 0.25)); gripper.GradientStops.Add(new GradientStop(shadow, 0.75)); gripper.GradientStops.Add(new GradientStop(shadow, 1.0)); } else { gripper.GradientStops.Add(new GradientStop(shadow, 0.0)); gripper.GradientStops.Add(new GradientStop(shadow, 0.25)); gripper.GradientStops.Add(new GradientStop(highlight, 0.75)); gripper.GradientStops.Add(new GradientStop(highlight, 1.0)); } gripper.Freeze(); CacheFreezable(gripper, (int)(horizontal ? RoyaleFreezables.HorizontalGripper : RoyaleFreezables.VerticalGripper)); } sideBrush = gripper; } dc.DrawRectangle(sideBrush, null, new Rect(horizontal ? 0.0 : Max0(size.Width - 2.0), 4.0, 2.0, Max0(size.Height - 8.0))); } } if (isSorted && (size.Width > 14.0) && (size.Height > 10.0)) { // When sorted, draw an arrow on the right TranslateTransform positionTransform = new TranslateTransform(size.Width - 15.0, (size.Height - 5.0) * 0.5); positionTransform.Freeze(); dc.PushTransform(positionTransform); bool ascending = (sortDirection == ListSortDirection.Ascending); PathGeometry arrowGeometry = (PathGeometry)GetCachedFreezable(ascending ? (int)RoyaleFreezables.ArrowUpGeometry : (int)RoyaleFreezables.ArrowDownGeometry); if (arrowGeometry == null) { arrowGeometry = new PathGeometry(); PathFigure arrowFigure = new PathFigure(); if (ascending) { arrowFigure.StartPoint = new Point(0.0, 5.0); LineSegment line = new LineSegment(new Point(5.0, 0.0), false); line.Freeze(); arrowFigure.Segments.Add(line); line = new LineSegment(new Point(10.0, 5.0), false); line.Freeze(); arrowFigure.Segments.Add(line); } else { arrowFigure.StartPoint = new Point(0.0, 0.0); LineSegment line = new LineSegment(new Point(10.0, 0.0), false); line.Freeze(); arrowFigure.Segments.Add(line); line = new LineSegment(new Point(5.0, 5.0), false); line.Freeze(); arrowFigure.Segments.Add(line); } arrowFigure.IsClosed = true; arrowFigure.Freeze(); arrowGeometry.Figures.Add(arrowFigure); arrowGeometry.Freeze(); CacheFreezable(arrowGeometry, ascending ? (int)RoyaleFreezables.ArrowUpGeometry : (int)RoyaleFreezables.ArrowDownGeometry); } SolidColorBrush arrowFill = (SolidColorBrush)GetCachedFreezable((int)RoyaleFreezables.ArrowFill); if (arrowFill == null) { arrowFill = new SolidColorBrush(Color.FromArgb(0xFF, 0xAC, 0xA8, 0x99)); arrowFill.Freeze(); CacheFreezable(arrowFill, (int)RoyaleFreezables.ArrowFill); } dc.DrawGeometry(arrowFill, null, arrowGeometry); dc.Pop(); // Position Transform } if (horizontal) { dc.Pop(); // Horizontal Rotate } }
private void RenderTheme(DrawingContext dc) { Size renderSize = base.RenderSize; bool flag = Orientation == Orientation.Horizontal; bool flag2 = IsClickable && base.IsEnabled; bool flag3 = flag2 && IsHovered; bool flag4 = flag2 && IsPressed; ListSortDirection?sortDirection = SortDirection; bool hasValue = sortDirection.HasValue; bool isSelected = IsSelected; bool flag5 = !flag3 && !flag4 && !hasValue && !isSelected; EnsureCache(19); if (flag) { Matrix trans = default(Matrix); trans.RotateAt(-90.0, 0.0, 0.0); Matrix trans2 = default(Matrix); trans2.Translate(0.0, renderSize.Height); MatrixTransform matrixTransform = new MatrixTransform(trans * trans2); matrixTransform.Freeze(); dc.PushTransform(matrixTransform); double width = renderSize.Width; renderSize.Width = renderSize.Height; renderSize.Height = width; } if (flag5) { LinearGradientBrush linearGradientBrush = (LinearGradientBrush)GetCachedFreezable(0); if (linearGradientBrush == null) { linearGradientBrush = new LinearGradientBrush(); linearGradientBrush.StartPoint = default(Point); linearGradientBrush.EndPoint = new Point(0.0, 1.0); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.0)); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.4)); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 252, 252, 253), 0.4)); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 251, 252, 252), 1.0)); linearGradientBrush.Freeze(); CacheFreezable(linearGradientBrush, 0); } dc.DrawRectangle(linearGradientBrush, null, new Rect(0.0, 0.0, renderSize.Width, renderSize.Height)); } AeroFreezables aeroFreezables = AeroFreezables.NormalBackground; if (flag4) { aeroFreezables = AeroFreezables.PressedBackground; } else if (flag3) { aeroFreezables = AeroFreezables.HoveredBackground; } else if (hasValue | isSelected) { aeroFreezables = AeroFreezables.SortedBackground; } LinearGradientBrush linearGradientBrush2 = (LinearGradientBrush)GetCachedFreezable((int)aeroFreezables); if (linearGradientBrush2 == null) { linearGradientBrush2 = new LinearGradientBrush(); linearGradientBrush2.StartPoint = default(Point); linearGradientBrush2.EndPoint = new Point(0.0, 1.0); switch (aeroFreezables) { case AeroFreezables.NormalBackground: linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.0)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 247, 248, 250), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 241, 242, 244), 1.0)); break; case AeroFreezables.PressedBackground: linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 188, 228, 249), 0.0)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 188, 228, 249), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 141, 214, 247), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 138, 209, 245), 1.0)); break; case AeroFreezables.HoveredBackground: linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 227, 247, byte.MaxValue), 0.0)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 227, 247, byte.MaxValue), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 189, 237, byte.MaxValue), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 183, 231, 251), 1.0)); break; case AeroFreezables.SortedBackground: linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 242, 249, 252), 0.0)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 242, 249, 252), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 225, 241, 249), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 216, 236, 246), 1.0)); break; } linearGradientBrush2.Freeze(); CacheFreezable(linearGradientBrush2, (int)aeroFreezables); } dc.DrawRectangle(linearGradientBrush2, null, new Rect(0.0, 0.0, renderSize.Width, renderSize.Height)); if (renderSize.Width >= 2.0) { AeroFreezables aeroFreezables2 = AeroFreezables.NormalSides; if (flag4) { aeroFreezables2 = AeroFreezables.PressedSides; } else if (flag3) { aeroFreezables2 = AeroFreezables.HoveredSides; } else if (hasValue | isSelected) { aeroFreezables2 = AeroFreezables.SortedSides; } if (SeparatorVisibility == Visibility.Visible) { Brush brush; if (SeparatorBrush != null) { brush = SeparatorBrush; } else { brush = (Brush)GetCachedFreezable((int)aeroFreezables2); if (brush == null) { LinearGradientBrush linearGradientBrush3 = null; if (aeroFreezables2 != AeroFreezables.SortedSides) { linearGradientBrush3 = new LinearGradientBrush(); linearGradientBrush3.StartPoint = default(Point); linearGradientBrush3.EndPoint = new Point(0.0, 1.0); brush = linearGradientBrush3; } switch (aeroFreezables2) { case AeroFreezables.NormalSides: linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 242, 242, 242), 0.0)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 239, 239, 239), 0.4)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 231, 232, 234), 0.4)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 222, 223, 225), 1.0)); break; case AeroFreezables.PressedSides: linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 122, 158, 177), 0.0)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 122, 158, 177), 0.4)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 80, 145, 175), 0.4)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 77, 141, 173), 1.0)); break; case AeroFreezables.HoveredSides: linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 136, 203, 235), 0.0)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 136, 203, 235), 0.4)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 105, 187, 227), 0.4)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 105, 187, 227), 1.0)); break; case AeroFreezables.SortedSides: brush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, 150, 217, 249)); break; } brush.Freeze(); CacheFreezable(brush, (int)aeroFreezables2); } } dc.DrawRectangle(brush, null, new Rect(0.0, 0.0, 1.0, Max0(renderSize.Height - 0.95))); dc.DrawRectangle(brush, null, new Rect(renderSize.Width - 1.0, 0.0, 1.0, Max0(renderSize.Height - 0.95))); } } if (flag4 && renderSize.Width >= 4.0 && renderSize.Height >= 4.0) { LinearGradientBrush linearGradientBrush4 = (LinearGradientBrush)GetCachedFreezable(5); if (linearGradientBrush4 == null) { linearGradientBrush4 = new LinearGradientBrush(); linearGradientBrush4.StartPoint = default(Point); linearGradientBrush4.EndPoint = new Point(0.0, 1.0); linearGradientBrush4.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 134, 163, 178), 0.0)); linearGradientBrush4.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 134, 163, 178), 0.1)); linearGradientBrush4.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 170, 206, 225), 0.9)); linearGradientBrush4.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 170, 206, 225), 1.0)); linearGradientBrush4.Freeze(); CacheFreezable(linearGradientBrush4, 5); } dc.DrawRectangle(linearGradientBrush4, null, new Rect(0.0, 0.0, renderSize.Width, 2.0)); LinearGradientBrush linearGradientBrush5 = (LinearGradientBrush)GetCachedFreezable(10); if (linearGradientBrush5 == null) { linearGradientBrush5 = new LinearGradientBrush(); linearGradientBrush5.StartPoint = default(Point); linearGradientBrush5.EndPoint = new Point(0.0, 1.0); linearGradientBrush5.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 162, 203, 224), 0.0)); linearGradientBrush5.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 162, 203, 224), 0.4)); linearGradientBrush5.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 114, 188, 223), 0.4)); linearGradientBrush5.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 110, 184, 220), 1.0)); linearGradientBrush5.Freeze(); CacheFreezable(linearGradientBrush5, 10); } dc.DrawRectangle(linearGradientBrush5, null, new Rect(1.0, 0.0, 1.0, renderSize.Height - 0.95)); dc.DrawRectangle(linearGradientBrush5, null, new Rect(renderSize.Width - 2.0, 0.0, 1.0, renderSize.Height - 0.95)); } if (renderSize.Height >= 2.0) { AeroFreezables aeroFreezables3 = AeroFreezables.NormalBottom; if (flag4) { aeroFreezables3 = AeroFreezables.PressedOrHoveredBottom; } else if (flag3) { aeroFreezables3 = AeroFreezables.PressedOrHoveredBottom; } else if (hasValue | isSelected) { aeroFreezables3 = AeroFreezables.SortedBottom; } SolidColorBrush solidColorBrush = (SolidColorBrush)GetCachedFreezable((int)aeroFreezables3); if (solidColorBrush == null) { switch (aeroFreezables3) { case AeroFreezables.NormalBottom: solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, 213, 213, 213)); break; case AeroFreezables.PressedOrHoveredBottom: solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, 147, 201, 227)); break; case AeroFreezables.SortedBottom: solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, 150, 217, 249)); break; } solidColorBrush.Freeze(); CacheFreezable(solidColorBrush, (int)aeroFreezables3); } dc.DrawRectangle(solidColorBrush, null, new Rect(0.0, renderSize.Height - 1.0, renderSize.Width, 1.0)); } if (hasValue && renderSize.Width > 14.0 && renderSize.Height > 10.0) { TranslateTransform translateTransform = new TranslateTransform((renderSize.Width - 8.0) * 0.5, 1.0); translateTransform.Freeze(); dc.PushTransform(translateTransform); bool flag6 = sortDirection == ListSortDirection.Ascending; PathGeometry pathGeometry = (PathGeometry)GetCachedFreezable(flag6 ? 17 : 18); if (pathGeometry == null) { pathGeometry = new PathGeometry(); PathFigure pathFigure = new PathFigure(); if (flag6) { pathFigure.StartPoint = new Point(0.0, 4.0); LineSegment lineSegment = new LineSegment(new Point(4.0, 0.0), false); lineSegment.Freeze(); pathFigure.Segments.Add(lineSegment); lineSegment = new LineSegment(new Point(8.0, 4.0), false); lineSegment.Freeze(); pathFigure.Segments.Add(lineSegment); } else { pathFigure.StartPoint = new Point(0.0, 0.0); LineSegment lineSegment2 = new LineSegment(new Point(8.0, 0.0), false); lineSegment2.Freeze(); pathFigure.Segments.Add(lineSegment2); lineSegment2 = new LineSegment(new Point(4.0, 4.0), false); lineSegment2.Freeze(); pathFigure.Segments.Add(lineSegment2); } pathFigure.IsClosed = true; pathFigure.Freeze(); pathGeometry.Figures.Add(pathFigure); pathGeometry.Freeze(); CacheFreezable(pathGeometry, flag6 ? 17 : 18); } LinearGradientBrush linearGradientBrush6 = (LinearGradientBrush)GetCachedFreezable(14); if (linearGradientBrush6 == null) { linearGradientBrush6 = new LinearGradientBrush(); linearGradientBrush6.StartPoint = default(Point); linearGradientBrush6.EndPoint = new Point(1.0, 1.0); linearGradientBrush6.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 60, 94, 114), 0.0)); linearGradientBrush6.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 60, 94, 114), 0.1)); linearGradientBrush6.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 195, 228, 245), 1.0)); linearGradientBrush6.Freeze(); CacheFreezable(linearGradientBrush6, 14); } dc.DrawGeometry(linearGradientBrush6, null, pathGeometry); LinearGradientBrush linearGradientBrush7 = (LinearGradientBrush)GetCachedFreezable(15); if (linearGradientBrush7 == null) { linearGradientBrush7 = new LinearGradientBrush(); linearGradientBrush7.StartPoint = default(Point); linearGradientBrush7.EndPoint = new Point(1.0, 1.0); linearGradientBrush7.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 97, 150, 182), 0.0)); linearGradientBrush7.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 97, 150, 182), 0.1)); linearGradientBrush7.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 202, 230, 245), 1.0)); linearGradientBrush7.Freeze(); CacheFreezable(linearGradientBrush7, 15); } ScaleTransform scaleTransform = (ScaleTransform)GetCachedFreezable(16); if (scaleTransform == null) { scaleTransform = new ScaleTransform(0.75, 0.75, 3.5, 4.0); scaleTransform.Freeze(); CacheFreezable(scaleTransform, 16); } dc.PushTransform(scaleTransform); dc.DrawGeometry(linearGradientBrush7, null, pathGeometry); dc.Pop(); dc.Pop(); } if (flag) { dc.Pop(); } }
public override void Execute() { using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.undoDescription)) { this.ConvertSelectedElementsToPathIfNecessary(); editTransaction.Update(); this.SceneViewModel.DefaultView.UpdateLayout(); SceneElementSelectionSet elementSelectionSet = this.SceneViewModel.ElementSelectionSet; SceneElement primarySelection = elementSelectionSet.PrimarySelection; System.Windows.Media.Geometry renderedGeometryAsWpf = this.SceneView.GetRenderedGeometryAsWpf(primarySelection); if (renderedGeometryAsWpf == null) { return; } this.Initialize(renderedGeometryAsWpf); SceneElementCollection elementCollection = new SceneElementCollection(); foreach (SceneElement shapeElement in elementSelectionSet.Selection) { if (shapeElement != primarySelection) { elementCollection.Add(shapeElement); System.Windows.Media.Geometry secondaryGeometry = this.SceneView.GetRenderedGeometryAsWpf(shapeElement); if (secondaryGeometry == null) { return; } Matrix transformToElement = shapeElement.GetComputedTransformToElement(primarySelection); if (!transformToElement.IsIdentity) { MatrixTransform matrixTransform = new MatrixTransform(transformToElement); matrixTransform.Freeze(); GeometryGroup geometryGroup = new GeometryGroup(); geometryGroup.Children.Add(secondaryGeometry); geometryGroup.Transform = (Transform)matrixTransform; secondaryGeometry = (System.Windows.Media.Geometry)geometryGroup; } this.Combine(secondaryGeometry); } } PathGeometry result = this.GetResult(); BooleanCommand.CleanUpPathGeometry(ref result); PathGeometry pathGeometry = PathConversionHelper.RemoveDegeneratePoints((System.Windows.Media.Geometry)result); elementSelectionSet.Clear(); PathGeometryUtilities.CollapseSingleSegmentsToPolySegments(pathGeometry); PathElement pathElement = (PathElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Path); Dictionary <IPropertyId, SceneNode> properties = (Dictionary <IPropertyId, SceneNode>)null; using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove()) { this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(primarySelection); properties = SceneElementHelper.StoreProperties((SceneNode)primarySelection); ISceneNodeCollection <SceneNode> collectionContainer = primarySelection.GetCollectionContainer(); int index = collectionContainer.IndexOf((SceneNode)primarySelection); collectionContainer[index] = (SceneNode)pathElement; } foreach (SceneElement element in elementCollection) { this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element); element.Remove(); } using (this.SceneViewModel.ForceBaseValue()) { if (properties != null) { SceneElementHelper.ApplyProperties((SceneNode)pathElement, properties); } pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)Stretch.Fill); PathCommandHelper.ReplacePathGeometry(pathElement, pathGeometry, editTransaction); } elementSelectionSet.SetSelection((SceneElement)pathElement); editTransaction.Commit(); } }
private void RenderTheme(DrawingContext dc) { Size renderSize = this.RenderSize; bool flag1 = this.Orientation == Orientation.Horizontal; bool flag2 = this.IsClickable && this.IsEnabled; bool flag3 = flag2 && this.IsHovered; bool flag4 = flag2 && this.IsPressed; ListSortDirection?sortDirection = this.SortDirection; bool hasValue = sortDirection.HasValue; bool isSelected = this.IsSelected; bool flag5 = !flag3 && !flag4 && !hasValue && !isSelected; DataGridHeaderBorder.EnsureCache(19); if (flag1) { Matrix matrix1 = new Matrix(); matrix1.RotateAt(-90.0, 0.0, 0.0); Matrix matrix2 = new Matrix(); matrix2.Translate(0.0, renderSize.Height); MatrixTransform matrixTransform = new MatrixTransform(matrix1 * matrix2); matrixTransform.Freeze(); dc.PushTransform((Transform)matrixTransform); double width = renderSize.Width; renderSize.Width = renderSize.Height; renderSize.Height = width; } if (flag5) { LinearGradientBrush linearGradientBrush = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(0); if (linearGradientBrush == null) { linearGradientBrush = new LinearGradientBrush(); linearGradientBrush.StartPoint = new Point(); linearGradientBrush.EndPoint = new Point(0.0, 1.0); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.0)); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.4)); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)252, (byte)252, (byte)253), 0.4)); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)251, (byte)252, (byte)252), 1.0)); linearGradientBrush.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush, 0); } dc.DrawRectangle((Brush)linearGradientBrush, (Pen)null, new Rect(0.0, 0.0, renderSize.Width, renderSize.Height)); } DataGridHeaderBorder.AeroFreezables aeroFreezables1 = DataGridHeaderBorder.AeroFreezables.NormalBackground; if (flag4) { aeroFreezables1 = DataGridHeaderBorder.AeroFreezables.PressedBackground; } else if (flag3) { aeroFreezables1 = DataGridHeaderBorder.AeroFreezables.HoveredBackground; } else if (hasValue || isSelected) { aeroFreezables1 = DataGridHeaderBorder.AeroFreezables.SortedBackground; } LinearGradientBrush linearGradientBrush1 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable((int)aeroFreezables1); if (linearGradientBrush1 == null) { linearGradientBrush1 = new LinearGradientBrush(); linearGradientBrush1.StartPoint = new Point(); linearGradientBrush1.EndPoint = new Point(0.0, 1.0); switch (aeroFreezables1) { case DataGridHeaderBorder.AeroFreezables.NormalBackground: linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.0)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.4)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)247, (byte)248, (byte)250), 0.4)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)241, (byte)242, (byte)244), 1.0)); break; case DataGridHeaderBorder.AeroFreezables.PressedBackground: linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)188, (byte)228, (byte)249), 0.0)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)188, (byte)228, (byte)249), 0.4)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)141, (byte)214, (byte)247), 0.4)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)138, (byte)209, (byte)245), 1.0)); break; case DataGridHeaderBorder.AeroFreezables.HoveredBackground: linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)227, (byte)247, byte.MaxValue), 0.0)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)227, (byte)247, byte.MaxValue), 0.4)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)189, (byte)237, byte.MaxValue), 0.4)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)183, (byte)231, (byte)251), 1.0)); break; case DataGridHeaderBorder.AeroFreezables.SortedBackground: linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)242, (byte)249, (byte)252), 0.0)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)242, (byte)249, (byte)252), 0.4)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)225, (byte)241, (byte)249), 0.4)); linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)216, (byte)236, (byte)246), 1.0)); break; } linearGradientBrush1.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush1, (int)aeroFreezables1); } dc.DrawRectangle((Brush)linearGradientBrush1, (Pen)null, new Rect(0.0, 0.0, renderSize.Width, renderSize.Height)); if (renderSize.Width >= 2.0) { DataGridHeaderBorder.AeroFreezables aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.NormalSides; if (flag4) { aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.PressedSides; } else if (flag3) { aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.HoveredSides; } else if (hasValue || isSelected) { aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.SortedSides; } if (this.SeparatorVisibility == Visibility.Visible) { Brush brush; if (this.SeparatorBrush != null) { brush = this.SeparatorBrush; } else { brush = (Brush)DataGridHeaderBorder.GetCachedFreezable((int)aeroFreezables2); if (brush == null) { LinearGradientBrush linearGradientBrush2 = (LinearGradientBrush)null; if (aeroFreezables2 != DataGridHeaderBorder.AeroFreezables.SortedSides) { linearGradientBrush2 = new LinearGradientBrush(); linearGradientBrush2.StartPoint = new Point(); linearGradientBrush2.EndPoint = new Point(0.0, 1.0); brush = (Brush)linearGradientBrush2; } switch (aeroFreezables2 - 6) { case DataGridHeaderBorder.AeroFreezables.NormalBevel: linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)242, (byte)242, (byte)242), 0.0)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)239, (byte)239, (byte)239), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)231, (byte)232, (byte)234), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)222, (byte)223, (byte)225), 1.0)); break; case DataGridHeaderBorder.AeroFreezables.NormalBackground: linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)122, (byte)158, (byte)177), 0.0)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)122, (byte)158, (byte)177), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)80, (byte)145, (byte)175), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)77, (byte)141, (byte)173), 1.0)); break; case DataGridHeaderBorder.AeroFreezables.PressedBackground: linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)136, (byte)203, (byte)235), 0.0)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)136, (byte)203, (byte)235), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)105, (byte)187, (byte)227), 0.4)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)105, (byte)187, (byte)227), 1.0)); break; case DataGridHeaderBorder.AeroFreezables.HoveredBackground: brush = (Brush) new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)150, (byte)217, (byte)249)); break; } brush.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)brush, (int)aeroFreezables2); } } dc.DrawRectangle(brush, (Pen)null, new Rect(0.0, 0.0, 1.0, DataGridHeaderBorder.Max0(renderSize.Height - 0.95))); dc.DrawRectangle(brush, (Pen)null, new Rect(renderSize.Width - 1.0, 0.0, 1.0, DataGridHeaderBorder.Max0(renderSize.Height - 0.95))); } } if (flag4 && renderSize.Width >= 4.0 && renderSize.Height >= 4.0) { LinearGradientBrush linearGradientBrush2 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(5); if (linearGradientBrush2 == null) { linearGradientBrush2 = new LinearGradientBrush(); linearGradientBrush2.StartPoint = new Point(); linearGradientBrush2.EndPoint = new Point(0.0, 1.0); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)134, (byte)163, (byte)178), 0.0)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)134, (byte)163, (byte)178), 0.1)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)170, (byte)206, (byte)225), 0.9)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)170, (byte)206, (byte)225), 1.0)); linearGradientBrush2.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush2, 5); } dc.DrawRectangle((Brush)linearGradientBrush2, (Pen)null, new Rect(0.0, 0.0, renderSize.Width, 2.0)); LinearGradientBrush linearGradientBrush3 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(10); if (linearGradientBrush3 == null) { linearGradientBrush3 = new LinearGradientBrush(); linearGradientBrush3.StartPoint = new Point(); linearGradientBrush3.EndPoint = new Point(0.0, 1.0); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)162, (byte)203, (byte)224), 0.0)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)162, (byte)203, (byte)224), 0.4)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)114, (byte)188, (byte)223), 0.4)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)110, (byte)184, (byte)220), 1.0)); linearGradientBrush3.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush3, 10); } dc.DrawRectangle((Brush)linearGradientBrush3, (Pen)null, new Rect(1.0, 0.0, 1.0, renderSize.Height - 0.95)); dc.DrawRectangle((Brush)linearGradientBrush3, (Pen)null, new Rect(renderSize.Width - 2.0, 0.0, 1.0, renderSize.Height - 0.95)); } if (renderSize.Height >= 2.0) { DataGridHeaderBorder.AeroFreezables aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.NormalBottom; if (flag4) { aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.PressedOrHoveredBottom; } else if (flag3) { aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.PressedOrHoveredBottom; } else if (hasValue || isSelected) { aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.SortedBottom; } SolidColorBrush solidColorBrush = (SolidColorBrush)DataGridHeaderBorder.GetCachedFreezable((int)aeroFreezables2); if (solidColorBrush == null) { switch (aeroFreezables2) { case DataGridHeaderBorder.AeroFreezables.NormalBottom: solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)213, (byte)213, (byte)213)); break; case DataGridHeaderBorder.AeroFreezables.PressedOrHoveredBottom: solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)147, (byte)201, (byte)227)); break; case DataGridHeaderBorder.AeroFreezables.SortedBottom: solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)150, (byte)217, (byte)249)); break; } solidColorBrush.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)solidColorBrush, (int)aeroFreezables2); } dc.DrawRectangle((Brush)solidColorBrush, (Pen)null, new Rect(0.0, renderSize.Height - 1.0, renderSize.Width, 1.0)); } if (hasValue && renderSize.Width > 14.0 && renderSize.Height > 10.0) { TranslateTransform translateTransform = new TranslateTransform((renderSize.Width - 8.0) * 0.5, 1.0); translateTransform.Freeze(); dc.PushTransform((Transform)translateTransform); ListSortDirection?nullable = sortDirection; bool flag6 = nullable.GetValueOrDefault() == ListSortDirection.Ascending && nullable.HasValue; PathGeometry pathGeometry = (PathGeometry)DataGridHeaderBorder.GetCachedFreezable(flag6 ? 17 : 18); if (pathGeometry == null) { pathGeometry = new PathGeometry(); PathFigure pathFigure = new PathFigure(); if (flag6) { pathFigure.StartPoint = new Point(0.0, 4.0); LineSegment lineSegment1 = new LineSegment(new Point(4.0, 0.0), false); lineSegment1.Freeze(); pathFigure.Segments.Add((PathSegment)lineSegment1); LineSegment lineSegment2 = new LineSegment(new Point(8.0, 4.0), false); lineSegment2.Freeze(); pathFigure.Segments.Add((PathSegment)lineSegment2); } else { pathFigure.StartPoint = new Point(0.0, 0.0); LineSegment lineSegment1 = new LineSegment(new Point(8.0, 0.0), false); lineSegment1.Freeze(); pathFigure.Segments.Add((PathSegment)lineSegment1); LineSegment lineSegment2 = new LineSegment(new Point(4.0, 4.0), false); lineSegment2.Freeze(); pathFigure.Segments.Add((PathSegment)lineSegment2); } pathFigure.IsClosed = true; pathFigure.Freeze(); pathGeometry.Figures.Add(pathFigure); pathGeometry.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)pathGeometry, flag6 ? 17 : 18); } LinearGradientBrush linearGradientBrush2 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(14); if (linearGradientBrush2 == null) { linearGradientBrush2 = new LinearGradientBrush(); linearGradientBrush2.StartPoint = new Point(); linearGradientBrush2.EndPoint = new Point(1.0, 1.0); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)60, (byte)94, (byte)114), 0.0)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)60, (byte)94, (byte)114), 0.1)); linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)195, (byte)228, (byte)245), 1.0)); linearGradientBrush2.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush2, 14); } dc.DrawGeometry((Brush)linearGradientBrush2, (Pen)null, (Geometry)pathGeometry); LinearGradientBrush linearGradientBrush3 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(15); if (linearGradientBrush3 == null) { linearGradientBrush3 = new LinearGradientBrush(); linearGradientBrush3.StartPoint = new Point(); linearGradientBrush3.EndPoint = new Point(1.0, 1.0); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)97, (byte)150, (byte)182), 0.0)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)97, (byte)150, (byte)182), 0.1)); linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)202, (byte)230, (byte)245), 1.0)); linearGradientBrush3.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush3, 15); } ScaleTransform scaleTransform = (ScaleTransform)DataGridHeaderBorder.GetCachedFreezable(16); if (scaleTransform == null) { scaleTransform = new ScaleTransform(0.75, 0.75, 3.5, 4.0); scaleTransform.Freeze(); DataGridHeaderBorder.CacheFreezable((Freezable)scaleTransform, 16); } dc.PushTransform((Transform)scaleTransform); dc.DrawGeometry((Brush)linearGradientBrush3, (Pen)null, (Geometry)pathGeometry); dc.Pop(); dc.Pop(); } if (!flag1) { return; } dc.Pop(); }