Commit 08d3b117 by liulongfei

页添加分组

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