#if FRAMEWORK20
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
namespace DevComponents.DotNetBar.Controls
{
///
/// Represents the PageNavigator control
///
[ToolboxBitmap(typeof(PageNavigator), "PageNavigator.PageNavigator.ico"), ToolboxItem(true)]
[DefaultEvent("ValueChanged"), ComVisible(false)] //, Designer(typeof(Design.PageNavigatorDesigner))]
public class PageNavigator : BaseItemControl
{
#region Private Variables
private PageNavigatorItem _PageNavItem; // Navigation item
#endregion
#region Events
///
/// Occurs when NavigateNextPage button is clicked
///
[Description("Occurs when NavigateNextPage button is clicked.")]
public event EventHandler NavigateNextPage;
///
/// Occurs when NavigateToday button is clicked
///
[Description("Occurs when NavigateToday button is clicked.")]
public event EventHandler NavigateToday;
///
/// Occurs when NavigatePreviousPage button is clicked
///
[Description("Occurs when NavigatePreviousPage button is clicked.")]
public event EventHandler NavigatePreviousPage;
#endregion
///
/// Constructor
///
public PageNavigator()
{
_PageNavItem = new PageNavigatorItem();
_PageNavItem.Style = eDotNetBarStyle.StyleManagerControlled;
this.Size = _PageNavItem.Size;
this.HostItem = _PageNavItem;
HookEvents(true);
}
#region DefaultSize
///
/// DefaultSize
///
protected override Size DefaultSize
{
get
{
// Set a default size based upon
// the current object layout orientation
int m = SystemInformation.VerticalScrollBarWidth;
int n = m * 3;
if (_PageNavItem != null &&
_PageNavItem.Orientation == eOrientation.Horizontal)
{
return (new Size(n, m));
}
return (new Size(m, n));
}
}
#endregion
#region Public properties
#region Orientation
///
/// Gets or sets the layout orientation. Default value is horizontal.
///
[DefaultValue(eOrientation.Horizontal), Category("Appearance")]
[Description("Indicates control layout orientation.")]
public eOrientation Orientation
{
get { return (_PageNavItem.Orientation); }
set
{
if (_PageNavItem.Orientation != value)
{
_PageNavItem.Orientation = value;
this.RecalcLayout();
}
}
}
#endregion
#region PreviousPageTooltip
///
/// Gets or sets the tooltip for the PreviousPage button of the control
///
[Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance")]
[Description("Indicates tooltip for the PreviousPage button of the control.")]
public string PreviousPageTooltip
{
get { return (_PageNavItem.PreviousPageTooltip); }
set { _PageNavItem.PreviousPageTooltip = value; }
}
#endregion
#region TodayTooltip
///
/// Gets or sets the tooltip for the Today button
///
[Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance")]
[Description("Indicates tooltip for the TodayPage button of the control.")]
public string TodayTooltip
{
get { return (_PageNavItem.TodayTooltip); }
set { _PageNavItem.TodayTooltip = value; }
}
#endregion
#region NextPageTooltip
///
/// Gets or sets the tooltip for the NextPage button
///
[Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance")]
[Description("Indicates tooltip for the NextPage button of the control.")]
public string NextPageTooltip
{
get { return (_PageNavItem.NextPageTooltip); }
set { _PageNavItem.NextPageTooltip = value; }
}
#endregion
#region Style
///
/// Gets/Sets the visual style for the control.
///
[Browsable(false), DefaultValue(eDotNetBarStyle.StyleManagerControlled)]
public override eDotNetBarStyle Style
{
get
{
return base.Style;
}
set
{
base.Style = value;
}
}
#endregion
#endregion
#region HookEvents
///
/// Hooks or unhooks our control events
///
/// true to hook, false to unhook
private void HookEvents(bool hook)
{
if (hook == true)
{
_PageNavItem.NavigatePreviousPage += PageNavNavigatePreviousPage;
_PageNavItem.NavigateNextPage += PageNavNavigateNextPage;
_PageNavItem.NavigateToday += PageNavNavigateToday;
}
else
{
_PageNavItem.NavigatePreviousPage -= PageNavNavigatePreviousPage;
_PageNavItem.NavigateNextPage -= PageNavNavigateNextPage;
_PageNavItem.NavigateToday -= PageNavNavigateToday;
}
}
#endregion
#region Event handling
#region PageNav_NavigatePreviousPage
///
/// Handles NavigatePreviousPage events
///
///
///
void PageNavNavigatePreviousPage(object sender, EventArgs e)
{
OnNavigatePreviousPage();
}
///
/// Raises the NavigatePreviousPage event
///
private void OnNavigatePreviousPage()
{
if (NavigatePreviousPage != null)
NavigatePreviousPage(this, EventArgs.Empty);
}
#endregion
#region PageNav_NavigateToday
///
/// Handles NavigateToday events
///
///
///
void PageNavNavigateToday(object sender, EventArgs e)
{
OnNavigateToday();
}
///
/// Raises the NavigateToday event
///
private void OnNavigateToday()
{
if (NavigateToday != null)
NavigateToday(this, EventArgs.Empty);
}
#endregion
#region PageNav_NavigateNextPage
///
/// Handles NavigateNextPage events
///
///
///
void PageNavNavigateNextPage(object sender, EventArgs e)
{
OnNavigateNextPage();
}
///
/// Raises the NavigateNextPage event
///
private void OnNavigateNextPage()
{
if (NavigateNextPage != null)
NavigateNextPage(this, EventArgs.Empty);
}
#endregion
#endregion
#region RecalcLayout
///
/// Forces the button to perform internal layout.
///
public override void RecalcLayout()
{
base.RecalcLayout();
}
#endregion
#region Dispose
///
/// Dispose
///
///
protected override void Dispose(bool disposing)
{
if (disposing == true)
HookEvents(false);
base.Dispose(disposing);
}
#endregion
}
#region enums
///
/// PageNavigator buttons
///
public enum PageNavigatorButton
{
///
/// Previous page
///
PreviousPage,
///
/// Today
///
Today,
///
/// Next page
///
NextPage
}
#endregion
}
#endif