From cd011718caa7b8b0f12d910e48924bc5299b0149 Mon Sep 17 00:00:00 2001 From: Taiizor <41683699+Taiizor@users.noreply.github.com> Date: Fri, 13 Dec 2024 21:02:20 +0300 Subject: [PATCH] #191 Bug Fixes --- .../Controls/ListBox/MaterialListBox.cs | 36 +++++++++++-------- src/ReaLTaiizor/ReaLTaiizor.cs | 2 +- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/ReaLTaiizor/Controls/ListBox/MaterialListBox.cs b/src/ReaLTaiizor/Controls/ListBox/MaterialListBox.cs index a73e68f7..3df8200a 100644 --- a/src/ReaLTaiizor/Controls/ListBox/MaterialListBox.cs +++ b/src/ReaLTaiizor/Controls/ListBox/MaterialListBox.cs @@ -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; @@ -291,7 +290,6 @@ private void SetDefaults() Items.CollectionChanged += InvalidateScroll; SelectedItems = new List(); _indicates = new List(); - _multiKeyDown = false; _scrollBar = new MaterialScrollBar() { Orientation = MateScrollOrientation.Vertical, @@ -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; @@ -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 @@ -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); } } @@ -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 @@ -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 { diff --git a/src/ReaLTaiizor/ReaLTaiizor.cs b/src/ReaLTaiizor/ReaLTaiizor.cs index 8bfd2f9b..a84ec9cc 100644 --- a/src/ReaLTaiizor/ReaLTaiizor.cs +++ b/src/ReaLTaiizor/ReaLTaiizor.cs @@ -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---------|