Commit 96456dd2 by liulongfei

设置页面逻辑

parent 9aa131c4
......@@ -15,7 +15,7 @@ namespace VIZ.TVP.Domain
/// <summary>
/// 连接分组集合
/// </summary>
public ObservableCollection<TVPConnectionGroupModel> ConnectionGroups { get; private set; } = new ObservableCollection<TVPConnectionGroupModel>();
public ObservableCollection<TVPConnectionGroupModel> ConnectionGroups { get; set; }
/// <summary>
/// 销毁
......
......@@ -14,13 +14,27 @@ namespace VIZ.TVP.Domain
/// </summary>
public class TVPConnectionGroupModel : ModelBase
{
/// <summary>
/// 包装连接分组模型
/// </summary>
/// <param name="entity">实体</param>
public TVPConnectionGroupModel(TVPConnectionGroupEntity entity)
{
this.Entity = entity;
}
/// <summary>
/// 实体
/// </summary>
public TVPConnectionGroupEntity Entity { get; private set; }
#region GroupID -- 分组ID
private string groupID;
private Guid groupID;
/// <summary>
/// 分组ID
/// </summary>
public string GroupID
public Guid GroupID
{
get { return groupID; }
set { groupID = value; this.RaisePropertyChanged(nameof(GroupID)); }
......@@ -28,16 +42,16 @@ namespace VIZ.TVP.Domain
#endregion
#region GroupDisplayName -- 分组显示名称
#region Name -- 名称
private string groupDisplayName;
private string name;
/// <summary>
/// 分组显示名称
/// 名称
/// </summary>
public string GroupDisplayName
public string Name
{
get { return groupDisplayName; }
set { groupDisplayName = value; this.RaisePropertyChanged(nameof(GroupDisplayName)); }
get { return name; }
set { name = value; this.RaisePropertyChanged(nameof(Name)); }
}
#endregion
......@@ -56,18 +70,70 @@ namespace VIZ.TVP.Domain
#endregion
#region Type -- 引擎类型
#region EngineType -- 引擎类型
private TVPEngineType type;
private TVPEngineType engineType;
/// <summary>
/// 引擎类型
/// </summary>
public TVPEngineType Type
public TVPEngineType EngineType
{
get { return engineType; }
set { engineType = value; this.RaisePropertyChanged(nameof(EngineType)); }
}
#endregion
#region OrderIndex -- 排序
private int orderIndex;
/// <summary>
/// 排序
/// </summary>
public int OrderIndex
{
get { return orderIndex; }
set { orderIndex = value; this.RaisePropertyChanged(nameof(OrderIndex)); }
}
#endregion
#region IsEnabled -- 是否启用
private bool isEnabled;
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled
{
get { return type; }
set { type = value; this.RaisePropertyChanged(nameof(Type)); }
get { return isEnabled; }
set { isEnabled = value; this.RaisePropertyChanged(nameof(IsEnabled)); }
}
#endregion
/// <summary>
/// 从实体中获取属性
/// </summary>
public void PropertyFromEntity()
{
this.GroupID = this.Entity.GroupID;
this.Name = this.Entity.Name;
this.EngineType = this.Entity.EngineType;
this.OrderIndex = this.Entity.OrderIndex;
this.IsEnabled = this.Entity.IsEnabled;
}
/// <summary>
/// 将属性填入实体
/// </summary>
public void PropertyToEntity()
{
this.Entity.GroupID = this.GroupID;
this.Entity.Name = this.Name;
this.Entity.EngineType = this.EngineType;
this.Entity.OrderIndex = this.OrderIndex;
this.Entity.IsEnabled = this.IsEnabled;
}
}
}
......@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Domain
{
......@@ -12,30 +13,73 @@ namespace VIZ.TVP.Domain
/// </summary>
public class TVPConnectionModel : ModelBase, IDisposable
{
#region ID -- 编号
/// <summary>
/// 包装连接模型
/// </summary>
/// <param name="entity">实体</param>
public TVPConnectionModel(TVPConnectionEntity entity)
{
this.Entity = entity;
}
/// <summary>
/// 实体
/// </summary>
public TVPConnectionEntity Entity { get; private set; }
#region GroupID -- 分组ID
private Guid groupID;
/// <summary>
/// 分组ID
/// </summary>
public Guid GroupID
{
get { return groupID; }
set { groupID = value; this.RaisePropertyChanged(nameof(GroupID)); }
}
#endregion
#region IP -- IP地址
private string id;
private string ip;
/// <summary>
/// 编号
/// IP地址
/// </summary>
public string ID
public string IP
{
get { return id; }
set { id = value; this.RaisePropertyChanged(nameof(ID)); }
get { return ip; }
set { ip = value; this.RaisePropertyChanged(nameof(IP)); }
}
#endregion
#region DisplayName -- 显示名称
#region Port -- 端口
private string displayName;
private int port;
/// <summary>
/// 显示名称
/// 端口
/// </summary>
public string DisplayName
public int Port
{
get { return displayName; }
set { displayName = value; this.RaisePropertyChanged(nameof(DisplayName)); }
get { return port; }
set { port = value; this.RaisePropertyChanged(nameof(Port)); }
}
#endregion
#region Remark -- 备注
private string remark;
/// <summary>
/// 备注
/// </summary>
public string Remark
{
get { return remark; }
set { remark = value; this.RaisePropertyChanged(nameof(Remark)); }
}
#endregion
......@@ -68,12 +112,52 @@ namespace VIZ.TVP.Domain
#endregion
#region OrderIndex -- 排序
private int orderIndex;
/// <summary>
/// 排序
/// </summary>
public int OrderIndex
{
get { return orderIndex; }
set { orderIndex = value; this.RaisePropertyChanged(nameof(OrderIndex)); }
}
#endregion
/// <summary>
/// 连接终结点
/// </summary>
public ITVPEndpointManager EndpointManager { get; private set; }
/// <summary>
/// 从实体中获取属性
/// </summary>
public void PropertyFromEntity()
{
this.GroupID = this.Entity.GroupID;
this.IP = this.Entity.IP;
this.Port = this.Entity.Port;
this.Remark = this.Entity.Remark;
this.IsEnabled = this.Entity.IsEnabled;
this.OrderIndex = this.Entity.OrderIndex;
}
/// <summary>
/// 将属性填入实体
/// </summary>
public void PropertyToEntity()
{
this.Entity.GroupID = this.GroupID;
this.Entity.IP = this.IP;
this.Entity.Port = this.Port;
this.Entity.Remark = this.Remark;
this.Entity.IsEnabled = this.IsEnabled;
this.Entity.OrderIndex = this.OrderIndex;
}
/// <summary>
/// 初始化终结点管理器
/// </summary>
/// <param name="endpointManager">终结点管理器</param>
......
......@@ -13,16 +13,16 @@
<StackPanel Orientation="Horizontal">
<dxb:MainMenuControl Caption="MainMenu" VerticalAlignment="Center">
<dxb:BarSubItem Content="项目" Alignment="Far">
<dxb:BarSubItem Content="项目">
<dxb:BarButtonItem Content="新建" Command="{Binding Path=CreateProjectCommand}" />
<dxb:BarButtonItem Content="打开" Command="{Binding Path=OpenProjectCommand}" />
<dxb:BarButtonItem Content="保存" Command="{Binding Path=SaveProjectCommand}" />
<dxb:BarButtonItem Content="另存为" Command="{Binding Path=SaveAsProjectCommand}" />
<dxb:BarButtonItem Content="关闭" Command="{Binding Path=CloseProjectCommand}" />
</dxb:BarSubItem>
<dxb:BarSubItem Content="设置" Alignment="Far">
<dxb:BarSubItem Content="设置" Command="{Binding Path=SettingCommand}">
</dxb:BarSubItem>
<dxb:BarSubItem Content="帮助" Alignment="Far">
<dxb:BarSubItem Content="帮助">
<dxb:BarButtonItem Content="关于" />
</dxb:BarSubItem>
</dxb:MainMenuControl>
......
......@@ -158,7 +158,9 @@ namespace VIZ.TVP.Module
/// </summary>
private void Setting()
{
SettingWindow window = new SettingWindow();
window.Owner = this.GetWindow();
window.ShowDialog();
}
#endregion
......
......@@ -106,11 +106,11 @@
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="备注" FieldName="Remark" 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"
Binding="{Binding Path=TemplateType,Converter={StaticResource Enum2EnumDescriptionConverter}}">
</dxg:GridColumn>
<dxg:GridColumn Header="备注" FieldName="Remark" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="引擎类型" FieldName="EngineType" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AllowEditing="True" ShowIndicator="True"
......@@ -183,10 +183,10 @@
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="层" FieldName="Layer" 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"
Binding="{Binding Path=TemplateType,Converter={StaticResource Enum2EnumDescriptionConverter}}">
</dxg:GridColumn>
<dxg:GridColumn Header="引擎类型" FieldName="EngineType" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="插件" FieldName="PluginName" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Module
{
/// <summary>
/// 设置视图模型
/// </summary>
public interface ISettingViewModel
{
/// <summary>
/// 保存
/// </summary>
void Save();
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Common;
using VIZ.Framework.Core;
namespace VIZ.TVP.Module
{
/// <summary>
/// 设置模型
/// </summary>
public class SettingModel : NavigationConfig
{
#region Icon -- 图标
#endregion
#region DisplayName -- 显示名称
private string displayName;
/// <summary>
/// 显示名称
/// </summary>
public string DisplayName
{
get { return displayName; }
set { displayName = value; this.RaisePropertyChanged(nameof(DisplayName)); }
}
#endregion
}
}
<UserControl x:Class="VIZ.TVP.Module.SettingView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxi="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:local="clr-namespace:VIZ.TVP.Module"
xmlns:domain="clr-namespace:VIZ.TVP.Domain;assembly=VIZ.TVP.Domain"
d:DataContext="{d:DesignInstance Type=local:SettingViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" MinWidth="240" MaxWidth="400"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="80"></RowDefinition>
</Grid.RowDefinitions>
<!-- 资源文件夹 -->
<ListBox ItemsSource="{Binding Path=SettingItems}" Margin="0,0,6,0"
SelectedValue="{Binding Path=SelectedSettingItem,Mode=TwoWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="30" Background="Transparent">
<TextBlock Text="{Binding Path=DisplayName}" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<GridSplitter Width="6" HorizontalAlignment="Right" VerticalAlignment="Stretch"></GridSplitter>
<!-- 面板 -->
<fcommon:NavigationControl x:Name="navigation" Grid.Column="1" ItemsSource="{Binding Path=SettingItems}"
SelectedValue="{Binding Path=SelectedSettingItem,Mode=OneWay}"></fcommon:NavigationControl>
<!-- 按钮组 -->
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
<Button Width="120" Height="30" Content="保存" Command="{Binding Path=SaveCommand}" Margin="0,0,10,0"></Button>
</StackPanel>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.TVP.Module
{
/// <summary>
/// SettingView.xaml 的交互逻辑
/// </summary>
public partial class SettingView : UserControl
{
public SettingView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new SettingViewModel());
}
}
}
<dx:ThemedWindow x:Class="VIZ.TVP.Module.SettingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:module="clr-namespace:VIZ.TVP.Module"
Title="设置" Height="900" Width="1600"
WindowStartupLocation="CenterScreen">
<Grid>
<module:SettingView></module:SettingView>
</Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace VIZ.TVP.Module
{
/// <summary>
/// Interaction logic for SettingWindow.xaml
/// </summary>
public partial class SettingWindow : ThemedWindow
{
public SettingWindow()
{
InitializeComponent();
}
}
}
using DevExpress.Mvvm.Native;
using DevExpress.Xpf.Core;
using DevExpress.Xpf.Core.Native;
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using VIZ.Framework.Core;
using VIZ.TVP.Domain;
namespace VIZ.TVP.Module
{
/// <summary>
/// 设置视图模型
/// </summary>
public class SettingViewModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(SettingViewModel));
public SettingViewModel()
{
// 初始化命令
this.initCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void initCommand()
{
this.LoadedCommand = new VCommand(this.Loaded);
this.SaveCommand = new VCommand(this.Save);
}
// ======================================================================================
// Property
// ======================================================================================
#region SettingItems -- 设置项集合
private ObservableCollection<SettingModel> settingItems;
/// <summary>
/// 设置项集合
/// </summary>
public ObservableCollection<SettingModel> SettingItems
{
get { return settingItems; }
set { settingItems = value; this.RaisePropertyChanged(nameof(SettingItems)); }
}
#endregion
#region SelectedSettingItem -- 当前选中的设置项
private SettingModel selectedSettingItem;
/// <summary>
/// 当前选中的设置项
/// </summary>
public SettingModel SelectedSettingItem
{
get { return selectedSettingItem; }
set { selectedSettingItem = value; this.RaisePropertyChanged(nameof(SelectedSettingItem)); }
}
#endregion
// ======================================================================================
// Command
// ======================================================================================
#region LoadedCommand -- 加载命令
/// <summary>
/// 加载命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载
/// </summary>
private void Loaded()
{
ObservableCollection<SettingModel> items = new ObservableCollection<SettingModel>();
// 加载内置设置页面
// 控制设置
SettingModel control = new SettingModel();
control.DisplayName = "控制";
control.ViewType = typeof(ControlSettingView);
items.Add(control);
// 插件设置页面
foreach (var plugin in ApplicationDomainEx.PluginManager.Plugins)
{
if (!plugin.HasSettingView)
continue;
SettingModel model = new SettingModel();
model.DisplayName = plugin.DisplayName;
model.ViewType = plugin.SettingViewInfo.ViewType;
model.ViewModelType = plugin.SettingViewInfo.ViewModelType;
items.Add(model);
}
foreach (var plugin in ApplicationDomainEx.PluginManager.TemplatePlugins)
{
if (!plugin.HasSettingView)
continue;
SettingModel model = new SettingModel();
model.DisplayName = plugin.DisplayName;
model.ViewType = plugin.SettingViewInfo.ViewType;
model.ViewModelType = plugin.SettingViewInfo.ViewModelType;
items.Add(model);
}
this.SettingItems = items;
}
#endregion
#region SaveCommand -- 保存命令
/// <summary>
/// 保存命令
/// </summary>
public VCommand SaveCommand { get; set; }
/// <summary>
/// 保存
/// </summary>
private void Save()
{
foreach (SettingModel item in this.SettingItems)
{
if (item.View == null)
continue;
if (!item.View.TryGetTarget(out object obj))
continue;
FrameworkElement view = obj as FrameworkElement;
if (view == null)
continue;
ISettingViewModel vm = view.DataContext as ISettingViewModel;
if (vm == null)
continue;
try
{
vm.Save();
}
catch (Exception ex)
{
log.Error(ex);
}
}
DXMessageBox.Show("保存成功!");
}
#endregion
}
}
<UserControl x:Class="VIZ.TVP.Module.ControlSettingView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxi="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:resource="clr-namespace:VIZ.TVP.Module.Resource;assembly=VIZ.TVP.Module.Resource"
xmlns:local="clr-namespace:VIZ.TVP.Module"
xmlns:domain="clr-namespace:VIZ.TVP.Domain;assembly=VIZ.TVP.Domain"
d:DataContext="{d:DesignInstance Type=local:ControlSettingViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<resource:RowHandleConverter x:Key="RowHandleConverter"></resource:RowHandleConverter>
<fcore:Bool2StringConverter x:Key="Bool2StringConverter" TrueResult="启用"></fcore:Bool2StringConverter>
</ResourceDictionary>
</UserControl.Resources>
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500" MinWidth="300" MaxWidth="800"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<GroupBox Header="分组" Margin="10,10,16,10" Padding="10">
<dxg:GridControl ItemsSource="{Binding Path=Groups}" ShowBorder="False"
SelectedItem="{Binding Path=SelectedGroup,Mode=TwoWay}">
<dxg:GridControl.ContextMenu>
<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}}"/>
<Separator/>
<MenuItem Header="启用" Command="{Binding Path=PlacementTarget.DataContext.EnabledGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
<dxg:GridColumn Header="序号" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="40" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding RowData.RowHandle,Converter={StaticResource RowHandleConverter}}"></TextBlock>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="分组名称" FieldName="Name" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings TextWrapping="Wrap" TextTrimming="CharacterEllipsis" MaxLength="50"
HorizontalContentAlignment="Left"></dxe:TextEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="是否启用" Width="80" Binding="{Binding IsEnabled,Converter={StaticResource Bool2StringConverter}}" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="引擎类型" FieldName="EngineType" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AllowEditing="True" ShowIndicator="True"
NavigationStyle="Cell"
ShowGroupPanel="False"
AllowDragDrop="True"
ShowBandsPanel="False"
ShowTotalSummary="False"
ShowFixedTotalSummary="False"
ShowDragDropHint="False"
ShowTargetInfoInDragDropHint="false">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</GroupBox>
<GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="6"></GridSplitter>
<GroupBox Header="项" Margin="10" Padding="10" Grid.Column="1">
<dxg:GridControl ItemsSource="{Binding Path=SelectedGroup.Items}" ShowBorder="False" Grid.Column="1"
SelectedItem="{Binding Path=SelectedItem,Mode=TwoWay}">
<dxg:GridControl.ContextMenu>
<ContextMenu>
<MenuItem Header="添加" Command="{Binding Path=PlacementTarget.DataContext.AddItemCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除" Command="{Binding Path=PlacementTarget.DataContext.DeleteItemCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
<dxg:GridColumn Header="序号" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="40" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding RowData.RowHandle,Converter={StaticResource RowHandleConverter}}"></TextBlock>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="IP地址" FieldName="IP" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<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>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="端口" FieldName="Port" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings TextWrapping="Wrap" MaskType="RegEx" HorizontalContentAlignment="Left" MaxLength="7"
Mask="[0-9]*"></dxe:TextEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="备注" FieldName="Remark" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings TextWrapping="Wrap" TextTrimming="CharacterEllipsis" MaxLength="50"
HorizontalContentAlignment="Left"></dxe:TextEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="是否启用" Width="80" FieldName="IsEnabled" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:CheckEditSettings></dxe:CheckEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AllowEditing="True" ShowIndicator="True"
NavigationStyle="Cell"
ShowGroupPanel="False"
AllowDragDrop="True"
ShowBandsPanel="False"
ShowTotalSummary="False"
ShowFixedTotalSummary="False"
ShowDragDropHint="False"
ShowTargetInfoInDragDropHint="false">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</GroupBox>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.TVP.Module
{
/// <summary>
/// ControlSettingView.xaml 的交互逻辑
/// </summary>
public partial class ControlSettingView : UserControl
{
public ControlSettingView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new ControlSettingViewModel());
}
private void CheckEditSettings_Checked(object sender, RoutedEventArgs e)
{
}
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.TVP.Domain;
using VIZ.TVP.Service;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Module
{
/// <summary>
/// 控制设置视图模型
/// </summary>
public class ControlSettingViewModel : ViewModelBase, ISettingViewModel
{
/// <summary>
/// 日志
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(ControlSettingViewModel));
public ControlSettingViewModel()
{
// 初始化命令
this.initCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void initCommand()
{
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.AddItemCommand = new VCommand(this.AddItem);
this.DeleteItemCommand = new VCommand(this.DeleteItem);
}
// ======================================================================================
// Field
// ======================================================================================
/// <summary>
/// 包装连接服务
/// </summary>
private ITVPConnectionService tvpConnectionService = new TVPConnectionService();
// ======================================================================================
// Property
// ======================================================================================
#region Groups -- 分组集合
private ObservableCollection<TVPConnectionGroupModel> groups;
/// <summary>
/// 分组集合
/// </summary>
public ObservableCollection<TVPConnectionGroupModel> Groups
{
get { return groups; }
set { groups = value; this.RaisePropertyChanged(nameof(Groups)); }
}
#endregion
#region SelectedGroup -- 当前选中的分组
private TVPConnectionGroupModel selectedGroup;
/// <summary>
/// 当前选中的分组
/// </summary>
public TVPConnectionGroupModel SelectedGroup
{
get { return selectedGroup; }
set { selectedGroup = value; this.RaisePropertyChanged(nameof(SelectedGroup)); }
}
#endregion
#region SelectedItem -- 当前选中的项
private TVPConnectionModel selectedItem;
/// <summary>
/// 当前选中的项
/// </summary>
public TVPConnectionModel SelectedItem
{
get { return selectedItem; }
set { selectedItem = value; this.RaisePropertyChanged(nameof(SelectedItem)); }
}
#endregion
// ======================================================================================
// Command
// ======================================================================================
#region LoadedCommand -- 加载命令
/// <summary>
/// 加载命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载
/// </summary>
private void Loaded()
{
if (this.IsAlreadyLoaded)
return;
this.IsAlreadyLoaded = true;
this.Groups = this.tvpConnectionService.GetGroups();
}
#endregion
#region AddGroupCommand -- 添加分组命令
/// <summary>
/// 添加分组命令
/// </summary>
public VCommand AddGroupCommand { get; set; }
/// <summary>
/// 添加分组
/// </summary>
private void AddGroup()
{
TVPConnectionGroupModel group = new TVPConnectionGroupModel(new Storage.TVPConnectionGroupEntity());
group.GroupID = Guid.NewGuid();
group.Name = "新建分组";
this.Groups.Add(group);
}
#endregion
#region DeleteGroupCommand -- 删除分组命令
/// <summary>
/// 删除分组
/// </summary>
public VCommand DeleteGroupCommand { get; set; }
/// <summary>
/// 删除分组
/// </summary>
private void DeleteGroup()
{
if (this.SelectedGroup == null)
return;
this.Groups.Remove(this.SelectedGroup);
}
#endregion
#region EnabledGroupCommand -- 启用组命令
/// <summary>
/// 启用组命令
/// </summary>
public VCommand EnabledGroupCommand { get; set; }
/// <summary>
/// 启用组
/// </summary>
private void EnabledGroup()
{
if (this.SelectedGroup == null)
return;
foreach (var group in this.Groups)
{
group.IsEnabled = group == this.SelectedGroup;
}
}
#endregion
#region AddItemCommand -- 添加项命令
/// <summary>
/// 添加项命令
/// </summary>
public VCommand AddItemCommand { get; set; }
/// <summary>
/// 添加项
/// </summary>
private void AddItem()
{
if (this.SelectedGroup == null)
return;
TVPConnectionModel item = new TVPConnectionModel(new Storage.TVPConnectionEntity());
item.GroupID = this.SelectedGroup.GroupID;
item.IP = "127.0.0.1";
item.Port = 6100;
this.SelectedGroup.Items.Add(item);
}
#endregion
#region DeleteItemCommand -- 删除项命令
/// <summary>
/// 删除项命令
/// </summary>
public VCommand DeleteItemCommand { get; set; }
/// <summary>
/// 删除项
/// </summary>
private void DeleteItem()
{
if (this.SelectedItem == null || this.SelectedGroup == null)
return;
this.SelectedGroup.Items.Remove(this.SelectedItem);
}
#endregion
// ======================================================================================
// Public Function
// ======================================================================================
/// <summary>
/// 保存
/// </summary>
public void Save()
{
this.tvpConnectionService.SaveGroups(this.Groups);
ApplicationDomainEx.TVPConnectionManager.ConnectionGroups = this.Groups;
}
}
}
......@@ -10,6 +10,7 @@ using VIZ.Framework.Connection;
using VIZ.Framework.Storage;
using VIZ.Framework.Module;
using VIZ.TVP.Domain;
using VIZ.TVP.Service;
namespace VIZ.TVP.Module
{
......@@ -29,6 +30,11 @@ namespace VIZ.TVP.Module
public override string Detail { get; } = "应用程序启动 -- 初始化LiteDB";
/// <summary>
/// 包装连接服务
/// </summary>
private ITVPConnectionService tvpConnectionService = new TVPConnectionService();
/// <summary>
/// 执行启动
/// </summary>
/// <param name="context">应用程序启动上下文</param>
......@@ -44,6 +50,9 @@ namespace VIZ.TVP.Module
string path = System.IO.Path.Combine(folder, "cache.db");
ApplicationDomainEx.DataBaseManager.LiteDbContext = new Storage.LiteDbContext(path);
// 初始化包装连接
ApplicationDomainEx.TVPConnectionManager.ConnectionGroups = this.tvpConnectionService.GetGroups();
return true;
}
......
......@@ -59,6 +59,9 @@
<Reference Include="DevExpress.Xpf.Grid.v22.1, Version=22.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Xpf.Grid.v22.1.Core, Version=22.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Xpf.Grid.v22.1.Extensions, Version=22.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="LiteDB, Version=5.0.13.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.13\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath>
</Reference>
......@@ -87,6 +90,10 @@
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Page Include="SettingInner\Control\View\ControlSettingView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\ControlList\View\ControlListView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......@@ -147,6 +154,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Setting\View\SettingWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Setting\View\SettingView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -161,6 +176,10 @@
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="SettingInner\Control\ViewModel\ControlSettingViewModel.cs" />
<Compile Include="SettingInner\Control\View\ControlSettingView.xaml.cs">
<DependentUpon>ControlSettingView.xaml</DependentUpon>
</Compile>
<Compile Include="Control\ControlList\ViewModel\ControlListViewModel.cs" />
<Compile Include="Control\ControlList\View\ControlListView.xaml.cs">
<DependentUpon>ControlListView.xaml</DependentUpon>
......@@ -242,6 +261,15 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Resource\MediaResource\MediaResourcePluginLifeCycle.cs" />
<Compile Include="Setting\ISettingViewModel.cs" />
<Compile Include="Setting\View\SettingWindow.xaml.cs">
<DependentUpon>SettingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Setting\Model\SettingModel.cs" />
<Compile Include="Setting\ViewModel\SettingViewModel.cs" />
<Compile Include="Setting\View\SettingView.xaml.cs">
<DependentUpon>SettingView.xaml</DependentUpon>
</Compile>
<Compile Include="Setup\Provider\Setup\AppSetup_InitLiteDB.cs" />
<Compile Include="Common\View\TextInputView.xaml.cs">
<DependentUpon>TextInputView.xaml</DependentUpon>
......
......@@ -140,20 +140,20 @@ namespace VIZ.TVP.Module
// --------------------------------------------------------------------
// 测试代码
// --------------------------------------------------------------------
TVPEngineConfig config = new TVPEngineConfig();
config.Name = "测试VIZ引擎";
config.EngineType = TVPEngineType.VIZ;
config.FullPath = @"D:\Program Files (x86)\Vizrt\Viz3\viz.exe";
//config.FullPath = @"C:\Program Files\Vizrt\Viz3\viz.exe";
//TVPEngineConfig config = new TVPEngineConfig();
//config.Name = "测试VIZ引擎";
//config.EngineType = TVPEngineType.VIZ;
//config.FullPath = @"D:\Program Files (x86)\Vizrt\Viz3\viz.exe";
////config.FullPath = @"C:\Program Files\Vizrt\Viz3\viz.exe";
// --------------------------------------------------------------------
//// --------------------------------------------------------------------
// Step 2. 等待发送命令
this.connectionModel = new TVPConnectionModel();
connectionModel.ID = "test";
connectionModel.InitEndpointManager(new VizEndpointManager("test", "localhost", 6100));
//// Step 2. 等待发送命令
//this.connectionModel = new TVPConnectionModel();
//connectionModel.ID = "test";
//connectionModel.InitEndpointManager(new VizEndpointManager("test", "localhost", 6100));
this.vizController.StartVizEngine(view, config, this.connectionModel);
//this.vizController.StartVizEngine(view, config, this.connectionModel);
}
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LiteDB" version="5.0.13" targetFramework="net48" />
<package id="log4net" version="2.0.14" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
</packages>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.TVP.Domain;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Service
{
/// <summary>
/// 包装连接服务
/// </summary>
public class TVPConnectionService : ITVPConnectionService
{
/// <summary>
/// 锁对象
/// </summary>
private static object lock_object = new object();
/// <summary>
/// 加载包装连接分组
/// </summary>
/// <returns>包装连接分组</returns>
public ObservableCollection<TVPConnectionGroupModel> GetGroups()
{
List<TVPConnectionGroupModel> list = new List<TVPConnectionGroupModel>();
foreach (TVPConnectionGroupEntity groupEntity in ApplicationDomainEx.DataBaseManager.LiteDbContext.TVPConnectionGroup.FindAll())
{
TVPConnectionGroupModel groupModel = new TVPConnectionGroupModel(groupEntity);
groupModel.PropertyFromEntity();
list.Add(groupModel);
}
Dictionary<Guid, TVPConnectionGroupModel> dic = list.ToDictionary(p => p.GroupID, p => p);
foreach (TVPConnectionEntity entity in ApplicationDomainEx.DataBaseManager.LiteDbContext.TVPConnection.FindAll())
{
TVPConnectionModel model = new TVPConnectionModel(entity);
model.PropertyFromEntity();
if (!dic.TryGetValue(model.GroupID, out TVPConnectionGroupModel groupModel))
continue;
groupModel.Items.Add(model);
}
foreach (var groupModel in list)
{
groupModel.Items = groupModel.Items.OrderBy(p => p.OrderIndex).ToObservableCollection();
}
return list.OrderBy(p => p.OrderIndex).ToObservableCollection();
}
/// <summary>
/// 保存包装连接分组集合
/// </summary>
/// <param name="groupModels">分组集合</param>
public void SaveGroups(IList<TVPConnectionGroupModel> groupModels)
{
List<TVPConnectionGroupEntity> groups = new List<TVPConnectionGroupEntity>();
List<TVPConnectionEntity> items = new List<TVPConnectionEntity>();
for (int i = 0; i < groupModels.Count; i++)
{
TVPConnectionGroupModel groupModel = groupModels[i];
groupModel.OrderIndex = i;
groupModel.PropertyToEntity();
groups.Add(groupModel.Entity);
for (int j = 0; j < groupModel.Items.Count; j++)
{
TVPConnectionModel model = groupModel.Items[j];
model.OrderIndex = j;
model.PropertyToEntity();
items.Add(model.Entity);
}
}
lock (lock_object)
{
ApplicationDomainEx.DataBaseManager.LiteDbContext.TVPConnectionGroup.DeleteAll();
ApplicationDomainEx.DataBaseManager.LiteDbContext.TVPConnection.DeleteAll();
ApplicationDomainEx.DataBaseManager.LiteDbContext.TVPConnectionGroup.Insert(groups);
ApplicationDomainEx.DataBaseManager.LiteDbContext.TVPConnection.Insert(items);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Domain;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Service
{
/// <summary>
/// 包装连接服务
/// </summary>
public interface ITVPConnectionService
{
/// <summary>
/// 加载包装连接分组
/// </summary>
/// <returns>包装连接分组</returns>
ObservableCollection<TVPConnectionGroupModel> GetGroups();
/// <summary>
/// 保存包装连接分组集合
/// </summary>
/// <param name="groupModels">分组集合</param>
void SaveGroups(IList<TVPConnectionGroupModel> groupModels);
}
}
......@@ -68,6 +68,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TVPConnection\Implementation\TVPConnectionService.cs" />
<Compile Include="TVPConnection\Interface\ITVPConnectionService.cs" />
<Compile Include="GH\Implementation\GHResourceService.cs" />
<Compile Include="GH\Implementation\GHService.cs" />
<Compile Include="GH\Interface\IGHResourceService.cs" />
......
......@@ -18,14 +18,14 @@ namespace VIZ.TVP.Storage
public int Id { get; set; }
/// <summary>
/// 分组ID
/// 所属分组ID
/// </summary>
public int GroupId { get; set; }
public Guid GroupID { get; set; }
/// <summary>
/// 显示名称
/// 名称
/// </summary>
public string DisplayName { get; set; }
public string Name { get; set; }
/// <summary>
/// IP地址
......@@ -38,8 +38,18 @@ namespace VIZ.TVP.Storage
public int Port { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled { get; set; }
/// <summary>
/// 排序
/// </summary>
public int OrderIndex { get; set; }
}
}
......@@ -18,13 +18,28 @@ namespace VIZ.TVP.Storage
public int Id { get; set; }
/// <summary>
/// 显示名称
/// 分组ID
/// </summary>
public string DisplayName { get; set; }
public Guid GroupID { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 引擎类型
/// </summary>
public TVPEngineType EngineType { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled { get; set; }
/// <summary>
/// 排序索引
/// </summary>
public int OrderIndex { 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