Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Files/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public BaseLayout()

protected abstract void SetSelectedItemsOnUi(List<ListedItem> selectedItems);

public abstract void FocusSelectedItems();

protected abstract ListedItem GetItemFromElement(object element);

private void AppSettings_LayoutModeChangeRequested(object sender, EventArgs e)
Expand Down Expand Up @@ -275,10 +277,6 @@ private void Page_Loaded(object sender, RoutedEventArgs e)

protected virtual void Page_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
{
var focusedElement = FocusManager.GetFocusedElement(XamlRoot) as FrameworkElement;
if (focusedElement is TextBox)
return;

char letterPressed = Convert.ToChar(args.KeyCode);
App.CurrentInstance.InteractionOperations.PushJumpChar(letterPressed);
}
Expand Down Expand Up @@ -321,6 +319,11 @@ protected async void Item_DragStarting(object sender, DragStartingEventArgs e)
selectedStorageItems.Add(await StorageFolder.GetFolderFromPathAsync(item.ItemPath));
}

if (selectedStorageItems.Count == 0) {
e.Cancel = true;
return;
}

e.Data.SetStorageItems(selectedStorageItems);
e.DragUI.SetContentFromDataPackage();
}
Expand Down Expand Up @@ -354,7 +357,7 @@ protected async void Item_Drop(object sender, DragEventArgs e)
protected void InitializeDrag(UIElement element)
{
ListedItem item = GetItemFromElement(element);
if(item != null)
if (item != null)
{
element.AllowDrop = false;
element.DragStarting -= Item_DragStarting;
Expand Down
7 changes: 6 additions & 1 deletion Files/Dialogs/AddItemDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public static async void CreateFile(AddItemType fileType)
StorageFolder folderToCreateItem = await StorageFolder.GetFolderFromPathAsync(currentPath);
RenameDialog renameDialog = new RenameDialog();

await renameDialog.ShowAsync();
var renameResult = await renameDialog.ShowAsync();
if (renameResult == ContentDialogResult.Secondary)
{
return;
}

var userInput = renameDialog.storedRenameInput;

if (fileType == AddItemType.Folder)
Expand Down
2 changes: 1 addition & 1 deletion Files/Dialogs/RenameDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:Windows10version1903="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 8)"
CornerRadius="4" Grid.RowSpan="4" DefaultButton="Primary" Title="Enter an item name" BorderThickness="0" SecondaryButtonClick="NameDialog_SecondaryButtonClick" PrimaryButtonClick="NameDialog_PrimaryButtonClick" x:Name="NameDialog" PrimaryButtonText="Set Name" SecondaryButtonText="Cancel" x:Uid="RenameDialog">
CornerRadius="4" Grid.RowSpan="4" DefaultButton="Primary" Title="Enter an item name" BorderThickness="0" PrimaryButtonClick="NameDialog_PrimaryButtonClick" x:Name="NameDialog" PrimaryButtonText="Set Name" SecondaryButtonText="Cancel" x:Uid="RenameDialog">

<Grid MinWidth="300">
<TextBox x:Name="RenameInput" x:Uid="RenameDialogInputText" PlaceholderText="Enter an item name without an extension" Height="35"/>
Expand Down
6 changes: 0 additions & 6 deletions Files/Dialogs/RenameDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,5 @@ private void NameDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogBu
{
storedRenameInput = inputBox.Text;
}

private void NameDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
storedRenameInput = null;
}

}
}
2 changes: 1 addition & 1 deletion Files/Helpers/NaturalStringComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal static class SafeNativeMethods
public static readonly String LOCALE_NAME_INVARIANT = String.Empty;
public static readonly String LOCALE_NAME_SYSTEM_DEFAULT = "!sys-default-locale";

[DllImport("api-ms-win-core-string-l1-1-0 .dll", CharSet = CharSet.Unicode)]
[DllImport("api-ms-win-core-string-l1-1-0.dll", CharSet = CharSet.Unicode)]
public static extern Int32 CompareStringEx(
String localeName,
Int32 flags,
Expand Down
57 changes: 18 additions & 39 deletions Files/Interacts/Interaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,16 @@ public async void OpenInNewWindowItem_Click(object sender, RoutedEventArgs e)
}
}

public void OpenDirectoryInNewTab_Click(object sender, RoutedEventArgs e)
public async void OpenDirectoryInNewTab_Click(object sender, RoutedEventArgs e)
{
var CurrentSourceType = App.CurrentInstance.CurrentPageType;
if (CurrentSourceType == typeof(GenericFileBrowser))
{
var items = (CurrentInstance.ContentPage as BaseLayout).SelectedItems;
foreach (ListedItem listedItem in items)
{
instanceTabsView.AddNewTab(typeof(ModernShellPage), listedItem.ItemPath);
}

}
else if (CurrentSourceType == typeof(PhotoAlbum))
var items = (CurrentInstance.ContentPage as BaseLayout).SelectedItems;
foreach (ListedItem listedItem in items)
{
var items = (CurrentInstance.ContentPage as BaseLayout).SelectedItems;
foreach (ListedItem listedItem in items)
await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
{
instanceTabsView.AddNewTab(typeof(ModernShellPage), listedItem.ItemPath);
}
});
}
}

