/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/cmdpal/ext/SamplePagesExtension/SampleUpdatingItemsPage.cs
43 строки
1 KB
Michael Jolley
CmdPal: Null pattern matching based on `is` expression rather than overridable operators (#40972)
18 авг 2025, 14:07
Не верифицирован
18 авг 2025, 14:07
6acb793
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Timers; using Microsoft.CommandPalette.Extensions; using Microsoft.CommandPalette.Extensions.Toolkit; using Microsoft.VisualBasic; namespace SamplePagesExtension; public partial class SampleUpdatingItemsPage : ListPage { private readonly ListItem hourItem = new(new NoOpCommand()); private readonly ListItem minuteItem = new(new NoOpCommand()); private readonly ListItem secondItem = new(new NoOpCommand()); private static Timer timer; public SampleUpdatingItemsPage() { Name = "Open"; Icon = new IconInfo("\uE72C"); } public override IListItem[] GetItems() { if (timer is null) { timer = new Timer(500); timer.Elapsed += (object source, ElapsedEventArgs e) => { var current = DateAndTime.Now; hourItem.Title = $"{current.Hour}"; minuteItem.Title = $"{current.Minute}"; secondItem.Title = $"{current.Second}"; }; timer.AutoReset = true; // Keep repeating timer.Enabled = true; } return [hourItem, minuteItem, secondItem]; } }