mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-02 07:09:27 +03:00
Scrollbars will now visually looked disabled.
Can now choose to have scrollbars always visible in scrollbase.
This commit is contained in:
parent
3a409516cc
commit
94670aac43
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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.
|
||||
|
12
DarkUI/Icons/ScrollIcons.Designer.cs
generated
12
DarkUI/Icons/ScrollIcons.Designer.cs
generated
@ -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>
|
||||
|
@ -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>
|
||||
|
BIN
DarkUI/Resources/scrollbar_disabled.png
Normal file
BIN
DarkUI/Resources/scrollbar_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
1
Example/Forms/Docking/DockLayers.Designer.cs
generated
1
Example/Forms/Docking/DockLayers.Designer.cs
generated
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user