Commit fae98791 by wangonghui

本地资源功能开发

parent f5e73f3a
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Domain.Model.Resource.LF
namespace VIZ.TVP.Domain
{
public class LFResourceFileModel: ResourceFileModelBase
public class LFResourceFileModel : ResourceFileModelBase, IResourceDrag, IDisposable
{
/// <summary>
/// GH 节点
/// </summary>
public GH_Entry_Node EntryNode { get; set; }
#region FloderModel -- 所属文件夹模型
private LFResourceFolderModel floderModel;
/// <summary>
/// 所属文件夹模型
/// </summary>
public LFResourceFolderModel FloderModel
{
get { return floderModel; }
set { floderModel = value; this.RaisePropertyChanged(nameof(FloderModel)); }
}
#endregion
#region Src --
private string src;
/// <summary>
/// 源
/// </summary>
public string Src
{
get { return src; }
set { src = value; this.RaisePropertyChanged(nameof(Src)); }
}
#endregion
#region Thumbnail -- 缩略图
private string thumbnail;
/// <summary>
/// 缩略图
/// </summary>
public string Thumbnail
{
get { return thumbnail; }
set { thumbnail = value; this.RaisePropertyChanged(nameof(Thumbnail)); }
}
#endregion
#region MimeType -- 文件格式
private string mimeType;
/// <summary>
/// 文件格式
/// </summary>
public string MimeType
{
get { return mimeType; }
set { mimeType = value; this.RaisePropertyChanged(nameof(MimeType)); }
}
#endregion
#region Path -- 路径
private string path;
/// <summary>
/// 路径
/// </summary>
public string Path
{
get { return path; }
set { path = value; this.RaisePropertyChanged(nameof(Path)); }
}
#endregion
#region ResourcePath -- 资源路径
/// <summary>
/// 资源路径
/// </summary>
public string ResourcePath
{
get { return $"{this.FileType}*{this.Path}"; }
}
#endregion
// ---------------------------------------------------------------------
// 扩展属性
#region ThumbnailBitmap -- 缩略图图片
private Bitmap thumbnailBitmap;
/// <summary>
/// 缩略图图片
/// </summary>
public Bitmap ThumbnailBitmap
{
get { return thumbnailBitmap; }
set { thumbnailBitmap = value; this.RaisePropertyChanged(nameof(ThumbnailBitmap)); }
}
#endregion
// ---------------------------------------------------------------------
// 方法
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
this.ThumbnailBitmap?.Dispose();
this.ThumbnailBitmap = null;
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Domain.Model.Resource.LF
namespace VIZ.TVP.Domain
{
public class LFResourceFolderModel: ResourceFolderModelBase
{
/// <summary>
/// GH 节点
/// </summary>
public GH_Entry_Node EntryNode { get; set; }
#region Path -- 路径
private string path;
/// <summary>
/// 路径
/// </summary>
public string Path
{
get { return path; }
set { path = value; this.RaisePropertyChanged(nameof(Path)); }
}
#endregion
#region Files -- 文件集合
private ObservableCollection<LFResourceFileModel> files;
/// <summary>
/// 文件集合
/// </summary>
public ObservableCollection<LFResourceFileModel> Files
{
get { return files; }
set { files = value; this.RaisePropertyChanged(nameof(Files)); }
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Domain;
namespace VIZ.TVP.Module
{
public interface ILocalResourceFileSupport
{
/// <summary>
/// 文件夹目录集合
/// </summary>
ObservableCollection<GHResourceFolderModel> FolderModels { get; set; }
/// <summary>
/// 当前选中的文件夹
/// </summary>
GHResourceFolderModel SelectedFolderModel { get; set; }
/// <summary>
/// 文件集合
/// </summary>
ObservableCollection<GHResourceFileModel> FileModels { get; set; }
/// <summary>
/// 选中的文件模型
/// </summary>
GHResourceFileModel SelectedFileModel { get; set; }
/// <summary>
/// 是否正在加载文件
/// </summary>
bool IsFileLoading { get; set; }
}
}
using DevExpress.Printing.Core.PdfExport.Metafile;
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using VIZ.Framework.Core;
using VIZ.TVP.Domain;
namespace VIZ.TVP.Module
{
public class LocalResourceFileController
{
/// <summary>
/// 日志
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(VizResourceFileController));
/// <summary>
/// VIZ资源缩略图控制器
/// </summary>
/// <param name="support">支持</param>
public LocalResourceFileController(ILocalResourceFileSupport support)
{
this.Support = support;
}
/// <summary>
/// 支持
/// </summary>
public ILocalResourceFileSupport Support { get; private set; }
/// <summary>
/// 更新文件模型
/// </summary>
/// <param name="folder">文件夹</param>
public void UpdateFileModels(GHResourceFolderModel folder)
{
//FolderModels = new ObservableCollection<LFResourceFolderModel>();
//FolderModels = tempfolderModel;
//SelectedFolderModel = tempSelecFolder;
if (folder == null) return;
ObservableCollection<GHResourceFileModel> ImgeFile = new ObservableCollection<GHResourceFileModel>();
//Task.Run(() =>
//{
if (folder.Files != null)
{
foreach (var fileModel in folder.Files)
{
if (IsImage(fileModel.Path))
{
// D:\世界杯单独项目\竖屏世界杯包装效果\VAR团队名单.jpg
WPFHelper.BeginInvoke(() =>
{
Image image = ThumbnailHelper.GetImage(fileModel.Path, 100, 200);
Bitmap btm = new Bitmap(image);
fileModel.ThumbnailBitmap = btm;
fileModel.FileType = ResourceFileType.IMAGE;
ImgeFile.Add(fileModel);
});
}
else if (IsVideo(fileModel.Path))
{
string strVedioPath = string.Format("{0}{1}", System.Environment.CurrentDirectory, "\\VedioImage\\Vedio.jpeg");
Image vedioImage = Image.FromFile(strVedioPath);
Bitmap vedioBtm = new Bitmap(vedioImage);
fileModel.ThumbnailBitmap = vedioBtm;
fileModel.FileType = ResourceFileType.Video;
ImgeFile.Add(fileModel);
}
}
this.Support.FileModels = ImgeFile;
}
//});
}
#region ---图片文件检测
private Boolean IsImage(string path)
{
try
{
if (IsImageByName(path))
{
System.Drawing.Image img = System.Drawing.Image.FromFile(path);
return true;
}
return false;
}
catch (Exception e)
{
return false;
}
}
private Boolean IsImageByName(string name)
{
int pos = name.LastIndexOf(".");
if (name.Length - pos - 1 < 3)
return false;
string ext = name.Substring(pos + 1, name.Length - pos - 1);
string[] imge = { "jpg", "jpeg", "png", "gif", "bmp", "TIFF", "tif" };
return IsInIgnoreCase(ext, imge);
}
private bool IsInIgnoreCase(string source, params string[] list)
{
if (null == source) return false;
IEnumerable<string> en = list.Where(i => string.Compare(i, source, StringComparison.OrdinalIgnoreCase) == 0);
return en.Count() == 0 ? false : true;
}
/// <summary>
/// 读取图片文件
/// </summary>
/// <param name="path">图片文件路径</param>
/// <returns>图片文件</returns>
private Bitmap ReadImageFile(String path)
{
Bitmap bitmap = null;
try
{
FileStream fileStream = File.OpenRead(path);
Int32 filelength = 0;
filelength = (int)fileStream.Length;
Byte[] image = new Byte[filelength];
fileStream.Read(image, 0, filelength);
System.Drawing.Image result = System.Drawing.Image.FromStream(fileStream);
fileStream.Close();
bitmap = new Bitmap(result);
}
catch (Exception ex)
{
// 异常输出
}
return bitmap;
}
private bool IsVideo(string filePath)
{
bool isVideo = false;
string fileName = filePath;
IList<string> formateList = new List<string> {
"avi","flv","mpg","mpeg","mpe","m1v","m2v","mpv2","mp2v","dat","ts","tp","tpr","pva","pss","mp4","m4v",
"m4p","m4b","3gp","3gpp","3g2","3gp2","ogg","mov","qt","amr","rm","ram","rmvb","rpm"};
string[] Namesuffix = fileName.Split('.');
if(Namesuffix.Length>1)
{
if (formateList.Contains(Namesuffix[1]))
{
isVideo = true;
}
}
return isVideo;
}
#endregion
/// <summary>
/// 销毁文件模型
/// </summary>
public void DisposeFileModels(GHResourceFolderModel folder)
{
if (folder == null || folder.Files == null || folder.Files.Count == 0)
return;
foreach (GHResourceFileModel file in folder.Files)
{
file.Dispose();
}
}
}
}
using DevExpress.Utils.Filtering.Internal;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Module
{
public class ThumbnailHelper
{
/// <summary>
/// 生成高清缩略图片方法
/// </summary>
/// <param name="image"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public static Image GetThumbnail(Image image, int width, int height)
{
Bitmap bmp = new Bitmap(width, height);
//从Bitmap创建一个System.Drawing.Graphics
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmp);
//设置
gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//下面这个也设成高质量
gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
//下面这个设成High
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
//把原始图像绘制成上面所设置宽高的缩小图
System.Drawing.Rectangle rectDestination = new Rectangle(0, 0, width, height);
gr.DrawImage(image, rectDestination, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
return bmp;
}
/// <summary>
/// 获取图片
/// </summary>
/// <param name="path"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public static Image GetImage(string path, int width, int height)
{
try
{
//string newPath = "";
//if (File.Exists(Application.StartupPath + path))
//{
// newPath = Application.StartupPath + path;
//}
//else
//{//如果图片不存在,使用默认图片
// //newPath = Application.StartupPath + LocalConfig.defaultPicPath;
//}
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Image result = Image.FromStream(fs);
fs.Close();
result = GetThumbnail(result, width, height);
return result;
}
catch (Exception e)
{
return null;
}
}
}
}
......@@ -9,11 +9,12 @@
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:fcore1="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:local="clr-namespace:VIZ.TVP.Module"
xmlns:common="clr-namespace:VIZ.TVP.Common;assembly=VIZ.TVP.Common"
xmlns:domain="clr-namespace:VIZ.TVP.Domain;assembly=VIZ.TVP.Domain"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:LocalResourceViewModel}"
d:DataContext="{d:DesignInstance Type=local:VizResourceViewModel}"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
......@@ -21,7 +22,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.TVP.Module.Resource;component/DevExpreess/GridControl/GridControl_Files.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<fcore:Bitmap2ImageSourceConverter x:Key="Bitmap2ImageSourceConverter"></fcore:Bitmap2ImageSourceConverter>
<fcore1:Bitmap2ImageSourceConverter x:Key="Bitmap2ImageSourceConverter"></fcore1:Bitmap2ImageSourceConverter>
</ResourceDictionary>
</UserControl.Resources>
......@@ -38,7 +39,7 @@
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 资源文件夹 -->
<dxg:TreeViewControl ItemsSource="{Binding Path=FolderModels}" Margin="0,0,6,0" Grid.Row="1"
<dxg:TreeViewControl ItemsSource="{Binding Path=FolderModels,Mode=TwoWay}" Margin="0,0,6,0" Grid.Row="1"
SelectedItem="{Binding Path=SelectedFolderModel,Mode=TwoWay}"
SelectionMode="Row" ShowNodeImages="True" ShowSearchPanel="False"
ExpandStateFieldName="IsExpand"
......@@ -57,6 +58,7 @@
</dxg:TreeViewControl.NodeImageSelector>
</dxg:TreeViewControl>
<!-- 文件夹等待 -->
<dx:WaitIndicator DeferedVisibility="{Binding IsFolderLoading}" Content="Loading..." Grid.Row="1" Margin="0,0,6,0" />
<GridSplitter HorizontalAlignment="Right" Width="4" Grid.Row="1"></GridSplitter>
......@@ -68,11 +70,11 @@
<dxmvvm:EventToCommand EventName="Checked" Command="{Binding Path=FileFilterCommand}" CommandParameter="{x:Static Member=domain:ResourceFileType.None}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
</RadioButton>
<RadioButton Height="30" Width="60" Content="场景">
<!--<RadioButton Height="30" Width="60" Content="场景">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Checked" Command="{Binding Path=FileFilterCommand}" CommandParameter="{x:Static Member=domain:ResourceFileType.SCENE}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
</RadioButton>
</RadioButton>-->
<RadioButton Height="30" Width="60" Content="图片">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Checked" Command="{Binding Path=FileFilterCommand}" CommandParameter="{x:Static Member=domain:ResourceFileType.IMAGE}"></dxmvvm:EventToCommand>
......@@ -91,6 +93,7 @@
<dxg:GridControl.Resources>
<!-- 定义Card模板 -->
<DataTemplate x:Key="CardTemplate">
<common:ResourceDragBorder Background="Transparent">
<Grid Width="160" ClipToBounds="False" UseLayoutRounding="True">
<Grid.RowDefinitions>
<RowDefinition Height="90" />
......@@ -100,6 +103,7 @@
<TextBlock Grid.Row="1" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center"
Text="{Binding Path=Row.Name}" ToolTip="{Binding Path=Row.Name}" Margin="0,5,0,0"/>
</Grid>
</common:ResourceDragBorder>
</DataTemplate>
</dxg:GridControl.Resources>
<dxg:GridControl.ContextMenu>
......@@ -109,7 +113,8 @@
</dxmvvm:Interaction.Behaviors>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator/>
<MenuItem Header="添加至场景模板" Command="{Binding Path=PlacementTarget.DataContext.AddProgramTemplateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<!--<MenuItem Header="添加至场景模板" Command="{Binding Path=PlacementTarget.DataContext.AddProgramTemplateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>-->
<MenuItem Header="复制路径" Command="{Binding Path=PlacementTarget.DataContext.CopyFilePathCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
......
......@@ -24,5 +24,7 @@ namespace VIZ.TVP.Module
{
InitializeComponent();
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Domain;
namespace VIZ.TVP.Module
{
public interface IMediaResourceFileSupport
{
/// <summary>
/// 文件夹目录集合
/// </summary>
ObservableCollection<GHResourceFolderModel> FolderModels { get; set; }
/// <summary>
/// 当前选中的文件夹
/// </summary>
GHResourceFolderModel SelectedFolderModel { get; set; }
/// <summary>
/// 文件集合
/// </summary>
ObservableCollection<GHResourceFileModel> FileModels { get; set; }
/// <summary>
/// 选中的文件模型
/// </summary>
GHResourceFileModel SelectedFileModel { get; set; }
/// <summary>
/// 是否正在加载文件
/// </summary>
bool IsFileLoading { get; set; }
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Drawing;
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
{
public class MediaResourceFileController
{
/// <summary>
/// 日志
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(VizResourceFileController));
/// <summary>
/// VIZ资源缩略图控制器
/// </summary>
/// <param name="support">支持</param>
public MediaResourceFileController(IMediaResourceFileSupport support)
{
this.Support = support;
}
/// <summary>
/// 支持
/// </summary>
public IMediaResourceFileSupport Support { get; private set; }
/// <summary>
/// GH 资源服务
/// </summary>
private IGHResourceService ghResourceService = new GHResourceService();
/// <summary>
/// GH 服务
/// </summary>
private IGHService ghService = new GHService();
/// <summary>
/// 更新文件模型
/// </summary>
/// <param name="folder">文件夹</param>
public void UpdateFileModels(GHResourceFolderModel folder)
{
// 文件夹对象不存在
if (folder == null)
{
this.Support.FileModels = null;
this.Support.SelectedFileModel = null;
return;
}
// 已经获取过文件
if (folder.IsRefreshedFiles)
{
this.Support.FileModels = folder.Files;
return;
}
GH_Link_Node link_related = folder.EntryNode.links.FirstOrDefault(p => p.rel == GH_Link_Rel_Enums.related);
if (link_related == null || string.IsNullOrWhiteSpace(link_related.href))
{
folder.IsRefreshedFiles = true;
return;
}
this.Support.IsFileLoading = true;
ThreadHelper.SafeRun(() =>
{
List<GHResourceFileModel> files = ghResourceService.GetGHResourceFiles(link_related.href, folder);
WPFHelper.BeginInvoke(() =>
{
folder.Files = files.ToObservableCollection();
this.Support.FileModels = folder.Files;
folder.IsRefreshedFiles = true;
this.Support.IsFileLoading = false;
// 开始下载缩略图
this.BeginDownloadThumbnail(folder);
});
});
}
/// <summary>
/// 开始下载缩略图
/// </summary>
/// <param name="folder">文件夹</param>
public void BeginDownloadThumbnail(GHResourceFolderModel folder)
{
if (folder == null || folder.Files == null || folder.Files.Count == 0)
return;
ThreadHelper.SafeRun(() =>
{
foreach (GHResourceFileModel file in folder.Files)
{
this.DownloadThumbnail(file);
}
});
}
/// <summary>
/// 开始下载缩略图
/// </summary>
/// <param name="file">文件</param>
public void DownloadThumbnail(GHResourceFileModel file)
{
if (file == null || string.IsNullOrWhiteSpace(file.Thumbnail))
return;
try
{
Bitmap bmp = this.ghService.GetImage(file.Thumbnail);
WPFHelper.BeginInvoke(() =>
{
file.ThumbnailBitmap = bmp;
});
}
catch (Exception ex)
{
log.Error(ex);
}
}
/// <summary>
/// 销毁文件模型
/// </summary>
public void DisposeFileModels(GHResourceFolderModel folder)
{
if (folder == null || folder.Files == null || folder.Files.Count == 0)
return;
foreach (GHResourceFileModel file in folder.Files)
{
file.Dispose();
}
}
}
}
......@@ -3,10 +3,142 @@
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:local="clr-namespace:VIZ.TVP.Module"
xmlns:common="clr-namespace:VIZ.TVP.Common;assembly=VIZ.TVP.Common"
xmlns:domain="clr-namespace:VIZ.TVP.Domain;assembly=VIZ.TVP.Domain"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:MediaResourceViewModel}"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.TVP.Module.Resource;component/DevExpreess/GridControl/GridControl_Files.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<fcore:Bitmap2ImageSourceConverter x:Key="Bitmap2ImageSourceConverter"></fcore:Bitmap2ImageSourceConverter>
</ResourceDictionary>
</UserControl.Resources>
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<Grid>
<TextBlock Text="媒体资源" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="36" Foreground="Red"></TextBlock>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="240" MaxWidth="400"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 资源文件夹 -->
<dxg:TreeViewControl ItemsSource="{Binding Path=FolderModels}" Margin="0,0,6,0" Grid.Row="1"
SelectedItem="{Binding Path=SelectedFolderModel,Mode=TwoWay}"
SelectionMode="Row" ShowNodeImages="True" ShowSearchPanel="False"
ExpandStateFieldName="IsExpand"
AllowEditing="False" TreeViewFieldName="Name" ChildNodesPath="Children">
<dxg:TreeViewControl.ContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFolderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:TreeViewControl.ContextMenu>
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="NodeDoubleClick" PassEventArgsToCommand="True" Command="{Binding Path=FolderExpandCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<dxg:TreeViewControl.NodeImageSelector>
<local:ResourceFolderNodeImageSelector Folder="/VIZ.TVP.Module.Resource;component/Icons/folder_24x24.png"
Project="/VIZ.TVP.Module.Resource;component/Icons/project_24x24.png"></local:ResourceFolderNodeImageSelector>
</dxg:TreeViewControl.NodeImageSelector>
</dxg:TreeViewControl>
<!-- 文件夹等待 -->
<dx:WaitIndicator DeferedVisibility="{Binding IsFolderLoading}" Content="Loading..." Grid.Row="1" Margin="0,0,6,0" />
<GridSplitter HorizontalAlignment="Right" Width="4" Grid.Row="1"></GridSplitter>
<!-- 资源文件 -->
<StackPanel Grid.Column="1" Orientation="Horizontal">
<RadioButton Height="30" Width="60" Content="All" IsChecked="True">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Checked" Command="{Binding Path=FileFilterCommand}" CommandParameter="{x:Static Member=domain:ResourceFileType.None}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
</RadioButton>
<!--<RadioButton Height="30" Width="60" Content="场景">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Checked" Command="{Binding Path=FileFilterCommand}" CommandParameter="{x:Static Member=domain:ResourceFileType.SCENE}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
</RadioButton>-->
<RadioButton Height="30" Width="60" Content="图片">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Checked" Command="{Binding Path=FileFilterCommand}" CommandParameter="{x:Static Member=domain:ResourceFileType.IMAGE}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
</RadioButton>
<RadioButton Height="30" Width="60" Content="视频">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Checked" Command="{Binding Path=FileFilterCommand}" CommandParameter="{x:Static Member=domain:ResourceFileType.Video}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
</RadioButton>
</StackPanel>
<dxg:GridControl x:Name="fileGrid" Grid.Column="1" ShowBorder="False" Grid.Row="1"
CustomRowFilterCommand="{Binding Path=FileRowFilterCommand}"
ItemsSource="{Binding Path=FileModels}"
SelectedItem="{Binding Path=SelectedFileModel,Mode=TwoWay}">
<dxg:GridControl.Resources>
<!-- 定义Card模板 -->
<DataTemplate x:Key="CardTemplate">
<common:ResourceDragBorder Background="Transparent">
<Grid Width="160" ClipToBounds="False" UseLayoutRounding="True">
<Grid.RowDefinitions>
<RowDefinition Height="90" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Image Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
<TextBlock Grid.Row="1" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center"
Text="{Binding Path=Row.Name}" ToolTip="{Binding Path=Row.Name}" Margin="0,5,0,0"/>
</Grid>
</common:ResourceDragBorder>
</DataTemplate>
</dxg:GridControl.Resources>
<dxg:GridControl.ContextMenu>
<ContextMenu>
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Opened" Command="{Binding Path=FileContextMenuOpendCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator/>
<MenuItem Header="添加至场景模板" Command="{Binding Path=PlacementTarget.DataContext.AddProgramTemplateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="复制路径" Command="{Binding Path=PlacementTarget.DataContext.CopyFilePathCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Name" AllowColumnFiltering="False" AllowEditing="False" ReadOnly="True"></dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:CardView IsColumnChooserVisible="False"
SeparatorThickness="0"
CardLayout="Rows"
ShowCardExpandButton="False"
ShowColumnHeaders="False"
ShowFilterPanelMode="Never"
ShowGroupedColumns="False"
ShowGroupPanel="False"
SearchPanelHighlightResults="False"
SearchPanelAllowFilter="True"
ShowSearchPanelMode="Never"
SearchColumns="Name"
NavigationStyle="Row"
CardTemplate="{StaticResource CardTemplate}"/>
</dxg:GridControl.View>
</dxg:GridControl>
<!-- 文件等待 -->
<dx:WaitIndicator DeferedVisibility="{Binding IsFileLoading}" Content="Loading..." Grid.Column="1" Grid.Row="1" />
</Grid>
</UserControl>
......@@ -199,6 +199,11 @@
<Compile Include="Program\View\ProgramItemCreateView.xaml.cs">
<DependentUpon>ProgramItemCreateView.xaml</DependentUpon>
</Compile>
<Compile Include="Resource\LocalResource\Controller\LocalResourceFile\ILocalResourceFileSupport.cs" />
<Compile Include="Resource\LocalResource\Controller\LocalResourceFile\LocalResourceFileController.cs" />
<Compile Include="Resource\LocalResource\Controller\LocalResourceFile\ThumbnailHelper.cs" />
<Compile Include="Resource\MediaResource\Controller\MediaResourceFile\IMediaResourceFileSupport.cs" />
<Compile Include="Resource\MediaResource\Controller\MediaResourceFile\MediaResourceFileController.cs" />
<Compile Include="SettingInner\Control\ViewModel\ControlSettingViewModel.cs" />
<Compile Include="SettingInner\Control\View\ControlSettingView.xaml.cs">
<DependentUpon>ControlSettingView.xaml</DependentUpon>
......@@ -396,8 +401,6 @@
<Folder Include="Login\Service\" />
<Folder Include="PluginPanel\Controller\" />
<Folder Include="Program\Controller\" />
<Folder Include="Resource\LocalResource\Controller\" />
<Folder Include="Resource\MediaResource\Controller\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ 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