2020-04-04 10:02:38 +08:00
|
|
|
// Copyright (c) Microsoft Corporation
|
2020-04-08 01:19:14 +08:00
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
// See the LICENSE file in the project root for more information.
|
2020-03-27 23:58:53 +08:00
|
|
|
using System;
|
2020-04-08 15:19:00 +08:00
|
|
|
using System.Collections.ObjectModel;
|
2020-03-27 23:58:53 +08:00
|
|
|
using System.Linq;
|
2020-04-08 15:19:00 +08:00
|
|
|
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
2020-03-27 23:58:53 +08:00
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Views
|
|
|
|
{
|
|
|
|
public sealed partial class PowerLauncherPage : Page
|
|
|
|
{
|
|
|
|
public PowerLauncherViewModel ViewModel { get; } = new PowerLauncherViewModel();
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
|
|
private readonly ObservableCollection<Tuple<string, string>> searchResultPreferencesOptions;
|
|
|
|
private readonly ObservableCollection<Tuple<string, string>> searchTypePreferencesOptions;
|
2020-03-27 23:58:53 +08:00
|
|
|
|
|
|
|
public PowerLauncherPage()
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
InitializeComponent();
|
2020-04-04 10:02:38 +08:00
|
|
|
|
|
|
|
var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
|
|
|
|
|
2020-04-11 06:22:07 +08:00
|
|
|
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"));
|
2020-04-04 10:02:38 +08:00
|
|
|
|
2020-04-11 06:22:07 +08:00
|
|
|
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"));
|
2020-04-04 10:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public Tuple<string, string> SelectedSearchResultPreference
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
return searchResultPreferencesOptions.First(item => item.Item2 == ViewModel.SearchResultPreference);
|
2020-04-04 10:02:38 +08:00
|
|
|
}
|
2020-04-08 15:19:00 +08:00
|
|
|
|
2020-04-04 10:02:38 +08:00
|
|
|
set
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
if (ViewModel.SearchResultPreference != value.Item2)
|
2020-04-04 10:02:38 +08:00
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
ViewModel.SearchResultPreference = value.Item2;
|
2020-04-04 10:02:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Tuple<string, string> SelectedSearchTypePreference
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
return searchTypePreferencesOptions.First(item => item.Item2 == ViewModel.SearchTypePreference);
|
2020-04-04 10:02:38 +08:00
|
|
|
}
|
2020-04-08 15:19:00 +08:00
|
|
|
|
2020-04-04 10:02:38 +08:00
|
|
|
set
|
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
if (ViewModel.SearchTypePreference != value.Item2)
|
2020-04-04 10:02:38 +08:00
|
|
|
{
|
2020-04-11 06:22:07 +08:00
|
|
|
ViewModel.SearchTypePreference = value.Item2;
|
2020-04-04 10:02:38 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-27 23:58:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|