mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Support editing
This commit is contained in:
@@ -8,28 +8,20 @@
|
|||||||
Height="180"
|
Height="180"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
d:DesignHeight="400" d:DesignWidth="300">
|
d:DesignHeight="400" d:DesignWidth="300">
|
||||||
<Grid Margin="10,10,10,0" VerticalAlignment="Top" Height="129" >
|
<StackPanel Orientation="Vertical">
|
||||||
<Grid.RowDefinitions>
|
<StackPanel Orientation="Horizontal">
|
||||||
<RowDefinition></RowDefinition>
|
|
||||||
<RowDefinition></RowDefinition>
|
|
||||||
<RowDefinition></RowDefinition>
|
|
||||||
<RowDefinition></RowDefinition>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
|
||||||
<Label Content="Directory:"/>
|
<Label Content="Directory:"/>
|
||||||
<TextBox Name="Directory" VerticalAlignment="Center" Width="238" Margin="0,7" />
|
<TextBox Name="Directory" VerticalAlignment="Center" Width="238" Margin="0,7" />
|
||||||
<Button Name="BrowseButton" Content="Browse" HorizontalAlignment="Left" VerticalAlignment="Center" Width="75" Click="BrowseButton_Click" />
|
<Button Name="BrowseButton" Content="Browse" HorizontalAlignment="Left" VerticalAlignment="Center" Width="75" Click="BrowseButton_Click" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Label Content="File Suffixes:" />
|
<Label Content="File Suffixes:" />
|
||||||
<TextBox x:Name="Suffixes" VerticalAlignment="Center" Width="297" Margin="0,7" />
|
<TextBox x:Name="Suffixes" VerticalAlignment="Center" Width="297" Margin="0,7" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Label Content="Maximum Search Depth (-1 is unlimited):" />
|
<Label Content="Maximum Search Depth (-1 is unlimited):" />
|
||||||
<TextBox Name="MaxDepth" Text="-1" VerticalAlignment="Center" Width="146" Margin="0,7" />
|
<TextBox Name="MaxDepth" Text="-1" VerticalAlignment="Center" Width="146" Margin="0,7" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="3" Orientation="Horizontal">
|
<Button VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Height="20" Width="70" Click="ButtonAdd_OnClick" Content="{DynamicResource wox_plugin_program_update}" />
|
||||||
<Button VerticalAlignment="Center" Height="20" Width="70" Click="ButtonAdd_OnClick" Content="{DynamicResource wox_plugin_program_update}" Margin="300,0" />
|
</StackPanel>
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -19,14 +19,21 @@ namespace Wox.Plugin.Program
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AddProgramSource
|
public partial class AddProgramSource
|
||||||
{
|
{
|
||||||
private Action reindex;
|
private ProgramSource _editing;
|
||||||
|
|
||||||
public AddProgramSource(Action reindex)
|
public AddProgramSource()
|
||||||
{
|
{
|
||||||
this.reindex = reindex;
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AddProgramSource(ProgramSource edit) : this()
|
||||||
|
{
|
||||||
|
this._editing = edit;
|
||||||
|
this.Directory.Text = this._editing.Location;
|
||||||
|
this.MaxDepth.Text = this._editing.MaxDepth.ToString();
|
||||||
|
this.Suffixes.Text = this._editing.Suffixes;
|
||||||
|
}
|
||||||
|
|
||||||
private void BrowseButton_Click(object sender, RoutedEventArgs e)
|
private void BrowseButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||||
@@ -44,16 +51,27 @@ namespace Wox.Plugin.Program
|
|||||||
{
|
{
|
||||||
max = -1;
|
max = -1;
|
||||||
}
|
}
|
||||||
ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
|
|
||||||
|
if(this._editing == null)
|
||||||
{
|
{
|
||||||
Location = this.Directory.Text,
|
ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
|
||||||
MaxDepth = max,
|
{
|
||||||
Suffixes = this.Suffixes.Text,
|
Location = this.Directory.Text,
|
||||||
Type = "FileSystemProgramSource",
|
MaxDepth = max,
|
||||||
Enabled = true
|
Suffixes = this.Suffixes.Text,
|
||||||
});
|
Type = "FileSystemProgramSource",
|
||||||
|
Enabled = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._editing.Location = this.Directory.Text;
|
||||||
|
this._editing.MaxDepth = max;
|
||||||
|
this._editing.Suffixes = this.Suffixes.Text;
|
||||||
|
}
|
||||||
|
|
||||||
ProgramStorage.Instance.Save();
|
ProgramStorage.Instance.Save();
|
||||||
reindex();
|
this.DialogResult = true;
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,11 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var add = new AddProgramSource(this.ReIndexing);
|
var add = new AddProgramSource();
|
||||||
add.Show();
|
if(add.ShowDialog() ?? false)
|
||||||
|
{
|
||||||
|
this.ReIndexing();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
|
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||||
@@ -69,14 +72,10 @@ namespace Wox.Plugin.Program
|
|||||||
ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
|
ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
|
||||||
if (selectedProgramSource != null)
|
if (selectedProgramSource != null)
|
||||||
{
|
{
|
||||||
//todo: update
|
var add = new AddProgramSource(selectedProgramSource);
|
||||||
var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
|
if (add.ShowDialog() ?? false)
|
||||||
if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
||||||
{
|
{
|
||||||
string path = folderBrowserDialog.SelectedPath;
|
this.ReIndexing();
|
||||||
selectedProgramSource.Location = path;
|
|
||||||
ProgramStorage.Instance.Save();
|
|
||||||
ReIndexing();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user