using System;
//using System.Drawing;
namespace Gwen.Control
{
///
/// Vertical slider.
///
public class VerticalSlider : Slider
{
///
/// Initializes a new instance of the class.
///
/// Parent control.
public VerticalSlider(Base parent)
: base(parent)
{
m_SliderBar.IsHorizontal = false;
}
protected override float CalculateValue()
{
return 1 - m_SliderBar.Y / (float)(Height - m_SliderBar.Height);
}
protected override void UpdateBarFromValue()
{
m_SliderBar.MoveTo(m_SliderBar.X, (int)((Height - m_SliderBar.Height) * (1 - m_Value)));
}
///
/// Handler invoked on mouse click (left) event.
///
/// X coordinate.
/// Y coordinate.
/// If set to true mouse button is down.
protected override void OnMouseClickedLeft(int x, int y, bool down)
{
m_SliderBar.MoveTo(m_SliderBar.X, (int) (CanvasPosToLocal(new Point(x, y)).Y - m_SliderBar.Height*0.5));
m_SliderBar.InputMouseClickedLeft(x, y, down);
OnMoved(m_SliderBar);
}
///
/// Lays out the control's interior according to alignment, padding, dock etc.
///
/// Skin to use.
protected override void Layout(Skin.Base skin)
{
m_SliderBar.SetSize(Width, 15);
UpdateBarFromValue();
}
///
/// Renders the control using specified skin.
///
/// Skin to use.
protected override void Render(Skin.Base skin)
{
skin.DrawSlider(this, false, m_SnapToNotches ? m_NotchCount : 0, m_SliderBar.Height);
}
}
}