using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace DevComponents.DotNetBar.Controls
{
///
/// Represents Range Slider Control.
///
[ToolboxBitmap(typeof(RangeSlider), "Controls.RangeSlider.ico"), ToolboxItem(true), DefaultEvent("ValueChanged"), ComVisible(false), Designer("DevComponents.DotNetBar.Design.RangeSliderDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
public class RangeSlider : BaseItemControl
{
#region Private Variables
private RangeSliderItem _Slider = null;
#endregion
#region Events
///
/// Occurs before Value has changed and allow the cancellation of the change.
///
[Description("Occurs before Value has changed and allow the cancellation of the change.")]
public event RangeSliderValueChangingEventHandler ValueChanging;
///
/// Raises ValueChanging event.
///
/// Provides event arguments.
protected virtual void OnValueChanging(RangeSliderValueChangingEventArgs e)
{
RangeSliderValueChangingEventHandler handler = ValueChanging;
if (handler != null)
handler(this, e);
}
///
/// Occurs after Value property has changed
///
[Description("Occurs after Value property has changed.")]
public event EventHandler ValueChanged;
///
/// Raises ValueChanged event.
///
/// Provides event arguments.
protected virtual void OnValueChanged(EventArgs e)
{
EventHandler handler = ValueChanged;
if (handler != null)
handler(this, e);
}
///
/// Occurs when control is about to display the range tooltip and it allows you to customize tooltip
///
[Description("Occurs when control is about to display the range tooltip and it allows you to customize tooltip")]
public event RangeTooltipEventHandler RangeTooltipText;
///
/// Raises GetRangeTooltipText event.
///
/// Provides event arguments.
protected virtual void OnRangeTooltipText(RangeTooltipEventArgs e)
{
RangeTooltipEventHandler handler = RangeTooltipText;
if (handler != null)
handler(this, e);
}
#endregion
#region Constructor, Dispose
public RangeSlider()
{
_Slider = new RangeSliderItem();
_Slider.Style = eDotNetBarStyle.StyleManagerControlled;
_Slider.ValueChanging += new RangeSliderValueChangingEventHandler(Slider_ValueChanging);
_Slider.ValueChanged += new EventHandler(Slider_ValueChanged);
_Slider.RangeTooltipText += new RangeTooltipEventHandler(Slider_RangeTooltipText);
this.HostItem = _Slider;
}
void Slider_RangeTooltipText(object sender, RangeTooltipEventArgs e)
{
OnRangeTooltipText(e);
}
void Slider_ValueChanged(object sender, EventArgs e)
{
OnValueChanged(e);
}
void Slider_ValueChanging(object sender, RangeSliderValueChangingEventArgs e)
{
OnValueChanging(e);
}
///
/// Forces the button to perform internal layout.
///
public override void RecalcLayout()
{
Rectangle r = GetItemBounds();
_Slider.Width = r.Width;
_Slider.Height = r.Height;
base.RecalcLayout();
}
protected override void OnHandleCreated(EventArgs e)
{
this.RecalcLayout();
base.OnHandleCreated(e);
}
//protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
//{
// if (keyData == System.Windows.Forms.Keys.Left)
// {
// m_Slider.Increment(-m_Slider.Step, eEventSource.Keyboard);
// return true;
// }
// else if (keyData == System.Windows.Forms.Keys.Right)
// {
// m_Slider.Increment(m_Slider.Step, eEventSource.Keyboard);
// return true;
// }
// return base.ProcessCmdKey(ref msg, keyData);
//}
///
/// Gets the RangeSliderItem.
///
internal RangeSliderItem SliderItem
{
get { return (_Slider); }
}
///
/// Indicates whether clicking the area outside of the range change buttons moves the range change button to the clicked location if possible thus allowing range change.
///
[DefaultValue(true), Category("Behavior"), Description("Indicates whether clicking the area outside of the range change buttons moves the range change button to the clicked location if possible thus allowing range change.")]
public bool ClientClickRangeChangeEnabled
{
get { return _Slider.ClientClickRangeChangeEnabled; }
set
{
_Slider.ClientClickRangeChangeEnabled = value;
}
}
///
/// Gets or sets the maximum value of the range of the control.
///
[Description("Gets or sets the maximum value of the range of the control."), Category("Behavior"), DefaultValue(10)]
public int Maximum
{
get { return _Slider.Maximum; }
set
{
_Slider.Maximum = value;
}
}
///
/// Gets or sets the minimum value of the range of the control.
///
[Description("Gets or sets the minimum value of the range of the control."), Category("Behavior"), DefaultValue(0)]
public int Minimum
{
get { return _Slider.Minimum; }
set
{
_Slider.Minimum = value;
}
}
///
/// Indicates image to be used as maximum range slider button instead of built-in button. Image is scaled to size set by RangeButtonSize.
///
[DefaultValue(null), Category("Appearance"), Description("Indicates image to be used as maximum range slider button instead of built-in button. Image is scaled to size set by RangeButtonSize.")]
public Image MaxRangeSliderImage
{
get { return _Slider.MaxRangeSliderImage; }
set
{
_Slider.MaxRangeSliderImage = value;
}
}
///
/// Indicates image to be used as minimum range slider button instead of built-in button. Image is scaled to size set by RangeButtonSize.
///
[DefaultValue(null), Category("Appearance"), Description("Indicates image to be used as minimum range slider button instead of built-in button. Image is scaled to size set by RangeButtonSize.")]
public Image MinRangeSliderImage
{
get { return _Slider.MinRangeSliderImage; }
set
{
_Slider.MinRangeSliderImage = value;
}
}
///
/// Specifies minimum absolute range that user can select. Absolute range is defined as Abs(Value.Max-Value.Min) Applies to user performed selection through mouse only.
///
[DefaultValue(0), Category("Behavior"), Description("Specifies minimum absolute range that user can select. Absolute range is defined as Abs(Value.Max-Value.Min) Applies to user performed selection through mouse only.")]
public int MinimumAbsoluteRange
{
get { return _Slider.MinimumAbsoluteRange; }
set
{
_Slider.MinimumAbsoluteRange = value;
}
}
///
/// Gets current part that is pressed using mouse left button.
///
[Browsable(false)]
public eRangeSliderPart MouseDownPart
{
get { return _Slider.MouseDownPart; }
}
///
/// Gets mouse over part.
///
[Browsable(false)]
public eRangeSliderPart MouseOverPart
{
get { return _Slider.MouseOverPart; }
}
///
/// Gets bounds of maximum range sliding button.
///
[Browsable(false)]
public Rectangle RangeButtonMaxBounds
{
get
{
return _Slider.RangeButtonMaxBounds;
}
}
///
/// Gets bounds of minimum range sliding button.
///
[Browsable(false)]
public Rectangle RangeButtonMinBounds
{
get
{
return _Slider.RangeButtonMinBounds;
}
}
///
/// Indicates the size of the range change buttons.
///
[Description("Indicates the size of the range change buttons."), Category("Appearance")]
public Size RangeButtonSize
{
get { return _Slider.RangeButtonSize; }
set
{
_Slider.RangeButtonSize = value;
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeRangeButtonSize()
{
return _Slider.ShouldSerializeRangeButtonSize();
}
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetRangeButtonSize()
{
_Slider.ResetRangeButtonSize();
}
///
/// Specifies the height of the range line
///
[DefaultValue(7), Category("Appearance"), Description("Specifies the height of the range line")]
public int RangeLineHeight
{
get { return _Slider.RangeLineHeight; }
set
{
_Slider.RangeLineHeight = value;
}
}
///
/// Gets or sets the string that is used to format the range value to be displayed while user moves the range buttons. Value set here is used in string.Format(RangeTooltipFormat, Value.Min, Value.Max).
///
[DefaultValue("{0} - {1}"), Description("Indicate string that is used to format the range value to be displayed while user moves the range buttons. Value set here is used in string.Format(RangeTooltipFormat, Value.Min, Value.Max)."), Localizable(true), Category("Behavior")]
public string RangeTooltipFormat
{
get { return _Slider.RangeTooltipFormat; }
set
{
_Slider.RangeTooltipFormat = value;
}
}
///
/// Gets or sets the color of the range value.
///
[Category("Appearance"), Description("Indicates color of range value.")]
public Color RangeValueColor
{
get { return _Slider.RangeValueColor; }
set
{
_Slider.RangeValueColor = value;
}
}
///
/// Gets whether property should be serialized.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeRangeValueColor()
{
return _Slider.ShouldSerializeRangeValueColor();
}
///
/// Resets property to its default value.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetRangeValueColor()
{
_Slider.ResetRangeValueColor();
}
///
/// Specifies whether range tooltip is shown while user is changing the range
///
[DefaultValue(true), Category("Behavior"), Description("Specifies whether range tooltip is shown while user is changing the range")]
public bool ShowRangeTooltip
{
get { return _Slider.ShowRangeTooltip; }
set
{
_Slider.ShowRangeTooltip = value;
}
}
///
/// Gets or sets the slider orientation. Default value is horizontal.
///
[DefaultValue(eOrientation.Horizontal), Category("Appearance"), Description("Indicates slider orientation.")]
public eOrientation SliderOrientation
{
get { return _Slider.SliderOrientation; }
set
{
_Slider.SliderOrientation = value;
}
}
[Browsable(false)]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
///
/// Gets tick marks bounds.
///
[Browsable(false)]
public Rectangle TicksBounds
{
get
{
return _Slider.TicksBounds;
}
}
private Rectangle _TicksBounds2 = Rectangle.Empty;
///
/// Gets tick marks bounds for second marker is visible.
///
[Browsable(false)]
public Rectangle TicksBounds2
{
get
{
return _Slider.TicksBounds2;
}
}
///
/// Specifies the ticks position inside of Range Slider.
///
[DefaultValue(eTicksPosition.Bottom), Category("Appearance"), Description("Specifies the ticks position inside of Range Slider.")]
public eTicksPosition TicksPosition
{
get { return _Slider.TicksPosition; }
set
{
_Slider.TicksPosition = value;
}
}
///
/// Indicates tick display period
///
[DefaultValue(1), Category("Appearance"), Description("Indicates tick display period")]
public int TicksStep
{
get { return _Slider.TicksStep; }
set
{
_Slider.TicksStep = value;
}
}
///
/// Indicates whether tick lines are shown
///
[DefaultValue(true), Category("Appearance"), Description("Indicates whether tick lines are shown")]
public bool TicksVisible
{
get { return _Slider.TicksVisible; }
set
{
_Slider.TicksVisible = value;
}
}
///
/// Gets or sets the range displayed by the control.
///
[Description("Specifies range displayed by the control."), Category("Data")]
public RangeValue Value
{
get { return _Slider.Value; }
set
{
_Slider.Value = value;
}
}
#endregion
}
}