public void BeforeRender(RectFloat clipRect) { if ((!this.afterRenderCalled || this.beforeRenderCalled) || this.renderCalled) { throw new PaintDotNet.InternalErrorException(); } this.afterRenderCalled = false; this.beforeRenderCalled = true; base.VerifyAccess(); double scaleRatio = this.canvasView.ScaleRatio; bool flag = scaleRatio == ((int)scaleRatio); int index = (int)DoubleUtil.Clamp(this.ConvertScaleRatioToMipLevel(scaleRatio), 0.0, (double)(this.MipLevelCount - 1)); DocumentCanvasLayerViewMipLayer item = this.mipLayers[index]; if (this.mipLayerZOrder.IndexOf(item) != 0) { this.mipLayerZOrder.Remove(item); this.mipLayerZOrder.Insert(0, item); item.IsVisible = true; item.IsActive = true; this.canvasView.Invalidate(); } this.tileCaches[this.mipLayerZOrder[0].MipLevel].ProcessTileRenderedQueue(); this.mipLayerZOrder[0].BeforeRender(clipRect); for (int i = this.mipLayerZOrder.Count - 1; i >= 1; i--) { this.mipLayerZOrder[i].BeforeRender(clipRect); this.mipLayerZOrder[i].IsActive = false; } }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { PointDouble viewportCanvasOffset = canvasView.ViewportCanvasOffset; Matrix3x2Double num2 = dc.Transform.Inverse * Matrix3x2Double.Translation(-viewportCanvasOffset.X, -viewportCanvasOffset.Y); this.checkerboardTx.Matrix = num2; SizeDouble canvasSize = base.Owner.CanvasSize; RectDouble rect = new RectDouble(PointDouble.Zero, canvasSize); using (dc.UseAntialiasMode(AntialiasMode.Aliased)) { using (CastOrRefHolder <IDrawingContext1> holder = dc.TryCastOrCreateRef <IDrawingContext1>()) { if (holder.HasRef) { using (holder.ObjectRef.UsePrimitiveBlend(PrimitiveBlend.Copy)) { dc.FillRectangle(rect, this.checkerboardBitmapBrush); goto Label_00CC; } } dc.FillRectangle(rect, this.checkerboardBitmapBrush); } } Label_00CC: base.OnRender(dc, clipRect, canvasView); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect) { if (this.wheelBackgroundDeviceBitmap == null) { this.CreateBitmapResources(); } double num = this.wheelCenterOffset + 0.5; double theta = this.hsvColor.Hue * 0.017453292519943295; double radius = Math.Pow(this.hsvColor.Saturation * 0.01, 0.7142857142857143); dc.Clear(new ColorRgba128Float?(this.BackColor)); RectDouble?dstRect = null; dc.DrawBitmap(this.wheelBackgroundDeviceBitmap, dstRect, 1.0, BitmapInterpolationMode.Linear, null); using (dc.UseTranslateTransform((float)num, (float)num, MatrixMultiplyOrder.Prepend)) { if (this.snap || (this.snapOpacity.Value > 0.0)) { this.DrawSnapIndicators(dc, radius); } if (this.lockRadius || (this.lockRadiusOpacity.Value > 0.0)) { this.DrawRadiusGuide(dc, radius); } if (this.lockHue || (this.lockHueOpacity.Value > 0.0)) { this.DrawHueGuide(dc, theta); } this.DrawSelectorNub(dc, theta, radius); } base.OnRender(dc, clipRect); }
private void EndRedraw(RectDouble canvasBounds, RectFloat maskSourceRect, IBitmap <ColorAlpha8> interiorMask, IBitmap <ColorAlpha8>[] dashedOutlineMasks) { base.VerifyAccess(); if (base.IsDisposed) { DisposableUtil.Free <IBitmap <ColorAlpha8> >(ref interiorMask); DisposableUtil.FreeContents <IBitmap <ColorAlpha8> >(dashedOutlineMasks); } else { this.isRedrawing = false; base.CanvasView.Invalidate(this.renderedCanvasBounds); this.ReturnOrFreeDeviceBitmap(ref this.renderedInteriorDeviceBitmap); this.ReturnOrFreeDeviceBitmaps(this.renderedDashedOutlineDeviceBitmaps); this.renderedDashedOutlineDeviceBitmaps = null; DisposableUtil.Free <IBitmap <ColorAlpha8> >(ref this.renderedInteriorMask); this.renderedInteriorMask = interiorMask; DisposableUtil.FreeContents <IBitmap <ColorAlpha8> >(this.renderedDashedOutlineMasks); this.renderedDashedOutlineMasks = dashedOutlineMasks; this.renderedCanvasBounds = canvasBounds; this.renderedMaskSourceRect = maskSourceRect; this.renderedRenderParams = this.redrawRenderParams; this.redrawRenderParams = null; base.CanvasView.Invalidate(this.renderedCanvasBounds); if (this.isRedrawNeeded) { this.isRedrawNeeded = false; this.QueueBeginRedraw(); } } }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { if ((canvasView.ScaleRatio >= 2.0) && GetIsPixelGridEnabled(canvasView)) { SizeDouble canvasSize = base.Owner.CanvasSize; RectDouble b = new RectDouble(PointDouble.Zero, canvasSize); RectInt32 rect = RectDouble.Intersect(clipRect, b).Int32Bound; Matrix3x2Double transform = dc.Transform; double num6 = 1.0 / canvasView.CanvasHairWidth; RectDouble num7 = transform.Transform(rect); double num9 = DoubleUtil.Clamp((canvasView.ScaleRatio - 2.0) / 4.0, 0.0, 1.0) / 2.0; this.stippleBitmapBrush.Opacity = num9; using (dc.UseAntialiasMode(AntialiasMode.Aliased)) { using (dc.UseTransform(Matrix3x2Float.Identity)) { using (dc.UseAxisAlignedClip((RectFloat)num7, AntialiasMode.Aliased)) { for (int i = -(rect.Width & 1); i <= rect.Width; i++) { dc.DrawLine(num7.X + (i * num6), num7.Y, num7.X + (i * num6), num7.Y + num7.Height, this.stippleBitmapBrush, 1.0); } for (int j = -(rect.Height & 1); j <= rect.Height; j++) { dc.DrawLine(num7.X, num7.Y + (j * num6), num7.X + num7.Width, num7.Y + (j * num6), this.stippleBitmapBrush, 1.0); } } } } } base.OnRender(dc, clipRect, canvasView); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect) { dc.Clear(new ColorRgba128Float?(this.BackColor)); using (dc.UseTranslateTransform(0.5f, 0.5f, MatrixMultiplyOrder.Append)) { RectDouble num = RectDouble.Inflate(base.ClientRectangle.ToRectInt32(), -1.0, -1.0); double num3 = Math.Min(num.Width, num.Height) / 2.0; PointDouble center = new PointDouble(num.X + num3, num.Y + num3); double d = MathUtil.DegreesToRadians(this.value); EllipseDouble ellipse = new EllipseDouble(center, num3 - 0.5, num3 - 0.5); double thickness = this.hover ? 2.0 : 1.0; double num8 = this.maxValue - this.minValue; if (num8 >= 360.0) { dc.FillEllipse(ellipse, validAnglesFillBrush); dc.DrawEllipse(ellipse, outlineBrush, thickness); } else { dc.FillEllipse(ellipse, invalidAnglesFillBrush); double width = num3; PointDouble num14 = new PointDouble(center.X + (width * Math.Cos(MathUtil.DegreesToRadians(this.minValue))), center.Y - (width * Math.Sin(MathUtil.DegreesToRadians(this.minValue)))); PointDouble num15 = new PointDouble(center.X + (width * Math.Cos(MathUtil.DegreesToRadians(this.maxValue))), center.Y - (width * Math.Sin(MathUtil.DegreesToRadians(this.maxValue)))); SizeDouble num16 = new SizeDouble(width, width); if (this.validRangeGeometry == null) { this.validRangeGeometry = new PathGeometry(); this.validRangeFigure = new PathFigure(); this.validRangeFigure.IsFilled = true; this.validRangeFigure.IsClosed = true; this.validRangeGeometry.Figures.Add(this.validRangeFigure); this.validRangeLineSegment1 = new LineSegment(); this.validRangeFigure.Segments.Add(this.validRangeLineSegment1); this.validRangeArcSegment = new ArcSegment(); this.validRangeArcSegment.SweepDirection = SweepDirection.Counterclockwise; this.validRangeFigure.Segments.Add(this.validRangeArcSegment); this.validRangeLineSegment2 = new LineSegment(); this.validRangeFigure.Segments.Add(this.validRangeLineSegment2); } this.validRangeFigure.StartPoint = center; this.validRangeLineSegment1.Point = num14; this.validRangeArcSegment.Point = num15; this.validRangeArcSegment.IsLargeArc = num8 >= 180.0; this.validRangeArcSegment.Size = num16; this.validRangeLineSegment2.Point = num15; dc.FillGeometry(this.validRangeGeometry, validAnglesFillBrush, null); dc.DrawEllipse(ellipse, outlineBrush, thickness); dc.DrawLine(center, num14, outlineBrush, 0.5); dc.DrawLine(center, num15, outlineBrush, 0.5); } double num9 = num3 - 2.0; PointDouble num10 = new PointDouble(center.X + (num9 * Math.Cos(d)), center.Y - (num9 * Math.Sin(d))); double radius = 2.5; EllipseDouble num12 = new EllipseDouble(center, radius); dc.FillEllipse(num12, gripFillBrush); dc.DrawLine(center, num10, gripBrush, this.hover ? 2.0 : 1.5); } base.OnRender(dc, clipRect); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect) { if (this.ShouldRender) { this.OnRenderSelection(dc, clipRect); } base.OnRender(dc, clipRect); }
public static void DrawText(RectFloat rect, string text, Vector4?color = null, TextAlignment alignment = TextAlignment.UpperLeft, float fontSize = -1) { if (fontSize == -1) { fontSize = font.size; } DrawString(font, fontSize, rect, text, color, alignment); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { TCanvasLayerView local; if (this.canvasLayerViews.TryGetValue(canvasView, out local)) { local.Render(dc, clipRect); } base.OnRender(dc, clipRect, canvasView); }
protected override void OnBeforeRender(RectFloat clipRect, CanvasView canvasView) { TCanvasLayerView local; if (this.canvasLayerViews.TryGetValue(canvasView, out local)) { local.BeforeRender(clipRect); } base.OnBeforeRender(clipRect, canvasView); }
protected override void OnAfterRender(RectFloat viewportClipRect) { if ((this.Canvas != null) && viewportClipRect.HasPositiveArea) { RectFloat extentRect = (RectFloat)this.canvasView.ConvertViewportToExtent(viewportClipRect); RectFloat clipRect = (RectFloat)this.canvasView.ConvertExtentToCanvas(extentRect); this.canvasView.Canvas.AfterRender(clipRect, this.canvasView); } base.OnAfterRender(viewportClipRect); }
protected override void OnBeforeRender(RectFloat clipRect, CanvasView canvasView) { DocumentCanvasLayerView view; if ((this.document != null) && this.documentCanvasLayerViews.TryGetValue(canvasView, out view)) { view.BeforeRender(clipRect); } base.OnBeforeRender(clipRect, canvasView); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { DocumentCanvasLayerView view; if ((this.document != null) && this.documentCanvasLayerViews.TryGetValue(canvasView, out view)) { view.Render(dc, clipRect); } base.OnRender(dc, clipRect, canvasView); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect) { if (this.clearTopInset.HasValue) { RectFloat num = new RectFloat(0f, 0f, (float)base.Width, (float)this.clearTopInset.Value); using (dc.UseAxisAlignedClip(num, AntialiasMode.Aliased)) { dc.Clear(null); } } base.OnRender(dc, clipRect); }
protected override void OnBeforeRender(RectFloat clipRect, CanvasView canvasView) { if (!LayoutManager.IsUpdatingLayout) { Visual rootVisual = this.compositionTarget.RootVisual; if ((rootVisual != null) && (PresentationSource.FromVisual(rootVisual) != null)) { LayoutManager.UpdateLayout(); } } base.OnBeforeRender(clipRect, canvasView); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { RectDouble cursorBounds = this.CursorBounds; RectDouble cursorOutlineRect = this.GetCursorOutlineRect(canvasView, cursorBounds); double opacity = this.opacityAnimation.Value; dc.FillRectangle(cursorBounds, SolidColorBrushCache.Get((ColorRgba128Float)Colors.Black, opacity)); double canvasHairWidth = canvasView.CanvasHairWidth; double thickness = 1.0 * canvasHairWidth; dc.DrawRectangle(cursorOutlineRect, SolidColorBrushCache.Get((ColorRgba128Float)Colors.White, opacity), thickness); base.OnRender(dc, clipRect, canvasView); }
public void BeforeRender(RectFloat clipRect) { if ((!this.afterRenderCalled || this.beforeRenderCalled) || this.renderCalled) { throw new PaintDotNet.InternalErrorException(); } this.afterRenderCalled = false; this.beforeRenderCalled = true; bool flag = this.canvasView.RenderTarget.IsSupported(RenderTargetType.Software, null, null, null); if (flag || this.IsActive) { this.renderStopwatch.Restart(); RectInt32 num2 = RectInt32.Intersect(clipRect.Int32Bound, this.owner.Document.Bounds()); bool flag2 = false; if (num2.HasPositiveArea) { PointInt32 num7; PointInt32[] array = this.nonCurrentTileOffsets.ToArrayEx <PointInt32>(); this.nonCurrentTileOffsets.Clear(); PointInt32 sourcePt = PointDouble.Round(this.owner.Owner.MouseLocation, MidpointRounding.AwayFromZero); PointInt32 comparand = this.tileMathHelper.ConvertSourcePointToTileOffset(sourcePt); CompareTileOffsetsByDistance comparer = new CompareTileOffsetsByDistance(comparand); ListUtil.Sort <PointInt32, ArrayStruct <PointInt32>, CompareTileOffsetsByDistance>(array.AsStruct <PointInt32>(), comparer); DequeSet <PointInt32> set = new DequeSet <PointInt32>(array); int count = set.Count; while (set.TryDequeue(out num7)) { if (!this.isDeviceBitmapCurrent[num7.Y][num7.X]) { if (flag2) { this.nonCurrentTileOffsets.TryEnqueue(num7); } else { if (!this.TryUpdateDeviceBitmap(num7)) { this.nonCurrentTileOffsets.TryEnqueue(num7); flag2 = true; } if ((!flag2 && !flag) && (this.renderStopwatch.ElapsedMilliseconds > 0x7fffffffffffffffL)) { flag2 = true; } } } } } } }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { Matrix3x2Float transform = dc.Transform; SizeDouble canvasSize = canvasView.CanvasSize; RectFloat rect = new RectFloat(0f, 0f, (float)canvasSize.Width, (float)canvasSize.Height); RectFloat num4 = transform.Transform(rect); int recommendedExtent = this.dropShadowRenderer.GetRecommendedExtent(num4.Int32Bound.Size); using (dc.UseTransform(Matrix3x2Float.Identity)) { this.dropShadowRenderer.RenderOutside(dc, new ColorRgba128Float(0f, 0f, 0f, 0.5f), num4, recommendedExtent); } base.OnRender(dc, clipRect, canvasView); }
protected override void OnRender(IDrawingContext dc, RectFloat viewportClipRect) { if ((this.Canvas != null) && viewportClipRect.HasPositiveArea) { RectFloat extentRect = (RectFloat)this.canvasView.ConvertViewportToExtent(viewportClipRect); RectFloat clipRect = (RectFloat)this.canvasView.ConvertExtentToCanvas(extentRect); using (dc.UseSaveDrawingState()) { this.canvasView.Canvas.Render(dc, clipRect, this.canvasView); } } base.OnRender(dc, viewportClipRect); this.renderCount++; }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { SizeDouble canvasSize = canvasView.CanvasSize; RectDouble num2 = RectDouble.FromEdges(-131072.0, 0.0, 0.0, canvasSize.Height); RectDouble num3 = RectDouble.FromEdges(-131072.0, -131072.0, 131072.0, 0.0); RectDouble num4 = RectDouble.FromEdges(canvasSize.Width, 0.0, 131072.0, canvasSize.Height); RectDouble num5 = RectDouble.FromEdges(-131072.0, canvasSize.Height, 131072.0, 131072.0); ColorRgba128Float num6 = (ThemeConfig.EffectiveTheme == PdnTheme.Aero) ? AeroColors.CanvasBackFillColor : ClassicColors.CanvasBackFillColor; dc.Clear((RectFloat)num2, AntialiasMode.Aliased, new ColorRgba128Float?(num6)); dc.Clear((RectFloat)num3, AntialiasMode.Aliased, new ColorRgba128Float?(num6)); dc.Clear((RectFloat)num4, AntialiasMode.Aliased, new ColorRgba128Float?(num6)); dc.Clear((RectFloat)num5, AntialiasMode.Aliased, new ColorRgba128Float?(num6)); base.OnRender(dc, clipRect, canvasView); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect) { if (!this.tickLabelFontLazy.IsValueCreated) { if (!this.isPrefetchingTickLabelFont) { this.isPrefetchingTickLabelFont = true; this.tickLabelFontLazy.Prefetch <SizedFontProperties>(< obj > => PdnSynchronizationContext.Instance.Post(delegate(object <state>) { try { base.Invalidate(true); } catch (Exception) { } }));
public void Render(IDrawingContext dc, RectFloat clipRect) { if ((!this.beforeRenderCalled || this.renderCalled) || this.afterRenderCalled) { throw new PaintDotNet.InternalErrorException(); } this.renderCalled = true; using (dc.UseAntialiasMode(AntialiasMode.Aliased)) { double scaleRatio = this.canvasView.ScaleRatio; double d = this.ConvertScaleRatioToMipLevel(scaleRatio); int num3 = (int)Math.Floor(d); bool flag = Math.Abs((double)(d - Math.Round(d, MidpointRounding.AwayFromZero))) < 0.01; bool isHighQualityScalingEnabled = DocumentCanvasLayer.GetIsHighQualityScalingEnabled(this.canvasView); for (int i = this.mipLayerZOrder.Count - 1; i >= 0; i--) { DocumentCanvasLayerViewMipLayer layer = this.mipLayerZOrder[i]; if (layer.MipLevel == 0) { if (flag) { layer.Render(dc, clipRect, 1f, BitmapInterpolationMode.NearestNeighbor); } else if (scaleRatio < 1.0) { layer.Render(dc, clipRect, 1f, isHighQualityScalingEnabled ? BitmapInterpolationMode.Linear : BitmapInterpolationMode.NearestNeighbor); } else { layer.Render(dc, clipRect, 1f, BitmapInterpolationMode.NearestNeighbor); if ((scaleRatio < 2.0) & isHighQualityScalingEnabled) { double num5 = d - num3; double num6 = 1.0 - (((1.0 - num5) * (1.0 - num5)) * (1.0 - num5)); double num7 = DoubleUtil.Clamp(num6, 0.0, 1.0); layer.Render(dc, clipRect, (float)num7, BitmapInterpolationMode.Linear); } } } else { layer.Render(dc, clipRect, 1f, isHighQualityScalingEnabled ? BitmapInterpolationMode.Linear : BitmapInterpolationMode.NearestNeighbor); } } } }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { if ((this.brushSize > 0.0) && (this.brushAlpha > 0)) { double opacity = ((double)this.brushAlpha) / 255.0; Brush brush = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.White, opacity); Brush brush2 = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.Black, opacity); double canvasHairWidth = canvasView.CanvasHairWidth; RectDouble brushRect = this.BrushRect; brushRect.Inflate((double)(-canvasHairWidth * 2.0), (double)(-canvasHairWidth * 2.0)); if (brushRect.HasPositiveArea) { this.ellipseGeometryInner.RadiusX = this.brushSize - (canvasHairWidth * 2.0); this.ellipseGeometryInner.RadiusY = this.brushSize - (canvasHairWidth * 2.0); this.ellipseGeometryMiddle.RadiusX = this.brushSize - canvasHairWidth; this.ellipseGeometryMiddle.RadiusY = this.brushSize - canvasHairWidth; this.ellipseGeometryOuter.RadiusX = this.brushSize; this.ellipseGeometryOuter.RadiusY = this.brushSize; using (dc.UseTranslateTransform(-((VectorFloat)this.brushLocation), MatrixMultiplyOrder.Prepend)) { using (CastOrRefHolder <IDrawingContext2> holder = dc.TryCastOrCreateRef <IDrawingContext2>()) { if (holder.HasRef) { this.ellipseRealizationInner = this.ellipseRealizationInner ?? new StrokedGeometryRealization(this.ellipseGeometryInner); this.ellipseRealizationMiddle = this.ellipseRealizationMiddle ?? new StrokedGeometryRealization(this.ellipseGeometryMiddle); this.ellipseRealizationOuter = this.ellipseRealizationOuter ?? new StrokedGeometryRealization(this.ellipseGeometryOuter); this.ellipseRealizationInner.Thickness = canvasHairWidth; this.ellipseRealizationMiddle.Thickness = canvasHairWidth; this.ellipseRealizationOuter.Thickness = canvasHairWidth; holder.ObjectRef.DrawGeometryRealization(this.ellipseRealizationInner, brush); holder.ObjectRef.DrawGeometryRealization(this.ellipseRealizationMiddle, brush2); holder.ObjectRef.DrawGeometryRealization(this.ellipseRealizationOuter, brush); } else { dc.DrawGeometry(this.ellipseGeometryInner, brush, canvasHairWidth); dc.DrawGeometry(this.ellipseGeometryMiddle, brush2, canvasHairWidth); dc.DrawGeometry(this.ellipseGeometryOuter, brush, canvasHairWidth); } } } } } base.OnRender(dc, clipRect, canvasView); }
public void Render(IDrawingContext dc, RectFloat clipRect, float opacity, BitmapInterpolationMode interpolationMode) { if (!this.beforeRenderCalled || this.afterRenderCalled) { throw new PaintDotNet.InternalErrorException(); } this.renderCalled = true; if (this.isRendering) { throw new InvalidOperationException("Render() is not reentrant"); } RectInt32 sourceRect = RectInt32.Intersect(clipRect.Int32Bound, this.owner.Document.Bounds()); if (sourceRect.HasPositiveArea) { this.isRendering = true; try { bool flag = dc.IsSupported(RenderTargetType.Software, null, null, null); foreach (PointInt32 num3 in this.tileMathHelper.EnumerateTileOffsets(sourceRect)) { if (flag) { IBitmap <ColorPbgra32> bitmap2 = this.tileBuffers[num3.Y][num3.X]; if ((bitmap2 != null) && bitmap2.IsDisposed) { continue; } } IDeviceBitmap bitmap = this.deviceBitmaps[num3.Y][num3.X]; if (bitmap != null) { RectInt32 tileSourceRect = this.tileMathHelper.GetTileSourceRect(num3.X, num3.Y); RectFloat?srcRect = null; dc.DrawBitmap(bitmap, new RectFloat?(tileSourceRect), opacity, interpolationMode, srcRect); } } } finally { this.isRendering = false; } } }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect) { using (dc.UseAntialiasMode(AntialiasMode.Aliased)) { SizeInt32 num; Size clientSize = base.ClientSize; if ((clientSize.Width < 2) || (clientSize.Height < 2)) { num = new SizeInt32(3, 3); } else { num = new SizeInt32(clientSize.Width, clientSize.Height); } dc.Clear(new ColorRgba128Float?((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Window)); int num2 = (int)(this.tolerance * 100f); string text = string.Format(percentageFormat, num2); if (this.textLayout == null) { this.textLayout = UIText.CreateLayout(dc, text, this.Font, null, HotkeyRenderMode.Ignore, 65535.0, 65535.0); this.textLayout.ParagraphAlignment = ParagraphAlignment.Center; this.textLayout.FontSize *= 0.9; } else { this.textLayout.Text = text; } this.textLayout.MaxWidth = num.Width - 6; this.textLayout.MaxHeight = num.Height - 6; PointDouble origin = new PointDouble(3.0, 3.0); dc.DrawTextLayout(origin, this.textLayout, SolidColorBrushCache.Get(base.Enabled ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.WindowText) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.GrayText)), DrawTextOptions.None); RectDouble rect = new RectDouble(0.0, 0.0, (double)num.Width, (double)num.Height); RectDouble num5 = RectDouble.Inflate(rect, -0.5, -0.5); dc.DrawRectangle(num5, SolidColorBrushCache.Get(base.Enabled ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.ControlDark) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.ControlDark)), 1.0); RectDouble num6 = new RectDouble(1.0, 1.0, (num.Width - 2.0) * this.tolerance, (double)(num.Height - 2)); PaintDotNet.UI.Media.Brush brush = SolidColorBrushCache.Get(base.Enabled ? (this.hovering ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.HotTrack) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Highlight)) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Control)); dc.FillRectangle(num6, brush); using (dc.UseAxisAlignedClip((RectFloat)num6, AntialiasMode.PerPrimitive)) { dc.DrawTextLayout(origin, this.textLayout, SolidColorBrushCache.Get(base.Enabled ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.HighlightText) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.GrayText)), DrawTextOptions.None); } } base.OnRender(dc, clipRect); }
public void AfterRender(RectFloat clipRect) { if ((!this.beforeRenderCalled || !this.renderCalled) || this.afterRenderCalled) { throw new PaintDotNet.InternalErrorException(); } this.afterRenderCalled = true; this.beforeRenderCalled = false; this.renderCalled = false; for (int i = this.mipLayerZOrder.Count - 1; i >= 0; i--) { this.mipLayerZOrder[i].AfterRender(clipRect); } if ((this.mipLayerZOrder.Count > 1) && this.mipLayerZOrder[0].IsRegionCurrent(this.canvasView.GetVisibleCanvasBounds().Int32Bound)) { for (int k = this.mipLayerZOrder.Count - 1; k >= 1; k--) { this.mipLayerZOrder[k].IsVisible = false; this.mipLayerZOrder.RemoveAt(k); } } bool flag = true; for (int j = 0; j < this.mipLayers.Length; j++) { if (this.mipLayers[j].IsActive) { if (!flag) { this.mipLayers[j].TileCache.Priority = WorkItemQueuePriority.High; return; } this.mipLayers[j].TileCache.Priority = WorkItemQueuePriority.AboveNormal; flag = false; } else { this.mipLayers[j].TileCache.Priority = WorkItemQueuePriority.Normal; } } }
protected override void OnBeforeRender(RectFloat clipRect) { if (this.ShouldRender) { IRenderTarget renderTarget = base.CanvasView.RenderTarget; if (renderTarget != null) { try { IDeviceBitmap bitmap; IDeviceBitmap bitmap2; IDeviceBitmap bitmap3; this.GetInitializedRenderBitmaps(renderTarget, out bitmap, out bitmap2, out bitmap3); } catch (RecreateTargetException) { } } } base.OnBeforeRender(clipRect); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { if ((this.brushSize > 0.0) && (this.brushAlpha > 0)) { double opacity = ((double)this.brushAlpha) / 255.0; Brush brush = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.White, opacity); Brush brush2 = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.Black, opacity); double canvasHairWidth = canvasView.CanvasHairWidth; RectDouble brushRect = this.BrushRect; brushRect.Inflate(-canvasHairWidth, -canvasHairWidth); if (brushRect.HasPositiveArea) { RectFloat num4 = (RectFloat)brushRect; using (dc.UseAntialiasMode(AntialiasMode.Aliased)) { dc.DrawRectangle(brushRect, brush2, canvasHairWidth * 3.0); dc.DrawRectangle(brushRect, brush, canvasHairWidth); } } } base.OnRender(dc, clipRect, canvasView); }
public void AfterRender(RectFloat clipRect) { if ((!this.beforeRenderCalled || !this.renderCalled) || this.afterRenderCalled) { throw new PaintDotNet.InternalErrorException(); } this.afterRenderCalled = true; this.beforeRenderCalled = false; this.renderCalled = false; if (this.nonCurrentTileOffsets.Any()) { RectInt32 canvasRect = ((IEnumerable <RectInt32>)(from to in this.nonCurrentTileOffsets select this.tileMathHelper.GetTileSourceRect(to))).Bounds(); if (canvasRect.HasPositiveArea) { this.canvasView.Invalidate(canvasRect); } } if (this.popTileCacheActiveAfterRender) { this.popTileCacheActiveAfterRender = false; this.PopTileCacheActive(); } }
public static bool Button(RectFloat rect, string text = null, bool active = true, Vector4?color = null) { bool hover = rect.Contains(InputEngine.MousePosition, true); bool anyPress = InputEngine.GetMouseButton(0); var style = skin.buttonStyle; var tex = active ? hover ? anyPress ? style.texActive : style.texHover : style.texNormal : style.texInactive; Draw(rect, tex, color, style); if (!string.IsNullOrEmpty(text)) { var textRect = new RectFloat( rect.x + style.border.left, rect.y + style.border.top, rect.width - style.border.left - style.border.right, rect.height - style.border.top - style.border.bottom ); DrawString(font, style.fontSize, textRect, text, alignment: style.textAlignment); } return(active && hover && InputEngine.GetMouseButtonUp(0) && rect.Contains(InputEngine.MousePosition, true)); }