PowerToys/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerLauncherPage.xaml.cs

69 lines
3.0 KiB
C#
Raw Normal View History

// 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;
2020-04-08 15:19:00 +08:00
using System.Collections.ObjectModel;
using System.Linq;
2020-04-08 15:19:00 +08:00
using Microsoft.PowerToys.Settings.UI.ViewModels;
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;
public PowerLauncherPage()
{
this.InitializeComponent();
var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
2020-04-08 15:19:00 +08:00
this.searchResultPreferencesOptions = new ObservableCollection<Tuple<string, string>>();
this.searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_AlphabeticalOrder"), "alphabetical_order"));
this.searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_MostRecentlyUsed"), "most_recently_used"));
this.searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_RunningProcessesOpenApplications"), "running_processes_open_applications"));
2020-04-08 15:19:00 +08:00
this.searchTypePreferencesOptions = new ObservableCollection<Tuple<string, string>>();
this.searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ApplicationName"), "application_name"));
this.searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_StringInApplication"), "string_in_application"));
this.searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ExecutableName"), "executable_name"));
}
public Tuple<string, string> SelectedSearchResultPreference
{
get
{
2020-04-08 15:19:00 +08:00
return this.searchResultPreferencesOptions.First(item => item.Item2 == this.ViewModel.SearchResultPreference);
}
2020-04-08 15:19:00 +08:00
set
{
2020-04-08 15:19:00 +08:00
if (this.ViewModel.SearchResultPreference != value.Item2)
{
2020-04-08 15:19:00 +08:00
this.ViewModel.SearchResultPreference = value.Item2;
}
}
}
public Tuple<string, string> SelectedSearchTypePreference
{
get
{
2020-04-08 15:19:00 +08:00
return this.searchTypePreferencesOptions.First(item => item.Item2 == this.ViewModel.SearchTypePreference);
}
2020-04-08 15:19:00 +08:00
set
{
2020-04-08 15:19:00 +08:00
if (this.ViewModel.SearchTypePreference != value.Item2)
{
2020-04-08 15:19:00 +08:00
this.ViewModel.SearchTypePreference = value.Item2;
}
}
}
}
}