2014-04-13 15:38:12 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows;
|
2015-01-03 15:20:34 +08:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using MessageBox = System.Windows.MessageBox;
|
|
|
|
|
using UserControl = System.Windows.Controls.UserControl;
|
2014-04-13 15:38:12 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
namespace Wox.Plugin.Folder
|
|
|
|
|
{
|
2014-06-30 21:31:13 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for FileSystemSettings.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class FileSystemSettings : UserControl
|
|
|
|
|
{
|
2015-01-07 18:59:55 +08:00
|
|
|
|
PluginInitContext context;
|
|
|
|
|
|
|
|
|
|
public FileSystemSettings(PluginInitContext context)
|
2015-01-05 22:41:17 +08:00
|
|
|
|
{
|
2015-01-07 18:59:55 +08:00
|
|
|
|
this.context = context;
|
2015-01-05 22:41:17 +08:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
lbxFolders.ItemsSource = FolderStorage.Instance.FolderLinks;
|
|
|
|
|
}
|
2014-04-13 15:38:12 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
private void btnDelete_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2014-04-13 15:38:12 +08:00
|
|
|
|
var selectedFolder = lbxFolders.SelectedItem as FolderLink;
|
|
|
|
|
if (selectedFolder != null)
|
|
|
|
|
{
|
2015-01-05 22:41:17 +08:00
|
|
|
|
FolderStorage.Instance.FolderLinks.Remove(selectedFolder);
|
2014-04-13 15:38:12 +08:00
|
|
|
|
lbxFolders.Items.Refresh();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-01-07 18:59:55 +08:00
|
|
|
|
string warning = context.API.GetTranslation("wox_plugin_folder_select_folder_link_warning");
|
|
|
|
|
MessageBox.Show(warning);
|
2014-04-13 15:38:12 +08:00
|
|
|
|
}
|
2015-01-05 22:41:17 +08:00
|
|
|
|
}
|
2014-04-13 15:38:12 +08:00
|
|
|
|
|
|
|
|
|
private void btnEdit_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var selectedFolder = lbxFolders.SelectedItem as FolderLink;
|
|
|
|
|
if (selectedFolder != null)
|
|
|
|
|
{
|
2015-01-03 15:20:34 +08:00
|
|
|
|
var folderBrowserDialog = new FolderBrowserDialog();
|
2014-04-13 15:38:12 +08:00
|
|
|
|
folderBrowserDialog.SelectedPath = selectedFolder.Path;
|
2015-01-03 15:20:34 +08:00
|
|
|
|
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
2014-04-13 15:38:12 +08:00
|
|
|
|
{
|
2015-01-05 22:41:17 +08:00
|
|
|
|
var link = FolderStorage.Instance.FolderLinks.First(x => x.Path == selectedFolder.Path);
|
2014-04-13 15:38:12 +08:00
|
|
|
|
link.Path = folderBrowserDialog.SelectedPath;
|
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
FolderStorage.Instance.Save();
|
2014-04-13 15:38:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lbxFolders.Items.Refresh();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-01-07 18:59:55 +08:00
|
|
|
|
string warning = context.API.GetTranslation("wox_plugin_folder_select_folder_link_warning");
|
|
|
|
|
MessageBox.Show(warning);
|
2014-04-13 15:38:12 +08:00
|
|
|
|
}
|
2015-01-05 22:41:17 +08:00
|
|
|
|
}
|
2014-04-13 15:38:12 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
private void btnAdd_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
|
|
|
|
|
if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
var newFolder = new FolderLink()
|
|
|
|
|
{
|
|
|
|
|
Path = folderBrowserDialog.SelectedPath
|
|
|
|
|
};
|
2014-04-13 15:38:12 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
if (FolderStorage.Instance.FolderLinks == null)
|
|
|
|
|
{
|
|
|
|
|
FolderStorage.Instance.FolderLinks = new List<FolderLink>();
|
|
|
|
|
}
|
2014-04-13 15:38:12 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
FolderStorage.Instance.FolderLinks.Add(newFolder);
|
|
|
|
|
FolderStorage.Instance.Save();
|
|
|
|
|
}
|
2014-04-13 15:38:12 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
lbxFolders.Items.Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-13 15:38:12 +08:00
|
|
|
|
}
|