本文整理汇总了C#中System.Windows.Forms.ScrollBar类的典型用法代码示例。如果您正苦于以下问题:C# ScrollBar类的具体用法?C# ScrollBar怎么用?C# ScrollBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScrollBar类属于System.Windows.Forms命名空间,在下文中一共展示了ScrollBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HeapLayoutView
public HeapLayoutView()
{
SetStyle(
ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
ControlStyles.Opaque | ControlStyles.ResizeRedraw |
ControlStyles.Selectable,
true
);
BackColor = SystemColors.Window;
ForeColor = SystemColors.WindowText;
ScrollBar = new VScrollBar {
SmallChange = 1,
LargeChange = 8,
TabStop = false
};
NextAllocationButton = new Button {
Text = ">",
TabStop = false,
UseVisualStyleBackColor = true
};
NextAllocationButton.Click += NextAllocationButton_Click;
ScrollBar.Scroll += ScrollBar_Scroll;
OnResize(EventArgs.Empty);
Controls.Add(ScrollBar);
Controls.Add(NextAllocationButton);
}
示例2: AdjustScrollbar
/// <summary>
/// This method for System.Windows.Forms.ScrollBar and inherited classes
/// </summary>
private void AdjustScrollbar(ScrollBar scrollBar, int max, int value, int clientSize)
{
scrollBar.LargeChange = clientSize / 3;
scrollBar.SmallChange = clientSize / 11;
scrollBar.Maximum = max + scrollBar.LargeChange;
scrollBar.Visible = max > 0;
scrollBar.Value = Math.Min(scrollBar.Maximum, value);
}
示例3: SetScrollbar
public void SetScrollbar(ScrollBar bar)
{
scrollbar = bar;
scrollbar.ValueChanged += (o, e) => invalidateScrollbar();
scrollbar.Scroll += (o, e) => invalidateScrollbar();
if (tileSet != null)
invalidateScrollbar();
}
示例4: TabControl
public TabControl(DockStyle dockStyle, AnchorAlignment stripAnchor)
{
if ((dockStyle == DockStyle.Fill) || (dockStyle == DockStyle.None))
{
throw new ArgumentException(DR.GetString("InvalidDockingStyle", new object[] { "dockStyle" }));
}
base.SuspendLayout();
this.stripAnchor = stripAnchor;
this.Dock = dockStyle;
this.allowDockChange = false;
if ((this.Dock == DockStyle.Left) || (this.Dock == DockStyle.Right))
{
base.Width = SystemInformation.VerticalScrollBarWidth + 2;
this.splitter = new Splitter();
this.tabStrip = new System.Workflow.ComponentModel.Design.TabStrip(Orientation.Vertical, SystemInformation.VerticalScrollBarWidth);
this.scrollBar = new VScrollBar();
if (this.stripAnchor == AnchorAlignment.Near)
{
this.tabStrip.Dock = DockStyle.Top;
this.splitter.Dock = DockStyle.Top;
this.scrollBar.Dock = DockStyle.Fill;
}
else
{
this.tabStrip.Dock = DockStyle.Bottom;
this.splitter.Dock = DockStyle.Bottom;
this.scrollBar.Dock = DockStyle.Fill;
}
}
else
{
base.Height = SystemInformation.HorizontalScrollBarHeight + 2;
this.splitter = new Splitter();
this.tabStrip = new System.Workflow.ComponentModel.Design.TabStrip(Orientation.Horizontal, SystemInformation.HorizontalScrollBarHeight);
this.scrollBar = new HScrollBar();
if (this.stripAnchor == AnchorAlignment.Near)
{
this.tabStrip.Dock = DockStyle.Left;
this.splitter.Dock = DockStyle.Left;
this.scrollBar.Dock = DockStyle.Fill;
}
else
{
this.tabStrip.Dock = DockStyle.Right;
this.splitter.Dock = DockStyle.Right;
this.scrollBar.Dock = DockStyle.Fill;
}
}
base.Controls.AddRange(new Control[] { this.scrollBar, this.splitter, this.tabStrip });
this.splitter.Size = new Size(6, 6);
this.splitter.Paint += new PaintEventHandler(this.OnSplitterPaint);
this.splitter.DoubleClick += new EventHandler(this.OnSplitterDoubleClick);
((ItemList<System.Workflow.ComponentModel.Design.ItemInfo>) this.TabStrip.Tabs).ListChanged += new ItemListChangeEventHandler<System.Workflow.ComponentModel.Design.ItemInfo>(this.OnTabsChanged);
this.BackColor = SystemColors.Control;
base.ResumeLayout();
}
示例5: Initialize
public void Initialize(ScrollBar v, ScrollBar h) {
this.VerticalSB = v;
this.HorizontalSB = h;
this.Texture = null;
Buffer = new Selection[BUFFER_SIZE];
for (int i = 0; i < BUFFER_SIZE; i++) {
Buffer[i] = new Selection {
GridWidth = 1, GridHeight = 1
};
}
}
示例6: AdjustScrollbar
private void AdjustScrollbar(float t, ScrollBar scrollMax, ScrollBar scrollMin)
{
if (t > scrollMax.Maximum)
{
scrollMax.Maximum = (int) t;
scrollMax.Minimum = scrollMin.Maximum;
}
if (t < scrollMin.Minimum)
{
scrollMin.Minimum = (int) t;
scrollMin.Maximum = scrollMax.Minimum;
}
}
示例7: SideBarControl
public SideBarControl(SideBar nSideBar)
{
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.CacheText, true);
AllowDrop = true;
mMouseWheelHandler = new MouseWheelHandler();
mSideTabContent = new SideTabContent(nSideBar);
mScrollBar = new VScrollBar();
mScrollBar.Scroll += new ScrollEventHandler(_scrollBarScrolled);
mSideBar = nSideBar;
mMouseDownTab = null;
Controls.Add(mScrollBar);
Controls.Add(mSideTabContent);
}
示例8: SystemScrollBarAdapter
public SystemScrollBarAdapter(Orientation orientation)
{
switch(orientation)
{
case Orientation.Vertical:
_scrollBar = new VScrollBar();
break;
case Orientation.Horizontal:
_scrollBar = new HScrollBar();
break;
default:
throw new ArgumentException("orientation");
}
_scrollBar.Scroll += OnScrollBarScroll;
_scrollBar.ValueChanged += OnScrollBarValueChanged;
_orientation = orientation;
}
示例9: ScrollBarReplacement
public ScrollBarReplacement(System.Windows.Forms.ScrollBar sb)
{
m_ParentScrollBar = sb;
m_ParentScrollBarWndProc = (IScrollBarExtender)m_ParentScrollBar;
m_IsVScrollBar = m_ParentScrollBar is VScrollBar;
m_ScrollBarCore = new ScrollBarCore(m_ParentScrollBar, false);
m_ScrollBarCore.ValueChanged += new EventHandler(ScrollBarCore_ValueChanged);
if (m_ParentScrollBar is HScrollBar)
m_ScrollBarCore.Orientation = eOrientation.Horizontal;
else
m_ScrollBarCore.Orientation = eOrientation.Vertical;
m_ScrollBarCore.Minimum = m_ParentScrollBar.Minimum;
m_ScrollBarCore.Maximum = m_ParentScrollBar.Maximum;
m_ScrollBarCore.Value = m_ParentScrollBar.Value;
m_ScrollBarCore.Enabled = m_ParentScrollBar.Enabled;
m_ParentScrollBar.EnabledChanged += new EventHandler(ParentScrollBar_EnabledChanged);
}
示例10: ScrollBarImplementation
public ScrollBarImplementation(System.Windows.Forms.ScrollBar sb)
{
m_ParentScrollBar = sb;
m_ParentScrollBarWndProc = (IScrollBarExtender)m_ParentScrollBar;
m_IsVScrollBar = m_ParentScrollBar is VScrollBar;
m_PaintTimer = new Timer();
m_PaintTimer.Interval = 50;
m_PaintTimer.Tick += new EventHandler(PaintTimerTick);
m_ScrollBarCore = new ScrollBarCore(m_ParentScrollBar, true);
//m_ScrollBarCore.IsAppScrollBarStyle = false;
if (m_ParentScrollBar is HScrollBar)
m_ScrollBarCore.Orientation = eOrientation.Horizontal;
else
m_ScrollBarCore.Orientation = eOrientation.Vertical;
m_ScrollBarCore.Minimum = m_ParentScrollBar.Minimum;
m_ScrollBarCore.Maximum = m_ParentScrollBar.Maximum;
m_ScrollBarCore.Value = m_ParentScrollBar.Value;
}
示例11: ScrollBarControlLogic
public ScrollBarControlLogic(Panel panel)
{
mPanel = panel;
mVerticalScrollBar = new VScrollBar();
mVerticalScrollBar.Dock = DockStyle.Right;
//mVerticalScrollBar.Scroll += HandleVerticalScroll;
mVerticalScrollBar.ValueChanged += HandleVerticalScroll;
panel.Controls.Add(mVerticalScrollBar);
mHorizontalScrollBar = new HScrollBar();
mHorizontalScrollBar.Dock = DockStyle.Bottom;
mHorizontalScrollBar.ValueChanged += HandleHorizontalScroll;
panel.Controls.Add(mHorizontalScrollBar);
UpdateToImage(2048, 2048);
mPanel.Resize += HandlePanelResize;
}
示例12: DeltaList
public DeltaList()
{
SetStyle(
ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
ControlStyles.Opaque | ControlStyles.ResizeRedraw |
ControlStyles.Selectable,
true
);
BackColor = SystemColors.Window;
ForeColor = SystemColors.WindowText;
ScrollBar = new VScrollBar {
SmallChange = 1,
LargeChange = 8,
TabStop = false
};
ScrollBar.Scroll += ScrollBar_Scroll;
OnResize(EventArgs.Empty);
Controls.Add(ScrollBar);
}
示例13: DrawScrollBar
public override void DrawScrollBar (Graphics dc, Rectangle clip, ScrollBar bar)
{
int scrollbutton_width = bar.scrollbutton_width;
int scrollbutton_height = bar.scrollbutton_height;
Rectangle first_arrow_area;
Rectangle second_arrow_area;
Rectangle thumb_pos;
thumb_pos = bar.ThumbPos;
if (bar.vert) {
first_arrow_area = new Rectangle(0, 0, bar.Width, scrollbutton_height);
bar.FirstArrowArea = first_arrow_area;
second_arrow_area = new Rectangle(0, bar.ClientRectangle.Height - scrollbutton_height, bar.Width, scrollbutton_height);
bar.SecondArrowArea = second_arrow_area;
thumb_pos.Width = bar.Width;
bar.ThumbPos = thumb_pos;
Brush VerticalBrush;
/* Background, upper track */
if (bar.thumb_moving == ScrollBar.ThumbMoving.Backwards)
VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
else
VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
Rectangle UpperTrack = new Rectangle (0, 0, bar.ClientRectangle.Width, bar.ThumbPos.Bottom);
if (clip.IntersectsWith (UpperTrack))
dc.FillRectangle (VerticalBrush, UpperTrack);
/* Background, lower track */
if (bar.thumb_moving == ScrollBar.ThumbMoving.Forward)
VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
else
VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
Rectangle LowerTrack = new Rectangle (0, bar.ThumbPos.Bottom, bar.ClientRectangle.Width, bar.ClientRectangle.Height - bar.ThumbPos.Bottom);
if (clip.IntersectsWith (LowerTrack))
dc.FillRectangle (VerticalBrush, LowerTrack);
/* Buttons */
if (clip.IntersectsWith (first_arrow_area))
CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
if (clip.IntersectsWith (second_arrow_area))
CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
} else {
first_arrow_area = new Rectangle(0, 0, scrollbutton_width, bar.Height);
bar.FirstArrowArea = first_arrow_area;
second_arrow_area = new Rectangle (bar.ClientRectangle.Width - scrollbutton_width, 0, scrollbutton_width, bar.Height);
bar.SecondArrowArea = second_arrow_area;
thumb_pos.Height = bar.Height;
bar.ThumbPos = thumb_pos;
Brush HorizontalBrush;
//Background, left track
if (bar.thumb_moving == ScrollBar.ThumbMoving.Backwards)
HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
else
HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
Rectangle LeftTrack = new Rectangle (0, 0, bar.ThumbPos.Right, bar.ClientRectangle.Height);
if (clip.IntersectsWith (LeftTrack))
dc.FillRectangle (HorizontalBrush, LeftTrack);
//Background, right track
if (bar.thumb_moving == ScrollBar.ThumbMoving.Forward)
HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
else
HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
Rectangle RightTrack = new Rectangle (bar.ThumbPos.Right, 0, bar.ClientRectangle.Width - bar.ThumbPos.Right, bar.ClientRectangle.Height);
if (clip.IntersectsWith (RightTrack))
dc.FillRectangle (HorizontalBrush, RightTrack);
/* Buttons */
if (clip.IntersectsWith (first_arrow_area))
CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state);
if (clip.IntersectsWith (second_arrow_area))
CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state);
}
/* Thumb */
ScrollBar_DrawThumb(bar, thumb_pos, clip, dc);
}
示例14: OnScroll
bool IWorkflowDesignerMessageSink.OnScroll(ScrollBar sender, int value)
{
try
{
OnScroll(sender, value);
}
catch
{
}
return true;
}
示例15: SetScroll
private void SetScroll( ScrollBar scrollBar, Axis axis, double scrollMin, double scrollMax )
{
if ( scrollBar != null && axis != null )
{
scrollBar.Minimum = 0;
scrollBar.Maximum = _ScrollControlSpan - 1;
if ( scrollMin > axis._scale._min )
scrollMin = axis._scale._min;
if ( scrollMax < axis._scale._max )
scrollMax = axis._scale._max;
int val = 0;
Scale scale = axis._scale;
double minLinearized = scale._minLinearized;
double maxLinearized = scale._maxLinearized;
scrollMin = scale.Linearize( scrollMin );
scrollMax = scale.Linearize( scrollMax );
double scrollMin2 = scrollMax - ( maxLinearized - minLinearized );
/*
if ( axis.Scale.IsLog )
scrollMin2 = scrollMax / ( axis._scale._max / axis._scale._min );
else
scrollMin2 = scrollMax - ( axis._scale._max - axis._scale._min );
*/
if ( scrollMin >= scrollMin2 )
{
//scrollBar.Visible = false;
scrollBar.Enabled = false;
scrollBar.Value = 0;
}
else
{
double ratio = ( maxLinearized - minLinearized ) / ( scrollMax - scrollMin );
/*
if ( axis.Scale.IsLog )
ratio = ( Math.Log( axis._scale._max ) - Math.Log( axis._scale._min ) ) /
( Math.Log( scrollMax ) - Math.Log( scrollMin ) );
else
ratio = ( axis._scale._max - axis._scale._min ) / ( scrollMax - scrollMin );
*/
int largeChange = (int)( ratio * _ScrollControlSpan + 0.5 );
if ( largeChange < 1 )
largeChange = 1;
scrollBar.LargeChange = largeChange;
int smallChange = largeChange / _ScrollSmallRatio;
if ( smallChange < 1 )
smallChange = 1;
scrollBar.SmallChange = smallChange;
int span = _ScrollControlSpan - largeChange;
val = (int)( ( minLinearized - scrollMin ) / ( scrollMin2 - scrollMin ) *
span + 0.5 );
/*
if ( axis.Scale.IsLog )
val = (int)( ( Math.Log( axis._scale._min ) - Math.Log( scrollMin ) ) /
( Math.Log( scrollMin2 ) - Math.Log( scrollMin ) ) * span + 0.5 );
else
val = (int)( ( axis._scale._min - scrollMin ) / ( scrollMin2 - scrollMin ) *
span + 0.5 );
*/
if ( val < 0 )
val = 0;
else if ( val > span )
val = span;
//if ( ( axis is XAxis && axis.IsReverse ) || ( ( ! axis is XAxis ) && ! axis.IsReverse ) )
if ( ( axis is XAxis ) == axis.Scale.IsReverse )
val = span - val;
if ( val < scrollBar.Minimum )
val = scrollBar.Minimum;
if ( val > scrollBar.Maximum )
val = scrollBar.Maximum;
scrollBar.Value = val;
scrollBar.Enabled = true;
//scrollBar.Visible = true;
}
}
}