Add File Select Dialogue

This commit is contained in:
DB p 2021-11-10 08:30:10 +09:00
parent c727150621
commit 07b42ff92c
2 changed files with 44 additions and 11 deletions

View file

@ -88,7 +88,7 @@
Orientation="Horizontal"> Orientation="Horizontal">
<Grid Width="545"> <Grid Width="545">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="220" /> <ColumnDefinition Width="200" />
<ColumnDefinition /> <ColumnDefinition />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -123,16 +123,35 @@
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="14" FontSize="14"
Text="{DynamicResource fileManager_path}" /> Text="{DynamicResource fileManager_path}" />
<TextBox <DockPanel Grid.Row="1" Grid.Column="1">
x:Name="PathTextBox" <TextBox
Grid.Row="1" x:Name="PathTextBox"
Grid.Column="1" Width="230"
Width="Auto" Margin="10,10,10,0"
Margin="10,10,15,0" HorizontalAlignment="Stretch"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
VerticalAlignment="Center" IsEnabled="{Binding Editable}"
IsEnabled="{Binding Editable}" Text="{Binding Path}" />
Text="{Binding Path}" /> <Button
Name="btnBrowseFile"
Width="80"
Margin="0,10,15,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Click="btnBrowseFile_Click"
Content="{DynamicResource selectPythonDirectory}"
DockPanel.Dock="Right">
<Button.Style>
<Style BasedOn="{StaticResource DefaultButtonStyle}" TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ProfileTextBox, UpdateSourceTrigger=PropertyChanged, Path=IsEnabled}" Value="False">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</DockPanel>
<TextBlock <TextBlock
Grid.Row="2" Grid.Row="2"
Grid.Column="0" Grid.Column="0"

View file

@ -73,5 +73,19 @@ namespace Flow.Launcher
{ {
CustomExplorers.RemoveAt(SelectedCustomExplorerIndex--); CustomExplorers.RemoveAt(SelectedCustomExplorerIndex--);
} }
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
TextBox path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");
path.Text = dlg.FileName;
path.Focus();
((Button)sender).Focus();
}
}
} }
} }