Commit 864b6cfb by liulongfei

自定义视频控制字段支持

parent 307c207d
<UserControl x:Class="VIZ.Package.Module.CustomVideoEditPanel"
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: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"
d:Background="White"
d:DataContext="{d:DesignInstance Type=local:CustomVideoEditPanelModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="值:" Margin="0,0,10,0" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<dxe:TextEdit Grid.Column="1" Height="30" EditValue="{Binding Path=Path}" IsReadOnly="True"></dxe:TextEdit>
<Button Grid.Column="2" Width="80" Height="30" Content="本地文件" Command="{Binding OpenLocalFileCommand}"></Button>
</Grid>
<dx:DXTabControl Grid.Row="1">
<dx:DXTabItem Header="媒资库">
<!-- 媒体资源面板 -->
<local:MediaResourcePanel x:Name="mhResourcePanel">
<local:MediaResourcePanel.FolderContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFolderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</local:MediaResourcePanel.FolderContextMenu>
<local:MediaResourcePanel.FileContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</local:MediaResourcePanel.FileContextMenu>
</local:MediaResourcePanel>
</dx:DXTabItem>
</dx:DXTabControl>
</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;
namespace VIZ.Package.Module
{
/// <summary>
/// CustomVideoEditPanel.xaml 的交互逻辑
/// </summary>
public partial class CustomVideoEditPanel : UserControl
{
public CustomVideoEditPanel()
{
InitializeComponent();
CustomVideoEditPanelModel vm = new CustomVideoEditPanelModel();
WPFHelper.BindingViewModel(this.mhResourcePanel, vm.MHResourceEditPartModel);
WPFHelper.BindingViewModel(this, vm);
}
}
}
using System;
using System.Collections.Generic;
using System.Dynamic;
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 CustomVideoEditPanelModel : ResourceEditPanelModelBase
{
public CustomVideoEditPanelModel()
{
this.GHResourceEditPartModel.FilterResourceFileType = ResourceFileType.NONE;
this.MHResourceEditPartModel.FilterResourceFileType = ResourceFileType.IMAGE;
this.MHResourceEditPartModel.OnFileDoubleClick += MHResourceEditPartModel_OnFileDoubleClick;
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.OpenLocalFileCommand = new VCommand(this.OpenLocalFile);
}
// =====================================================================
// Field
// =====================================================================
/// <summary>
/// Viz资源视频筛选器
/// </summary>
private string VIZ_VIDEO_FILTER = ApplicationDomainEx.IniStorage.GetValue<VizConfig, string>(p => p.VIZ_VIDEO_FILTER);
// =====================================================================
// Property
// =====================================================================
#region Path -- 路径
private string path;
/// <summary>
/// 路径
/// </summary>
public string Path
{
get { return path; }
set
{
path = value;
this.RaisePropertyChanged(nameof(Path));
this.OnPathChanged();
}
}
#endregion
// =====================================================================
// Command
// =====================================================================
#region OpenLocalFileCommand -- 打开本地文件命令
/// <summary>
/// 打开本地文件命令
/// </summary>
public VCommand OpenLocalFileCommand { get; set; }
/// <summary>
/// 打开本地文件
/// </summary>
private void OpenLocalFile()
{
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
ofd.Filter = VIZ_VIDEO_FILTER;
ofd.Multiselect = false;
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
this.IsSendToPreview = false;
this.GHResourceEditPartModel.SelectedFileModel = null;
this.IsSendToPreview = true;
this.Path = ofd.FileName;
}
#endregion
// =====================================================================
// Public Function
// =====================================================================
/// <summary>
/// 更新
/// </summary>
/// <param name="controlObject">控制对象</param>
/// <param name="controlField">控制字段</param>
public override void Update(ControlObjectModel controlObject, ControlFieldNodeModel controlField)
{
base.Update(controlObject, controlField);
this.IsSendToPreview = false;
this.Path = controlField?.Value;
this.IsSendToPreview = true;
}
/// <summary>
/// 更新动态数据
/// </summary>
/// <param name="listCellEdit">列单元格编辑器</param>
/// <param name="columnDefinition">列定义</param>
/// <param name="rowHandle">行号</param>
/// <param name="row">行数据</param>
public override void UpdateDynamic(ListCellEditBase listCellEdit, GridColumnControlFieldDefinition columnDefinition, int rowHandle, ExpandoObject row)
{
base.UpdateDynamic(listCellEdit, columnDefinition, rowHandle, row);
IDictionary<string, object> dic = row as IDictionary<string, object>;
this.IsSendToPreview = false;
this.Path = dic?[columnDefinition.FieldName]?.ToString();
this.IsSendToPreview = true;
}
/// <summary>
/// 获取字段值
/// </summary>
/// <returns>字段值</returns>
public override string GetFieldValue()
{
return this.Path;
}
// =====================================================================
// Private Function
// =====================================================================
/// <summary>
/// 路径切换时触发
/// </summary>
private void OnPathChanged()
{
// 不需要向预览发送值
if (!this.IsSendToPreview)
return;
// 没有预览连接
if (ApplicationDomainEx.PreviewConn == null)
return;
// 没有控制对象或控制字段
if (this.ControlObject == null || this.ControlField == null)
return;
if (this.FieldEditMode == FieldEditMode.Normal)
{
this.ControlField.Value = this.Path;
if (!this.ControlField.IsCustom)
{
this.VizCommandControlObjectService.SetControlObjectValue(
ApplicationDomainEx.PreviewConn,
this.ControlObject.TreeNodePath,
this.ControlField.FieldIdentifier,
this.ControlField.Value);
}
else
{
this.VizCommandControlObjectService.SetCustomControlFieldValue(ApplicationDomainEx.PreviewConn, new List<ControlFieldNodeModel> { this.ControlField });
}
return;
}
// 没有列信息或行数据
if (this.ColumnDefinition == null || this.Row == null)
return;
// 动态模式编辑
if (this.FieldEditMode == FieldEditMode.Dynamic)
{
IDictionary<string, object> dic = this.Row as IDictionary<string, object>;
dic[this.ColumnDefinition.FieldName] = this.Path;
this.ListCellEdit.UpdateEditValue(this.ColumnDefinition, this.RowHandle, this.Row);
return;
}
}
/// <summary>
/// GH库双击文件时触发
/// </summary>
private void GHResourceEditPartModel_OnFileDoubleClick(object sender, GHResourceFileDoubleClickEventArgs e)
{
if (e.File == null)
return;
this.Path = e.File?.ResourcePath;
}
/// <summary>
/// 媒体库点击文件时触发
/// </summary>
private void MHResourceEditPartModel_OnFileDoubleClick(object sender, MHResourceFileDoubleClickEventArgs e)
{
if (e.File == null)
return;
this.Path = e.File?.Path;
}
}
}
......@@ -110,6 +110,14 @@ namespace VIZ.Package.Module
ViewType = typeof(FontEditPanel),
ViewCreated = this.OnViewCreated
});
// 自定义视频
this.NavigationConfigs.Add(new NavigationConfig
{
Key = VizControlFieldType.custom_video.ToString(),
ViewType = typeof(CustomVideoEditPanel),
ViewCreated = this.OnViewCreated
});
}
// =============================================================
......
......@@ -90,6 +90,10 @@
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="ControlObject\FieldEdit\Edit\CustomVideoEdit\CustomVideoEditPanel.xaml.cs">
<DependentUpon>CustomVideoEditPanel.xaml</DependentUpon>
</Compile>
<Compile Include="ControlObject\FieldEdit\Edit\CustomVideoEdit\CustomVideoEditPanelModel.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\FloatEdit\FloatEditPanel.xaml.cs">
<DependentUpon>FloatEditPanel.xaml</DependentUpon>
</Compile>
......@@ -390,11 +394,14 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="ControlObject\FieldEdit\Edit\CustomVideoEdit\" />
<Folder Include="Main\Controller\" />
<Folder Include="ProjectManager\Model\" />
</ItemGroup>
<ItemGroup>
<Page Include="ControlObject\FieldEdit\Edit\CustomVideoEdit\CustomVideoEditPanel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ControlObject\FieldEdit\Edit\FloatEdit\FloatEditPanel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
......@@ -19,6 +19,12 @@ namespace VIZ.Package.Storage
public string VIZ_IMAGE_FILTER { get; set; }
/// <summary>
/// Viz资源视频筛选器
/// </summary>
[Ini(Section = "Viz", DefaultValue = "视频|*.mp4;*.wav;", Type = typeof(string))]
public string VIZ_VIDEO_FILTER { get; set; }
/// <summary>
/// Viz预览重启等待时间(单位:毫秒)
/// </summary>
[Ini(Section = "Viz", DefaultValue = "3000", Type = typeof(int))]
......
......@@ -4,6 +4,8 @@ APPLICATION_IS_DEBUG=false
[Viz]
; Viz图片筛选器
VIZ_IMAGE_FILTER=图片|*.jpg;*.jpeg;*.bmp;*.png;
; Viz资源视频筛选器
VIZ_VIDEO_FILTER=视频|*.mp4;*.wav;
; Viz预览重启等待时间(单位:毫秒)
VIZ_PREVIEW_RESTART_WAIT=3000
; Viz预览编辑器类型: duplet、triplet 数据隐藏过滤器, 使用 "|" 分隔
......
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