Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions ST.Library.UI/NodeEditor/FrmNodePreviewPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using SkiaSharp;

namespace ST.Library.UI.NodeEditor
{
Expand All @@ -28,6 +27,8 @@ internal class FrmNodePreviewPanel : Form
private STNodeEditor m_editor;
private STNodePropertyGrid m_property;

private Pen m_pen = new Pen(Color.Black);
private SolidBrush m_brush = new SolidBrush(Color.Black);
private static FrmNodePreviewPanel m_last_frm;

[DllImport("user32.dll")]
Expand Down Expand Up @@ -90,7 +91,11 @@ protected override void OnLoad(EventArgs e) {
m_rect_panel.Y = this.Top;
m_region = new Region(new Rectangle(Point.Empty, this.Size));
m_region.Exclude(m_rect_exclude);
FrmNodePreviewPanel.SetWindowRgn(this.Handle, IntPtr.Zero, false);
using (Graphics g = this.CreateGraphics()) {
IntPtr h = m_region.GetHrgn(g);
FrmNodePreviewPanel.SetWindowRgn(this.Handle, h, false);
m_region.ReleaseHrgn(h);
}

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

protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
Graphics g = e.Graphics;
m_pen.Color = this.AutoBorderColor ? m_node.TitleColor : this.BorderColor;
m_brush.Color = m_pen.Color;
g.DrawRectangle(m_pen, 0, 0, this.Width - 1, this.Height - 1);
g.FillRectangle(m_brush, m_rect_exclude.X - 1, m_rect_exclude.Y - 1, m_rect_exclude.Width + 2, m_rect_exclude.Height + 2);

Rectangle rect = this.RectangleToClient(m_rect_handle);
rect.Y = (m_nHandleSize - 14) / 2;
rect.X += rect.Y + 1;
rect.Width = rect.Height = 14;
m_pen.Width = 2;
g.DrawLine(m_pen, rect.X + 4, rect.Y + 3, rect.X + 10, rect.Y + 3);
g.DrawLine(m_pen, rect.X + 4, rect.Y + 6, rect.X + 10, rect.Y + 6);
g.DrawLine(m_pen, rect.X + 4, rect.Y + 11, rect.X + 10, rect.Y + 11);
g.DrawLine(m_pen, rect.X + 7, rect.Y + 7, rect.X + 7, rect.Y + 10);
m_pen.Width = 1;
g.DrawRectangle(m_pen, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
}
}
}
35 changes: 34 additions & 1 deletion ST.Library.UI/NodeEditor/FrmSTNodePropertyInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
using System.Windows.Forms;
using System.Drawing;
using ST.Library.UI.NodeEditor;
using SkiaSharp;

namespace ST.Library.UI
{
internal class FrmSTNodePropertyInput : Form
{
private STNodePropertyDescriptor m_descriptor;
private Rectangle m_rect;
private Pen m_pen;
private SolidBrush m_brush;
private TextBox m_tbx;

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

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

protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
Graphics g = e.Graphics;
m_brush.Color = m_tbx.BackColor;
g.FillRectangle(m_brush, 1, 1, this.Width - 2 - m_rect.Height, this.Height - 2);
m_brush.Color = m_descriptor.Control.ForeColor;
//Enter
g.FillPolygon(m_brush, new Point[]{
new Point(this.Width - 21, this.Height - 2),
new Point(this.Width - 14, this.Height - 2),
new Point(this.Width - 14, this.Height - 8)
});
g.DrawLine(m_pen, this.Width - 14, this.Height - 3, this.Width - 4, this.Height - 3);
g.DrawLine(m_pen, this.Width - 4, this.Height - 3, this.Width - 4, 14);
g.DrawLine(m_pen, this.Width - 8, 13, this.Width - 4, 13);
//----
g.DrawLine(m_pen, this.Width - 19, 11, this.Width - 4, 11);
//E
g.DrawLine(m_pen, this.Width - 19, 3, this.Width - 16, 3);
g.DrawLine(m_pen, this.Width - 19, 6, this.Width - 16, 6);
g.DrawLine(m_pen, this.Width - 19, 9, this.Width - 16, 9);
g.DrawLine(m_pen, this.Width - 19, 3, this.Width - 19, 9);
//S
g.DrawLine(m_pen, this.Width - 13, 3, this.Width - 10, 3);
g.DrawLine(m_pen, this.Width - 13, 6, this.Width - 10, 6);
g.DrawLine(m_pen, this.Width - 13, 9, this.Width - 10, 9);
g.DrawLine(m_pen, this.Width - 13, 3, this.Width - 13, 6);
g.DrawLine(m_pen, this.Width - 10, 6, this.Width - 10, 9);
//C
g.DrawLine(m_pen, this.Width - 7, 3, this.Width - 4, 3);
g.DrawLine(m_pen, this.Width - 7, 9, this.Width - 4, 9);
g.DrawLine(m_pen, this.Width - 7, 3, this.Width - 7, 9);
}

void tbx_KeyDown(object sender, KeyEventArgs e) {
Expand Down
32 changes: 31 additions & 1 deletion ST.Library.UI/NodeEditor/FrmSTNodePropertySelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

using System.Windows.Forms;
using System.Drawing;
using SkiaSharp;

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

private static Type m_t_bool = typeof(bool);
private Pen m_pen;
private SolidBrush m_brush;
private StringFormat m_sf;
private Color m_clr_item_1 = Color.FromArgb(10, 0, 0, 0);// Color.FromArgb(255, 40, 40, 40);
private Color m_clr_item_2 = Color.FromArgb(10, 255, 255, 255);// Color.FromArgb(255, 50, 50, 50);
private object m_item_hover;
Expand All @@ -31,6 +33,11 @@ public FrmSTNodePropertySelect(STNodePropertyDescriptor descriptor) {
this.ShowInTaskbar = false;
this.BackColor = descriptor.Control.BackColor;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
m_pen = new Pen(descriptor.Control.AutoColor ? descriptor.Node.TitleColor : descriptor.Control.ItemSelectedColor, 1);
m_brush = new SolidBrush(this.BackColor);
m_sf = new StringFormat();
m_sf.LineAlignment = StringAlignment.Center;
m_sf.FormatFlags = StringFormatFlags.NoWrap;
}

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

protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
Graphics g = e.Graphics;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
Rectangle rect_back = new Rectangle(0, 0, this.Width, m_nItemHeight);
Rectangle rect_font = new Rectangle(10, 0, this.Width - 13, m_nItemHeight);
int nIndex = 0;
string strVal = m_descriptor.GetStringFromValue();
foreach (var v in m_lst_item) {
m_brush.Color = nIndex++ % 2 == 0 ? m_clr_item_1 : m_clr_item_2;
g.FillRectangle(m_brush, rect_back);
if (v == m_item_hover) {
m_brush.Color = m_descriptor.Control.ItemHoverColor;
g.FillRectangle(m_brush, rect_back);
}
if (v.ToString() == strVal) {
m_brush.Color = m_descriptor.Control.ItemSelectedColor;
g.FillRectangle(m_brush, 4, rect_back.Top + 10, 5, 5);
}
m_brush.Color = m_descriptor.Control.ForeColor;
g.DrawString(v.ToString(), m_descriptor.Control.Font, m_brush, rect_font, m_sf);
rect_back.Y += m_nItemHeight;
rect_font.Y += m_nItemHeight;
}
g.DrawRectangle(m_pen, 0, 0, this.Width - 1, this.Height - 1);
}

protected override void OnMouseMove(MouseEventArgs e) {
Expand Down
Loading