Skip to content

Commit 323a8cb

Browse files
authored
Code quality: Improved code readability (#10116)
1 parent 99cb5dc commit 323a8cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4136
-4462
lines changed

src/Files.App/BaseLayout.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,15 @@ public string JumpString
167167
IEnumerable<ListedItem> candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders
168168
.SkipWhile(x => x != previouslySelectedItem)
169169
.Skip(value.Length == 1 ? 1 : 0) // User is trying to cycle through items starting with the same letter
170-
.Where(f => f.ItemName.Length >= value.Length && string.Equals(f.ItemName.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
170+
.Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
171171
jumpedToItem = candidateItems.FirstOrDefault();
172172
}
173173

174174
if (jumpedToItem == null)
175175
{
176176
// Use FilesAndFolders because only displayed entries should be jumped to
177177
IEnumerable<ListedItem> candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders
178-
.Where(f => f.ItemName.Length >= value.Length && string.Equals(f.ItemName.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
178+
.Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
179179
jumpedToItem = candidateItems.FirstOrDefault();
180180
}
181181

@@ -761,7 +761,7 @@ protected void FileList_DragItemsStarting(object sender, DragItemsStartingEventA
761761
try
762762
{
763763
// Only support IStorageItem capable paths
764-
var itemList = e.Items.OfType<ListedItem>().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcutItem)).Select(x => VirtualStorageItem.FromListedItem(x));
764+
var itemList = e.Items.OfType<ListedItem>().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcut)).Select(x => VirtualStorageItem.FromListedItem(x));
765765
e.Data.SetStorageItems(itemList, false);
766766
}
767767
catch (Exception)
@@ -820,7 +820,7 @@ protected async void Item_DragOver(object sender, DragEventArgs e)
820820
else if (handledByFtp)
821821
{
822822
e.DragUIOverride.IsCaptionVisible = true;
823-
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.ItemName);
823+
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name);
824824
e.AcceptedOperation = DataPackageOperation.Copy;
825825
}
826826
else if (!draggedItems.Any())
@@ -832,38 +832,38 @@ protected async void Item_DragOver(object sender, DragEventArgs e)
832832
e.DragUIOverride.IsCaptionVisible = true;
833833
if (item.IsExecutable)
834834
{
835-
e.DragUIOverride.Caption = $"{"OpenItemsWithCaptionText".GetLocalizedResource()} {item.ItemName}";
835+
e.DragUIOverride.Caption = $"{"OpenItemsWithCaptionText".GetLocalizedResource()} {item.Name}";
836836
e.AcceptedOperation = DataPackageOperation.Link;
837837
} // Items from the same drive as this folder are dragged into this folder, so we move the items instead of copy
838838
else if (e.Modifiers.HasFlag(DragDropModifiers.Alt) || e.Modifiers.HasFlag(DragDropModifiers.Control | DragDropModifiers.Shift))
839839
{
840-
e.DragUIOverride.Caption = string.Format("LinkToFolderCaptionText".GetLocalizedResource(), item.ItemName);
840+
e.DragUIOverride.Caption = string.Format("LinkToFolderCaptionText".GetLocalizedResource(), item.Name);
841841
e.AcceptedOperation = DataPackageOperation.Link;
842842
}
843843
else if (e.Modifiers.HasFlag(DragDropModifiers.Control))
844844
{
845-
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.ItemName);
845+
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name);
846846
e.AcceptedOperation = DataPackageOperation.Copy;
847847
}
848848
else if (e.Modifiers.HasFlag(DragDropModifiers.Shift))
849849
{
850-
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.ItemName);
850+
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
851851
e.AcceptedOperation = DataPackageOperation.Move;
852852
}
853853
else if (draggedItems.Any(x => x.Item is ZipStorageFile || x.Item is ZipStorageFolder)
854854
|| ZipStorageFolder.IsZipPath(item.ItemPath))
855855
{
856-
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.ItemName);
856+
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name);
857857
e.AcceptedOperation = DataPackageOperation.Copy;
858858
}
859859
else if (draggedItems.AreItemsInSameDrive(item.ItemPath))
860860
{
861-
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.ItemName);
861+
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
862862
e.AcceptedOperation = DataPackageOperation.Move;
863863
}
864864
else
865865
{
866-
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.ItemName);
866+
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name);
867867
e.AcceptedOperation = DataPackageOperation.Copy;
868868
}
869869
}
@@ -1016,10 +1016,9 @@ protected internal void FileListItem_PointerExited(object sender, PointerRoutedE
10161016
protected void FileListItem_RightTapped(object sender, RightTappedRoutedEventArgs e)
10171017
{
10181018
var rightClickedItem = GetItemFromElement(sender);
1019+
10191020
if (rightClickedItem != null && !((SelectorItem)sender).IsSelected)
1020-
{
10211021
ItemManipulationModel.SetSelectedItem(rightClickedItem);
1022-
}
10231022
}
10241023

10251024
private readonly RecycleBinHelpers recycleBinHelpers = new();

0 commit comments

Comments
 (0)