/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/Navigation/NextTabAction.cs
54 строки
2 KB
yair100
Code Quality: Add Category, ExtendedLabel, AutomationId and AccessKey to actions (#18308)
27 мар 2026, 00:40
Не верифицирован
27 мар 2026, 00:40
6ef1f17
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; namespace Files.App.Actions { [GeneratedRichCommand] internal sealed partial class NextTabAction : ObservableObject, IAction { private readonly IMultitaskingContext multitaskingContext; private readonly IContentPageContext contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>(); public string Label => Strings.NextTab.GetLocalizedResource(); public string Description => Strings.NextTabDescription.GetLocalizedResource(); public ActionCategory Category => ActionCategory.Navigation; public bool IsExecutable => multitaskingContext.TabCount > 1; public HotKey HotKey => new(Keys.Tab, KeyModifiers.Ctrl); public NextTabAction() { multitaskingContext = Ioc.Default.GetRequiredService<IMultitaskingContext>(); multitaskingContext.PropertyChanged += MultitaskingContext_PropertyChanged; } public async Task ExecuteAsync(object? parameter = null) { App.AppModel.TabStripSelectedIndex = (App.AppModel.TabStripSelectedIndex + 1) % multitaskingContext.TabCount; // Small delay for the UI to load await Task.Delay(500); // Focus the content of the selected tab item (needed for keyboard navigation) contentPageContext.ShellPage!.PaneHolder.FocusActivePane(); } private void MultitaskingContext_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(IMultitaskingContext.TabCount)) OnPropertyChanged(nameof(IsExecutable)); } } }