From 101955fc01d037615d48e3622dabf8d7ded28c13 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 9 Dec 2022 17:46:11 +0900 Subject: [PATCH 1/7] - Adjust JsonRPCplugin Panel Layout - Adjust System Plugin Setting Panel Margin --- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 75 +++++++++++++------ .../Flow.Launcher.Plugin.Sys/SysSettings.xaml | 70 +++++++++-------- .../SysSettings.xaml.cs | 13 ++++ 3 files changed, 105 insertions(+), 53 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index e3efcd296c4..28a79da5ba2 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -340,9 +340,10 @@ public virtual async Task InitAsync(PluginInitContext context) this.context = context; await InitSettingAsync(); } - private static readonly Thickness settingControlMargin = new(10, 4, 10, 4); - private static readonly Thickness settingPanelMargin = new(15, 20, 15, 20); - private static readonly Thickness settingTextBlockMargin = new(10, 4, 10, 4); + private static readonly Thickness settingControlMargin = new(0, 6, 0, 6); + private static readonly Thickness settingPanelMargin = new(70, 18, 18, 18); + private static readonly Thickness settingTextBlockMargin = new(0, 6, 0, 6); + private static readonly Thickness settingLabelMargin = new(0, 0, 18, 0); private JsonRpcConfigurationModel _settingsTemplate; public Control CreateSettingPanel() @@ -350,26 +351,35 @@ public Control CreateSettingPanel() if (Settings == null) return new(); var settingWindow = new UserControl(); - var mainPanel = new StackPanel + var mainPanel = new Grid { - Margin = settingPanelMargin, Orientation = Orientation.Vertical + Margin = settingPanelMargin }; + ColumnDefinition gridCol1 = new ColumnDefinition() { Width = GridLength.Auto }; + ColumnDefinition gridCol2 = new ColumnDefinition(); + gridCol2.Width = new GridLength(75, GridUnitType.Star); + mainPanel.ColumnDefinitions.Add(gridCol1); + mainPanel.ColumnDefinitions.Add(gridCol2); + settingWindow.Content = mainPanel; - + int rowCount = 0; foreach (var (type, attribute) in _settingsTemplate.Body) { - var panel = new StackPanel - { - Orientation = Orientation.Horizontal, Margin = settingControlMargin - }; + //var panel = new StackPanel + //{ + //Orientation = Orientation.Horizontal, Margin = settingControlMargin + //}; + RowDefinition gridRow = new RowDefinition(); + mainPanel.RowDefinitions.Add(gridRow); var name = new TextBlock() { Text = attribute.Label, - Width = 120, VerticalAlignment = VerticalAlignment.Center, - Margin = settingControlMargin, + Margin = settingLabelMargin, TextWrapping = TextWrapping.WrapWithOverflow }; + Grid.SetColumn(name, 0); + Grid.SetRow(name, rowCount); FrameworkElement contentControl; @@ -381,10 +391,15 @@ public Control CreateSettingPanel() { Text = attribute.Description.Replace("\\r\\n", "\r\n"), Margin = settingTextBlockMargin, - MaxWidth = 500, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Left, + TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.WrapWithOverflow }; - break; + Grid.SetColumn(contentControl, 0); + Grid.SetColumnSpan(contentControl, 2); + Grid.SetRow(contentControl, rowCount); + break; } case "input": { @@ -393,6 +408,7 @@ public Control CreateSettingPanel() Width = 300, Text = Settings[attribute.Name] as string ?? string.Empty, Margin = settingControlMargin, + HorizontalAlignment = HorizontalAlignment.Left, ToolTip = attribute.Description }; textBox.TextChanged += (_, _) => @@ -400,7 +416,9 @@ public Control CreateSettingPanel() Settings[attribute.Name] = textBox.Text; }; contentControl = textBox; - break; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + break; } case "textarea": { @@ -411,6 +429,7 @@ public Control CreateSettingPanel() Margin = settingControlMargin, TextWrapping = TextWrapping.WrapWithOverflow, AcceptsReturn = true, + HorizontalAlignment = HorizontalAlignment.Left, Text = Settings[attribute.Name] as string ?? string.Empty, ToolTip = attribute.Description }; @@ -419,7 +438,9 @@ public Control CreateSettingPanel() Settings[attribute.Name] = ((TextBox)sender).Text; }; contentControl = textBox; - break; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + break; } case "passwordBox": { @@ -429,6 +450,7 @@ public Control CreateSettingPanel() Margin = settingControlMargin, Password = Settings[attribute.Name] as string ?? string.Empty, PasswordChar = attribute.passwordChar == default ? '*' : attribute.passwordChar, + HorizontalAlignment = HorizontalAlignment.Left, ToolTip = attribute.Description }; passwordBox.PasswordChanged += (sender, _) => @@ -436,7 +458,9 @@ public Control CreateSettingPanel() Settings[attribute.Name] = ((PasswordBox)sender).Password; }; contentControl = passwordBox; - break; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + break; } case "dropdown": { @@ -445,6 +469,7 @@ public Control CreateSettingPanel() ItemsSource = attribute.Options, SelectedItem = Settings[attribute.Name], Margin = settingControlMargin, + HorizontalAlignment = HorizontalAlignment.Left, ToolTip = attribute.Description }; comboBox.SelectionChanged += (sender, _) => @@ -452,13 +477,16 @@ public Control CreateSettingPanel() Settings[attribute.Name] = (string)((ComboBox)sender).SelectedItem; }; contentControl = comboBox; - break; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + break; } case "checkbox": var checkBox = new CheckBox { IsChecked = Settings[attribute.Name] is bool isChecked ? isChecked : bool.Parse(attribute.DefaultValue), Margin = settingControlMargin, + HorizontalAlignment = HorizontalAlignment.Left, ToolTip = attribute.Description }; checkBox.Click += (sender, _) => @@ -466,15 +494,20 @@ public Control CreateSettingPanel() Settings[attribute.Name] = ((CheckBox)sender).IsChecked; }; contentControl = checkBox; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); break; default: continue; } if (type != "textBlock") _settingControls[attribute.Name] = contentControl; - panel.Children.Add(name); - panel.Children.Add(contentControl); - mainPanel.Children.Add(panel); + //panel.Children.Add(name); + //panel.Children.Add(contentControl); + //mainPanel.Children.Add(panel); + mainPanel.Children.Add(name); + mainPanel.Children.Add(contentControl); + rowCount++; } return settingWindow; } diff --git a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml index 66aa34b2a19..f806900dedc 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml @@ -1,33 +1,39 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs index cdcc977a9a9..b5f1531c3a2 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Windows; using System.Windows.Controls; namespace Flow.Launcher.Plugin.Sys @@ -14,5 +15,17 @@ public SysSettings(List Results) lbxCommands.Items.Add(Result); } } + private void ListView_SizeChanged(object sender, SizeChangedEventArgs e) + { + ListView listView = sender as ListView; + GridView gView = listView.View as GridView; + + var workingWidth = listView.ActualWidth - SystemParameters.VerticalScrollBarWidth; // take into account vertical scrollbar + var col1 = 0.3; + var col2 = 0.7; + + gView.Columns[0].Width = workingWidth * col1; + gView.Columns[1].Width = workingWidth * col2; + } } } From b1768b5abf67c18ea3f79785ae90ba42849b74be Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 9 Dec 2022 17:46:11 +0900 Subject: [PATCH 2/7] - Adjust JsonRPCplugin Panel Layout - Adjust System Plugin Setting Panel Margin --- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 72 +++++++++++++------ .../Flow.Launcher.Plugin.Sys/SysSettings.xaml | 70 +++++++++--------- .../SysSettings.xaml.cs | 13 ++++ 3 files changed, 102 insertions(+), 53 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index e3efcd296c4..a39ef6790ff 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -340,9 +340,10 @@ public virtual async Task InitAsync(PluginInitContext context) this.context = context; await InitSettingAsync(); } - private static readonly Thickness settingControlMargin = new(10, 4, 10, 4); - private static readonly Thickness settingPanelMargin = new(15, 20, 15, 20); - private static readonly Thickness settingTextBlockMargin = new(10, 4, 10, 4); + private static readonly Thickness settingControlMargin = new(0, 6, 0, 6); + private static readonly Thickness settingPanelMargin = new(70, 18, 18, 18); + private static readonly Thickness settingTextBlockMargin = new(0, 6, 0, 6); + private static readonly Thickness settingLabelMargin = new(0, 0, 18, 0); private JsonRpcConfigurationModel _settingsTemplate; public Control CreateSettingPanel() @@ -350,26 +351,35 @@ public Control CreateSettingPanel() if (Settings == null) return new(); var settingWindow = new UserControl(); - var mainPanel = new StackPanel + var mainPanel = new Grid { - Margin = settingPanelMargin, Orientation = Orientation.Vertical + Margin = settingPanelMargin }; + ColumnDefinition gridCol1 = new ColumnDefinition() { Width = GridLength.Auto }; + ColumnDefinition gridCol2 = new ColumnDefinition(); + gridCol2.Width = new GridLength(75, GridUnitType.Star); + mainPanel.ColumnDefinitions.Add(gridCol1); + mainPanel.ColumnDefinitions.Add(gridCol2); + settingWindow.Content = mainPanel; - + int rowCount = 0; foreach (var (type, attribute) in _settingsTemplate.Body) { - var panel = new StackPanel - { - Orientation = Orientation.Horizontal, Margin = settingControlMargin - }; + //var panel = new StackPanel + //{ + //Orientation = Orientation.Horizontal, Margin = settingControlMargin + //}; + RowDefinition gridRow = new RowDefinition(); + mainPanel.RowDefinitions.Add(gridRow); var name = new TextBlock() { Text = attribute.Label, - Width = 120, VerticalAlignment = VerticalAlignment.Center, - Margin = settingControlMargin, + Margin = settingLabelMargin, TextWrapping = TextWrapping.WrapWithOverflow }; + Grid.SetColumn(name, 0); + Grid.SetRow(name, rowCount); FrameworkElement contentControl; @@ -381,10 +391,15 @@ public Control CreateSettingPanel() { Text = attribute.Description.Replace("\\r\\n", "\r\n"), Margin = settingTextBlockMargin, - MaxWidth = 500, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Left, + TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.WrapWithOverflow }; - break; + Grid.SetColumn(contentControl, 0); + Grid.SetColumnSpan(contentControl, 2); + Grid.SetRow(contentControl, rowCount); + break; } case "input": { @@ -393,6 +408,7 @@ public Control CreateSettingPanel() Width = 300, Text = Settings[attribute.Name] as string ?? string.Empty, Margin = settingControlMargin, + HorizontalAlignment = HorizontalAlignment.Left, ToolTip = attribute.Description }; textBox.TextChanged += (_, _) => @@ -400,7 +416,9 @@ public Control CreateSettingPanel() Settings[attribute.Name] = textBox.Text; }; contentControl = textBox; - break; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + break; } case "textarea": { @@ -411,6 +429,7 @@ public Control CreateSettingPanel() Margin = settingControlMargin, TextWrapping = TextWrapping.WrapWithOverflow, AcceptsReturn = true, + HorizontalAlignment = HorizontalAlignment.Left, Text = Settings[attribute.Name] as string ?? string.Empty, ToolTip = attribute.Description }; @@ -419,7 +438,9 @@ public Control CreateSettingPanel() Settings[attribute.Name] = ((TextBox)sender).Text; }; contentControl = textBox; - break; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + break; } case "passwordBox": { @@ -429,6 +450,7 @@ public Control CreateSettingPanel() Margin = settingControlMargin, Password = Settings[attribute.Name] as string ?? string.Empty, PasswordChar = attribute.passwordChar == default ? '*' : attribute.passwordChar, + HorizontalAlignment = HorizontalAlignment.Left, ToolTip = attribute.Description }; passwordBox.PasswordChanged += (sender, _) => @@ -436,7 +458,9 @@ public Control CreateSettingPanel() Settings[attribute.Name] = ((PasswordBox)sender).Password; }; contentControl = passwordBox; - break; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + break; } case "dropdown": { @@ -445,6 +469,7 @@ public Control CreateSettingPanel() ItemsSource = attribute.Options, SelectedItem = Settings[attribute.Name], Margin = settingControlMargin, + HorizontalAlignment = HorizontalAlignment.Left, ToolTip = attribute.Description }; comboBox.SelectionChanged += (sender, _) => @@ -452,13 +477,16 @@ public Control CreateSettingPanel() Settings[attribute.Name] = (string)((ComboBox)sender).SelectedItem; }; contentControl = comboBox; - break; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + break; } case "checkbox": var checkBox = new CheckBox { IsChecked = Settings[attribute.Name] is bool isChecked ? isChecked : bool.Parse(attribute.DefaultValue), Margin = settingControlMargin, + HorizontalAlignment = HorizontalAlignment.Left, ToolTip = attribute.Description }; checkBox.Click += (sender, _) => @@ -466,15 +494,17 @@ public Control CreateSettingPanel() Settings[attribute.Name] = ((CheckBox)sender).IsChecked; }; contentControl = checkBox; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); break; default: continue; } if (type != "textBlock") _settingControls[attribute.Name] = contentControl; - panel.Children.Add(name); - panel.Children.Add(contentControl); - mainPanel.Children.Add(panel); + mainPanel.Children.Add(name); + mainPanel.Children.Add(contentControl); + rowCount++; } return settingWindow; } diff --git a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml index 66aa34b2a19..f806900dedc 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml @@ -1,33 +1,39 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs index cdcc977a9a9..b5f1531c3a2 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Windows; using System.Windows.Controls; namespace Flow.Launcher.Plugin.Sys @@ -14,5 +15,17 @@ public SysSettings(List Results) lbxCommands.Items.Add(Result); } } + private void ListView_SizeChanged(object sender, SizeChangedEventArgs e) + { + ListView listView = sender as ListView; + GridView gView = listView.View as GridView; + + var workingWidth = listView.ActualWidth - SystemParameters.VerticalScrollBarWidth; // take into account vertical scrollbar + var col1 = 0.3; + var col2 = 0.7; + + gView.Columns[0].Width = workingWidth * col1; + gView.Columns[1].Width = workingWidth * col2; + } } } From ba3ed35699953fc95a370bda2db5b24611231b3c Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 10 Dec 2022 08:04:56 +0900 Subject: [PATCH 3/7] - Adjust JsonRPC Panel Design --- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 104 ++++++++++++++++----- 1 file changed, 80 insertions(+), 24 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index a39ef6790ff..3b809db2a85 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -340,10 +340,13 @@ public virtual async Task InitAsync(PluginInitContext context) this.context = context; await InitSettingAsync(); } - private static readonly Thickness settingControlMargin = new(0, 6, 0, 6); - private static readonly Thickness settingPanelMargin = new(70, 18, 18, 18); - private static readonly Thickness settingTextBlockMargin = new(0, 6, 0, 6); - private static readonly Thickness settingLabelMargin = new(0, 0, 18, 0); + private static readonly Thickness settingControlMargin = new(0, 9, 18, 9); + private static readonly Thickness settingCheckboxMargin = new(0, 9, 9, 9); + private static readonly Thickness settingPanelMargin = new(0, 0, 0, 0); + private static readonly Thickness settingTextBlockMargin = new(70, 17, 18, 0); + private static readonly Thickness settingLabelMargin = new(70, 0, 18, 0); + private static readonly Thickness settingDescMargin = new(70, 0, 18, 0); + private static readonly Thickness settingSepMargin = new(0, 0, 0, 2); private JsonRpcConfigurationModel _settingsTemplate; public Control CreateSettingPanel() @@ -355,20 +358,25 @@ public Control CreateSettingPanel() { Margin = settingPanelMargin }; - ColumnDefinition gridCol1 = new ColumnDefinition() { Width = GridLength.Auto }; + ColumnDefinition gridCol1 = new ColumnDefinition(); ColumnDefinition gridCol2 = new ColumnDefinition(); - gridCol2.Width = new GridLength(75, GridUnitType.Star); + + gridCol1.Width = new GridLength(70, GridUnitType.Star); + gridCol2.Width = new GridLength(30, GridUnitType.Star); mainPanel.ColumnDefinitions.Add(gridCol1); mainPanel.ColumnDefinitions.Add(gridCol2); - settingWindow.Content = mainPanel; int rowCount = 0; foreach (var (type, attribute) in _settingsTemplate.Body) { - //var panel = new StackPanel - //{ - //Orientation = Orientation.Horizontal, Margin = settingControlMargin - //}; + Separator sep = new Separator(); + sep.VerticalAlignment = VerticalAlignment.Top; + sep.Margin = settingSepMargin; + sep.SetResourceReference(Separator.BackgroundProperty, "Color03B"); /* for theme change */ + var panel = new StackPanel + { + Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Center + }; RowDefinition gridRow = new RowDefinition(); mainPanel.RowDefinitions.Add(gridRow); var name = new TextBlock() @@ -378,8 +386,27 @@ public Control CreateSettingPanel() Margin = settingLabelMargin, TextWrapping = TextWrapping.WrapWithOverflow }; - Grid.SetColumn(name, 0); - Grid.SetRow(name, rowCount); + var desc = new TextBlock() + { + Text = attribute.Description, FontSize = 12, + VerticalAlignment = VerticalAlignment.Center,Margin = settingDescMargin, + TextWrapping = TextWrapping.WrapWithOverflow + }; + desc.SetResourceReference(TextBlock.ForegroundProperty, "Color04B"); + + if (attribute.Description == null) /* if no description, hide */ + desc.Visibility = Visibility.Collapsed; + + + if (type != "textBlock") /* if textBlock, hide desc */ + { + panel.Children.Add(name); + panel.Children.Add(desc); + } + + + Grid.SetColumn(panel, 0); + Grid.SetRow(panel, rowCount); FrameworkElement contentControl; @@ -391,7 +418,7 @@ public Control CreateSettingPanel() { Text = attribute.Description.Replace("\\r\\n", "\r\n"), Margin = settingTextBlockMargin, - VerticalAlignment = VerticalAlignment.Center, + VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left, TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.WrapWithOverflow @@ -399,16 +426,20 @@ public Control CreateSettingPanel() Grid.SetColumn(contentControl, 0); Grid.SetColumnSpan(contentControl, 2); Grid.SetRow(contentControl, rowCount); + if (rowCount != 0) + mainPanel.Children.Add(sep); + Grid.SetRow(sep, rowCount); + Grid.SetColumn(sep, 0); + Grid.SetColumnSpan(sep, 2); break; } case "input": { var textBox = new TextBox() { - Width = 300, Text = Settings[attribute.Name] as string ?? string.Empty, Margin = settingControlMargin, - HorizontalAlignment = HorizontalAlignment.Left, + HorizontalAlignment = HorizontalAlignment.Stretch, ToolTip = attribute.Description }; textBox.TextChanged += (_, _) => @@ -418,18 +449,23 @@ public Control CreateSettingPanel() contentControl = textBox; Grid.SetColumn(contentControl, 1); Grid.SetRow(contentControl, rowCount); + if (rowCount != 0) + mainPanel.Children.Add(sep); + Grid.SetRow(sep, rowCount); + Grid.SetColumn(sep, 0); + Grid.SetColumnSpan(sep, 2); break; } case "textarea": { var textBox = new TextBox() { - Width = 300, Height = 120, Margin = settingControlMargin, + VerticalAlignment = VerticalAlignment.Center, TextWrapping = TextWrapping.WrapWithOverflow, AcceptsReturn = true, - HorizontalAlignment = HorizontalAlignment.Left, + HorizontalAlignment = HorizontalAlignment.Stretch, Text = Settings[attribute.Name] as string ?? string.Empty, ToolTip = attribute.Description }; @@ -440,17 +476,21 @@ public Control CreateSettingPanel() contentControl = textBox; Grid.SetColumn(contentControl, 1); Grid.SetRow(contentControl, rowCount); + if (rowCount != 0) + mainPanel.Children.Add(sep); + Grid.SetRow(sep, rowCount); + Grid.SetColumn(sep, 0); + Grid.SetColumnSpan(sep, 2); break; } case "passwordBox": { var passwordBox = new PasswordBox() { - Width = 300, Margin = settingControlMargin, Password = Settings[attribute.Name] as string ?? string.Empty, PasswordChar = attribute.passwordChar == default ? '*' : attribute.passwordChar, - HorizontalAlignment = HorizontalAlignment.Left, + HorizontalAlignment = HorizontalAlignment.Stretch, ToolTip = attribute.Description }; passwordBox.PasswordChanged += (sender, _) => @@ -460,6 +500,11 @@ public Control CreateSettingPanel() contentControl = passwordBox; Grid.SetColumn(contentControl, 1); Grid.SetRow(contentControl, rowCount); + if (rowCount != 0) + mainPanel.Children.Add(sep); + Grid.SetRow(sep, rowCount); + Grid.SetColumn(sep, 0); + Grid.SetColumnSpan(sep, 2); break; } case "dropdown": @@ -469,7 +514,7 @@ public Control CreateSettingPanel() ItemsSource = attribute.Options, SelectedItem = Settings[attribute.Name], Margin = settingControlMargin, - HorizontalAlignment = HorizontalAlignment.Left, + HorizontalAlignment = HorizontalAlignment.Right, ToolTip = attribute.Description }; comboBox.SelectionChanged += (sender, _) => @@ -479,14 +524,19 @@ public Control CreateSettingPanel() contentControl = comboBox; Grid.SetColumn(contentControl, 1); Grid.SetRow(contentControl, rowCount); + if (rowCount != 0) + mainPanel.Children.Add(sep); + Grid.SetRow(sep, rowCount); + Grid.SetColumn(sep, 0); + Grid.SetColumnSpan(sep, 2); break; } case "checkbox": var checkBox = new CheckBox { IsChecked = Settings[attribute.Name] is bool isChecked ? isChecked : bool.Parse(attribute.DefaultValue), - Margin = settingControlMargin, - HorizontalAlignment = HorizontalAlignment.Left, + Margin = settingCheckboxMargin, + HorizontalAlignment = HorizontalAlignment.Right, ToolTip = attribute.Description }; checkBox.Click += (sender, _) => @@ -496,15 +546,21 @@ public Control CreateSettingPanel() contentControl = checkBox; Grid.SetColumn(contentControl, 1); Grid.SetRow(contentControl, rowCount); + if (rowCount != 0) + mainPanel.Children.Add(sep); + Grid.SetRow(sep, rowCount); + Grid.SetColumn(sep, 0); + Grid.SetColumnSpan(sep, 2); break; default: continue; } if (type != "textBlock") _settingControls[attribute.Name] = contentControl; - mainPanel.Children.Add(name); + mainPanel.Children.Add(panel); mainPanel.Children.Add(contentControl); rowCount++; + } return settingWindow; } From 27016c4f2daea4bd85c86451af0a0a8a70490a64 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 10 Dec 2022 09:53:41 +0900 Subject: [PATCH 4/7] Add hyperlink layout --- .../Plugin/JsonRPCConfigurationModel.cs | 7 +++-- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 26 ++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCConfigurationModel.cs b/Flow.Launcher.Core/Plugin/JsonRPCConfigurationModel.cs index 1f63f85a806..6dc4be881a8 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCConfigurationModel.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCConfigurationModel.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace Flow.Launcher.Core.Plugin { @@ -26,6 +27,8 @@ public class FieldAttributes public string Name { get; set; } public string Label { get; set; } public string Description { get; set; } + public string urlLabel { get; set; } + public Uri url { get; set; } public bool Validation { get; set; } public List Options { get; set; } public string DefaultValue { get; set; } @@ -40,4 +43,4 @@ public void Deconstruct(out string Name, out string Label, out string Descriptio DefaultValue = this.DefaultValue; } } -} \ No newline at end of file +} diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index 3b809db2a85..91d7d662ae6 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -22,6 +22,9 @@ using Orientation = System.Windows.Controls.Orientation; using TextBox = System.Windows.Controls.TextBox; using UserControl = System.Windows.Controls.UserControl; +using System.Windows.Documents; +using static System.Windows.Forms.LinkLabel; +using Droplex; namespace Flow.Launcher.Core.Plugin { @@ -33,7 +36,6 @@ internal abstract class JsonRPCPlugin : IAsyncPlugin, IContextMenu, ISettingProv { protected PluginInitContext context; public const string JsonRPC = "JsonRPC"; - /// /// The language this JsonRPCPlugin support /// @@ -552,6 +554,28 @@ public Control CreateSettingPanel() Grid.SetColumn(sep, 0); Grid.SetColumnSpan(sep, 2); break; + case "hyperlink": + var hyperlink = new Hyperlink + { + ToolTip = attribute.Description, + NavigateUri = attribute.url + }; + var linkbtn = new Button + { + HorizontalAlignment = HorizontalAlignment.Right, + Margin = settingControlMargin + }; + linkbtn.Content = attribute.urlLabel; + + contentControl = linkbtn; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + if (rowCount != 0) + mainPanel.Children.Add(sep); + Grid.SetRow(sep, rowCount); + Grid.SetColumn(sep, 0); + Grid.SetColumnSpan(sep, 2); + break; default: continue; } From 28b6bba4389a9f7ef1419f04a1cf20a142e812b2 Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 11 Dec 2022 12:29:17 +0900 Subject: [PATCH 5/7] Adjust TextBlock --- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index 91d7d662ae6..2b42befe03f 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -345,9 +345,10 @@ public virtual async Task InitAsync(PluginInitContext context) private static readonly Thickness settingControlMargin = new(0, 9, 18, 9); private static readonly Thickness settingCheckboxMargin = new(0, 9, 9, 9); private static readonly Thickness settingPanelMargin = new(0, 0, 0, 0); - private static readonly Thickness settingTextBlockMargin = new(70, 17, 18, 0); - private static readonly Thickness settingLabelMargin = new(70, 0, 18, 0); - private static readonly Thickness settingDescMargin = new(70, 0, 18, 0); + private static readonly Thickness settingTextBlockMargin = new(70, 9, 18, 9); + private static readonly Thickness settingLabelPanelMargin = new(70, 9, 18, 9); + private static readonly Thickness settingLabelMargin = new(0, 0, 0, 0); + private static readonly Thickness settingDescMargin = new(0, 2, 0, 0); private static readonly Thickness settingSepMargin = new(0, 0, 0, 2); private JsonRpcConfigurationModel _settingsTemplate; @@ -358,7 +359,7 @@ public Control CreateSettingPanel() var settingWindow = new UserControl(); var mainPanel = new Grid { - Margin = settingPanelMargin + Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center }; ColumnDefinition gridCol1 = new ColumnDefinition(); ColumnDefinition gridCol2 = new ColumnDefinition(); @@ -377,7 +378,9 @@ public Control CreateSettingPanel() sep.SetResourceReference(Separator.BackgroundProperty, "Color03B"); /* for theme change */ var panel = new StackPanel { - Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Center + Background = System.Windows.SystemColors.GrayTextBrush, + Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Center, + Margin = settingLabelPanelMargin }; RowDefinition gridRow = new RowDefinition(); mainPanel.RowDefinitions.Add(gridRow); @@ -420,10 +423,10 @@ public Control CreateSettingPanel() { Text = attribute.Description.Replace("\\r\\n", "\r\n"), Margin = settingTextBlockMargin, - VerticalAlignment = VerticalAlignment.Stretch, + Padding = new Thickness(0,0,0,0), HorizontalAlignment = HorizontalAlignment.Left, TextAlignment = TextAlignment.Left, - TextWrapping = TextWrapping.WrapWithOverflow + TextWrapping = TextWrapping.Wrap }; Grid.SetColumn(contentControl, 0); Grid.SetColumnSpan(contentControl, 2); From b4b342fa6f1fd37883836d561f0993486ce48e4c Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 11 Dec 2022 12:39:28 +0900 Subject: [PATCH 6/7] Add Layout for Browse button --- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 58 ++++++++++++++++++---- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index 2b42befe03f..6ab35fb901b 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -25,6 +25,7 @@ using System.Windows.Documents; using static System.Windows.Forms.LinkLabel; using Droplex; +using System.Windows.Forms; namespace Flow.Launcher.Core.Plugin { @@ -424,7 +425,7 @@ public Control CreateSettingPanel() Text = attribute.Description.Replace("\\r\\n", "\r\n"), Margin = settingTextBlockMargin, Padding = new Thickness(0,0,0,0), - HorizontalAlignment = HorizontalAlignment.Left, + HorizontalAlignment = System.Windows.HorizontalAlignment.Left, TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.Wrap }; @@ -444,7 +445,7 @@ public Control CreateSettingPanel() { Text = Settings[attribute.Name] as string ?? string.Empty, Margin = settingControlMargin, - HorizontalAlignment = HorizontalAlignment.Stretch, + HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, ToolTip = attribute.Description }; textBox.TextChanged += (_, _) => @@ -461,6 +462,41 @@ public Control CreateSettingPanel() Grid.SetColumnSpan(sep, 2); break; } + case "inputWithFileBtn": + { + var textBox = new TextBox() + { + Margin = new Thickness(10, 0, 0, 0), + Text = Settings[attribute.Name] as string ?? string.Empty, + HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, + ToolTip = attribute.Description + }; + textBox.TextChanged += (_, _) => + { + Settings[attribute.Name] = textBox.Text; + }; + var Btn = new System.Windows.Controls.Button() + { + Margin = new Thickness(10,0,0,0), + Content = "Browse" + }; + var dockPanel = new DockPanel() + { + Margin = settingControlMargin + }; + DockPanel.SetDock(Btn, Dock.Right); + dockPanel.Children.Add(Btn); + dockPanel.Children.Add(textBox); + contentControl = dockPanel; + Grid.SetColumn(contentControl, 1); + Grid.SetRow(contentControl, rowCount); + if (rowCount != 0) + mainPanel.Children.Add(sep); + Grid.SetRow(sep, rowCount); + Grid.SetColumn(sep, 0); + Grid.SetColumnSpan(sep, 2); + break; + } case "textarea": { var textBox = new TextBox() @@ -470,7 +506,7 @@ public Control CreateSettingPanel() VerticalAlignment = VerticalAlignment.Center, TextWrapping = TextWrapping.WrapWithOverflow, AcceptsReturn = true, - HorizontalAlignment = HorizontalAlignment.Stretch, + HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, Text = Settings[attribute.Name] as string ?? string.Empty, ToolTip = attribute.Description }; @@ -495,7 +531,7 @@ public Control CreateSettingPanel() Margin = settingControlMargin, Password = Settings[attribute.Name] as string ?? string.Empty, PasswordChar = attribute.passwordChar == default ? '*' : attribute.passwordChar, - HorizontalAlignment = HorizontalAlignment.Stretch, + HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, ToolTip = attribute.Description }; passwordBox.PasswordChanged += (sender, _) => @@ -514,17 +550,17 @@ public Control CreateSettingPanel() } case "dropdown": { - var comboBox = new ComboBox() + var comboBox = new System.Windows.Controls.ComboBox() { ItemsSource = attribute.Options, SelectedItem = Settings[attribute.Name], Margin = settingControlMargin, - HorizontalAlignment = HorizontalAlignment.Right, + HorizontalAlignment = System.Windows.HorizontalAlignment.Right, ToolTip = attribute.Description }; comboBox.SelectionChanged += (sender, _) => { - Settings[attribute.Name] = (string)((ComboBox)sender).SelectedItem; + Settings[attribute.Name] = (string)((System.Windows.Controls.ComboBox)sender).SelectedItem; }; contentControl = comboBox; Grid.SetColumn(contentControl, 1); @@ -541,7 +577,7 @@ public Control CreateSettingPanel() { IsChecked = Settings[attribute.Name] is bool isChecked ? isChecked : bool.Parse(attribute.DefaultValue), Margin = settingCheckboxMargin, - HorizontalAlignment = HorizontalAlignment.Right, + HorizontalAlignment = System.Windows.HorizontalAlignment.Right, ToolTip = attribute.Description }; checkBox.Click += (sender, _) => @@ -563,9 +599,9 @@ public Control CreateSettingPanel() ToolTip = attribute.Description, NavigateUri = attribute.url }; - var linkbtn = new Button + var linkbtn = new System.Windows.Controls.Button { - HorizontalAlignment = HorizontalAlignment.Right, + HorizontalAlignment = System.Windows.HorizontalAlignment.Right, Margin = settingControlMargin }; linkbtn.Content = attribute.urlLabel; @@ -623,7 +659,7 @@ public void UpdateSettings(Dictionary settings) case PasswordBox passwordBox: passwordBox.Dispatcher.Invoke(() => passwordBox.Password = value as string); break; - case ComboBox comboBox: + case System.Windows.Controls.ComboBox comboBox: comboBox.Dispatcher.Invoke(() => comboBox.SelectedItem = value); break; case CheckBox checkBox: From d6a31f02abcb8a1d92b3baae6d452d2ced0c886c Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 11 Dec 2022 12:40:30 +0900 Subject: [PATCH 7/7] Remove Color of debugging --- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index 6ab35fb901b..4df5037a574 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -379,7 +379,6 @@ public Control CreateSettingPanel() sep.SetResourceReference(Separator.BackgroundProperty, "Color03B"); /* for theme change */ var panel = new StackPanel { - Background = System.Windows.SystemColors.GrayTextBrush, Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Center, Margin = settingLabelPanelMargin };