Expand Down Expand Up @@ -943,7 +934,7 @@ public async Task PasteItems(DataPackageView packageView, string destinationPath

if (acceptedOperation == DataPackageOperation.Move)
{
foreach (IStorageItem item in itemsToPaste)
foreach (IStorageItem item in pastedItems)
{
if (item.IsOfType(StorageItemTypes.File))
{
Expand All @@ -965,6 +956,7 @@ public async Task PasteItems(DataPackageView packageView, string destinationPath
List<string> pastedItemPaths = pastedItems.Select(item => item.Path).ToList();
List<ListedItem> copiedItems = CurrentInstance.ViewModel.FilesAndFolders.Where(listedItem => pastedItemPaths.Contains(listedItem.ItemPath)).ToList();
CurrentInstance.ContentPage.SelectedItems = copiedItems;
CurrentInstance.ContentPage.FocusSelectedItems();
}
packageView.ReportOperationCompleted(acceptedOperation);
}
Expand Down Expand Up @@ -1087,34 +1079,21 @@ await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal

public void SelectAllItems()
{
if (App.CurrentInstance.CurrentPageType == typeof(GenericFileBrowser))
{
var CurrentInstance = App.CurrentInstance;
foreach (ListedItem li in (CurrentInstance.ContentPage as GenericFileBrowser).AllView.ItemsSource)
{
if (!(CurrentInstance.ContentPage as GenericFileBrowser).SelectedItems.Contains(li))
{
(CurrentInstance.ContentPage as GenericFileBrowser).AllView.SelectedItems.Add(li);
}
}
}
else if (App.CurrentInstance.CurrentPageType == typeof(PhotoAlbum))
{
(CurrentInstance.ContentPage as PhotoAlbum).FileList.SelectAll();
}
CurrentInstance.ContentPage.SelectedItems = App.CurrentInstance.ViewModel.FilesAndFolders.ToList();
}

public void InvertAllItems()
{
List<ListedItem> oldSelectedItems = CurrentInstance.ContentPage.SelectedItems;
List<ListedItem> newSelectedItems = CurrentInstance.ViewModel.FilesAndFolders.ToList();
foreach (ListedItem listedItem in oldSelectedItems)
newSelectedItems.Remove(listedItem);
CurrentInstance.ContentPage.SelectedItems = newSelectedItems;
}

public void ClearAllItems()
{
if (App.CurrentInstance.CurrentPageType == typeof(GenericFileBrowser))
{
var CurrentInstance = App.CurrentInstance;
(CurrentInstance.ContentPage as GenericFileBrowser).AllView.SelectedItems.Clear();
}
else if (App.CurrentInstance.CurrentPageType == typeof(PhotoAlbum))
{
(CurrentInstance.ContentPage as PhotoAlbum).FileList.SelectedItems.Clear();
}
CurrentInstance.ContentPage.SelectedItems = new List<ListedItem>();
}

public void ToggleQuickLook_Click(object sender, RoutedEventArgs e)
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.de-DE.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@
<source>Settings</source>
<target state="new">Settings</target>
</trans-unit>
<trans-unit id="StatusBarControlInvertSelection.Text" translate="yes" xml:space="preserve">
<source>Invert Selection</source>
<target state="new">Invert Selection</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
6 changes: 5 additions & 1 deletion Files/MultilingualResources/Files.es-ES.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,11 @@
<source>Settings</source>
<target state="translated">Ajustes</target>
</trans-unit>
<trans-unit id="StatusBarControlInvertSelection.Text" translate="yes" xml:space="preserve">
<source>Invert Selection</source>
<target state="new">Invert Selection</target>
</trans-unit>
</group>
</body>
</file>
</xliff>
</xliff>
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.fr-FR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
<source>Settings</source>
<target state="new">Settings</target>
</trans-unit>
<trans-unit id="StatusBarControlInvertSelection.Text" translate="yes" xml:space="preserve">
<source>Invert Selection</source>
<target state="new">Invert Selection</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.nl-NL.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
<source>Settings</source>
<target state="new">Settings</target>
</trans-unit>
<trans-unit id="StatusBarControlInvertSelection.Text" translate="yes" xml:space="preserve">
<source>Invert Selection</source>
<target state="new">Invert Selection</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.pl-PL.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
<source>Settings</source>
<target state="new">Settings</target>
</trans-unit>
<trans-unit id="StatusBarControlInvertSelection.Text" translate="yes" xml:space="preserve">
<source>Invert Selection</source>
<target state="new">Invert Selection</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.ru-RU.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@
<source>Settings</source>
<target state="new">Settings</target>
</trans-unit>
<trans-unit id="StatusBarControlInvertSelection.Text" translate="yes" xml:space="preserve">
<source>Invert Selection</source>
<target state="new">Invert Selection</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.tr-TR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
<source>Settings</source>
<target state="new">Settings</target>
</trans-unit>
<trans-unit id="StatusBarControlInvertSelection.Text" translate="yes" xml:space="preserve">
<source>Invert Selection</source>
<target state="new">Invert Selection</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.uk-UA.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@
<source>Settings</source>
<target state="new">Settings</target>
</trans-unit>
<trans-unit id="StatusBarControlInvertSelection.Text" translate="yes" xml:space="preserve">
<source>Invert Selection</source>
<target state="new">Invert Selection</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
<source>Settings</source>
<target state="new">Settings</target>
</trans-unit>
<trans-unit id="StatusBarControlInvertSelection.Text" translate="yes" xml:space="preserve">
<source>Invert Selection</source>
<target state="new">Invert Selection</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
11 changes: 7 additions & 4 deletions Files/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
</data>
<data name="ModernNavigationToolbaNewTextDocument.Text" xml:space="preserve">
<value>Text Document</value>
</data>
</data>
<data name="NavigationToolbarCopyPath.Text" xml:space="preserve">
<value>Copy Path</value>
</data>
Expand Down Expand Up @@ -219,21 +219,24 @@
<data name="StatusBarControlSelectAll.Text" xml:space="preserve">
<value>Select All</value>
</data>
<data name="StatusBarControlInvertSelection.Text" xml:space="preserve">
<value>Invert Selection</value>
</data>
<data name="StatusBarControlClearSelection.Text" xml:space="preserve">
<value>Clear Selection</value>
</data>
</data>
<data name="StatusBarControlListView.Text" xml:space="preserve">
<value>List View</value>
</data>
<data name="StatusBarControlGridView.Text" xml:space="preserve">
<value>Grid View</value>
</data>
</data>
<data name="PropertiesModified.Text" xml:space="preserve">
<value>Modified:</value>
</data>
<data name="RecentItemClearAll.Text" xml:space="preserve">
<value>Clear all items</value>
</data>
</data>
<data name="NavigationToolbarVisiblePath.PlaceholderText" xml:space="preserve">
<value>Enter a path</value>
</data>
Expand Down
18 changes: 14 additions & 4 deletions Files/UserControls/LayoutModes/GenericFileBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ protected override void SetSelectedItemOnUi(ListedItem selectedItem)
{
AllView.SelectedItem = selectedItem;
AllView.UpdateLayout();
AllView.ScrollIntoView(AllView.SelectedItem, null);
}
}

protected override void SetSelectedItemsOnUi(List<ListedItem> selectedItems)
{
// To prevent program from crashing when the page is first loaded
Expand All @@ -108,6 +108,10 @@ protected override void SetSelectedItemsOnUi(List<ListedItem> selectedItems)
foreach (ListedItem selectedItem in selectedItems)
AllView.SelectedItems.Add(selectedItem);
AllView.UpdateLayout();
}

public override void FocusSelectedItems()
{
AllView.ScrollIntoView(AllView.ItemsSource.Cast<ListedItem>().Last(), null);
}

Expand Down Expand Up @@ -136,14 +140,14 @@ private async void ViewModel_PropertyChanged(object sender, PropertyChangedEvent
// Swap arrows
SortedColumn = _sortedColumn;
}
else if (e.PropertyName == "isLoadingItems")
else if (e.PropertyName == "IsLoadingItems")
{
if (!AssociatedViewModel.IsLoadingItems && AssociatedViewModel.FilesAndFolders.Count > 0)
{
var allRows = new List<DataGridRow>();

Interacts.Interaction.FindChildren<DataGridRow>(allRows, AllView);
foreach (DataGridRow row in allRows.Take(20))
foreach (DataGridRow row in allRows.Take(25))
{
if (!(row.DataContext as ListedItem).ItemPropertiesInitialized)
{
Expand Down Expand Up @@ -216,7 +220,7 @@ private async void AllView_Sorting(object sender, DataGridColumnEventArgs e)
var allRows = new List<DataGridRow>();

Interacts.Interaction.FindChildren<DataGridRow>(allRows, AllView);
foreach (DataGridRow row in allRows.Take(20))
foreach (DataGridRow row in allRows.Take(25))
{
if (!(row.DataContext as ListedItem).ItemPropertiesInitialized)
{
Expand Down Expand Up @@ -256,6 +260,12 @@ protected override void Page_CharacterReceived(CoreWindow sender, CharacterRecei
{
if (App.CurrentInstance.CurrentPageType == typeof(GenericFileBrowser))
{
var focusedElement = FocusManager.GetFocusedElement(XamlRoot) as FrameworkElement;
if (focusedElement is TextBox)
{
return;
}

base.Page_CharacterReceived(sender, args);
AllView.Focus(FocusState.Keyboard);
}
Expand Down
Loading