Skip to content

Commit

Permalink
other errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jinek committed Oct 21, 2024
1 parent 36cfbcc commit c1de176
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ NavigationDirection.Down or
NavigationDirection.Up)
{
var elementCast = (InputElement)element;
var visualRoot = (Visual)elementCast.GetVisualRoot()!;
var visualRoot = (Visual)elementCast.GetVisualRoot();
(Point p1, Point p2) = GetOriginalPoint(elementCast.GetTransformedBounds().NotNull().Clip);
Point originalPoint = p1 / 2 + p2 / 2;

var focusableElements = visualRoot.GetVisualDescendants()
var focusableElements = visualRoot!.GetVisualDescendants()
.OfType<InputElement>()
// only focusable
.Where(inputElement => inputElement.Focusable && inputElement.IsEffectivelyEnabled &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ public Task ShowDialogAsync(Control parent)
return _taskCompletionSource.Task;
}

private static DialogHost GetDialogHost(Control parent)
private static DialogHost GetDialogHost(Visual parent)
{
var window = parent.FindAncestorOfType<Window>(true)!;
DialogHost dialogHost = window.GetValue(DialogHost.DialogHostProperty);
var window = parent.FindAncestorOfType<Window>(true);
DialogHost dialogHost = window!.GetValue(DialogHost.DialogHostProperty);
return dialogHost;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

namespace Consolonia.Themes.TurboVision.Templates.Controls
{
[SuppressMessage("Resharper", "PartialTypeWithSinglePart")]
[SuppressMessage("Usage", "PartialTypeWithSinglePart", Justification = "Partial class required for XAML code generation.")]
// ReSharper disable once PartialTypeWithSinglePart
internal partial class DialogWrap : UserControl
{
public readonly ContentPresenter FoundContentPresenter;
Expand All @@ -24,15 +25,15 @@ public DialogWrap()

AttachedToVisualTree += (_, _) =>
{
var parentWindow = this.FindAncestorOfType<Window>()!;
_disposable = parentWindow.GetPropertyChangedObservable(TopLevel.ClientSizeProperty).Subscribe(new AnonymousObserver<AvaloniaPropertyChangedEventArgs>(
var parentWindow = this.FindAncestorOfType<Window>();
_disposable = parentWindow!.GetPropertyChangedObservable(TopLevel.ClientSizeProperty).Subscribe(new AnonymousObserver<AvaloniaPropertyChangedEventArgs>(
args =>
{
var newSize = (Size)args.NewValue!;

SetNewSize(newSize);
}));
SetNewSize(parentWindow.ClientSize);
SetNewSize(parentWindow!.ClientSize);
};
DetachedFromLogicalTree += (_, _) => { _disposable.Dispose(); };
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Reflection;
using Avalonia;
using Avalonia.Controls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ static ConsoloniaTextPresenter()
public ConsoloniaTextPresenter()
{
// we need to disable blinking caret, our terminal caret blinks itself once shown
var caretTickTimer = (DispatcherTimer)TickTimerField.GetValue(this)!;
caretTickTimer.Interval =
var caretTickTimer = (DispatcherTimer)TickTimerField.GetValue(this);
caretTickTimer!.Interval =
TimeSpan.FromMilliseconds(int
.MaxValue); //see DispatcherTimer.Interval, since we can not disable it, setting it to the longest interval possible
caretTickTimer.Tick += (_, _) => throw new NotImplementedException("How to disable timer completely?");
caretTickTimer!.Tick += (_, _) => throw new NotImplementedException("How to disable timer completely?");

CaretBrush =
new FourBitColorBrush(ConsoleColor.Black, PixelBackgroundMode.Transparent); // we want to draw own caret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ public static void ProcessFocusOnOpen<TElementType, TParentControl>(AvaloniaProp
where TElementType : Control where TParentControl : Control
{
var dropDownControl = (TElementType)args.Sender;
var parentControl = dropDownControl.FindLogicalAncestorOfType<TParentControl>()!;
var parentControl = dropDownControl.FindLogicalAncestorOfType<TParentControl>();

if (args.NewValue.Value)
{
dropDownControl.AttachedToVisualTree += focusDropDownAction;

IDisposable disposable1 = parentControl.GetPropertyChangedObservable(InputElement.IsFocusedProperty)
IDisposable disposable1 = parentControl!.GetPropertyChangedObservable(InputElement.IsFocusedProperty)
.Subscribe(new AnonymousObserver<AvaloniaPropertyChangedEventArgs>(eventArgs =>
{
if (!(bool)eventArgs.NewValue! && !dropDownControl.IsKeyboardFocusWithin)
Dispatcher.UIThread.Post(() => { parentControl.SetValue(dropDownProperty, false); });
Dispatcher.UIThread.Post(() => { parentControl!.SetValue(dropDownProperty, false); });
}));

IDisposable disposable2 = dropDownControl
.GetPropertyChangedObservable(InputElement.IsKeyboardFocusWithinProperty)
.Subscribe(new AnonymousObserver<AvaloniaPropertyChangedEventArgs>(eventArgs =>
{
if (!(bool)eventArgs.NewValue! && !parentControl.IsKeyboardFocusWithin)
if (!(bool)eventArgs.NewValue! && !parentControl!.IsKeyboardFocusWithin)
Dispatcher.UIThread.Post(() =>
{
parentControl.SetValue(dropDownProperty, false);
focusParentAction(parentControl);
parentControl!.SetValue(dropDownProperty, false);
focusParentAction(parentControl!);
});
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ static MenuExtensions()
if (!(bool)eventArgs.NewValue!)
Dispatcher.UIThread.Post(() =>
{
var focusedControl = (Control)AvaloniaLocator.Current.GetRequiredService<IFocusManager>()!.GetFocusedElement()!;
var focusedControl = (Control)AvaloniaLocator.Current.GetRequiredService<IFocusManager>()!.GetFocusedElement();
var menuItems = visual.GetLogicalAncestors().OfType<MenuItem>();

var focusedTree = focusedControl.GetLogicalAncestors();
var focusedTree = focusedControl!.GetLogicalAncestors();

foreach (MenuItem menuItem in menuItems.Where(item => !focusedTree.Contains(item))
.ToArray())
Expand Down

0 comments on commit c1de176

Please sign in to comment.