Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved Sidebar item context menu options from SidebarControl.xaml.cs into INavigationControlItem #8506

Merged
Merged
Show file tree
Hide file tree
Changes from 12 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
9 changes: 9 additions & 0 deletions src/Files.Uwp/DataModels/NavigationControlItems/DriveItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public string SpaceText

public SectionType Section { get; set; }

public SidebarContextMenuOptions MenuOptions { get; set; }
yaira2 marked this conversation as resolved.
Show resolved Hide resolved

private float percentageUsed = 0.0f;

public float PercentageUsed
Expand Down Expand Up @@ -143,6 +145,13 @@ public static async Task<DriveItem> CreateFromPropertiesAsync(StorageFolder root
await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(async () => await item.SetBitmapImage(imageStream));
item.Text = root.DisplayName;
item.Type = type;
item.MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true,
ShowEjectDevice = item.IsRemovable,
ShowShellItems=true,
ShowProperties = true
};
item.Path = string.IsNullOrEmpty(root.Path) ? $"\\\\?\\{root.Name}\\" : root.Path;
item.DeviceID = deviceId;
item.Root = root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public string Path

public SectionType Section { get; set; }

public SidebarContextMenuOptions MenuOptions { get; set; }

public NavigationControlItemType ItemType => NavigationControlItemType.FileTag;

public int CompareTo(INavigationControlItem other) => Text.CompareTo(other.Text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface INavigationControlItem : IComparable<INavigationControlItem>
public string HoverDisplayText { get; }

public NavigationControlItemType ItemType { get; }

public SidebarContextMenuOptions MenuOptions { get; }
}

public enum NavigationControlItemType
Expand All @@ -36,4 +38,25 @@ public enum SectionType
WSL,
FileTag
}

public class SidebarContextMenuOptions
{
public bool IsLibrariesHeader { get; set; }

public bool ShowHideSection { get; set; }

public bool IsLocationItem { get; set; }

public bool ShowUnpinItem { get; set; }

public bool IsItemMovable { get; set; }

public bool ShowProperties { get; set; }

public bool ShowEmptyRecycleBin { get; set; }

public bool ShowEjectDevice { get; set; }

public bool ShowShellItems { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public bool IsExpanded

public SectionType Section { get; set; }

public SidebarContextMenuOptions MenuOptions { get; set; }

public int CompareTo(INavigationControlItem other) => Text.CompareTo(other.Text);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public string Path

public SectionType Section { get; private set; }

public SidebarContextMenuOptions MenuOptions { get; set; }

public int CompareTo(INavigationControlItem other) => Text.CompareTo(other.Text);
}
}
23 changes: 23 additions & 0 deletions src/Files.Uwp/DataModels/SidebarPinnedModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ public async Task ShowHideRecycleBinItemAsync(bool show)
{
Text = ApplicationData.Current.LocalSettings.Values.Get("RecycleBin_Title", "Recycle Bin"),
IsDefaultLocation = true,
MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true,
ShowUnpinItem = true,
ShowShellItems=true,
d2dyno1 marked this conversation as resolved.
Show resolved Hide resolved
ShowEmptyRecycleBin = true
},
Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIHelpers.GetIconResource(Constants.ImageRes.RecycleBin)),
Path = CommonPaths.RecycleBinPath
};
Expand Down Expand Up @@ -260,6 +267,14 @@ public async Task AddItemToSidebarAsync(string path)
Font = MainViewModel.FontName,
Path = path,
Section = SectionType.Favorites,
MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true,
ShowProperties = true,
ShowUnpinItem = true,
ShowShellItems=true,
IsItemMovable = true
},
IsDefaultLocation = false,
Text = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\'))
};
Expand Down Expand Up @@ -327,6 +342,10 @@ public async Task AddAllItemsToSidebar()
{
Text = "Home".GetLocalized(),
Section = SectionType.Home,
MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true
},
Font = MainViewModel.FontName,
IsDefaultLocation = true,
Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => new BitmapImage(new Uri("ms-appx:///Assets/FluentIcons/Home.png"))),
Expand All @@ -337,6 +356,10 @@ public async Task AddAllItemsToSidebar()
{
Text = "SidebarFavorites".GetLocalized(),
Section = SectionType.Favorites,
MenuOptions = new SidebarContextMenuOptions
{
ShowHideSection = true
},
SelectsOnInvoked = false,
Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIHelpers.GetIconResource(Constants.Shell32.QuickAccess)),
Font = MainViewModel.FontName,
Expand Down
14 changes: 12 additions & 2 deletions src/Files.Uwp/Filesystem/CloudDrivesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ public async Task EnumerateDrivesAsync()
{
Text = provider.Name,
Path = provider.SyncFolder,
Type = DriveType.CloudDrive,
Type = DriveType.CloudDrive
};
cloudProviderItem.MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true,
ShowEjectDevice = cloudProviderItem.IsRemovable,
ShowShellItems=true,
ShowProperties = true
};

var iconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(provider.SyncFolder, 24);
if (iconData != null)
{
Expand Down Expand Up @@ -111,6 +117,10 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
{
Text = "SidebarCloudDrives".GetLocalized(),
Section = SectionType.CloudDrives,
MenuOptions = new SidebarContextMenuOptions
{
ShowHideSection = true
},
SelectsOnInvoked = false,
Icon = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/FluentIcons/CloudDrive.png")),
ChildItems = new ObservableCollection<INavigationControlItem>()
Expand Down
4 changes: 4 additions & 0 deletions src/Files.Uwp/Filesystem/Drives.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
{
Text = "Drives".GetLocalized(),
Section = SectionType.Drives,
MenuOptions = new SidebarContextMenuOptions
{
ShowHideSection = true
},
SelectsOnInvoked = false,
Icon = await UIHelpers.GetIconResource(Constants.ImageRes.ThisPC),
ChildItems = new ObservableCollection<INavigationControlItem>()
Expand Down
10 changes: 9 additions & 1 deletion src/Files.Uwp/Filesystem/FileTagsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
{
Text = "FileTags".GetLocalized(),
Section = SectionType.FileTag,
MenuOptions = new SidebarContextMenuOptions
{
ShowHideSection = true
},
SelectsOnInvoked = false,
Icon = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/FluentIcons/FileTags.png")),
ChildItems = new ObservableCollection<INavigationControlItem>()
Expand All @@ -79,7 +83,11 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
{
Text = tag.TagName,
Path = $"tag:{tag.TagName}",
FileTag = tag
FileTag = tag,
MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true
}
});
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/Files.Uwp/Filesystem/LibraryLocationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ public class LibraryLocationItem : LocationItem
public LibraryLocationItem(ShellLibraryItem shellLibrary)
{
Section = SectionType.Library;
MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true,
ShowProperties = true,
ShowShellItems=true,
ShowUnpinItem = (true && !shellLibrary.IsPinned)
};
Text = shellLibrary.DisplayName;
Path = shellLibrary.FullPath;
DefaultSaveFolder = shellLibrary.DefaultSaveFolder;
Folders = shellLibrary.Folders == null ? null : new ReadOnlyCollection<string>(shellLibrary.Folders);
IsDefaultLocation = shellLibrary.IsPinned;

}

public override bool Equals(object obj)
Expand Down
5 changes: 5 additions & 0 deletions src/Files.Uwp/Filesystem/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
{
Text = "SidebarLibraries".GetLocalized(),
Section = SectionType.Library,
MenuOptions = new SidebarContextMenuOptions
{
IsLibrariesHeader = true,
ShowHideSection = true
},
SelectsOnInvoked = false,
Icon = await UIHelpers.GetIconResource(Constants.ImageRes.Libraries),
ChildItems = new ObservableCollection<INavigationControlItem>()
Expand Down
18 changes: 18 additions & 0 deletions src/Files.Uwp/Filesystem/NetworkDrivesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public NetworkDrivesManager()
Type = DriveType.Network,
ItemType = NavigationControlItemType.Drive
};
networkItem.MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true,
ShowShellItems=true,
ShowEjectDevice = networkItem.IsRemovable,
ShowProperties = true
};
lock (drivesList)
{
drivesList.Add(networkItem);
Expand Down Expand Up @@ -81,6 +88,13 @@ public async Task EnumerateDrivesAsync()
Type = DriveType.Network,
ItemType = NavigationControlItemType.Drive
};
networkItem.MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true,
ShowEjectDevice = networkItem.IsRemovable,
ShowShellItems=true,
ShowProperties = true
};
lock (drivesList)
{
if (!drivesList.Any(x => x.Path == networkItem.Path))
Expand Down Expand Up @@ -129,6 +143,10 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
{
Text = "SidebarNetworkDrives".GetLocalized(),
Section = SectionType.Network,
MenuOptions = new SidebarContextMenuOptions
{
ShowHideSection = true
},
SelectsOnInvoked = false,
Icon = await UIHelpers.GetIconResource(Constants.ImageRes.NetworkDrives),
ChildItems = new ObservableCollection<INavigationControlItem>()
Expand Down
10 changes: 9 additions & 1 deletion src/Files.Uwp/Filesystem/WSLDistroManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
{
Text = "WSL".GetLocalized(),
Section = SectionType.WSL,
MenuOptions = new SidebarContextMenuOptions
{
ShowHideSection = true
},
SelectsOnInvoked = false,
Icon = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/WSL/genericpng.png")),
ChildItems = new ObservableCollection<INavigationControlItem>()
Expand Down Expand Up @@ -104,7 +108,11 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
{
Text = folder.DisplayName,
Path = folder.Path,
Logo = logoURI
Logo = logoURI,
MenuOptions = new SidebarContextMenuOptions
{
IsLocationItem = true
}
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Files.Uwp/UserControls/SidebarControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
IsRightTapEnabled="True"
MenuItemsSource="{x:Bind ChildItems}"
PointerPressed="Sidebar_PointerPressed"
RightTapped="NavigationViewLocationItem_RightTapped"
RightTapped="NavigationViewItem_RightTapped"
SelectsOnInvoked="{x:Bind SelectsOnInvoked}"
Tag="{x:Bind Path}"
ToolTipService.ToolTip="{x:Bind HoverDisplayText}">
Expand All @@ -78,7 +78,7 @@
Drop="NavigationViewDriveItem_Drop"
IsRightTapEnabled="True"
PointerPressed="Sidebar_PointerPressed"
RightTapped="NavigationViewDriveItem_RightTapped"
RightTapped="NavigationViewItem_RightTapped"
Tag="{x:Bind Path}"
ToolTipService.ToolTip="{x:Bind HoverDisplayText, Mode=OneWay}"
Visibility="{x:Bind ItemVisibility}">
Expand All @@ -96,7 +96,7 @@
DragEnter="NavigationViewItem_DragEnter"
DragLeave="NavigationViewItem_DragLeave"
PointerPressed="Sidebar_PointerPressed"
RightTapped="NavigationViewWSLItem_RightTapped"
RightTapped="NavigationViewItem_RightTapped"
Tag="{x:Bind Path}"
ToolTipService.ToolTip="{x:Bind HoverDisplayText}">
<muxc:NavigationViewItem.Icon>
Expand All @@ -121,7 +121,7 @@
Drop="NavigationViewFileTag_Drop"
IsRightTapEnabled="True"
PointerPressed="Sidebar_PointerPressed"
RightTapped="NavigationViewFileTagsItem_RightTapped"
RightTapped="NavigationViewItem_RightTapped"
Tag="{x:Bind Path}"
ToolTipService.ToolTip="{x:Bind HoverDisplayText}">
<muxc:NavigationViewItem.Icon>
Expand Down
Loading