Skip to content

Commit

Permalink
Automated JetBrains cleanup
Browse files Browse the repository at this point in the history
Co-authored-by:  <[email protected]>
  • Loading branch information
github-actions[bot] committed Nov 30, 2024
1 parent 80ef015 commit e265f4a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 39 deletions.
44 changes: 22 additions & 22 deletions src/Consolonia.Core/Controls/MessageBox.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,6 @@ public MessageBox()
AttachedToVisualTree += OnShowDialog;
}

private void OnShowDialog(object sender, VisualTreeAttachmentEventArgs e)
{
// we don't hook this up until the dialog is shown as the visible state is driven off of the DataContext
// which is set at ShowDialogAsync() time.
AttachedToVisualTree -= OnShowDialog;
if (OkButton.IsVisible)
OkButton.AttachedToVisualTree += ButtonAttached;
else if (YesButton.IsVisible)
YesButton.AttachedToVisualTree += ButtonAttached;
else if (CancelButton.IsVisible)
CancelButton.AttachedToVisualTree += ButtonAttached;
else if (NoButton.IsVisible)
NoButton.AttachedToVisualTree += ButtonAttached;
}

private void ButtonAttached(object sender, VisualTreeAttachmentEventArgs e)
{
var button = (Button)sender;
button.AttachedToVisualTree -= ButtonAttached;
button.Focus();
}

public Mode Mode
{
get => _mode;
Expand Down Expand Up @@ -98,6 +76,28 @@ public object No
set => SetAndRaise(NoProperty, ref _no, value);
}

private void OnShowDialog(object sender, VisualTreeAttachmentEventArgs e)
{
// we don't hook this up until the dialog is shown as the visible state is driven off of the DataContext
// which is set at ShowDialogAsync() time.
AttachedToVisualTree -= OnShowDialog;
if (OkButton.IsVisible)
OkButton.AttachedToVisualTree += ButtonAttached;
else if (YesButton.IsVisible)
YesButton.AttachedToVisualTree += ButtonAttached;
else if (CancelButton.IsVisible)
CancelButton.AttachedToVisualTree += ButtonAttached;
else if (NoButton.IsVisible)
NoButton.AttachedToVisualTree += ButtonAttached;
}

private void ButtonAttached(object sender, VisualTreeAttachmentEventArgs e)
{
var button = (Button)sender;
button.AttachedToVisualTree -= ButtonAttached;
button.Focus();
}

public async Task<MessageBoxResult> ShowDialogAsync(Control parent, string text, string title = null)
{
DataContext = new MessageBoxViewModel(Mode, Ok, Cancel, Yes, No, text, title ?? Title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public IDrawingContextLayerImpl CreateOffscreenRenderTarget(PixelSize pixelSize,

public bool IsLost => false;

public IReadOnlyDictionary<Type, object> PublicFeatures { get; private set; } = new Dictionary<Type, object>();
public IReadOnlyDictionary<Type, object> PublicFeatures { get; } = new Dictionary<Type, object>();
}
}
14 changes: 7 additions & 7 deletions src/Consolonia.Core/Drawing/RenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ void IDrawingContextLayerImpl.Blit(IDrawingContextImpl context)

public bool IsCorrupted => false;

public IDrawingContextImpl CreateDrawingContext(bool useScaledDrawing)
{
if (useScaledDrawing)
throw new NotImplementedException("Consolonia doesn't support useScaledDrawing");
return new DrawingContextImpl(_consoleWindow);
}


private void OnResized(Size size, WindowResizeReason reason)
{
Expand Down Expand Up @@ -142,13 +149,6 @@ private void RenderToDevice()
}
}

public IDrawingContextImpl CreateDrawingContext(bool useScaledDrawing)
{
if (useScaledDrawing)
throw new NotImplementedException($"Consolonia doesn't support useScaledDrawing");
return new DrawingContextImpl(_consoleWindow);
}

private struct FlushingBuffer
{
//todo: move class out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,13 @@ private void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Handled) return;

if (e.Source is MenuItem)
{
return;
}
if (e.Source is MenuItem) return;

if (e.Key == Key.Escape)
{
// if there is a overlay popup, close it
var overlay = sender as OverlayPopupHost ??
((Visual)sender).FindDescendantOfType<OverlayPopupHost>();
OverlayPopupHost overlay = sender as OverlayPopupHost ??
((Visual)sender).FindDescendantOfType<OverlayPopupHost>();
if (overlay != null)
{
// it will have a popup as the parent.
Expand Down
6 changes: 3 additions & 3 deletions src/Consolonia.Core/Infrastructure/ConsoloniaPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public void Initialize()
AvaloniaLocator.CurrentMutable.Bind<IClipboard>()
.ToFunc(() =>
{
var assembly = Assembly.Load("Avalonia.Win32");
Assembly assembly = Assembly.Load("Avalonia.Win32");
ArgumentNullException.ThrowIfNull(assembly, "Avalonia.Win32");
var type = assembly.GetType(assembly.GetName().Name + ".ClipboardImpl");
Type type = assembly.GetType(assembly.GetName().Name + ".ClipboardImpl");
ArgumentNullException.ThrowIfNull(type, "ClipboardImpl");
IClipboard clipboard = Activator.CreateInstance(type) as IClipboard;
var clipboard = Activator.CreateInstance(type) as IClipboard;
ArgumentNullException.ThrowIfNull(clipboard, nameof(clipboard));
return clipboard;
});
Expand Down

0 comments on commit e265f4a

Please sign in to comment.