From be911510f8c5c562f4041b52452f27705ac75044 Mon Sep 17 00:00:00 2001 From: Gleb Fomenko Date: Sun, 7 Aug 2022 20:31:38 +0300 Subject: [PATCH] Improvement: now main window is not topmost --- .../Commands/ChangeWindowVisibilityCommand.cs | 5 +++++ WallpapersSlideshower/ViewModels/MainWindowViewModel.cs | 3 +++ WallpapersSlideshower/Views/MainWindow.xaml | 2 +- WallpapersSlideshower/WallpapersSlideshower.csproj | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/WallpapersSlideshower/Commands/ChangeWindowVisibilityCommand.cs b/WallpapersSlideshower/Commands/ChangeWindowVisibilityCommand.cs index 60655e3..31fb10c 100644 --- a/WallpapersSlideshower/Commands/ChangeWindowVisibilityCommand.cs +++ b/WallpapersSlideshower/Commands/ChangeWindowVisibilityCommand.cs @@ -22,6 +22,11 @@ public override void Execute(object? parameter) if (parameter == null) throw new ArgumentNullException(nameof(parameter), "Argument can't be null."); var enableVisibility = (bool)parameter; _mainWindowViewModel.WindowVisibility = enableVisibility; + if (enableVisibility) + { + _mainWindowViewModel.Topmost = true; + _mainWindowViewModel.Topmost = false; + } } } } diff --git a/WallpapersSlideshower/ViewModels/MainWindowViewModel.cs b/WallpapersSlideshower/ViewModels/MainWindowViewModel.cs index 737637f..6146438 100644 --- a/WallpapersSlideshower/ViewModels/MainWindowViewModel.cs +++ b/WallpapersSlideshower/ViewModels/MainWindowViewModel.cs @@ -39,6 +39,9 @@ public class MainWindowViewModel : ViewModelBase public bool AutorunIsEnabled { get => _autorunIsEnabled; set => Set(ref _autorunIsEnabled, value); } private bool _autorunIsEnabled; + public bool Topmost { get => _topmost; set => Set(ref _topmost, value); } + private bool _topmost; + public WindowState WindowStateBeforeHide { get; set; } public ICommand SelectFolderCommand { get; } diff --git a/WallpapersSlideshower/Views/MainWindow.xaml b/WallpapersSlideshower/Views/MainWindow.xaml index 920f6e5..d547d0d 100644 --- a/WallpapersSlideshower/Views/MainWindow.xaml +++ b/WallpapersSlideshower/Views/MainWindow.xaml @@ -14,7 +14,7 @@ Title="Wallpapers Slideshower" Height="500" Width="1048" Icon="/Resources/Icons/wallpaper-svgrepo-com.ico" WindowState="{Binding WindowState, Mode=TwoWay}" - Topmost="True"> + Topmost="{Binding Topmost}"> diff --git a/WallpapersSlideshower/WallpapersSlideshower.csproj b/WallpapersSlideshower/WallpapersSlideshower.csproj index bd4386e..e9e783c 100644 --- a/WallpapersSlideshower/WallpapersSlideshower.csproj +++ b/WallpapersSlideshower/WallpapersSlideshower.csproj @@ -5,7 +5,7 @@ net6.0-windows enable true - 1.4.2 + 1.4.3