Add selection outlines for vertex color selector
This commit is contained in:
parent
bffa623e01
commit
7751ebed52
@ -87,8 +87,8 @@ namespace Toolbox.Library.Forms
|
|||||||
this.BackgroundImage = Properties.Resources.CheckerBackground;
|
this.BackgroundImage = Properties.Resources.CheckerBackground;
|
||||||
this.BackColor = Color.Transparent;
|
this.BackColor = Color.Transparent;
|
||||||
this.MouseClick += OnMouseClick;
|
this.MouseClick += OnMouseClick;
|
||||||
this.MouseUp += OnMouseUp;
|
this.MouseMove += OnMouseMove;
|
||||||
this.MouseHover += new EventHandler(OnMouseHover);
|
this.MouseLeave += OnMouseLeave;
|
||||||
this.SetStyle(
|
this.SetStyle(
|
||||||
ControlStyles.AllPaintingInWmPaint |
|
ControlStyles.AllPaintingInWmPaint |
|
||||||
ControlStyles.UserPaint |
|
ControlStyles.UserPaint |
|
||||||
@ -105,30 +105,32 @@ namespace Toolbox.Library.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnMouseHover(object sender, EventArgs e)
|
private void OnMouseMove(object sender, MouseEventArgs e) {
|
||||||
{
|
if (dialogActive) return;
|
||||||
isHovered = true;
|
|
||||||
mouseLoc = Control.MousePosition;
|
mouseLoc = e.Location;
|
||||||
this.Invalidate();
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMouseLeave(object sender, EventArgs e) {
|
||||||
|
if (dialogActive) return;
|
||||||
|
|
||||||
|
mouseLoc = Point.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMouseUp(object sender, MouseEventArgs e) {
|
private void OnMouseUp(object sender, MouseEventArgs e) {
|
||||||
leftClicked = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isHovered;
|
|
||||||
private bool dialogActive;
|
private bool dialogActive;
|
||||||
private STColorDialog colorDlg;
|
private STColorDialog colorDlg;
|
||||||
private Point mouseLoc;
|
private Point mouseLoc = Point.Empty;
|
||||||
private bool leftClicked = false;
|
|
||||||
private void OnMouseClick(object sender, MouseEventArgs e)
|
private void OnMouseClick(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (TopLeftHit == null) return;
|
if (TopLeftHit == null) return;
|
||||||
|
|
||||||
if (e.Button == MouseButtons.Left)
|
if (e.Button == MouseButtons.Left)
|
||||||
{
|
{
|
||||||
leftClicked = true;
|
|
||||||
mouseLoc = e.Location;
|
mouseLoc = e.Location;
|
||||||
this.Invalidate();
|
this.Invalidate();
|
||||||
|
|
||||||
@ -161,6 +163,8 @@ namespace Toolbox.Library.Forms
|
|||||||
colorDlg.Show();
|
colorDlg.Show();
|
||||||
colorDlg.FormClosed += delegate
|
colorDlg.FormClosed += delegate
|
||||||
{
|
{
|
||||||
|
mouseLoc = Point.Empty;
|
||||||
|
this.Invalidate();
|
||||||
dialogActive = false;
|
dialogActive = false;
|
||||||
};
|
};
|
||||||
colorDlg.ColorChanged += delegate
|
colorDlg.ColorChanged += delegate
|
||||||
@ -177,8 +181,6 @@ namespace Toolbox.Library.Forms
|
|||||||
ColorChanged();
|
ColorChanged();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
leftClicked = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Invalidate();
|
this.Invalidate();
|
||||||
@ -205,6 +207,8 @@ namespace Toolbox.Library.Forms
|
|||||||
colorDlg = new STColorDialog(color);
|
colorDlg = new STColorDialog(color);
|
||||||
colorDlg.FormClosed += delegate
|
colorDlg.FormClosed += delegate
|
||||||
{
|
{
|
||||||
|
mouseLoc = Point.Empty;
|
||||||
|
this.Invalidate();
|
||||||
dialogActive = false;
|
dialogActive = false;
|
||||||
};
|
};
|
||||||
colorDlg.Show();
|
colorDlg.Show();
|
||||||
@ -245,6 +249,8 @@ namespace Toolbox.Library.Forms
|
|||||||
colorDlg = new STColorDialog(color);
|
colorDlg = new STColorDialog(color);
|
||||||
colorDlg.FormClosed += delegate
|
colorDlg.FormClosed += delegate
|
||||||
{
|
{
|
||||||
|
mouseLoc = Point.Empty;
|
||||||
|
this.Invalidate();
|
||||||
dialogActive = false;
|
dialogActive = false;
|
||||||
};
|
};
|
||||||
colorDlg.Show();
|
colorDlg.Show();
|
||||||
@ -380,7 +386,7 @@ namespace Toolbox.Library.Forms
|
|||||||
using (Brush br = new SolidBrush(BottomRightColor.GrayScale(true).Inverse()))
|
using (Brush br = new SolidBrush(BottomRightColor.GrayScale(true).Inverse()))
|
||||||
pe.Graphics.DrawString("BR", font, br, new Point(RightX, BottomY));
|
pe.Graphics.DrawString("BR", font, br, new Point(RightX, BottomY));
|
||||||
|
|
||||||
if (mouseLoc != null)
|
if (mouseLoc != Point.Empty)
|
||||||
{
|
{
|
||||||
if (AllHit.IsHit(mouseLoc))
|
if (AllHit.IsHit(mouseLoc))
|
||||||
DrawSelectionOutline(pe, AllHit);
|
DrawSelectionOutline(pe, AllHit);
|
||||||
@ -406,7 +412,16 @@ namespace Toolbox.Library.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawSelectionOutline(PaintEventArgs pe, Rectangle rect) {
|
private void DrawSelectionOutline(PaintEventArgs pe, Rectangle rect) {
|
||||||
pe.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black), 1), rect);
|
//Select entire regions
|
||||||
|
Rectangle selection = rect;
|
||||||
|
if (rect == TopHit || rect == BottomHit) {
|
||||||
|
selection = new Rectangle(0, rect.Y, pe.ClipRectangle.Width, rect.Height);
|
||||||
|
}
|
||||||
|
if (rect == LeftHit || rect == RightHit) {
|
||||||
|
selection = new Rectangle(rect.X,0, rect.Width, pe.ClipRectangle.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
pe.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black), 1), selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user