#if FRAMEWORK20 using System; using System.Drawing; using System.Windows.Forms; namespace DevComponents.DotNetBar.Schedule { public class VScrollPanel : BaseItem { #region Events public event EventHandler ScrollBarChanged; #endregion #region Variables protected CalendarView CalendarView; // CalendarView private VScrollBarAdv _ScrollBar; // Scroll bar #endregion /// /// Constructor /// /// public VScrollPanel(CalendarView calendarView) { CalendarView = calendarView; SetUpScrollBar(); } #region Public properties /// /// Gets and sets the panel Bounds /// public override Rectangle Bounds { get { return (base.Bounds); } set { base.Bounds = value; UpdateScrollBar(); } } /// /// Gets and sets the control visibility /// public override bool Visible { get { return (base.Visible); } set { if (base.Visible != value) { base.Visible = value; ScrollBar.Visible = value; if (value == true) ScrollBar.BringToFront(); } } } /// /// Gets the scrollBar /// public VScrollBarAdv ScrollBar { get { return (_ScrollBar); } } #endregion #region Private properties /// /// Gets the scrollBar SmallChange value /// protected virtual int ScrollPanelSmallChange { get { return (1); } } /// /// Gets the scrollBar Maximum value /// protected virtual int ScrollPanelMaximum { get { return (100); } } #endregion #region SetupScrollBar /// /// Performs scrollBar setup /// private void SetUpScrollBar() { _ScrollBar = new VScrollBarAdv(); Control c = (Control)CalendarView.CalendarPanel.GetContainerControl(true); if (c != null) c.Controls.Add(_ScrollBar); _ScrollBar.ValueChanged += ValueChanged; UpdateScrollBar(); } #endregion #region UpdateScrollBar /// /// Updates our scrollbar /// internal void UpdateScrollBar() { _ScrollBar.Location = Bounds.Location; _ScrollBar.Height = Bounds.Height; _ScrollBar.Width = Bounds.Width; _ScrollBar.LargeChange = Bounds.Height; _ScrollBar.SmallChange = 1; _ScrollBar.SmallChange = ScrollPanelSmallChange; _ScrollBar.Maximum = ScrollPanelMaximum; int n = _ScrollBar.Maximum - _ScrollBar.LargeChange + 1; if (n < 0) { _ScrollBar.Maximum = Bounds.Height; _ScrollBar.Value = 0; _ScrollBar.Enabled = false; } else { _ScrollBar.Enabled = true; if (_ScrollBar.Value > n) _ScrollBar.Value = n; else Refresh(); } OnScrollBarUpdate(); } #endregion #region DisableScrollBar /// /// Disables the scrollbar /// internal void DisableScrollBar() { _ScrollBar.Location = Bounds.Location; _ScrollBar.Height = Bounds.Height; _ScrollBar.LargeChange = Bounds.Height; _ScrollBar.SmallChange = 1; _ScrollBar.SmallChange = ScrollPanelSmallChange; _ScrollBar.Maximum = Bounds.Height; _ScrollBar.Value = 0; _ScrollBar.Enabled = false; OnScrollBarUpdate(); } #endregion #region ValueChanged /// object /// EventArgs void ValueChanged(object sender, EventArgs e) { OnScrollBarUpdate(); } /// /// Passes the scroll onto others /// private void OnScrollBarUpdate() { if (ScrollBarChanged != null) ScrollBarChanged(this, EventArgs.Empty); } #endregion #region IDisposable Members protected override void Dispose(bool disposing) { if (_ScrollBar != null) { _ScrollBar.ValueChanged -= ValueChanged; _ScrollBar.Dispose(); } base.Dispose(disposing); } #endregion #region Paint public override void Paint(ItemPaintArgs p) { } #endregion #region Copy public override BaseItem Copy() { return (null); } #endregion } } #endif