private void CreateBitmapResources() { DisposableUtil.Free <ISurface <ColorBgra> >(ref this.wheelBackgroundSurface); this.wheelBackgroundSurface = new Surface(base.ClientRectangle.Size.ToSizeInt32()); this.DrawWheelSurface(this.wheelBackgroundSurface); if (!base.Enabled) { DisabledRendering.ConvertToDisabled(this.wheelBackgroundSurface); } this.wheelBackgroundBitmap = this.wheelBackgroundSurface.CreateAliasedImagingBitmap(PixelFormats.Bgra32); this.wheelBackgroundDeviceBitmap = new DeviceBitmap(this.wheelBackgroundBitmap); }
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) { Graphics graphics = e.Graphics; Rectangle arrowRectangle = e.ArrowRectangle; Color color = e.Item.Enabled ? e.ArrowColor : DisabledRendering.GetDisabledColor(e.ArrowColor); using (System.Drawing.Brush brush = new SolidBrush(color)) { Point point = new Point(arrowRectangle.Left + (arrowRectangle.Width / 2), arrowRectangle.Top + (arrowRectangle.Height / 2)); switch (e.Direction) { case ArrowDirection.Right: this.onRenderArrowPoints3[0] = new Point(-2, -4); this.onRenderArrowPoints3[1] = new Point(-2, 4); this.onRenderArrowPoints3[2] = new Point(2, 0); break; case ArrowDirection.Left: this.onRenderArrowPoints3[0] = new Point(2, -4); this.onRenderArrowPoints3[1] = new Point(2, 4); this.onRenderArrowPoints3[2] = new Point(-2, 0); break; case ArrowDirection.Up: this.onRenderArrowPoints3[0] = new Point(-3, 2); this.onRenderArrowPoints3[1] = new Point(3, 2); this.onRenderArrowPoints3[2] = new Point(0, -2); break; default: this.onRenderArrowPoints3[0] = new Point(-3, -1); this.onRenderArrowPoints3[1] = new Point(3, -1); this.onRenderArrowPoints3[2] = new Point(0, 2); break; } for (int i = 0; i < this.onRenderArrowPoints3.Length; i++) { this.onRenderArrowPoints3[i] = new Point(point.X + UIUtil.ScaleWidth(this.onRenderArrowPoints3[i].X), point.Y + UIUtil.ScaleHeight(this.onRenderArrowPoints3[i].Y)); } graphics.FillPolygon(brush, this.onRenderArrowPoints3); } }
private void DrawGradient(Graphics g) { Rectangle rectangle; double num; g.PixelOffsetMode = PixelOffsetMode.Half; System.Windows.Forms.Orientation orientation = this.orientation; if (orientation != System.Windows.Forms.Orientation.Horizontal) { if (orientation != System.Windows.Forms.Orientation.Vertical) { throw ExceptionUtil.InvalidEnumArgumentException <System.Windows.Forms.Orientation>(this.orientation, "this.Orientation"); } } else { num = 180.0; goto Label_0040; } num = 90.0; Label_0040: rectangle = base.ClientRectangle; orientation = this.orientation; if (orientation != System.Windows.Forms.Orientation.Horizontal) { if (orientation != System.Windows.Forms.Orientation.Vertical) { throw ExceptionUtil.InvalidEnumArgumentException <System.Windows.Forms.Orientation>(this.orientation, "this.Orientation"); } } else { rectangle.Inflate(-3, -4); goto Label_0082; } rectangle.Inflate(-4, -3); Label_0082: if (((this.customGradient != null) && (rectangle.Width > 1)) && (rectangle.Height > 1)) { Surface surface = new Surface(rectangle.Size.ToSizeInt32()); using (RenderArgs args = new RenderArgs(surface)) { ColorRectangle.Draw(args.Graphics, args.Bounds, Color.Transparent, true, false); if (this.Orientation == System.Windows.Forms.Orientation.Horizontal) { for (int j = 0; j < surface.Width; j++) { double num16; double num17; double num18; double d = ((double)(j * (this.customGradient.Length - 1))) / ((double)(surface.Width - 1)); int index = (int)Math.Floor(d); double num5 = 1.0 - (d - index); int num6 = (int)Math.Min((double)(this.customGradient.Length - 1), Math.Ceiling(d)); Color c = this.customGradient[index]; Color disabledColor = this.customGradient[num6]; if (!base.Enabled) { c = DisabledRendering.GetDisabledColor(c); disabledColor = DisabledRendering.GetDisabledColor(disabledColor); } double num7 = ((double)c.A) / 255.0; double num8 = ((double)c.R) / 255.0; double num9 = ((double)c.G) / 255.0; double num10 = ((double)c.B) / 255.0; double num11 = ((double)disabledColor.A) / 255.0; double num12 = ((double)disabledColor.R) / 255.0; double num13 = ((double)disabledColor.G) / 255.0; double num14 = ((double)disabledColor.B) / 255.0; double num15 = (num5 * num7) + ((1.0 - num5) * num11); if (num15 == 0.0) { num16 = 0.0; num17 = 0.0; num18 = 0.0; } else { num16 = (((num5 * num7) * num8) + (((1.0 - num5) * num11) * num12)) / num15; num17 = (((num5 * num7) * num9) + (((1.0 - num5) * num11) * num13)) / num15; num18 = (((num5 * num7) * num10) + (((1.0 - num5) * num11) * num14)) / num15; } int num19 = ((int)Math.Round((double)(num15 * 255.0), MidpointRounding.AwayFromZero)).Clamp(0, 0xff); int num20 = ((int)Math.Round((double)(num16 * 255.0), MidpointRounding.AwayFromZero)).Clamp(0, 0xff); int num21 = ((int)Math.Round((double)(num17 * 255.0), MidpointRounding.AwayFromZero)).Clamp(0, 0xff); int num22 = ((int)Math.Round((double)(num18 * 255.0), MidpointRounding.AwayFromZero)).Clamp(0, 0xff); for (int k = 0; k < surface.Height; k++) { ColorBgra bgra = surface[j, k]; int num24 = ((num20 * num19) + (bgra.R * (0xff - num19))) / 0xff; int num25 = ((num21 * num19) + (bgra.G * (0xff - num19))) / 0xff; int num26 = ((num22 * num19) + (bgra.B * (0xff - num19))) / 0xff; surface[j, k] = ColorBgra.FromBgra((byte)num26, (byte)num25, (byte)num24, 0xff); } } g.DrawImage(args.Bitmap, rectangle, args.Bounds, GraphicsUnit.Pixel); } else if (this.Orientation != System.Windows.Forms.Orientation.Vertical) { throw ExceptionUtil.InvalidEnumArgumentException <System.Windows.Forms.Orientation>(this.orientation, "this.Orientation"); } } surface.Dispose(); } else { Color color3 = base.Enabled ? this.maxColor : DisabledRendering.GetDisabledColor(this.maxColor); Color color4 = base.Enabled ? this.minColor : DisabledRendering.GetDisabledColor(this.minColor); using (LinearGradientBrush brush = new LinearGradientBrush(base.ClientRectangle, color3, color4, (float)num, false)) { g.FillRectangle(brush, rectangle); } } using (PdnRegion region = new PdnRegion()) { region.MakeInfinite(); region.Exclude(rectangle); using (SolidBrush brush2 = new SolidBrush(this.BackColor)) { g.FillRegion(brush2, region.GetRegionReadOnly()); } } for (int i = 0; i < this.vals.Length; i++) { Brush blue; Pen pen; Point point; Point point2; Point point3; Point point4; Point point5; Point point6; int x = this.ValueToPosition(this.vals[i]); if (i == this.highlight) { blue = Brushes.Blue; pen = (Pen)Pens.White.Clone(); } else { blue = base.Enabled ? Brushes.Black : Brushes.Gray; pen = (Pen)Pens.Gray.Clone(); } g.SmoothingMode = SmoothingMode.AntiAlias; orientation = this.orientation; if (orientation != System.Windows.Forms.Orientation.Horizontal) { if (orientation != System.Windows.Forms.Orientation.Vertical) { throw ExceptionUtil.InvalidEnumArgumentException <System.Windows.Forms.Orientation>(this.orientation, "this.Orientation"); } } else { point = new Point(x - 3, 0); point2 = new Point(x, 6); point3 = new Point(x + 3, 0); point4 = new Point(point.X, (base.Height - 1) - point.Y); point5 = new Point(point2.X, (base.Height - 1) - point2.Y); point6 = new Point(point3.X, (base.Height - 1) - point3.Y); goto Label_0678; } point = new Point(0, x - 3); point2 = new Point(6, x); point3 = new Point(0, x + 3); point4 = new Point((base.Width - 1) - point.X, point.Y); point5 = new Point((base.Width - 1) - point2.X, point2.Y); point6 = new Point((base.Width - 1) - point3.X, point3.Y); Label_0678: if (this.drawNearNub) { Point[] points = new Point[] { point, point2, point3, point }; g.FillPolygon(blue, points); } if (this.drawFarNub) { Point[] pointArray2 = new Point[] { point4, point5, point6, point4 }; g.FillPolygon(blue, pointArray2); } if (pen != null) { if (this.drawNearNub) { Point[] pointArray3 = new Point[] { point, point2, point3, point }; g.DrawPolygon(pen, pointArray3); } if (this.drawFarNub) { Point[] pointArray4 = new Point[] { point4, point5, point6, point4 }; g.DrawPolygon(pen, pointArray4); } pen.Dispose(); } } }
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) { if (!string.IsNullOrWhiteSpace(e.Text)) { int num; Rectangle textRectangle = e.TextRectangle; Rectangle rect = textRectangle; if ((e.TextFormat & (TextFormatFlags.Right | TextFormatFlags.HorizontalCenter)) == TextFormatFlags.Default) { num = 10; } else { num = 0; } rect.Width += num; using (IDrawingContext context = DrawingContextUtil.FromGraphics(e.Graphics, rect, false, FactorySource.PerThread)) { HotkeyRenderMode ignore; Color c = (ThemeConfig.EffectiveTheme == PdnTheme.Aero) ? this.AeroColorTheme.MenuTextColor : e.Item.ForeColor; Color color2 = e.Item.Enabled ? c : DisabledRendering.GetDisabledColor(c); this.textBrush.Color = color2; if ((e.TextFormat & TextFormatFlags.NoPrefix) == TextFormatFlags.NoPrefix) { ignore = HotkeyRenderMode.Ignore; } else if ((e.TextFormat & TextFormatFlags.HidePrefix) == TextFormatFlags.HidePrefix) { ignore = HotkeyRenderMode.Hide; } else { ignore = HotkeyRenderMode.Show; } TextLayout textLayout = UIText.CreateLayout(context, e.Text, e.TextFont, null, ignore, (double)textRectangle.Width, (double)textRectangle.Height); if ((e.TextFormat & TextFormatFlags.Right) == TextFormatFlags.Right) { textLayout.TextAlignment = PaintDotNet.DirectWrite.TextAlignment.Trailing; } else if ((e.TextFormat & TextFormatFlags.HorizontalCenter) == TextFormatFlags.HorizontalCenter) { textLayout.TextAlignment = PaintDotNet.DirectWrite.TextAlignment.Center; } if ((e.TextFormat & TextFormatFlags.Bottom) == TextFormatFlags.Bottom) { textLayout.ParagraphAlignment = ParagraphAlignment.Far; } else if ((e.TextFormat & TextFormatFlags.VerticalCenter) == TextFormatFlags.VerticalCenter) { textLayout.ParagraphAlignment = ParagraphAlignment.Center; } textLayout.WordWrapping = WordWrapping.NoWrap; UIText.AdjustFontSizeToFitLayoutSize(context, textLayout, (double)textRectangle.Width, 65535.0, 0.6); if (e.Item is PdnToolStripStatusLabel) { textLayout.TrimmingGranularity = TrimmingGranularity.Character; textLayout.TrimmingStyle = TextTrimmingStyle.Ellipsis; } context.DrawTextLayout((double)rect.X, (double)rect.Y, textLayout, this.textBrush, DrawTextOptions.None); } } }