protected override void OnRender(IDrawingContext dc, RectFloat clipRect) { if (this.historyStack != null) { dc.Clear(new ColorRgba128Float?(this.BackColor)); using (dc.UseTranslateTransform(0f, (float)-this.scrollOffset, MatrixMultiplyOrder.Prepend)) { int num7; int num8; int num11; int num12; RectDouble? nullable; TextLayoutAlgorithm?nullable2; int num = UIUtil.ScaleWidth(1); int num2 = (this.itemHeight - this.imageHeight) / 2; int num3 = UIUtil.ScaleWidth(2); RectInt32 a = this.ClientRectangleToViewRectangle(base.ClientRectangle.ToRectInt32()); RectInt32 undoViewRectangle = this.UndoViewRectangle; dc.FillRectangle(undoViewRectangle, PaintDotNet.UI.Media.SystemBrushes.Window); RectInt32 num6 = RectInt32.Intersect(a, undoViewRectangle); if ((num6.Width > 0) && (num6.Height > 0)) { ItemType type; this.ViewPointToStackIndex(num6.Location, out type, out num7); this.ViewPointToStackIndex(new PointInt32(num6.Left, num6.Bottom - 1), out type, out num8); } else { num7 = 0; num8 = -1; } for (int i = num7; i <= num8; i++) { DeviceBitmap deviceBitmap; int imageHeight; HighlightState hover; ImageResource image = this.historyStack.UndoStack[i].Image; if (image != null) { deviceBitmap = ImageResourceUtil.GetDeviceBitmap(image); } else { deviceBitmap = null; } if (deviceBitmap != null) { imageHeight = (deviceBitmap.PixelSize.Width * this.imageHeight) / deviceBitmap.PixelSize.Height; } else { imageHeight = this.imageHeight; } if (i == (this.historyStack.UndoStack.Count - 1)) { hover = HighlightState.Checked; } else if (i == this.undoItemHighlight) { hover = HighlightState.Hover; } else { hover = HighlightState.Default; } RectInt32 bounds = new RectInt32(0, i * this.itemHeight, this.ViewWidth, this.itemHeight); this.selectionHighlightRenderer.HighlightState = hover; this.selectionHighlightRenderer.RenderBackground(dc, bounds); PaintDotNet.UI.Media.Brush embeddedTextBrush = this.selectionHighlightRenderer.EmbeddedTextBrush; if (deviceBitmap != null) { nullable = null; dc.DrawBitmap(deviceBitmap, new RectDouble?(new RectInt32(bounds.X + num, bounds.Y + num2, imageHeight, this.imageHeight)), 1.0, BitmapInterpolationMode.Linear, nullable); } int x = (num + num3) + imageHeight; RectInt32 num17 = new RectInt32(x, bounds.Y, this.ViewWidth - x, this.itemHeight); nullable2 = null; TextLayout textLayout = UIText.CreateLayout(dc, this.historyStack.UndoStack[i].Name, this.Font, nullable2, HotkeyRenderMode.Hide, (double)num17.Width, (double)num17.Height); textLayout.WordWrapping = WordWrapping.Wrap; textLayout.ParagraphAlignment = ParagraphAlignment.Center; UIText.AdjustFontSizeToFitLayoutSize(dc, textLayout, (double)num17.Width, (double)num17.Height, 0.6); dc.DrawTextLayout(num17.Location, textLayout, embeddedTextBrush, DrawTextOptions.None); } RectInt32 redoViewRectangle = this.RedoViewRectangle; dc.FillRectangle(redoViewRectangle, slateGrayBrush); RectInt32 num10 = RectInt32.Intersect(a, redoViewRectangle); if ((num10.Width > 0) && (num10.Height > 0)) { ItemType type2; this.ViewPointToStackIndex(num10.Location, out type2, out num11); this.ViewPointToStackIndex(new PointInt32(num10.Left, num10.Bottom - 1), out type2, out num12); } else { num11 = 0; num12 = -1; } for (int j = num11; j <= num12; j++) { DeviceBitmap bitmap2; int num20; PaintDotNet.UI.Media.Brush inactiveCaptionText; ImageResource imageResource = this.historyStack.RedoStack[j].Image; if (imageResource != null) { bitmap2 = ImageResourceUtil.GetDeviceBitmap(imageResource); } else { bitmap2 = null; } if (bitmap2 != null) { num20 = (bitmap2.PixelSize.Width * this.imageHeight) / bitmap2.PixelSize.Height; } else { num20 = this.imageHeight; } RectInt32 num21 = new RectInt32(0, redoViewRectangle.Top + (j * this.itemHeight), this.ViewWidth, this.itemHeight); if (j == this.redoItemHighlight) { this.selectionHighlightRenderer.HighlightState = HighlightState.Hover; this.selectionHighlightRenderer.RenderBackground(dc, num21); inactiveCaptionText = this.selectionHighlightRenderer.EmbeddedTextBrush; } else { inactiveCaptionText = PaintDotNet.UI.Media.SystemBrushes.InactiveCaptionText; } if (bitmap2 != null) { nullable = null; dc.DrawBitmap(bitmap2, new RectDouble?(new RectInt32(num21.X + num, num21.Y + num2, num20, this.imageHeight)), 1.0, BitmapInterpolationMode.Linear, nullable); } int num22 = (num + num3) + num20; RectInt32 num23 = new RectInt32(num22, num21.Y, this.ViewWidth - num22, this.itemHeight); nullable2 = null; TextLayout layout2 = UIText.CreateLayout(dc, this.historyStack.RedoStack[j].Name, this.Font, nullable2, HotkeyRenderMode.Hide, (double)num23.Width, (double)num23.Height); layout2.WordWrapping = WordWrapping.NoWrap; layout2.ParagraphAlignment = ParagraphAlignment.Center; layout2.FontStyle = PaintDotNet.DirectWrite.FontStyle.Italic; UIText.AdjustFontSizeToFitLayoutSize(dc, layout2, (double)num23.Width, (double)num23.Height, 0.6); dc.DrawTextLayout(num23.Location, layout2, inactiveCaptionText, DrawTextOptions.None); } } } base.OnRender(dc, clipRect); }
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); } } }