Skip to content

Commit 67c9004

Browse files
onesoundstaooceros
authored andcommitted
Add File Select Dialogue
1 parent a2c1233 commit 67c9004

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

Flow.Launcher/SelectFileManagerWindow.xaml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
Orientation="Horizontal">
8989
<Grid Width="545">
9090
<Grid.ColumnDefinitions>
91-
<ColumnDefinition Width="220" />
91+
<ColumnDefinition Width="200" />
9292
<ColumnDefinition />
9393
</Grid.ColumnDefinitions>
9494
<Grid.RowDefinitions>
@@ -123,16 +123,35 @@
123123
VerticalAlignment="Center"
124124
FontSize="14"
125125
Text="{DynamicResource fileManager_path}" />
126-
<TextBox
127-
x:Name="PathTextBox"
128-
Grid.Row="1"
129-
Grid.Column="1"
130-
Width="Auto"
131-
Margin="10,10,15,0"
132-
HorizontalAlignment="Stretch"
133-
VerticalAlignment="Center"
134-
IsEnabled="{Binding Editable}"
135-
Text="{Binding Path}" />
126+
<DockPanel Grid.Row="1" Grid.Column="1">
127+
<TextBox
128+
x:Name="PathTextBox"
129+
Width="230"
130+
Margin="10,10,10,0"
131+
HorizontalAlignment="Stretch"
132+
VerticalAlignment="Center"
133+
IsEnabled="{Binding Editable}"
134+
Text="{Binding Path}" />
135+
<Button
136+
Name="btnBrowseFile"
137+
Width="80"
138+
Margin="0,10,15,0"
139+
HorizontalAlignment="Right"
140+
VerticalAlignment="Center"
141+
Click="btnBrowseFile_Click"
142+
Content="{DynamicResource selectPythonDirectory}"
143+
DockPanel.Dock="Right">
144+
<Button.Style>
145+
<Style BasedOn="{StaticResource DefaultButtonStyle}" TargetType="{x:Type Button}">
146+
<Style.Triggers>
147+
<DataTrigger Binding="{Binding ElementName=ProfileTextBox, UpdateSourceTrigger=PropertyChanged, Path=IsEnabled}" Value="False">
148+
<Setter Property="IsEnabled" Value="False" />
149+
</DataTrigger>
150+
</Style.Triggers>
151+
</Style>
152+
</Button.Style>
153+
</Button>
154+
</DockPanel>
136155
<TextBlock
137156
Grid.Row="2"
138157
Grid.Column="0"

Flow.Launcher/SelectFileManagerWindow.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,19 @@ private void btnDelete_Click(object sender, RoutedEventArgs e)
7373
{
7474
CustomExplorers.RemoveAt(SelectedCustomExplorerIndex--);
7575
}
76+
77+
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
78+
{
79+
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
80+
Nullable<bool> result = dlg.ShowDialog();
81+
82+
if (result == true)
83+
{
84+
TextBox path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");
85+
path.Text = dlg.FileName;
86+
path.Focus();
87+
((Button)sender).Focus();
88+
}
89+
}
7690
}
7791
}

0 commit comments

Comments
 (0)