Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.TVP
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘龙飞
VIZ.TVP
Commits
70f03df4
Commit
70f03df4
authored
Dec 08, 2022
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GH资源管理器开发
parent
b94a6ea3
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
531 additions
and
54 deletions
+531
-54
Doc/GH资源接口返回结果_文件.xml
+0
-0
VIZ.TVP.Domain/Model/Resource/Enum/ResourceFileType.cs
+1
-1
VIZ.TVP.Domain/Model/Resource/GH/GHResourceFileModel.cs
+45
-1
VIZ.TVP.Domain/Model/Resource/ResourceFolderModelBase.cs
+14
-0
VIZ.TVP.Domain/VIZ.TVP.Domain.csproj
+1
-0
VIZ.TVP.Module.Resource/VIZ.TVP.Module.Resource.csproj
+4
-1
VIZ.TVP.Module/VIZ.TVP.Module.csproj
+3
-0
VIZ.TVP.Module/VizResource/Controller/VizResourceFile/IVizResourceFileSupport.cs
+41
-0
VIZ.TVP.Module/VizResource/Controller/VizResourceFile/VizResourceFileController.cs
+154
-0
VIZ.TVP.Module/VizResource/View/VizResourceView.xaml
+29
-12
VIZ.TVP.Module/VizResource/ViewModel/VizResourceViewModel.cs
+139
-36
VIZ.TVP.Service/GH/Implementation/GHResourceService.cs
+11
-3
VIZ.TVP.Service/GH/Implementation/GHService.cs
+22
-0
VIZ.TVP.Service/GH/Interface/IGHService.cs
+8
-0
VIZ.TVP.Service/VIZ.TVP.Service.csproj
+1
-0
VIZ.TVP.Storage/VIZ.TVP.Storage.csproj
+1
-0
VIZ.TVP.Storage/XML/GH/Enum/GH_Category_Term_Enums.cs
+5
-0
VIZ.TVP.Storage/XML/GH/GH_Thumbnail_Node.cs
+45
-0
VIZ.TVP.Storage/XML/GH/Node/GH_Entry_Node.cs
+7
-0
No files found.
Doc/GH资源接口返回结果_文件.xml
View file @
70f03df4
This source diff could not be displayed because it is too large. You can
view the blob
instead.
VIZ.TVP.Domain/Model/Resource/Enum/ResourceFileType.cs
View file @
70f03df4
...
@@ -22,7 +22,7 @@ namespace VIZ.TVP.Domain
...
@@ -22,7 +22,7 @@ namespace VIZ.TVP.Domain
/// <summary>
/// <summary>
/// 场景
/// 场景
/// </summary>
/// </summary>
S
cene
,
S
CENE
,
/// <summary>
/// <summary>
/// 视频
/// 视频
/// </summary>
/// </summary>
...
...
VIZ.TVP.Domain/Model/Resource/GH/GHResourceFileModel.cs
View file @
70f03df4
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -10,7 +11,7 @@ namespace VIZ.TVP.Domain
...
@@ -10,7 +11,7 @@ namespace VIZ.TVP.Domain
/// <summary>
/// <summary>
/// GH 资源文件模型
/// GH 资源文件模型
/// </summary>
/// </summary>
public
class
GHResourceFileModel
:
ResourceFileModelBase
public
class
GHResourceFileModel
:
ResourceFileModelBase
,
IDisposable
{
{
/// <summary>
/// <summary>
/// GH 节点
/// GH 节点
...
@@ -31,6 +32,20 @@ namespace VIZ.TVP.Domain
...
@@ -31,6 +32,20 @@ namespace VIZ.TVP.Domain
#
endregion
#
endregion
#
region
Thumbnail
--
缩略图
private
string
thumbnail
;
/// <summary>
/// 缩略图
/// </summary>
public
string
Thumbnail
{
get
{
return
thumbnail
;
}
set
{
thumbnail
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
Thumbnail
));
}
}
#
endregion
#
region
MimeType
--
文件格式
#
region
MimeType
--
文件格式
private
string
mimeType
;
private
string
mimeType
;
...
@@ -44,5 +59,34 @@ namespace VIZ.TVP.Domain
...
@@ -44,5 +59,34 @@ namespace VIZ.TVP.Domain
}
}
#
endregion
#
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
;
}
}
}
}
}
VIZ.TVP.Domain/Model/Resource/ResourceFolderModelBase.cs
View file @
70f03df4
...
@@ -82,5 +82,19 @@ namespace VIZ.TVP.Domain
...
@@ -82,5 +82,19 @@ namespace VIZ.TVP.Domain
}
}
#
endregion
#
endregion
#
region
IsExpand
--
是否展开
private
bool
isExpand
;
/// <summary>
/// 是否展开
/// </summary>
public
bool
IsExpand
{
get
{
return
isExpand
;
}
set
{
isExpand
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
IsExpand
));
}
}
#
endregion
}
}
}
}
VIZ.TVP.Domain/VIZ.TVP.Domain.csproj
View file @
70f03df4
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
<Reference Include="System" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data.DataSetExtensions" />
...
...
VIZ.TVP.Module.Resource/VIZ.TVP.Module.Resource.csproj
View file @
70f03df4
...
@@ -95,6 +95,8 @@
...
@@ -95,6 +95,8 @@
<ItemGroup>
<ItemGroup>
<Resource Include="Icons\project_24x24.png" />
<Resource Include="Icons\project_24x24.png" />
</ItemGroup>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Style\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
\ No newline at end of file
VIZ.TVP.Module/VIZ.TVP.Module.csproj
View file @
70f03df4
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
<Reference Include="System" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.CSharp" />
...
@@ -139,6 +140,8 @@
...
@@ -139,6 +140,8 @@
</Compile>
</Compile>
<Compile Include="VizRender\ViewModel\VizRenderViewModel.cs" />
<Compile Include="VizRender\ViewModel\VizRenderViewModel.cs" />
<Compile Include="VizRender\VizRenderPluginLifeCycle.cs" />
<Compile Include="VizRender\VizRenderPluginLifeCycle.cs" />
<Compile Include="VizResource\Controller\VizResourceFile\IVizResourceFileSupport.cs" />
<Compile Include="VizResource\Controller\VizResourceFile\VizResourceFileController.cs" />
<Compile Include="VizResource\Core\ResourceFolderNodeImageSelector.cs" />
<Compile Include="VizResource\Core\ResourceFolderNodeImageSelector.cs" />
<Compile Include="VizResource\View\VizResourceView.xaml.cs">
<Compile Include="VizResource\View\VizResourceView.xaml.cs">
<DependentUpon>VizResourceView.xaml</DependentUpon>
<DependentUpon>VizResourceView.xaml</DependentUpon>
...
...
VIZ.TVP.Module/VizResource/Controller/VizResourceFile/IVizResourceFileSupport.cs
0 → 100644
View file @
70f03df4
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
{
/// <summary>
/// VIZ资源文件支持
/// </summary>
public
interface
IVizResourceFileSupport
{
/// <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
;
}
}
}
VIZ.TVP.Module/VizResource/Controller/VizResourceFile/VizResourceFileController.cs
0 → 100644
View file @
70f03df4
using
DevExpress.XtraPrinting.Native.Extensions
;
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
{
/// <summary>
/// VIZ资源文件控制器
/// </summary>
public
class
VizResourceFileController
{
/// <summary>
/// 日志
/// </summary>
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
VizResourceFileController
));
/// <summary>
/// VIZ资源缩略图控制器
/// </summary>
/// <param name="support">支持</param>
public
VizResourceFileController
(
IVizResourceFileSupport
support
)
{
this
.
Support
=
support
;
}
/// <summary>
/// 支持
/// </summary>
public
IVizResourceFileSupport
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
);
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
();
}
}
}
}
VIZ.TVP.Module/VizResource/View/VizResourceView.xaml
View file @
70f03df4
...
@@ -9,9 +9,10 @@
...
@@ -9,9 +9,10 @@
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxi="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
xmlns:dxi="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
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:local="clr-namespace:VIZ.TVP.Module"
xmlns:domain="clr-namespace:VIZ.TVP.Domain;assembly=VIZ.TVP.Domain"
xmlns:domain="clr-namespace:VIZ.TVP.Domain;assembly=VIZ.TVP.Domain"
mc:Ignorable="d"
mc:Ignorable="d"
x:Name="uc"
d:DataContext="{d:DesignInstance Type=local:VizResourceViewModel}"
d:DataContext="{d:DesignInstance Type=local:VizResourceViewModel}"
d:DesignHeight="450" d:DesignWidth="800">
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<UserControl.Resources>
...
@@ -19,6 +20,7 @@
...
@@ -19,6 +20,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.TVP.Module.Resource;component/DevExpreess/GridControl/GridControl_Files.xaml"></ResourceDictionary>
<ResourceDictionary Source="/VIZ.TVP.Module.Resource;component/DevExpreess/GridControl/GridControl_Files.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary.MergedDictionaries>
<fcore:Bitmap2ImageSourceConverter x:Key="Bitmap2ImageSourceConverter"></fcore:Bitmap2ImageSourceConverter>
</ResourceDictionary>
</ResourceDictionary>
</UserControl.Resources>
</UserControl.Resources>
...
@@ -27,19 +29,33 @@
...
@@ -27,19 +29,33 @@
</dxmvvm:Interaction.Behaviors>
</dxmvvm:Interaction.Behaviors>
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"
MinWidth="240" MaxWidth="400"
></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<!-- 资源文件夹 -->
<!-- 资源文件夹 -->
<dxg:TreeViewControl ItemsSource="{Binding Path=FolderModels}"
<dxg:TreeViewControl ItemsSource="{Binding Path=FolderModels}"
Margin="0,0,6,0"
SelectedItem="{Binding Path=SelectedFolderModel,Mode=TwoWay}"
SelectedItem="{Binding Path=SelectedFolderModel,Mode=TwoWay}"
SelectionMode="Row" ShowNodeImages="True" ShowSearchPanel="False"
SelectionMode="Row" ShowNodeImages="True" ShowSearchPanel="False"
ExpandStateFieldName="IsExpand"
AllowEditing="False" TreeViewFieldName="Name" ChildNodesPath="Children">
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>
<dxg:TreeViewControl.NodeImageSelector>
<local:ResourceFolderNodeImageSelector Folder="/VIZ.TVP.Module.Resource;component/Icons/folder_24x24.png"
<local:ResourceFolderNodeImageSelector Folder="/VIZ.TVP.Module.Resource;component/Icons/folder_24x24.png"
Project="/VIZ.TVP.Module.Resource;component/Icons/project_24x24.png"></local:ResourceFolderNodeImageSelector>
Project="/VIZ.TVP.Module.Resource;component/Icons/project_24x24.png"></local:ResourceFolderNodeImageSelector>
</dxg:TreeViewControl.NodeImageSelector>
</dxg:TreeViewControl.NodeImageSelector>
</dxg:TreeViewControl>
</dxg:TreeViewControl>
<!-- 文件夹等待 -->
<dx:WaitIndicator DeferedVisibility="{Binding IsFolderLoading}" Content="Loading..." Margin="0,0,6,0" />
<GridSplitter HorizontalAlignment="Right" Width="6"></GridSplitter>
<!-- 资源文件 -->
<!-- 资源文件 -->
<dxg:GridControl Grid.Column="1" ShowBorder="False"
<dxg:GridControl Grid.Column="1" ShowBorder="False"
ItemsSource="{Binding Path=FileModels}"
ItemsSource="{Binding Path=FileModels}"
...
@@ -52,19 +68,17 @@
...
@@ -52,19 +68,17 @@
<RowDefinition Height="90" />
<RowDefinition Height="90" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
</Grid.RowDefinitions>
<!--<dxe:ImageEdit RenderOptions.BitmapScalingMode="HighQuality"
<Image Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
SnapsToDevicePixels="True"
ShowMenu="False"
IsReadOnly="True"
EditMode="InplaceInactive"
ShowBorder="False" />-->
<TextBlock Grid.Row="0" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center"
Text="{Binding Path=Row.Src}" ToolTip="{Binding Path=Row.Src}"/>
<TextBlock Grid.Row="1" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center"
<TextBlock Grid.Row="1" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center"
Text="{Binding Path=Row.Name}" ToolTip="{Binding Path=Row.Name}"/>
Text="{Binding Path=Row.Name}" ToolTip="{Binding Path=Row.Name}"
Margin="0,5,0,0"
/>
</Grid>
</Grid>
</DataTemplate>
</DataTemplate>
</dxg:GridControl.Resources>
</dxg:GridControl.Resources>
<dxg:GridControl.ContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Name" AllowColumnFiltering="False" AllowEditing="False" ReadOnly="True"></dxg:GridColumn>
<dxg:GridColumn FieldName="Name" AllowColumnFiltering="False" AllowEditing="False" ReadOnly="True"></dxg:GridColumn>
</dxg:GridControl.Columns>
</dxg:GridControl.Columns>
...
@@ -85,5 +99,8 @@
...
@@ -85,5 +99,8 @@
CardTemplate="{StaticResource CardTemplate}"/>
CardTemplate="{StaticResource CardTemplate}"/>
</dxg:GridControl.View>
</dxg:GridControl.View>
</dxg:GridControl>
</dxg:GridControl>
<!-- 文件等待 -->
<dx:WaitIndicator DeferedVisibility="{Binding IsFileLoading}" Content="Loading..." Grid.Column="1" />
</Grid>
</Grid>
</UserControl>
</UserControl>
VIZ.TVP.Module/VizResource/ViewModel/VizResourceViewModel.cs
View file @
70f03df4
using
DevExpress.Xpf.Core.Native
;
using
DevExpress.Mvvm.UI.Native.ViewGenerator
;
using
DevExpress.Xpf.Core.Native
;
using
log4net
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Collections.ObjectModel
;
...
@@ -16,10 +18,18 @@ namespace VIZ.TVP.Module
...
@@ -16,10 +18,18 @@ namespace VIZ.TVP.Module
/// <summary>
/// <summary>
/// VIZ资源视图模型
/// VIZ资源视图模型
/// </summary>
/// </summary>
public
class
VizResourceViewModel
:
PluginViewModelBase
public
class
VizResourceViewModel
:
PluginViewModelBase
,
IVizResourceFileSupport
{
{
/// <summary>
/// 日志
/// </summary>
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
VizResourceViewModel
));
public
VizResourceViewModel
()
public
VizResourceViewModel
()
{
{
// 初始化控制器
this
.
initController
();
// 初始化命令
// 初始化命令
this
.
initCommand
();
this
.
initCommand
();
}
}
...
@@ -30,6 +40,17 @@ namespace VIZ.TVP.Module
...
@@ -30,6 +40,17 @@ namespace VIZ.TVP.Module
private
void
initCommand
()
private
void
initCommand
()
{
{
this
.
LoadedCommand
=
new
VCommand
(
this
.
Loaded
);
this
.
LoadedCommand
=
new
VCommand
(
this
.
Loaded
);
this
.
RefreshFolderCommand
=
new
VCommand
(
this
.
RefreshFolder
);
this
.
RefreshFileCommand
=
new
VCommand
(
this
.
RefreshFile
);
this
.
FolderExpandCommand
=
new
VCommand
<
DevExpress
.
Xpf
.
Grid
.
TreeList
.
NodeDoubleClickEventArgs
>(
this
.
FolderExpand
);
}
/// <summary>
/// 初始化控制器
/// </summary>
private
void
initController
()
{
this
.
vizResourceFileController
=
new
VizResourceFileController
(
this
);
}
}
// ==================================================================================
// ==================================================================================
...
@@ -64,7 +85,7 @@ namespace VIZ.TVP.Module
...
@@ -64,7 +85,7 @@ namespace VIZ.TVP.Module
selectedFolderModel
=
value
;
selectedFolderModel
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
SelectedFolderModel
));
this
.
RaisePropertyChanged
(
nameof
(
SelectedFolderModel
));
// 更新文件模型
// 更新文件模型
this
.
u
pdateFileModels
(
value
);
this
.
vizResourceFileController
.
U
pdateFileModels
(
value
);
}
}
}
}
...
@@ -98,6 +119,34 @@ namespace VIZ.TVP.Module
...
@@ -98,6 +119,34 @@ namespace VIZ.TVP.Module
#
endregion
#
endregion
#
region
IsFolderLoading
--
是否正在加载文件夹
private
bool
isFolderLoading
;
/// <summary>
/// 是否正在加载文件夹
/// </summary>
public
bool
IsFolderLoading
{
get
{
return
isFolderLoading
;
}
set
{
isFolderLoading
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
IsFolderLoading
));
}
}
#
endregion
#
region
IsFileLoading
--
是否正在加载文件
private
bool
isFileLoading
;
/// <summary>
/// 是否正在加载文件
/// </summary>
public
bool
IsFileLoading
{
get
{
return
isFileLoading
;
}
set
{
isFileLoading
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
IsFileLoading
));
}
}
#
endregion
// ==================================================================================
// ==================================================================================
// Service & Controller
// Service & Controller
// ==================================================================================
// ==================================================================================
...
@@ -107,6 +156,11 @@ namespace VIZ.TVP.Module
...
@@ -107,6 +156,11 @@ namespace VIZ.TVP.Module
/// </summary>
/// </summary>
private
IGHResourceService
ghResourceService
=
new
GHResourceService
();
private
IGHResourceService
ghResourceService
=
new
GHResourceService
();
/// <summary>
/// VIZ资源文件控制器
/// </summary>
private
VizResourceFileController
vizResourceFileController
;
// ==================================================================================
// ==================================================================================
// Command
// Command
// ==================================================================================
// ==================================================================================
...
@@ -126,66 +180,115 @@ namespace VIZ.TVP.Module
...
@@ -126,66 +180,115 @@ namespace VIZ.TVP.Module
if
(
this
.
IsAlreadyLoaded
)
if
(
this
.
IsAlreadyLoaded
)
return
;
return
;
List
<
GHResourceFolderModel
>
list
=
this
.
ghResourceService
.
GetGHResourceFolders
(
"http://localhost:19398/folders/"
)
;
this
.
IsFolderLoading
=
true
;
this
.
FolderModels
=
list
.
FirstOrDefault
()?.
Children
.
Select
(
p
=>
(
GHResourceFolderModel
)
p
).
ToObservableCollection
();
// 刷新文件夹
this
.
RefreshFolder
();
this
.
IsAlreadyLoaded
=
true
;
this
.
IsAlreadyLoaded
=
true
;
}
}
#
endregion
#
endregion
#
region
RefreshFolderCommand
--
刷新文件夹命令
// ==================================================================================
/// <summary>
// Public Function
/// 刷新文件夹命令
// ==================================================================================
/// </summary>
public
VCommand
RefreshFolderCommand
{
get
;
set
;
}
/// <summary>
/// <summary>
///
销毁
///
刷新文件夹
/// </summary>
/// </summary>
p
ublic
override
void
Dispose
()
p
rivate
void
RefreshFolder
()
{
{
this
.
IsFolderLoading
=
true
;
Task
.
Run
(()
=>
{
try
{
List
<
GHResourceFolderModel
>
list
=
this
.
ghResourceService
.
GetGHResourceFolders
(
"http://localhost:19398/folders/"
);
WPFHelper
.
BeginInvoke
(()
=>
{
this
.
FolderModels
=
list
.
FirstOrDefault
()?.
Children
.
Select
(
p
=>
(
GHResourceFolderModel
)
p
).
ToObservableCollection
();
this
.
IsFolderLoading
=
false
;
});
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
);
}
});
}
}
#
endregion
// ==================================================================================
#
region
RefreshFileCommand
--
刷新文件命令
// Private Function
// ==================================================================================
/// <summary>
/// <summary>
///
更新文件模型
///
刷新文件命令
/// </summary>
/// </summary>
/// <param name="folder">文件夹</param>
public
VCommand
RefreshFileCommand
{
get
;
set
;
}
private
void
updateFileModels
(
GHResourceFolderModel
folder
)
/// <summary>
/// 刷新文件
/// </summary>
private
void
RefreshFile
()
{
{
// 文件夹对象不存在
GHResourceFolderModel
folder
=
this
.
SelectedFolderModel
;
if
(
folder
==
null
)
if
(
folder
==
null
)
{
this
.
FileModels
=
null
;
this
.
SelectedFileModel
=
null
;
return
;
return
;
}
// 已经获取过文件
this
.
vizResourceFileController
.
DisposeFileModels
(
folder
);
if
(
folder
.
IsRefreshedFiles
)
{
this
.
FileModels
=
folder
.
Files
;
return
;
}
GH_Link_Node
link_related
=
folder
.
EntryNode
.
links
.
FirstOrDefault
(
p
=>
p
.
rel
==
GH_Link_Rel_Enums
.
related
);
folder
.
IsRefreshedFiles
=
false
;
if
(
link_related
==
null
||
string
.
IsNullOrWhiteSpace
(
link_related
.
href
))
{
this
.
vizResourceFileController
.
UpdateFileModels
(
this
.
SelectedFolderModel
);
folder
.
IsRefreshedFiles
=
true
;
}
#
endregion
#
region
FolderExpandCommand
--
文件夹展开命令
/// <summary>
/// 文件夹展开命令
/// </summary>
public
VCommand
<
DevExpress
.
Xpf
.
Grid
.
TreeList
.
NodeDoubleClickEventArgs
>
FolderExpandCommand
{
get
;
set
;
}
/// <summary>
/// 文件夹展开
/// </summary>
private
void
FolderExpand
(
DevExpress
.
Xpf
.
Grid
.
TreeList
.
NodeDoubleClickEventArgs
e
)
{
if
(
this
.
SelectedFolderModel
==
null
||
e
.
ChangedButton
!=
System
.
Windows
.
Input
.
MouseButton
.
Left
)
return
;
return
;
}
folder
.
Files
=
ghResourceService
.
GetGHResourceFiles
(
link_related
.
href
).
ToObservableCollection
();
this
.
SelectedFolderModel
.
IsExpand
=
!
this
.
SelectedFolderModel
.
IsExpand
;
this
.
FileModels
=
folder
.
Files
;
}
#
endregion
// ==================================================================================
// Public Function
// ==================================================================================
/// <summary>
/// 销毁
/// </summary>
public
override
void
Dispose
()
{
folder
.
IsRefreshedFiles
=
true
;
return
;
}
}
// ==================================================================================
// Private Function
// ==================================================================================
}
}
}
}
VIZ.TVP.Service/GH/Implementation/GHResourceService.cs
View file @
70f03df4
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -85,13 +86,20 @@ namespace VIZ.TVP.Service
...
@@ -85,13 +86,20 @@ namespace VIZ.TVP.Service
// 名称
// 名称
child
.
Name
=
entry_node
.
title
;
child
.
Name
=
entry_node
.
title
;
child
.
Src
=
entry_node
.
content
.
src
;
child
.
Thumbnail
=
entry_node
.
thumbnail
.
url
;
child
.
MimeType
=
entry_node
.
content
.
type
;
// 图片
类型
// 图片
if
(
entry_node
.
categorys
.
Any
(
p
=>
p
.
term
==
GH_Category_Term_Enums
.
IMAGE
))
if
(
entry_node
.
categorys
.
Any
(
p
=>
p
.
term
==
GH_Category_Term_Enums
.
IMAGE
))
{
{
child
.
FileType
=
ResourceFileType
.
IMAGE
;
child
.
FileType
=
ResourceFileType
.
IMAGE
;
child
.
Src
=
entry_node
.
content
.
src
;
}
child
.
MimeType
=
entry_node
.
content
.
type
;
// 场景
if
(
entry_node
.
categorys
.
Any
(
p
=>
p
.
term
==
GH_Category_Term_Enums
.
SCENE
))
{
child
.
FileType
=
ResourceFileType
.
SCENE
;
}
}
list
.
Add
(
child
);
list
.
Add
(
child
);
...
...
VIZ.TVP.Service/GH/Implementation/GHService.cs
View file @
70f03df4
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Net
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Core
;
using
VIZ.Framework.Core
;
...
@@ -40,5 +43,24 @@ namespace VIZ.TVP.Service
...
@@ -40,5 +43,24 @@ namespace VIZ.TVP.Service
return
node
;
return
node
;
}
}
/// <summary>
/// 获取图片
/// </summary>
/// <param name="url">地址</param>
/// <returns>图片对象</returns>
public
Bitmap
GetImage
(
string
url
)
{
Dictionary
<
string
,
string
>
headers
=
new
Dictionary
<
string
,
string
>();
headers
[
"Authorization"
]
=
this
.
GetAuthorization
();
MemoryStream
ms
=
HttpHelper
.
GetStream
(
url
,
headers
,
null
,
null
);
Image
img
=
Bitmap
.
FromStream
(
ms
);
Bitmap
bmp
=
new
Bitmap
(
img
);
ms
.
Dispose
();
img
.
Dispose
();
return
bmp
;
}
}
}
}
}
VIZ.TVP.Service/GH/Interface/IGHService.cs
View file @
70f03df4
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -18,5 +19,12 @@ namespace VIZ.TVP.Service
...
@@ -18,5 +19,12 @@ namespace VIZ.TVP.Service
/// <param name="url">地址</param>
/// <param name="url">地址</param>
/// <returns>Feed节点</returns>
/// <returns>Feed节点</returns>
GH_Feed_Node
GetFeedNode
(
string
url
);
GH_Feed_Node
GetFeedNode
(
string
url
);
/// <summary>
/// 获取图片
/// </summary>
/// <param name="url">地址</param>
/// <returns>图片对象</returns>
Bitmap
GetImage
(
string
url
);
}
}
}
}
VIZ.TVP.Service/VIZ.TVP.Service.csproj
View file @
70f03df4
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
<Reference Include="System" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data.DataSetExtensions" />
...
...
VIZ.TVP.Storage/VIZ.TVP.Storage.csproj
View file @
70f03df4
...
@@ -56,6 +56,7 @@
...
@@ -56,6 +56,7 @@
<Compile Include="XML\GH\Enum\GH_Link_Type_Enums.cs" />
<Compile Include="XML\GH\Enum\GH_Link_Type_Enums.cs" />
<Compile Include="XML\GH\Enum\GH_Xmlns_Enums.cs" />
<Compile Include="XML\GH\Enum\GH_Xmlns_Enums.cs" />
<Compile Include="XML\GH\GH_NodeHelper.cs" />
<Compile Include="XML\GH\GH_NodeHelper.cs" />
<Compile Include="XML\GH\GH_Thumbnail_Node.cs" />
<Compile Include="XML\GH\Node\GH_Author_Node.cs" />
<Compile Include="XML\GH\Node\GH_Author_Node.cs" />
<Compile Include="XML\GH\Node\GH_Category_Node.cs" />
<Compile Include="XML\GH\Node\GH_Category_Node.cs" />
<Compile Include="XML\GH\Node\GH_Content_Node.cs" />
<Compile Include="XML\GH\Node\GH_Content_Node.cs" />
...
...
VIZ.TVP.Storage/XML/GH/Enum/GH_Category_Term_Enums.cs
View file @
70f03df4
...
@@ -27,6 +27,11 @@ namespace VIZ.TVP.Storage
...
@@ -27,6 +27,11 @@ namespace VIZ.TVP.Storage
public
const
string
IMAGE
=
"IMAGE"
;
public
const
string
IMAGE
=
"IMAGE"
;
/// <summary>
/// <summary>
/// 场景
/// </summary>
public
const
string
SCENE
=
"SCENE"
;
/// <summary>
/// 资源
/// 资源
/// </summary>
/// </summary>
public
const
string
asset
=
"asset"
;
public
const
string
asset
=
"asset"
;
...
...
VIZ.TVP.Storage/XML/GH/GH_Thumbnail_Node.cs
0 → 100644
View file @
70f03df4
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Xml.Linq
;
using
VIZ.Framework.Core
;
namespace
VIZ.TVP.Storage
{
/// <summary>
/// GH 缩略图节点
/// </summary>
public
class
GH_Thumbnail_Node
:
IXmlSerialize
{
/// <summary>
/// 地址
/// </summary>
public
string
url
{
get
;
set
;
}
/// <summary>
/// 宽度
/// </summary>
public
string
width
{
get
;
set
;
}
/// <summary>
/// 高度
/// </summary>
public
string
height
{
get
;
set
;
}
/// <summary>
/// 从XElement节点获取数据
/// </summary>
/// <param name="element">XElement节点</param>
public
void
FromXmlElement
(
XElement
element
)
{
if
(
element
==
null
)
return
;
this
.
url
=
element
.
GetAttributeValue
<
string
>(
"url"
);
this
.
width
=
element
.
GetAttributeValue
<
string
>(
"width"
);
this
.
height
=
element
.
GetAttributeValue
<
string
>(
"height"
);
}
}
}
VIZ.TVP.Storage/XML/GH/Node/GH_Entry_Node.cs
View file @
70f03df4
...
@@ -43,6 +43,11 @@ namespace VIZ.TVP.Storage
...
@@ -43,6 +43,11 @@ namespace VIZ.TVP.Storage
public
GH_Content_Node
content
{
get
;
set
;
}
=
new
GH_Content_Node
();
public
GH_Content_Node
content
{
get
;
set
;
}
=
new
GH_Content_Node
();
/// <summary>
/// <summary>
/// 缩略图
/// </summary>
public
GH_Thumbnail_Node
thumbnail
{
get
;
set
;
}
=
new
GH_Thumbnail_Node
();
/// <summary>
/// 从XElement节点获取数据
/// 从XElement节点获取数据
/// </summary>
/// </summary>
/// <param name="element">XElement节点</param>
/// <param name="element">XElement节点</param>
...
@@ -75,6 +80,8 @@ namespace VIZ.TVP.Storage
...
@@ -75,6 +80,8 @@ namespace VIZ.TVP.Storage
// 内容
// 内容
this
.
content
.
FromXmlElement
(
element
.
Element
(
XName
.
Get
(
"content"
,
GH_Xmlns_Enums
.
xmlns
)));
this
.
content
.
FromXmlElement
(
element
.
Element
(
XName
.
Get
(
"content"
,
GH_Xmlns_Enums
.
xmlns
)));
// 缩略图
this
.
thumbnail
.
FromXmlElement
(
element
.
Element
(
XName
.
Get
(
"thumbnail"
,
GH_Xmlns_Enums
.
media
)));
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment