From 689d5e7a806ac79888b8da3360a80b44e44c2ef9 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Tue, 17 Jan 2023 17:21:18 +0800 Subject: [PATCH] chore: modify open image logic. --- .../Controls/Image/ImageViewer.cs | 12 ++++++------ .../Controls/Window/ImageBrowser.cs | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs index faf3a6928..7257403f9 100644 --- a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs +++ b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs @@ -166,6 +166,8 @@ public class ImageViewer : Control private MouseBinding _mouseMoveBinding; + private ImageBrowser _imageBrowser; + #endregion Data #region ctor @@ -588,13 +590,11 @@ private void ButtonSave_OnClick(object sender, RoutedEventArgs e) private void ButtonWindowsOpen_OnClick(object sender, RoutedEventArgs e) { - try - { - Process.Start(ImgPath); - } - catch (Exception exception) + if (Uri is { } uri) { - MessageBox.Show(exception.Message); + _imageBrowser?.Close(); + _imageBrowser = new ImageBrowser(uri); + _imageBrowser.Show(); } } diff --git a/src/Shared/HandyControl_Shared/Controls/Window/ImageBrowser.cs b/src/Shared/HandyControl_Shared/Controls/Window/ImageBrowser.cs index ba6974352..c9039cbd6 100644 --- a/src/Shared/HandyControl_Shared/Controls/Window/ImageBrowser.cs +++ b/src/Shared/HandyControl_Shared/Controls/Window/ImageBrowser.cs @@ -43,6 +43,7 @@ public ImageBrowser() WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStyle = WindowStyle.None; + Topmost = true; AllowsTransparency = true; }