/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Views/HomePage.xaml.cs
103 строки
3 KB
yair100
Feature: Added right click context menu to the Home Page (#18233)
09 мар 2026, 08:04
Не верифицирован
09 мар 2026, 08:04
e713a35
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Navigation; namespace Files.App.Views { public sealed partial class HomePage : Page, IDisposable { // Dependency injections private readonly ICommandManager Commands = Ioc.Default.GetRequiredService<ICommandManager>(); public HomeViewModel ViewModel { get; } = Ioc.Default.GetRequiredService<HomeViewModel>(); // Properties private IShellPage AppInstance { get; set; } = null!; // Constructor public HomePage() { InitializeComponent(); } // Methods protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is not NavigationArguments parameters) return; AppInstance = parameters.AssociatedTabInstance!; AppInstance.InstanceViewModel.IsPageTypeNotHome = false; AppInstance.InstanceViewModel.IsPageTypeSearchResults = false; AppInstance.InstanceViewModel.IsPageTypeMtpDevice = false; AppInstance.InstanceViewModel.IsPageTypeRecycleBin = false; AppInstance.InstanceViewModel.IsPageTypeCloudDrive = false; AppInstance.InstanceViewModel.IsPageTypeFtp = false; AppInstance.InstanceViewModel.IsPageTypeZipFolder = false; AppInstance.InstanceViewModel.IsPageTypeLibrary = false; AppInstance.InstanceViewModel.GitRepositoryPath = null; AppInstance.InstanceViewModel.IsGitRepository = false; AppInstance.InstanceViewModel.IsPageTypeReleaseNotes = false; AppInstance.InstanceViewModel.IsPageTypeSettings = false; AppInstance.ToolbarViewModel.CanRefresh = true; AppInstance.ToolbarViewModel.CanGoBack = AppInstance.CanNavigateBackward; AppInstance.ToolbarViewModel.CanGoForward = AppInstance.CanNavigateForward; AppInstance.ToolbarViewModel.CanNavigateToParent = false; // Set path of working directory empty await AppInstance.ShellViewModel.SetWorkingDirectoryAsync("Home"); AppInstance.ShellViewModel.CheckForBackgroundImage(); AppInstance.SlimContentPage?.StatusBarViewModel.UpdateGitInfo(false, string.Empty, null); AppInstance.ToolbarViewModel.PathComponents.Clear(); string componentLabel = parameters?.NavPathParam == "Home" ? Strings.Home.GetLocalizedResource() : parameters?.NavPathParam ?? string.Empty; string tag = parameters?.NavPathParam ?? string.Empty; var item = new PathBoxItem() { Title = componentLabel, Path = tag, ChevronToolTip = string.Format(Strings.BreadcrumbBarChevronButtonToolTip.GetLocalizedResource(), componentLabel), }; AppInstance.ToolbarViewModel.PathComponents.Add(item); base.OnNavigatedTo(e); } private void ScrollViewer_RightTapped(object sender, RightTappedRoutedEventArgs e) { if (sender is FrameworkElement element) HomePageContextMenu.ShowAt(element, e.GetPosition(element)); e.Handled = true; } protected override void OnNavigatedFrom(NavigationEventArgs e) { Dispose(); } // Disposer public void Dispose() { ViewModel?.Dispose(); } } }