Skip to content

Commit 84ae1df

Browse files
committed
Merge branch 'main' into release
2 parents 9483635 + b55dad0 commit 84ae1df

22 files changed

+540
-108
lines changed

README.md

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ VariableBox is an Avalonia Control for building cross-platform UIs with Avalonia
3333
| Light | ![lf](https://github.com/heartacker/VariableBox.Avalonia/blob/main/assets/light-fluent.png) | ![ls](https://github.com/heartacker/VariableBox.Avalonia/blob/main/assets/light-semi.png) |
3434

3535
## ChangeLog
36+
- 2025/03/10(0.8.0)
37+
- unify the semi NumericalBox and VariableBox
38+
- Use MonoSpace etc. font by default
39+
- Update readme for event and command
40+
- Update demo for event and command
41+
3642
- 2025/02/25(0.7.0)
3743
- Mass UI Polish
3844
- Uniform the UI for each App Theme
@@ -108,7 +114,7 @@ You can now use VariableBox controls in your Avalonia Application.
108114
xmlns:vbox="VariableBox"
109115
...>
110116
<StackPanel Margin="20">
111-
<vbox:VariableBoxUInt Value="{Binding Value}"
117+
<vbox:VariableBoxUInt Value="{Binding Value}"
112118
FormatString="X8"
113119
HeaderContent="0x"
114120
ParsingNumberStyle="AllowHexSpecifier"
@@ -119,16 +125,97 @@ You can now use VariableBox controls in your Avalonia Application.
119125
</Window>
120126
```
121127

128+
### CommandS and Events
129+
130+
FYI, you can see demo.
131+
132+
#### Event
133+
134+
we have Read and Write(ValueChenged)Event.
135+
136+
- **ValueChanged** or you click write, you can get the old and new value
137+
138+
`public event EventHandler<ValueChangedEventArgs<T>>? ValueChanged`
139+
140+
- **ReadRequestedEvent** When you Click Read,
141+
>**you can update your value while reading and there is not valueChangeEvent**
142+
143+
`public event RoutedEvent<RoutedEventArgs> ReadRequestedEvent`
144+
145+
- **HeaderDoubleTapedEvent** When you Double the header
146+
147+
`public static readonly RoutedEvent<TappedEventArgs> HeaderDoubleTapedEvent`
148+
149+
#### Command for MVVM
150+
151+
- `Commnad` Value changed or click the write
152+
>**Please don't set the CommandParater to Current Value, Like `CommandParameter="{Binding Value}"` will get you the old value**
153+
154+
1. you can just binding with a command like `WriteCommnad(uint v)`, **you don't need to set the Command parater by default**
155+
2. we will send the updated-value for you
156+
157+
- `ReadCommand` When you click Read
158+
159+
same as `Commnad`, The default parameter will be the **current value**
160+
161+
- `HeaderDoubleTapedCommand` when you double click the Header
162+
163+
#### Demo
164+
165+
```csharp
166+
//view
167+
Command="{Binding TrythisCommand}"
168+
ReadCommand="{Binding ReadDemoCommand}"
169+
170+
// viewmodel
171+
[RelayCommand]
172+
void Trythis(uint v)
173+
{
174+
CommandUpdateText =
175+
$"Binding without CommandParater, and the default parameter will be the new value={v}";
176+
}
177+
178+
// viewmodel
179+
[RelayCommand]
180+
void Trythis()
181+
{
182+
// also work too
183+
}
184+
185+
// viewmodel
186+
[RelayCommand]
187+
void ReadDemo(uint v)
188+
{
189+
CommandUpdateText =
190+
$"Binding without CommandParater,
191+
and the default parameter will be the current value={v}";
192+
}
193+
194+
// viewmodel
195+
[RelayCommand]
196+
void ReadDemo()
197+
{
198+
// also work too
199+
}
200+
201+
```
202+
203+
#### Note for command
204+
205+
- `CommandParameter="{Binding Value}"` will get you the old value
206+
122207
### PseudoClasses
123208

209+
> VariableBox is based vbox:NumericUpDown
210+
124211
- `:editing` for editing
125212
- `:invalid` for invalid input
126213

127214
e.g.:
128215

129216
<div style="display: flex;">
130217
<div style="flex: 50%; padding: 2px;">
131-
218+
132219

133220
```xml
134221
<Style Selector="vbox|NumericUpDown:editing">
@@ -209,7 +296,7 @@ dotnet add package Semi.Avalonia
209296
xmlns:vbox="VariableBox"
210297
....>
211298
<Application.Styles>
212-
<!-- if use semi -->
299+
<!-- if use semi -->
213300
<semi:SemiTheme Locale="zh-CN"/>
214301
<vbox:SemiTheme Locale="zh-CN"/>
215302
</Application.Styles>

demo/Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
33
<Nullable>enable</Nullable>
4-
<AvaloniaVersion>11.2.4</AvaloniaVersion>
4+
<AvaloniaVersion>11.2.5</AvaloniaVersion>
55
<!--<SemiAvaloniaVersion>11.1.0-beta1.1</SemiAvaloniaVersion>-->
6-
<SemiAvaloniaVersion>11.2.1.4</SemiAvaloniaVersion>
6+
<SemiAvaloniaVersion>11.2.1.5</SemiAvaloniaVersion>
77
</PropertyGroup>
88
</Project>

demo/VariableBox.Demo.Browser/AvaloniaAppBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Ursa.Demo.Browser;
55

66
public static class AvaloniaAppBuilderExtensions
77
{
8-
private static string DefaultFontFamily => "avares://Ursa.Demo.Browser/Assets#Source Han Sans CN";
8+
private static string DefaultFontFamily => "avares://VariableBox.Demo.Browser/Assets#Source Han Sans CN";
99
//private static string DefaultFontFamily => "Courier New";
1010

1111
public static AppBuilder WithSourceHanSansCNFont(this AppBuilder builder) =>

demo/VariableBox.Demo.Browser/VariableBox.Demo.Browser.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
<OutputType>Exe</OutputType>
44
<TargetFramework>net9.0-browser</TargetFramework>
55
<Platforms>AnyCPU;x64</Platforms>
6-
<StartupObject>Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint</StartupObject>
6+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
<Nullable>enable</Nullable>
8+
<!-- <StartupObject>Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint</StartupObject>-->
79
</PropertyGroup>
8-
<PropertyGroup Label="Avalonia">
9-
<AvaloniaUseCompiledBindingsByDefault>True</AvaloniaUseCompiledBindingsByDefault>
10+
<PropertyGroup Label="Avalonia">
11+
<AvaloniaUseCompiledBindingsByDefault>True</AvaloniaUseCompiledBindingsByDefault>
1012
</PropertyGroup>
1113

1214
<ItemGroup>
13-
<!--
14-
<TrimmerRootDescriptor Include="Roots.xml"/>
15-
-->
15+
<TrimmerRootDescriptor Include="Roots.xml" />
1616
<AvaloniaResource Include="Assets\**" />
1717
</ItemGroup>
1818

demo/VariableBox.Demo/App.axaml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:local="clr-namespace:VariableBox.Demo.Converters"
66
xmlns:semi="https://irihi.tech/semi"
7+
xmlns:u="https://irihi.tech/ursa"
8+
xmlns:u-semi="https://irihi.tech/ursa/themes/semi"
79
xmlns:vbox="VariableBox"
810
RequestedThemeVariant="Default"
911
>
@@ -15,34 +17,36 @@
1517
<FluentTheme />
1618
<vbox:FluentTheme Locale="zh-CN" />
1719

18-
<!-- <semi:SemiTheme Locale="zh-CN" />
19-
<vbox:SemiTheme Locale="zh-CN" />-->
20+
<!--<semi:SemiTheme Locale="zh-CN" />-->
21+
<!--<vbox:SemiTheme Locale="zh-CN" />-->
2022

2123
<!-- <SimpleTheme />
2224
<vbox:SimpleTheme Locale="zh-CN" />-->
2325

26+
<u-semi:SemiTheme Locale="zh-CN" />
27+
2428
<Style Selector="vbox|NumericUpDown">
25-
<Setter Property="FontFamily" Value="Sarasa Mono SC" />
29+
<!-- <Setter Property="FontFamily" Value="Sarasa Mono SC" /> -->
30+
</Style>
31+
32+
<Style Selector="vbox|NumericUpDown:pointerover">
33+
<Setter Property="FontWeight" Value="Bold" />
2634
</Style>
27-
28-
<Style Selector="vbox|NumericUpDown:pointerover">
29-
<Setter Property="FontWeight" Value="Bold" />
30-
</Style>
3135
<Style Selector="vbox|NumericUpDown:editing">
32-
<Setter Property="BorderBrush" Value="Green" />
36+
<Setter Property="BorderBrush" Value="Green" />
3337
<Style Selector="^ /template/ TextBox#PART_TextBox">
34-
<!-- <Setter Property="Foreground" Value="Green" /> -->
35-
<Setter Property="RenderTransform">
36-
<Setter.Value>
37-
<ScaleTransform ScaleX="1.1" ScaleY="1.1" />
38-
</Setter.Value>
39-
</Setter>
38+
<!-- <Setter Property="Foreground" Value="Green" /> -->
39+
<Setter Property="RenderTransform">
40+
<Setter.Value>
41+
<ScaleTransform ScaleX="1.1" ScaleY="1.1" />
42+
</Setter.Value>
43+
</Setter>
4044
</Style>
41-
<Style Selector="^:invalid">
42-
<Setter Property="BorderBrush" Value="Red" />
43-
<Style Selector="^ /template/ TextBox#PART_TextBox">
44-
<Setter Property="Foreground" Value="Red" />
45-
</Style>
45+
<Style Selector="^:invalid">
46+
<Setter Property="BorderBrush" Value="Red" />
47+
<Style Selector="^ /template/ TextBox#PART_TextBox">
48+
<Setter Property="Foreground" Value="Red" />
49+
</Style>
4650
</Style>
4751
</Style>
4852
</Application.Styles>

demo/VariableBox.Demo/App.axaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using HotAvalonia;
55
using VariableBox.Demo.ViewModels;
66
using VariableBox.Demo.Views;
7+
using VariableBox.Demo.Pages;
78

89
namespace VariableBox.Demo;
910

demo/VariableBox.Demo/Views/MainView.axaml renamed to demo/VariableBox.Demo/Pages/MainView.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<UserControl
2-
x:Class="VariableBox.Demo.Views.MainView"
2+
x:Class="VariableBox.Demo.Pages.MainView"
33
xmlns="https://github.com/avaloniaui"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:Pages="clr-namespace:VariableBox.Demo.Pages"

demo/VariableBox.Demo/Views/MainView.axaml.cs renamed to demo/VariableBox.Demo/Pages/MainView.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using Avalonia.Interactivity;
44
using Avalonia.Styling;
55

6-
namespace VariableBox.Demo.Views;
6+
namespace VariableBox.Demo.Pages;
77

88
public partial class MainView : UserControl
99
{

demo/VariableBox.Demo/Pages/ManyVariableBox.axaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:u="https://irihi.tech/ursa"
78
xmlns:v="VariableBox"
9+
xmlns:vm="using:VariableBox.Demo.ViewModels"
810
d:DesignHeight="500"
911
d:DesignWidth="400"
12+
x:DataType="vm:ManyVariableBoxViewModel"
1013
mc:Ignorable="d"
1114
>
1215

@@ -46,19 +49,22 @@
4649
</NumericUpDown.Styles>
4750
</NumericUpDown>
4851

52+
<u:Banner Content="Variable" />
4953
<HyperlinkButton Content="VariableBox:" NavigateUri="https://github.com/heartacker/VariableBox.Avalonia" />
5054
<!-- =================we should use AllowHexSpecifier -->
5155
<v:VariableBoxUInt
5256
Name="uint_AllowHexSpecifier"
5357
HorizontalContentAlignment="Right"
58+
Command="{Binding SendCommand}"
5459
FontFamily="Consolas"
5560
FormatString="{}{0:X3}"
5661
HeaderContent="AllowHexSpecifier"
5762
IsAllowDrag="False"
5863
ParsingNumberStyle="AllowHexSpecifier"
64+
ReadCommand="{Binding ReadCommand}"
5965
Step="1"
6066
Watermark="AllowHexSpecifier"
61-
Value="2"
67+
Value="{Binding ValueHex}"
6268
/>
6369

6470
<v:VariableBoxInt
@@ -69,12 +75,12 @@
6975
IsShowWriteButton="False"
7076
Step="1"
7177
Watermark="Input Value"
72-
Value="4"
78+
Value="{Binding Value2}"
7379
/>
7480
<v:VariableBoxUInt
7581
Name="NoSpnnner"
7682
HorizontalContentAlignment="Right"
77-
FontFamily="Consolas"
83+
FontFamily="Consolas, MonoSpace"
7884
FormatString="X8"
7985
HeaderContent="No.Spin:0x"
8086
IsAllowDrag="False"
@@ -107,6 +113,7 @@
107113
FormatString="{}{0:X8}"
108114
HeaderContent="HexNumber(error):"
109115
IsAllowDrag="False"
116+
FontFamily="Yahei"
110117
ParsingNumberStyle="HexNumber"
111118
Step="1"
112119
Watermark="Input Value"

demo/VariableBox.Demo/Pages/ManyVariableBox.axaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Avalonia;
22
using Avalonia.Controls;
33
using Avalonia.Markup.Xaml;
4+
using VariableBox.Demo.ViewModels;
45

56
namespace VariableBox.Demo.Pages;
67

@@ -9,5 +10,6 @@ public partial class ManyVariableBox : UserControl
910
public ManyVariableBox()
1011
{
1112
InitializeComponent();
13+
DataContext = new ManyVariableBoxViewModel();
1214
}
1315
}

0 commit comments

Comments
 (0)