Compare commits

6 Commits

Author SHA1 Message Date
xyy
e941113da9 2026-03-16 15:36:54 +08:00
xyy
533ca5a0fd 2026-03-16 11:17:49 +08:00
xyy
98d0111560 2026-03-14 19:21:11 +08:00
xyy
0bc8dce03e 2026-03-13 10:31:33 +08:00
xyy
b2848b4510 2026-03-11 15:31:20 +08:00
xyy
9b2d17d0ea 2026-03-11 15:24:40 +08:00
19 changed files with 839 additions and 242 deletions

View File

@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:自救器呼吸器综合检验仪"
Title="自救器呼吸器综合检验仪" Height="900" Width="1280"
Title="自救器呼吸器综合检验仪" Height="730" Width="1024"
WindowStartupLocation="CenterScreen"
Background="Transparent"
FontFamily="Microsoft YaHeui" Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing">
@@ -72,7 +72,7 @@
FontSize="14" Foreground="#CCFFFFFF" Margin="0,5,0,0"/>-->
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Center">
<TextBlock Text="样品编号:" FontSize="26" FontWeight="Bold" Foreground="White" Style="{StaticResource LabelStyle}"/>
<TextBlock Text="样品编号:" FontSize="26" FontWeight="Bold" Foreground="White" Margin="200 0 0 0" Style="{StaticResource LabelStyle}"/>
<TextBox x:Name="pressureDiff2" Text="" Width="180" Style="{StaticResource TextBoxStyle}" LostFocus="pressureDiff2_GotFocus"/>
</StackPanel>
@@ -100,6 +100,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<!-- 左侧:配置与监控区 -->
@@ -120,9 +121,9 @@
<!-- 检验时间配置 -->
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="检验时间:" Width="100" VerticalAlignment="Center"
<TextBlock Text="检验时间:" Width="84" VerticalAlignment="Center"
FontSize="14" FontWeight="SemiBold" Foreground="#2C3E50"/>
<TextBox x:Name="settingtime" Text="0" Width="100" Height="35"
<TextBox x:Name="settingtime" Text="0" Width="66" Height="34"
VerticalContentAlignment="Center" TextAlignment="Center"
BorderBrush="#DCDFE6" BorderThickness="1" Background="#FAFBFC"
FontSize="14" TextChanged="settingtime_TextChanged"/>
@@ -131,17 +132,17 @@
<Button Content="🔧 设置参数" Click="BtnWrite401_Click"
Background="#3498DB" Foreground="White" FontSize="13" FontWeight="Bold"
Width="120" Height="38" BorderThickness="0" Margin="0,0,25,0"
Width="100" Height="38" BorderThickness="0" Margin="-30,0,25,0"
Cursor="Hand"/>
<Button x:Name="btn_flow2" Content="定量供氧L/min" Click="BtnWrite400_Click"
Background="#3498DB" Foreground="White" FontSize="13" FontWeight="Bold"
Width="120" Height="38" BorderThickness="0" Margin="0,0,25,0"
Width="100" Height="38" BorderThickness="0" Margin="-20,0,25,0"
Cursor="Hand"/>
<Button x:Name="btn_flow3" Content="自动/手动补给供氧(L/min)" Click="BtnWrite400_Click1"
Background="#3498DB" Foreground="White" FontSize="13" FontWeight="Bold"
Width="174" Height="38" BorderThickness="0" Margin="0,0,25,0"
Width="157" Height="38" BorderThickness="0" Margin="-20,0,25,0"
Cursor="Hand"/>
@@ -286,7 +287,7 @@
<Button Content="🔬 定量供应检验"
Background="#3498DB" Foreground="White" FontSize="12" FontWeight="Bold"
Width="140" Height="40" BorderThickness="0" Margin="8,5" Cursor="Hand"/>
Width="140" Height="40" BorderThickness="0" Margin="8,5" Cursor="Hand" Click="Button_Click_8"/>
<Button Content="📉 负压气密性检验" Click="Button_Click_5"
Background="White" Foreground="#2C3E50" FontSize="12" FontWeight="Bold"
@@ -305,5 +306,6 @@
</StackPanel>
</Border>
</Grid>
</Grid>
</Window>

