mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 05:06:36 +02:00
[ImageResizer] Workaround for exception in wpf ui. (#30225)
* [ImageResizer] Workaround for exception in wpf ui. * Adding try catch to the other 3 places the SystemThemeWatcher is used. Rearranging code in Image Resizer, which might solve the issue.
This commit is contained in:
@@ -49,7 +49,17 @@ public partial class OCROverlay : Window
|
|||||||
Top = screenRectangle.Top >= 0 ? screenRectangle.Top : screenRectangle.Top + (screenRectangle.Height / 2);
|
Top = screenRectangle.Top >= 0 ? screenRectangle.Top : screenRectangle.Top + (screenRectangle.Height / 2);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this, Wpf.Ui.Controls.WindowBackdropType.None);
|
|
||||||
|
// workaround for #30177
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this, Wpf.Ui.Controls.WindowBackdropType.None);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Exception in SystemThemeWatcher.Watch, issue 30177. {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
PopulateLanguageMenu();
|
PopulateLanguageMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Common.UI;
|
using Common.UI;
|
||||||
using ImageResizer.ViewModels;
|
using ImageResizer.ViewModels;
|
||||||
|
using ManagedCommon;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Wpf.Ui.Controls;
|
using Wpf.Ui.Controls;
|
||||||
using AppResources = ImageResizer.Properties.Resources;
|
using AppResources = ImageResizer.Properties.Resources;
|
||||||
@@ -18,7 +19,8 @@ namespace ImageResizer.Views
|
|||||||
public MainWindow(MainViewModel viewModel)
|
public MainWindow(MainViewModel viewModel)
|
||||||
{
|
{
|
||||||
DataContext = viewModel;
|
DataContext = viewModel;
|
||||||
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this);
|
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
if (OSVersionHelper.IsWindows11())
|
if (OSVersionHelper.IsWindows11())
|
||||||
{
|
{
|
||||||
@@ -29,7 +31,15 @@ namespace ImageResizer.Views
|
|||||||
WindowBackdropType = WindowBackdropType.None;
|
WindowBackdropType = WindowBackdropType.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeComponent();
|
// workaround for #30177
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this, WindowBackdropType);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Exception in SystemThemeWatcher.Watch, issue 30177. {ex.Message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> OpenPictureFiles()
|
public IEnumerable<string> OpenPictureFiles()
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ namespace PowerLauncher
|
|||||||
_settings = settings;
|
_settings = settings;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this);
|
|
||||||
|
|
||||||
if (OSVersionHelper.IsWindows11())
|
if (OSVersionHelper.IsWindows11())
|
||||||
{
|
{
|
||||||
WindowBackdropType = Wpf.Ui.Controls.WindowBackdropType.Acrylic;
|
WindowBackdropType = Wpf.Ui.Controls.WindowBackdropType.Acrylic;
|
||||||
@@ -67,6 +65,16 @@ namespace PowerLauncher
|
|||||||
WindowBackdropType = Wpf.Ui.Controls.WindowBackdropType.None;
|
WindowBackdropType = Wpf.Ui.Controls.WindowBackdropType.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// workaround for #30217
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this, WindowBackdropType);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Exception("Exception in SystemThemeWatcher.Watch, issue 30217.", ex, GetType());
|
||||||
|
}
|
||||||
|
|
||||||
_firstDeleteTimer.Elapsed += CheckForFirstDelete;
|
_firstDeleteTimer.Elapsed += CheckForFirstDelete;
|
||||||
_firstDeleteTimer.Interval = 1000;
|
_firstDeleteTimer.Interval = 1000;
|
||||||
NativeEventWaiter.WaitForEventLoop(
|
NativeEventWaiter.WaitForEventLoop(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using ManagedCommon;
|
||||||
using Wpf.Ui.Controls;
|
using Wpf.Ui.Controls;
|
||||||
using Point = PowerAccent.Core.Point;
|
using Point = PowerAccent.Core.Point;
|
||||||
using Size = PowerAccent.Core.Size;
|
using Size = PowerAccent.Core.Size;
|
||||||
@@ -38,7 +39,17 @@ public partial class Selector : FluentWindow, IDisposable, INotifyPropertyChange
|
|||||||
public Selector()
|
public Selector()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this);
|
|
||||||
|
// workaround for #30177
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Exception in SystemThemeWatcher.Watch, issue 30177. {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
Application.Current.MainWindow.ShowActivated = false;
|
Application.Current.MainWindow.ShowActivated = false;
|
||||||
Application.Current.MainWindow.Topmost = true;
|
Application.Current.MainWindow.Topmost = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user