Skip to content

Commit b4b342f

Browse files
committed
Add Layout for Browse button
1 parent 28b6bba commit b4b342f

File tree

1 file changed

+47
-11
lines changed

1 file changed

+47
-11
lines changed

Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using System.Windows.Documents;
2626
using static System.Windows.Forms.LinkLabel;
2727
using Droplex;
28+
using System.Windows.Forms;
2829

2930
namespace Flow.Launcher.Core.Plugin
3031
{
@@ -424,7 +425,7 @@ public Control CreateSettingPanel()
424425
Text = attribute.Description.Replace("\\r\\n", "\r\n"),
425426
Margin = settingTextBlockMargin,
426427
Padding = new Thickness(0,0,0,0),
427-
HorizontalAlignment = HorizontalAlignment.Left,
428+
HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
428429
TextAlignment = TextAlignment.Left,
429430
TextWrapping = TextWrapping.Wrap
430431
};
@@ -444,7 +445,7 @@ public Control CreateSettingPanel()
444445
{
445446
Text = Settings[attribute.Name] as string ?? string.Empty,
446447
Margin = settingControlMargin,
447-
HorizontalAlignment = HorizontalAlignment.Stretch,
448+
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
448449
ToolTip = attribute.Description
449450
};
450451
textBox.TextChanged += (_, _) =>
@@ -461,6 +462,41 @@ public Control CreateSettingPanel()
461462
Grid.SetColumnSpan(sep, 2);
462463
break;
463464
}
465+
case "inputWithFileBtn":
466+
{
467+
var textBox = new TextBox()
468+
{
469+
Margin = new Thickness(10, 0, 0, 0),
470+
Text = Settings[attribute.Name] as string ?? string.Empty,
471+
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
472+
ToolTip = attribute.Description
473+
};
474+
textBox.TextChanged += (_, _) =>
475+
{
476+
Settings[attribute.Name] = textBox.Text;
477+
};
478+
var Btn = new System.Windows.Controls.Button()
479+
{
480+
Margin = new Thickness(10,0,0,0),
481+
Content = "Browse"
482+
};
483+
var dockPanel = new DockPanel()
484+
{
485+
Margin = settingControlMargin
486+
};
487+
DockPanel.SetDock(Btn, Dock.Right);
488+
dockPanel.Children.Add(Btn);
489+
dockPanel.Children.Add(textBox);
490+
contentControl = dockPanel;
491+
Grid.SetColumn(contentControl, 1);
492+
Grid.SetRow(contentControl, rowCount);
493+
if (rowCount != 0)
494+
mainPanel.Children.Add(sep);
495+
Grid.SetRow(sep, rowCount);
496+
Grid.SetColumn(sep, 0);
497+
Grid.SetColumnSpan(sep, 2);
498+
break;
499+
}
464500
case "textarea":
465501
{
466502
var textBox = new TextBox()
@@ -470,7 +506,7 @@ public Control CreateSettingPanel()
470506
VerticalAlignment = VerticalAlignment.Center,
471507
TextWrapping = TextWrapping.WrapWithOverflow,
472508
AcceptsReturn = true,
473-
HorizontalAlignment = HorizontalAlignment.Stretch,
509+
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
474510
Text = Settings[attribute.Name] as string ?? string.Empty,
475511
ToolTip = attribute.Description
476512
};
@@ -495,7 +531,7 @@ public Control CreateSettingPanel()
495531
Margin = settingControlMargin,
496532
Password = Settings[attribute.Name] as string ?? string.Empty,
497533
PasswordChar = attribute.passwordChar == default ? '*' : attribute.passwordChar,
498-
HorizontalAlignment = HorizontalAlignment.Stretch,
534+
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
499535
ToolTip = attribute.Description
500536
};
501537
passwordBox.PasswordChanged += (sender, _) =>
@@ -514,17 +550,17 @@ public Control CreateSettingPanel()
514550
}
515551
case "dropdown":
516552
{
517-
var comboBox = new ComboBox()
553+
var comboBox = new System.Windows.Controls.ComboBox()
518554
{
519555
ItemsSource = attribute.Options,
520556
SelectedItem = Settings[attribute.Name],
521557
Margin = settingControlMargin,
522-
HorizontalAlignment = HorizontalAlignment.Right,
558+
HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
523559
ToolTip = attribute.Description
524560
};
525561
comboBox.SelectionChanged += (sender, _) =>
526562
{
527-
Settings[attribute.Name] = (string)((ComboBox)sender).SelectedItem;
563+
Settings[attribute.Name] = (string)((System.Windows.Controls.ComboBox)sender).SelectedItem;
528564
};
529565
contentControl = comboBox;
530566
Grid.SetColumn(contentControl, 1);
@@ -541,7 +577,7 @@ public Control CreateSettingPanel()
541577
{
542578
IsChecked = Settings[attribute.Name] is bool isChecked ? isChecked : bool.Parse(attribute.DefaultValue),
543579
Margin = settingCheckboxMargin,
544-
HorizontalAlignment = HorizontalAlignment.Right,
580+
HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
545581
ToolTip = attribute.Description
546582
};
547583
checkBox.Click += (sender, _) =>
@@ -563,9 +599,9 @@ public Control CreateSettingPanel()
563599
ToolTip = attribute.Description,
564600
NavigateUri = attribute.url
565601
};
566-
var linkbtn = new Button
602+
var linkbtn = new System.Windows.Controls.Button
567603
{
568-
HorizontalAlignment = HorizontalAlignment.Right,
604+
HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
569605
Margin = settingControlMargin
570606
};
571607
linkbtn.Content = attribute.urlLabel;
@@ -623,7 +659,7 @@ public void UpdateSettings(Dictionary<string, object> settings)
623659
case PasswordBox passwordBox:
624660
passwordBox.Dispatcher.Invoke(() => passwordBox.Password = value as string);
625661
break;
626-
case ComboBox comboBox:
662+
case System.Windows.Controls.ComboBox comboBox:
627663
comboBox.Dispatcher.Invoke(() => comboBox.SelectedItem = value);
628664
break;
629665
case CheckBox checkBox:

0 commit comments

Comments
 (0)