View File

@@ -14,6 +14,7 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
@@ -282,6 +283,7 @@ namespace 自救器呼吸器综合检验仪
private void Window_Loaded(object sender, RoutedEventArgs e)
{
string plcIp = "192.168.1.10";
//string plcIp = "127.0.0.1";
bool initSuccess = Data.ModbusResourceManager.Instance.Init(plcIp, 502);
if (!initSuccess)
{
@@ -384,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. 复用窗口实例:不存在则创建,存在则激活
// 创建一个简易的加载覆盖窗口,作为状态栏/遮罩,避免白屏
Window overlay = null;
try
{
overlay = new Window
{
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
};
// 内容:底部居中的状态文本(不遮挡背景)
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.Show();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
//return;
ShowTargetWindow(windowInstance);
}
}
catch (Exception ex)
{
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态)
this.Hide();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
}
// 添加重连方法
@@ -635,6 +699,11 @@ namespace 自救器呼吸器综合检验仪
{
}
private void Button_Click_8(object sender, RoutedEventArgs e)
{
}
}

View File

@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:自救器呼吸器综合检验仪"
Title="自救器呼吸器综合检验仪" Height="900" Width="1280"
Title="自救器呼吸器综合检验仪" Height="730" Width="1024"
WindowStartupLocation="CenterScreen"
Background="Transparent"
FontFamily="Microsoft YaHeui" Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing">

View File

@@ -17,6 +17,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Windows.Media.Animation;
using ;
using .Data;
@@ -478,44 +479,98 @@ 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. 复用窗口实例:不存在则创建,存在则激活
Window overlay = null;
try
{
overlay = new Window
{
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
};
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.Show();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
//return;
ShowTargetWindow(windowInstance);
}
}
catch (Exception ex)
{
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态)
this.Hide();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
}
// 添加重连方法
private bool TryReconnect()
@@ -643,7 +698,7 @@ namespace 自救器呼吸器综合检验仪
}
string No = ConfigurationManager.AppSettings["No"]?.ToString();
// 添加记录到窗口(无论窗口是否显示)
_reportWindow2.AddRecord(currentTime, currentDate, startPress, endPress, diffPress, ProtectTime,No);
_reportWindow2.AddRecord(currentTime, currentDate, startPress, endPress, diffPress, ProtectTime, No);
});
}

View File

@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:自救器呼吸器综合检验仪"
Title="自救器呼吸器综合检验仪" Height="900" Width="1280"
Title="自救器呼吸器综合检验仪" Height="730" Width="1024"
WindowStartupLocation="CenterScreen"
Background="Transparent"
FontFamily="Microsoft YaHeui"

View File

@@ -17,6 +17,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Windows.Media.Animation;
using ;
using .Data;
@@ -451,44 +452,98 @@ 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. 复用窗口实例:不存在则创建,存在则激活
Window overlay = null;
try
{
overlay = new Window
{
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
};
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.Show();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
//return;
ShowTargetWindow(windowInstance);
}
}
catch (Exception ex)
{
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态)
this.Hide();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
}
// 添加重连方法
private bool TryReconnect()

View File

@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:自救器呼吸器综合检验仪"
Title="自救器呼吸器综合检验仪" Height="900" Width="1280"
Title="自救器呼吸器综合检验仪" Height="730" Width="1024"
WindowStartupLocation="CenterScreen"
Background="Transparent"
FontFamily="Microsoft YaHeui"

View File

@@ -17,6 +17,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Windows.Media.Animation;
using ;
using .Data;
@@ -296,44 +297,98 @@ 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. 复用窗口实例:不存在则创建,存在则激活
Window overlay = null;
try
{
overlay = new Window
{
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
};
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.Show();
this.Activate();
};
ShowTargetWindow(windowInstance);
}
else
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
//return;
ShowTargetWindow(windowInstance);
}
}
catch (Exception ex)
{
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态)
this.Hide();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
}
private bool TryReconnect()
{

View File

@@ -1,7 +1,7 @@
<Window x:Class="自救器呼吸器综合检验仪.ParameterSettingsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="参数设置" Height="768" Width="1024"
Title="参数设置" Height="730" Width="1024"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize" Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing">

View File

@@ -6,6 +6,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using System.Windows.Media.Animation;
using .Data;
namespace
@@ -118,44 +119,100 @@ 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. 复用窗口实例:不存在则创建,存在则激活
Window overlay = null;
try
{
overlay = new Window
{
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
};
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
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
return;
ShowTargetWindow(windowInstance);
}
}
catch (Exception ex)
{
overlay?.Close();
ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态)
this.Hide();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
}

