Commit f33e1d02 by liulongfei

添加插件映射设置,添加页时默认使用映射的插件

parent ccbb18c2
......@@ -83,6 +83,11 @@ namespace VIZ.Package.Domain
/// </summary>
public static List<PluginInfo> PluginInfos { get; set; }
/// <summary>
/// 插件映射配置
/// </summary>
public static PluginMappingConfigEntity PluginMappingConfig { get; set; }
// =============================================================
// 其他
// =============================================================
......
......@@ -82,5 +82,10 @@ namespace VIZ.Package.Domain
/// 媒资库设置
/// </summary>
public const string MEDIA_CONFIG_SETTING = "MEDIA_CONFIG_SETTING";
/// <summary>
/// 插件映射设置
/// </summary>
public const string PLUGIN_MAPPING_SETTING = "PLUGIN_MAPPING_SETTING";
}
}
......@@ -121,4 +121,41 @@
</Setter>
</Style>
<!-- IconButton_Menu_Mask -->
<Style x:Key="IconButton_Menu_Mask" TargetType="fcommon:IconButton">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="BorderBrush" Value="Transparent"></Setter>
<Setter Property="BorderThickness" Value="0"></Setter>
<Setter Property="Width" Value="30"></Setter>
<Setter Property="Height" Value="30"></Setter>
<Setter Property="IconWidth" Value="20"></Setter>
<Setter Property="IconHeight" Value="20"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="fcommon:IconButton">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<Border x:Name="icon" Background="#BBFFFFFF" VerticalAlignment="Center" HorizontalAlignment="Center"
Width="{TemplateBinding IconWidth}" Height="{TemplateBinding IconHeight}">
<Border.OpacityMask>
<ImageBrush ImageSource="{Binding Icon,RelativeSource={RelativeSource AncestorType=fcommon:IconButton,Mode=FindAncestor}}"></ImageBrush>
</Border.OpacityMask>
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#11FFFFFF"></Setter>
<Setter TargetName="icon" Property="Background" Value="#FF4E4BDE"></Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="icon" Property="Background" Value="#AA4E4BDE"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
......@@ -215,5 +215,9 @@
<ItemGroup>
<Resource Include="Icons\preview_connection_32x32.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\add_32x32.png" />
<Resource Include="Icons\delete_32x32.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -224,7 +224,7 @@ namespace VIZ.Package.Module
mediaConfig = mediaConfig ?? new MediaConfigEntity();
ApplicationDomainEx.MediaConfig = mediaConfig;
// Step 2. 加载插件信息
// Step 3. 加载插件信息
ApplicationDomainEx.PluginInfos = this.pluginService.LoadPluginInfos();
this.UpdatePluginInfos(vizConfig);
......
......@@ -220,7 +220,5 @@ namespace VIZ.Package.Module
return path;
}
}
}
......@@ -122,13 +122,19 @@ namespace VIZ.Package.Module
/// </summary>
private void Loaded()
{
// 模板插件集合
this.TemplatePlugins = ApplicationDomainEx.PluginInfos.Where(
p => !string.IsNullOrWhiteSpace(p.Group) &&
p.Group != ApplicationConstants.APPLICATION_GROUP_NAME &&
p.Group == ApplicationDomainEx.VizConfig.PluginGroup &&
p.PluginType == PluginType.Page).ToList();
// TODO: 选择默认模板
// 选择默认模板
PluginMapping mapping = ApplicationDomainEx.PluginMappingConfig?.Mappings?.FirstOrDefault(p => p.Scene == this.Scene);
if (mapping != null)
{
this.SelectedTemplatePlugin = this.TemplatePlugins.FirstOrDefault(p => p.ID == mapping.PluginID);
}
}
#endregion
......
......@@ -17,6 +17,11 @@
d:DataContext="{d:DesignInstance Type=local:PluginViewModel}"
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>
<fcommon:NavigationControl ItemsSource="{Binding ItemsSource}"
SelectedValue="{Binding Path=SelectedValue,Mode=OneWay}"></fcommon:NavigationControl>
......
using DevExpress.Xpf.Printing;
using DevExpress.Xpf.Core.Native;
using DevExpress.Xpf.Printing;
using log4net;
using System;
using System.Collections.Generic;
......@@ -10,6 +11,7 @@ using VIZ.Framework.Common;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
using VIZ.Package.Storage;
namespace VIZ.Package.Module
{
......@@ -25,6 +27,9 @@ namespace VIZ.Package.Module
public PluginViewModel()
{
// 初始化命令
this.InitCommand();
// 初始化消息
this.InitMessage();
......@@ -33,6 +38,14 @@ namespace VIZ.Package.Module
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.LoadedCommand = new VCommand(this.Loaded);
}
/// <summary>
/// 初始化消息
/// </summary>
private void InitMessage()
......@@ -77,6 +90,39 @@ namespace VIZ.Package.Module
// Command
// ========================================================================
#region LoadedCommand -- 加载命令
/// <summary>
/// 加载命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载
/// </summary>
private void Loaded()
{
if (this.IsAlreadyLoaded)
return;
// 获取插件映射配置
PluginMappingConfigEntity config = ApplicationDomainEx.LocalDbContext.PluginMappingConfig.FindOne(p => p.PluginGroup == ApplicationDomainEx.VizConfig.PluginGroup);
if (config == null)
{
config = new PluginMappingConfigEntity();
config.PluginGroup = ApplicationDomainEx.VizConfig.PluginGroup;
config.Mappings = new List<PluginMapping>();
ApplicationDomainEx.LocalDbContext.PluginMappingConfig.Insert(config);
}
ApplicationDomainEx.PluginMappingConfig = config;
this.IsAlreadyLoaded = true;
}
#endregion
// ========================================================================
// Message
// ========================================================================
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// 插件映射模型
/// </summary>
public class PluginMappingModel : ModelBase
{
#region Scene -- 场景
private string scene;
/// <summary>
/// 场景
/// </summary>
public string Scene
{
get { return scene; }
set { scene = value; this.RaisePropertyChanged(nameof(Scene)); }
}
#endregion
#region PluginID -- 插件ID
private string pluginID;
/// <summary>
/// 插件ID
/// </summary>
public string PluginID
{
get { return pluginID; }
set { pluginID = value; this.RaisePropertyChanged(nameof(PluginID)); }
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
namespace VIZ.Package.Module
{
/// <summary>
/// 插件映射插件生命周期
/// </summary>
public class PluginMappingSettingPluginLifeCycle : IPluginLifeCycle
{
/// <summary>
/// 插件分组
/// </summary>
public const string PLUGIN_GROUP = ApplicationConstants.APPLICATION_GROUP_NAME;
/// <summary>
/// 插件ID
/// </summary>
/// <remarks>
/// 插件ID不能包含点号
/// </remarks>
public const string PLUGIN_ID = ModulePluginIds.PLUGIN_MAPPING_SETTING;
/// <summary>
/// 插件名称
/// </summary>
public const string PLUGIN_NAME = "插件映射";
/// <summary>
/// 注册
/// </summary>
/// <returns>插件信息</returns>
public PluginInfo Register()
{
PluginInfo info = new PluginInfo();
info.Group = PLUGIN_GROUP;
info.ID = PLUGIN_ID;
info.Name = PLUGIN_NAME;
info.PluginType = PluginType.Setting;
info.ViewType = typeof(PluginMappingSettingView);
return info;
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
}
}
}
<UserControl x:Class="VIZ.Package.Module.PluginMappingSettingView"
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:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:storage="clr-namespace:VIZ.Package.Storage;assembly=VIZ.Package.Storage"
xmlns:resource="clr-namespace:VIZ.Package.Module.Resource;assembly=VIZ.Package.Module.Resource"
xmlns:local="clr-namespace:VIZ.Package.Module"
xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
d:DataContext="{d:DesignInstance Type=local:PluginMappingSettingViewModel}"
d:Background="White"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.Package.Module.Resource;component/Style/IconButton/IconButton_Default.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<resource:RowHandleConverter x:Key="RowHandleConverter"></resource:RowHandleConverter>
</ResourceDictionary>
</UserControl.Resources>
<GroupBox Header="插件映射" Padding="10" Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 按钮组 -->
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<fcommon:IconButton Icon="/VIZ.Package.Module.Resource;component/Icons/add_32x32.png"
Width="40" ToolTip="添加"
Command="{Binding AddCommand}"
Style="{StaticResource IconButton_Menu_Mask}"></fcommon:IconButton>
<fcommon:IconButton Icon="/VIZ.Package.Module.Resource;component/Icons/delete_32x32.png"
Width="40" ToolTip="删除"
Command="{Binding DeleteCommand}"
Style="{StaticResource IconButton_Menu_Mask}"></fcommon:IconButton>
</StackPanel>
<!-- 列表 -->
<dxg:GridControl Grid.Row="1" ItemsSource="{Binding Path=Mappings}"
SelectedItem="{Binding Path=SelectedMapping,Mode=TwoWay}">
<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="Scene" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings AcceptsReturn="False"></dxe:TextEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="插件" FieldName="PluginID" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding Path=PluginInfos}"
DisplayMember="Name" ValueMember="ID"></dxe:ComboBoxEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView IsColumnMenuEnabled="False"
AllowEditing="True" ShowIndicator="False"
NavigationStyle="Cell" ShowVerticalLines="False"
ShowGroupPanel="False" EditorShowMode="MouseUp"
AllowDragDrop="False"
ShowBandsPanel="False"
ShowTotalSummary="False"
ShowFixedTotalSummary="False"
ShowDragDropHint="False"
ShowTargetInfoInDragDropHint="false">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</GroupBox>
</UserControl>
\ No newline at end of file
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;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
/// <summary>
/// PluginMappingSettingView.xaml 的交互逻辑
/// </summary>
public partial class PluginMappingSettingView : UserControl, IPluginSettingView
{
public PluginMappingSettingView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new PluginMappingSettingViewModel());
}
/// <summary>
/// 保存
/// </summary>
public void Save()
{
PluginMappingSettingViewModel vm = this.DataContext as PluginMappingSettingViewModel;
vm.Save();
}
}
}
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.Package.Domain;
using VIZ.Package.Storage;
namespace VIZ.Package.Module
{
/// <summary>
/// 插件映射设置视图模型
/// </summary>
public class PluginMappingSettingViewModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(PluginMappingSettingViewModel));
/// <summary>
/// 媒资库配置设置视图模型
/// </summary>
public PluginMappingSettingViewModel()
{
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.LoadedCommand = new VCommand(this.Loaded);
this.AddCommand = new VCommand(this.Add);
this.DeleteCommand = new VCommand(this.Delete);
}
// =========================================================================
// Property
// =========================================================================
#region Mappings -- 映射集合
private ObservableCollection<PluginMappingModel> mappings;
/// <summary>
/// 映射集合
/// </summary>
public ObservableCollection<PluginMappingModel> Mappings
{
get { return mappings; }
set { mappings = value; this.RaisePropertyChanged(nameof(Mappings)); }
}
#endregion
#region SelectedMapping -- 当前选中的映射
private PluginMappingModel selectedMapping;
/// <summary>
/// 当前选中的映射
/// </summary>
public PluginMappingModel SelectedMapping
{
get { return selectedMapping; }
set { selectedMapping = value; this.RaisePropertyChanged(nameof(SelectedMapping)); }
}
#endregion
#region PluginInfos -- 插件信息集合
private List<PluginInfo> pluginInfos;
/// <summary>
/// 插件信息集合
/// </summary>
public List<PluginInfo> PluginInfos
{
get { return pluginInfos; }
set { pluginInfos = value; this.RaisePropertyChanged(nameof(PluginInfos)); }
}
#endregion
// =========================================================================
// Command
// =========================================================================
#region LoadedCommand -- 加载命令
/// <summary>
/// 加载命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载
/// </summary>
private void Loaded()
{
// 插件映射配置
PluginMappingConfigEntity config = ApplicationDomainEx.PluginMappingConfig;
ObservableCollection<PluginMappingModel> list = new ObservableCollection<PluginMappingModel>();
if (config.Mappings != null)
{
foreach (PluginMapping item in config.Mappings)
{
PluginMappingModel model = new PluginMappingModel();
model.Scene = item.Scene;
model.PluginID = item.PluginID;
list.Add(model);
}
}
this.Mappings = list;
// 插件信息
this.PluginInfos = ApplicationDomainEx.PluginInfos.Where(p => p.PluginType == PluginType.Page && p.Group != ApplicationConstants.APPLICATION_GROUP_NAME).ToList();
}
#endregion
#region AddCommand -- 添加命令
/// <summary>
/// 添加命令
/// </summary>
public VCommand AddCommand { get; set; }
/// <summary>
/// 添加
/// </summary>
private void Add()
{
PluginMappingModel model = new PluginMappingModel();
this.Mappings.Add(model);
}
#endregion
#region DeleteCommand -- 删除命令
/// <summary>
/// 删除命令
/// </summary>
public VCommand DeleteCommand { get; set; }
/// <summary>
/// 删除
/// </summary>
private void Delete()
{
if (this.SelectedMapping == null)
return;
this.Mappings.Remove(this.SelectedMapping);
}
#endregion
// =========================================================================
// Public Function
// =========================================================================
/// <summary>
/// 保存
/// </summary>
public void Save()
{
PluginMappingConfigEntity config = ApplicationDomainEx.PluginMappingConfig;
List<PluginMapping> list = new List<PluginMapping>();
if (this.Mappings != null)
{
foreach (PluginMappingModel model in this.Mappings)
{
PluginMapping item = new PluginMapping();
item.Scene = model.Scene;
item.PluginID = model.PluginID;
list.Add(item);
}
}
config.Mappings = list;
ApplicationDomainEx.LocalDbContext.PluginMappingConfig.Update(config);
}
}
}
\ No newline at end of file
......@@ -319,6 +319,12 @@
<DependentUpon>MediaSettingView.xaml</DependentUpon>
</Compile>
<Compile Include="Setting\Media\MediaSettingPluginLifeCycle.cs" />
<Compile Include="Setting\PluginMapping\Model\PluginMappingModel.cs" />
<Compile Include="Setting\PluginMapping\PluginMappingSettingPluginLifeCycle.cs" />
<Compile Include="Setting\PluginMapping\ViewModel\PluginMappingSettingViewModel.cs" />
<Compile Include="Setting\PluginMapping\View\PluginMappingSettingView.xaml.cs">
<DependentUpon>PluginMappingSettingView.xaml</DependentUpon>
</Compile>
<Compile Include="Setting\VizConfig\VizConfigSettingPluginLifeCycle.cs" />
<Compile Include="Setting\VizConfig\ViewModel\VizConfigSettingViewModel.cs" />
<Compile Include="Setup\AppSetup_InitLiteDB.cs" />
......@@ -553,6 +559,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Setting\PluginMapping\View\PluginMappingSettingView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Task\PackageTask\View\PackageTaskView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Storage
{
/// <summary>
/// 插件映射
/// </summary>
public class PluginMapping
{
/// <summary>
/// 场景
/// </summary>
public string Scene { get; set; }
/// <summary>
/// 插件ID
/// </summary>
public string PluginID { get; set; }
}
/// <summary>
/// 插件映射配置
/// </summary>
public class PluginMappingConfigEntity
{
/// <summary>
/// 编号
/// </summary>
[BsonId(true)]
public int Id { get; set; }
/// <summary>
/// 插件分组
/// </summary>
public string PluginGroup { get; set; }
/// <summary>
/// 映射集合
/// </summary>
public List<PluginMapping> Mappings { get; set; }
}
}
......@@ -37,6 +37,7 @@ namespace VIZ.Package.Storage
this.MediaConfig = this.Database.GetCollection<MediaConfigEntity>();
this.ConnGroup = this.Database.GetCollection<ConnGroupEntity>();
this.Conn = this.Database.GetCollection<ConnEntity>();
this.PluginMappingConfig = this.Database.GetCollection<PluginMappingConfigEntity>();
}
/// <summary>
......@@ -65,6 +66,11 @@ namespace VIZ.Package.Storage
public ILiteCollection<ConnEntity> Conn { get; private set; }
/// <summary>
/// 插件映射
/// </summary>
public ILiteCollection<PluginMappingConfigEntity> PluginMappingConfig { get; private set; }
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
......@@ -73,6 +79,7 @@ namespace VIZ.Package.Storage
this.MediaConfig = null;
this.ConnGroup = null;
this.Conn = null;
this.PluginMappingConfig = null;
this.Database?.Dispose();
}
......
......@@ -68,6 +68,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Entity\Config\MediaConfigEntity.cs" />
<Compile Include="Entity\Config\PluginMappingConfigEntity.cs" />
<Compile Include="Entity\Conn\ConnEntity.cs" />
<Compile Include="Entity\Conn\ConnGroupEntity.cs" />
<Compile Include="Entity\ControlObject\ControlFieldEntity.cs" />
......
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