Compare commits
4 commits
f8c1ef0e96
...
7e40c1dc0b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e40c1dc0b | ||
|
|
a212870d09 | ||
|
|
055c2fae03 | ||
|
|
0b06265117 |
10 changed files with 372 additions and 80 deletions
17
src/AdvancedCalculator.Android/Styles/Android.axaml
Normal file
17
src/AdvancedCalculator.Android/Styles/Android.axaml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<!-- Android overrides: larger, touch-first -->
|
||||||
|
<x:Double x:Key="FontSizeBase">16</x:Double>
|
||||||
|
<x:Double x:Key="FontSizeLarge">18</x:Double>
|
||||||
|
<x:Double x:Key="IconSizeM">24</x:Double>
|
||||||
|
<x:Double x:Key="LineHeightBase">1.35</x:Double>
|
||||||
|
|
||||||
|
<!-- Thin overlay-like scrollbars -->
|
||||||
|
<Style Selector="ScrollBar:vertical">
|
||||||
|
<Setter Property="Width" Value="8"/>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ScrollBar:horizontal">
|
||||||
|
<Setter Property="Height" Value="8"/>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
|
|
||||||
16
src/AdvancedCalculator.Browser/Styles/Browser.axaml
Normal file
16
src/AdvancedCalculator.Browser/Styles/Browser.axaml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<!-- Browser overrides: middle ground -->
|
||||||
|
<x:Double x:Key="FontSizeBase">15</x:Double>
|
||||||
|
<x:Double x:Key="IconSizeM">22</x:Double>
|
||||||
|
<x:Double x:Key="LineHeightBase">1.3</x:Double>
|
||||||
|
|
||||||
|
<!-- Slightly thinner scrollbars on web -->
|
||||||
|
<Style Selector="ScrollBar:vertical">
|
||||||
|
<Setter Property="Width" Value="8"/>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ScrollBar:horizontal">
|
||||||
|
<Setter Property="Height" Value="8"/>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
|
|
||||||
16
src/AdvancedCalculator.Desktop/Styles/Desktop.axaml
Normal file
16
src/AdvancedCalculator.Desktop/Styles/Desktop.axaml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<!-- Desktop overrides: slightly denser -->
|
||||||
|
<x:Double x:Key="FontSizeBase">13</x:Double>
|
||||||
|
<x:Double x:Key="LineHeightBase">1.2</x:Double>
|
||||||
|
<x:Double x:Key="IconSizeM">20</x:Double>
|
||||||
|
|
||||||
|
<!-- Scrollbars a bit thicker on desktop -->
|
||||||
|
<Style Selector="ScrollBar:vertical">
|
||||||
|
<Setter Property="Width" Value="12"/>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ScrollBar:horizontal">
|
||||||
|
<Setter Property="Height" Value="12"/>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<FluentTheme />
|
<FluentTheme />
|
||||||
|
<StyleInclude Source="avares://AdvancedCalculator/Styles/Typography.axaml"/>
|
||||||
|
<StyleInclude Source="avares://AdvancedCalculator/Styles/Scroll.axaml"/>
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
|
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Data.Core.Plugins;
|
using Avalonia.Data.Core.Plugins;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Avalonia.Styling;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace AdvancedCalculator;
|
namespace AdvancedCalculator;
|
||||||
|
|
||||||
|
|
@ -21,6 +23,40 @@ public partial class App : Application
|
||||||
// Without this line you will get duplicate validations from both Avalonia and CT
|
// Without this line you will get duplicate validations from both Avalonia and CT
|
||||||
BindingPlugins.DataValidators.RemoveAt(0);
|
BindingPlugins.DataValidators.RemoveAt(0);
|
||||||
|
|
||||||
|
// Load platform-specific styles (typography, scrollbars overrides)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var styles = Current?.Styles;
|
||||||
|
if (styles is not null)
|
||||||
|
{
|
||||||
|
if (OperatingSystem.IsAndroid())
|
||||||
|
{
|
||||||
|
styles.Add(new StyleInclude(new Uri("avares://AdvancedCalculator/"))
|
||||||
|
{
|
||||||
|
Source = new Uri("avares://AdvancedCalculator.Android/Styles/Android.axaml")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (OperatingSystem.IsBrowser())
|
||||||
|
{
|
||||||
|
styles.Add(new StyleInclude(new Uri("avares://AdvancedCalculator/"))
|
||||||
|
{
|
||||||
|
Source = new Uri("avares://AdvancedCalculator.Browser/Styles/Browser.axaml")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
styles.Add(new StyleInclude(new Uri("avares://AdvancedCalculator/"))
|
||||||
|
{
|
||||||
|
Source = new Uri("avares://AdvancedCalculator.Desktop/Styles/Desktop.axaml")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// If a platform-specific style dictionary is missing, continue without failing.
|
||||||
|
}
|
||||||
|
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
desktop.MainWindow = new MainWindow
|
desktop.MainWindow = new MainWindow
|
||||||
|
|
|
||||||
31
src/AdvancedCalculator/Converters/WidthToBooleanConverter.cs
Normal file
31
src/AdvancedCalculator/Converters/WidthToBooleanConverter.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using Avalonia.Data.Converters;
|
||||||
|
|
||||||
|
namespace AdvancedCalculator.Converters;
|
||||||
|
|
||||||
|
// Returns true if width (double) is less than the provided threshold (parameter),
|
||||||
|
// otherwise false. Default threshold is 640 when parameter is null or invalid.
|
||||||
|
public class WidthToBooleanConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public static readonly WidthToBooleanConverter Instance = new();
|
||||||
|
|
||||||
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo? culture)
|
||||||
|
{
|
||||||
|
if (value is double width)
|
||||||
|
{
|
||||||
|
double threshold = 640;
|
||||||
|
if (parameter is double p)
|
||||||
|
threshold = p;
|
||||||
|
else if (parameter is string s && double.TryParse(s, NumberStyles.Number, CultureInfo.InvariantCulture, out var parsed))
|
||||||
|
threshold = parsed;
|
||||||
|
|
||||||
|
return width < threshold;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo? culture)
|
||||||
|
=> throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
21
src/AdvancedCalculator/Styles/Scroll.axaml
Normal file
21
src/AdvancedCalculator/Styles/Scroll.axaml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<!-- Shared scrolling defaults -->
|
||||||
|
<Style Selector="ListBox">
|
||||||
|
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
||||||
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="ScrollViewer">
|
||||||
|
<Setter Property="CanScrollHorizontally" Value="False"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- Thin-ish scrollbars by default; platform overrides will adjust -->
|
||||||
|
<Style Selector="ScrollBar:vertical">
|
||||||
|
<Setter Property="Width" Value="10"/>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ScrollBar:horizontal">
|
||||||
|
<Setter Property="Height" Value="10"/>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
|
|
||||||
30
src/AdvancedCalculator/Styles/Typography.axaml
Normal file
30
src/AdvancedCalculator/Styles/Typography.axaml
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<!-- Shared typography resources -->
|
||||||
|
<x:Double x:Key="FontSizeSmall">12</x:Double>
|
||||||
|
<x:Double x:Key="FontSizeBase">14</x:Double>
|
||||||
|
<x:Double x:Key="FontSizeLarge">16</x:Double>
|
||||||
|
<x:Double x:Key="FontSizeXL">20</x:Double>
|
||||||
|
|
||||||
|
<x:Double x:Key="IconSizeS">18</x:Double>
|
||||||
|
<x:Double x:Key="IconSizeM">22</x:Double>
|
||||||
|
<x:Double x:Key="IconSizeL">26</x:Double>
|
||||||
|
|
||||||
|
<x:Double x:Key="LineHeightTight">1.1</x:Double>
|
||||||
|
<x:Double x:Key="LineHeightBase">1.25</x:Double>
|
||||||
|
<x:Double x:Key="LineHeightRelaxed">1.4</x:Double>
|
||||||
|
|
||||||
|
<!-- Defaults for text -->
|
||||||
|
<Style Selector="TextBlock">
|
||||||
|
<Setter Property="TextElement.FontSize" Value="{DynamicResource FontSizeBase}"/>
|
||||||
|
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||||
|
<Setter Property="LineHeight" Value="{DynamicResource LineHeightBase}"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- Subtle caption text helper -->
|
||||||
|
<Style Selector="TextBlock.caption">
|
||||||
|
<Setter Property="TextElement.FontSize" Value="{DynamicResource FontSizeSmall}"/>
|
||||||
|
<Setter Property="Opacity" Value="0.85"/>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
|
|
||||||
|
|
@ -41,6 +41,37 @@ public partial class MainViewModel : ViewModelBase
|
||||||
IsFunctionsPanelOpen = !IsFunctionsPanelOpen;
|
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)]
|
[RelayCommand(AllowConcurrentExecutions = false)]
|
||||||
private async Task Submit()
|
private async Task Submit()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,92 +10,184 @@
|
||||||
x:DataType="vm:MainViewModel">
|
x:DataType="vm:MainViewModel">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<conv:BoolToGridLengthConverter x:Key="BoolToGridLengthConverter" />
|
<conv:BoolToGridLengthConverter x:Key="BoolToGridLengthConverter" />
|
||||||
|
<conv:WidthToBooleanConverter x:Key="WidthToBooleanConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
<!-- Replace columns with a responsive SplitView -->
|
||||||
|
<SplitView x:Name="RootSplit"
|
||||||
|
OpenPaneLength="320"
|
||||||
|
CompactPaneLength="0">
|
||||||
|
<!-- Responsive behavior: set DisplayMode and IsPaneOpen based on width -->
|
||||||
|
<SplitView.Styles>
|
||||||
|
<Style Selector="SplitView#RootSplit">
|
||||||
|
<Style.Triggers>
|
||||||
|
<!-- Narrow: Overlay mode, pane closed by default -->
|
||||||
|
<DataTrigger Value="True"
|
||||||
|
Binding="{Binding $parent[Window].Bounds.Width,
|
||||||
|
Converter={StaticResource WidthToBooleanConverter},
|
||||||
|
ConverterParameter=640}">
|
||||||
|
<Setter Property="DisplayMode" Value="Overlay" />
|
||||||
|
<Setter Property="IsPaneOpen" Value="False" />
|
||||||
|
</DataTrigger>
|
||||||
|
<!-- Wide: Inline mode, pane open -->
|
||||||
|
<DataTrigger Value="False"
|
||||||
|
Binding="{Binding $parent[Window].Bounds.Width,
|
||||||
|
Converter={StaticResource WidthToBooleanConverter},
|
||||||
|
ConverterParameter=640}">
|
||||||
|
<Setter Property="DisplayMode" Value="Inline" />
|
||||||
|
<Setter Property="IsPaneOpen" Value="True" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</SplitView.Styles>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="*,3*">
|
<!-- Left pane: Variables + Functions -->
|
||||||
<!-- Left column: Variables + Functions -->
|
<SplitView.Pane>
|
||||||
<Grid Grid.Column="0">
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="{Binding IsFunctionsPanelOpen, Converter={StaticResource BoolToGridLengthConverter}}" />
|
<RowDefinition Height="{Binding IsFunctionsPanelOpen, Converter={StaticResource BoolToGridLengthConverter}}" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Variables list -->
|
<!-- Variables list with empty-state hint overlay -->
|
||||||
<ListBox Grid.Row="0" ItemsSource="{Binding Variables}" SelectedIndex="-1">
|
<Grid Grid.Row="0">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox ItemsSource="{Binding Variables}" SelectedIndex="-1" HorizontalContentAlignment="Stretch"
|
||||||
<DataTemplate x:DataType="m:VariableItem">
|
AutomationProperties.Name="Variables list">
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto" Margin="4,2">
|
<ListBox.ItemTemplate>
|
||||||
<TextBlock Grid.Column="0" FontFamily="{StaticResource MDI}"
|
<DataTemplate x:DataType="m:VariableItem">
|
||||||
FontSize="22" Text="{Binding Icon}" VerticalAlignment="Center" Margin="0,0,8,0" />
|
<Button Command="{Binding DataContext.InsertVariableCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||||
<TextBlock Grid.Column="1" Text="{Binding VariableName}" FontWeight="Bold" VerticalAlignment="Center" />
|
CommandParameter="{Binding VariableName}"
|
||||||
<StackPanel Grid.Column="2" Spacing="2">
|
Background="Transparent" BorderThickness="0" Padding="8" MinHeight="44"
|
||||||
<TextBlock Text="{Binding Value}" />
|
AutomationProperties.Name="Insert variable">
|
||||||
<TextBlock IsVisible="{Binding IsExpression}" Text="{Binding ExpressionComputation}" FontStyle="Italic" />
|
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||||
</StackPanel>
|
<TextBlock Grid.Column="0" FontFamily="{StaticResource MDI}"
|
||||||
</Grid>
|
FontSize="{DynamicResource IconSizeM}" Text="{Binding Icon}" VerticalAlignment="Center" Margin="0,0,8,0" />
|
||||||
</DataTemplate>
|
<TextBlock Grid.Column="1" Text="{Binding VariableName}" FontWeight="Bold" VerticalAlignment="Center" />
|
||||||
</ListBox.ItemTemplate>
|
<StackPanel Grid.Column="2" Spacing="6" VerticalAlignment="Center">
|
||||||
</ListBox>
|
<TextBlock Text="{Binding Value}" />
|
||||||
|
<TextBlock IsVisible="{Binding IsExpression}" Text="{Binding ExpressionComputation}" FontStyle="Italic" />
|
||||||
<!-- Function definitions -->
|
|
||||||
<ListBox Grid.Row="1" BorderThickness="0"
|
|
||||||
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" />
|
|
||||||
</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>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</Grid>
|
||||||
</ItemsControl.ItemTemplate>
|
</Button>
|
||||||
</ItemsControl>
|
</DataTemplate>
|
||||||
</StackPanel>
|
</ListBox.ItemTemplate>
|
||||||
</DataTemplate>
|
</ListBox>
|
||||||
</ListBox.ItemTemplate>
|
<TextBlock Text="No variables yet. Define with: x = 5"
|
||||||
</ListBox>
|
IsVisible="False"
|
||||||
</Grid>
|
IsHitTestVisible="False"
|
||||||
|
Opacity="0.6"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
|
<TextBlock.Styles>
|
||||||
|
<Style Selector="TextBlock">
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding Variables.Count}" Value="0">
|
||||||
|
<Setter Property="IsVisible" Value="True" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</TextBlock.Styles>
|
||||||
|
</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<!-- GridSplitter between columns -->
|
<!-- Function definitions -->
|
||||||
<GridSplitter Grid.Column="0" HorizontalAlignment="Right" Width="5" Background="Transparent" />
|
<ListBox Grid.Row="1" BorderThickness="0" HorizontalContentAlignment="Stretch"
|
||||||
|
ItemsSource="{x:Static m:FunctionDefinitionItem.DefinedFunctions}"
|
||||||
<!-- Right column: History + Input -->
|
AutomationProperties.Name="Functions list">
|
||||||
<Grid Grid.Column="1" RowDefinitions="*,Auto">
|
<ListBox.ItemTemplate>
|
||||||
<!-- History -->
|
<DataTemplate x:DataType="m:FunctionDefinitionItem">
|
||||||
<ListBox Grid.Row="0" ItemsSource="{Binding History}" SelectedIndex="{Binding SelectedHistoryIndex}">
|
<Button Command="{Binding DataContext.InsertFunctionCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||||
<ListBox.ItemTemplate>
|
CommandParameter="{Binding FunctionName}"
|
||||||
<DataTemplate x:DataType="m:HistoryItem">
|
Background="Transparent" BorderThickness="0" Padding="8" MinHeight="44"
|
||||||
<Grid ColumnDefinitions="Auto,*" Margin="4,2">
|
AutomationProperties.Name="Insert function">
|
||||||
<TextBlock FontFamily="{StaticResource MDI}" Text="{x:Static m:IconFont.ArrowRightDropCircle}"
|
<StackPanel Spacing="8">
|
||||||
FontSize="22" VerticalAlignment="Center" Margin="0,0,8,0" />
|
<StackPanel Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
|
||||||
<StackPanel Grid.Column="1">
|
<TextBlock FontFamily="{StaticResource MDI}" Text="{Binding Icon}" />
|
||||||
<TextBlock Text="{Binding Input}" />
|
<TextBlock Text="{Binding FunctionName}" FontWeight="Bold" />
|
||||||
<TextBlock Text="{Binding Output}" FontWeight="Bold" />
|
</StackPanel>
|
||||||
</StackPanel>
|
<TextBlock Text="{Binding FunctionDescription}" FontStyle="Italic" TextWrapping="Wrap" />
|
||||||
</Grid>
|
<ItemsControl ItemsSource="{Binding FunctionArguments}">
|
||||||
</DataTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
</ListBox.ItemTemplate>
|
<DataTemplate>
|
||||||
</ListBox>
|
<StackPanel>
|
||||||
|
<TextBlock Text="{Binding Key}" />
|
||||||
<!-- Input Row -->
|
<TextBlock Text="{Binding Value}" FontStyle="Italic" Margin="8,0,0,0" />
|
||||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,*" Margin="4">
|
</StackPanel>
|
||||||
<Button Command="{Binding ToggleFunctionsCommand}" Margin="0,0,6,0">
|
</DataTemplate>
|
||||||
<TextBlock FontFamily="{StaticResource MDI}" Text="{x:Static m:IconFont.Function}" />
|
</ItemsControl.ItemTemplate>
|
||||||
</Button>
|
</ItemsControl>
|
||||||
<TextBox Grid.Column="1" Text="{Binding InputText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
|
</StackPanel>
|
||||||
<InputElement.KeyBindings>
|
</Button>
|
||||||
<KeyBinding Gesture="Enter" Command="{Binding SubmitCommand}" />
|
</DataTemplate>
|
||||||
</InputElement.KeyBindings>
|
</ListBox.ItemTemplate>
|
||||||
</TextBox>
|
</ListBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</SplitView.Pane>
|
||||||
</Grid>
|
|
||||||
|
<!-- Right content: History + Input -->
|
||||||
|
<SplitView.Content>
|
||||||
|
<Grid RowDefinitions="*,Auto">
|
||||||
|
<!-- History -->
|
||||||
|
<Grid Grid.Row="0">
|
||||||
|
<ListBox ItemsSource="{Binding History}" SelectedIndex="{Binding SelectedHistoryIndex}"
|
||||||
|
AutomationProperties.Name="History list">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="m:HistoryItem">
|
||||||
|
<Grid ColumnDefinitions="Auto,*" Margin="4,2">
|
||||||
|
<TextBlock FontFamily="{StaticResource MDI}" Text="{x:Static m:IconFont.ArrowRightDropCircle}"
|
||||||
|
FontSize="{DynamicResource IconSizeM}" VerticalAlignment="Center" Margin="0,0,8,0" />
|
||||||
|
<StackPanel Grid.Column="1">
|
||||||
|
<TextBlock Text="{Binding Input}" MaxLines="3" />
|
||||||
|
<TextBlock Text="{Binding Output}" FontWeight="Bold" MaxLines="2" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<TextBlock Text="No history yet. Enter an expression and Evaluate."
|
||||||
|
IsVisible="False"
|
||||||
|
IsHitTestVisible="False"
|
||||||
|
Opacity="0.6"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
|
<TextBlock.Styles>
|
||||||
|
<Style Selector="TextBlock">
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding History.Count}" Value="0">
|
||||||
|
<Setter Property="IsVisible" Value="True" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</TextBlock.Styles>
|
||||||
|
</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Input Row -->
|
||||||
|
<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,
|
||||||
|
Converter={StaticResource WidthToBooleanConverter},
|
||||||
|
ConverterParameter=640}"
|
||||||
|
IsChecked="{Binding #RootSplit.IsPaneOpen}"
|
||||||
|
AutomationProperties.Name="Open side panel">
|
||||||
|
<TextBlock Text="≡" FontSize="18"/>
|
||||||
|
</ToggleButton>
|
||||||
|
|
||||||
|
<!-- Toggle functions panel inside the pane -->
|
||||||
|
<Button Grid.Column="1" Command="{Binding ToggleFunctionsCommand}" Margin="0,0,6,0" MinHeight="40" MinWidth="40"
|
||||||
|
AutomationProperties.Name="Toggle functions panel">
|
||||||
|
<TextBlock FontFamily="{StaticResource MDI}" Text="{x:Static m:IconFont.Function}" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<TextBox Grid.Column="2" Text="{Binding InputText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinHeight="44"
|
||||||
|
AutomationProperties.Name="Expression input"
|
||||||
|
Watermark="Type an expression (e.g., 2 + 2)"/>
|
||||||
|
|
||||||
|
<!-- Explicit evaluate button for touch -->
|
||||||
|
<Button Grid.Column="3" Command="{Binding SubmitCommand}" MinHeight="44" Padding="16,8"
|
||||||
|
AutomationProperties.Name="Evaluate">
|
||||||
|
<TextBlock Text="Evaluate"/>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</SplitView.Content>
|
||||||
|
</SplitView>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue