diff --git a/Directory.Core.Build.props b/Directory.Core.Build.props index 4f24099a..90acdb61 100644 --- a/Directory.Core.Build.props +++ b/Directory.Core.Build.props @@ -11,7 +11,7 @@ true - true + true true \ No newline at end of file diff --git a/src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs b/src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs index 998dfb1e..7f03c62e 100644 --- a/src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs +++ b/src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs @@ -90,12 +90,14 @@ public IWriteableBitmapImpl LoadWriteableBitmap(Stream stream) throw new NotImplementedException(); } - IBitmapImpl IPlatformRenderInterface.LoadBitmapToWidth(Stream stream, int width, BitmapInterpolationMode interpolationMode) + IBitmapImpl IPlatformRenderInterface.LoadBitmapToWidth(Stream stream, int width, + BitmapInterpolationMode interpolationMode) { throw new NotImplementedException(); } - IBitmapImpl IPlatformRenderInterface.LoadBitmapToHeight(Stream stream, int height, BitmapInterpolationMode interpolationMode) + IBitmapImpl IPlatformRenderInterface.LoadBitmapToHeight(Stream stream, int height, + BitmapInterpolationMode interpolationMode) { throw new NotImplementedException(); } @@ -105,7 +107,7 @@ IBitmapImpl IPlatformRenderInterface.ResizeBitmap(IBitmapImpl bitmapImpl, PixelS { throw new NotImplementedException(); } - + public IBitmapImpl LoadBitmap( PixelFormat format, AlphaFormat alphaFormat, @@ -117,10 +119,11 @@ public IBitmapImpl LoadBitmap( throw new NotImplementedException(); } - public IGlyphRunImpl CreateGlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize, IReadOnlyList glyphInfos, + public IGlyphRunImpl CreateGlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize, + IReadOnlyList glyphInfos, Point baselineOrigin) { - return new GlyphRunImpl(glyphTypeface,glyphInfos,baselineOrigin); + return new GlyphRunImpl(glyphTypeface, glyphInfos, baselineOrigin); } public IPlatformRenderInterfaceContext CreateBackendContext(IPlatformGraphicsContext graphicsApiContext) diff --git a/src/Consolonia.Core/Drawing/DrawingContextImpl.cs b/src/Consolonia.Core/Drawing/DrawingContextImpl.cs index 17e18ac6..eca569f5 100644 --- a/src/Consolonia.Core/Drawing/DrawingContextImpl.cs +++ b/src/Consolonia.Core/Drawing/DrawingContextImpl.cs @@ -170,6 +170,7 @@ public void DrawGlyphRun(IBrush foreground, IGlyphRunImpl glyphRun) ConsoloniaPlatform.RaiseNotSupported(17, glyphRun); throw new InvalidProgramException(); } + if (glyphRun.FontRenderingEmSize.IsNearlyEqual(0)) return; if (!glyphRun.FontRenderingEmSize.IsNearlyEqual(1)) { @@ -195,9 +196,9 @@ public void PushClip(Rect clip) public void PushClip(RoundedRect clip) { - if(clip.IsRounded) + if (clip.IsRounded) ConsoloniaPlatform.RaiseNotSupported(2); - + PushClip(clip.Rect); } @@ -351,7 +352,7 @@ void DrawPixelAndMoveHead(int count) } } } - + private void DrawStringInternal(IBrush foreground, string str, Point origin = new()) { if (foreground is not FourBitColorBrush { Mode: PixelBackgroundMode.Colored } consoleColorBrush) diff --git a/src/Consolonia.Core/Drawing/FourBitColorBrush.cs b/src/Consolonia.Core/Drawing/FourBitColorBrush.cs index 0a9d5242..bd523b82 100644 --- a/src/Consolonia.Core/Drawing/FourBitColorBrush.cs +++ b/src/Consolonia.Core/Drawing/FourBitColorBrush.cs @@ -43,19 +43,19 @@ public ConsoleColor Color set => SetValue(ColorProperty, value); } + public double Opacity => 1; + public ITransform Transform => null; + public RelativePoint TransformOrigin => RelativePoint.TopLeft; + // ReSharper disable once UnusedMember.Global used by Avalonia // ReSharper disable once UnusedParameter.Global public IBrush ProvideValue(IServiceProvider _) { return this; } - - public double Opacity => 1; - public ITransform Transform => null; - public RelativePoint TransformOrigin => RelativePoint.TopLeft; } - public class FourBitBrushConverter : TypeConverter + public class FourBitBrushConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { @@ -66,15 +66,11 @@ public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string s) - { - return Enum.TryParse(s, out ConsoleColor result) - ? result + return Enum.TryParse(s, out ConsoleColor result) + ? result : null; - } - + return null; } } - - } \ No newline at end of file diff --git a/src/Consolonia.Core/Drawing/RenderTarget.cs b/src/Consolonia.Core/Drawing/RenderTarget.cs index 096edd7b..d4cacc4e 100644 --- a/src/Consolonia.Core/Drawing/RenderTarget.cs +++ b/src/Consolonia.Core/Drawing/RenderTarget.cs @@ -67,6 +67,13 @@ void IDrawingContextLayerImpl.Blit(IDrawingContextImpl context) bool IDrawingContextLayerImpl.CanBlit => true; + public IDrawingContextImpl CreateDrawingContext() + { + return new DrawingContextImpl(_consoleWindow, _bufferBuffer); + } + + public bool IsCorrupted => false; + private void OnResized(Size size, WindowResizeReason reason) { @@ -110,7 +117,7 @@ private void RenderToDevice() throw new InvalidOperationException("Caret is already shown"); caretPosition = new PixelBufferCoordinate(x, y); } - + /* todo: There is not IWindowImpl.Invalidate anymore. if (!_consoleWindow.InvalidatedRects.Any(rect => rect.ContainsExclusive(new Point(x, y)))) continue;*/ @@ -221,12 +228,5 @@ public void Flush() _stringBuilder.Clear(); } } - - public IDrawingContextImpl CreateDrawingContext() - { - return new DrawingContextImpl(_consoleWindow, _bufferBuffer); - } - - public bool IsCorrupted => false; } } \ No newline at end of file diff --git a/src/Consolonia.Core/Infrastructure/ArrowsAndKeyboardNavigationHandler.cs b/src/Consolonia.Core/Infrastructure/ArrowsAndKeyboardNavigationHandler.cs index 7cd82e27..4beb2077 100644 --- a/src/Consolonia.Core/Infrastructure/ArrowsAndKeyboardNavigationHandler.cs +++ b/src/Consolonia.Core/Infrastructure/ArrowsAndKeyboardNavigationHandler.cs @@ -10,11 +10,11 @@ namespace Consolonia.Core.Infrastructure { public class ArrowsAndKeyboardNavigationHandler : IKeyboardNavigationHandler { + private readonly IKeyboardNavigationHandler _keyboardNavigationHandler; + //todo: check XTFocus https://github.com/jinek/Consolonia/issues/105#issuecomment-2089015880 private IInputRoot _owner; - private readonly IKeyboardNavigationHandler _keyboardNavigationHandler; - public ArrowsAndKeyboardNavigationHandler(IKeyboardNavigationHandler keyboardNavigationHandler) { _keyboardNavigationHandler = keyboardNavigationHandler; diff --git a/src/Consolonia.Core/Infrastructure/ConsoleWindow.cs b/src/Consolonia.Core/Infrastructure/ConsoleWindow.cs index 7325cffe..e5f9c148 100644 --- a/src/Consolonia.Core/Infrastructure/ConsoleWindow.cs +++ b/src/Consolonia.Core/Infrastructure/ConsoleWindow.cs @@ -31,6 +31,8 @@ public ConsoleWindow() Console.FocusEvent += ConsoleOnFocusEvent; } + private IMouseDevice MouseDevice { get; } + public void Dispose() { Closed?.Invoke(); @@ -40,7 +42,7 @@ public void Dispose() Console.FocusEvent -= ConsoleOnFocusEvent; Console.Dispose(); } - + public void SetInputRoot(IInputRoot inputRoot) { _inputRoot = inputRoot; @@ -76,7 +78,7 @@ public void SetFrameThemeVariant(PlatformThemeVariant themeVariant) { //todo: } - + public Size ClientSize { get @@ -104,7 +106,6 @@ public Size ClientSize public Compositor Compositor { get; } = new(null); public Action Closed { get; set; } public Action LostFocus { get; set; } - private IMouseDevice MouseDevice { get; } public WindowTransparencyLevel TransparencyLevel => WindowTransparencyLevel.None; @@ -240,6 +241,14 @@ public void SetExtendClientAreaTitleBarHeightHint(double titleBarHeight) // ReSharper disable once UnassignedGetOnlyAutoProperty todo: what is this property public Thickness OffScreenMargin { get; } + public object TryGetFeature(Type featureType) + { + if (featureType == typeof(ISystemNavigationManagerImpl)) + return null; + if (featureType == typeof(ITextInputMethodImpl)) return null; + throw new NotImplementedException("Consider this"); + } + private void ConsoleOnMouseEvent(RawPointerEventType type, Point point, Vector? wheelDelta, RawInputModifiers modifiers) { @@ -333,16 +342,5 @@ await Dispatcher.UIThread.InvokeAsync(() => }, DispatcherPriority.Input); } } - - public object TryGetFeature(Type featureType) - { - if (featureType == typeof(ISystemNavigationManagerImpl)) - return null; - if (featureType == typeof(ITextInputMethodImpl)) - { - return null; - } - throw new NotImplementedException("Consider this"); - } } } \ No newline at end of file diff --git a/src/Consolonia.Core/Infrastructure/ConsoloniaPlatform.cs b/src/Consolonia.Core/Infrastructure/ConsoloniaPlatform.cs index 0026ec6b..d35f111e 100644 --- a/src/Consolonia.Core/Infrastructure/ConsoloniaPlatform.cs +++ b/src/Consolonia.Core/Infrastructure/ConsoloniaPlatform.cs @@ -41,7 +41,7 @@ public void Initialize() .Bind().ToConstant(new UiThreadRenderTimer(120)) .Bind().ToConstant(new ManagedDispatcherImpl(null)) /*.Bind().ToConstant(new SleepLoopRenderTimer(120))*/ - /*SleepLoopRenderTimer : IRenderTimer*/ + /*SleepLoopRenderTimer : IRenderTimer*/ /*.Bind().ToConstant(new RenderLoop()) todo: is internal now*/ .Bind().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Control)) .Bind().ToConstant(new ConsoleKeyboardDevice()) diff --git a/src/Consolonia.Core/Infrastructure/ExceptionSink.cs b/src/Consolonia.Core/Infrastructure/ExceptionSink.cs index ba5bf7bb..717fdf66 100644 --- a/src/Consolonia.Core/Infrastructure/ExceptionSink.cs +++ b/src/Consolonia.Core/Infrastructure/ExceptionSink.cs @@ -16,9 +16,7 @@ public bool IsEnabled(LogEventLevel level, string area) public void Log(LogEventLevel level, string area, object source, string messageTemplate) { Log(level, area, source, messageTemplate, Array.Empty()); - } - - // ReSharper disable UnusedMember.Global + } // ReSharper disable UnusedMember.Global public void Log(LogEventLevel level, string area, object source, string messageTemplate, T0 propertyValue0) { Log(level, area, source, messageTemplate, new object[] { propertyValue0 }); diff --git a/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs b/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs index d6e54536..38f6a210 100644 --- a/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs +++ b/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs @@ -83,9 +83,7 @@ public void Print(PixelBufferCoordinate bufferPoint, ConsoleColor backgroundColo if (str.Any( c => ConsoleText.IsWideChar(c) && char.IsLetterOrDigit(c) /*todo: https://github.com/SlimeNull/NullLib.ConsoleEx/issues/2*/)) - { throw new NotSupportedException("Is not supposed to be rendered"); - } Console.Write(str); diff --git a/src/Consolonia.Core/InternalHelpers/CommonInternalHelper.cs b/src/Consolonia.Core/InternalHelpers/CommonInternalHelper.cs index 276c8836..dc15318f 100644 --- a/src/Consolonia.Core/InternalHelpers/CommonInternalHelper.cs +++ b/src/Consolonia.Core/InternalHelpers/CommonInternalHelper.cs @@ -6,7 +6,8 @@ namespace Consolonia.Core.InternalHelpers internal static class CommonInternalHelper { public static bool IsNearlyEqual(this double value, double compareTo) - {//todo: strange implementation for this name + { + //todo: strange implementation for this name return value.CompareTo(compareTo) == 0; } diff --git a/src/Consolonia.Core/Styles/ResourceIncludeBase.cs b/src/Consolonia.Core/Styles/ResourceIncludeBase.cs index 63d13d8e..0b41173d 100644 --- a/src/Consolonia.Core/Styles/ResourceIncludeBase.cs +++ b/src/Consolonia.Core/Styles/ResourceIncludeBase.cs @@ -46,11 +46,12 @@ public IStyle Loaded return _loaded[0]; } } + public bool TryGetResource(object key, ThemeVariant theme, out object value) { if (!_isLoading && Loaded is IResourceProvider p) return p.TryGetResource(key, theme, out value); - + value = null; return false; } diff --git a/src/Consolonia.Core/Text/FontManagerImpl.cs b/src/Consolonia.Core/Text/FontManagerImpl.cs index d93344f3..c3c53874 100644 --- a/src/Consolonia.Core/Text/FontManagerImpl.cs +++ b/src/Consolonia.Core/Text/FontManagerImpl.cs @@ -11,11 +11,6 @@ namespace Consolonia.Core.Text /// internal class FontManagerImpl : IFontManagerImpl { - public static string GetTheOnlyFontFamilyName() - { - return "ConsoleDefault(F7D6533C-AC9D-4C4A-884F-7719A9B5DC0C)"; - } - public string GetDefaultFontFamilyName() { return GetTheOnlyFontFamilyName(); @@ -23,10 +18,11 @@ public string GetDefaultFontFamilyName() string[] IFontManagerImpl.GetInstalledFontFamilyNames(bool checkForUpdates) { - return new []{GetTheOnlyFontFamilyName()}; + return new[] { GetTheOnlyFontFamilyName() }; } - public bool TryMatchCharacter(int codepoint, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch, + public bool TryMatchCharacter(int codepoint, FontStyle fontStyle, FontWeight fontWeight, + FontStretch fontStretch, CultureInfo culture, out Typeface typeface) { throw new NotImplementedException(); @@ -44,5 +40,10 @@ public bool TryCreateGlyphTypeface(Stream stream, out IGlyphTypeface glyphTypefa { throw new NotImplementedException(); } + + public static string GetTheOnlyFontFamilyName() + { + return "ConsoleDefault(F7D6533C-AC9D-4C4A-884F-7719A9B5DC0C)"; + } } } \ No newline at end of file diff --git a/src/Consolonia.Core/Text/GlyphRunImpl.cs b/src/Consolonia.Core/Text/GlyphRunImpl.cs index 93b8fc08..7c141569 100644 --- a/src/Consolonia.Core/Text/GlyphRunImpl.cs +++ b/src/Consolonia.Core/Text/GlyphRunImpl.cs @@ -20,9 +20,10 @@ public GlyphRunImpl(IGlyphTypeface glyphTypeface, IReadOnlyList glyph new Size(glyphInfos.Sum(info => info.GlyphAdvance), FontRenderingEmSize)); } + public ushort[] GlyphIndices { get; } + public void Dispose() { - } public IReadOnlyList GetIntersections(float lowerLimit, float upperLimit) @@ -35,6 +36,5 @@ public IReadOnlyList GetIntersections(float lowerLimit, float upperLimit) public double FontRenderingEmSize { get; } public Point BaselineOrigin { get; } public Rect Bounds { get; } - public ushort[] GlyphIndices { get; } } } \ No newline at end of file diff --git a/src/Consolonia.Core/Text/TextShaper.cs b/src/Consolonia.Core/Text/TextShaper.cs index 9df478e6..fae6321a 100644 --- a/src/Consolonia.Core/Text/TextShaper.cs +++ b/src/Consolonia.Core/Text/TextShaper.cs @@ -12,14 +12,11 @@ public class TextShaper : ITextShaperImpl public ShapedBuffer ShapeText(ReadOnlyMemory text, TextShaperOptions options) { var glyphInfos = Convert(text.Span.ToString()); - + var shapedBuffer = new ShapedBuffer(text, glyphInfos.Length, new GlyphTypeface(), 1, 0 /*todo: must be 1 for right to left?*/); - - for (int i = 0; i < shapedBuffer.Length; i++) - { - shapedBuffer[i] = glyphInfos[i]; - } + + for (int i = 0; i < shapedBuffer.Length; i++) shapedBuffer[i] = glyphInfos[i]; return shapedBuffer; } @@ -30,8 +27,8 @@ public static GlyphInfo[] Convert(string str) // ReSharper disable once InvertIf if (str.Any( - c => ConsoleText.IsWideChar(c) && - char.IsLetterOrDigit(c) /*todo: https://github.com/SlimeNull/NullLib.ConsoleEx/issues/2*/)) + c => ConsoleText.IsWideChar(c) && + char.IsLetterOrDigit(c) /*todo: https://github.com/SlimeNull/NullLib.ConsoleEx/issues/2*/)) { StringBuilder stringBuilder = new(); foreach (char c in str) diff --git a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryAnimatedLines.axaml.cs b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryAnimatedLines.axaml.cs index 507833ea..88aa351c 100644 --- a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryAnimatedLines.axaml.cs +++ b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryAnimatedLines.axaml.cs @@ -9,7 +9,7 @@ namespace Consolonia.Gallery.Gallery.GalleryViews { // ReSharper disable once UnusedType.Global - public partial class GalleryAnimatedLines : UserControl + public class GalleryAnimatedLines : UserControl { public GalleryAnimatedLines() { diff --git a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryButton.axaml.cs b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryButton.axaml.cs index dfe84a0d..59e3c9f9 100644 --- a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryButton.axaml.cs +++ b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryButton.axaml.cs @@ -4,7 +4,7 @@ namespace Consolonia.Gallery.Gallery.GalleryViews { [GalleryOrder(30)] - public partial class GalleryButton : UserControl + public class GalleryButton : UserControl { public GalleryButton() { diff --git a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCalendar.axaml.cs b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCalendar.axaml.cs index b4e2ca33..9a006c49 100644 --- a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCalendar.axaml.cs +++ b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCalendar.axaml.cs @@ -5,7 +5,7 @@ namespace Consolonia.Gallery.Gallery.GalleryViews { [GalleryOrder(30)] - public partial class GalleryCalendar : UserControl + public class GalleryCalendar : UserControl { public GalleryCalendar() { diff --git a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCalendarPicker.axaml.cs b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCalendarPicker.axaml.cs index 112474c1..50b7cbd7 100644 --- a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCalendarPicker.axaml.cs +++ b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCalendarPicker.axaml.cs @@ -8,7 +8,7 @@ namespace Consolonia.Gallery.Gallery.GalleryViews { [GalleryOrder(35)] - public partial class GalleryCalendarPicker : UserControl + public class GalleryCalendarPicker : UserControl { public GalleryCalendarPicker() { @@ -53,7 +53,7 @@ public DateTime? ValidatedDateExample } public event PropertyChangedEventHandler PropertyChanged; - + private void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); diff --git a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCheckBox.axaml.cs b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCheckBox.axaml.cs index 425d38b2..7de368ba 100644 --- a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCheckBox.axaml.cs +++ b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryCheckBox.axaml.cs @@ -4,7 +4,7 @@ namespace Consolonia.Gallery.Gallery.GalleryViews { [GalleryOrder(40)] - public partial class GalleryCheckBox : UserControl + public class GalleryCheckBox : UserControl { public GalleryCheckBox() { diff --git a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryComboBox.axaml b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryComboBox.axaml index f727ca5d..df58d9f5 100644 --- a/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryComboBox.axaml +++ b/src/Consolonia.Gallery/Gallery/GalleryViews/GalleryComboBox.axaml @@ -1,6 +1,5 @@