public unsafe void Render(ISurface <ColorAlpha8> dst, PointInt32 renderOffset) { this.cancelToken.ThrowIfCancellationRequested <ICancellationToken>(); int width = dst.Width; int height = dst.Height; RectInt32 bounds = RectInt32.Inflate(new RectInt32(renderOffset, new SizeInt32(width, height)), 1, 1); byte[] buffer = toleranceToMaskValueLookupTable(this.tolerance); this.cancelToken.ThrowIfCancellationRequested <ICancellationToken>(); using (ISurface <ColorAlpha8> surface = UseTileOrToSurfaceWithEdgePadding(this.stencilSource, bounds, ColorAlpha8.Transparent)) { for (int i = 0; i < height; i++) { this.cancelToken.ThrowIfCancellationRequested <ICancellationToken>(); byte *rowPointer = (byte *)dst.GetRowPointer <ColorAlpha8>(i); byte *numPtr2 = (byte *)surface.GetPointPointer <ColorAlpha8>(0, i); byte *numPtr3 = (byte *)surface.GetPointPointer <ColorAlpha8>(0, (i + 1)); byte *numPtr4 = (byte *)surface.GetPointPointer <ColorAlpha8>(0, (i + 2)); for (int j = 0; j < width; j++) { byte num6; byte num7 = numPtr3[1]; if (num7 != 0) { num6 = num7; } else { byte num8 = numPtr2[0]; byte num9 = numPtr2[1]; byte num10 = numPtr2[2]; byte num11 = numPtr3[0]; byte num12 = numPtr3[2]; byte num13 = numPtr4[0]; byte num14 = numPtr4[1]; byte num15 = numPtr4[2]; if ((((num8 == 0xff) || (num9 == 0xff)) || ((num10 == 0xff) || (num11 == 0xff))) || (((num12 == 0xff) || (num13 == 0xff)) || ((num14 == 0xff) || (num15 == 0xff)))) { ColorBgra b = this.colorSource.GetPointSlow(j + renderOffset.X, i + renderOffset.Y); byte distance = FloodFillAlgorithm.GetDistance(this.basis, b); byte mask = buffer[distance]; byte coverage = this.GetCoverageValue(num8, num9, num10, num11, num12, num13, num14, num15); num6 = this.CombineMaskAndCoverageValues(mask, coverage); } else { num6 = 0; } } rowPointer[0] = num6; rowPointer++; numPtr2++; numPtr3++; numPtr4++; } } } }
private void OnSectionsListBoxDrawItem(object sender, DrawItemEventArgs e) { SettingsDialogSection section = this.sectionsListBox.Items[e.Index] as SettingsDialogSection; int x = UIUtil.ScaleWidth(4); using (IDrawingContext context = DrawingContextUtil.FromGraphics(e.Graphics, e.Bounds, false, FactorySource.PerThread)) { HighlightState disabled; context.Clear(new ColorRgba128Float?(this.BackColor)); if (e.State.HasFlag(DrawItemState.Disabled) || e.State.HasFlag(DrawItemState.Grayed)) { disabled = HighlightState.Disabled; } else if (e.State.HasFlag(DrawItemState.Selected)) { disabled = HighlightState.Checked; } else if (e.State.HasFlag(DrawItemState.HotLight) || (e.Index == this.hotTrackIndex)) { disabled = HighlightState.Hover; } else { disabled = HighlightState.Default; } RectInt32 bounds = e.Bounds.ToRectInt32(); bounds.Inflate(-1, -1); this.selectionHighlightRenderer.HighlightState = disabled; this.selectionHighlightRenderer.RenderBackground(context, bounds); SizeInt32 num4 = UIUtil.ScaleSize(section.DeviceIcon.PixelSize); RectInt32 num5 = new RectInt32(x, e.Bounds.Top + ((e.Bounds.Height - num4.Height) / 2), num4.Width, num4.Height); context.DrawBitmap(section.DeviceIcon, new RectDouble?(num5), 1.0, BitmapInterpolationMode.Linear, null); HotkeyRenderMode hotkeyRenderMode = !e.State.HasFlag(DrawItemState.NoAccelerator) ? HotkeyRenderMode.Show : HotkeyRenderMode.Hide; TextLayout resourceSource = UIText.CreateLayout(context, section.DisplayName, e.Font, null, hotkeyRenderMode, 65535.0, 65535.0); ITextLayout cachedOrCreateResource = context.GetCachedOrCreateResource <ITextLayout>(resourceSource); int num6 = num5.Right + x; float num7 = e.Bounds.Top + ((e.Bounds.Height - cachedOrCreateResource.Metrics.Height) / 2f); context.DrawTextLayout((double)num6, (double)num7, resourceSource, this.selectionHighlightRenderer.EmbeddedTextBrush, DrawTextOptions.None); if (!e.State.HasFlag(DrawItemState.NoFocusRect)) { context.DrawFocusRectangle(e.Bounds.ToRectFloat()); } } }
protected override RectInt32 OnGetMaxRenderBounds() => RectInt32.Inflate(this.Points.Bounds().Int32Bound, 1, 1);
private void DrawToDrawingContext(IDrawingContext dc) { RectInt32 rect = base.ClientRectangle.ToRectInt32(); dc.Clear(new ColorRgba128Float?(this.BackColor)); using (dc.UseTranslateTransform(0.5f, 0.5f, MatrixMultiplyOrder.Append)) { using (dc.UseAntialiasMode(AntialiasMode.PerPrimitive)) { RectInt32 num2 = RectInt32.Inflate(rect, -2, -2); int num3 = Math.Min(num2.Width, num2.Height); PointInt32 center = new PointInt32(num2.X + (num3 / 2), num2.Y + (num3 / 2)); double radius = ((double)num3) / 2.0; double scale = ((double)num3) / 3.0; double num7 = ((double)num3) / 2.0; double d = -MathUtil.DegreesToRadians(this.angle); double num9 = Math.Cos(d); double num10 = Math.Sin(d); double rx = (this.rollAmount * Math.Cos(MathUtil.DegreesToRadians(this.rollDirection))) / 90.0; double num12 = (this.rollAmount * Math.Sin(MathUtil.DegreesToRadians(this.rollDirection))) / 90.0; double num13 = rx / (((num12 * num12) < 0.99) ? Math.Sqrt(1.0 - (num12 * num12)) : 1.0); double num14 = num12 / (((rx * rx) < 0.99) ? Math.Sqrt(1.0 - (rx * rx)) : 1.0); double thickness = (this.mouseEntered && !this.onSphere) ? 2.0 : 1.0; if (this.ringOuterEllipseGeometry == null) { this.ringOuterEllipseGeometry = new EllipseGeometry(); } if (this.ringInnerEllipseGeometry == null) { this.ringInnerEllipseGeometry = new EllipseGeometry(); } if (this.ringFillGeometry == null) { this.ringFillGeometry = new CombinedGeometry(GeometryCombineMode.Exclude, this.ringOuterEllipseGeometry, this.ringInnerEllipseGeometry); } this.ringOuterEllipseGeometry.Center = center; this.ringOuterEllipseGeometry.RadiusX = radius - 0.5; this.ringOuterEllipseGeometry.RadiusY = radius - 0.5; this.ringInnerEllipseGeometry.Center = center; this.ringInnerEllipseGeometry.RadiusX = radius; this.ringInnerEllipseGeometry.RadiusY = radius; dc.FillGeometry(this.ringFillGeometry, ringFillBrush, null); if (this.ringOutlinePen == null) { this.ringOutlinePen = new PaintDotNet.UI.Media.Pen(); } this.ringOutlinePen.Brush = ringOutlineBrush; this.ringOutlinePen.Thickness = thickness; dc.DrawCircle(center, radius, this.ringOutlinePen); double num16 = (this.mouseEntered && !this.onSphere) ? ((double)2) : ((double)1); dc.DrawLine(center.X + (scale * num9), center.Y + (scale * num10), center.X + (num7 * num9), center.Y + (num7 * num10), thetaLineBrush, num16); using (dc.UseTranslateTransform((float)center.X, (float)center.Y, MatrixMultiplyOrder.Prepend)) { double num17 = (this.angle * 3.1415926535897931) / 180.0; float num18 = (this.mouseEntered && this.onSphere) ? 1.5f : 1f; int num19 = 0x18; for (int i = 0; i >= (-num19 / 2); i--) { double num22 = (i * 3.1415926535897931) / ((double)num19); double num23 = -num17 - 3.1415926535897931; double xs = Math.Cos(num23) * Math.Cos(num22); double ys = Math.Sin(num23) * Math.Cos(num22); double zs = Math.Sin(num22); double num30 = ((double)(i + (num19 / 2))) / ((double)(num19 / 2)); byte index = Int32Util.ClampToByte((int)(num30 * 255.0)); if (this.latBrushCache[index] == null) { ColorBgra bgra = ColorBgra.Blend(latGradStart, latGradEnd, index); this.latBrushCache[index] = SolidColorBrushCache.Get((ColorRgba128Float)bgra); } SolidColorBrush brush = this.latBrushCache[index]; for (int k = -num19 * 6; k <= (num19 * 6); k++) { num23 = -num17 + ((k * 3.1415926535897931) / ((double)(num19 * 6))); double num33 = Math.Cos(num22); double num34 = Math.Sin(num22); double xe = Math.Cos(num23) * Math.Cos(num22); double ye = Math.Sin(num23) * Math.Cos(num22); double ze = Math.Sin(num22); double num35 = (this.mouseEntered && this.onSphere) ? 1.5 : 1.0; this.Draw3DLine(dc, rx, -num12, scale, xs, ys, zs, xe, ye, ze, brush, num35); xs = xe; ys = ye; zs = ze; } } int num20 = 4; for (int j = -num20; j < num20; j++) { double num37 = -num17 + ((j * 3.1415926535897931) / ((double)num20)); double num38 = -1.5707963267948966; double num39 = Math.Cos(num37) * Math.Cos(num38); double num40 = Math.Sin(num37) * Math.Cos(num38); double num41 = Math.Sin(num38); for (int m = -num20 * 4; m <= 0; m++) { num38 = (m * 3.1415926535897931) / ((double)(num20 * 8)); double num42 = Math.Cos(num37) * Math.Cos(num38); double num43 = Math.Sin(num37) * Math.Cos(num38); double num44 = Math.Sin(num38); double num46 = (this.mouseEntered && this.onSphere) ? 2.0 : 1.0; this.Draw3DLine(dc, rx, -num12, scale, num39, num40, num41, num42, num43, num44, lightBrush, num46); num39 = num42; num40 = num43; num41 = num44; } } } dc.DrawCircle(center, scale, ringInlineBrush, thickness); } } }