Commit 08d3b117 by liulongfei

页添加分组

parent e8f8a419
......@@ -88,6 +88,11 @@ namespace VIZ.Package.Domain
// =============================================================
/// <summary>
/// 预览连接分组
/// </summary>
public static ConnGroupModel PreviewConnGroup { get; set; }
/// <summary>
/// 预览连接
/// </summary>
public static ConnModel PreviewConn { get; set; }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 连接分组状态
/// </summary>
public enum ConnGroupStatus
{
/// <summary>
/// 全部断开
/// </summary>
AllDisconnection,
/// <summary>
/// 有至少一个处于连接状态
/// </summary>
AnyConnection,
/// <summary>
/// 全部处于连接状态
/// </summary>
AllConnection
}
}
......@@ -12,14 +12,6 @@ namespace VIZ.Package.Domain
/// </summary>
public class ConnChangedMessage
{
/// <summary>
/// 老的连接分组
/// </summary>
public ConnGroupModel OldGroup { get; set; }
/// <summary>
/// 新的连接分组
/// </summary>
public ConnGroupModel NewGroup { get; set; }
}
}
......@@ -56,6 +56,20 @@ namespace VIZ.Package.Domain
#endregion
#region IsDefault -- 是否是默认分组
private bool isDefault;
/// <summary>
/// 是否是默认分组
/// </summary>
public bool IsDefault
{
get { return isDefault; }
set { isDefault = value; this.RaisePropertyChanged(nameof(IsDefault)); }
}
#endregion
#region EngineType -- 引擎类型
private EngineType engineType;
......@@ -84,5 +98,56 @@ namespace VIZ.Package.Domain
}
#endregion
#region IsLocalPreview -- 是否是本地预览
private bool isLocalPreview;
/// <summary>
/// 是否是本地预览
/// </summary>
public bool IsLocalPreview
{
get { return isLocalPreview; }
set { isLocalPreview = value; this.RaisePropertyChanged(nameof(IsLocalPreview)); }
}
#endregion
#region Status -- 状态
private ConnGroupStatus status;
/// <summary>
/// 状态
/// </summary>
public ConnGroupStatus Status
{
get { return status; }
set { status = value; this.RaisePropertyChanged(nameof(Status)); }
}
#endregion
/// <summary>
/// 更新状态
/// </summary>
public void UpdateStatus()
{
// 没有连接项 | 全断开
if (this.Items.Count == 0 || this.Items.Where(p => p.IsEnabled).All(p => !p.IsConnected))
{
this.Status = ConnGroupStatus.AllDisconnection;
return;
}
// 全连接
if (this.Items.Where(p => p.IsEnabled).All(p => p.IsConnected))
{
this.Status = ConnGroupStatus.AllConnection;
return;
}
// 部分连接
this.Status = ConnGroupStatus.AnyConnection;
}
}
}
......@@ -125,6 +125,20 @@ namespace VIZ.Package.Domain
#endregion
#region ErrorMessage -- 错误信息
private string errorMessage;
/// <summary>
/// 错误信息
/// </summary>
public string ErrorMessage
{
get { return errorMessage; }
set { errorMessage = value; this.RaisePropertyChanged(nameof(ErrorMessage)); }
}
#endregion
// ============================================================================
#region IsLoading -- 是否正在等待
......@@ -147,11 +161,19 @@ namespace VIZ.Package.Domain
public IPackageEndpointManager EndpointManager { get; private set; }
/// <summary>
/// 所属分组
/// </summary>
public ConnGroupModel OwnerGroup { get; set; }
/// <summary>
/// 初始化终结点管理器
/// </summary>
/// <param name="groupModel">分组</param>
/// <param name="endpointManager">终结点管理器</param>
public void InitEndpointManager(IPackageEndpointManager endpointManager)
public void InitEndpointManager(ConnGroupModel groupModel, IPackageEndpointManager endpointManager)
{
this.OwnerGroup = groupModel;
if (this.EndpointManager != null)
{
this.EndpointManager.ConnectionStateChanged -= EndpointManager_ConnectionStateChanged;
......@@ -179,6 +201,9 @@ namespace VIZ.Package.Domain
WPFHelper.BeginInvoke(() =>
{
this.IsConnected = e.IsConnected;
this.ErrorMessage = e.Exception?.Message;
this.OwnerGroup?.UpdateStatus();
});
}
}
......
......@@ -96,5 +96,19 @@ namespace VIZ.Package.Domain
}
#endregion
#region ConnGroupID -- 连接分组ID
private Guid connGroupID;
/// <summary>
/// 连接分组ID
/// </summary>
public Guid ConnGroupID
{
get { return connGroupID; }
set { connGroupID = value; this.RaisePropertyChanged(nameof(ConnGroupID)); }
}
#endregion
}
}
......@@ -15,25 +15,25 @@ namespace VIZ.Package.Domain
/// 上版
/// </summary>
/// <param name="conns">连接</param>
void TakIn(IList<ConnModel> conns);
void TakIn(ConnModel conns);
/// <summary>
/// 继续
/// </summary>
/// <param name="conns">连接</param>
void TakeContinue(IList<ConnModel> conns);
void TakeContinue(ConnModel conns);
/// <summary>
/// 下版子
/// </summary>
/// <param name="conns">连接</param>
void TakeOut(IList<ConnModel> conns);
void TakeOut(ConnModel conns);
/// <summary>
/// 更新
/// </summary>
/// <param name="conns">连接</param>
void TakeUpdate(IList<ConnModel> conns);
void TakeUpdate(ConnModel conns);
/// <summary>
/// 预览上版子
......
......@@ -75,6 +75,7 @@
<Compile Include="ApplicationConstants.cs" />
<Compile Include="ApplicationDomainEx.cs" />
<Compile Include="Core\GridColumnDefinition.cs" />
<Compile Include="Enum\ConnGroupStatus.cs" />
<Compile Include="Enum\ModulePluginIds.cs" />
<Compile Include="Enum\ViewServiceKeys.cs" />
<Compile Include="Info\VizTreeNodeInfo.cs" />
......
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
using VIZ.Package.Domain;
namespace VIZ.Package.Module.Resource
{
/// <summary>
/// 连接分组状态 到 纯色画刷转化器
/// </summary>
public class ConnGroupStatus2BrushConverter : IValueConverter
{
/// <summary>
/// 全断开画刷
/// </summary>
public SolidColorBrush AllDisconnectionBrush { get; set; }
/// <summary>
/// 部分连接画刷
/// </summary>
public SolidColorBrush AnyConnectionBrush { get; set; }
/// <summary>
/// 全连接画刷
/// </summary>
public SolidColorBrush AllConnectionBrush { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is ConnGroupStatus status))
return null;
switch (status)
{
case ConnGroupStatus.AllDisconnection: return this.AllDisconnectionBrush;
case ConnGroupStatus.AnyConnection: return this.AnyConnectionBrush;
case ConnGroupStatus.AllConnection: return this.AllConnectionBrush;
default: return null;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
......@@ -99,6 +99,7 @@
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Converter\ConnGroupStatus2BrushConverter.cs" />
<Compile Include="Converter\ResourceFileSelectionModeConverter.cs" />
<Compile Include="Converter\RichText2TextConverter.cs" />
<Compile Include="Converter\RowHandleConverter.cs" />
......@@ -207,6 +208,12 @@
<ItemGroup>
<Resource Include="Icons\icon_save_as_hover_30x30.png" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="Icons\preview_local_32x32.png" />
<Resource Include="Icons\preview_remote_32x32.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\preview_connection_32x32.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -82,18 +82,20 @@ namespace VIZ.Package.Module
service.TryUpdateControlFieldListValue();
// 执行上版流程
this.Execute(
controlObjectAction: (obj, conn) =>
this.Execute((obj, view, conn) =>
{
this.vizCommandService.SetEnabledUpdate(conn, false);
this.vizCommandService.SetObject(conn, ApplicationDomainEx.CurrentPage.ScenePath, ApplicationDomainEx.CurrentPage.Layer);
if (obj != null)
{
this.vizCommandControlObjectService.SetControlObject(conn, obj);
}
if (view != null)
{
view.TakIn(conn);
}
this.vizCommandService.SetEnabledUpdate(conn, true);
this.vizCommandService.Start(conn, ApplicationDomainEx.CurrentPage.Layer);
},
pluginAction: (view, conns) =>
{
view.TakIn(conns);
});
}
......@@ -111,14 +113,10 @@ namespace VIZ.Package.Module
/// </summary>
private void Continue()
{
this.Execute(
controlObjectAction: (obj, conn) =>
this.Execute((obj, view, conn) =>
{
this.vizCommandService.TakeContinue(conn, ApplicationDomainEx.CurrentPage.Layer);
},
pluginAction: (view, conns) =>
{
view.TakeContinue(conns);
view?.TakeContinue(conn);
});
}
......@@ -136,14 +134,10 @@ namespace VIZ.Package.Module
/// </summary>
private void TakeOut()
{
this.Execute(
controlObjectAction: (obj, conn) =>
this.Execute((obj, view, conn) =>
{
this.vizCommandService.TakeOut(conn, ApplicationDomainEx.CurrentPage.Layer);
},
pluginAction: (view, conns) =>
{
view.TakeOut(conns);
view?.TakeOut(conn);
});
}
......@@ -170,14 +164,13 @@ namespace VIZ.Package.Module
service.TryUpdateControlFieldListValue();
// 执行更新流程
this.Execute(
controlObjectAction: (obj, conn) =>
this.Execute((obj, view, conn) =>
{
this.vizCommandControlObjectService.SetControlObject(conn, obj);
},
pluginAction: (view, conns) =>
if (obj != null)
{
view.TakeUpdate(conns);
this.vizCommandControlObjectService.SetControlObject(conn, obj);
}
view?.TakeOut(conn);
});
}
......@@ -190,25 +183,33 @@ namespace VIZ.Package.Module
/// <summary>
/// 执行
/// </summary>
/// <param name="controlObjectAction">控制对象行为</param>
/// <param name="pluginAction">插件行为</param>
private void Execute(Action<ControlObjectModel, ConnModel> controlObjectAction, Action<IPluginView, IList<ConnModel>> pluginAction)
/// <param name="action">行为</param>
private void Execute(Action<ControlObjectModel, IPluginView, ConnModel> action)
{
// 是否拥有打开的页或模板页
if (ApplicationDomainEx.CurrentPage == null)
return;
// 是否有启用的连接分组
ConnGroupModel group = ApplicationDomainEx.ConnGroups.FirstOrDefault(p => p.IsEnabled);
if (group == null)
// 插件服务
IPluginService pluginService = ApplicationDomainEx.ServiceManager.GetService<IPluginService>(ViewServiceKeys.PLUGIN_SERVICE);
if (pluginService == null)
return;
// 控制字段树服务
IFieldTreeService fieldTreeService = ApplicationDomainEx.ServiceManager.GetService<IFieldTreeService>(ViewServiceKeys.FIELD_TREE_SERVICE);
ControlObjectModel controlObject = fieldTreeService?.GetControlObject();
if (fieldTreeService == null)
return;
// Step 1. 处理控制对象
if (controlObject != null)
ControlObjectModel controlObject = fieldTreeService.GetControlObject();
// 模板
if (ApplicationDomainEx.CurrentPage is PageTemplateModel template)
{
// 模板上版等操作使用默认分组
ConnGroupModel group = ApplicationDomainEx.ConnGroups.FirstOrDefault(p => p.IsDefault);
if (group == null)
return;
foreach (var item in group.Items)
{
if (!item.IsEnabled || !item.IsConnected)
......@@ -216,7 +217,7 @@ namespace VIZ.Package.Module
try
{
controlObjectAction(controlObject, item);
action(controlObject, null, item);
}
catch (Exception ex)
{
......@@ -224,25 +225,29 @@ namespace VIZ.Package.Module
}
}
}
// 页
else if (ApplicationDomainEx.CurrentPage is PageModel page)
{
// 模板上版等操作使用默认分组
ConnGroupModel group = ApplicationDomainEx.ConnGroups.FirstOrDefault(p => p.GroupID == page.ConnGroupID);
if (group == null)
{
// 记录日志
log.Error($"ConnGroupID: {page.ConnGroupID} is not found.");
// Step 2. 执行插件脚本
if (!(ApplicationDomainEx.CurrentPage is PageModel page))
return;
if (string.IsNullOrWhiteSpace(page.PluginID))
return;
IPluginService pluginService = ApplicationDomainEx.ServiceManager.GetService<IPluginService>(ViewServiceKeys.PLUGIN_SERVICE);
if (pluginService == null)
return;
}
IPluginView view = pluginService.GetCurrentPluginView() as IPluginView;
if (view == null)
return;
foreach (var item in group.Items)
{
if (!item.IsEnabled || !item.IsConnected)
continue;
try
{
pluginAction(view, group.Items.Where(p => p.IsEnabled && p.IsConnected).ToList());
action(controlObject, view, item);
}
catch (Exception ex)
{
......@@ -250,4 +255,6 @@ namespace VIZ.Package.Module
}
}
}
}
}
}
\ No newline at end of file
......@@ -125,7 +125,7 @@
<dxg:GridControl.View>
<dxg:TableView x:Name="tabView" AllowEditing="True" ShowIndicator="False"
IsColumnMenuEnabled="False"
NavigationStyle="Cell" EditorShowMode="MouseDown"
NavigationStyle="Cell" EditorShowMode="MouseDown" ShowVerticalLines="False"
ShowGroupPanel="False"
AllowDrop="True"
ShowBandsPanel="False"
......
......@@ -28,7 +28,7 @@
<dxg:GridControl.View>
<dxg:TreeListView AllowEditing="False" ShowIndicator="False"
IsColumnMenuEnabled="False"
NavigationStyle="Row"
NavigationStyle="Row" ShowVerticalLines="False"
ShowBandsPanel="False"
ShowTotalSummary="False"
ShowFixedTotalSummary="False"
......
......@@ -10,6 +10,7 @@
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:plugin="clr-namespace:VIZ.Package.Plugin;assembly=VIZ.Package.Plugin"
xmlns:resource="clr-namespace:VIZ.Package.Module.Resource;assembly=VIZ.Package.Module.Resource"
xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:MainConnViewModel}"
mc:Ignorable="d" x:Name="uc"
......@@ -22,15 +23,16 @@
</ResourceDictionary.MergedDictionaries>
<fcore:Bool2BoolConverter x:Key="Bool2BoolConverter"></fcore:Bool2BoolConverter>
<fcore:Bool2SolidColorBrushConverter x:Key="Bool2SolidColorBrushConverter"
TrueBrush="#FF92FF3D"
FalseBrush="#FFFF5353"
NoneBrush="#FFFF5353"></fcore:Bool2SolidColorBrushConverter>
<resource:ConnGroupStatus2BrushConverter x:Key="ConnGroupStatus2BrushConverter"
AllDisconnectionBrush="#FFFF5353"
AnyConnectionBrush="Yellow"
AllConnectionBrush="#FF92FF3D"></resource:ConnGroupStatus2BrushConverter>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<ListBox Style="{StaticResource ListBox_None}"
<ListBox Style="{StaticResource ListBox_None}" Margin="10,0,0,0"
ItemsSource="{Binding Path=ItemsSrouce}"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden">
......@@ -41,12 +43,49 @@
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border>
<StackPanel Orientation="Horizontal" Background="Transparent" VerticalAlignment="Center"
<Grid Background="Transparent" x:Name="root">
<!-- 内容 -->
<StackPanel Orientation="Horizontal">
<Border Width="16" Height="16" VerticalAlignment="Center"
Background="{Binding Path=Status,Converter={StaticResource ConnGroupStatus2BrushConverter}}">
<Border.OpacityMask>
<ImageBrush ImageSource="/VIZ.Package.Module.Resource;component/Icons/preview_connection_32x32.png"></ImageBrush>
</Border.OpacityMask>
</Border>
<TextBlock Text="{Binding Path=Name}" Grid.Column="1" VerticalAlignment="Center" Margin="10,0,50,0"
MaxWidth="200"
Foreground="{Binding Path=Status,Converter={StaticResource ConnGroupStatus2BrushConverter}}"
TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"></TextBlock>
</StackPanel>
<!-- 弹出框 -->
<Popup AllowsTransparency="True"
PopupAnimation="Fade"
PlacementTarget="{Binding ElementName=root}"
Placement="Top"
Width="320"
MinHeight="200"
IsOpen="{Binding ElementName=root, Path=IsMouseOver, Mode=OneWay}">
<Border Background="#FF252526" BorderBrush="#FF4E4BDE" BorderThickness="1" Width="300">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="分组: " Foreground="#aaffffff"></TextBlock>
<TextBlock Text="{Binding Path=Name}" Margin="10,0,10,0" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"></TextBlock>
</StackPanel>
<ListBox Style="{StaticResource ListBox_None}" ItemsSource="{Binding Path=Items}" Grid.Row="1">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="innerRoot"
Orientation="Horizontal" Background="Transparent" VerticalAlignment="Center"
IsEnabled="{Binding Path=IsLoading,Converter={StaticResource Bool2BoolConverter}}"
TextBlock.Foreground="{Binding Path=IsConnected,Converter={StaticResource Bool2SolidColorBrushConverter}}"
TextBlock.FontSize="12"
Cursor="Hand" MinWidth="120" Margin="10,0,0,0">
TextBlock.Foreground="#FFFF5353"
TextBlock.FontSize="12" Height="24 "
Cursor="Hand">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand Event="PreviewMouseLeftButtonDown"
CommandParameter="{Binding .}"
......@@ -59,7 +98,23 @@
<TextBlock Text="{Binding Path=Remark}" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="]" Margin="3,0,3,0" VerticalAlignment="Center"></TextBlock>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=IsConnected}" Value="True">
<Setter Property="TextBlock.Foreground" TargetName="innerRoot" Value="#FF92FF3D"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsEnabled}" Value="False">
<Setter Property="IsEnabled" Value="False"></Setter>
<Setter Property="Opacity" Value="0.4"></Setter>
<Setter Property="TextBlock.Foreground" TargetName="innerRoot" Value="White"></Setter>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
</Popup>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
......
......@@ -63,11 +63,11 @@ namespace VIZ.Package.Module
#region ItemsSrouce -- 数据源
private ObservableCollection<ConnModel> itemsSrouce = new ObservableCollection<ConnModel>();
private ObservableCollection<ConnGroupModel> itemsSrouce = new ObservableCollection<ConnGroupModel>();
/// <summary>
/// 数据源
/// </summary>
public ObservableCollection<ConnModel> ItemsSrouce
public ObservableCollection<ConnGroupModel> ItemsSrouce
{
get { return itemsSrouce; }
set { itemsSrouce = value; this.RaisePropertyChanged(nameof(ItemsSrouce)); }
......@@ -122,15 +122,7 @@ namespace VIZ.Package.Module
/// <param name="msg">消息</param>
private void OnConnChangedMessage(ConnChangedMessage msg)
{
if (msg.OldGroup != null)
{
foreach (ConnModel item in msg.OldGroup.Items)
{
item.Dispose();
}
}
this.InitAndConnnectGroups(msg.NewGroup);
this.InitAndConnnectGroups();
}
/// <summary>
......@@ -142,33 +134,43 @@ namespace VIZ.Package.Module
List<ConnGroupModel> groups = this.connService.LoadGroups();
ApplicationDomainEx.ConnGroups = groups;
ConnGroupModel group = groups.FirstOrDefault(p => p.IsEnabled == true);
this.InitAndConnnectGroups(group);
this.InitAndConnnectGroups();
}
/// <summary>
/// 初始化 & 连接
/// </summary>
/// <param name="group">连接分组</param>
private void InitAndConnnectGroups(ConnGroupModel group)
private void InitAndConnnectGroups()
{
// 清理之前的连接
foreach (ConnGroupModel group in this.ItemsSrouce)
{
foreach (ConnModel item in group.Items)
{
if (item == ApplicationDomainEx.PreviewConn)
continue;
item.Dispose();
}
}
this.ItemsSrouce.Clear();
// 预览连接
this.ItemsSrouce.Add(ApplicationDomainEx.PreviewConn);
// 预览分组
this.ItemsSrouce.Add(ApplicationDomainEx.PreviewConnGroup);
if (group == null)
return;
// 其他分组
foreach (ConnGroupModel group in ApplicationDomainEx.ConnGroups)
{
if (!group.IsEnabled)
continue;
foreach (ConnModel item in group.Items)
{
if (!item.IsEnabled)
continue;
item.InitEndpointManager(new VizEndpointManager(item.ConnID.ToString(), item.IP, item.Port));
this.ItemsSrouce.Add(item);
item.InitEndpointManager(group, new VizEndpointManager(item.ConnID.ToString(), item.IP, item.Port));
// 启动连接
ThreadHelper.SafeRun(() =>
......@@ -183,6 +185,9 @@ namespace VIZ.Package.Module
}
});
}
this.ItemsSrouce.Add(group);
}
}
}
}
......@@ -99,6 +99,12 @@
IsTextEditable="False"></dxe:ComboBoxEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="连接" FieldName="ConnGroupID" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding ElementName=uc, Path=DataContext.ConnGroups,Mode=TwoWay}"
DisplayMember="Name" ValueMember="GroupID" IsTextEditable="False"></dxe:ComboBoxEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="引擎类型" FieldName="EngineType" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="模板类型" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"
Binding="{Binding Path=TemplateType,Converter={StaticResource Enum2EnumDescriptionConverter}}">
......@@ -108,7 +114,7 @@
<dxg:GridControl.View>
<dxg:TableView IsColumnMenuEnabled="False"
AllowEditing="True" ShowIndicator="False"
NavigationStyle="Cell"
NavigationStyle="Cell" ShowVerticalLines="False"
ShowGroupPanel="False" EditorShowMode="MouseUp"
AllowDragDrop="True"
ShowBandsPanel="False"
......
......@@ -58,6 +58,7 @@ namespace VIZ.Package.Module
ApplicationDomainEx.MessageManager.Register<ProjectCloseMessage>(this, this.OnProjectCloseMessage);
ApplicationDomainEx.MessageManager.Register<ProjectSaveMessage>(this, this.OnProjectSaveMessage);
ApplicationDomainEx.MessageManager.Register<ConnChangedMessage>(this, this.OnConnChangedMessage);
}
// ======================================================================================
......@@ -159,6 +160,20 @@ namespace VIZ.Package.Module
#endregion
#region ConnGroups -- 连接分组集合
private List<ConnGroupModel> connGroups;
/// <summary>
/// 连接分组集合
/// </summary>
public List<ConnGroupModel> ConnGroups
{
get { return connGroups; }
set { connGroups = value; this.RaisePropertyChanged(nameof(ConnGroups)); }
}
#endregion
// ======================================================================================
// Command
// ======================================================================================
......@@ -316,6 +331,7 @@ namespace VIZ.Package.Module
this.SelectedPageGroupModel = null;
this.SelectedPageModel = null;
this.IsLoading = true;
this.UpdateConnGroups();
ThreadHelper.SafeRun(() =>
{
......@@ -370,6 +386,15 @@ namespace VIZ.Package.Module
this.pageService.SavePageGroups(this.PageGroupModels);
}
/// <summary>
/// 连接切换消息
/// </summary>
/// <param name="msg">消息</param>
private void OnConnChangedMessage(ConnChangedMessage msg)
{
this.UpdateConnGroups();
}
// ======================================================================================
// Public Function
// ======================================================================================
......@@ -509,5 +534,13 @@ namespace VIZ.Package.Module
return false;
}
/// <summary>
/// 更新连接分组
/// </summary>
public void UpdateConnGroups()
{
this.ConnGroups = ApplicationDomainEx.ConnGroups;
}
}
}
......@@ -67,7 +67,7 @@
<dxg:GridControl.View>
<dxg:TableView IsColumnMenuEnabled="False"
AllowEditing="True" ShowIndicator="False"
NavigationStyle="Cell"
NavigationStyle="Cell" ShowVerticalLines="False"
ShowGroupPanel="False" EditorShowMode="MouseUp"
AllowDragDrop="True"
ShowBandsPanel="False"
......@@ -114,7 +114,7 @@
<dxg:GridControl.View>
<dxg:TableView IsColumnMenuEnabled="False"
AllowEditing="True" ShowIndicator="False"
NavigationStyle="Cell"
NavigationStyle="Cell" ShowVerticalLines="False"
ShowGroupPanel="False" EditorShowMode="MouseUp"
AllowDragDrop="False"
ShowBandsPanel="False"
......
......@@ -259,14 +259,10 @@ namespace VIZ.Package.Module
/// </summary>
private void Play()
{
this.Execute(
action: (conn) =>
this.Execute((obj, view, conn) =>
{
this.vizCommandService.Start(conn, null, VizLayer.MAIN_LAYER);
},
pluginAction: (view, conn) =>
{
view.PreviewIn(conn);
view?.PreviewIn(conn);
});
}
......@@ -284,14 +280,10 @@ namespace VIZ.Package.Module
/// </summary>
private void Continue()
{
this.Execute(
action: (conn) =>
this.Execute((obj, view, conn) =>
{
this.vizCommandService.Continue(conn, null, VizLayer.MAIN_LAYER);
},
pluginAction: (view, conn) =>
{
view.PreviewContinue(conn);
view?.PreviewContinue(conn);
});
}
......@@ -309,14 +301,10 @@ namespace VIZ.Package.Module
/// </summary>
private void Stop()
{
this.Execute(
action: (conn) =>
this.Execute((obj, view, conn) =>
{
this.vizCommandService.Stop(conn, null, VizLayer.MAIN_LAYER);
},
pluginAction: (view, conn) =>
{
view.PreviewOut(conn);
view?.PreviewOut(conn);
});
}
......@@ -489,6 +477,14 @@ namespace VIZ.Package.Module
return;
VizConfigEntity vizConfig = ApplicationDomainEx.VizConfig;
ConnGroupModel connGroup = ApplicationDomainEx.PreviewConnGroup;
if (connGroup == null)
{
connGroup = new ConnGroupModel();
connGroup.Name = "预览";
connGroup.IsEnabled = true;
connGroup.IsLocalPreview = true;
}
ConnModel conn = ApplicationDomainEx.PreviewConn;
if (conn != null)
{
......@@ -499,8 +495,13 @@ namespace VIZ.Package.Module
conn.IP = vizConfig.VIZ_IP;
conn.Port = vizConfig.VIZ_Port;
conn.Remark = "预览";
conn.InitEndpointManager(new VizEndpointManager("local", vizConfig.VIZ_IP, vizConfig.VIZ_Port));
conn.IsEnabled = true;
conn.InitEndpointManager(connGroup, new VizEndpointManager("local", vizConfig.VIZ_IP, vizConfig.VIZ_Port));
connGroup.Items.Clear();
connGroup.Items.Add(conn);
ApplicationDomainEx.PreviewConnGroup = connGroup;
ApplicationDomainEx.PreviewConn = conn;
string path = null;
......@@ -521,52 +522,51 @@ namespace VIZ.Package.Module
/// <summary>
/// 执行
/// </summary>
/// <param name="action">播放行为</param>
/// <param name="pluginAction">插件行为</param>
private void Execute(Action<ConnModel> action, Action<IPluginView, ConnModel> pluginAction)
/// <param name="action">行为</param>
private void Execute(Action<ControlObjectModel, IPluginView, ConnModel> action)
{
// 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.CurrentPage == null)
// 是否拥有打开的页或模板页
if (ApplicationDomainEx.CurrentPage == null)
return;
// 预览连接为准备好
if (ApplicationDomainEx.PreviewConn == null || !ApplicationDomainEx.PreviewConn.IsConnected)
return;
// Step 1. 播放行为
try
{
action(ApplicationDomainEx.PreviewConn);
}
catch (Exception ex)
{
log.Error(ex);
}
// Step 2. 插件行为
if (!(ApplicationDomainEx.CurrentPage is PageModel page))
// 插件服务
IPluginService pluginService = ApplicationDomainEx.ServiceManager.GetService<IPluginService>(ViewServiceKeys.PLUGIN_SERVICE);
if (pluginService == null)
return;
if (string.IsNullOrWhiteSpace(page.PluginID))
// 控制字段树服务
IFieldTreeService fieldTreeService = ApplicationDomainEx.ServiceManager.GetService<IFieldTreeService>(ViewServiceKeys.FIELD_TREE_SERVICE);
if (fieldTreeService == null)
return;
IPluginService pluginService = ApplicationDomainEx.ServiceManager.GetService<IPluginService>(ViewServiceKeys.PLUGIN_SERVICE);
if (pluginService == null)
return;
ControlObjectModel controlObject = fieldTreeService.GetControlObject();
// 模板
if (ApplicationDomainEx.CurrentPage is PageTemplateModel template)
{
if (ApplicationDomainEx.PreviewConn != null && ApplicationDomainEx.PreviewConn.IsConnected)
{
action(controlObject, null, ApplicationDomainEx.PreviewConn);
}
}
// 页
else if (ApplicationDomainEx.CurrentPage is PageModel page)
{
IPluginView view = pluginService.GetCurrentPluginView() as IPluginView;
if (view == null)
return;
try
{
pluginAction(view, ApplicationDomainEx.PreviewConn);
if (ApplicationDomainEx.PreviewConn != null && ApplicationDomainEx.PreviewConn.IsConnected)
{
action(controlObject, view, ApplicationDomainEx.PreviewConn);
}
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
/// <summary>
/// 是否显示安全框改变
......
......@@ -23,7 +23,7 @@
<ResourceDictionary Source="/VIZ.Framework.Common.Resource;component/Style/GridSplitter/GridSplitter_None.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<resource:RowHandleConverter x:Key="RowHandleConverter"></resource:RowHandleConverter>
<fcore:Bool2StringConverter x:Key="Bool2StringConverter" TrueResult="启用"></fcore:Bool2StringConverter>
<fcore:Bool2StringConverter x:Key="Bool2StringConverter" TrueResult="默认"></fcore:Bool2StringConverter>
</ResourceDictionary>
</UserControl.Resources>
......@@ -33,11 +33,11 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="450" MinWidth="450" MaxWidth="800"></ColumnDefinition>
<ColumnDefinition Width="*" MinWidth="450" MaxWidth="800"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<GroupBox Header="分组" Margin="10,10,10,10" Padding="10">
<GroupBox Header="分组" Margin="5" Padding="5">
<dxg:GridControl ItemsSource="{Binding Path=Groups}" ShowBorder="False"
SelectedItem="{Binding Path=SelectedGroup,Mode=TwoWay}">
<dxg:GridControl.ContextMenu>
......@@ -45,7 +45,7 @@
<MenuItem Header="添加分组" Command="{Binding Path=PlacementTarget.DataContext.AddGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除分组" Command="{Binding Path=PlacementTarget.DataContext.DeleteGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator/>
<MenuItem Header="启用" Command="{Binding Path=PlacementTarget.DataContext.EnabledGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="设为默认分组" Command="{Binding Path=PlacementTarget.DataContext.SetDefaultGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
......@@ -62,8 +62,13 @@
HorizontalContentAlignment="Left"></dxe:TextEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="是否启用" Width="80" Binding="{Binding IsEnabled,Converter={StaticResource Bool2StringConverter}}"
<dxg:GridColumn Header="默认分组" Width="80" Binding="{Binding IsDefault,Converter={StaticResource Bool2StringConverter}}"
AllowSorting="False" AllowColumnFiltering="False" ReadOnly="True"></dxg:GridColumn>
<dxg:GridColumn Header="是否启用" FieldName="IsEnabled" Width="80" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:CheckEditSettings></dxe:CheckEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="引擎类型" FieldName="EngineType" AllowSorting="False" AllowColumnFiltering="False"
ReadOnly="True"></dxg:GridColumn>
</dxg:GridControl.Columns>
......@@ -71,7 +76,7 @@
<dxg:TableView AllowEditing="True" ShowIndicator="True"
IsColumnMenuEnabled="False"
ShowGroupPanelsForUngroupedDetails="False"
NavigationStyle="Cell"
NavigationStyle="Cell" ShowVerticalLines="False"
ShowGroupPanel="False"
AllowDragDrop="False"
ShowBandsPanel="False"
......@@ -84,10 +89,10 @@
</dxg:GridControl>
</GroupBox>
<GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="10"
<GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="5"
Style="{StaticResource GridSplitter_None}"></GridSplitter>
<GroupBox Header="项" Margin="10" Padding="10" Grid.Column="1">
<GroupBox Header="项" Margin="5" Padding="5" Grid.Column="1">
<dxg:GridControl ItemsSource="{Binding Path=SelectedGroup.Items}" ShowBorder="False" Grid.Column="1"
SelectedItem="{Binding Path=SelectedItem,Mode=TwoWay}">
<dxg:GridControl.ContextMenu>
......@@ -131,7 +136,7 @@
<dxg:GridControl.View>
<dxg:TableView AllowEditing="True" ShowIndicator="True"
IsColumnMenuEnabled="False"
NavigationStyle="Cell"
NavigationStyle="Cell" ShowVerticalLines="False"
ShowGroupPanel="False"
AllowDragDrop="False"
ShowBandsPanel="False"
......
......@@ -36,7 +36,7 @@ namespace VIZ.Package.Module
this.LoadedCommand = new VCommand(this.Loaded);
this.AddGroupCommand = new VCommand(this.AddGroup);
this.DeleteGroupCommand = new VCommand(this.DeleteGroup);
this.EnabledGroupCommand = new VCommand(this.EnabledGroup);
this.SetDefaultGroupCommand = new VCommand(this.SetDefaultGroup);
this.AddItemCommand = new VCommand(this.AddItem);
this.DeleteItemCommand = new VCommand(this.DeleteItem);
}
......@@ -162,24 +162,24 @@ namespace VIZ.Package.Module
#endregion
#region EnabledGroupCommand -- 启用组命令
#region SetDefaultGroupCommand -- 启用组命令
/// <summary>
/// 启用组命令
/// 设置默认分组命令
/// </summary>
public VCommand EnabledGroupCommand { get; set; }
public VCommand SetDefaultGroupCommand { get; set; }
/// <summary>
/// 启用
/// 设置默认分
/// </summary>
private void EnabledGroup()
private void SetDefaultGroup()
{
if (this.SelectedGroup == null)
return;
foreach (var group in this.Groups)
{
group.IsEnabled = group == this.SelectedGroup;
group.IsDefault = group == this.SelectedGroup;
}
}
......@@ -243,14 +243,10 @@ namespace VIZ.Package.Module
// 保存配置
this.connService.SaveGroups(this.Groups);
ConnGroupModel oldGroup = ApplicationDomainEx.ConnGroups.FirstOrDefault(p => p.IsEnabled);
ConnGroupModel newGroup = this.Groups.FirstOrDefault(p => p.IsEnabled);
ApplicationDomainEx.ConnGroups = this.Groups.ToList();
// 发送连接改变消息
ConnChangedMessage msg = new ConnChangedMessage();
msg.OldGroup = oldGroup;
msg.NewGroup = newGroup;
ApplicationDomainEx.MessageManager.Send(msg);
}
}
......
......@@ -121,6 +121,7 @@ namespace VIZ.Package.Service
model.Order = entity.Order;
model.PluginName = ApplicationDomainEx.PluginInfos.FirstOrDefault(p => p.ID == entity.PluginID)?.Name;
model.PageNum = entity.PageNum;
model.ConnGroupID = entity.ConnGroupID;
groupModel.Pages.Add(model);
}
......@@ -177,6 +178,7 @@ namespace VIZ.Package.Service
pageEntity.TemplateID = pageModel.TemplateID;
pageEntity.PluginID = pageModel.PluginID;
pageEntity.PageNum = pageModel.PageNum;
pageEntity.ConnGroupID = pageModel.ConnGroupID;
pageEntity.Order = j;
pages.Add(pageEntity);
......
......@@ -36,5 +36,10 @@ namespace VIZ.Package.Storage
/// 页号
/// </summary>
public int PageNum { get; set; }
/// <summary>
/// 连接分组ID
/// </summary>
public Guid ConnGroupID { get; set; }
}
}
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