📄 xtrackbar.cs
字号:
this.DrawColorSlider(e, colorArray[0], colorArray[1], colorArray[2], colorArray[3], colorArray[4]);
}
else if (this.mouseEffects && this.mouseInRegion)
{
Color[] colorsToLighten = new Color[] { this.thumbOuterColor, this.thumbInnerColor, this.thumbPenColor };
Color[] colorArray2 = LightenColors(colorsToLighten);
this.DrawColorSlider(e, colorArray2[0], colorArray2[1], colorArray2[2], this.barOuterColor, this.barInnerColor);
}
else
{
this.DrawColorSlider(e, this.thumbOuterColor, this.thumbInnerColor, this.thumbPenColor, this.barOuterColor, this.barInnerColor);
}
}
protected override bool ProcessDialogKey(Keys keyData)
{
if ((keyData == Keys.Tab) | (Control.ModifierKeys == Keys.Shift))
{
return base.ProcessDialogKey(keyData);
}
this.OnKeyDown(new KeyEventArgs(keyData));
return true;
}
private void SetProperValue(int val)
{
if (val < this.barMinimum)
{
this.Value = this.barMinimum;
}
else if (val > this.barMaximum)
{
this.Value = this.barMaximum;
}
else
{
this.Value = val;
}
}
[Category("XTrackBar"), DefaultValue(typeof(Color), "DarkSlateBlue"), Description("Set Slider bar inner color")]
public Color BarInnerColor
{
get
{
return this.barInnerColor;
}
set
{
this.barInnerColor = value;
base.Invalidate();
}
}
[DefaultValue(typeof(Color), "SkyBlue"), Category("XTrackBar"), Description("Set Slider bar outer color")]
public Color BarOuterColor
{
get
{
return this.barOuterColor;
}
set
{
this.barOuterColor = value;
base.Invalidate();
}
}
[Category("XTrackBar"), DefaultValue(3), Description("Set Slider bar size")]
public int BarSize
{
get
{
return this.barSize;
}
set
{
if (this.barSize != value)
{
if (!((value > 0) & (value < ((this.barOrientation == System.Windows.Forms.Orientation.Horizontal) ? this.ClientRectangle.Height : this.ClientRectangle.Width))))
{
throw new ArgumentOutOfRangeException("TrackSize has to be greather than zero and lower than half of Slider width");
}
this.barSize = value;
base.Invalidate();
}
}
}
public Rectangle ClientRectangle
{
get
{
return new Rectangle(base.get_Padding().get_Left(), base.get_Padding().get_Top(), base.Width - base.get_Padding().get_Horizontal(), base.Height - base.get_Padding().get_Vertical());
}
}
[Description("Set Slider color schema. Has no effect when slider colors are changed manually after schema was applied."), DefaultValue(typeof(ColorSchemas), "PerlBlueGreen"), Category("XTrackBar")]
public ColorSchemas ColorSchema
{
get
{
return this.colorSchema;
}
set
{
this.colorSchema = value;
byte num = (byte) value;
this.thumbOuterColor = *(this.aColorSchema[num, 0]);
this.thumbInnerColor = *(this.aColorSchema[num, 1]);
this.thumbPenColor = *(this.aColorSchema[num, 2]);
this.barOuterColor = *(this.aColorSchema[num, 3]);
this.barInnerColor = *(this.aColorSchema[num, 4]);
base.Invalidate();
}
}
[Description("Set whether to draw focus rectangle"), Category("XTrackBar"), DefaultValue(true)]
public bool DrawFocusRectangle
{
get
{
return this.drawFocusRectangle;
}
set
{
this.drawFocusRectangle = value;
base.Invalidate();
}
}
[Category("XTrackBar"), DefaultValue(true), Description("Set whether to draw semitransparent thumb")]
public bool DrawSemitransparentThumb
{
get
{
return this.drawSemitransparentThumb;
}
set
{
this.drawSemitransparentThumb = value;
base.Invalidate();
}
}
[DefaultValue(5), Category("XTrackBar"), Description("Set trackbar's large change")]
public uint LargeChange
{
get
{
return this.largeChange;
}
set
{
this.largeChange = value;
}
}
[DefaultValue(100), Category("XTrackBar"), Description("Set Slider maximal point")]
public int Maximum
{
get
{
return this.barMaximum;
}
set
{
if (value <= this.barMinimum)
{
throw new ArgumentOutOfRangeException("Maximal value is lower than minimal one");
}
this.barMaximum = value;
if (this.trackerValue > this.barMaximum)
{
this.trackerValue = this.barMaximum;
if (this.ValueChanged != null)
{
this.ValueChanged(this, new EventArgs());
}
}
base.Invalidate();
}
}
[Description("Set Slider minimal point"), Category("XTrackBar"), DefaultValue(0)]
public int Minimum
{
get
{
return this.barMinimum;
}
set
{
if (value >= this.barMaximum)
{
throw new ArgumentOutOfRangeException("Minimal value is greather than maximal one");
}
this.barMinimum = value;
if (this.trackerValue < this.barMinimum)
{
this.trackerValue = this.barMinimum;
if (this.ValueChanged != null)
{
this.ValueChanged(this, new EventArgs());
}
}
base.Invalidate();
}
}
[Description("Set whether mouse entry and exit actions have impact on how control look"), DefaultValue(true), Category("XTrackBar")]
public bool MouseEffects
{
get
{
return this.mouseEffects;
}
set
{
this.mouseEffects = value;
base.Invalidate();
}
}
[DefaultValue(10), Description("Set to how many parts is bar divided when using mouse wheel"), Category("XTrackBar")]
public int MouseWheelBarPartitions
{
get
{
return this.mouseWheelBarPartitions;
}
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException("MouseWheelBarPartitions has to be greather than zero");
}
this.mouseWheelBarPartitions = value;
}
}
[DefaultValue(0), Description("Set Slider orientation"), Category("XTrackBar")]
public System.Windows.Forms.Orientation Orientation
{
get
{
return this.barOrientation;
}
set
{
if (this.barOrientation != value)
{
this.barOrientation = value;
int width = base.Width;
base.Width = base.Height;
base.Height = width;
if (this.thumbCustomShape != null)
{
this.thumbSize = ((this.barOrientation == System.Windows.Forms.Orientation.Horizontal) ? ((int) this.thumbCustomShape.GetBounds().Width) : ((int) this.thumbCustomShape.GetBounds().Height)) + 1;
}
base.Invalidate();
}
}
}
[DefaultValue(1), Category("XTrackBar"), Description("Set trackbar's small change")]
public uint SmallChange
{
get
{
return this.smallChange;
}
set
{
this.smallChange = value;
}
}
[Description("Set Slider's thumb's custom shape"), Category("XTrackBar"), Browsable(false), DefaultValue(typeof(GraphicsPath), "null")]
public GraphicsPath ThumbCustomShape
{
get
{
return this.thumbCustomShape;
}
set
{
this.thumbCustomShape = value;
this.thumbSize = ((this.barOrientation == System.Windows.Forms.Orientation.Horizontal) ? ((int) value.GetBounds().Width) : ((int) value.GetBounds().Height)) + 1;
base.Invalidate();
}
}
[Category("XTrackBar"), DefaultValue(typeof(Color), "Gainsboro"), Description("Set Slider thumb inner color")]
public Color ThumbInnerColor
{
get
{
return this.thumbInnerColor;
}
set
{
this.thumbInnerColor = value;
base.Invalidate();
}
}
[Category("XTrackBar"), DefaultValue(typeof(Color), "White"), Description("Set Slider thumb outer color")]
public Color ThumbOuterColor
{
get
{
return this.thumbOuterColor;
}
set
{
this.thumbOuterColor = value;
base.Invalidate();
}
}
[Description("Set Slider thumb pen color"), Category("XTrackBar"), DefaultValue(typeof(Color), "Silver")]
public Color ThumbPenColor
{
get
{
return this.thumbPenColor;
}
set
{
this.thumbPenColor = value;
base.Invalidate();
}
}
[Browsable(false)]
public Rectangle ThumbRect
{
get
{
return this.thumbRect;
}
}
[DefaultValue(15), Description("Set Slider thumb size"), Category("XTrackBar")]
public int ThumbSize
{
get
{
return this.thumbSize;
}
set
{
if (!((value > 0) & (value < ((this.barOrientation == System.Windows.Forms.Orientation.Horizontal) ? this.ClientRectangle.Width : this.ClientRectangle.Height))))
{
throw new ArgumentOutOfRangeException("TrackSize has to be greather than zero and lower than half of Slider width");
}
this.thumbSize = value;
base.Invalidate();
}
}
[Category("XTrackBar"), Description("Set Slider value"), DefaultValue(50)]
public int Value
{
get
{
return this.trackerValue;
}
set
{
if (this.trackerValue != value)
{
if (!((value >= this.barMinimum) & (value <= this.barMaximum)))
{
throw new ArgumentOutOfRangeException("Value is outside appropriate range (min, max)");
}
this.trackerValue = value;
if (this.ValueChanged != null)
{
this.ValueChanged(this, new EventArgs());
}
base.Invalidate();
}
}
}
public enum ColorSchemas
{
Fetion,
PerlBlueGreen,
PerlRedCoral,
PerlGold,
PerlRoyalColors
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -