add Node.js file path browser to Settings window

This commit is contained in:
Jeremy 2022-10-25 07:59:31 +11:00
parent 9e55fc5854
commit 9b4a592635
2 changed files with 40 additions and 2 deletions

View file

@ -921,6 +921,25 @@
</ItemsControl>
</Border>
<Border Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource nodeFilePath}" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<TextBox
Width="300"
Height="34"
Text="{Binding Settings.PluginSettings.NodeFilePath, TargetNullValue='No Setting'}" />
<Button
Height="34"
Margin="10,10,18,10"
Click="OnSelectNodeFilePathClick"
Content="{DynamicResource select}" />
</StackPanel>
</ItemsControl>
</Border>
<Border Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">

View file

@ -1,4 +1,4 @@
using Droplex;
using Droplex;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core.Resource;
@ -30,6 +30,7 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using MessageBox = System.Windows.MessageBox;
using TextBox = System.Windows.Controls.TextBox;
using ThemeManager = ModernWpf.ThemeManager;
using OpenFileDialog = System.Windows.Forms.OpenFileDialog;
namespace Flow.Launcher
{
@ -86,7 +87,6 @@ namespace Flow.Launcher
if (File.Exists(pythonPath))
{
settings.PluginSettings.PythonDirectory = pythonDirectory;
MessageBox.Show("Remember to restart Flow Launcher use new Python path");
}
else
{
@ -96,6 +96,25 @@ namespace Flow.Launcher
}
}
private void OnSelectNodeFilePathClick(object sender, RoutedEventArgs e)
{
var dlg = new OpenFileDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
Multiselect = false,
CheckFileExists = true,
CheckPathExists = true,
Title = $"Please select the Node.js executable"
};
var result = dlg.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
Constant.NodePath = dlg.FileName;
settings.PluginSettings.NodeFilePath = Constant.NodePath;
}
}
private void OnSelectFileManagerClick(object sender, RoutedEventArgs e)
{
SelectFileManagerWindow fileManagerChangeWindow = new SelectFileManagerWindow(settings);