Commit 52ba4949 by wangonghui
parents 259bfd4b 8d60e45b
...@@ -64,6 +64,11 @@ namespace VIZ.Package.Domain ...@@ -64,6 +64,11 @@ namespace VIZ.Package.Domain
public static VizConfigEntity VizConfig { get; set; } public static VizConfigEntity VizConfig { get; set; }
/// <summary> /// <summary>
/// 媒资库配置
/// </summary>
public static MediaConfigEntity MediaConfig { get; set; }
/// <summary>
/// 插件信息 /// 插件信息
/// </summary> /// </summary>
public static List<PluginInfo> PluginInfos { get; set; } public static List<PluginInfo> PluginInfos { get; set; }
...@@ -96,11 +101,5 @@ namespace VIZ.Package.Domain ...@@ -96,11 +101,5 @@ namespace VIZ.Package.Domain
/// 当前页 /// 当前页
/// </summary> /// </summary>
public static PageModelBase CurrentPage { get; set; } public static PageModelBase CurrentPage { get; set; }
/// <summary>
/// 媒体库配置
/// </summary>
public static ConfigContext MediaConfig { get; set; }
} }
} }
...@@ -77,5 +77,10 @@ namespace VIZ.Package.Domain ...@@ -77,5 +77,10 @@ namespace VIZ.Package.Domain
/// Viz设置 /// Viz设置
/// </summary> /// </summary>
public const string VIZ_CONFIG_SETTING = "VIZ_CONFIG_SETTING"; public const string VIZ_CONFIG_SETTING = "VIZ_CONFIG_SETTING";
/// <summary>
/// 媒资库设置
/// </summary>
public const string MEDIA_CONFIG_SETTING = "MEDIA_CONFIG_SETTING";
} }
} }
...@@ -219,6 +219,11 @@ namespace VIZ.Package.Module ...@@ -219,6 +219,11 @@ namespace VIZ.Package.Module
ApplicationDomainEx.VizConfig = vizConfig; ApplicationDomainEx.VizConfig = vizConfig;
this.UpdateVizConfig(vizConfig); this.UpdateVizConfig(vizConfig);
// Step 2. 加载媒资库信息
MediaConfigEntity mediaConfig = ApplicationDomainEx.LocalDbContext.MediaConfig.FindAll().FirstOrDefault();
mediaConfig = mediaConfig ?? new MediaConfigEntity();
ApplicationDomainEx.MediaConfig = mediaConfig;
// Step 2. 加载插件信息 // Step 2. 加载插件信息
ApplicationDomainEx.PluginInfos = this.pluginService.LoadPluginInfos(); ApplicationDomainEx.PluginInfos = this.pluginService.LoadPluginInfos();
this.UpdatePluginInfos(vizConfig); this.UpdatePluginInfos(vizConfig);
......
...@@ -4,9 +4,16 @@ ...@@ -4,9 +4,16 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module" xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:MainStatusViewModel}"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="35" d:DesignWidth="800"> d:DesignHeight="35" d:DesignWidth="800">
<Grid> <Grid>
<TextBlock Text="状态面板" Foreground="Red" FontSize="24" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<!-- 項目名 -->
<TextBlock Text="项目:" Margin="10,0,0,0" Opacity="0.6"></TextBlock>
<TextBlock Text="{Binding ProjectName}" Margin="10,0,0,0"></TextBlock>
<TextBlock Text="场景:" Margin="40,0,0,0" Opacity="0.6"></TextBlock>
<TextBlock Text="{Binding Scene}" Margin="10,0,0,0"></TextBlock>
</StackPanel>
</Grid> </Grid>
</UserControl> </UserControl>
...@@ -4,6 +4,7 @@ using System.Linq; ...@@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Domain;
namespace VIZ.Package.Module namespace VIZ.Package.Module
{ {
...@@ -12,5 +13,83 @@ namespace VIZ.Package.Module ...@@ -12,5 +13,83 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
public class MainStatusViewModel : ViewModelBase public class MainStatusViewModel : ViewModelBase
{ {
/// <summary>
/// 状态视图模型
/// </summary>
public MainStatusViewModel()
{
ApplicationDomainEx.MessageManager.Register<ProjectOpenMessage>(this, this.OnProjectOpenMessage);
ApplicationDomainEx.MessageManager.Register<ProjectCloseMessage>(this, this.OnProjectCloseMessage);
ApplicationDomainEx.MessageManager.Register<PageOpenMessage>(this, this.OnPageOpenMessage);
}
// ======================================================================
// Property
// ======================================================================
#region ProjectName -- 项目名称
private string projectName;
/// <summary>
/// 项目名称
/// </summary>
public string ProjectName
{
get { return projectName; }
set { projectName = value; this.RaisePropertyChanged(nameof(ProjectName)); }
}
#endregion
#region Scene -- 当前打开的场景
private string scene;
/// <summary>
/// 当前打开的场景
/// </summary>
public string Scene
{
get { return scene; }
set { scene = value; this.RaisePropertyChanged(nameof(Scene)); }
}
#endregion
// ======================================================================
// Message
// ======================================================================
/// <summary>
/// 项目打开消息
/// </summary>
/// <param name="msg">消息</param>
private void OnProjectOpenMessage(ProjectOpenMessage msg)
{
if (ApplicationDomainEx.ProjectDbContext == null)
{
this.ProjectName = null;
return;
}
this.ProjectName = System.IO.Path.GetFileNameWithoutExtension(ApplicationDomainEx.ProjectDbContext.Path);
}
/// <summary>
/// 项目关闭消息
/// </summary>
/// <param name="msg">消息</param>
private void OnProjectCloseMessage(ProjectCloseMessage msg)
{
this.ProjectName = null;
}
/// <summary>
/// 页打开消息
/// </summary>
/// <param name="msg">消息</param>
private void OnPageOpenMessage(PageOpenMessage msg)
{
this.Scene = msg.Page?.Scene;
}
} }
} }
...@@ -122,7 +122,7 @@ namespace VIZ.Package.Module ...@@ -122,7 +122,7 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
private void Loaded() private void Loaded()
{ {
this.TemplatePlugins = ApplicationDomainEx.PluginInfos.Where(p => p.PluginType == PluginType.Page).ToList(); this.TemplatePlugins = ApplicationDomainEx.PluginInfos.Where(p => p.Group == ApplicationDomainEx.VizConfig.PluginGroup && p.PluginType == PluginType.Page).ToList();
// TODO: 选择默认模板 // TODO: 选择默认模板
} }
......
...@@ -6,6 +6,7 @@ using System.Collections.ObjectModel; ...@@ -6,6 +6,7 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Domain; using VIZ.Package.Domain;
using VIZ.Package.Service; using VIZ.Package.Service;
...@@ -234,6 +235,9 @@ namespace VIZ.Package.Module ...@@ -234,6 +235,9 @@ namespace VIZ.Package.Module
if (this.SelectedPageGroupModel == null) if (this.SelectedPageGroupModel == null)
return; return;
if (DXMessageBox.Show($"是否删除分组【{this.SelectedPageGroupModel.GroupName}】?", "提示", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
return;
this.PageGroupModels.Remove(this.SelectedPageGroupModel); this.PageGroupModels.Remove(this.SelectedPageGroupModel);
} }
......
...@@ -33,10 +33,10 @@ ...@@ -33,10 +33,10 @@
<ContextMenu> <ContextMenu>
<MenuItem Header="打开" Command="{Binding Path=PlacementTarget.DataContext.OpenScenePageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="打开" Command="{Binding Path=PlacementTarget.DataContext.OpenScenePageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator></Separator> <Separator></Separator>
<MenuItem Header="添加至节目单" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateAddToPageGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="添加至节目单" Command="{Binding Path=PlacementTarget.DataContext.AddToPageGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="更新模板" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateUpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="更新模板" Command="{Binding Path=PlacementTarget.DataContext.UpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator></Separator> <Separator></Separator>
<MenuItem Header="删除模板" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateDeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="删除模板" Command="{Binding Path=PlacementTarget.DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu> </ContextMenu>
</dxg:GridControl.ContextMenu> </dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns> <dxg:GridControl.Columns>
......
...@@ -6,6 +6,7 @@ using System.Collections.ObjectModel; ...@@ -6,6 +6,7 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Controls.Primitives;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Domain; using VIZ.Package.Domain;
using VIZ.Package.Service; using VIZ.Package.Service;
...@@ -26,10 +27,10 @@ namespace VIZ.Package.Module ...@@ -26,10 +27,10 @@ namespace VIZ.Package.Module
public PageTemplateViewModel() public PageTemplateViewModel()
{ {
// 初始化命令 // 初始化命令
this.initCommand(); this.InitCommand();
// 初始化消息 // 初始化消息
this.initMessage(); this.InitMessage();
// 注册服务 // 注册服务
ApplicationDomainEx.ServiceManager.AddService(ViewServiceKeys.PAGE_TEMPLATE_SERVICE, this); ApplicationDomainEx.ServiceManager.AddService(ViewServiceKeys.PAGE_TEMPLATE_SERVICE, this);
...@@ -38,16 +39,18 @@ namespace VIZ.Package.Module ...@@ -38,16 +39,18 @@ namespace VIZ.Package.Module
/// <summary> /// <summary>
/// 初始化命令 /// 初始化命令
/// </summary> /// </summary>
private void initCommand() private void InitCommand()
{ {
this.SceneTemplateAddToPageGroupCommand = new VCommand(this.SceneTemplateAddToPageGroup); this.AddToPageGroupCommand = new VCommand(this.AddToPageGroup);
this.OpenScenePageCommand = new VCommand(this.OpenScenePage); this.OpenScenePageCommand = new VCommand(this.OpenScenePage);
this.UpdateCommand = new VCommand(this.Update);
this.DeleteCommand = new VCommand(this.Delete);
} }
/// <summary> /// <summary>
/// 初始化消息 /// 初始化消息
/// </summary> /// </summary>
private void initMessage() private void InitMessage()
{ {
ApplicationDomainEx.MessageManager.Register<ProjectOpenMessage>(this, this.OnProjectOpenMessage); ApplicationDomainEx.MessageManager.Register<ProjectOpenMessage>(this, this.OnProjectOpenMessage);
ApplicationDomainEx.MessageManager.Register<ProjectCloseMessage>(this, this.OnProjectCloseMessage); ApplicationDomainEx.MessageManager.Register<ProjectCloseMessage>(this, this.OnProjectCloseMessage);
...@@ -68,6 +71,21 @@ namespace VIZ.Package.Module ...@@ -68,6 +71,21 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
private PageService pageService = new PageService(); private PageService pageService = new PageService();
/// <summary>
/// Viz命令服务
/// </summary>
private VizCommandService vizCommandService = new VizCommandService();
/// <summary>
/// Viz控制对象服务
/// </summary>
private VizCommandControlObjectService vizCommandControlObjectService = new VizCommandControlObjectService();
/// <summary>
/// 控制对象服务
/// </summary>
private ControlObjectService controlObjectService = new ControlObjectService();
// ====================================================================================== // ======================================================================================
// Property // Property
// ====================================================================================== // ======================================================================================
...@@ -160,17 +178,17 @@ namespace VIZ.Package.Module ...@@ -160,17 +178,17 @@ namespace VIZ.Package.Module
// Command // Command
// ====================================================================================== // ======================================================================================
#region SceneTemplateAddToPageGroupCommand -- 场景模板添加至页分组命令 #region AddToPageGroupCommand -- 场景模板添加至页分组命令
/// <summary> /// <summary>
/// 场景模板添加至页分组命令 /// 场景模板添加至页分组命令
/// </summary> /// </summary>
public VCommand SceneTemplateAddToPageGroupCommand { get; set; } public VCommand AddToPageGroupCommand { get; set; }
/// <summary> /// <summary>
/// 场景模板添加至页分组 /// 场景模板添加至页分组
/// </summary> /// </summary>
private void SceneTemplateAddToPageGroup() private void AddToPageGroup()
{ {
if (this.SelectedSceneTemplateModel == null) if (this.SelectedSceneTemplateModel == null)
return; return;
...@@ -211,6 +229,81 @@ namespace VIZ.Package.Module ...@@ -211,6 +229,81 @@ namespace VIZ.Package.Module
#endregion #endregion
#region UpdateCommand -- 更新命令
/// <summary>
/// 更新命令
/// </summary>
public VCommand UpdateCommand { get; set; }
/// <summary>
/// 更新
/// </summary>
private void Update()
{
if (this.SelectedSceneTemplateModel == null)
return;
IFieldTreeService service = ApplicationDomainEx.ServiceManager.GetService<IFieldTreeService>(ViewServiceKeys.FIELD_TREE_SERVICE);
if (service == null)
return;
this.IsLoading = true;
ThreadHelper.SafeRun(action: () =>
{
// 重新加载版子
this.vizCommandService.Reload(ApplicationDomainEx.PreviewConn, this.SelectedSceneTemplateModel.ScenePath);
// 获取控制对象
ControlObjectModel controlObject = this.vizCommandControlObjectService.GetControlObject(ApplicationDomainEx.PreviewConn);
// 将控制字段写入数据库
this.controlObjectService.SaveControlFields(this.SelectedSceneTemplateModel, controlObject.AllFiledNodes); ;
// 如果当前打开的项目是该模板,那么从新打开
if (ApplicationDomainEx.CurrentPage == this.SelectedSceneTemplateModel)
{
WPFHelper.Invoke(() =>
{
this.OpenScenePage();
});
}
},
final: () =>
{
WPFHelper.BeginInvoke(() =>
{
this.IsLoading = false;
});
});
}
#endregion
#region DeleteCommand -- 删除命令
/// <summary>
/// 删除命令
/// </summary>
public VCommand DeleteCommand { get; set; }
/// <summary>
/// 删除
/// </summary>
private void Delete()
{
if (this.SelectedSceneTemplateModel == null)
return;
if (DXMessageBox.Show($"是否删除模板【{this.SelectedSceneTemplateModel.Scene}】?", "提示", System.Windows.MessageBoxButton.YesNo) != System.Windows.MessageBoxResult.Yes)
return;
this.SceneTemplateModels.Remove(this.SelectedSceneTemplateModel);
}
#endregion
// ====================================================================================== // ======================================================================================
// Message // Message
// ====================================================================================== // ======================================================================================
......
...@@ -18,11 +18,6 @@ namespace VIZ.Package.Module ...@@ -18,11 +18,6 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(MediaResourceFileController)); private static readonly ILog log = LogManager.GetLogger(typeof(MediaResourceFileController));
public static AppSettingsSection config = ApplicationDomainEx.MediaConfig.configuration.AppSettings;
private static string httpUrl = config.Settings["url"].Value.ToString();
/// <summary> /// <summary>
/// VIZ资源缩略图控制器 /// VIZ资源缩略图控制器
/// </summary> /// </summary>
...@@ -66,7 +61,7 @@ namespace VIZ.Package.Module ...@@ -66,7 +61,7 @@ namespace VIZ.Package.Module
WPFHelper.BeginInvoke(async () => WPFHelper.BeginInvoke(async () =>
{ {
string header = string.Format("{0}GetListFile?filePath={1}", httpUrl, folder.Path); string header = string.Format("{0}GetListFile?filePath={1}", ApplicationDomainEx.MediaConfig.Url, folder.Path);
var FileResult = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, ""); var FileResult = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, "");
List<MHResourceFileModel> list = new List<MHResourceFileModel>(); List<MHResourceFileModel> list = new List<MHResourceFileModel>();
...@@ -81,7 +76,7 @@ namespace VIZ.Package.Module ...@@ -81,7 +76,7 @@ namespace VIZ.Package.Module
{ {
GHFile.Name = file.fileName; GHFile.Name = file.fileName;
GHFile.Path = file.smallIconUrl; GHFile.Path = file.smallIconUrl;
string url = string.Format("{0}GetFile?filePath={1}", httpUrl, GHFile.Path); string url = string.Format("{0}GetFile?filePath={1}", ApplicationDomainEx.MediaConfig.Url, GHFile.Path);
var fileResult = await MediaResourceFileService.GetImage(url); var fileResult = await MediaResourceFileService.GetImage(url);
GHFile.FileType = ResourceFileType.IMAGE; GHFile.FileType = ResourceFileType.IMAGE;
...@@ -126,7 +121,7 @@ namespace VIZ.Package.Module ...@@ -126,7 +121,7 @@ namespace VIZ.Package.Module
/// <param name="newPath"></param> /// <param name="newPath"></param>
public async Task<fileListResult> MoveFile(string oldPath, string newPath) public async Task<fileListResult> MoveFile(string oldPath, string newPath)
{ {
string header = string.Format("{0}MoveFile?oldFile={1}&newFile={2}", httpUrl, oldPath, newPath); string header = string.Format("{0}MoveFile?oldFile={1}&newFile={2}", ApplicationDomainEx.MediaConfig.Url, oldPath, newPath);
var result = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, ""); var result = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, "");
return result; return result;
} }
...@@ -137,7 +132,7 @@ namespace VIZ.Package.Module ...@@ -137,7 +132,7 @@ namespace VIZ.Package.Module
/// <param name="path"></param> /// <param name="path"></param>
public async Task<fileListResult> CreateFolder(string path) public async Task<fileListResult> CreateFolder(string path)
{ {
string header = string.Format("{0}CreateFiles?filePath={1}", httpUrl, path); string header = string.Format("{0}CreateFiles?filePath={1}", ApplicationDomainEx.MediaConfig.Url, path);
var result = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, ""); var result = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, "");
return result; return result;
} }
...@@ -149,7 +144,7 @@ namespace VIZ.Package.Module ...@@ -149,7 +144,7 @@ namespace VIZ.Package.Module
/// <param name="path"></param> /// <param name="path"></param>
public async Task<fileListResult> DeleteFolder(string path) public async Task<fileListResult> DeleteFolder(string path)
{ {
string header = string.Format("{0}DeleteFiles?filePath={1}", httpUrl, path); string header = string.Format("{0}DeleteFiles?filePath={1}", ApplicationDomainEx.MediaConfig.Url, path);
var result = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, ""); var result = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, "");
return result; return result;
} }
...@@ -162,7 +157,7 @@ namespace VIZ.Package.Module ...@@ -162,7 +157,7 @@ namespace VIZ.Package.Module
/// <returns></returns> /// <returns></returns>
public async Task<fileUploadResult> CreateFile(string filePath, string fileName) public async Task<fileUploadResult> CreateFile(string filePath, string fileName)
{ {
string requestUri = string.Format("{0}UplodFile?filePath={1}", httpUrl, this.Support.SelectedFolderModel.Path + "\\"); string requestUri = string.Format("{0}UplodFile?filePath={1}", ApplicationDomainEx.MediaConfig.Url, this.Support.SelectedFolderModel.Path + "\\");
fileUploadResult upLoadResult = await MediaResourceFileService.PostImage<fileUploadResult>(requestUri, filePath, fileName); fileUploadResult upLoadResult = await MediaResourceFileService.PostImage<fileUploadResult>(requestUri, filePath, fileName);
...@@ -181,7 +176,7 @@ namespace VIZ.Package.Module ...@@ -181,7 +176,7 @@ namespace VIZ.Package.Module
{ {
try try
{ {
string header = string.Format("{0}DeleteFile?filePath={1}", httpUrl, path); string header = string.Format("{0}DeleteFile?filePath={1}", ApplicationDomainEx.MediaConfig.Url, path);
var result = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, ""); var result = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(header, "");
return result; return result;
} }
...@@ -204,7 +199,7 @@ namespace VIZ.Package.Module ...@@ -204,7 +199,7 @@ namespace VIZ.Package.Module
{ {
// var config = // var config =
var folderResult = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(string.Format("{0}GetListFiles", httpUrl), ""); var folderResult = await MediaResourceFileService.PostObjectAsync<fileListResult, string>(string.Format("{0}GetListFiles", ApplicationDomainEx.MediaConfig.Url), "");
if (folderResult == null) if (folderResult == null)
return null; return null;
RootPath = folderResult.rootPath; RootPath = folderResult.rootPath;
......
...@@ -434,19 +434,6 @@ namespace VIZ.Package.Module ...@@ -434,19 +434,6 @@ namespace VIZ.Package.Module
public VCommand CreateFileCommand { get; set; } public VCommand CreateFileCommand { get; set; }
/// <summary>
/// 从配置文件读取
/// </summary>
public static AppSettingsSection config = ApplicationDomainEx.MediaConfig.configuration.AppSettings;
/// <summary>
/// 从配置文件读取过滤字符串
/// </summary>
private static string filter = config.Settings["MediaFilter"].Value.ToString();
/// <summary> /// <summary>
/// 创建文件方法 /// 创建文件方法
/// </summary> /// </summary>
...@@ -455,7 +442,7 @@ namespace VIZ.Package.Module ...@@ -455,7 +442,7 @@ namespace VIZ.Package.Module
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
ofd.Filter = filter; ofd.Filter = ApplicationDomainEx.MediaConfig.MediaFilter;
ofd.Multiselect = false; ofd.Multiselect = false;
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{ {
......
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 MediaSettingPluginLifeCycle : IPluginLifeCycle
{
/// <summary>
/// 插件ID
/// </summary>
/// <remarks>
/// 插件ID不能包含点号
/// </remarks>
public const string PLUGIN_ID = ModulePluginIds.MEDIA_CONFIG_SETTING;
/// <summary>
/// 插件名称
/// </summary>
public const string PLUGIN_NAME = "媒资库配置";
/// <summary>
/// 注册
/// </summary>
/// <returns>插件信息</returns>
public PluginInfo Register()
{
PluginInfo info = new PluginInfo();
info.ID = PLUGIN_ID;
info.Name = PLUGIN_NAME;
info.SettingViewType = typeof(MediaSettingView);
return info;
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
}
}
}
<UserControl x:Class="VIZ.Package.Module.MediaSettingView"
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:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:MediaSettingViewModel}"
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>
<Grid>
<!-- 媒资库设置 -->
<GroupBox Header="媒资库设置" Margin="10" Padding="10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<!-- 地址 -->
<TextBlock Text="地址:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Column="1" Height="30"
EditValue="{Binding Path=Url,Mode=TwoWay}"></dxe:TextEdit>
<!-- 媒资筛选 -->
<TextBlock Text="媒资筛选:" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Row="1" Grid.Column="1" Height="30"
EditValue="{Binding Path=MediaFilter,Mode=TwoWay}"></dxe:TextEdit>
</Grid>
</GroupBox>
</Grid>
</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>
/// MediaSettingView.xaml 的交互逻辑
/// </summary>
public partial class MediaSettingView : UserControl, IPluginSettingView
{
public MediaSettingView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new MediaSettingViewModel());
}
/// <summary>
/// 保存
/// </summary>
public void Save()
{
MediaSettingViewModel vm = this.DataContext as MediaSettingViewModel;
vm.Save();
}
}
}
using log4net;
using System;
using System.Collections.Generic;
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 MediaSettingViewModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(MediaSettingViewModel));
/// <summary>
/// 媒资库配置设置视图模型
/// </summary>
public MediaSettingViewModel()
{
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.LoadedCommand = new VCommand(this.Loaded);
}
// =========================================================================
// Property
// =========================================================================
#region Url -- 地址
private string url;
/// <summary>
/// 地址
/// </summary>
public string Url
{
get { return url; }
set { url = value; this.RaisePropertyChanged(nameof(Url)); }
}
#endregion
#region MediaFilter -- 媒资筛选
private string mediaFilter;
/// <summary>
/// 媒资筛选
/// </summary>
public string MediaFilter
{
get { return mediaFilter; }
set { mediaFilter = value; this.RaisePropertyChanged(nameof(MediaFilter)); }
}
#endregion
// =========================================================================
// Command
// =========================================================================
#region LoadedCommand -- 加载命令
/// <summary>
/// 加载命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载
/// </summary>
private void Loaded()
{
MediaConfigEntity config = ApplicationDomainEx.MediaConfig;
this.Url = config.Url;
this.MediaFilter = config.MediaFilter;
}
#endregion
// =========================================================================
// Public Function
// =========================================================================
/// <summary>
/// 保存
/// </summary>
public void Save()
{
MediaConfigEntity config = ApplicationDomainEx.MediaConfig;
config.Url = this.Url;
config.MediaFilter = this.MediaFilter;
ApplicationDomainEx.LocalDbContext.MediaConfig.Update(config);
}
}
}
\ No newline at end of file
...@@ -216,7 +216,7 @@ namespace VIZ.Package.Module ...@@ -216,7 +216,7 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
private void Loaded() private void Loaded()
{ {
VizConfigEntity config = ApplicationDomainEx.LocalDbContext.VizConfig.FindAll().FirstOrDefault(); VizConfigEntity config = ApplicationDomainEx.VizConfig;
this.GH_IP = config.GH_IP; this.GH_IP = config.GH_IP;
this.GH_Port = config.GH_Port; this.GH_Port = config.GH_Port;
...@@ -291,7 +291,7 @@ namespace VIZ.Package.Module ...@@ -291,7 +291,7 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
public void Save() public void Save()
{ {
VizConfigEntity config = ApplicationDomainEx.LocalDbContext.VizConfig.FindAll().FirstOrDefault(); VizConfigEntity config = ApplicationDomainEx.VizConfig;
config.GH_IP = this.GH_IP; config.GH_IP = this.GH_IP;
config.GH_Port = this.GH_Port; config.GH_Port = this.GH_Port;
......
...@@ -11,7 +11,7 @@ namespace VIZ.Package.Module ...@@ -11,7 +11,7 @@ namespace VIZ.Package.Module
/// <summary> /// <summary>
/// Viz配置插件生命周期 /// Viz配置插件生命周期
/// </summary> /// </summary>
public class VizConfigPluginLifeCycle : IPluginLifeCycle public class VizConfigSettingPluginLifeCycle : IPluginLifeCycle
{ {
/// <summary> /// <summary>
/// 插件ID /// 插件ID
......
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Module;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
/// <summary>
/// 媒体库配置文件
/// </summary>
public class AppSetup_InitMedia : AppSetupBase
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(AppSetup_InitMedia));
public override string Detail { get; } = "应用程序启动 -- 初始化媒体资源库";
public override bool Setup(AppSetupContext context)
{
ApplicationDomainEx.MediaConfig = new Storage.ConfigContext();
this.LoadConfig();
return true;
}
/// <summary>
/// 加载插件配置
/// </summary>
private void LoadConfig()
{
string folder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config");
if (!System.IO.Directory.Exists(folder))
{
System.IO.Directory.CreateDirectory(folder);
}
string path = System.IO.Path.Combine(folder, "MediaResouce.config");
ApplicationDomainEx.MediaConfig.LoadMediaConfig(path);
}
public override void Shutdown(AppSetupContext context)
{
}
}
}
...@@ -292,7 +292,12 @@ ...@@ -292,7 +292,12 @@
<Compile Include="Setting\Core\View\SettingWindow.xaml.cs"> <Compile Include="Setting\Core\View\SettingWindow.xaml.cs">
<DependentUpon>SettingWindow.xaml</DependentUpon> <DependentUpon>SettingWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Setting\VizConfig\VizConfigPluginLifeCycle.cs" /> <Compile Include="Setting\Media\ViewModel\MediaSettingViewModel.cs" />
<Compile Include="Setting\Media\View\MediaSettingView.xaml.cs">
<DependentUpon>MediaSettingView.xaml</DependentUpon>
</Compile>
<Compile Include="Setting\Media\MediaSettingPluginLifeCycle.cs" />
<Compile Include="Setting\VizConfig\VizConfigSettingPluginLifeCycle.cs" />
<Compile Include="Setting\VizConfig\ViewModel\VizConfigSettingViewModel.cs" /> <Compile Include="Setting\VizConfig\ViewModel\VizConfigSettingViewModel.cs" />
<Compile Include="Setup\AppSetup_InitLiteDB.cs" /> <Compile Include="Setup\AppSetup_InitLiteDB.cs" />
<Compile Include="Preview\VizPreview\Controller\VizPreviewController.cs" /> <Compile Include="Preview\VizPreview\Controller\VizPreviewController.cs" />
...@@ -307,7 +312,6 @@ ...@@ -307,7 +312,6 @@
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\TextListCellEdit.xaml.cs"> <Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\TextListCellEdit.xaml.cs">
<DependentUpon>TextListCellEdit.xaml</DependentUpon> <DependentUpon>TextListCellEdit.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Setup\AppSetup_InitMedia.cs" />
<Compile Include="Setting\VizConfig\View\VizConfigSettingView.xaml.cs"> <Compile Include="Setting\VizConfig\View\VizConfigSettingView.xaml.cs">
<DependentUpon>VizConfigSettingView.xaml</DependentUpon> <DependentUpon>VizConfigSettingView.xaml</DependentUpon>
</Compile> </Compile>
...@@ -490,6 +494,10 @@ ...@@ -490,6 +494,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Setting\Media\View\MediaSettingView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Generic.xaml"> <Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
......
...@@ -29,6 +29,16 @@ namespace VIZ.Package.Service ...@@ -29,6 +29,16 @@ namespace VIZ.Package.Service
} }
/// <summary> /// <summary>
/// 重新加载场景
/// </summary>
/// <param name="conn">连接</param>
/// <param name="scene">场景</param>
public void Reload(ConnModel conn, string scene)
{
conn.EndpointManager.Send($"SCENE**{scene} RELOAD");
}
/// <summary>
/// 播放 /// 播放
/// </summary> /// </summary>
/// <param name="conn">连接</param> /// <param name="conn">连接</param>
...@@ -248,7 +258,7 @@ namespace VIZ.Package.Service ...@@ -248,7 +258,7 @@ namespace VIZ.Package.Service
/// <summary> /// <summary>
/// 下版子 /// 下版子
/// </summary> /// </summary>
/// <param name="connection">连接</param> /// <param name="conn">连接</param>
/// <param name="layer">层</param>s /// <param name="layer">层</param>s
public void TakeOut(ConnModel conn, VizLayer layer) public void TakeOut(ConnModel conn, VizLayer layer)
{ {
......
using log4net;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Storage
{
/// <summary>
/// 媒体库配置文件
/// </summary>
public class ConfigContext
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(ConfigContext));
public Configuration configuration { get; set; }
/// <summary>
/// 加载插件配置
/// </summary>
/// <param name="path">文件路径</param>
public void LoadMediaConfig(string path)
{
if (File.Exists(path) == false)
{
{
string msg = string.Format("{0}路径下的文件未找到 ", path);
throw new FileNotFoundException(msg);
}
}
try
{
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap();
configFile.ExeConfigFilename = path;
configuration = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}
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 MediaConfigEntity
{
/// <summary>
/// 编号
/// </summary>
[BsonId(true)]
public int Id { get; set; }
/// <summary>
/// 地址
/// </summary>
public string Url { get; set; } = "http://localhost:9000/api/home/";
/// <summary>
/// 媒体筛选
/// </summary>
public string MediaFilter { get; set; } = "(*.jpg,*.png,*.jpeg,*.bmp,*.gif,*.avi,*.mp4)|*.jgp;*.png;*.jpeg;*.bmp;*.gif;*.avi;*.mp4";
}
}
...@@ -34,6 +34,7 @@ namespace VIZ.Package.Storage ...@@ -34,6 +34,7 @@ namespace VIZ.Package.Storage
this.Database = new LiteDatabase(path); this.Database = new LiteDatabase(path);
this.VizConfig = this.Database.GetCollection<VizConfigEntity>(); this.VizConfig = this.Database.GetCollection<VizConfigEntity>();
this.MediaConfig = this.Database.GetCollection<MediaConfigEntity>();
this.ConnGroup = this.Database.GetCollection<ConnGroupEntity>(); this.ConnGroup = this.Database.GetCollection<ConnGroupEntity>();
this.Conn = this.Database.GetCollection<ConnEntity>(); this.Conn = this.Database.GetCollection<ConnEntity>();
} }
...@@ -49,6 +50,11 @@ namespace VIZ.Package.Storage ...@@ -49,6 +50,11 @@ namespace VIZ.Package.Storage
public ILiteCollection<VizConfigEntity> VizConfig { get; private set; } public ILiteCollection<VizConfigEntity> VizConfig { get; private set; }
/// <summary> /// <summary>
/// 媒资库配置
/// </summary>
public ILiteCollection<MediaConfigEntity> MediaConfig { get; private set; }
/// <summary>
/// 连接分组 /// 连接分组
/// </summary> /// </summary>
public ILiteCollection<ConnGroupEntity> ConnGroup { get; private set; } public ILiteCollection<ConnGroupEntity> ConnGroup { get; private set; }
...@@ -64,6 +70,7 @@ namespace VIZ.Package.Storage ...@@ -64,6 +70,7 @@ namespace VIZ.Package.Storage
public void Dispose() public void Dispose()
{ {
this.VizConfig = null; this.VizConfig = null;
this.MediaConfig = null;
this.ConnGroup = null; this.ConnGroup = null;
this.Conn = null; this.Conn = null;
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Entity\Config\ConfigContext.cs" /> <Compile Include="Entity\Config\MediaConfigEntity.cs" />
<Compile Include="Entity\Conn\ConnEntity.cs" /> <Compile Include="Entity\Conn\ConnEntity.cs" />
<Compile Include="Entity\Conn\ConnGroupEntity.cs" /> <Compile Include="Entity\Conn\ConnGroupEntity.cs" />
<Compile Include="Entity\ControlObject\ControlFieldEntity.cs" /> <Compile Include="Entity\ControlObject\ControlFieldEntity.cs" />
......
...@@ -20,15 +20,12 @@ namespace VIZ.Package ...@@ -20,15 +20,12 @@ namespace VIZ.Package
{ {
public App() public App()
{ {
// 设置DevExpress主 // 设置DevExpress主
ApplicationThemeHelper.ApplicationThemeName = Theme.VS2019DarkName; ApplicationThemeHelper.ApplicationThemeName = Theme.VS2019DarkName;
// 初始化LiteDB // 初始化LiteDB
AppSetup.AppendSetup(new AppSetup_InitLiteDB()); AppSetup.AppendSetup(new AppSetup_InitLiteDB());
//初始化媒体资源配置文件
AppSetup.AppendSetup(new AppSetup_InitMedia());
// 执行启动流程 // 执行启动流程
AppSetupContext context = AppSetup.Setup(); AppSetupContext context = AppSetup.Setup();
......
...@@ -130,9 +130,6 @@ ...@@ -130,9 +130,6 @@
<None Include="config\log.config"> <None Include="config\log.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="config\MediaResouce.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
......
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="url" value="http://localhost:9000/api/home/"/>
<add key="MediaFilter" value="(*.jpg,*.png,*.jpeg,*.bmp,*.gif,*.avi,*.mp4)|*.jgp;*.png;*.jpeg;*.bmp;*.gif;*.avi;*.mp4"/>
</appSettings>
</configuration>
\ No newline at end of file
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