This commit is contained in:
@@ -386,44 +386,106 @@ namespace 自救器呼吸器综合检验仪
|
|||||||
|
|
||||||
private void SwitchWindow<T>(ref T windowInstance, Func<T> createFunc) where T : Window, new()
|
private void SwitchWindow<T>(ref T windowInstance, Func<T> createFunc) where T : Window, new()
|
||||||
{
|
{
|
||||||
// 1. 停止当前窗口的定时器(不释放资源)
|
// 停止当前窗口的定时器(不释放资源)
|
||||||
_readTimer?.Stop();
|
_readTimer?.Stop();
|
||||||
|
|
||||||
// 2. 检查资源是否可用(添加重连机制)
|
// 检查资源是否可用(添加重连机制)
|
||||||
if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null)
|
if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null)
|
||||||
{
|
{
|
||||||
// 尝试重新连接
|
if (!TryReconnect())
|
||||||
bool reconnectSuccess = TryReconnect();
|
|
||||||
if (!reconnectSuccess)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("TCP连接已断开,请重新连接!", "提示");
|
MessageBox.Show("TCP连接已断开,请重新连接!", "提示");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 复用窗口实例:不存在则创建,存在则激活
|
// 创建一个简易的加载覆盖窗口,作为状态栏/遮罩,避免白屏
|
||||||
if (windowInstance == null)
|
Window overlay = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
windowInstance = createFunc();
|
overlay = new Window
|
||||||
// 添加窗口关闭事件处理
|
|
||||||
windowInstance.Closed += (s, args) =>
|
|
||||||
{
|
{
|
||||||
// 窗口关闭时重新启动定时器并显示当前窗口
|
Owner = this,
|
||||||
_readTimer?.Start();
|
WindowStyle = WindowStyle.None,
|
||||||
//this.Show();
|
AllowsTransparency = true,
|
||||||
this.Activate();
|
// 取消遮罩背景色,使用完全透明背景以避免暗色遮罩
|
||||||
|
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();
|
var grid = new Grid();
|
||||||
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
|
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}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加重连方法
|
// 添加重连方法
|
||||||
|
|||||||
@@ -490,43 +490,86 @@ namespace 自救器呼吸器综合检验仪
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowTargetWindow(T target)
|
Window overlay = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (target.IsVisible)
|
overlay = new Window
|
||||||
{
|
{
|
||||||
target.Activate();
|
Owner = this,
|
||||||
this.Hide();
|
WindowStyle = WindowStyle.None,
|
||||||
return;
|
AllowsTransparency = true,
|
||||||
}
|
Background = Brushes.Transparent,
|
||||||
|
ShowInTaskbar = false,
|
||||||
target.Opacity = 0;
|
ResizeMode = ResizeMode.NoResize,
|
||||||
void OnContentRendered(object s, EventArgs e)
|
Width = this.ActualWidth,
|
||||||
{
|
Height = this.ActualHeight,
|
||||||
target.ContentRendered -= OnContentRendered;
|
Left = this.Left,
|
||||||
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
|
Top = this.Top,
|
||||||
target.BeginAnimation(Window.OpacityProperty, anim);
|
ShowActivated = false,
|
||||||
this.Hide();
|
Topmost = true
|
||||||
target.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
target.ContentRendered += OnContentRendered;
|
|
||||||
target.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowInstance == null)
|
|
||||||
{
|
|
||||||
windowInstance = createFunc();
|
|
||||||
windowInstance.Closed += (s, args) =>
|
|
||||||
{
|
|
||||||
_readTimer?.Start();
|
|
||||||
this.Activate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 添加重连方法
|
// 添加重连方法
|
||||||
|
|||||||
@@ -463,43 +463,86 @@ namespace 自救器呼吸器综合检验仪
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowTargetWindow(T target)
|
Window overlay = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (target.IsVisible)
|
overlay = new Window
|
||||||
{
|
{
|
||||||
target.Activate();
|
Owner = this,
|
||||||
this.Hide();
|
WindowStyle = WindowStyle.None,
|
||||||
return;
|
AllowsTransparency = true,
|
||||||
}
|
Background = Brushes.Transparent,
|
||||||
|
ShowInTaskbar = false,
|
||||||
target.Opacity = 0;
|
ResizeMode = ResizeMode.NoResize,
|
||||||
void OnContentRendered(object s, EventArgs e)
|
Width = this.ActualWidth,
|
||||||
{
|
Height = this.ActualHeight,
|
||||||
target.ContentRendered -= OnContentRendered;
|
Left = this.Left,
|
||||||
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
|
Top = this.Top,
|
||||||
target.BeginAnimation(Window.OpacityProperty, anim);
|
ShowActivated = false,
|
||||||
this.Hide();
|
Topmost = true
|
||||||
target.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
target.ContentRendered += OnContentRendered;
|
|
||||||
target.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowInstance == null)
|
|
||||||
{
|
|
||||||
windowInstance = createFunc();
|
|
||||||
windowInstance.Closed += (s, args) =>
|
|
||||||
{
|
|
||||||
_readTimer?.Start();
|
|
||||||
this.Activate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 添加重连方法
|
// 添加重连方法
|
||||||
|
|||||||
@@ -308,43 +308,86 @@ namespace 自救器呼吸器综合检验仪
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowTargetWindow(T target)
|
Window overlay = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (target.IsVisible)
|
overlay = new Window
|
||||||
{
|
{
|
||||||
target.Activate();
|
Owner = this,
|
||||||
this.Hide();
|
WindowStyle = WindowStyle.None,
|
||||||
return;
|
AllowsTransparency = true,
|
||||||
}
|
Background = Brushes.Transparent,
|
||||||
|
ShowInTaskbar = false,
|
||||||
target.Opacity = 0;
|
ResizeMode = ResizeMode.NoResize,
|
||||||
void OnContentRendered(object s, EventArgs e)
|
Width = this.ActualWidth,
|
||||||
{
|
Height = this.ActualHeight,
|
||||||
target.ContentRendered -= OnContentRendered;
|
Left = this.Left,
|
||||||
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
|
Top = this.Top,
|
||||||
target.BeginAnimation(Window.OpacityProperty, anim);
|
ShowActivated = false,
|
||||||
this.Hide();
|
Topmost = true
|
||||||
target.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
target.ContentRendered += OnContentRendered;
|
|
||||||
target.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowInstance == null)
|
|
||||||
{
|
|
||||||
windowInstance = createFunc();
|
|
||||||
windowInstance.Closed += (s, args) =>
|
|
||||||
{
|
|
||||||
_readTimer?.Start();
|
|
||||||
this.Activate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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()
|
private bool TryReconnect()
|
||||||
|
|||||||
@@ -131,44 +131,87 @@ namespace 自救器呼吸器综合检验仪
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowTargetWindow(T target)
|
Window overlay = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (target.IsVisible)
|
overlay = new Window
|
||||||
{
|
{
|
||||||
target.Activate();
|
Owner = this,
|
||||||
this.Hide();
|
WindowStyle = WindowStyle.None,
|
||||||
return;
|
AllowsTransparency = true,
|
||||||
}
|
Background = System.Windows.Media.Brushes.Transparent,
|
||||||
|
ShowInTaskbar = false,
|
||||||
target.Opacity = 0;
|
ResizeMode = ResizeMode.NoResize,
|
||||||
void OnContentRendered(object s, EventArgs e)
|
Width = this.ActualWidth,
|
||||||
{
|
Height = this.ActualHeight,
|
||||||
target.ContentRendered -= OnContentRendered;
|
Left = this.Left,
|
||||||
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
|
Top = this.Top,
|
||||||
target.BeginAnimation(Window.OpacityProperty, anim);
|
ShowActivated = false,
|
||||||
this.Hide();
|
Topmost = true
|
||||||
target.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
target.ContentRendered += OnContentRendered;
|
|
||||||
target.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowInstance == null)
|
|
||||||
{
|
|
||||||
windowInstance = createFunc();
|
|
||||||
windowInstance.Closed += (s, args) =>
|
|
||||||
{
|
|
||||||
_readTimer?.Start();
|
|
||||||
this.Show();
|
|
||||||
this.Activate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -272,43 +272,86 @@ namespace 自救器呼吸器综合检验仪
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowTargetWindow(T target)
|
Window overlay = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (target.IsVisible)
|
overlay = new Window
|
||||||
{
|
{
|
||||||
target.Activate();
|
Owner = this,
|
||||||
this.Hide();
|
WindowStyle = WindowStyle.None,
|
||||||
return;
|
AllowsTransparency = true,
|
||||||
}
|
Background = System.Windows.Media.Brushes.Transparent,
|
||||||
|
ShowInTaskbar = false,
|
||||||
target.Opacity = 0;
|
ResizeMode = ResizeMode.NoResize,
|
||||||
void OnContentRendered(object s, EventArgs e)
|
Width = this.ActualWidth,
|
||||||
{
|
Height = this.ActualHeight,
|
||||||
target.ContentRendered -= OnContentRendered;
|
Left = this.Left,
|
||||||
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
|
Top = this.Top,
|
||||||
target.BeginAnimation(Window.OpacityProperty, anim);
|
ShowActivated = false,
|
||||||
this.Hide();
|
Topmost = true
|
||||||
target.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
target.ContentRendered += OnContentRendered;
|
|
||||||
target.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowInstance == null)
|
|
||||||
{
|
|
||||||
windowInstance = createFunc();
|
|
||||||
windowInstance.Closed += (s, args) =>
|
|
||||||
{
|
|
||||||
this.Show();
|
|
||||||
this.Activate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -290,43 +290,86 @@ namespace 自救器呼吸器综合检验仪
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowTargetWindow(T target)
|
Window overlay = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (target.IsVisible)
|
overlay = new Window
|
||||||
{
|
{
|
||||||
target.Activate();
|
Owner = this,
|
||||||
this.Hide();
|
WindowStyle = WindowStyle.None,
|
||||||
return;
|
AllowsTransparency = true,
|
||||||
}
|
Background = System.Windows.Media.Brushes.Transparent,
|
||||||
|
ShowInTaskbar = false,
|
||||||
target.Opacity = 0;
|
ResizeMode = ResizeMode.NoResize,
|
||||||
void OnContentRendered(object s, EventArgs e)
|
Width = this.ActualWidth,
|
||||||
{
|
Height = this.ActualHeight,
|
||||||
target.ContentRendered -= OnContentRendered;
|
Left = this.Left,
|
||||||
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
|
Top = this.Top,
|
||||||
target.BeginAnimation(Window.OpacityProperty, anim);
|
ShowActivated = false,
|
||||||
this.Hide();
|
Topmost = true
|
||||||
target.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
target.ContentRendered += OnContentRendered;
|
|
||||||
target.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowInstance == null)
|
|
||||||
{
|
|
||||||
windowInstance = createFunc();
|
|
||||||
windowInstance.Closed += (s, args) =>
|
|
||||||
{
|
|
||||||
this.Show();
|
|
||||||
this.Activate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using System.Text;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using 自救器呼吸器综合检验仪.Data;
|
using 自救器呼吸器综合检验仪.Data;
|
||||||
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
|
||||||
namespace 自救器呼吸器综合检验仪
|
namespace 自救器呼吸器综合检验仪
|
||||||
@@ -288,43 +289,86 @@ namespace 自救器呼吸器综合检验仪
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowTargetWindow(T target)
|
Window overlay = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (target.IsVisible)
|
overlay = new Window
|
||||||
{
|
{
|
||||||
target.Activate();
|
Owner = this,
|
||||||
this.Hide();
|
WindowStyle = WindowStyle.None,
|
||||||
return;
|
AllowsTransparency = true,
|
||||||
}
|
Background = System.Windows.Media.Brushes.Transparent,
|
||||||
|
ShowInTaskbar = false,
|
||||||
target.Opacity = 0;
|
ResizeMode = ResizeMode.NoResize,
|
||||||
void OnContentRendered(object s, EventArgs e)
|
Width = this.ActualWidth,
|
||||||
{
|
Height = this.ActualHeight,
|
||||||
target.ContentRendered -= OnContentRendered;
|
Left = this.Left,
|
||||||
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
|
Top = this.Top,
|
||||||
target.BeginAnimation(Window.OpacityProperty, anim);
|
ShowActivated = false,
|
||||||
this.Hide();
|
Topmost = true
|
||||||
target.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
target.ContentRendered += OnContentRendered;
|
|
||||||
target.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowInstance == null)
|
|
||||||
{
|
|
||||||
windowInstance = createFunc();
|
|
||||||
windowInstance.Closed += (s, args) =>
|
|
||||||
{
|
|
||||||
this.Show();
|
|
||||||
this.Activate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using System.Text;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using 自救器呼吸器综合检验仪.Data;
|
using 自救器呼吸器综合检验仪.Data;
|
||||||
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
|
||||||
namespace 自救器呼吸器综合检验仪
|
namespace 自救器呼吸器综合检验仪
|
||||||
@@ -329,43 +330,86 @@ namespace 自救器呼吸器综合检验仪
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowTargetWindow(T target)
|
Window overlay = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (target.IsVisible)
|
overlay = new Window
|
||||||
{
|
{
|
||||||
target.Activate();
|
Owner = this,
|
||||||
this.Hide();
|
WindowStyle = WindowStyle.None,
|
||||||
return;
|
AllowsTransparency = true,
|
||||||
}
|
Background = System.Windows.Media.Brushes.Transparent,
|
||||||
|
ShowInTaskbar = false,
|
||||||
target.Opacity = 0;
|
ResizeMode = ResizeMode.NoResize,
|
||||||
void OnContentRendered(object s, EventArgs e)
|
Width = this.ActualWidth,
|
||||||
{
|
Height = this.ActualHeight,
|
||||||
target.ContentRendered -= OnContentRendered;
|
Left = this.Left,
|
||||||
var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
|
Top = this.Top,
|
||||||
target.BeginAnimation(Window.OpacityProperty, anim);
|
ShowActivated = false,
|
||||||
this.Hide();
|
Topmost = true
|
||||||
target.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
target.ContentRendered += OnContentRendered;
|
|
||||||
target.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowInstance == null)
|
|
||||||
{
|
|
||||||
windowInstance = createFunc();
|
|
||||||
windowInstance.Closed += (s, args) =>
|
|
||||||
{
|
|
||||||
this.Show();
|
|
||||||
this.Activate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user