Skip to content

Commit

Permalink
Merge branch 'main' into Bug_Drag_Multiple_Files_Tag_Area
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrariofilippo authored May 4, 2023
2 parents fe71f52 + 6955a93 commit f282757
Show file tree
Hide file tree
Showing 208 changed files with 1,825 additions and 1,419 deletions.
3 changes: 3 additions & 0 deletions specs/RichCommand/CommandList.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This is the list of all commands defined in `CommandCodes` enum except `None`.
| | Search | Search | Go to search box | Ctrl+F, F3 |
| | Redo | Redo | Redo the last file operation | Ctrl+Y |
| | Undo | Undo | Undo the last file operation | Ctrl+Z |
| | EditPath | Edit path | Focus path bar | Ctrl+L, Alt+D |
| Show | ToggleShowHiddenItems | Show hidden items | Toggle whether to show hidden items | Ctrl+H |
| | ToggleShowFileExtensions | Show file extensions | Toggle whether to show file extensions | |
| | TogglePreviewPane | Toggle the preview pane | Toggle whether to show preview pane | Ctrl+P |
Expand All @@ -24,6 +25,7 @@ This is the list of all commands defined in `CommandCodes` enum except `None`.
| | DeleteItem | Delete | Delete item(s) | Delete, Ctrl+D |
| | DeletemeItemPermanently | Delete permanently | Delete item(s) permanently | Shift+Delete |
| | CreateFolder | Folder | Create new folder | |
| | AddItem | New | Create new item | Ctrl+Shift+N |
| | CreateShortcut | Create shortcut | Create new shortcut(s) to selected item(s) | |
| | CreateShortcutFromDialog | Shortcut | Create new shortcut to any item | |
| | EmptyRecycleBin | Empty Recycle Bin | Empty recycle bin | |
Expand All @@ -33,6 +35,7 @@ This is the list of all commands defined in `CommandCodes` enum except `None`.
| | OpenItem | Open | Open item(s) | Enter |
| | OpenItemWithApplicationPicker | Open With | Open item(s) with selected application | |
| | OpenParentFolder | Open parent folder | Open parent folder of searched item | |
| | OpenFileLocation | Open file location | Open the item's location | |
| | RefreshItems | Refresh | Refresh page contents | Ctrl+R, F5 |
| | Rename | Rename | Rename selected item | F2 |
| Selection | SelectAll | Select All | Select all items | Ctrl+A |
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App (Package)/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
IgnorableNamespaces="uap uap5 mp rescap desktop6 desktop4 desktop">
<Identity Name="FilesDev" Publisher="CN=Files" Version="2.4.69.0" />
<Identity Name="FilesDev" Publisher="CN=Files" Version="2.4.70.0" />
<Properties>
<DisplayName>Files - Dev</DisplayName>
<PublisherDisplayName>Yair A</PublisherDisplayName>
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App.Storage/FtpStorage/FtpManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Files.App.Storage.FtpStorage
{
internal static class FtpManager
public static class FtpManager
{
public static readonly Dictionary<string, NetworkCredential> Credentials = new();

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App.Storage/FtpStorage/FtpStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Files.App.Storage.FtpStorage
{
public sealed class FtpStorageService : IStorageService
public sealed class FtpStorageService : IFtpStorageService
{
public Task<bool> IsAccessibleAsync(CancellationToken cancellationToken = default)
{
Expand Down
62 changes: 62 additions & 0 deletions src/Files.App/Actions/FileSystem/AddItemAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Commands;
using Files.App.Contexts;
using Files.App.Extensions;
using Files.App.Helpers;
using Files.Backend.Enums;
using Files.Backend.Services;
using Files.Backend.ViewModels.Dialogs.AddItemDialog;
using System.ComponentModel;
using System.Threading.Tasks;

namespace Files.App.Actions
{
internal class AddItemAction : ObservableObject, IAction
{
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();

private readonly IDialogService dialogService = Ioc.Default.GetRequiredService<IDialogService>();

private readonly AddItemDialogViewModel viewModel = new();

public string Label { get; } = "BaseLayoutContextFlyoutNew/Label".GetLocalizedResource();

public string Description => "AddItemDescription".GetLocalizedResource();

public HotKey HotKey { get; } = new(Keys.N, KeyModifiers.CtrlShift);

public RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconNew");

public bool IsExecutable => context.CanCreateItem && !context.HasSelection;

public AddItemAction()
{
context.PropertyChanged += Context_PropertyChanged;
}

public async Task ExecuteAsync()
{
await dialogService.ShowDialogAsync(viewModel);

if (viewModel.ResultType.ItemType == AddItemDialogItemType.Shortcut)
await Ioc.Default.GetRequiredService<ICommandManager>().CreateShortcutFromDialog.ExecuteAsync();
else if (viewModel.ResultType.ItemType != AddItemDialogItemType.Cancel)
UIFilesystemHelpers.CreateFileFromDialogResultType(
viewModel.ResultType.ItemType,
viewModel.ResultType.ItemInfo,
context.ShellPage!);
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(IContentPageContext.CanCreateItem):
case nameof(IContentPageContext.HasSelection):
OnPropertyChanged(nameof(IsExecutable));
break;
}
}
}
}
11 changes: 8 additions & 3 deletions src/Files.App/Actions/FileSystem/CreateFolderAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class CreateFolderAction : BaseUIAction, IAction

public RichGlyph Glyph { get; } = new RichGlyph(baseGlyph: "\uE8B7");

public override bool IsExecutable => context.ShellPage is not null && UIHelpers.CanShowDialog;
public override bool IsExecutable => context.CanCreateItem && !context.HasSelection && UIHelpers.CanShowDialog;

public CreateFolderAction()
{
Expand All @@ -38,8 +38,13 @@ public Task ExecuteAsync()

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(IContentPageContext.HasSelection))
OnPropertyChanged(nameof(IsExecutable));
switch (e.PropertyName)
{
case nameof(IContentPageContext.CanCreateItem):
case nameof(IContentPageContext.HasSelection):
OnPropertyChanged(nameof(IsExecutable));
break;
}
}
}
}
11 changes: 8 additions & 3 deletions src/Files.App/Actions/FileSystem/CreateShortcutAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class CreateShortcutAction : BaseUIAction, IAction

public RichGlyph Glyph { get; } = new RichGlyph(opacityStyle: "ColorIconShortcut");

public override bool IsExecutable => context.HasSelection && UIHelpers.CanShowDialog;
public override bool IsExecutable => context.HasSelection && context.CanCreateItem && UIHelpers.CanShowDialog;

public CreateShortcutAction()
{
Expand Down Expand Up @@ -51,8 +51,13 @@ public async Task ExecuteAsync()

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(IContentPageContext.HasSelection))
OnPropertyChanged(nameof(IsExecutable));
switch (e.PropertyName)
{
case nameof(IContentPageContext.HasSelection):
case nameof(IContentPageContext.CanCreateItem):
OnPropertyChanged(nameof(IsExecutable));
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal class CreateShortcutFromDialogAction : BaseUIAction, IAction

public RichGlyph Glyph { get; } = new RichGlyph(opacityStyle: "ColorIconShortcut");

public override bool IsExecutable => context.ShellPage is not null && UIHelpers.CanShowDialog;
public override bool IsExecutable => context.CanCreateItem && UIHelpers.CanShowDialog;

public CreateShortcutFromDialogAction()
{
Expand All @@ -30,12 +30,12 @@ public CreateShortcutFromDialogAction()

public async Task ExecuteAsync()
{
await UIFilesystemHelpers.CreateShortcutFromDialogAsync(context.ShellPage);
await UIFilesystemHelpers.CreateShortcutFromDialogAsync(context.ShellPage!);
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(IContentPageContext.ShellPage))
if (e.PropertyName is nameof(IContentPageContext.CanCreateItem))
OnPropertyChanged(nameof(IsExecutable));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/FileSystem/FormatDriveAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Contexts;
using Files.App.DataModels.NavigationControlItems;
using Files.App.Data.Items;
using Files.App.Extensions;
using Files.App.Shell;
using Files.App.ViewModels;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/FileSystem/PasteItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Commands;
using Files.App.Contexts;
using Files.App.DataModels;
using Files.App.Data.Models;
using Files.App.Extensions;
using Files.App.Helpers;
using System.ComponentModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Commands;
using Files.App.Contexts;
using Files.App.DataModels;
using Files.App.Data.Models;
using Files.App.Extensions;
using Files.App.Filesystem;
using Files.App.Helpers;
Expand Down
29 changes: 29 additions & 0 deletions src/Files.App/Actions/Global/EditPathAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Commands;
using Files.App.Contexts;
using Files.App.Extensions;
using System.Threading.Tasks;

namespace Files.App.Actions
{
internal class EditPathAction : IAction
{
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();

public string Label { get; } = "EditPath".GetLocalizedResource();

public string Description { get; } = "EditPathDescription".GetLocalizedResource();

public HotKey HotKey { get; } = new(Keys.L, KeyModifiers.Ctrl);

public HotKey SecondHotKey { get; } = new(Keys.D, KeyModifiers.Menu);

public Task ExecuteAsync()
{
if (context.ShellPage is not null)
context.ShellPage.ToolbarViewModel.IsEditModeEnabled = true;

return Task.CompletedTask;
}
}
}
8 changes: 2 additions & 6 deletions src/Files.App/Actions/Start/UnpinFromStartAction.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Commands;
using Files.App.Contexts;
using Files.App.Extensions;
using Files.App.Filesystem;
using System.Threading.Tasks;

namespace Files.App.Actions
{
Expand All @@ -25,11 +21,11 @@ public async Task ExecuteAsync()
if (context.SelectedItems.Count > 0)
{
foreach (ListedItem listedItem in context.ShellPage?.SlimContentPage.SelectedItems)
await App.SecondaryTileHelper.TryPinFolderAsync(listedItem.ItemPath, listedItem.Name);
await App.SecondaryTileHelper.UnpinFromStartAsync(listedItem.ItemPath);
}
else
{
await App.SecondaryTileHelper.TryPinFolderAsync(context.ShellPage?.FilesystemViewModel.CurrentFolder.ItemPath, context.ShellPage?.FilesystemViewModel.CurrentFolder.Name);
await App.SecondaryTileHelper.UnpinFromStartAsync(context.ShellPage?.FilesystemViewModel.CurrentFolder.ItemPath);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using CommunityToolkit.WinUI.Notifications;
using Files.App.Commands;
using Files.App.Contexts;
using Files.App.DataModels;
using Files.App.Data.Models;
using Files.App.Extensions;
using Files.App.Filesystem;
using Files.App.Filesystem.Cloud;
Expand All @@ -14,6 +14,7 @@
using Files.App.ServicesImplementation.DateTimeFormatter;
using Files.App.ServicesImplementation.Settings;
using Files.App.Shell;
using Files.App.Storage.FtpStorage;
using Files.App.Storage.NativeStorage;
using Files.App.UserControls.MultitaskingControl;
using Files.App.ViewModels;
Expand Down Expand Up @@ -206,6 +207,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
#else
.AddSingleton<IStorageService, NativeStorageService>()
#endif
.AddSingleton<IFtpStorageService, FtpStorageService>()
.AddSingleton<IAddItemService, AddItemService>()
#if STABLE || PREVIEW
.AddSingleton<IUpdateService, SideloadUpdateService>()
Expand Down
29 changes: 14 additions & 15 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.WinUI;
using CommunityToolkit.WinUI.UI;
using Files.App.Filesystem.StorageItems;
using Files.App.Helpers.ContextFlyouts;
Expand All @@ -25,9 +24,9 @@
using Windows.Storage;
using Windows.System;
using static Files.App.Helpers.PathNormalization;
using VA = Vanara.Windows.Shell;
using DispatcherQueueTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;
using SortDirection = Files.Shared.Enums.SortDirection;
using VanaraWindowsShell = Vanara.Windows.Shell;

namespace Files.App
{
Expand Down Expand Up @@ -891,7 +890,7 @@ protected void FileList_DragItemsStarting(object sender, DragItemsStartingEventA
{
try
{
var shellItemList = e.Items.OfType<ListedItem>().Select(x => new VA.ShellItem(x.ItemPath)).ToArray();
var shellItemList = e.Items.OfType<ListedItem>().Select(x => new VanaraWindowsShell.ShellItem(x.ItemPath)).ToArray();
if (shellItemList[0].FileSystemPath is not null && !InstanceViewModel.IsPageTypeSearchResults)
{
var iddo = shellItemList[0].Parent.GetChildrenUIObjects<IDataObject>(HWND.NULL, shellItemList);
Expand Down Expand Up @@ -1353,21 +1352,21 @@ await DispatcherQueue.EnqueueOrInvokeAsync(() =>
showError?.Invoke(false);
}
}
}

public class ContextMenuExtensions : DependencyObject
{
public static ItemsControl GetItemsControl(DependencyObject obj)
public class ContextMenuExtensions : DependencyObject
{
return (ItemsControl)obj.GetValue(ItemsControlProperty);
}
public static ItemsControl GetItemsControl(DependencyObject obj)
{
return (ItemsControl)obj.GetValue(ItemsControlProperty);
}

public static void SetItemsControl(DependencyObject obj, ItemsControl value)
{
obj.SetValue(ItemsControlProperty, value);
}
public static void SetItemsControl(DependencyObject obj, ItemsControl value)
{
obj.SetValue(ItemsControlProperty, value);
}

public static readonly DependencyProperty ItemsControlProperty =
DependencyProperty.RegisterAttached("ItemsControl", typeof(ItemsControl), typeof(ContextMenuExtensions), new PropertyMetadata(null));
public static readonly DependencyProperty ItemsControlProperty =
DependencyProperty.RegisterAttached("ItemsControl", typeof(ItemsControl), typeof(ContextMenuExtensions), new PropertyMetadata(null));
}
}
}
2 changes: 2 additions & 0 deletions src/Files.App/Commands/CommandCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum CommandCodes
ExitCompactOverlay,
ToggleCompactOverlay,
Search,
EditPath,
Redo,
Undo,

Expand All @@ -32,6 +33,7 @@ public enum CommandCodes
DeleteItem,
DeleteItemPermanently,
CreateFolder,
AddItem,
CreateShortcut,
CreateShortcutFromDialog,
EmptyRecycleBin,
Expand Down
Loading

0 comments on commit f282757

Please sign in to comment.