From 3d203cdc9dbbef41a1d716ed82121469b2be7d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Pi=C4=85tek?= Date: Sun, 7 Aug 2022 18:00:57 +0200 Subject: [PATCH] Enable Tab navigation in vault and action parameters --- .../ScriptRunner.GUI/ParamsPanelFactory.cs | 57 ++++++++++++++----- .../ScriptRunner.GUI/Views/MainWindow.axaml | 12 +++- .../ScriptRunner.GUI/Views/Vault.axaml | 7 ++- 3 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/ScriptRunner/ScriptRunner.GUI/ParamsPanelFactory.cs b/src/ScriptRunner/ScriptRunner.GUI/ParamsPanelFactory.cs index d778114..868e0cb 100644 --- a/src/ScriptRunner/ScriptRunner.GUI/ParamsPanelFactory.cs +++ b/src/ScriptRunner/ScriptRunner.GUI/ParamsPanelFactory.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using Avalonia.Collections; using Avalonia.Controls; @@ -21,10 +22,10 @@ public ParamsPanel Create(IEnumerable parameters, Dictionary(); - foreach (var param in parameters) + foreach (var (param,i) in parameters.Select((x,i)=>(x,i))) { values.TryGetValue(param.Name, out var value); - var controlRecord = CreateControlRecord(param, value); + var controlRecord = CreateControlRecord(param, value, i); controlRecord.Name = param.Name; var actionPanel = new StackPanel { @@ -50,7 +51,7 @@ public ParamsPanel Create(IEnumerable parameters, Dictionary(), - SelectedItem = value + SelectedItem = value, + TabIndex = index, + IsTabStop = true } }; case PromptType.Multiselect: @@ -88,7 +95,9 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) { SelectionMode = SelectionMode.Multiple, Items = p.GetPromptSettings("options", out var multiSelectOptions) ? multiSelectOptions.Split(delimiter) : Array.Empty(), - SelectedItems = new AvaloniaList((value ?? string.Empty).Split(delimiter)) + SelectedItems = new AvaloniaList((value ?? string.Empty).Split(delimiter)), + TabIndex = index, + IsTabStop = true }, Delimiter = delimiter }; @@ -103,7 +112,9 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) new CalendarDatePicker { SelectedDate = selectedDate?.Date, - IsTodayHighlighted = true + IsTodayHighlighted = true, + TabIndex = index, + IsTabStop = true } : new DatePicker { @@ -111,7 +122,9 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) YearVisible = yearVisible, MonthVisible = monthVisible, DayVisible = dayVisible, - + TabIndex = index, + IsTabStop = true + }, Format = p.GetPromptSettings("format", out var format) ? format : null, }; @@ -121,7 +134,9 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) Control = new TimePicker { SelectedTime = string.IsNullOrWhiteSpace(value)?null: TimeSpan.Parse(value), - ClockIdentifier = "24HourClock" + ClockIdentifier = "24HourClock", + TabIndex = index, + IsTabStop = true }, Format = p.GetPromptSettings("format", out var timeFormat) ? timeFormat : null, }; @@ -131,7 +146,9 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) { Control = new CheckBox { - IsChecked = string.IsNullOrWhiteSpace(value) == false && value == checkedValueText + IsChecked = string.IsNullOrWhiteSpace(value) == false && value == checkedValueText, + TabIndex = index, + IsTabStop = true }, CheckedValue = checkedValueText, UncheckedValue = p.GetPromptSettings("uncheckedValue", out var uncheckedValue)? uncheckedValue: "false", @@ -144,7 +161,9 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) TextWrapping = TextWrapping.Wrap, AcceptsReturn = true, Height = 100, - Text = value + Text = value, + TabIndex = index, + IsTabStop = true } }; case PromptType.FileContent: @@ -155,7 +174,9 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) TextWrapping = TextWrapping.Wrap, AcceptsReturn = true, Height = 100, - Text = File.Exists(value)? File.ReadAllText(value): string.Empty + Text = File.Exists(value)? File.ReadAllText(value): string.Empty, + TabIndex = index, + IsTabStop = true } }; case PromptType.FilePicker: @@ -163,7 +184,9 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) { Control = new FilePicker { - FilePath = value + FilePath = value, + TabIndex = index, + IsTabStop = true } }; case PromptType.DirectoryPicker: @@ -171,7 +194,9 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) { Control = new DirectoryPicker { - DirPath = value + DirPath = value, + TabIndex = index, + IsTabStop = true } }; case PromptType.Numeric: @@ -182,6 +207,8 @@ private static IControlRecord CreateControlRecord(ScriptParam p, string? value) Minimum = p.GetPromptSettings("min", out var minValue) && double.TryParse(minValue, out var mindDouble)? mindDouble : double.MinValue, Maximum = p.GetPromptSettings("max", out var maxValue) && double.TryParse(maxValue, out var maxDouble)? maxDouble: double.MaxValue, Increment = p.GetPromptSettings("step", out var stepValue) && double.TryParse(stepValue, out var stepDouble)? stepDouble: 1.0, + TabIndex = index, + IsTabStop = true } }; default: diff --git a/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml b/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml index 8de707f..6899615 100644 --- a/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml +++ b/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml @@ -59,7 +59,7 @@