启动加载页
This commit is contained in:
@@ -233,6 +233,12 @@ namespace MainModule.ViewModels
|
||||
}
|
||||
#region 命令处理与事件
|
||||
private async Task OnLoad()
|
||||
{
|
||||
// 设备初始化期间仅对当前台架显示灰度遮罩层,初始化完成后关闭(finally 保证异常时也能关闭)
|
||||
_eventAggregator.GetEvent<ScopeOverlayEvent>().Publish(new ScopeOverlayArgs { Scope = TestStatus, Show = true });
|
||||
// 让遮罩层先完成渲染,再进入同步阻塞的设备初始化(泵送 Dispatcher 至 Render 优先级)
|
||||
System.Windows.Application.Current?.Dispatcher.Invoke(() => { }, System.Windows.Threading.DispatcherPriority.Render);
|
||||
try
|
||||
{
|
||||
if (!IsInitialized)
|
||||
{
|
||||
@@ -240,6 +246,12 @@ namespace MainModule.ViewModels
|
||||
IsInitialized = true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_eventAggregator.GetEvent<ScopeOverlayEvent>().Publish(new ScopeOverlayArgs { Scope = TestStatus, Show = false });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnRefresh()
|
||||
{
|
||||
|
||||
@@ -128,6 +128,26 @@
|
||||
</vs:ParametersManager.Style>
|
||||
</vs:ParametersManager>
|
||||
|
||||
<Border x:Name="Overlay"
|
||||
Background="#40000000"
|
||||
Visibility="Collapsed"
|
||||
Panel.ZIndex="1"
|
||||
Grid.RowSpan="2"
|
||||
Grid.ColumnSpan="4">
|
||||
<StackPanel Width="150"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 0 0 100">
|
||||
<ProgressBar Width="80"
|
||||
Height="80"
|
||||
Margin="20"
|
||||
IsIndeterminate="True"
|
||||
Style="{StaticResource MaterialDesignCircularProgressBar}" />
|
||||
<TextBlock FontSize="30"
|
||||
Text="加载中......"
|
||||
HorizontalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using Prism.Events;
|
||||
using MainModule.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -12,6 +14,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using UIShare.PubEvent;
|
||||
|
||||
namespace MainModule.Views
|
||||
{
|
||||
@@ -20,9 +23,23 @@ namespace MainModule.Views
|
||||
/// </summary>
|
||||
public partial class AutomatedTestingView : UserControl
|
||||
{
|
||||
public AutomatedTestingView()
|
||||
public AutomatedTestingView(IEventAggregator eventAggregator)
|
||||
{
|
||||
InitializeComponent();
|
||||
eventAggregator.GetEvent<OverlayEvent>().Subscribe(ShowOverlay);
|
||||
// 台架级加载遮罩:仅台架名称匹配时响应,避免其他台架/主窗口同时变灰
|
||||
eventAggregator.GetEvent<ScopeOverlayEvent>().Subscribe(ShowScopeOverlay);
|
||||
}
|
||||
private void ShowOverlay(bool arg)
|
||||
{
|
||||
Overlay.Visibility = arg ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void ShowScopeOverlay(ScopeOverlayArgs args)
|
||||
{
|
||||
// 只处理属于当前台架的遮罩事件(TestStatus 在 OnNavigatedTo 时赋值)
|
||||
if (DataContext is not AutomatedTestingViewModel vm || vm.TestStatus != args.Scope) return;
|
||||
Overlay.Visibility = args.Show ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,22 @@ namespace UIShare.PubEvent
|
||||
public class OverlayEvent : PubSubEvent<bool>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 作用域感知的灰度遮罩事件:仅台架名称与 Scope 匹配的台架视图显示/隐藏加载遮罩,
|
||||
/// 避免全局 OverlayEvent 导致所有台架及主窗口同时变灰。
|
||||
/// </summary>
|
||||
public class ScopeOverlayEvent : PubSubEvent<ScopeOverlayArgs>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>作用域遮罩事件参数。</summary>
|
||||
public class ScopeOverlayArgs
|
||||
{
|
||||
/// <summary>台架名称(与 SystemConfig.Title / TestStatus 一致)。</summary>
|
||||
public string Scope { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>true 显示遮罩,false 隐藏遮罩。</summary>
|
||||
public bool Show { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user