This commit is contained in:
xyy
2026-03-16 15:36:54 +08:00
parent 533ca5a0fd
commit e941113da9
9 changed files with 681 additions and 273 deletions

View File

@@ -386,44 +386,106 @@ namespace 自救器呼吸器综合检验仪
private void SwitchWindow<T>(ref T windowInstance, Func<T> createFunc) where T : Window, new()
{
// 1. 停止当前窗口的定时器(不释放资源)
// 停止当前窗口的定时器(不释放资源)
_readTimer?.Stop();
// 2. 检查资源是否可用(添加重连机制)
// 检查资源是否可用(添加重连机制)
if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null)
{
// 尝试重新连接
bool reconnectSuccess = TryReconnect();
if (!reconnectSuccess)
if (!TryReconnect())
{
MessageBox.Show("TCP连接已断开请重新连接", "提示");
return;
}
}
// 3. 复用窗口实例:不存在则创建,存在则激活
if (windowInstance == null)
// 创建一个简易的加载覆盖窗口,作为状态栏/遮罩,避免白屏
Window overlay = null;
try
{
windowInstance = createFunc();
// 添加窗口关闭事件处理
windowInstance.Closed += (s, args) =>
overlay = new Window
{
// 窗口关闭时重新启动定时器并显示当前窗口
_readTimer?.Start();
//this.Show();
this.Activate();
Owner = this,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
// 取消遮罩背景色,使用完全透明背景以避免暗色遮罩
Background = Brushes.Transparent,
ShowInTaskbar = false,
ResizeMode = ResizeMode.NoResize,
Width = this.ActualWidth,
Height = this.ActualHeight,
Left = this.Left,
Top = this.Top,
ShowActivated = false,
Topmost = true
};
}
else
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
//return;
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态
this.Hide();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
// 内容:底部居中的状态文本(不遮挡背景
var grid = new Grid();
var tb = new TextBlock
{
Text = "正在加载,请稍候...",
Foreground = Brushes.Black,
Background = Brushes.Transparent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 20),
FontSize = 16
};
grid.Children.Add(tb);
overlay.Content = grid;
// 显示遮罩
overlay.Show();
void ShowTargetWindow(T target)
{
// 如果目标已可见,直接激活并隐藏当前
if (target.IsVisible)
{
target.Activate();
this.Hide();
overlay?.Close();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
overlay?.Close();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
// 创建或复用窗口实例
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
_readTimer?.Start();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
ShowTargetWindow(windowInstance);
}
}
catch (Exception ex)
{
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}
// 添加重连方法

View File

@@ -490,43 +490,86 @@ namespace 自救器呼吸器综合检验仪
}
}
void ShowTargetWindow(T target)
Window overlay = null;
try
{
if (target.IsVisible)
overlay = new Window
{
target.Activate();
this.Hide();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
_readTimer?.Start();
this.Activate();
Owner = this,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
Background = Brushes.Transparent,
ShowInTaskbar = false,
ResizeMode = ResizeMode.NoResize,
Width = this.ActualWidth,
Height = this.ActualHeight,
Left = this.Left,
Top = this.Top,
ShowActivated = false,
Topmost = true
};
ShowTargetWindow(windowInstance);
var grid = new Grid();
var tb = new TextBlock
{
Text = "正在加载,请稍候...",
Foreground = Brushes.Black,
Background = Brushes.Transparent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 20),
FontSize = 16
};
grid.Children.Add(tb);
overlay.Content = grid;
overlay.Show();
void ShowTargetWindow(T target)
{
if (target.IsVisible)
{
target.Activate();
this.Hide();
overlay?.Close();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
overlay?.Close();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
_readTimer?.Start();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
ShowTargetWindow(windowInstance);
}
}
else
catch (Exception ex)
{
ShowTargetWindow(windowInstance);
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}
// 添加重连方法

View File

@@ -463,43 +463,86 @@ namespace 自救器呼吸器综合检验仪
}
}
void ShowTargetWindow(T target)
Window overlay = null;
try
{
if (target.IsVisible)
overlay = new Window
{
target.Activate();
this.Hide();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
_readTimer?.Start();
this.Activate();
Owner = this,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
Background = Brushes.Transparent,
ShowInTaskbar = false,
ResizeMode = ResizeMode.NoResize,
Width = this.ActualWidth,
Height = this.ActualHeight,
Left = this.Left,
Top = this.Top,
ShowActivated = false,
Topmost = true
};
ShowTargetWindow(windowInstance);
var grid = new Grid();
var tb = new TextBlock
{
Text = "正在加载,请稍候...",
Foreground = Brushes.Black,
Background = Brushes.Transparent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 20),
FontSize = 16
};
grid.Children.Add(tb);
overlay.Content = grid;
overlay.Show();
void ShowTargetWindow(T target)
{
if (target.IsVisible)
{
target.Activate();
this.Hide();
overlay?.Close();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
overlay?.Close();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
_readTimer?.Start();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
ShowTargetWindow(windowInstance);
}
}
else
catch (Exception ex)
{
ShowTargetWindow(windowInstance);
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}
// 添加重连方法

