81 lines
2.5 KiB
C#
81 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mip
|
|
{
|
|
class CustomControls
|
|
{
|
|
|
|
|
|
public class RotatedLabel : System.Windows.Forms.Label
|
|
{
|
|
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
|
|
{
|
|
|
|
string Name = base.Name;
|
|
Name = Parent.Name;
|
|
var g = e.Graphics;
|
|
g.DrawString(Name, new Font("Tahoma", 10), Brushes.Black, 0, 0, new StringFormat(StringFormatFlags.DirectionVertical));
|
|
}
|
|
|
|
}
|
|
|
|
public class NoScrollPanel : Panel
|
|
{
|
|
|
|
protected override void OnMouseWheel(MouseEventArgs e)
|
|
{
|
|
HandledMouseEventArgs mouseEvent = (HandledMouseEventArgs)e;
|
|
mouseEvent.Handled = true;
|
|
|
|
}
|
|
}
|
|
|
|
public class AdaptiveSizeTextBox : TextBox
|
|
{
|
|
protected override void OnTextChanged(EventArgs e)
|
|
{
|
|
using (Graphics g = CreateGraphics())
|
|
{
|
|
SizeF size = g.MeasureString(Text, Font);
|
|
if (size.Width > 20) Width = (int)Math.Ceiling(size.Width) +5;
|
|
else Width = 25;
|
|
}
|
|
base.OnTextChanged(e);
|
|
}
|
|
|
|
}
|
|
public class FloatTrackBar : TrackBar
|
|
{
|
|
private float precision = 0.01f;
|
|
|
|
public float Precision
|
|
{
|
|
get { return precision; }
|
|
set
|
|
{
|
|
precision = value;
|
|
// todo: update the 5 properties below
|
|
}
|
|
}
|
|
public new float LargeChange
|
|
{ get { return base.LargeChange * precision; } set { base.LargeChange = (int)(value / precision); } }
|
|
public new float Maximum
|
|
{ get { return base.Maximum * precision; } set { base.Maximum = (int)(value / precision); } }
|
|
public new float Minimum
|
|
{ get { return base.Minimum * precision; } set { base.Minimum = (int)(value / precision); } }
|
|
public new float SmallChange
|
|
{ get { return base.SmallChange * precision; } set { base.SmallChange = (int)(value / precision); } }
|
|
public new float Value
|
|
{ get { return base.Value * precision; } set { base.Value = (int)(value / precision); } }
|
|
}
|
|
}
|
|
|
|
|
|
}
|