DotNet 4.8.1 build of DotNetBar
This commit is contained in:
28
PROMS/DotNetBar Source Code/ScrollBar/HScrollBarAdv.cs
Normal file
28
PROMS/DotNetBar Source Code/ScrollBar/HScrollBarAdv.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.ScrollBar
|
||||
{
|
||||
[ToolboxItem(true), ToolboxBitmap(typeof(HScrollBarAdv), "ScrollBar.HScrollBarAdv.ico")]
|
||||
public class HScrollBarAdv : ScrollBarAdv
|
||||
{
|
||||
#region Private Variables
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
protected override bool IsVertical()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
BIN
PROMS/DotNetBar Source Code/ScrollBar/HScrollBarAdv.ico
Normal file
BIN
PROMS/DotNetBar Source Code/ScrollBar/HScrollBarAdv.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,283 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.ScrollBar
|
||||
{
|
||||
internal class Office2007ScrollBarPainter : ScrollBarPainter, IOffice2007Painter
|
||||
{
|
||||
#region Private Variables
|
||||
private Office2007ColorTable m_ColorTable = null;
|
||||
private bool m_AppStyleScrollBar = false;
|
||||
private Presentation.ShapeBorder m_ThumbOuterBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeBorder m_ThumbInnerBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeFill m_ThumbInnerFill = new Presentation.ShapeFill();
|
||||
private Presentation.ShapeFill m_ThumbSignFill = new Presentation.ShapeFill();
|
||||
private Presentation.Shape m_ThumbShape = null;
|
||||
private Presentation.ShapePath m_ThumbSignShape = null;
|
||||
private Size m_ThumbSignSize = new Size(9, 5);
|
||||
|
||||
private Presentation.Shape m_TrackShape = null;
|
||||
private Presentation.ShapeBorder m_TrackOuterBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeBorder m_TrackInnerBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeFill m_TrackInnerFill = new Presentation.ShapeFill();
|
||||
|
||||
private Presentation.Shape m_BackgroundShape = null;
|
||||
private Presentation.ShapeBorder m_BackgroundBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeFill m_BackgroundFill = new Presentation.ShapeFill();
|
||||
#endregion
|
||||
|
||||
#region IOffice2007Painter Members
|
||||
|
||||
public DevComponents.DotNetBar.Rendering.Office2007ColorTable ColorTable
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ColorTable;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_ColorTable = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Implemementation
|
||||
public Office2007ScrollBarPainter()
|
||||
{
|
||||
m_ThumbShape = GetThumbShape();
|
||||
m_TrackShape = GetTrackShape();
|
||||
m_BackgroundShape = GetBackgroundShape();
|
||||
}
|
||||
|
||||
public override void PaintThumb(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, eScrollThumbPosition position, eScrollBarState state)
|
||||
{
|
||||
Office2007ScrollBarStateColorTable ct = GetColorTable(state);
|
||||
if (ct == null) return;
|
||||
|
||||
// Initialize Colors
|
||||
m_ThumbOuterBorder.Apply(ct.ThumbOuterBorder);
|
||||
m_ThumbInnerBorder.Apply(ct.ThumbInnerBorder);
|
||||
m_ThumbInnerFill.BackgroundColorBlend = ct.ThumbBackground;
|
||||
m_ThumbSignFill.Apply(ct.ThumbSignBackground);
|
||||
|
||||
m_ThumbSignShape.Path = GetThumbSignPath(position);
|
||||
m_ThumbShape.Paint(new Presentation.ShapePaintInfo(g, bounds));
|
||||
m_ThumbSignShape.Path.Dispose();
|
||||
m_ThumbSignShape.Path = null;
|
||||
}
|
||||
|
||||
private Office2007ScrollBarStateColorTable GetColorTable(eScrollBarState state)
|
||||
{
|
||||
Office2007ScrollBarColorTable csb = m_AppStyleScrollBar ? m_ColorTable.AppScrollBar : m_ColorTable.ScrollBar;
|
||||
if (state == eScrollBarState.Normal)
|
||||
return csb.Default;
|
||||
else if (state == eScrollBarState.Disabled)
|
||||
return csb.Disabled;
|
||||
else if (state == eScrollBarState.ControlMouseOver)
|
||||
return csb.MouseOverControl;
|
||||
else if (state == eScrollBarState.PartMouseOver)
|
||||
return csb.MouseOver;
|
||||
else if (state == eScrollBarState.Pressed)
|
||||
return csb.Pressed;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void PaintTrackHorizontal(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, eScrollBarState state)
|
||||
{
|
||||
Office2007ScrollBarStateColorTable ct = GetColorTable(state);
|
||||
if (ct == null) return;
|
||||
|
||||
// Apply Colors...
|
||||
m_TrackOuterBorder.Apply(ct.TrackOuterBorder);
|
||||
m_TrackInnerBorder.Apply(ct.TrackInnerBorder);
|
||||
m_TrackInnerFill.BackgroundColorBlend = ct.TrackBackground;
|
||||
m_TrackInnerFill.GradientAngle = 90;
|
||||
|
||||
m_TrackShape.Paint(new Presentation.ShapePaintInfo(g, bounds));
|
||||
|
||||
if (bounds.Width > Dpi.Width10 && !ct.TrackSignBackground.Start.IsEmpty)
|
||||
{
|
||||
Rectangle r = new Rectangle(bounds.X + (bounds.Width - Dpi.Width7) / 2, bounds.Y + (bounds.Height - Dpi.Height8) / 2, Dpi.Width8, Dpi.Height8);
|
||||
Pen penDark = new Pen(ct.TrackSignBackground.Start, Dpi.Width1);
|
||||
Pen penLight = null;
|
||||
if (!ct.TrackSignBackground.End.IsEmpty) penLight = new Pen(ct.TrackSignBackground.End, Dpi.Width1);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
g.DrawLine(penDark, r.X, r.Y, r.X, r.Bottom);
|
||||
r.X+=Dpi.Width1;
|
||||
if (penLight != null)
|
||||
g.DrawLine(penLight, r.X, r.Y, r.X, r.Bottom);
|
||||
r.X += Dpi.Width1;
|
||||
}
|
||||
if (penDark != null) penDark.Dispose();
|
||||
if (penLight != null) penLight.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public override void PaintTrackVertical(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, eScrollBarState state)
|
||||
{
|
||||
Office2007ScrollBarStateColorTable ct = GetColorTable(state);
|
||||
if (ct == null) return;
|
||||
|
||||
// Apply Colors...
|
||||
m_TrackOuterBorder.Apply(ct.TrackOuterBorder);
|
||||
m_TrackInnerBorder.Apply(ct.TrackInnerBorder);
|
||||
m_TrackInnerFill.BackgroundColorBlend = ct.TrackBackground;
|
||||
m_TrackInnerFill.GradientAngle = 0;
|
||||
|
||||
m_TrackShape.Paint(new Presentation.ShapePaintInfo(g, bounds));
|
||||
|
||||
if (bounds.Height > Dpi.Height10 && !ct.TrackSignBackground.Start.IsEmpty)
|
||||
{
|
||||
Rectangle r = new Rectangle(bounds.X + (bounds.Width - Dpi.Width8) / 2, bounds.Y + (bounds.Height - Dpi.Height6) / 2, Dpi.Width8, Dpi.Height8);
|
||||
Pen penDark = new Pen(ct.TrackSignBackground.Start, Dpi.Width1);
|
||||
Pen penLight = null;
|
||||
if (!ct.TrackSignBackground.End.IsEmpty) penLight = new Pen(ct.TrackSignBackground.End, Dpi.Width1);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
g.DrawLine(penDark, r.X, r.Y, r.Right, r.Y);
|
||||
r.Y+=Dpi.Height1;
|
||||
if (penLight != null)
|
||||
g.DrawLine(penLight, r.X, r.Y, r.Right, r.Y);
|
||||
r.Y += Dpi.Height1;
|
||||
}
|
||||
if (penDark != null) penDark.Dispose();
|
||||
if (penLight != null) penLight.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public override void PaintBackground(Graphics g, Rectangle bounds, eScrollBarState state, bool horizontal, bool sideBorderOnly, bool rtl)
|
||||
{
|
||||
Office2007ScrollBarStateColorTable ct = GetColorTable(state);
|
||||
if (ct == null) return;
|
||||
|
||||
// Apply Colors...
|
||||
if (sideBorderOnly)
|
||||
m_BackgroundBorder.Apply(null);
|
||||
else
|
||||
m_BackgroundBorder.Apply(ct.Border);
|
||||
|
||||
m_BackgroundFill.Apply(ct.Background);
|
||||
m_BackgroundFill.GradientAngle = horizontal ? 90 : 0;
|
||||
|
||||
m_BackgroundShape.Paint(new Presentation.ShapePaintInfo(g, bounds));
|
||||
if (sideBorderOnly && !ct.Border.Start.IsEmpty)
|
||||
{
|
||||
if (horizontal)
|
||||
DisplayHelp.DrawLine(g, bounds.X, bounds.Y, bounds.Right, bounds.Y, ct.Border.Start, 1);
|
||||
else
|
||||
{
|
||||
if (rtl)
|
||||
DisplayHelp.DrawLine(g, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom, ct.Border.Start, 1);
|
||||
else
|
||||
DisplayHelp.DrawLine(g, 0, bounds.Y, 0, bounds.Bottom, ct.Border.Start, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Presentation.Shape GetBackgroundShape()
|
||||
{
|
||||
Presentation.Rectangle b = new Presentation.Rectangle();
|
||||
b.Border = m_BackgroundBorder;
|
||||
b.Fill = m_BackgroundFill;
|
||||
b.Padding = new Presentation.PaddingInfo(1, 1, 1, 1);
|
||||
return b;
|
||||
}
|
||||
|
||||
private Presentation.Shape GetThumbShape()
|
||||
{
|
||||
Presentation.Rectangle thumb = new Presentation.Rectangle();
|
||||
thumb.Border = m_ThumbOuterBorder;
|
||||
thumb.Padding = new Presentation.PaddingInfo(1, 1, 1, 1);
|
||||
Presentation.Rectangle innerRect = new Presentation.Rectangle();
|
||||
innerRect.Padding = new Presentation.PaddingInfo(1, 1, 1, 1);
|
||||
innerRect.Border = m_ThumbInnerBorder;
|
||||
innerRect.Fill = m_ThumbInnerFill;
|
||||
thumb.Children.Add(innerRect);
|
||||
|
||||
|
||||
m_ThumbSignShape = new Presentation.ShapePath();
|
||||
m_ThumbSignShape.Fill = m_ThumbSignFill;
|
||||
innerRect.Children.Add(m_ThumbSignShape);
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
private Presentation.Shape GetTrackShape()
|
||||
{
|
||||
Presentation.Rectangle thumb = new Presentation.Rectangle();
|
||||
thumb.CornerType = eCornerType.Rounded;
|
||||
thumb.CornerSize = 1;
|
||||
thumb.Border = m_TrackOuterBorder;
|
||||
thumb.Padding = new Presentation.PaddingInfo(1, 1, 1, 1);
|
||||
Presentation.Rectangle innerRect = new Presentation.Rectangle();
|
||||
innerRect.Padding = new Presentation.PaddingInfo(1, 1, 1, 1);
|
||||
innerRect.Border = m_TrackInnerBorder;
|
||||
innerRect.Fill = m_TrackInnerFill;
|
||||
thumb.Children.Add(innerRect);
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
private GraphicsPath GetThumbSignPath(eScrollThumbPosition pos)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
Size signSize = Dpi.Size(m_ThumbSignSize);
|
||||
|
||||
if (pos == eScrollThumbPosition.Left || pos == eScrollThumbPosition.Right)
|
||||
{
|
||||
int w = signSize.Width;
|
||||
signSize.Width = signSize.Height;
|
||||
signSize.Height = w;
|
||||
}
|
||||
|
||||
if (pos == eScrollThumbPosition.Top)
|
||||
{
|
||||
path.AddPolygon(new PointF[] {new PointF(-1, signSize.Height),
|
||||
new PointF(signSize.Width / 2 , -1),
|
||||
new PointF(signSize.Width / 2, -1), new PointF(signSize.Width, signSize.Height),
|
||||
new PointF(signSize.Width, signSize.Height), new PointF(-1, signSize.Height)});
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
else if (pos == eScrollThumbPosition.Bottom)
|
||||
{
|
||||
path.AddLine(signSize.Width / 2, signSize.Height + 1, signSize.Width, 1);
|
||||
path.AddLine(signSize.Width, 1, 0, 1);
|
||||
path.AddLine(0, 1, signSize.Width / 2, signSize.Height + 1);
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
else if (pos == eScrollThumbPosition.Left)
|
||||
{
|
||||
//signSize.Width++;
|
||||
signSize.Height++;
|
||||
int h2 = (int)(signSize.Height / 2);
|
||||
path.AddLine(0, h2, signSize.Width, 0);
|
||||
path.AddLine(signSize.Width, 0, signSize.Width, signSize.Height);
|
||||
path.AddLine(signSize.Width, signSize.Height, 0, h2);
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
else if (pos == eScrollThumbPosition.Right)
|
||||
{
|
||||
signSize.Height++;
|
||||
path.AddLine(signSize.Width, signSize.Height / 2, 0, 0);
|
||||
path.AddLine(0, 0, 0, signSize.Height);
|
||||
path.AddLine(0, signSize.Height, signSize.Width, signSize.Height / 2);
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public bool AppStyleScrollBar
|
||||
{
|
||||
get { return m_AppStyleScrollBar; }
|
||||
set { m_AppStyleScrollBar = value; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
780
PROMS/DotNetBar Source Code/ScrollBar/ScrollBarAdv.cs
Normal file
780
PROMS/DotNetBar Source Code/ScrollBar/ScrollBarAdv.cs
Normal file
@@ -0,0 +1,780 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
using DevComponents.DotNetBar.ScrollBar;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
[ToolboxItem(false), DefaultEvent("Scroll"), DefaultProperty("Value")]
|
||||
public abstract class ScrollBarAdv : Control, ICommandSource
|
||||
{
|
||||
#region Private Variables
|
||||
private ScrollBarCore _ScrollBar = null;
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// Occurs when the Value property is changed, either by a Scroll event or programmatically.
|
||||
/// </summary>
|
||||
public event EventHandler ValueChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the scroll box has been moved by either a mouse or keyboard action.
|
||||
/// </summary>
|
||||
public event ScrollEventHandler Scroll;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ScrollBarAdv class.
|
||||
/// </summary>
|
||||
public ScrollBarAdv()
|
||||
{
|
||||
this.TabStop = false;
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
this.SetStyle(ControlStyles.Opaque, true);
|
||||
this.SetStyle(ControlStyles.ResizeRedraw, true);
|
||||
this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
|
||||
this.SetStyle(ControlStyles.SupportsTransparentBackColor, false);
|
||||
this.SetStyle(ControlStyles.ContainerControl, false);
|
||||
this.SetStyle(ControlStyles.Selectable, true);
|
||||
CreateScrollBarCore();
|
||||
StyleManager.Register(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Called by StyleManager to notify control that style on manager has changed and that control should refresh its appearance if
|
||||
/// its style is controlled by StyleManager.
|
||||
/// </summary>
|
||||
/// <param name="newStyle">New active style.</param>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void StyleManagerStyleChanged(eDotNetBarStyle newStyle)
|
||||
{
|
||||
if (_ScrollBar != null)
|
||||
_ScrollBar.InvalidateScrollBar();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (_ScrollBar != null)
|
||||
{
|
||||
_ScrollBar.ValueChanged -= new EventHandler(CoreValueChanged);
|
||||
_ScrollBar.Scroll -= new ScrollEventHandler(CoreScroll);
|
||||
_ScrollBar.Dispose();
|
||||
_ScrollBar = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
|
||||
{
|
||||
UpdateScaling(factor);
|
||||
base.ScaleControl(factor, specified);
|
||||
}
|
||||
|
||||
internal void UpdateScaling(SizeF factor)
|
||||
{
|
||||
if (Dpi.RecordScalePerControl)
|
||||
Dpi.SetScaling(factor);
|
||||
_ScrollBar.ScaleItem(factor);
|
||||
}
|
||||
|
||||
protected override void OnEnabledChanged(EventArgs e)
|
||||
{
|
||||
_ScrollBar.Enabled = this.Enabled;
|
||||
this.Refresh();
|
||||
base.OnEnabledChanged(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether scrollbar is vertical.
|
||||
/// </summary>
|
||||
/// <returns>true if scrollbar is vertical otherwise false for horizontal scrollbar</returns>
|
||||
protected abstract bool IsVertical();
|
||||
|
||||
private void CreateScrollBarCore()
|
||||
{
|
||||
_ScrollBar = new ScrollBarCore(this, false);
|
||||
_ScrollBar.Orientation = IsVertical() ? eOrientation.Vertical : eOrientation.Horizontal;
|
||||
_ScrollBar.LargeChange = _LargeChange;
|
||||
_ScrollBar.Maximum = _Maximum;
|
||||
_ScrollBar.Minimum = _Minimum;
|
||||
_ScrollBar.SmallChange = this.SmallChange;
|
||||
_ScrollBar.Value = _Value;
|
||||
_ScrollBar.ValueChanged += new EventHandler(CoreValueChanged);
|
||||
_ScrollBar.Scroll += new ScrollEventHandler(CoreScroll);
|
||||
}
|
||||
|
||||
private void CoreScroll(object sender, ScrollEventArgs e)
|
||||
{
|
||||
OnScroll(e);
|
||||
}
|
||||
|
||||
private void CoreValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
OnValueChanged(e);
|
||||
ExecuteCommand();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
if (_ScrollBar != null)
|
||||
{
|
||||
_ScrollBar.Paint(GetItemPaintArgs(e));
|
||||
}
|
||||
base.OnPaint(e);
|
||||
}
|
||||
|
||||
private ItemPaintArgs GetItemPaintArgs(PaintEventArgs e)
|
||||
{
|
||||
ItemPaintArgs p = new ItemPaintArgs(null, this, e.Graphics, null);
|
||||
return p;
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
if (_ScrollBar != null) _ScrollBar.MouseMove(e);
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
if (this.TabStop && !this.Focused)
|
||||
{
|
||||
this.Select();
|
||||
}
|
||||
if (_ScrollBar != null) _ScrollBar.MouseDown(e);
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnEnter(EventArgs e)
|
||||
{
|
||||
if (_ScrollBar != null) _ScrollBar.InvalidateScrollBar();
|
||||
base.OnEnter(e);
|
||||
}
|
||||
|
||||
protected override void OnLeave(EventArgs e)
|
||||
{
|
||||
if (_ScrollBar != null) _ScrollBar.InvalidateScrollBar();
|
||||
base.OnLeave(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
if (_ScrollBar != null) _ScrollBar.MouseUp(e);
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
if (_ScrollBar != null) _ScrollBar.MouseLeave();
|
||||
base.OnMouseLeave(e);
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
if (_ScrollBar != null) _ScrollBar.DisplayRectangle = new System.Drawing.Rectangle(0, 0, this.Width, this.Height);
|
||||
base.OnResize(e);
|
||||
}
|
||||
|
||||
private int _LargeChange = 10;
|
||||
/// <summary>
|
||||
/// Gets or sets a value to be added to or subtracted from the <paramref name="Value">Value</paramref> property when the scroll box is moved a large distance.
|
||||
/// <value>A numeric value. The default value is 10.</value>
|
||||
/// <remarks>ArgumentOutOfRangeException is raised if assigned value is less than 0. </remarks>
|
||||
/// </summary>
|
||||
[DefaultValue(10), Category("Behavior"), Description("Indicates value to be added to or subtracted from the Value property when the scroll box is moved a large distance")]
|
||||
public int LargeChange
|
||||
{
|
||||
get { return _LargeChange; }
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
||||
if (_LargeChange != value)
|
||||
{
|
||||
_LargeChange = value;
|
||||
if (_ScrollBar != null) _ScrollBar.LargeChange = _LargeChange;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _Maximum = 100;
|
||||
/// <summary>
|
||||
/// Gets or sets the upper limit of values of the scrollable range.
|
||||
/// <value>A numeric value. The default value is 100.</value>
|
||||
/// </summary>
|
||||
[DefaultValue(100), Category("Behavior"), Description("Indicates upper limit of values of the scrollable range."), RefreshProperties(RefreshProperties.Repaint)]
|
||||
public int Maximum
|
||||
{
|
||||
get { return _Maximum; }
|
||||
set
|
||||
{
|
||||
if (_Maximum != value)
|
||||
{
|
||||
_Maximum = value;
|
||||
if (_ScrollBar != null) _ScrollBar.Maximum = _Maximum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _Minimum = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the lower limit of values of the scrollable range.
|
||||
/// <value>A numeric value. The default value is 0.</value>
|
||||
/// </summary>
|
||||
[DefaultValue(0), Category("Behavior"), Description("Indicates lower limit of values of the scrollable range."), RefreshProperties(RefreshProperties.Repaint)]
|
||||
public int Minimum
|
||||
{
|
||||
get { return _Minimum; }
|
||||
set
|
||||
{
|
||||
if (_Minimum != value)
|
||||
{
|
||||
_Minimum = value;
|
||||
if (_ScrollBar != null) _ScrollBar.Minimum = _Minimum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _SmallChange = 1;
|
||||
/// <summary>
|
||||
/// Gets or sets the value to be added to or subtracted from the <paramref name="Value">Value</paramref> property when the scroll box is moved a small distance.
|
||||
/// <value>A numeric value. The default value is 1.</value>
|
||||
/// <remarks>ArgumentOutOfRangeException is raised if assigned value is less than 0. </remarks>
|
||||
/// </summary>
|
||||
[DefaultValue(1), Category("Behavior"), Description("Indicates value to be added to or subtracted from the Value property when the scroll box is moved a small distance.")]
|
||||
public int SmallChange
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Min(_SmallChange, _LargeChange);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
||||
if (_SmallChange != value)
|
||||
{
|
||||
_SmallChange = value;
|
||||
|
||||
if (_ScrollBar != null)
|
||||
_ScrollBar.SmallChange = this.SmallChange;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _Value = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets a numeric value that represents the current position of the scroll box on the scroll bar control.
|
||||
/// <value>A numeric value that is within the Minimum and Maximum range. The default value is 0.</value>
|
||||
/// <remarks>ArgumentOutOfRangeException is raised if assigned value is less than the Minimum property value or assigned value is greater than the Maximum property value.</remarks>
|
||||
/// </summary>
|
||||
[DefaultValue(0), Category("Behavior"), Description("Indicates numeric value that represents the current position of the scroll box on the scroll bar control"), RefreshProperties(RefreshProperties.Repaint)]
|
||||
public int Value
|
||||
{
|
||||
get { if (_ScrollBar != null) return _ScrollBar.Value; else return 0; }
|
||||
set
|
||||
{
|
||||
if (value < Minimum)
|
||||
throw new ArgumentOutOfRangeException("Value must be greater or equal than Minimum property value.");
|
||||
if(value>Maximum)
|
||||
throw new ArgumentOutOfRangeException("Value must be less or equal than Maximum property value.");
|
||||
if (_ScrollBar != null) _ScrollBar.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal void DoScroll(int newValue, ScrollEventType eventType)
|
||||
{
|
||||
int oldValue = this.Value;
|
||||
this.Value = newValue;
|
||||
#if FRAMEWORK20
|
||||
OnScroll(new ScrollEventArgs(eventType, oldValue, newValue, _ScrollBar.Orientation == eOrientation.Vertical ? ScrollOrientation.VerticalScroll : ScrollOrientation.HorizontalScroll));
|
||||
#else
|
||||
OnScroll(new ScrollEventArgs(eventType, newValue));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the Scroll event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides Event arguments.</param>
|
||||
protected virtual void OnScroll(ScrollEventArgs e)
|
||||
{
|
||||
ScrollEventHandler h = this.Scroll;
|
||||
if (h != null)
|
||||
h(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the ValueChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides Event arguments.</param>
|
||||
protected virtual void OnValueChanged(EventArgs e)
|
||||
{
|
||||
EventHandler h = this.ValueChanged;
|
||||
if (h != null)
|
||||
h(this, e);
|
||||
}
|
||||
|
||||
private eScrollBarAppearance _Appearance = eScrollBarAppearance.Default;
|
||||
/// <summary>
|
||||
/// Gets or sets the scroll bar appearance style.
|
||||
/// </summary>
|
||||
[DefaultValue(eScrollBarAppearance.Default), Category("Appearance"), Description("Indicates scroll bar appearance style."), RefreshProperties(RefreshProperties.Repaint)]
|
||||
public eScrollBarAppearance Appearance
|
||||
{
|
||||
get { return _Appearance; }
|
||||
set
|
||||
{
|
||||
if (_Appearance != value)
|
||||
{
|
||||
_Appearance = value;
|
||||
OnAppearanceChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAppearanceChanged()
|
||||
{
|
||||
if (_ScrollBar != null)
|
||||
{
|
||||
if (_Appearance == eScrollBarAppearance.Default)
|
||||
_ScrollBar.IsAppScrollBarStyle = false;
|
||||
else
|
||||
_ScrollBar.IsAppScrollBarStyle = true;
|
||||
}
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
if (_ScrollBar!=null)
|
||||
return _ScrollBar.ProcessCmdKey(ref msg, keyData);
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Property Hiding
|
||||
#if FRAMEWORK20
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public override bool AutoSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.AutoSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.AutoSize = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public new event EventHandler AutoSizeChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
base.AutoSizeChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.AutoSizeChanged -= value;
|
||||
}
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event MouseEventHandler MouseClick
|
||||
{
|
||||
add
|
||||
{
|
||||
base.MouseClick += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.MouseClick -= value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public new event MouseEventHandler MouseDoubleClick
|
||||
{
|
||||
add
|
||||
{
|
||||
base.MouseDoubleClick += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.MouseDoubleClick -= value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override Color BackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.BackColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.BackColor = value;
|
||||
}
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event EventHandler BackColorChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
base.BackColorChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.BackColorChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public override Image BackgroundImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.BackgroundImage;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.BackgroundImage = value;
|
||||
}
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event EventHandler BackgroundImageChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
base.BackgroundImageChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.BackgroundImageChanged -= value;
|
||||
}
|
||||
}
|
||||
#if FRAMEWORK20
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override ImageLayout BackgroundImageLayout
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.BackgroundImageLayout;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.BackgroundImageLayout = value;
|
||||
}
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event EventHandler BackgroundImageLayoutChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
base.BackgroundImageLayoutChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.BackgroundImageLayoutChanged -= value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
}
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new ImeMode ImeMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImeMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImeMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
public new bool TabStop
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.TabStop;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.TabStop = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Bindable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event EventHandler Click
|
||||
{
|
||||
add
|
||||
{
|
||||
base.Click += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.Click -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public new event EventHandler DoubleClick
|
||||
{
|
||||
add
|
||||
{
|
||||
base.DoubleClick += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.DoubleClick -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public new event EventHandler FontChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
base.FontChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.FontChanged -= value;
|
||||
}
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event EventHandler ForeColorChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
base.ForeColorChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.ForeColorChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public new event EventHandler ImeModeChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
base.ImeModeChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.ImeModeChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event MouseEventHandler MouseDown
|
||||
{
|
||||
add
|
||||
{
|
||||
base.MouseDown += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.MouseDown -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event MouseEventHandler MouseMove
|
||||
{
|
||||
add
|
||||
{
|
||||
base.MouseMove += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.MouseMove -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event MouseEventHandler MouseUp
|
||||
{
|
||||
add
|
||||
{
|
||||
base.MouseUp += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.MouseUp -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public new event PaintEventHandler Paint
|
||||
{
|
||||
add
|
||||
{
|
||||
base.Paint += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.Paint -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public new event EventHandler TextChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
base.TextChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.TextChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override RightToLeft RightToLeft
|
||||
{
|
||||
get
|
||||
{
|
||||
return RightToLeft.No;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
|
||||
public event EventHandler RightToLeftChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
base.RightToLeftChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
base.RightToLeftChanged -= value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICommandSource Members
|
||||
protected virtual void ExecuteCommand()
|
||||
{
|
||||
if (_Command == null) return;
|
||||
CommandManager.ExecuteCommand(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the command assigned to the item. Default value is null.
|
||||
/// <remarks>Note that if this property is set to null Enabled property will be set to false automatically to disable the item.</remarks>
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Commands"), Description("Indicates the command assigned to the item.")]
|
||||
public Command Command
|
||||
{
|
||||
get { return (Command)((ICommandSource)this).Command; }
|
||||
set
|
||||
{
|
||||
((ICommandSource)this).Command = value;
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _Command = null;
|
||||
//[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
ICommand ICommandSource.Command
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Command;
|
||||
}
|
||||
set
|
||||
{
|
||||
bool changed = false;
|
||||
if (_Command != value)
|
||||
changed = true;
|
||||
|
||||
if (_Command != null)
|
||||
CommandManager.UnRegisterCommandSource(this, _Command);
|
||||
_Command = value;
|
||||
if (value != null)
|
||||
CommandManager.RegisterCommand(this, value);
|
||||
if (changed)
|
||||
OnCommandChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when Command property value changes.
|
||||
/// </summary>
|
||||
protected virtual void OnCommandChanged()
|
||||
{
|
||||
}
|
||||
|
||||
private object _CommandParameter = null;
|
||||
/// <summary>
|
||||
/// Gets or sets user defined data value that can be passed to the command when it is executed.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(null), Category("Commands"), Description("Indicates user defined data value that can be passed to the command when it is executed."), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)), System.ComponentModel.Localizable(true)]
|
||||
public object CommandParameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CommandParameter;
|
||||
}
|
||||
set
|
||||
{
|
||||
_CommandParameter = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
802
PROMS/DotNetBar Source Code/ScrollBar/ScrollBarCore.cs
Normal file
802
PROMS/DotNetBar Source Code/ScrollBar/ScrollBarCore.cs
Normal file
@@ -0,0 +1,802 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.ScrollBar
|
||||
{
|
||||
public class ScrollBarCore : IDisposable
|
||||
{
|
||||
#region Private Variables
|
||||
private Rectangle m_DisplayRectangle = Rectangle.Empty;
|
||||
private eOrientation m_Orientation = eOrientation.Vertical;
|
||||
|
||||
// Default thumb sizes...
|
||||
private Size m_VThumbSize = new Size(Dpi.Width15, Dpi.Height17);
|
||||
private Size m_HThumbSize = new Size(Dpi.Width17, Dpi.Height15);
|
||||
private Rectangle m_ThumbDecrease = Rectangle.Empty;
|
||||
private Rectangle m_ThumbIncrease = Rectangle.Empty;
|
||||
private Rectangle m_Track = Rectangle.Empty;
|
||||
private eScrollPart m_MouseOverPart = eScrollPart.None;
|
||||
|
||||
private Control m_ParentControl = null;
|
||||
private bool m_MouseDown = false;
|
||||
private Timer m_ClickTimer = null;
|
||||
private int m_MouseDownTrackOffset = 0;
|
||||
private Bitmap m_CashedView = null;
|
||||
private bool m_ViewExpired = true;
|
||||
private bool m_PassiveScrollBar = false;
|
||||
private bool m_IsAppScrollBarStyle = false;
|
||||
public event EventHandler ValueChanged;
|
||||
private bool m_IsScrollBarParent = false;
|
||||
private bool m_IsAdvScrollBar = false;
|
||||
private int m_AutoClickCount = 0;
|
||||
public event ScrollEventHandler Scroll;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public ScrollBarCore() : this(null) { }
|
||||
|
||||
public ScrollBarCore(Control parentControl) : this(parentControl, false) { }
|
||||
|
||||
public ScrollBarCore(Control parentControl, bool isPassive)
|
||||
{
|
||||
m_ParentControl = parentControl;
|
||||
m_IsScrollBarParent = m_ParentControl is System.Windows.Forms.ScrollBar || m_ParentControl is ScrollBarAdv;
|
||||
m_IsAdvScrollBar = m_ParentControl is ScrollBarAdv;
|
||||
m_PassiveScrollBar = isPassive;
|
||||
DisposeCashedView();
|
||||
}
|
||||
|
||||
internal void DisposeCashedView()
|
||||
{
|
||||
if (m_CashedView != null)
|
||||
{
|
||||
m_CashedView.Dispose();
|
||||
m_CashedView = null;
|
||||
}
|
||||
}
|
||||
|
||||
private ScrollBarPainter GetScrollBarPainter()
|
||||
{
|
||||
ScrollBarPainter scp = null;
|
||||
if (StyleManager.IsMetro(StyleManager.Style))
|
||||
{
|
||||
DevComponents.DotNetBar.Metro.Rendering.MetroScrollBarPainter painter = new DevComponents.DotNetBar.Metro.Rendering.MetroScrollBarPainter();
|
||||
painter.ColorTable = ((Rendering.Office2007Renderer)Rendering.GlobalManager.Renderer).ColorTable;
|
||||
painter.AppStyleScrollBar = m_IsAppScrollBarStyle;
|
||||
scp = painter;
|
||||
}
|
||||
else
|
||||
{
|
||||
Office2007ScrollBarPainter painter = new Office2007ScrollBarPainter();
|
||||
painter.ColorTable = ((Rendering.Office2007Renderer)Rendering.GlobalManager.Renderer).ColorTable;
|
||||
painter.AppStyleScrollBar = m_IsAppScrollBarStyle;
|
||||
scp = painter;
|
||||
}
|
||||
return scp;
|
||||
}
|
||||
|
||||
private bool _IsPainting = false;
|
||||
public void Paint(ItemPaintArgs p)
|
||||
{
|
||||
if (_IsPainting) return;
|
||||
|
||||
_IsPainting = true;
|
||||
try
|
||||
{
|
||||
if (m_DisplayRectangle.IsEmpty || m_DisplayRectangle.Width <= 0 || m_DisplayRectangle.Height <= 0 || p.Graphics == null) return;
|
||||
|
||||
ScrollBarPainter painter = GetScrollBarPainter();
|
||||
|
||||
if (m_CashedView == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_CashedView = new Bitmap(m_DisplayRectangle.Width, m_DisplayRectangle.Height, p.Graphics);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_CashedView.MakeTransparent();
|
||||
m_ViewExpired = true;
|
||||
}
|
||||
|
||||
if (!m_ViewExpired)
|
||||
{
|
||||
Bitmap cachedView = m_CashedView;
|
||||
if (cachedView != null)
|
||||
p.Graphics.DrawImageUnscaled(cachedView, m_DisplayRectangle.Location);
|
||||
return;
|
||||
}
|
||||
|
||||
using (Graphics g = Graphics.FromImage(m_CashedView))
|
||||
{
|
||||
if (!m_DisplayRectangle.Location.IsEmpty)
|
||||
g.TranslateTransform(-m_DisplayRectangle.X, -m_DisplayRectangle.Y);
|
||||
eScrollBarState state = m_Enabled ? eScrollBarState.Normal : eScrollBarState.Disabled;
|
||||
if (m_Enabled && (m_MouseOverPart != eScrollPart.None || IsFocused)) state = eScrollBarState.ControlMouseOver;
|
||||
bool rtl = false;
|
||||
if (m_ParentControl != null) rtl = m_ParentControl.RightToLeft == RightToLeft.Yes;
|
||||
painter.PaintBackground(g, m_DisplayRectangle, state, m_Orientation == eOrientation.Horizontal, m_SideBorderOnly, rtl);
|
||||
|
||||
eScrollThumbPosition tp = eScrollThumbPosition.Top;
|
||||
if (m_Orientation == eOrientation.Horizontal) tp = eScrollThumbPosition.Left;
|
||||
if (m_MouseOverPart == eScrollPart.ThumbDecrease && m_Enabled)
|
||||
{
|
||||
if (m_MouseDown)
|
||||
state = eScrollBarState.Pressed;
|
||||
else
|
||||
state = eScrollBarState.PartMouseOver;
|
||||
}
|
||||
painter.PaintThumb(g, m_ThumbDecrease, tp, state);
|
||||
|
||||
tp = eScrollThumbPosition.Bottom;
|
||||
if (m_MouseOverPart == eScrollPart.ThumbIncrease && m_Enabled)
|
||||
{
|
||||
if (m_MouseDown)
|
||||
state = eScrollBarState.Pressed;
|
||||
else
|
||||
state = eScrollBarState.PartMouseOver;
|
||||
}
|
||||
else if (m_MouseOverPart != eScrollPart.None && m_Enabled)
|
||||
state = eScrollBarState.ControlMouseOver;
|
||||
|
||||
if (m_Orientation == eOrientation.Horizontal) tp = eScrollThumbPosition.Right;
|
||||
painter.PaintThumb(g, m_ThumbIncrease, tp, state);
|
||||
|
||||
if (m_MouseOverPart == eScrollPart.Track && m_Enabled)
|
||||
{
|
||||
if (m_MouseDown)
|
||||
state = eScrollBarState.Pressed;
|
||||
else
|
||||
state = eScrollBarState.PartMouseOver;
|
||||
}
|
||||
else if ((m_MouseOverPart != eScrollPart.None || this.IsFocused) && m_Enabled)
|
||||
state = eScrollBarState.ControlMouseOver;
|
||||
if (m_Orientation == eOrientation.Horizontal)
|
||||
painter.PaintTrackHorizontal(g, m_Track, state);
|
||||
else
|
||||
painter.PaintTrackVertical(g, m_Track, state);
|
||||
}
|
||||
|
||||
p.Graphics.DrawImageUnscaled(m_CashedView, m_DisplayRectangle.Location);
|
||||
m_ViewExpired = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_IsPainting = false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsFocused
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_IsAdvScrollBar && m_ParentControl.Focused)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void MouseMove(MouseEventArgs e)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
Point p = new Point(e.X, e.Y);
|
||||
if (m_MouseDown && m_MouseOverPart == eScrollPart.Track)
|
||||
{
|
||||
if (!m_PassiveScrollBar)
|
||||
{
|
||||
// Update Track position based on mouse position...
|
||||
int i = ValueFromMouseCoordinates(p);
|
||||
SetValue(i, ScrollEventType.ThumbTrack);
|
||||
//this.Value = i;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Button != MouseButtons.None && m_MouseOverPart!=eScrollPart.None) return;
|
||||
|
||||
if (m_DisplayRectangle.Contains(p))
|
||||
{
|
||||
eScrollPart part = eScrollPart.Control;
|
||||
if (m_ThumbDecrease.Contains(p))
|
||||
part = eScrollPart.ThumbDecrease;
|
||||
else if (m_ThumbIncrease.Contains(p))
|
||||
part = eScrollPart.ThumbIncrease;
|
||||
else if (m_Track.Contains(p))
|
||||
part = eScrollPart.Track;
|
||||
|
||||
if (m_MouseOverPart != part)
|
||||
{
|
||||
m_MouseOverPart = part;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
else if (m_MouseOverPart != eScrollPart.None)
|
||||
{
|
||||
m_MouseOverPart = eScrollPart.None;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private int ValueFromMouseCoordinates(Point p)
|
||||
{
|
||||
if (m_Orientation == eOrientation.Vertical)
|
||||
{
|
||||
int trackY = p.Y - m_MouseDownTrackOffset;
|
||||
trackY = Math.Max(trackY, m_ThumbDecrease.Bottom);
|
||||
trackY = Math.Min(trackY, m_ThumbIncrease.Y - GetTrackSize());
|
||||
trackY -= m_ThumbDecrease.Bottom;
|
||||
|
||||
int totalSize = GetAvailableTrackArea() - GetTrackSize();
|
||||
return (int)((this.GetMaximumValue() - this.Minimum) * ((float)trackY / (float)totalSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
int trackX = p.X - m_MouseDownTrackOffset;
|
||||
trackX = Math.Max(trackX, m_ThumbDecrease.Right);
|
||||
trackX = Math.Min(trackX, m_ThumbIncrease.X - GetTrackSize());
|
||||
trackX -= m_ThumbDecrease.Right;
|
||||
|
||||
int totalSize = GetAvailableTrackArea() - GetTrackSize();
|
||||
return (int)((this.GetMaximumValue() - this.Minimum) * ((float)trackX / (float)totalSize));
|
||||
}
|
||||
}
|
||||
|
||||
public void MouseLeave()
|
||||
{
|
||||
if (m_MouseOverPart != eScrollPart.None)
|
||||
{
|
||||
if (m_MouseDown && (m_MouseOverPart == eScrollPart.Track || m_MouseOverPart != eScrollPart.None && m_PassiveScrollBar))
|
||||
return;
|
||||
m_MouseOverPart = eScrollPart.None;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void MouseDown(MouseEventArgs e)
|
||||
{
|
||||
if (m_MouseOverPart != eScrollPart.None)
|
||||
{
|
||||
m_MouseDown = true;
|
||||
if (m_PassiveScrollBar)
|
||||
{
|
||||
m_ViewExpired = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_Orientation == eOrientation.Vertical)
|
||||
m_MouseDownTrackOffset = e.Y - m_Track.Y;
|
||||
else
|
||||
m_MouseDownTrackOffset = e.X - m_Track.X;
|
||||
|
||||
if (m_MouseOverPart == eScrollPart.ThumbDecrease)
|
||||
SetValue(this.Value - m_SmallChange, ScrollEventType.SmallDecrement);
|
||||
else if (m_MouseOverPart == eScrollPart.ThumbIncrease)
|
||||
SetValue(this.Value + m_SmallChange, ScrollEventType.SmallIncrement);
|
||||
else if (m_MouseOverPart == eScrollPart.Track)
|
||||
{
|
||||
this.Invalidate();
|
||||
if (m_ParentControl != null)
|
||||
m_ParentControl.Capture = true;
|
||||
}
|
||||
else if (m_MouseOverPart == eScrollPart.Control)
|
||||
{
|
||||
MousePageDown(new Point(e.X, e.Y));
|
||||
}
|
||||
|
||||
SetupClickTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private void MousePageDown(Point p)
|
||||
{
|
||||
if (m_Orientation == eOrientation.Vertical && (p.Y<m_Track.Y || p.Y>m_Track.Bottom) ||
|
||||
m_Orientation == eOrientation.Horizontal && (p.X<m_Track.X || p.X>m_Track.Right))
|
||||
{
|
||||
if (m_Orientation == eOrientation.Vertical && m_Track.Y > p.Y || m_Orientation == eOrientation.Horizontal && m_Track.X > p.X)
|
||||
SetValue(this.Value - this.LargeChange, ScrollEventType.LargeDecrement);
|
||||
else
|
||||
{
|
||||
if (m_IsScrollBarParent)
|
||||
{
|
||||
if (this.Value + this.LargeChange > this.GetMaximumValue())
|
||||
{
|
||||
SetValue(this.GetMaximumValue(), ScrollEventType.LargeIncrement);
|
||||
}
|
||||
else
|
||||
SetValue(this.Value + this.LargeChange, ScrollEventType.LargeIncrement);
|
||||
}
|
||||
else
|
||||
SetValue(this.Value + this.LargeChange, ScrollEventType.LargeIncrement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMouseDown
|
||||
{
|
||||
get { return m_MouseDown; }
|
||||
}
|
||||
|
||||
public void MouseUp(MouseEventArgs e)
|
||||
{
|
||||
if (m_ParentControl != null && m_ParentControl.Capture)
|
||||
m_ParentControl.Capture = false;
|
||||
|
||||
if(m_MouseDown)
|
||||
{
|
||||
if (m_MouseOverPart != eScrollPart.None && _RaiseEndScroll)
|
||||
{
|
||||
#if FRAMEWORK20
|
||||
if(m_MouseOverPart == eScrollPart.Track)
|
||||
OnScroll(new ScrollEventArgs(ScrollEventType.ThumbPosition, this.Value, this.Value, this.ScrollOrientation));
|
||||
OnScroll(new ScrollEventArgs(ScrollEventType.EndScroll, this.Value, this.Value, this.ScrollOrientation));
|
||||
#else
|
||||
if(m_MouseOverPart == eScrollPart.Track)
|
||||
OnScroll(new ScrollEventArgs(ScrollEventType.ThumbPosition, this.Value));
|
||||
OnScroll(new ScrollEventArgs(ScrollEventType.EndScroll, this.Value));
|
||||
#endif
|
||||
_RaiseEndScroll = false;
|
||||
}
|
||||
DisposeTimer();
|
||||
m_MouseDown = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
if (!this.DisplayRectangle.Contains(e.X, e.Y))
|
||||
MouseLeave();
|
||||
}
|
||||
|
||||
private ScrollOrientation ScrollOrientation
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Orientation == eOrientation.Horizontal ? ScrollOrientation.HorizontalScroll : ScrollOrientation.VerticalScroll;
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeTimer()
|
||||
{
|
||||
Timer clickTimer = m_ClickTimer;
|
||||
m_ClickTimer = null;
|
||||
if (clickTimer != null)
|
||||
{
|
||||
clickTimer.Enabled = false;
|
||||
clickTimer.Tick -= new EventHandler(ClickTimer_Tick);
|
||||
clickTimer.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupClickTimer()
|
||||
{
|
||||
if (m_ClickTimer != null) return;
|
||||
m_AutoClickCount = 0;
|
||||
m_ClickTimer = new Timer();
|
||||
m_ClickTimer.Interval = 100;
|
||||
m_ClickTimer.Tick += new EventHandler(ClickTimer_Tick);
|
||||
m_ClickTimer.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClickTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
Control parentControl = m_ParentControl;
|
||||
if (m_MouseDown && m_MouseOverPart == eScrollPart.ThumbDecrease)
|
||||
{
|
||||
SetValue(this.Value - m_SmallChange, ScrollEventType.SmallDecrement);
|
||||
}
|
||||
else if (m_MouseDown && m_MouseOverPart == eScrollPart.ThumbIncrease)
|
||||
{
|
||||
SetValue(this.Value + m_SmallChange, ScrollEventType.SmallIncrement);
|
||||
}
|
||||
else if (m_MouseDown && m_MouseOverPart == eScrollPart.Control && parentControl != null)
|
||||
{
|
||||
Point p = parentControl.PointToClient(Control.MousePosition);
|
||||
if (m_Track.Contains(p))
|
||||
{
|
||||
DisposeTimer();
|
||||
m_MouseDown = false;
|
||||
}
|
||||
else
|
||||
MousePageDown(p);
|
||||
}
|
||||
m_AutoClickCount++;
|
||||
if (m_AutoClickCount > 4 && m_ClickTimer != null && m_ClickTimer.Interval > 20)
|
||||
{
|
||||
m_ClickTimer.Interval -= 10;
|
||||
}
|
||||
}
|
||||
|
||||
private void Invalidate()
|
||||
{
|
||||
m_ViewExpired = true;
|
||||
Control parentControl = m_ParentControl;
|
||||
if (parentControl != null && !m_PassiveScrollBar)
|
||||
{
|
||||
parentControl.Invalidate(m_DisplayRectangle);
|
||||
parentControl.Update();
|
||||
}
|
||||
}
|
||||
|
||||
private bool m_HasBorder = true;
|
||||
internal bool HasBorder
|
||||
{
|
||||
get { return m_HasBorder; }
|
||||
set { m_HasBorder = value; }
|
||||
}
|
||||
|
||||
private bool m_SideBorderOnly = false;
|
||||
internal bool SideBorderOnly
|
||||
{
|
||||
get { return m_SideBorderOnly; }
|
||||
set { m_SideBorderOnly = value; }
|
||||
}
|
||||
|
||||
private void UpdateLayout()
|
||||
{
|
||||
if (m_PassiveScrollBar)
|
||||
return;
|
||||
|
||||
Rectangle r = m_DisplayRectangle;
|
||||
if(m_HasBorder)
|
||||
r.Inflate(-1, -1);
|
||||
|
||||
if (m_Orientation == eOrientation.Vertical)
|
||||
{
|
||||
m_ThumbDecrease = new Rectangle(r.X, r.Y, r.Width, m_VThumbSize.Height);
|
||||
m_ThumbIncrease = new Rectangle(r.X, r.Bottom - m_VThumbSize.Height, r.Width, m_VThumbSize.Height);
|
||||
int i = GetTrackSize();
|
||||
m_Track = new Rectangle(r.X, r.Y + GetTrackPosition(), r.Width, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ThumbDecrease = new Rectangle(r.X, r.Y, m_HThumbSize.Width, r.Height);
|
||||
m_ThumbIncrease = new Rectangle(r.Right - m_HThumbSize.Width, r.Y, m_HThumbSize.Width, r.Height);
|
||||
int i = GetTrackSize();
|
||||
m_Track = new Rectangle(r.X + GetTrackPosition(), r.Y, i, r.Height);
|
||||
|
||||
}
|
||||
if(!(m_ParentControl is System.Windows.Forms.ScrollBar))
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
public virtual void ScaleItem(SizeF factor)
|
||||
{
|
||||
m_VThumbSize = new Size(Dpi.Width15, Dpi.Height17);
|
||||
m_HThumbSize = new Size(Dpi.Width17, Dpi.Height15);
|
||||
}
|
||||
|
||||
private int GetTrackSize()
|
||||
{
|
||||
int i = 0;
|
||||
int size = GetAvailableTrackArea();
|
||||
//Rectangle r = m_DisplayRectangle;
|
||||
//r.Inflate(-1, -1);
|
||||
|
||||
i = (int)(size * ((float)m_LargeChange / (float)(m_Maximum - m_Minimum + 1)));
|
||||
//i = (int)(size / ((float)m_Maximum / (float)m_LargeChange));
|
||||
//if (m_Orientation == eOrientation.Horizontal)
|
||||
//{
|
||||
// i = (int)(r.Width * ((float)m_LargeChange / (float)m_Maximum));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// i = (int)(r.Height * ((float)m_LargeChange / (float)m_Maximum));
|
||||
//}
|
||||
i = Math.Max(14, i);
|
||||
i = Math.Min(i, size);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private int GetAvailableTrackArea()
|
||||
{
|
||||
Rectangle r = m_DisplayRectangle;
|
||||
if(m_HasBorder)
|
||||
r.Inflate(-1, -1);
|
||||
|
||||
int size = r.Height;
|
||||
|
||||
if (m_Orientation == eOrientation.Horizontal)
|
||||
{
|
||||
size = r.Width - m_HThumbSize.Width * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
size -= m_VThumbSize.Height * 2;
|
||||
}
|
||||
|
||||
return Math.Max(size, 8);
|
||||
}
|
||||
|
||||
private int GetTrackPosition()
|
||||
{
|
||||
int trackSize = GetTrackSize();
|
||||
int totalSize = GetAvailableTrackArea() - trackSize;
|
||||
int i = Math.Min(totalSize, Math.Max((int)(totalSize * ((float)m_Value / (float)GetMaximumValue())), 0));
|
||||
if (m_Orientation == eOrientation.Vertical)
|
||||
i += m_VThumbSize.Height;
|
||||
else
|
||||
i += m_HThumbSize.Width;
|
||||
return i;
|
||||
}
|
||||
|
||||
public Rectangle ThumbDecreaseRectangle
|
||||
{
|
||||
get { return m_ThumbDecrease; }
|
||||
set
|
||||
{
|
||||
m_ThumbDecrease = value;
|
||||
DisposeCashedView();
|
||||
}
|
||||
}
|
||||
|
||||
public Rectangle ThumbIncreaseRectangle
|
||||
{
|
||||
get { return m_ThumbIncrease; }
|
||||
set
|
||||
{
|
||||
m_ThumbIncrease = value;
|
||||
DisposeCashedView();
|
||||
}
|
||||
}
|
||||
|
||||
public Rectangle TrackRectangle
|
||||
{
|
||||
get { return m_Track; }
|
||||
set
|
||||
{
|
||||
m_Track = value;
|
||||
DisposeCashedView();
|
||||
}
|
||||
}
|
||||
|
||||
public Rectangle DisplayRectangle
|
||||
{
|
||||
get { return m_DisplayRectangle; }
|
||||
set
|
||||
{
|
||||
m_DisplayRectangle = value;
|
||||
DisposeCashedView();
|
||||
UpdateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public eOrientation Orientation
|
||||
{
|
||||
get { return m_Orientation; }
|
||||
set
|
||||
{
|
||||
m_Orientation = value;
|
||||
DisposeCashedView();
|
||||
}
|
||||
}
|
||||
|
||||
private int m_Minimum = 0;
|
||||
public int Minimum
|
||||
{
|
||||
get { return m_Minimum; }
|
||||
set
|
||||
{
|
||||
m_Minimum = value;
|
||||
DisposeCashedView();
|
||||
UpdateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private int m_Maximum = 0;
|
||||
public int Maximum
|
||||
{
|
||||
get { return m_Maximum; }
|
||||
set
|
||||
{
|
||||
m_Maximum = value;
|
||||
DisposeCashedView();
|
||||
UpdateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private int m_SmallChange = 1;
|
||||
public int SmallChange
|
||||
{
|
||||
get { return m_SmallChange; }
|
||||
set { m_SmallChange = value; }
|
||||
}
|
||||
|
||||
private int m_LargeChange = 16;
|
||||
public int LargeChange
|
||||
{
|
||||
get { return m_LargeChange; }
|
||||
set
|
||||
{
|
||||
m_LargeChange = value;
|
||||
DisposeCashedView();
|
||||
UpdateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private int m_Value = 0;
|
||||
public int Value
|
||||
{
|
||||
get { return m_Value; }
|
||||
set
|
||||
{
|
||||
value = NormalizeValue(value);
|
||||
if (m_Value == value && (!m_IsScrollBarParent || m_IsAdvScrollBar)) return;
|
||||
|
||||
m_Value = value;
|
||||
if (m_PassiveScrollBar) return;
|
||||
DisposeCashedView();
|
||||
UpdateLayout();
|
||||
if (ValueChanged != null)
|
||||
ValueChanged(this, new EventArgs());
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private bool _RaiseEndScroll = false;
|
||||
private void SetValue(int value, ScrollEventType type)
|
||||
{
|
||||
value = NormalizeValue(value);
|
||||
#if FRAMEWORK20
|
||||
OnScroll(new ScrollEventArgs(type, m_Value, value, this.ScrollOrientation));
|
||||
#else
|
||||
OnScroll(new ScrollEventArgs(type, value));
|
||||
#endif
|
||||
Value = value;
|
||||
_RaiseEndScroll = true;
|
||||
}
|
||||
|
||||
private int NormalizeValue(int value)
|
||||
{
|
||||
int max = m_IsAdvScrollBar ? GetMaximumValue() : m_Maximum;
|
||||
if (value < m_Minimum) value = m_Minimum;
|
||||
if (value > max) value = max;
|
||||
return value;
|
||||
}
|
||||
|
||||
private void OnScroll(ScrollEventArgs e)
|
||||
{
|
||||
ScrollEventHandler h = this.Scroll;
|
||||
if (h != null)
|
||||
h(this, e);
|
||||
}
|
||||
|
||||
internal int GetMaximumValue()
|
||||
{
|
||||
if (m_IsScrollBarParent)
|
||||
{
|
||||
return m_Maximum - m_LargeChange + 1;
|
||||
}
|
||||
else
|
||||
return m_Maximum;
|
||||
}
|
||||
|
||||
internal eScrollPart MouseOverPart
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MouseOverPart;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_MouseOverPart = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool m_Visible = true;
|
||||
public bool Visible
|
||||
{
|
||||
get { return m_Visible; }
|
||||
set { m_Visible = value; }
|
||||
}
|
||||
|
||||
public Control ParentControl
|
||||
{
|
||||
get { return m_ParentControl; }
|
||||
set
|
||||
{
|
||||
m_ParentControl = value;
|
||||
if (m_ParentControl == null) DisposeTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private bool m_Enabled = true;
|
||||
public bool Enabled
|
||||
{
|
||||
get { return m_Enabled; }
|
||||
set
|
||||
{
|
||||
if (m_Enabled != value)
|
||||
{
|
||||
m_Enabled = value;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAppScrollBarStyle
|
||||
{
|
||||
get { return m_IsAppScrollBarStyle; }
|
||||
set { m_IsAppScrollBarStyle = value; DisposeCashedView(); }
|
||||
}
|
||||
|
||||
internal enum eScrollPart
|
||||
{
|
||||
ThumbIncrease,
|
||||
ThumbDecrease,
|
||||
Track,
|
||||
Control,
|
||||
None
|
||||
}
|
||||
|
||||
internal bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
if (keyData == Keys.PageDown)
|
||||
{
|
||||
SetValue(this.Value + m_LargeChange, ScrollEventType.LargeIncrement);
|
||||
return true;
|
||||
}
|
||||
else if (keyData == Keys.PageUp)
|
||||
{
|
||||
SetValue(this.Value - m_LargeChange, ScrollEventType.LargeIncrement);
|
||||
return true;
|
||||
}
|
||||
else if (keyData == Keys.Up || keyData == Keys.Left)
|
||||
{
|
||||
SetValue(this.Value - m_SmallChange, ScrollEventType.SmallDecrement);
|
||||
return true;
|
||||
}
|
||||
else if (keyData == Keys.Down || keyData == Keys.Right)
|
||||
{
|
||||
SetValue(this.Value + m_SmallChange, ScrollEventType.SmallIncrement);
|
||||
return true;
|
||||
}
|
||||
else if (keyData == Keys.Home)
|
||||
{
|
||||
SetValue(m_Minimum, ScrollEventType.First);
|
||||
return true;
|
||||
}
|
||||
else if (keyData == Keys.End)
|
||||
{
|
||||
SetValue(m_Maximum, ScrollEventType.Last);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DisposeTimer();
|
||||
DisposeCashedView();
|
||||
m_ParentControl = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal void InvalidateScrollBar()
|
||||
{
|
||||
DisposeCashedView();
|
||||
Control parentControl = m_ParentControl;
|
||||
if (parentControl != null)
|
||||
parentControl.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#if !FRAMEWORK20
|
||||
public enum ScrollOrientation
|
||||
{
|
||||
HorizontalScroll,
|
||||
VerticalScroll
|
||||
}
|
||||
#endif
|
||||
}
|
47
PROMS/DotNetBar Source Code/ScrollBar/ScrollBarPainter.cs
Normal file
47
PROMS/DotNetBar Source Code/ScrollBar/ScrollBarPainter.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.ScrollBar
|
||||
{
|
||||
internal class ScrollBarPainter
|
||||
{
|
||||
#region Internal Implementation
|
||||
public virtual void PaintThumb(Graphics g, System.Drawing.Rectangle bounds, eScrollThumbPosition position, eScrollBarState state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void PaintTrackVertical(Graphics g, System.Drawing.Rectangle bounds, eScrollBarState state)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void PaintTrackHorizontal(Graphics g, System.Drawing.Rectangle bounds, eScrollBarState state)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void PaintBackground(Graphics g, System.Drawing.Rectangle bounds, eScrollBarState state, bool horizontal, bool sideBorderOnly, bool rtl)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
internal enum eScrollThumbPosition
|
||||
{
|
||||
Top,
|
||||
Bottom,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
|
||||
internal enum eScrollBarState
|
||||
{
|
||||
Normal,
|
||||
PartMouseOver,
|
||||
ControlMouseOver,
|
||||
Pressed,
|
||||
Disabled
|
||||
}
|
||||
}
|
33
PROMS/DotNetBar Source Code/ScrollBar/VScrollBarAdv.cs
Normal file
33
PROMS/DotNetBar Source Code/ScrollBar/VScrollBarAdv.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
[ToolboxItem(true), ToolboxBitmap(typeof(VScrollBarAdv), "ScrollBar.VScrollBarAdv.ico")]
|
||||
public class VScrollBarAdv : ScrollBarAdv
|
||||
{
|
||||
#region Private Variables
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
protected override bool IsVertical()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Property Hiding
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
BIN
PROMS/DotNetBar Source Code/ScrollBar/VScrollBarAdv.ico
Normal file
BIN
PROMS/DotNetBar Source Code/ScrollBar/VScrollBarAdv.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Reference in New Issue
Block a user