Scrollbars will now visually looked disabled.

Can now choose to have scrollbars always visible in scrollbase.
This commit is contained in:
Robin 2017-03-05 21:03:21 +00:00
parent 3a409516cc
commit 94670aac43
7 changed files with 66 additions and 19 deletions

View File

@ -388,16 +388,8 @@ namespace DarkUI.Controls
public void UpdateScrollBar()
{
if (ViewSize >= Maximum)
return;
var area = ClientRectangle;
// Cap to maximum value
var maximumValue = Maximum - ViewSize;
if (Value > maximumValue)
Value = maximumValue;
// Arrow buttons
if (_scrollOrientation == DarkScrollOrientation.Vertical)
{
@ -427,7 +419,15 @@ namespace DarkUI.Controls
}
private void UpdateThumb(bool forceRefresh = false)
{
{
if (ViewSize >= Maximum)
return;
// Cap to maximum value
var maximumValue = Maximum - ViewSize;
if (Value > maximumValue)
Value = maximumValue;
// Calculate size ratio
_viewContentRatio = (float)ViewSize / (float)Maximum;
var viewAreaSize = Maximum - ViewSize;
@ -493,6 +493,9 @@ namespace DarkUI.Controls
if (_upArrowClicked)
upIcon = ScrollIcons.scrollbar_arrow_clicked;
if (!Enabled)
upIcon = ScrollIcons.scrollbar_arrow_disabled;
if (_scrollOrientation == DarkScrollOrientation.Vertical)
upIcon.RotateFlip(RotateFlipType.RotateNoneFlipY);
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
@ -508,6 +511,9 @@ namespace DarkUI.Controls
if (_downArrowClicked)
downIcon = ScrollIcons.scrollbar_arrow_clicked;
if (!Enabled)
downIcon = ScrollIcons.scrollbar_arrow_disabled;
if (_scrollOrientation == DarkScrollOrientation.Horizontal)
downIcon.RotateFlip(RotateFlipType.Rotate270FlipNone);
@ -516,14 +522,17 @@ namespace DarkUI.Controls
_downArrowArea.Top + (_downArrowArea.Height / 2) - (downIcon.Height / 2));
// Draw thumb
var scrollColor = _thumbHot ? Colors.GreyHighlight : Colors.GreySelection;
if (_isScrolling)
scrollColor = Colors.ActiveControl;
using (var b = new SolidBrush(scrollColor))
if (Enabled)
{
g.FillRectangle(b, _thumbArea);
var scrollColor = _thumbHot ? Colors.GreyHighlight : Colors.GreySelection;
if (_isScrolling)
scrollColor = Colors.ActiveControl;
using (var b = new SolidBrush(scrollColor))
{
g.FillRectangle(b, _thumbArea);
}
}
}

View File

@ -30,6 +30,8 @@ namespace DarkUI.Controls
private int _maxDragChange = 0;
private Timer _dragTimer;
private bool _hideScrollBars = true;
#endregion
#region Property Region
@ -88,6 +90,19 @@ namespace DarkUI.Controls
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsDragging { get; private set; }
[Category("Behavior")]
[Description("Determines whether scrollbars will remain visible when disabled.")]
[DefaultValue(true)]
public bool HideScrollBars
{
get { return _hideScrollBars; }
set
{
_hideScrollBars = value;
UpdateScrollBars();
}
}
#endregion
#region Constructor Region
@ -159,8 +174,14 @@ namespace DarkUI.Controls
private void SetScrollBarVisibility()
{
_vScrollBar.Visible = _visibleSize.Height < ContentSize.Height;
_hScrollBar.Visible = _visibleSize.Width < ContentSize.Width;
_vScrollBar.Enabled = _visibleSize.Height < ContentSize.Height;
_hScrollBar.Enabled = _visibleSize.Width < ContentSize.Width;
if (_hideScrollBars)
{
_vScrollBar.Visible = _vScrollBar.Enabled;
_hScrollBar.Visible = _hScrollBar.Enabled;
}
}
private void SetVisibleSize()

View File

@ -309,6 +309,9 @@
<ItemGroup>
<None Include="Resources\small_arrow.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\scrollbar_disabled.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace DarkUI.Icons {
namespace DarkUI {
using System;
@ -80,6 +80,16 @@ namespace DarkUI.Icons {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap scrollbar_arrow_disabled {
get {
object obj = ResourceManager.GetObject("scrollbar_arrow_disabled", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -124,6 +124,9 @@
<data name="scrollbar_arrow_clicked" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scrollbar_arrow_clicked.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="scrollbar_arrow_disabled" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scrollbar_disabled.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="scrollbar_arrow_hot" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scrollbar_arrow_hot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -38,6 +38,7 @@ namespace Example
// lstLayers
//
this.lstLayers.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstLayers.HideScrollBars = false;
this.lstLayers.Location = new System.Drawing.Point(0, 51);
this.lstLayers.Name = "lstLayers";
this.lstLayers.ShowIcons = true;