View File

@@ -308,43 +308,86 @@ namespace 自救器呼吸器综合检验仪
}
}
void ShowTargetWindow(T target)
Window overlay = null;
try
{
if (target.IsVisible)
overlay = new Window
{
target.Activate();
this.Hide();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
_readTimer?.Start();
this.Activate();
Owner = this,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
Background = Brushes.Transparent,
ShowInTaskbar = false,
ResizeMode = ResizeMode.NoResize,
Width = this.ActualWidth,
Height = this.ActualHeight,
Left = this.Left,
Top = this.Top,
ShowActivated = false,
Topmost = true
};
ShowTargetWindow(windowInstance);
var grid = new Grid();
var tb = new TextBlock
{
Text = "正在加载,请稍候...",
Foreground = Brushes.Black,
Background = Brushes.Transparent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 20),
FontSize = 16
};
grid.Children.Add(tb);
overlay.Content = grid;
overlay.Show();
void ShowTargetWindow(T target)
{
if (target.IsVisible)
{
target.Activate();
this.Hide();
overlay?.Close();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
overlay?.Close();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
_readTimer?.Start();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
ShowTargetWindow(windowInstance);
}
}
else
catch (Exception ex)
{
ShowTargetWindow(windowInstance);
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}
private bool TryReconnect()

View File

@@ -131,44 +131,87 @@ namespace 自救器呼吸器综合检验仪
}
}
void ShowTargetWindow(T target)
Window overlay = null;
try
{
if (target.IsVisible)
overlay = new Window
{
target.Activate();
this.Hide();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
_readTimer?.Start();
this.Show();
this.Activate();
Owner = this,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
Background = System.Windows.Media.Brushes.Transparent,
ShowInTaskbar = false,
ResizeMode = ResizeMode.NoResize,
Width = this.ActualWidth,
Height = this.ActualHeight,
Left = this.Left,
Top = this.Top,
ShowActivated = false,
Topmost = true
};
ShowTargetWindow(windowInstance);
var grid = new Grid();
var tb = new TextBlock
{
Text = "正在加载,请稍候...",
Foreground = System.Windows.Media.Brushes.Black,
Background = System.Windows.Media.Brushes.Transparent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 20),
FontSize = 16
};
grid.Children.Add(tb);
overlay.Content = grid;
overlay.Show();
void ShowTargetWindow(T target)
{
if (target.IsVisible)
{
target.Activate();
this.Hide();
overlay?.Close();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
overlay?.Close();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
_readTimer?.Start();
this.Show();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
ShowTargetWindow(windowInstance);
}
}
else
catch (Exception ex)
{
ShowTargetWindow(windowInstance);
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}

View File

