This commit is contained in:
@@ -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}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user