UX touch-friendly: add Evaluate button; increase min sizes/spacing; make variables/functions tap-to-insert via InsertVariable/InsertFunction commands.
This commit is contained in:
parent
0b06265117
commit
055c2fae03
2 changed files with 74 additions and 34 deletions
|
@ -41,6 +41,37 @@ public partial class MainViewModel : ViewModelBase
|
|||
IsFunctionsPanelOpen = !IsFunctionsPanelOpen;
|
||||
}
|
||||
|
||||
// Insert helpers for touch: appends tokens to the input box
|
||||
[RelayCommand]
|
||||
private void InsertVariable(string? variableName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(variableName))
|
||||
return;
|
||||
InsertToken(variableName);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void InsertFunction(string? functionName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(functionName))
|
||||
return;
|
||||
InsertToken(functionName + "()");
|
||||
}
|
||||
|
||||
private void InsertToken(string token)
|
||||
{
|
||||
if (string.IsNullOrEmpty(InputText))
|
||||
{
|
||||
InputText = token;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!char.IsWhiteSpace(InputText[^1]))
|
||||
InputText += " ";
|
||||
|
||||
InputText += token;
|
||||
}
|
||||
|
||||
[RelayCommand(AllowConcurrentExecutions = false)]
|
||||
private async Task Submit()
|
||||
{
|
||||
|
|
|
@ -49,44 +49,52 @@
|
|||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Variables list -->
|
||||
<ListBox Grid.Row="0" ItemsSource="{Binding Variables}" SelectedIndex="-1">
|
||||
<ListBox Grid.Row="0" ItemsSource="{Binding Variables}" SelectedIndex="-1" HorizontalContentAlignment="Stretch">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="m:VariableItem">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto" Margin="4,2">
|
||||
<TextBlock Grid.Column="0" FontFamily="{StaticResource MDI}"
|
||||
FontSize="22" Text="{Binding Icon}" VerticalAlignment="Center" Margin="0,0,8,0" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding VariableName}" FontWeight="Bold" VerticalAlignment="Center" />
|
||||
<StackPanel Grid.Column="2" Spacing="2">
|
||||
<TextBlock Text="{Binding Value}" />
|
||||
<TextBlock IsVisible="{Binding IsExpression}" Text="{Binding ExpressionComputation}" FontStyle="Italic" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Button Command="{Binding DataContext.InsertVariableCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
CommandParameter="{Binding VariableName}"
|
||||
Background="Transparent" BorderThickness="0" Padding="8" MinHeight="44">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<TextBlock Grid.Column="0" FontFamily="{StaticResource MDI}"
|
||||
FontSize="22" Text="{Binding Icon}" VerticalAlignment="Center" Margin="0,0,8,0" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding VariableName}" FontWeight="Bold" VerticalAlignment="Center" />
|
||||
<StackPanel Grid.Column="2" Spacing="6" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding Value}" />
|
||||
<TextBlock IsVisible="{Binding IsExpression}" Text="{Binding ExpressionComputation}" FontStyle="Italic" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<!-- Function definitions -->
|
||||
<ListBox Grid.Row="1" BorderThickness="0"
|
||||
<ListBox Grid.Row="1" BorderThickness="0" HorizontalContentAlignment="Stretch"
|
||||
ItemsSource="{x:Static m:FunctionDefinitionItem.DefinedFunctions}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="m:FunctionDefinitionItem">
|
||||
<StackPanel Spacing="2" Margin="4,6">
|
||||
<StackPanel Orientation="Horizontal" Spacing="6">
|
||||
<TextBlock FontFamily="{StaticResource MDI}" Text="{Binding Icon}" />
|
||||
<TextBlock Text="{Binding FunctionName}" FontWeight="Bold" />
|
||||
<Button Command="{Binding DataContext.InsertFunctionCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
CommandParameter="{Binding FunctionName}"
|
||||
Background="Transparent" BorderThickness="0" Padding="8" MinHeight="44">
|
||||
<StackPanel Spacing="8">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
|
||||
<TextBlock FontFamily="{StaticResource MDI}" Text="{Binding Icon}" />
|
||||
<TextBlock Text="{Binding FunctionName}" FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding FunctionDescription}" FontStyle="Italic" TextWrapping="Wrap" />
|
||||
<ItemsControl ItemsSource="{Binding FunctionArguments}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Key}" />
|
||||
<TextBlock Text="{Binding Value}" FontStyle="Italic" Margin="8,0,0,0" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding FunctionDescription}" FontStyle="Italic" TextWrapping="Wrap" />
|
||||
<ItemsControl ItemsSource="{Binding FunctionArguments}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Key}" />
|
||||
<TextBlock Text="{Binding Value}" FontStyle="Italic" Margin="8,0,0,0" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
@ -113,7 +121,7 @@
|
|||
</ListBox>
|
||||
|
||||
<!-- Input Row -->
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,Auto,*" Margin="4">
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,Auto,*,Auto" Margin="4" ColumnSpacing="6">
|
||||
<!-- Pane toggle: visible on narrow only -->
|
||||
<ToggleButton Margin="0,0,6,0"
|
||||
IsVisible="{Binding $parent[Window].Bounds.Width,
|
||||
|
@ -124,15 +132,16 @@
|
|||
</ToggleButton>
|
||||
|
||||
<!-- Toggle functions panel inside the pane -->
|
||||
<Button Grid.Column="1" Command="{Binding ToggleFunctionsCommand}" Margin="0,0,6,0">
|
||||
<Button Grid.Column="1" Command="{Binding ToggleFunctionsCommand}" Margin="0,0,6,0" MinHeight="40" MinWidth="40">
|
||||
<TextBlock FontFamily="{StaticResource MDI}" Text="{x:Static m:IconFont.Function}" />
|
||||
</Button>
|
||||
|
||||
<TextBox Grid.Column="2" Text="{Binding InputText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
|
||||
<InputElement.KeyBindings>
|
||||
<KeyBinding Gesture="Enter" Command="{Binding SubmitCommand}" />
|
||||
</InputElement.KeyBindings>
|
||||
</TextBox>
|
||||
<TextBox Grid.Column="2" Text="{Binding InputText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinHeight="44"/>
|
||||
|
||||
<!-- Explicit evaluate button for touch -->
|
||||
<Button Grid.Column="3" Command="{Binding SubmitCommand}" MinHeight="44" Padding="16,8">
|
||||
<TextBlock Text="Evaluate"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</SplitView.Content>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue