Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
pomianowski committed Jul 24, 2024
1 parent 66b42ee commit 45969c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
5 changes: 1 addition & 4 deletions samples/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ public partial class MainWindow : INavigationWindow
{
public ViewModels.MainWindowViewModel ViewModel { get; }

public MainWindow(
ViewModels.MainWindowViewModel viewModel,
INavigationService navigationService
)
public MainWindow(ViewModels.MainWindowViewModel viewModel, INavigationService navigationService)
{
ViewModel = viewModel;
DataContext = this;
Expand Down
23 changes: 14 additions & 9 deletions src/Wpf.Ui/Controls/MessageBox/MessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
// All Rights Reserved.

using System.Reflection;
#if NET8_0_OR_GREATER
using System.Runtime.CompilerServices;
#endif
using Wpf.Ui.Input;
using Wpf.Ui.Interop;
using Size = System.Windows.Size;
#if NET8_0_OR_GREATER
using System.Runtime.CompilerServices;
#endif

// ReSharper disable once CheckNamespace
namespace Wpf.Ui.Controls;
Expand Down Expand Up @@ -236,8 +236,10 @@ public bool IsPrimaryButtonEnabled
/// </summary>
public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty);

private static readonly PropertyInfo CanCenterOverWPFOwnerPropertyInfo =
typeof(Window).GetProperty("CanCenterOverWPFOwner", BindingFlags.NonPublic | BindingFlags.Instance)!;
private static readonly PropertyInfo CanCenterOverWPFOwnerPropertyInfo = typeof(Window).GetProperty(
"CanCenterOverWPFOwner",
BindingFlags.NonPublic | BindingFlags.Instance
)!;

/// <summary>
/// Initializes a new instance of the <see cref="MessageBox"/> class.
Expand Down Expand Up @@ -333,8 +335,10 @@ protected virtual void OnLoaded()
CenterWindowOnScreen();
break;
case WindowStartupLocation.CenterOwner:
if (!CanCenterOverWPFOwner() ||
Owner.WindowState is WindowState.Maximized or WindowState.Minimized)
if (
!CanCenterOverWPFOwner()
|| Owner.WindowState is WindowState.Maximized or WindowState.Minimized
)
{
CenterWindowOnScreen();
}
Expand All @@ -344,15 +348,16 @@ protected virtual void OnLoaded()
}

break;
default: throw new InvalidOperationException();
default:
throw new InvalidOperationException();
}
}

// CanCenterOverWPFOwner property see https://source.dot.net/#PresentationFramework/System/Windows/Window.cs,e679e433777b21b8
private bool CanCenterOverWPFOwner()
{
#if NET8_0_OR_GREATER
return CanCenterOverWPFOwnerAccessor(this);
return CanCenterOverWPFOwnerAccessor(this);
#else
return (bool)CanCenterOverWPFOwnerPropertyInfo.GetValue(this)!;
#endif
Expand Down

0 comments on commit 45969c0

Please sign in to comment.