View File

@@ -1,7 +1,7 @@
<Window x:Class="自救器呼吸器综合检验仪.ReportWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="定量供氧检验报表" Height="900" Width="1280"
Title="定量供氧检验报表" Height="730" Width="1024"
WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing" >
<Grid>
<Grid.RowDefinitions>

View File

@@ -10,6 +10,7 @@ using System.Text;
using System.Windows;
using System.Windows.Controls;
using .Data;
using System.Windows.Media.Animation;
namespace
{
@@ -230,6 +231,14 @@ namespace 自救器呼吸器综合检验仪
private void BtnPrint_Click(object sender, RoutedEventArgs e)
{
// 判断是否有数据可打印
if (_records == null || _records.Count == 0)
{
MessageBox.Show("当前没有可打印的数据。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
// 触发打印/硬件动作
ma.BtnClickFunctionForNew(Function.ButtonType., 15);
}
@@ -254,42 +263,96 @@ namespace 自救器呼吸器综合检验仪
private void SwitchWindow<T>(ref T windowInstance, Func<T> createFunc) where T : Window, new()
{
// 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
{
// 窗口关闭时重新启动定时器并显示当前窗口
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
};
}
else
var grid = new Grid();
var tb = new TextBlock
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
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;
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态)
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();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
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);
}
}
catch (Exception ex)
{
overlay?.Close();
//ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}
private void BtnClose_Click(object sender, RoutedEventArgs e)

View File

@@ -1,7 +1,7 @@
<Window x:Class="自救器呼吸器综合检验仪.ReportWindow2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="负压气密性检验报表" Height="900" Width="1280"
Title="负压气密性检验报表" Height="730" Width="1024"
WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing">
<Grid>
<Grid.RowDefinitions>

View File

@@ -10,6 +10,7 @@ using System.Text;
using System.Windows;
using System.Windows.Controls;
using .Data;
using System.Windows.Media.Animation;
namespace
{
@@ -250,6 +251,12 @@ namespace 自救器呼吸器综合检验仪
private void BtnPrint_Click(object sender, RoutedEventArgs e)
{
// 判断是否有数据可打印
if (_records == null || _records.Count == 0)
{
MessageBox.Show("当前没有可打印的数据。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
ma.BtnClickFunctionForNew(Function.ButtonType., 15);
}
@@ -274,42 +281,96 @@ namespace 自救器呼吸器综合检验仪
private void SwitchWindow<T>(ref T windowInstance, Func<T> createFunc) where T : Window, new()
{
// 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
{
// 窗口关闭时重新启动定时器并显示当前窗口
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
};
}
else
var grid = new Grid();
var tb = new TextBlock
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
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;
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态)
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();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
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);
}
}
catch (Exception ex)
{
overlay?.Close();
//ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}
private void BtnClose_Click(object sender, RoutedEventArgs e)

View File

@@ -1,7 +1,7 @@
<Window x:Class="自救器呼吸器综合检验仪.ReportWindow3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="正压气密性检验报表" Height="900" Width="1280"
Title="正压气密性检验报表" Height="730" Width="1024"
WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing">
<Grid>
<Grid.RowDefinitions>

View File

@@ -10,6 +10,8 @@ using System.Text;
using System.Windows;
using System.Windows.Controls;
using .Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace
{
@@ -191,6 +193,12 @@ namespace 自救器呼吸器综合检验仪
private void BtnPrint_Click(object sender, RoutedEventArgs e)
{
// 判断是否有数据可打印
if (_records == null || _records.Count == 0)
{
MessageBox.Show("当前没有可打印的数据。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
ma.BtnClickFunctionForNew(Function.ButtonType., 15);
}
@@ -272,42 +280,96 @@ namespace 自救器呼吸器综合检验仪
private void SwitchWindow<T>(ref T windowInstance, Func<T> createFunc) where T : Window, new()
{
// 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
{
// 窗口关闭时重新启动定时器并显示当前窗口
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
};
}
else
var grid = new Grid();
var tb = new TextBlock
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
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;
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态)
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();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
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);
}
}
catch (Exception ex)
{
overlay?.Close();
//ShowErrorMsg($"切换窗口失败:{ex.Message}");
}
}
private void BtnClose_Click(object sender, RoutedEventArgs e)

View File

@@ -1,7 +1,7 @@
<Window x:Class="自救器呼吸器综合检验仪.ReportWindow4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="排气阀检验报表" Height="900" Width="1280"
Title="排气阀检验报表" Height="730" Width="1024"
WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing" >
<Grid>
<Grid.RowDefinitions>

View File

@@ -10,6 +10,8 @@ using System.Text;
using System.Windows;
using System.Windows.Controls;
using .Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace
{
@@ -233,6 +235,12 @@ namespace 自救器呼吸器综合检验仪
private void BtnPrint_Click(object sender, RoutedEventArgs e)
{
// 判断是否有数据可打印
if (_records == null || _records.Count == 0)
{
MessageBox.Show("当前没有可打印的数据。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
ma.BtnClickFunctionForNew(Function.ButtonType., 15);
}
@@ -313,42 +321,96 @@ namespace 自救器呼吸器综合检验仪
private void SwitchWindow<T>(ref T windowInstance, Func<T> createFunc) where T : Window, new()
{
// 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
{
// 窗口关闭时重新启动定时器并显示当前窗口
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
};
}
else
var grid = new Grid();
var tb = new TextBlock
{
// 激活已存在的窗口(前置显示)
windowInstance.Activate();
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;
}
// 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态)
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();
windowInstance.Show(); // 使用 Show() 而不是 ShowDialog()
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);
}
}
catch (Exception ex)
{
overlay?.Close();
MessageBox.Show($"切换窗口失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void BtnClose_Click(object sender, RoutedEventArgs e)

56
oxygen_testsystem.sql Normal file
View File

@@ -0,0 +1,56 @@
-- --------------------------------------------------------
-- 主机: 127.0.0.1
-- 服务器版本: 10.3.2-MariaDB - mariadb.org binary distribution
-- 服务器操作系统: Win64
-- HeidiSQL 版本: 9.4.0.5125
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- 导出 oxygen_testsystem 的数据库结构
DROP DATABASE IF EXISTS `oxygen_testsystem`;
CREATE DATABASE IF NOT EXISTS `oxygen_testsystem` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `oxygen_testsystem`;
-- 导出 表 oxygen_testsystem.test_records 结构
DROP TABLE IF EXISTS `test_records`;
CREATE TABLE IF NOT EXISTS `test_records` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Time` varchar(10) NOT NULL,
`Date` varchar(10) NOT NULL,
`FlowRate` decimal(10,2) NOT NULL,
`Duration` varchar(10) NOT NULL,
`CreateTime` datetime NOT NULL,
`Type` int(11) NOT NULL,
`FlowRate2` decimal(10,2) unsigned zerofill DEFAULT NULL,
`No` varchar(50) NOT NULL,
PRIMARY KEY (`Id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=139 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- 数据导出被取消选择。
-- 导出 表 oxygen_testsystem.test_recordsfornegativepressure 结构
DROP TABLE IF EXISTS `test_recordsfornegativepressure`;
CREATE TABLE IF NOT EXISTS `test_recordsfornegativepressure` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Time` varchar(10) NOT NULL,
`Date` varchar(10) NOT NULL,
`StartPress` decimal(10,2) NOT NULL,
`Duration` varchar(10) DEFAULT NULL,
`CreateTime` datetime NOT NULL,
`EndPress` decimal(10,2) NOT NULL,
`DiffPress` decimal(10,2) NOT NULL,
`ProtectTime` decimal(10,2) NOT NULL,
`Type` int(11) NOT NULL,
`No` varchar(50) NOT NULL,
PRIMARY KEY (`Id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- 数据导出被取消选择。
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;