Commit 1435e982 by liulongfei

添加预览重启

parent 0f4c4d27
...@@ -69,6 +69,11 @@ namespace VIZ.Package.Domain ...@@ -69,6 +69,11 @@ namespace VIZ.Package.Domain
// ============================================================= // =============================================================
/// <summary> /// <summary>
/// Viz预览是否可用
/// </summary>
public static bool IsVizPreviewReadly { get; set; }
/// <summary>
/// Viz配置 /// Viz配置
/// </summary> /// </summary>
public static VizConfigEntity VizConfig { get; set; } public static VizConfigEntity VizConfig { get; set; }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// Viz引擎重启消息
/// </summary>
public class VizPreviewRestartMessage
{
}
}
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
<Compile Include="Message\Project\ProjectCloseMessage.cs" /> <Compile Include="Message\Project\ProjectCloseMessage.cs" />
<Compile Include="Message\Project\ProjectOpenMessage.cs" /> <Compile Include="Message\Project\ProjectOpenMessage.cs" />
<Compile Include="Message\Viz\VizPreviewReadyMessage.cs" /> <Compile Include="Message\Viz\VizPreviewReadyMessage.cs" />
<Compile Include="Message\Viz\VizPreviewRestartMessage.cs" />
<Compile Include="Model\Conn\ConnGroupModel.cs" /> <Compile Include="Model\Conn\ConnGroupModel.cs" />
<Compile Include="Model\Conn\ConnModel.cs" /> <Compile Include="Model\Conn\ConnModel.cs" />
<Compile Include="Core\IPackageEndpointManager.cs" /> <Compile Include="Core\IPackageEndpointManager.cs" />
......
...@@ -249,5 +249,8 @@ ...@@ -249,5 +249,8 @@
<ItemGroup> <ItemGroup>
<Resource Include="Icons\top_icon_about_20x20.png" /> <Resource Include="Icons\top_icon_about_20x20.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Icons\preview_refresh_32x32.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -52,6 +52,7 @@ namespace VIZ.Package.Module ...@@ -52,6 +52,7 @@ namespace VIZ.Package.Module
private void InitMessage() private void InitMessage()
{ {
ApplicationDomainEx.MessageManager.Register<VizPreviewReadyMessage>(this, this.OnVizPreviewReadyMessage); ApplicationDomainEx.MessageManager.Register<VizPreviewReadyMessage>(this, this.OnVizPreviewReadyMessage);
ApplicationDomainEx.MessageManager.Register<VizPreviewRestartMessage>(this, this.OnVizPreviewRestartMessage);
ApplicationDomainEx.MessageManager.Register<ApplicationClosingMessage>(this, this.OnApplicationClosingMessage); ApplicationDomainEx.MessageManager.Register<ApplicationClosingMessage>(this, this.OnApplicationClosingMessage);
} }
...@@ -361,6 +362,15 @@ namespace VIZ.Package.Module ...@@ -361,6 +362,15 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 预览引擎重启消息
/// </summary>
/// <param name="msg">消息</param>
private void OnVizPreviewRestartMessage(VizPreviewRestartMessage msg)
{
this.IsVizPreviewReady = false;
}
/// <summary>
/// 应用程序关闭前消息 /// 应用程序关闭前消息
/// </summary> /// </summary>
/// <param name="msg">消息</param> /// <param name="msg">消息</param>
......
...@@ -37,8 +37,6 @@ namespace VIZ.Package.Module ...@@ -37,8 +37,6 @@ namespace VIZ.Package.Module
/// <param name="conn">连接模型</param> /// <param name="conn">连接模型</param>
public void StartVizEngine(VizPreviewView view, string path, ConnModel conn) public void StartVizEngine(VizPreviewView view, string path, ConnModel conn)
{ {
this.ViewModel.IsEngineReady = false;
var dpi = WPFHelper.GetDpiByGraphics(); var dpi = WPFHelper.GetDpiByGraphics();
int width = (int)(view.host.ActualWidth * (dpi.X / 96d)); int width = (int)(view.host.ActualWidth * (dpi.X / 96d));
int height = (int)(view.host.ActualHeight * (dpi.Y / 96d)); int height = (int)(view.host.ActualHeight * (dpi.Y / 96d));
...@@ -83,19 +81,19 @@ namespace VIZ.Package.Module ...@@ -83,19 +81,19 @@ namespace VIZ.Package.Module
// Step 3. 发送渲染命令 // Step 3. 发送渲染命令
do do
{ {
System.Threading.Thread.Sleep(1000); System.Threading.Thread.Sleep(2000);
if (vizConfig.EngineFullType == EngineFullType.VIZ_Eng3) if (vizConfig.EngineFullType == EngineFullType.VIZ_Eng3)
{ {
string cmd = $"RENDERER WINDOW_OPEN_ON_PARENT 0x{hWnd.ToString("X6")} {width} {height} ONAIR"; string cmd = $"RENDERER WINDOW_OPEN_ON_PARENT 0x{hWnd.ToString("X6")} {width} {height} ONAIR";
conn.EndpointManager.Send(cmd); string result = conn.EndpointManager.Request(cmd);
} }
else if (string.IsNullOrWhiteSpace(ApplicationDomainEx.VizPreviewRenderer) && vizConfig.EngineFullType == EngineFullType.VIZ_Eng4) else if (string.IsNullOrWhiteSpace(ApplicationDomainEx.VizPreviewRenderer) && vizConfig.EngineFullType == EngineFullType.VIZ_Eng4)
{ {
// 创建 EDITOR // 创建 EDITOR
ApplicationDomainEx.VizPreviewRenderer = conn.EndpointManager.Request("EDITOR CREATE RENDERER"); ApplicationDomainEx.VizPreviewRenderer = conn.EndpointManager.Request("EDITOR CREATE RENDERER");
string cmd = $"{ApplicationDomainEx.VizPreviewRenderer} WINDOW_OPEN_ON_PARENT 0x{hWnd.ToString("X6")} {width} {height} ONAIR"; string cmd = $"{ApplicationDomainEx.VizPreviewRenderer} WINDOW_OPEN_ON_PARENT 0x{hWnd.ToString("X6")} {width} {height} ONAIR";
conn.EndpointManager.Send(cmd); string result = conn.EndpointManager.Request(cmd);
} }
WPFHelper.Invoke(() => WPFHelper.Invoke(() =>
...@@ -108,7 +106,8 @@ namespace VIZ.Package.Module ...@@ -108,7 +106,8 @@ namespace VIZ.Package.Module
// Step 4. 启动完成 // Step 4. 启动完成
WPFHelper.BeginInvoke(() => WPFHelper.BeginInvoke(() =>
{ {
this.ViewModel.IsEngineReady = true; // 设置
ApplicationDomainEx.IsVizPreviewReadly = true;
// 发送引擎嵌入完成消息 // 发送引擎嵌入完成消息
VizPreviewReadyMessage msg = new VizPreviewReadyMessage(); VizPreviewReadyMessage msg = new VizPreviewReadyMessage();
......
...@@ -52,6 +52,12 @@ ...@@ -52,6 +52,12 @@
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">
<fcommon:IconButton Icon="/VIZ.Package.Module.Resource;component/Icons/preview_refresh_32x32.png"
ToolTip="重启预览引擎"
Style="{StaticResource IconButton_Menu_Mask}" Margin="0,0,40,0"
IconWidth="16" IconHeight="16" Height="30" Width="30"
Command="{Binding Path=RestartPreviewCommand}"></fcommon:IconButton>
<CheckBox Content="TA" Style="{StaticResource CheckBox_Preview_TA}" Margin="5,0,0,0" <CheckBox Content="TA" Style="{StaticResource CheckBox_Preview_TA}" Margin="5,0,0,0"
IsChecked="{Binding Path=IsShowTS,Mode=TwoWay}"> IsChecked="{Binding Path=IsShowTS,Mode=TwoWay}">
</CheckBox> </CheckBox>
......
...@@ -42,7 +42,8 @@ namespace VIZ.Package.Module ...@@ -42,7 +42,8 @@ namespace VIZ.Package.Module
private void initCommand() private void initCommand()
{ {
this.LoadedCommand = new VCommand(this.Loaded); this.LoadedCommand = new VCommand(this.Loaded);
this.WindowHostSizeChangedCommand = new VCommand<System.Windows.SizeChangedEventArgs>(this.WindowHostSizeChanged); this.WindowHostSizeChangedCommand = new VCommand<SizeChangedEventArgs>(this.WindowHostSizeChanged);
this.RestartPreviewCommand = new VCommand(this.RestartPreview);
this.PlayCommand = new VCommand(this.Play); this.PlayCommand = new VCommand(this.Play);
this.ContinueCommand = new VCommand(this.Continue); this.ContinueCommand = new VCommand(this.Continue);
this.StopCommand = new VCommand(this.Stop); this.StopCommand = new VCommand(this.Stop);
...@@ -74,20 +75,6 @@ namespace VIZ.Package.Module ...@@ -74,20 +75,6 @@ namespace VIZ.Package.Module
// Property // Property
// ================================================================================ // ================================================================================
#region IsEngineReady -- 引擎是否准备完毕
private bool isEngineReady;
/// <summary>
/// 引擎是否准备完毕
/// </summary>
public bool IsEngineReady
{
get { return isEngineReady; }
set { isEngineReady = value; this.RaisePropertyChanged(nameof(IsEngineReady)); }
}
#endregion
#region IsShowTS -- 是否显示安全框 #region IsShowTS -- 是否显示安全框
private bool isShowTS; private bool isShowTS;
...@@ -187,6 +174,10 @@ namespace VIZ.Package.Module ...@@ -187,6 +174,10 @@ namespace VIZ.Package.Module
if (view == null) if (view == null)
return; return;
// 设置预览状态不可用
ApplicationDomainEx.IsVizPreviewReadly = false;
// 启动引擎嵌入线程
ThreadHelper.SafeRun(() => ThreadHelper.SafeRun(() =>
{ {
// 等待能正确获取到界面宽度时再嵌入VIZ引擎 // 等待能正确获取到界面宽度时再嵌入VIZ引擎
...@@ -215,12 +206,12 @@ namespace VIZ.Package.Module ...@@ -215,12 +206,12 @@ namespace VIZ.Package.Module
/// <summary> /// <summary>
/// 宿主容器大小改变命令 /// 宿主容器大小改变命令
/// </summary> /// </summary>
public VCommand<System.Windows.SizeChangedEventArgs> WindowHostSizeChangedCommand { get; set; } public VCommand<SizeChangedEventArgs> WindowHostSizeChangedCommand { get; set; }
/// <summary> /// <summary>
/// 宿主容器大小改变 /// 宿主容器大小改变
/// </summary> /// </summary>
private void WindowHostSizeChanged(System.Windows.SizeChangedEventArgs e) private void WindowHostSizeChanged(SizeChangedEventArgs e)
{ {
VizConfigEntity config = ApplicationDomainEx.VizConfig; VizConfigEntity config = ApplicationDomainEx.VizConfig;
ConnModel conn = ApplicationDomainEx.PreviewConn; ConnModel conn = ApplicationDomainEx.PreviewConn;
...@@ -247,6 +238,45 @@ namespace VIZ.Package.Module ...@@ -247,6 +238,45 @@ namespace VIZ.Package.Module
#endregion #endregion
#region RestartPreviewCommand -- 重启预览命令
/// <summary>
/// 重启预览命令
/// </summary>
public VCommand RestartPreviewCommand { get; set; }
/// <summary>
/// 重启预览
/// </summary>
private void RestartPreview()
{
// 设置预览引擎未准备完毕
ApplicationDomainEx.IsVizPreviewReadly = false;
// 发送Viz引擎重启消息
VizPreviewRestartMessage msg = new VizPreviewRestartMessage();
ApplicationDomainEx.MessageManager.Send(msg);
// 关闭引擎进程
try
{
ApplicationDomainEx.VizPreviewProcess.Kill();
}
catch (Exception ex)
{
log.Error(ex);
}
// 启动引擎启动线程
ThreadHelper.SafeRun(() =>
{
// 启动引擎
this.StartVizEngine();
});
}
#endregion
#region PlayCommand -- 播放命令 #region PlayCommand -- 播放命令
/// <summary> /// <summary>
...@@ -326,7 +356,7 @@ namespace VIZ.Package.Module ...@@ -326,7 +356,7 @@ namespace VIZ.Package.Module
private void ShowRGB() private void ShowRGB()
{ {
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理 // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null) if (!ApplicationDomainEx.IsVizPreviewReadly || ApplicationDomainEx.CurrentPage == null)
return; return;
this.vizCommandService.ShowRGB(ApplicationDomainEx.PreviewConn); this.vizCommandService.ShowRGB(ApplicationDomainEx.PreviewConn);
...@@ -347,7 +377,7 @@ namespace VIZ.Package.Module ...@@ -347,7 +377,7 @@ namespace VIZ.Package.Module
private void ShowKey() private void ShowKey()
{ {
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理 // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null) if (!ApplicationDomainEx.IsVizPreviewReadly || ApplicationDomainEx.CurrentPage == null)
return; return;
this.vizCommandService.ShowKey(ApplicationDomainEx.PreviewConn); this.vizCommandService.ShowKey(ApplicationDomainEx.PreviewConn);
...@@ -368,7 +398,7 @@ namespace VIZ.Package.Module ...@@ -368,7 +398,7 @@ namespace VIZ.Package.Module
private void ShowKeyPreview() private void ShowKeyPreview()
{ {
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理 // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null) if (!ApplicationDomainEx.IsVizPreviewReadly || ApplicationDomainEx.CurrentPage == null)
return; return;
this.vizCommandService.ShowKeyPreview(ApplicationDomainEx.PreviewConn); this.vizCommandService.ShowKeyPreview(ApplicationDomainEx.PreviewConn);
...@@ -387,7 +417,7 @@ namespace VIZ.Package.Module ...@@ -387,7 +417,7 @@ namespace VIZ.Package.Module
private void OnPageOpenMessage(PageOpenMessage msg) private void OnPageOpenMessage(PageOpenMessage msg)
{ {
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理 // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null) if (!ApplicationDomainEx.IsVizPreviewReadly || ApplicationDomainEx.CurrentPage == null)
return; return;
this.vizCommandService.SetObject(ApplicationDomainEx.PreviewConn, msg.Page.ScenePath, VizLayer.MAIN_LAYER); this.vizCommandService.SetObject(ApplicationDomainEx.PreviewConn, msg.Page.ScenePath, VizLayer.MAIN_LAYER);
...@@ -428,7 +458,7 @@ namespace VIZ.Package.Module ...@@ -428,7 +458,7 @@ namespace VIZ.Package.Module
private void OnControlFieldChangedMessage(ControlFieldChangedMessage msg) private void OnControlFieldChangedMessage(ControlFieldChangedMessage msg)
{ {
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理 // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null) if (!ApplicationDomainEx.IsVizPreviewReadly || ApplicationDomainEx.CurrentPage == null)
return; return;
// 缺少信息 // 缺少信息
...@@ -449,7 +479,7 @@ namespace VIZ.Package.Module ...@@ -449,7 +479,7 @@ namespace VIZ.Package.Module
private void OnControlListFieldChangedMessage(ControlListFieldChangedMessage msg) private void OnControlListFieldChangedMessage(ControlListFieldChangedMessage msg)
{ {
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理 // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null) if (!ApplicationDomainEx.IsVizPreviewReadly || ApplicationDomainEx.CurrentPage == null)
return; return;
// 缺少信息 // 缺少信息
...@@ -477,14 +507,11 @@ namespace VIZ.Package.Module ...@@ -477,14 +507,11 @@ namespace VIZ.Package.Module
return; return;
VizConfigEntity vizConfig = ApplicationDomainEx.VizConfig; VizConfigEntity vizConfig = ApplicationDomainEx.VizConfig;
ConnGroupModel connGroup = ApplicationDomainEx.PreviewConnGroup; ConnGroupModel connGroup = new ConnGroupModel();
if (connGroup == null)
{
connGroup = new ConnGroupModel();
connGroup.Name = "预览"; connGroup.Name = "预览";
connGroup.IsEnabled = true; connGroup.IsEnabled = true;
connGroup.IsLocalPreview = true; connGroup.IsLocalPreview = true;
}
ConnModel conn = ApplicationDomainEx.PreviewConn; ConnModel conn = ApplicationDomainEx.PreviewConn;
if (conn != null) if (conn != null)
{ {
...@@ -574,7 +601,7 @@ namespace VIZ.Package.Module ...@@ -574,7 +601,7 @@ namespace VIZ.Package.Module
private void IsShowTSChanged() private void IsShowTSChanged()
{ {
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理 // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null) if (!ApplicationDomainEx.IsVizPreviewReadly || ApplicationDomainEx.CurrentPage == null)
return; return;
this.vizCommandService.ShowTS(ApplicationDomainEx.PreviewConn, this.IsShowTS); this.vizCommandService.ShowTS(ApplicationDomainEx.PreviewConn, this.IsShowTS);
...@@ -586,7 +613,7 @@ namespace VIZ.Package.Module ...@@ -586,7 +613,7 @@ namespace VIZ.Package.Module
private void IsShowSAChanged() private void IsShowSAChanged()
{ {
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理 // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null) if (!ApplicationDomainEx.IsVizPreviewReadly || ApplicationDomainEx.CurrentPage == null)
return; return;
this.vizCommandService.ShowSA(ApplicationDomainEx.PreviewConn, this.IsShowSA); this.vizCommandService.ShowSA(ApplicationDomainEx.PreviewConn, this.IsShowSA);
...@@ -598,7 +625,7 @@ namespace VIZ.Package.Module ...@@ -598,7 +625,7 @@ namespace VIZ.Package.Module
private void IsShowBBChanged() private void IsShowBBChanged()
{ {
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理 // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null) if (!ApplicationDomainEx.IsVizPreviewReadly || ApplicationDomainEx.CurrentPage == null)
return; return;
this.vizCommandService.ShowBB(ApplicationDomainEx.PreviewConn, this.IsShowBB); this.vizCommandService.ShowBB(ApplicationDomainEx.PreviewConn, this.IsShowBB);
......
...@@ -228,7 +228,7 @@ namespace VIZ.Package.Module ...@@ -228,7 +228,7 @@ namespace VIZ.Package.Module
List<string> updateMessage = new List<string>(); List<string> updateMessage = new List<string>();
// 更新预览 // 更新预览
if (task.IsPreviewEnabled && ApplicationDomainEx.PreviewConn != null && ApplicationDomainEx.PreviewConn.IsConnected) if (task.IsPreviewEnabled && ApplicationDomainEx.IsVizPreviewReadly && ApplicationDomainEx.PreviewConn != null && ApplicationDomainEx.PreviewConn.IsConnected)
{ {
this.ExecuteTaskPreviewUpdate(task, updateMessage); this.ExecuteTaskPreviewUpdate(task, updateMessage);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment