mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
* Initial commit * Changed some loggers (WIP) * ColorPicker * Add version to all logs * FancyZones * push * PowerOCR and Measuretool * Settings * Hosts + Fix settings * Fix some using statements * FileLocksmith * Fix awake * Fixed Hosts logger * Fix spelling * Remove added submodule * Fiy FileLocksmith and PowerAccent * Fix PowerAccent * Test * Changed logger locic and added ColorPicker * Fixed package * Add documentation * Add locallow capability to Logger and add FancyZones * Fixed FancyZones and added FileLocksmith * Add Hosts * Fixed spelling mistakes * Add MeasureTool * Add MouseJump * Add PowerOCR * Add PowerAccent * Add monaco * Add Settings * Fixed Monaco * Update installer * Update doc/devdocs/logging.md Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> * Update doc/devdocs/logging.md Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> * Update doc/devdocs/logging.md Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> * Update logging.md * Fix unneccesairy includes. --------- Co-authored-by: Dustin L. Howett <dustin@howett.net> Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
129 lines
5.4 KiB
C#
129 lines
5.4 KiB
C#
// 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;
|
|
using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using ManagedCommon;
|
|
using Microsoft.PowerToys.Settings.UI.Helpers;
|
|
using Microsoft.PowerToys.Settings.UI.Library;
|
|
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
|
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using Windows.ApplicationModel.Resources;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Views
|
|
{
|
|
public sealed partial class PowerLauncherPage : Page, IRefreshablePage
|
|
{
|
|
public PowerLauncherViewModel ViewModel { get; set; }
|
|
|
|
private readonly ObservableCollection<Tuple<string, string>> searchResultPreferencesOptions;
|
|
private readonly ObservableCollection<Tuple<string, string>> searchTypePreferencesOptions;
|
|
|
|
private int _lastIPCMessageSentTick;
|
|
|
|
// Keep track of the last IPC Message that was sent.
|
|
private int SendDefaultIPCMessageTimed(string msg)
|
|
{
|
|
_lastIPCMessageSentTick = Environment.TickCount;
|
|
return ShellPage.SendDefaultIPCMessage(msg);
|
|
}
|
|
|
|
public PowerLauncherPage()
|
|
{
|
|
InitializeComponent();
|
|
var settingsUtils = new SettingsUtils();
|
|
_lastIPCMessageSentTick = Environment.TickCount;
|
|
|
|
PowerLauncherSettings settings = SettingsRepository<PowerLauncherSettings>.GetInstance(settingsUtils)?.SettingsConfig;
|
|
ViewModel = new PowerLauncherViewModel(settings, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SendDefaultIPCMessageTimed, App.IsDarkTheme);
|
|
DataContext = ViewModel;
|
|
_ = Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", () =>
|
|
{
|
|
if (Environment.TickCount < _lastIPCMessageSentTick + 500)
|
|
{
|
|
// Don't try to update data from the file if we tried to write to it through IPC in the last 500 milliseconds.
|
|
return;
|
|
}
|
|
|
|
PowerLauncherSettings powerLauncherSettings = null;
|
|
try
|
|
{
|
|
powerLauncherSettings = SettingsRepository<PowerLauncherSettings>.GetInstance(settingsUtils)?.SettingsConfig;
|
|
}
|
|
catch (IOException ex)
|
|
{
|
|
Logger.LogInfo(ex.Message);
|
|
}
|
|
|
|
if (powerLauncherSettings != null && !ViewModel.IsUpToDate(powerLauncherSettings))
|
|
{
|
|
this.DispatcherQueue.TryEnqueue(() =>
|
|
{
|
|
DataContext = ViewModel = new PowerLauncherViewModel(powerLauncherSettings, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, App.IsDarkTheme);
|
|
this.Bindings.Update();
|
|
});
|
|
}
|
|
});
|
|
|
|
var loader = ResourceLoader.GetForViewIndependentUse();
|
|
|
|
searchResultPreferencesOptions = new ObservableCollection<Tuple<string, string>>();
|
|
searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_AlphabeticalOrder"), "alphabetical_order"));
|
|
searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_MostRecentlyUsed"), "most_recently_used"));
|
|
searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_RunningProcessesOpenApplications"), "running_processes_open_applications"));
|
|
|
|
searchTypePreferencesOptions = new ObservableCollection<Tuple<string, string>>();
|
|
searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ApplicationName"), "application_name"));
|
|
searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_StringInApplication"), "string_in_application"));
|
|
searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ExecutableName"), "executable_name"));
|
|
}
|
|
|
|
private void OpenColorsSettings_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
|
{
|
|
Helpers.StartProcessHelper.Start(Helpers.StartProcessHelper.ColorsSettings);
|
|
}
|
|
|
|
public void RefreshEnabledState()
|
|
{
|
|
ViewModel.RefreshEnabledState();
|
|
}
|
|
|
|
/*
|
|
public Tuple<string, string> SelectedSearchResultPreference
|
|
{
|
|
get
|
|
{
|
|
return searchResultPreferencesOptions.First(item => item.Item2 == ViewModel.SearchResultPreference);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (ViewModel.SearchResultPreference != value.Item2)
|
|
{
|
|
ViewModel.SearchResultPreference = value.Item2;
|
|
}
|
|
}
|
|
}
|
|
|
|
public Tuple<string, string> SelectedSearchTypePreference
|
|
{
|
|
get
|
|
{
|
|
return searchTypePreferencesOptions.First(item => item.Item2 == ViewModel.SearchTypePreference);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (ViewModel.SearchTypePreference != value.Item2)
|
|
{
|
|
ViewModel.SearchTypePreference = value.Item2;
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
}
|