Skip to content

Commit

Permalink
Changing form size are more smooth when title bar was hidden, level s…
Browse files Browse the repository at this point in the history
…tream start point now has vertical red line, and some other minor bug fix.
  • Loading branch information
osamusg committed Feb 20, 2024
1 parent 1ed97e9 commit d6d2b11
Show file tree
Hide file tree
Showing 8 changed files with 379 additions and 336 deletions.
11 changes: 7 additions & 4 deletions SpeAnaLED/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

404 changes: 199 additions & 205 deletions SpeAnaLED/Form1.cs

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions SpeAnaLED/Form2.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion SpeAnaLED/Form2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ private void PeakholdDescentSpeedTextBox_KeyDown(object sender, KeyEventArgs e)
PeakholdDescentSpeedTextBox.Text = PeakholdDescentSpeedTrackBar.Value.ToString();
}
}

}

private void PeakholdDescentSpeedTextBox_Leave(object sender, EventArgs e)
Expand Down
3 changes: 3 additions & 0 deletions SpeAnaLED/Form3.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

130 changes: 76 additions & 54 deletions SpeAnaLED/Form3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public partial class Form3 : Form

private readonly Form1 myParent;
private readonly bool hideTitle;
private Point mousePoint = new Point(0, 0);
private Point mouseDragStartPoint = new Point(0, 0);
private bool pinchLeft, pinchRight, pinchTop, pinchBottom;
public readonly Bitmap[] canvas = new Bitmap[2];
private bool inFormSizeChange;
private readonly string panelFontName = "Levenim MT Bold";
Expand All @@ -38,8 +39,8 @@ private void Form3_Load(object sender, System.EventArgs e)
this.FormBorderStyle = FormBorderStyle.None;
}

private void Draw_Panel()
{
private void Draw_Panel()
{
Font panelFont = new Font(panelFontName, 9f, FontStyle.Bold);

FormPictureBox.Top = FormPictureBox.Left = 0;
Expand Down Expand Up @@ -89,77 +90,98 @@ private void Form3_FormClosed(object sender, FormClosedEventArgs e)

private void LevelPictureBox_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
mousePoint = new Point(e.X, e.Y);
else if (e.Button == MouseButtons.Right)
PictureBox_MouseDown?.Invoke(this, e);
if (this.Cursor != Cursors.Default)
inFormSizeChange = true;
else
inFormSizeChange = false;
int mdt = 8; // mouse detect thickness (inner)

if (e.Button == MouseButtons.Right)
{
PictureBox_MouseDown?.Invoke(sender, e);
}
else if (e.Button == MouseButtons.Left)
{
if (FormBorderStyle == FormBorderStyle.None)
{
mouseDragStartPoint = new Point(e.X, e.Y);

pinchLeft = e.X < mdt;
pinchRight = e.X > Width - mdt;
pinchTop = e.Y < mdt;
pinchBottom = e.Y > Height - mdt;
inFormSizeChange = pinchLeft || pinchRight || pinchTop || pinchBottom;
if (!inFormSizeChange) Cursor = Cursors.SizeAll;
}
}
}

private void LevelPictureBox_MouseMove(object sender, MouseEventArgs e)
{
int minWidth = 64;
int minHeight = 32;

if (e.Button == MouseButtons.Left)
if (FormBorderStyle == FormBorderStyle.None)
{
if (this.Cursor == Cursors.SizeWE)
int minWidth = 64;
int minHeight = 32;
int mdt = 8; // mouse detect thickness

if (e.Button == MouseButtons.Left)
{
if (e.X < this.Width / 2)
{
this.Width -= e.X - mousePoint.X;
if (this.Width < minWidth) this.Width = minWidth;
else this.Left += e.X - mousePoint.X;
}
else
if (Cursor == Cursors.SizeWE)
{
this.Width += (e.X - mousePoint.X) / 25;
if (this.Width < minWidth) this.Width = minWidth;
if (pinchLeft)
{
Width -= e.X - mouseDragStartPoint.X;
if (Width < minWidth) Width = minWidth;
else Left += e.X - mouseDragStartPoint.X;
}
else if (pinchRight)
{
Width = e.X;
if (Width < minWidth) Width = minWidth;
}
}
}
else if (this.Cursor == Cursors.SizeNS)
{
if (e.Y < this.Height / 3)
else if (Cursor == Cursors.SizeNS)
{
this.Height -= (e.Y - mousePoint.Y) / 15;
if (this.Height < minHeight) this.Height = minHeight;
else this.Top += (e.Y - mousePoint.Y) / 15;
if (pinchTop)
{
Height -= e.Y - mouseDragStartPoint.Y;
if (Height < minHeight) Height = minHeight;
else Top += e.Y - mouseDragStartPoint.Y;
}
else if (pinchBottom)
{
Height = e.Y;
if (Height < minHeight) Height = minHeight;
}
}
else if (e.Y > this.Height * 1 / 2)
else
{
this.Height += (e.Y - mousePoint.Y) / 25;
if (this.Height < minHeight) this.Height = minHeight;
Left += e.X - mouseDragStartPoint.X;
Top += e.Y - mouseDragStartPoint.Y;
}
}
else
{
this.Left += e.X - mousePoint.X;
this.Top += e.Y - mousePoint.Y;
}
}
if (this.FormBorderStyle == FormBorderStyle.None)
{
if (e.X < 8 || e.X > this.Width - 8)
this.Cursor = Cursors.SizeWE;
else if (e.Y < 8 || e.Y > this.Height - 8)
this.Cursor = Cursors.SizeNS;
else if (!inFormSizeChange)
this.Cursor = Cursors.Default;
}
}

private void LevelPictureBox_DoubleClick(object sender, EventArgs e)
{
if (!myParent.Visible) myParent.Visible = true;
if (e.X < mdt || e.X > Width - mdt)
Cursor = Cursors.SizeWE;
else if (e.Y < mdt || e.Y > Height - mdt)
Cursor = Cursors.SizeNS;
else if (Cursor != Cursors.SizeAll && e.Button == MouseButtons.None)
Cursor = Cursors.Default;
}
}

private void LevelPictureBox_MouseHover(object sender, EventArgs e)
{
inFormSizeChange = false;
this.Cursor = Cursors.Default;
}

private void LevelPictureBox_MouseUp(object sender, MouseEventArgs e)
{
if (Cursor != Cursors.Default)
Cursor = Cursors.Default;
pinchLeft = pinchRight = pinchTop = pinchBottom = false;
}

private void LevelPictureBox_DoubleClick(object sender, EventArgs e)
{
if (!myParent.Visible) myParent.Visible = true;
}
}
}
1 change: 1 addition & 0 deletions SpeAnaLED/Form4.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d6d2b11

Please sign in to comment.