mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 03:37:10 +08:00
c589978e84
cc @aaroncampf
74 lines
2.5 KiB
C#
74 lines
2.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using Wox.Infrastructure.Storage.UserSettings;
|
|
|
|
namespace Wox.Plugin.SystemPlugins.FileSystem {
|
|
/// <summary>
|
|
/// Interaction logic for FileSystemSettings.xaml
|
|
/// </summary>
|
|
public partial class FileSystemSettings : UserControl {
|
|
public FileSystemSettings() {
|
|
InitializeComponent();
|
|
lbxFolders.ItemsSource = Wox.Infrastructure.Storage.UserSettings.UserSettingStorage.Instance.FolderLinks;
|
|
}
|
|
|
|
private void btnDelete_Click(object sender, RoutedEventArgs e) {
|
|
var selectedFolder = lbxFolders.SelectedItem as FolderLink;
|
|
if (selectedFolder != null)
|
|
{
|
|
UserSettingStorage.Instance.FolderLinks.Remove(selectedFolder);
|
|
lbxFolders.Items.Refresh();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Please select a folder link!");
|
|
}
|
|
}
|
|
|
|
private void btnEdit_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var selectedFolder = lbxFolders.SelectedItem as FolderLink;
|
|
if (selectedFolder != null)
|
|
{
|
|
|
|
var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
|
|
folderBrowserDialog.SelectedPath = selectedFolder.Path;
|
|
if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
var link = UserSettingStorage.Instance.FolderLinks.First(x => x.Path == selectedFolder.Path);
|
|
link.Path = folderBrowserDialog.SelectedPath;
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
}
|
|
|
|
lbxFolders.Items.Refresh();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Please select a folder link!");
|
|
}
|
|
}
|
|
|
|
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 Wox.Infrastructure.Storage.UserSettings.FolderLink() {
|
|
Path = folderBrowserDialog.SelectedPath
|
|
};
|
|
|
|
if (UserSettingStorage.Instance.FolderLinks == null) {
|
|
UserSettingStorage.Instance.FolderLinks = new List<FolderLink>();
|
|
}
|
|
|
|
UserSettingStorage.Instance.FolderLinks.Add(newFolder);
|
|
UserSettingStorage.Instance.Save();
|
|
}
|
|
|
|
lbxFolders.Items.Refresh();
|
|
}
|
|
}
|
|
}
|