diff --git a/src/Consolonia.Core/Infrastructure/ConsoloniaApplication.cs b/src/Consolonia.Core/Infrastructure/ConsoloniaApplication.cs index 728947af..1785f265 100644 --- a/src/Consolonia.Core/Infrastructure/ConsoloniaApplication.cs +++ b/src/Consolonia.Core/Infrastructure/ConsoloniaApplication.cs @@ -1,8 +1,12 @@ using System; +using System.Linq; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Controls.Primitives; +using Avalonia.Controls.Templates; using Avalonia.Input; +using Consolonia.Core.Controls; using Consolonia.Core.Helpers; using Consolonia.Core.Infrastructure; @@ -21,6 +25,25 @@ public override void RegisterServices() public override void OnFrameworkInitializationCompleted() { + // override AccessText to use ConsoloniaAccessText as default contentpresenter for unknown data types (aka string) + this.DataTemplates.Add(new FuncDataTemplate( + (data, s) => + { + if (data != null && data is string str) + { + var result = new ConsoloniaAccessText(); + result.Bind(TextBlock.TextProperty, + result.GetObservable(Control.DataContextProperty)); + return result; + } + else + { + return null; + } + }, + true) + ); + base.OnFrameworkInitializationCompleted(); this.AddConsoloniaDesignMode(); diff --git a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryLabel.axaml b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryLabel.axaml new file mode 100644 index 00000000..28594003 --- /dev/null +++ b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryLabel.axaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryLabel.axaml.cs b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryLabel.axaml.cs new file mode 100644 index 00000000..75a80a6d --- /dev/null +++ b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryLabel.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia.Controls; + +namespace Consolonia.Gallery.Gallery.GalleryViews +{ + public partial class GalleryLabel : UserControl + { + public GalleryLabel() + { + InitializeComponent(); + } + + } +} \ No newline at end of file diff --git a/src/Consolonia.Gallery/View/ControlsListView.axaml b/src/Consolonia.Gallery/View/ControlsListView.axaml index 5b4b2822..41610f7d 100644 --- a/src/Consolonia.Gallery/View/ControlsListView.axaml +++ b/src/Consolonia.Gallery/View/ControlsListView.axaml @@ -20,7 +20,7 @@ - diff --git a/src/Consolonia.PlatformSupport/WindowsConsole.cs b/src/Consolonia.PlatformSupport/WindowsConsole.cs index d88d7d57..665c609d 100644 --- a/src/Consolonia.PlatformSupport/WindowsConsole.cs +++ b/src/Consolonia.PlatformSupport/WindowsConsole.cs @@ -203,7 +203,10 @@ private void HandleKeyInput(WindowsConsole.InputRecord inputRecord) char character = keyEvent.UnicodeChar; RawInputModifiers modifiers = ModifiersFlagTranslator.Translate(keyEvent.dwControlKeyState); - RaiseKeyPress(DefaultNetConsole.ConvertToKey((ConsoleKey)keyEvent.wVirtualKeyCode), + var key = DefaultNetConsole.ConvertToKey((ConsoleKey)keyEvent.wVirtualKeyCode); + if (key == Avalonia.Input.Key.LeftAlt || key == Avalonia.Input.Key.RightAlt) + modifiers |= RawInputModifiers.Alt; + RaiseKeyPress(key, character, modifiers, keyEvent.bKeyDown, (ulong)Stopwatch.GetTimestamp()); }