Skip to content

Commit fb5a284

Browse files
committed
Fix SkiaDrawingHelper after RenderToGraphics removal
1 parent a296731 commit fb5a284

37 files changed

+835
-1131
lines changed

ST.Library.UI/NodeEditor/FrmNodePreviewPanel.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Text;
88
using System.Windows.Forms;
99
using System.Runtime.InteropServices;
10+
using SkiaSharp;
1011

1112
namespace ST.Library.UI.NodeEditor
1213
{
@@ -27,8 +28,6 @@ internal class FrmNodePreviewPanel : Form
2728
private STNodeEditor m_editor;
2829
private STNodePropertyGrid m_property;
2930

30-
private Pen m_pen = new Pen(Color.Black);
31-
private SolidBrush m_brush = new SolidBrush(Color.Black);
3231
private static FrmNodePreviewPanel m_last_frm;
3332

3433
[DllImport("user32.dll")]
@@ -91,11 +90,7 @@ protected override void OnLoad(EventArgs e) {
9190
m_rect_panel.Y = this.Top;
9291
m_region = new Region(new Rectangle(Point.Empty, this.Size));
9392
m_region.Exclude(m_rect_exclude);
94-
using (Graphics g = this.CreateGraphics()) {
95-
IntPtr h = m_region.GetHrgn(g);
96-
FrmNodePreviewPanel.SetWindowRgn(this.Handle, h, false);
97-
m_region.ReleaseHrgn(h);
98-
}
93+
FrmNodePreviewPanel.SetWindowRgn(this.Handle, IntPtr.Zero, false);
9994

10095
this.MouseLeave += Event_MouseLeave;
10196
m_editor.MouseLeave += Event_MouseLeave;
@@ -122,23 +117,6 @@ void Event_MouseLeave(object sender, EventArgs e) {
122117

123118
protected override void OnPaint(PaintEventArgs e) {
124119
base.OnPaint(e);
125-
Graphics g = e.Graphics;
126-
m_pen.Color = this.AutoBorderColor ? m_node.TitleColor : this.BorderColor;
127-
m_brush.Color = m_pen.Color;
128-
g.DrawRectangle(m_pen, 0, 0, this.Width - 1, this.Height - 1);
129-
g.FillRectangle(m_brush, m_rect_exclude.X - 1, m_rect_exclude.Y - 1, m_rect_exclude.Width + 2, m_rect_exclude.Height + 2);
130-
131-
Rectangle rect = this.RectangleToClient(m_rect_handle);
132-
rect.Y = (m_nHandleSize - 14) / 2;
133-
rect.X += rect.Y + 1;
134-
rect.Width = rect.Height = 14;
135-
m_pen.Width = 2;
136-
g.DrawLine(m_pen, rect.X + 4, rect.Y + 3, rect.X + 10, rect.Y + 3);
137-
g.DrawLine(m_pen, rect.X + 4, rect.Y + 6, rect.X + 10, rect.Y + 6);
138-
g.DrawLine(m_pen, rect.X + 4, rect.Y + 11, rect.X + 10, rect.Y + 11);
139-
g.DrawLine(m_pen, rect.X + 7, rect.Y + 7, rect.X + 7, rect.Y + 10);
140-
m_pen.Width = 1;
141-
g.DrawRectangle(m_pen, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
142120
}
143121
}
144122
}

ST.Library.UI/NodeEditor/FrmSTNodePropertyInput.cs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
using System.Windows.Forms;
77
using System.Drawing;
88
using ST.Library.UI.NodeEditor;
9+
using SkiaSharp;
910

1011
namespace ST.Library.UI
1112
{
1213
internal class FrmSTNodePropertyInput : Form
1314
{
1415
private STNodePropertyDescriptor m_descriptor;
1516
private Rectangle m_rect;
16-
private Pen m_pen;
17-
private SolidBrush m_brush;
1817
private TextBox m_tbx;
1918

2019
public FrmSTNodePropertyInput(STNodePropertyDescriptor descriptor) {
@@ -29,8 +28,6 @@ public FrmSTNodePropertyInput(STNodePropertyDescriptor descriptor) {
2928
this.ShowInTaskbar = false;
3029
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
3130
this.BackColor = descriptor.Control.AutoColor ? descriptor.Node.TitleColor : descriptor.Control.ItemSelectedColor;
32-
m_pen = new Pen(descriptor.Control.ForeColor, 1);
33-
m_brush = new SolidBrush(this.BackColor);
3431
}
3532

3633
protected override void OnLoad(EventArgs e) {
@@ -57,36 +54,6 @@ protected override void OnLoad(EventArgs e) {
5754

5855
protected override void OnPaint(PaintEventArgs e) {
5956
base.OnPaint(e);
60-
Graphics g = e.Graphics;
61-
m_brush.Color = m_tbx.BackColor;
62-
g.FillRectangle(m_brush, 1, 1, this.Width - 2 - m_rect.Height, this.Height - 2);
63-
m_brush.Color = m_descriptor.Control.ForeColor;
64-
//Enter
65-
g.FillPolygon(m_brush, new Point[]{
66-
new Point(this.Width - 21, this.Height - 2),
67-
new Point(this.Width - 14, this.Height - 2),
68-
new Point(this.Width - 14, this.Height - 8)
69-
});
70-
g.DrawLine(m_pen, this.Width - 14, this.Height - 3, this.Width - 4, this.Height - 3);
71-
g.DrawLine(m_pen, this.Width - 4, this.Height - 3, this.Width - 4, 14);
72-
g.DrawLine(m_pen, this.Width - 8, 13, this.Width - 4, 13);
73-
//----
74-
g.DrawLine(m_pen, this.Width - 19, 11, this.Width - 4, 11);
75-
//E
76-
g.DrawLine(m_pen, this.Width - 19, 3, this.Width - 16, 3);
77-
g.DrawLine(m_pen, this.Width - 19, 6, this.Width - 16, 6);
78-
g.DrawLine(m_pen, this.Width - 19, 9, this.Width - 16, 9);
79-
g.DrawLine(m_pen, this.Width - 19, 3, this.Width - 19, 9);
80-
//S
81-
g.DrawLine(m_pen, this.Width - 13, 3, this.Width - 10, 3);
82-
g.DrawLine(m_pen, this.Width - 13, 6, this.Width - 10, 6);
83-
g.DrawLine(m_pen, this.Width - 13, 9, this.Width - 10, 9);
84-
g.DrawLine(m_pen, this.Width - 13, 3, this.Width - 13, 6);
85-
g.DrawLine(m_pen, this.Width - 10, 6, this.Width - 10, 9);
86-
//C
87-
g.DrawLine(m_pen, this.Width - 7, 3, this.Width - 4, 3);
88-
g.DrawLine(m_pen, this.Width - 7, 9, this.Width - 4, 9);
89-
g.DrawLine(m_pen, this.Width - 7, 3, this.Width - 7, 9);
9057
}
9158

9259
void tbx_KeyDown(object sender, KeyEventArgs e) {

ST.Library.UI/NodeEditor/FrmSTNodePropertySelect.cs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.Windows.Forms;
77
using System.Drawing;
8+
using SkiaSharp;
89

910
namespace ST.Library.UI.NodeEditor
1011
{
@@ -14,9 +15,6 @@ internal class FrmSTNodePropertySelect : Form
1415
private int m_nItemHeight = 25;
1516

1617
private static Type m_t_bool = typeof(bool);
17-
private Pen m_pen;
18-
private SolidBrush m_brush;
19-
private StringFormat m_sf;
2018
private Color m_clr_item_1 = Color.FromArgb(10, 0, 0, 0);// Color.FromArgb(255, 40, 40, 40);
2119
private Color m_clr_item_2 = Color.FromArgb(10, 255, 255, 255);// Color.FromArgb(255, 50, 50, 50);
2220
private object m_item_hover;
@@ -33,11 +31,6 @@ public FrmSTNodePropertySelect(STNodePropertyDescriptor descriptor) {
3331
this.ShowInTaskbar = false;
3432
this.BackColor = descriptor.Control.BackColor;
3533
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
36-
m_pen = new Pen(descriptor.Control.AutoColor ? descriptor.Node.TitleColor : descriptor.Control.ItemSelectedColor, 1);
37-
m_brush = new SolidBrush(this.BackColor);
38-
m_sf = new StringFormat();
39-
m_sf.LineAlignment = StringAlignment.Center;
40-
m_sf.FormatFlags = StringFormatFlags.NoWrap;
4134
}
4235

4336
private List<object> m_lst_item = new List<object>();
@@ -65,29 +58,6 @@ protected override void OnLoad(EventArgs e) {
6558

6659
protected override void OnPaint(PaintEventArgs e) {
6760
base.OnPaint(e);
68-
Graphics g = e.Graphics;
69-
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
70-
Rectangle rect_back = new Rectangle(0, 0, this.Width, m_nItemHeight);
71-
Rectangle rect_font = new Rectangle(10, 0, this.Width - 13, m_nItemHeight);
72-
int nIndex = 0;
73-
string strVal = m_descriptor.GetStringFromValue();
74-
foreach (var v in m_lst_item) {
75-
m_brush.Color = nIndex++ % 2 == 0 ? m_clr_item_1 : m_clr_item_2;
76-
g.FillRectangle(m_brush, rect_back);
77-
if (v == m_item_hover) {
78-
m_brush.Color = m_descriptor.Control.ItemHoverColor;
79-
g.FillRectangle(m_brush, rect_back);
80-
}
81-
if (v.ToString() == strVal) {
82-
m_brush.Color = m_descriptor.Control.ItemSelectedColor;
83-
g.FillRectangle(m_brush, 4, rect_back.Top + 10, 5, 5);
84-
}
85-
m_brush.Color = m_descriptor.Control.ForeColor;
86-
g.DrawString(v.ToString(), m_descriptor.Control.Font, m_brush, rect_font, m_sf);
87-
rect_back.Y += m_nItemHeight;
88-
rect_font.Y += m_nItemHeight;
89-
}
90-
g.DrawRectangle(m_pen, 0, 0, this.Width - 1, this.Height - 1);
9161
}
9262

9363
protected override void OnMouseMove(MouseEventArgs e) {

0 commit comments

Comments
 (0)