2014-03-30 11:16:44 +08:00
|
|
|
|
using System.Windows;
|
2014-03-29 14:42:43 +08:00
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using Wox.Infrastructure.Storage.UserSettings;
|
|
|
|
|
|
2014-03-30 11:16:44 +08:00
|
|
|
|
namespace Wox.Plugin.SystemPlugins.Program
|
2014-03-29 14:42:43 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for ProgramSetting.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ProgramSetting : UserControl
|
|
|
|
|
{
|
|
|
|
|
public ProgramSetting()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Loaded += Setting_Loaded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
programSourceView.ItemsSource = UserSettingStorage.Instance.ProgramSources;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReloadProgramSourceView()
|
|
|
|
|
{
|
|
|
|
|
programSourceView.Items.Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ProgramSourceSetting programSource = new ProgramSourceSetting(this);
|
|
|
|
|
programSource.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2014-07-10 23:16:46 +08:00
|
|
|
|
ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
|
|
|
|
|
if (selectedProgramSource != null)
|
2014-03-29 14:42:43 +08:00
|
|
|
|
{
|
2014-07-10 23:16:46 +08:00
|
|
|
|
if (MessageBox.Show("Are your sure to delete " + selectedProgramSource.ToString(), "Delete ProgramSource",
|
2014-07-10 23:06:50 +08:00
|
|
|
|
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
|
|
|
|
{
|
2014-07-10 23:16:46 +08:00
|
|
|
|
UserSettingStorage.Instance.ProgramSources.Remove(selectedProgramSource);
|
2014-07-10 23:06:50 +08:00
|
|
|
|
programSourceView.Items.Refresh();
|
|
|
|
|
}
|
2014-03-29 14:42:43 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Please select a program source");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2014-07-10 23:16:46 +08:00
|
|
|
|
ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
|
|
|
|
|
if (selectedProgramSource != null)
|
2014-03-29 14:42:43 +08:00
|
|
|
|
{
|
|
|
|
|
ProgramSourceSetting programSource = new ProgramSourceSetting(this);
|
2014-07-10 23:16:46 +08:00
|
|
|
|
programSource.UpdateItem(selectedProgramSource);
|
2014-03-29 14:42:43 +08:00
|
|
|
|
programSource.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Please select a program source");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|