Skip to content

Commit

Permalink
#191 Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Dec 13, 2024
1 parent 8f194f6 commit cd01171
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
36 changes: 21 additions & 15 deletions src/ReaLTaiizor/Controls/ListBox/MaterialListBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class MaterialListBox : Control, MaterialControlI
private int _selectedIndex;
private MaterialListBoxItem _selectedItem;
private bool _showScrollBar;
private bool _multiKeyDown;
private int _hoveredItem;
private MaterialScrollBar _scrollBar;
private bool _smoothScrolling = true;
Expand Down Expand Up @@ -291,7 +290,6 @@ private void SetDefaults()
Items.CollectionChanged += InvalidateScroll;
SelectedItems = new List<object>();
_indicates = new List<object>();
_multiKeyDown = false;
_scrollBar = new MaterialScrollBar()
{
Orientation = MateScrollOrientation.Vertical,
Expand Down Expand Up @@ -403,15 +401,14 @@ protected override void OnPaint(PaintEventArgs e)
int itemOffset = SmoothScrolling ? _scrollBar.Value - (firstItem * _itemHeight) : 0;

// Calculate the last item
int lastItem = (_scrollBar.Value / _itemHeight) + ((Height + itemOffset) / _itemHeight) + 1 > Items.Count ?
Items.Count :
(_scrollBar.Value / _itemHeight) + ((Height + itemOffset) / _itemHeight) + 1;
int lastItem = (_scrollBar.Value / _itemHeight) + ((Height + itemOffset) / _itemHeight) + 1 > Items.Count ? Items.Count : (_scrollBar.Value / _itemHeight) + ((Height + itemOffset) / _itemHeight) + 1;

g.FillRectangle(Enabled ? SkinManager.BackgroundBrush : SkinManager.BackgroundDisabledBrush, mainRect);

//Set TextAlignFlags
MaterialNativeTextRenderer.TextAlignFlags primaryTextAlignFlags;
MaterialNativeTextRenderer.TextAlignFlags secondaryTextAlignFlags = MaterialNativeTextRenderer.TextAlignFlags.Left | MaterialNativeTextRenderer.TextAlignFlags.Top;

if (_style is ListBoxStyle.TwoLine or ListBoxStyle.ThreeLine)
{
primaryTextAlignFlags = MaterialNativeTextRenderer.TextAlignFlags.Left | MaterialNativeTextRenderer.TextAlignFlags.Bottom;
Expand Down Expand Up @@ -451,10 +448,7 @@ protected override void OnPaint(PaintEventArgs e)
}
else if (_indicates.Contains(i))
{
g.FillRectangle(Enabled ?
SelectedBrush :
new SolidBrush(BlendColor(SelectedColor, SkinManager.SwitchOffDisabledThumbColor, 197)),
itemRect);
g.FillRectangle(Enabled ? SelectedBrush : new SolidBrush(BlendColor(SelectedColor, SkinManager.SwitchOffDisabledThumbColor, 197)), itemRect);
}
}
else
Expand All @@ -465,10 +459,7 @@ protected override void OnPaint(PaintEventArgs e)
}
else if (i == SelectedIndex)
{
g.FillRectangle(Enabled ?
SelectedBrush :
new SolidBrush(BlendColor(SelectedColor, SkinManager.SwitchOffDisabledThumbColor, 197)),
itemRect);
g.FillRectangle(Enabled ? SelectedBrush : new SolidBrush(BlendColor(SelectedColor, SkinManager.SwitchOffDisabledThumbColor, 197)), itemRect);
}
}

Expand Down Expand Up @@ -497,7 +488,7 @@ protected override void OnPaint(PaintEventArgs e)
NativeText.DrawTransparentText(
itemText,
_primaryFont,
Enabled ? (i != SelectedIndex || UseAccentColor) ?
Enabled ? ((i != SelectedIndex && !_indicates.Contains(i)) || UseAccentColor) ?
SkinManager.TextHighEmphasisColor :
SkinManager.ColorScheme.TextColor :
SkinManager.TextDisabledOrHintColor, // Disabled
Expand Down Expand Up @@ -733,10 +724,25 @@ protected override void OnMouseDown(MouseEventArgs e)

if (index >= 0 && index < Items.Count)
{
if (MultiSelect && _multiKeyDown)
if (MultiSelect && (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift))
{
if (SelectedIndex >= 0)
{
if (!_indicates.Contains(SelectedIndex))
{
_indicates.Add(SelectedIndex);
}
if (!SelectedItems.Contains(Items[SelectedIndex]))
{
SelectedItems.Add(Items[SelectedIndex]);
}

SelectedIndex = -1;
}

_indicates.Add(index);
SelectedItems.Add(Items[index]);
SelectedValueChanged?.Invoke(this, Items[index]);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/ReaLTaiizor/ReaLTaiizor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Creator: Taiizor
// Website: www.vegalya.com
// Created: 15.May.2019
// Changed: 10.Dec.2024
// Changed: 13.Dec.2024
// Version: 3.8.1.1
//
// |---------DO-NOT-REMOVE---------|
Expand Down

0 comments on commit cd01171

Please sign in to comment.