public ResetButtonDrawing() { this.buttonBackgroundDrawing.ClassName = VisualStyleElement.Button.PushButton.Normal.ClassName; this.buttonBackgroundDrawing.Part = VisualStyleElement.Button.PushButton.Normal.Part; this.buttonBackgroundDrawing.SetBinding <PdnPushButtonState, int>(VisualStyleRendererDrawing.StateProperty, this, new PaintDotNet.ObjectModel.PropertyPath(ButtonStateProperty.Name, Array.Empty <object>()), BindingMode.OneWay, ppbs => (int)ppbs); this.buttonBackgroundDrawing2 = new ControlPaintButtonDrawing(); this.buttonBackgroundDrawing2.SetBinding <PdnPushButtonState, System.Windows.Forms.ButtonState>(ControlPaintButtonDrawing.StateProperty, this, new PaintDotNet.ObjectModel.PropertyPath(ButtonStateProperty.Name, Array.Empty <object>()), BindingMode.OneWay, new Func <PdnPushButtonState, System.Windows.Forms.ButtonState>(ResetButtonDrawing.ConvertPdnPushButtonStateToButtonState)); this.buttonBackgroundDrawing.FallbackDrawing = this.buttonBackgroundDrawing2; this.resetIconDrawing = new DeviceBitmapDrawing(ImageResourceUtil.GetDeviceBitmap(PdnResources.GetImageResource("Icons.ResetIcon.png"))); this.resetIconDrawingContainer = new DrawingGroup(); Transform[] items = new Transform[] { new ScaleTransform(16.0 / this.resetIconDrawing.Bounds.Width, 16.0 / this.resetIconDrawing.Bounds.Height), new TranslateTransform(2.0, 2.0) }; this.resetIconDrawingContainer.Transform = new TransformGroup(ArrayUtil.Infer <Transform>(items)); this.resetIconDrawingContainer.Children.Add(this.resetIconDrawing); this.buttonBackgroundDrawing.Size = new SizeInt32(((int)Math.Round(this.resetIconDrawingContainer.Bounds.Width, MidpointRounding.AwayFromZero)) + 4, ((int)Math.Round(this.resetIconDrawingContainer.Bounds.Height, MidpointRounding.AwayFromZero)) + 4); base.DrawingGroup.Children.Add(this.buttonBackgroundDrawing); base.DrawingGroup.Children.Add(this.resetIconDrawingContainer); }
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); }