mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-10-02 10:07:15 +13:00
Fix iteration over filtered items
This commit is contained in:
parent
a52897787e
commit
8c62122c7e
3 changed files with 8 additions and 7 deletions
|
@ -675,7 +675,7 @@ namespace SystemTrayMenu.Business
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<RowData> rowDatas = new();
|
List<RowData> rowDatas = new();
|
||||||
foreach (RowData rowData in menu.GetDataGridView().Items)
|
foreach (RowData rowData in menu.GetDataGridView().Items.SourceCollection)
|
||||||
{
|
{
|
||||||
if (rowData.Path.StartsWith($"{e.OldFullPath}"))
|
if (rowData.Path.StartsWith($"{e.OldFullPath}"))
|
||||||
{
|
{
|
||||||
|
@ -741,7 +741,7 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
foreach (RowData rowToRemove in rowsToRemove)
|
foreach (RowData rowToRemove in rowsToRemove)
|
||||||
{
|
{
|
||||||
((IEditableCollectionView)dgv.Items).Remove(rowToRemove);
|
((List<RowData>)dgv.ItemsSource).Remove(rowToRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.SelectedItem = null;
|
menu.SelectedItem = null;
|
||||||
|
@ -770,7 +770,7 @@ namespace SystemTrayMenu.Business
|
||||||
rowData.HiddenEntry = hasHiddenFlag;
|
rowData.HiddenEntry = hasHiddenFlag;
|
||||||
rowData.LoadIcon();
|
rowData.LoadIcon();
|
||||||
|
|
||||||
var items = menu.GetDataGridView().Items;
|
var items = (List<RowData>)menu.GetDataGridView().Items.SourceCollection;
|
||||||
List<RowData> rowDatas = new(items.Count + 1) { rowData };
|
List<RowData> rowDatas = new(items.Count + 1) { rowData };
|
||||||
foreach (RowData item in items)
|
foreach (RowData item in items)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
namespace SystemTrayMenu.DataClasses
|
namespace SystemTrayMenu.DataClasses
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -284,7 +285,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
internal void OpenSubMenu()
|
internal void OpenSubMenu()
|
||||||
{
|
{
|
||||||
// TODO: always true? maybe only when cached in WaitToLoadMenu or keyboardInput?
|
// TODO: always true? maybe only when cached in WaitToLoadMenu or keyboardInput?
|
||||||
if (Owner?.GetDataGridView().Items.Contains(this) ?? false)
|
if (((List<RowData>?)Owner?.GetDataGridView().Items.SourceCollection)?.Contains(this) ?? false)
|
||||||
{
|
{
|
||||||
Menu? openSubMenu = Owner.SubMenu;
|
Menu? openSubMenu = Owner.SubMenu;
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
RowDataParent.SubMenu = null;
|
RowDataParent.SubMenu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (RowData item in dgv.Items)
|
foreach (RowData item in dgv.Items.SourceCollection)
|
||||||
{
|
{
|
||||||
item.SubMenu?.Close();
|
item.SubMenu?.Close();
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
foreach (RowData rowData in dgv.Items)
|
foreach (RowData rowData in dgv.Items.SourceCollection)
|
||||||
{
|
{
|
||||||
if (rowData.SubMenu != null)
|
if (rowData.SubMenu != null)
|
||||||
{
|
{
|
||||||
|
@ -1075,7 +1075,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
// TODO: Refactor item selection to prevent running this loop
|
// TODO: Refactor item selection to prevent running this loop
|
||||||
ListView lv = (ListView)sender;
|
ListView lv = (ListView)sender;
|
||||||
foreach (RowData itemData in lv.Items)
|
foreach (RowData itemData in lv.Items.SourceCollection)
|
||||||
{
|
{
|
||||||
itemData.IsSelected = lv.SelectedItem == itemData;
|
itemData.IsSelected = lv.SelectedItem == itemData;
|
||||||
itemData.UpdateColors();
|
itemData.UpdateColors();
|
||||||
|
|
Loading…
Reference in a new issue