Skip to content

Commit

Permalink
RangeControl: reduce allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Jul 20, 2023
1 parent 134e3ea commit 142d367
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 56 deletions.
52 changes: 12 additions & 40 deletions ExtLibs/Controls/RangeControl.Designer.cs

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

35 changes: 19 additions & 16 deletions ExtLibs/Controls/RangeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,9 @@ public NumericUpDown NumericUpDownControl
set { numericUpDown1 = value; }
}

public string DescriptionText
{
get { return label1.Text; }
set
{
//label1.MaximumSize = new Size(this.Width - 30, 0);
label1.Text = value;
//this.Height += label1.Height;
}
}
public string DescriptionText;

public string LabelText
{
get { return myLabel1.Text; }
set { myLabel1.Text = value; }
}
public string LabelText;

public TrackBar TrackBarControl
{
Expand Down Expand Up @@ -130,7 +117,6 @@ public RangeControl()
delegate (object sender, MouseEventArgs args) { ((HandledMouseEventArgs)args).Handled = true; };
}


public RangeControl(string param, String Desc, string Label, float increment, float Displayscale, float minrange,
float maxrange, string value)
{
Expand Down Expand Up @@ -162,6 +148,9 @@ public void setup(string param, string Desc, string Label, float increment, floa

#endregion

Font FontLabel = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));


#region Methods

protected override void OnPaint(PaintEventArgs e)
Expand All @@ -172,6 +161,20 @@ protected override void OnPaint(PaintEventArgs e)
if (!numericUpDown1.Visible)
numericUpDown1.Visible = true;
base.OnPaint(e);

e.Graphics.DrawString(LabelText, FontLabel, new SolidBrush(this.Parent.ForeColor), 3, 0);

e.Graphics.DrawString(DescriptionText, this.Font, new SolidBrush(this.Parent.ForeColor),
new RectangleF(3, 15, this.Width, 39));
/*
e.Graphics.DrawString(LBL_min, this.Font, new SolidBrush(this.Parent.ForeColor),
new RectangleF(trackBar1.Left, trackBar1.Bottom - this.Font.Height, 100, this.Font.Height));
var size = e.Graphics.MeasureString(LBL_max, this.Font);
e.Graphics.DrawString(LBL_max, this.Font, new SolidBrush(this.Parent.ForeColor),
new RectangleF(trackBar1.Right - size.Width, trackBar1.Bottom - this.Font.Height, size.Width,
this.Font.Height));
*/
}

public void AttachEvents()
Expand Down

0 comments on commit 142d367

Please sign in to comment.