@@ -272,43 +272,86 @@ namespace 自救器呼吸器综合检验仪
}
}
void ShowTargetWindow(T target)
Window overlay = null;
try
{
if (target.IsVisible)
overlay = new Window
{
target.Activate();
this.Hide();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
this.Show();
this.Activate();
Owner = this,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
Background = System.Windows.Media.Brushes.Transparent,
ShowInTaskbar = false,
ResizeMode = ResizeMode.NoResize,
Width = this.ActualWidth,
Height = this.ActualHeight,
Left = this.Left,
Top = this.Top,
ShowActivated = false,
Topmost = true
};
ShowTargetWindow(windowInstance);
var grid = new Grid();
var tb = new TextBlock
{
Text = "正在加载,请稍候...",
Foreground = System.Windows.Media.Brushes.Black,
Background = System.Windows.Media.Brushes.Transparent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 20),
FontSize = 16
};
grid.Children.Add(tb);
overlay.Content = grid;
overlay.Show();
void ShowTargetWindow(T target)
{
if (target.IsVisible)
{
target.Activate();
this.Hide();
overlay?.Close();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
overlay?.Close();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
this.Show();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
ShowTargetWindow(windowInstance);
}
}
else
catch (Exception ex)
{
ShowTargetWindow(windowInstance);
overlay?.Close();
//ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}

View File

@@ -290,43 +290,86 @@ namespace 自救器呼吸器综合检验仪
}
}
void ShowTargetWindow(T target)
Window overlay = null;
try
{
if (target.IsVisible)
overlay = new Window
{
target.Activate();
this.Hide();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
this.Show();
this.Activate();
Owner = this,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
Background = System.Windows.Media.Brushes.Transparent,
ShowInTaskbar = false,
ResizeMode = ResizeMode.NoResize,
Width = this.ActualWidth,
Height = this.ActualHeight,
Left = this.Left,
Top = this.Top,
ShowActivated = false,
Topmost = true
};
ShowTargetWindow(windowInstance);
var grid = new Grid();
var tb = new TextBlock
{
Text = "正在加载,请稍候...",
Foreground = System.Windows.Media.Brushes.Black,
Background = System.Windows.Media.Brushes.Transparent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 20),
FontSize = 16
};
grid.Children.Add(tb);
overlay.Content = grid;
overlay.Show();
void ShowTargetWindow(T target)
{
if (target.IsVisible)
{
target.Activate();
this.Hide();
overlay?.Close();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
overlay?.Close();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
this.Show();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
ShowTargetWindow(windowInstance);
}
}
else
catch (Exception ex)
{
ShowTargetWindow(windowInstance);
overlay?.Close();
//ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}

View File

@@ -10,6 +10,7 @@ using System.Text;
using System.Windows;
using System.Windows.Controls;
using .Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace
@@ -288,43 +289,86 @@ namespace 自救器呼吸器综合检验仪
}
}
void ShowTargetWindow(T target)
Window overlay = null;
try
{
if (target.IsVisible)
overlay = new Window
{
target.Activate();
this.Hide();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
this.Show();
this.Activate();
Owner = this,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
Background = System.Windows.Media.Brushes.Transparent,
ShowInTaskbar = false,
ResizeMode = ResizeMode.NoResize,
Width = this.ActualWidth,
Height = this.ActualHeight,
Left = this.Left,
Top = this.Top,
ShowActivated = false,
Topmost = true
};
ShowTargetWindow(windowInstance);
var grid = new Grid();
var tb = new TextBlock
{
Text = "正在加载,请稍候...",
Foreground = System.Windows.Media.Brushes.Black,
Background = System.Windows.Media.Brushes.Transparent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 20),
FontSize = 16
};
grid.Children.Add(tb);
overlay.Content = grid;
overlay.Show();
void ShowTargetWindow(T target)
{
if (target.IsVisible)
{
target.Activate();
this.Hide();
overlay?.Close();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
overlay?.Close();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
this.Show();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
ShowTargetWindow(windowInstance);
}
}
else
catch (Exception ex)
{
ShowTargetWindow(windowInstance);
overlay?.Close();
//ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}

View File

@@ -10,6 +10,7 @@ using System.Text;
using System.Windows;
using System.Windows.Controls;
using .Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace
@@ -329,43 +330,86 @@ namespace 自救器呼吸器综合检验仪
}
}
void ShowTargetWindow(T target)
Window overlay = null;
try
{
if (target.IsVisible)
overlay = new Window
{
target.Activate();
this.Hide();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
this.Show();
this.Activate();
Owner = this,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
Background = System.Windows.Media.Brushes.Transparent,
ShowInTaskbar = false,
ResizeMode = ResizeMode.NoResize,
Width = this.ActualWidth,
Height = this.ActualHeight,
Left = this.Left,
Top = this.Top,
ShowActivated = false,
Topmost = true
};
ShowTargetWindow(windowInstance);
var grid = new Grid();
var tb = new TextBlock
{
Text = "正在加载,请稍候...",
Foreground = System.Windows.Media.Brushes.Black,
Background = System.Windows.Media.Brushes.Transparent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 20),
FontSize = 16
};
grid.Children.Add(tb);
overlay.Content = grid;
overlay.Show();
void ShowTargetWindow(T target)
{
if (target.IsVisible)
{
target.Activate();
this.Hide();
overlay?.Close();
return;
}
target.Opacity = 0;
void OnContentRendered(object s, EventArgs e)
{
target.ContentRendered -= OnContentRendered;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
target.BeginAnimation(Window.OpacityProperty, anim);
this.Hide();
target.Activate();
overlay?.Close();
}
target.ContentRendered += OnContentRendered;
target.Show();
}
if (windowInstance == null)
{
windowInstance = createFunc();
windowInstance.Closed += (s, args) =>
{
this.Show();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
ShowTargetWindow(windowInstance);
}
}
else
catch (Exception ex)
{
ShowTargetWindow(windowInstance);
overlay?.Close();
MessageBox.Show($"切换窗口失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}