From 098f57ecad75c664382fb4b5aca3b8e4245ad333 Mon Sep 17 00:00:00 2001 From: Riccardo De Agostini Date: Fri, 19 Aug 2022 16:01:25 +0200 Subject: [PATCH 1/7] Detect method BuildAvaloniaApp in base class. --- .../Remote/RemoteDesignerEntryPoint.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs index be2405efde..ca2c2c7fb2 100644 --- a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs +++ b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs @@ -168,8 +168,12 @@ namespace Avalonia.DesignerSupport.Remote var entryPoint = asm.EntryPoint; if (entryPoint == null) throw Die($"Assembly {args.AppPath} doesn't have an entry point"); - var builderMethod = entryPoint.DeclaringType.GetMethod(BuilderMethodName, - BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Array.Empty(), null); + var builderMethod = entryPoint.DeclaringType.GetMethod( + BuilderMethodName, + BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy, + null, + Array.Empty(), + null); if (builderMethod == null) throw Die($"{entryPoint.DeclaringType.FullName} doesn't have a method named {BuilderMethodName}"); Design.IsDesignMode = true; From bf0b79fd329c3d051c0516251080d65beacddc46 Mon Sep 17 00:00:00 2001 From: Jan Lukas Gernert Date: Mon, 22 Aug 2022 17:09:35 +0200 Subject: [PATCH 2/7] update SkiaSharp to 2.88.1 --- build/SkiaSharp.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/SkiaSharp.props b/build/SkiaSharp.props index cc573825cd..31619399f9 100644 --- a/build/SkiaSharp.props +++ b/build/SkiaSharp.props @@ -1,7 +1,7 @@  - - - + + + From 2831ff5ad168caff947463f6d59c5b44e2fc82c9 Mon Sep 17 00:00:00 2001 From: Takoooooo Date: Tue, 23 Aug 2022 14:06:58 +0300 Subject: [PATCH 3/7] Fix Fluent theme port bugs --- src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml | 1 - src/Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml | 1 + src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml | 7 ------- src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml | 7 ------- 4 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml b/src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml index 5ae83427b5..364a2a52e3 100644 --- a/src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml +++ b/src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml @@ -53,7 +53,6 @@ - diff --git a/src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml b/src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml index bc47f3892e..e9c60570c7 100644 --- a/src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml @@ -56,18 +56,11 @@ - - diff --git a/src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml b/src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml index 0d1b416d7a..fb02071c3f 100644 --- a/src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml @@ -55,18 +55,11 @@ - - From 7fb99a39817777c4887b7c157fd93391de979200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 24 Aug 2022 12:55:48 +0200 Subject: [PATCH 4/7] Update Avalonia.Web.Blazor dependencies --- src/Web/Avalonia.Web.Blazor/Avalonia.Web.Blazor.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Web/Avalonia.Web.Blazor/Avalonia.Web.Blazor.csproj b/src/Web/Avalonia.Web.Blazor/Avalonia.Web.Blazor.csproj index 1531c95830..2d598687a9 100644 --- a/src/Web/Avalonia.Web.Blazor/Avalonia.Web.Blazor.csproj +++ b/src/Web/Avalonia.Web.Blazor/Avalonia.Web.Blazor.csproj @@ -45,8 +45,8 @@ - - + + From f86b74c136b78d3e2d5d3720a51b5b155a73f10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 24 Aug 2022 13:24:36 +0200 Subject: [PATCH 5/7] Fix build --- .../Interop/Typescript/StorageProvider.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Web/Avalonia.Web.Blazor/Interop/Typescript/StorageProvider.ts b/src/Web/Avalonia.Web.Blazor/Interop/Typescript/StorageProvider.ts index aee74b9067..1ee055eff9 100644 --- a/src/Web/Avalonia.Web.Blazor/Interop/Typescript/StorageProvider.ts +++ b/src/Web/Avalonia.Web.Blazor/Interop/Typescript/StorageProvider.ts @@ -8,7 +8,6 @@ declare global { type PermissionsMode = "read" | "readwrite"; interface FileSystemFileHandle { name: string, - kind: "file" | "directory", getFile(): Promise; createWritable(options?: { keepExistingData?: boolean }): Promise; @@ -169,10 +168,6 @@ class StorageItem { } public async getItems(): Promise { - if (this.handle.kind !== "directory"){ - return new StorageItems([]); - } - const items: StorageItem[] = []; for await (const [key, value] of this.handle.entries()) { items.push(new StorageItem(value)); From 0b01a51c9e83a779ea273277d9efc8a90e444fea Mon Sep 17 00:00:00 2001 From: hacklex Date: Sun, 28 Aug 2022 18:41:21 +0300 Subject: [PATCH 6/7] TextConverter property for finer control over NumericUpDown text display (#8839) * Added TextConverter property to NumericUpDown * Added a hex NumericUpDown sample to ControlCatalog * Requested changes to conversion calls * Fixed NumericUpDown::OnTextConverterChanged logic --- .../ControlCatalog/Converter/HexConverter.cs | 34 +++++++++++ .../Pages/NumericUpDownPage.xaml | 12 ++++ .../NumericUpDown/NumericUpDown.cs | 61 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 samples/ControlCatalog/Converter/HexConverter.cs diff --git a/samples/ControlCatalog/Converter/HexConverter.cs b/samples/ControlCatalog/Converter/HexConverter.cs new file mode 100644 index 0000000000..83a52212f6 --- /dev/null +++ b/samples/ControlCatalog/Converter/HexConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Globalization; +using Avalonia; +using Avalonia.Data.Converters; + +namespace ControlCatalog.Converter; + +public class HexConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var str = value?.ToString(); + if (str == null) + return AvaloniaProperty.UnsetValue; + if (int.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int x)) + return (decimal)x; + return AvaloniaProperty.UnsetValue; + + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + try + { + if (value is decimal d) + return ((int)d).ToString("X8"); + return AvaloniaProperty.UnsetValue; + } + catch + { + return AvaloniaProperty.UnsetValue; + } + } +} diff --git a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml index 1f4d1e6018..045ba4a059 100644 --- a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml +++ b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml @@ -1,6 +1,7 @@  @@ -97,6 +98,17 @@ + + + + + + + + + + diff --git a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs index dc2b2cd7cc..190dab67aa 100644 --- a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs +++ b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs @@ -5,6 +5,7 @@ using System.Linq; using Avalonia.Controls.Metadata; using Avalonia.Controls.Primitives; using Avalonia.Data; +using Avalonia.Data.Converters; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Layout; @@ -96,6 +97,13 @@ namespace Avalonia.Controls AvaloniaProperty.RegisterDirect(nameof(Text), o => o.Text, (o, v) => o.Text = v, defaultBindingMode: BindingMode.TwoWay, enableDataValidation: true); + /// + /// Defines the property. + /// + public static readonly DirectProperty TextConverterProperty = + AvaloniaProperty.RegisterDirect(nameof(TextConverter), + updown => updown.TextConverter, (o, v) => o.TextConverter = v, null, BindingMode.OneWay, false); + /// /// Defines the property. /// @@ -125,6 +133,7 @@ namespace Avalonia.Controls private decimal? _value; private string? _text; + private IValueConverter? _textConverter; private bool _internalValueSet; private bool _clipValueToMinMax; private bool _isSyncingTextAndValueProperties; @@ -235,6 +244,8 @@ namespace Avalonia.Controls /// /// Gets or sets the parsing style (AllowLeadingWhite, Float, AllowHexSpecifier, ...). By default, Any. + /// Note that Hex style does not work with decimal. + /// For hexadecimal display, use . /// public NumberStyles ParsingNumberStyle { @@ -251,6 +262,17 @@ namespace Avalonia.Controls set { SetAndRaise(TextProperty, ref _text, value); } } + /// + /// Gets or sets the custom bidirectional Text-Value converter. + /// Non-null converter overrides , providing finer control over + /// string representation of the underlying value. + /// + public IValueConverter? TextConverter + { + get { return _textConverter; } + set { SetAndRaise(TextConverterProperty, ref _textConverter, value); } + } + /// /// Gets or sets the value. /// @@ -319,6 +341,7 @@ namespace Avalonia.Controls MaximumProperty.Changed.Subscribe(OnMaximumChanged); MinimumProperty.Changed.Subscribe(OnMinimumChanged); TextProperty.Changed.Subscribe(OnTextChanged); + TextConverterProperty.Changed.Subscribe(OnTextConverterChanged); ValueProperty.Changed.Subscribe(OnValueChanged); } @@ -485,6 +508,19 @@ namespace Avalonia.Controls SyncTextAndValueProperties(true, Text); } } + + /// + /// Called when the property value changed. + /// + /// The old value. + /// The new value. + protected virtual void OnTextConverterChanged(IValueConverter? oldValue, IValueConverter? newValue) + { + if (IsInitialized) + { + SyncTextAndValueProperties(false, null); + } + } /// /// Called when the property value changed. @@ -612,6 +648,10 @@ namespace Avalonia.Controls /// private string? ConvertValueToText() { + if (TextConverter != null) + { + return TextConverter.ConvertBack(Value, typeof(string), null, CultureInfo.CurrentCulture)?.ToString(); + } //Manage FormatString of type "{}{0:N2} °" (in xaml) or "{0:N2} °" in code-behind. if (FormatString.Contains("{0")) { @@ -788,6 +828,21 @@ namespace Avalonia.Controls } } + /// + /// Called when the property value changed. + /// + /// The event args. + private static void OnTextConverterChanged(AvaloniaPropertyChangedEventArgs e) + { + if (e.Sender is NumericUpDown upDown) + { + var oldValue = (IValueConverter?)e.OldValue; + var newValue = (IValueConverter?)e.NewValue; + upDown.OnTextConverterChanged(oldValue, newValue); + } + } + + /// /// Called when the property value changed. /// @@ -1012,6 +1067,12 @@ namespace Avalonia.Controls return null; } + if (TextConverter != null) + { + var valueFromText = TextConverter.Convert(text, typeof(decimal?), null, CultureInfo.CurrentCulture); + return (decimal?)valueFromText; + } + if (IsPercent(FormatString)) { result = ParsePercent(text, NumberFormat); From 854b11e38c2efa8ff19bf0d3636f17c125af9fcb Mon Sep 17 00:00:00 2001 From: Lobster Uberlord Date: Mon, 29 Aug 2022 19:25:18 +0700 Subject: [PATCH 7/7] Disable auto-capitalization of input element text in AvaloniaView On Android Chrome the auto-capitalization forces the keyboard to switch to uppercase for each and every character, this made typing in rather difficult. --- src/Web/Avalonia.Web.Blazor/AvaloniaView.razor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Web/Avalonia.Web.Blazor/AvaloniaView.razor b/src/Web/Avalonia.Web.Blazor/AvaloniaView.razor index b501db16d3..4802191077 100644 --- a/src/Web/Avalonia.Web.Blazor/AvaloniaView.razor +++ b/src/Web/Avalonia.Web.Blazor/AvaloniaView.razor @@ -15,7 +15,8 @@ + oncut="return false;" + autocapitalize="none"/>