Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.Package
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.Package
Commits
45d0ec7b
Commit
45d0ec7b
authored
Jan 12, 2023
by
liulongfei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://49.233.21.66/liulongfei/VIZ.Package
parents
d92fbea6
bef2c9fd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
175 additions
and
38 deletions
+175
-38
VIZ.Package.Domain/Model/Resource/MH/MHResourceFileModel.cs
+12
-0
VIZ.Package.Module/Resource/MediaResource/Controller/MediaResourceFileController.cs
+21
-2
VIZ.Package.Module/Resource/MediaResource/View/MediaResourceView.xaml
+2
-0
VIZ.Package.Module/Resource/MediaResource/ViewModel/MediaResourcePanelViewModel.cs
+140
-36
No files found.
VIZ.Package.Domain/Model/Resource/MH/MHResourceFileModel.cs
View file @
45d0ec7b
...
...
@@ -114,6 +114,18 @@ namespace VIZ.Package.Domain
#
endregion
#
region
----
源图
private
Bitmap
originThumbnailBitmap
;
public
Bitmap
OriginThumbnailBitmap
{
get
{
return
originThumbnailBitmap
;
}
set
{
originThumbnailBitmap
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
OriginThumbnailBitmap
));
}
}
#
endregion
// ---------------------------------------------------------------------
// 方法
...
...
VIZ.Package.Module/Resource/MediaResource/Controller/MediaResourceFileController.cs
View file @
45d0ec7b
...
...
@@ -62,10 +62,13 @@ namespace VIZ.Package.Module
{
try
{
string
header
=
string
.
Format
(
"{0}GetListFile?filePath={1}"
,
ApplicationDomainEx
.
MediaConfig
.
Url
,
folder
.
Path
);
string
header
=
string
.
Format
(
"{0}GetListFile?filePath={1}&isResize=false"
,
ApplicationDomainEx
.
MediaConfig
.
Url
,
folder
.
Path
);
log
.
Info
(
"调用接口开始"
);
var
FileResult
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>(
header
,
""
);
log
.
Info
(
"调用接口结束"
);
List
<
MHResourceFileModel
>
list
=
new
List
<
MHResourceFileModel
>();
// folder.Files = new System.Collections.ObjectModel.ObservableCollection<GHResourceFileModel>();
if
(
FileResult
.
masterData
==
null
)
return
;
foreach
(
var
file
in
FileResult
.
masterData
)
{
try
...
...
@@ -76,16 +79,30 @@ namespace VIZ.Package.Module
GHFile
.
Name
=
file
.
fileName
;
GHFile
.
Path
=
file
.
smallIconUrl
;
string
url
=
string
.
Format
(
"{0}GetFile?filePath={1}"
,
ApplicationDomainEx
.
MediaConfig
.
Url
,
GHFile
.
Path
);
log
.
Info
(
"获取图片开始"
);
var
fileResult
=
await
MediaResourceFileService
.
GetImage
(
url
);
log
.
Info
(
"后去图片结束"
);
GHFile
.
FileType
=
ResourceFileType
.
IMAGE
;
Image
img
=
Bitmap
.
FromStream
(
fileResult
);
// img = ThumbnailHelper.GetThumbnail(img, img.Width / 2, img.Height / 2);
Bitmap
originBmp
=
new
Bitmap
(
img
);
GHFile
.
OriginThumbnailBitmap
=
originBmp
;
//缩略图
img
=
ThumbnailHelper
.
GetThumbnail
(
img
,
img
.
Width
/
2
,
img
.
Height
/
2
);
Bitmap
bmp
=
new
Bitmap
(
img
);
Bitmap
bmp
=
new
Bitmap
(
img
);
GHFile
.
ThumbnailBitmap
=
bmp
;
list
.
Add
(
GHFile
);
log
.
Info
(
"转换图片结束"
);
log
.
Info
(
"图片处理"
);
}
else
if
(
ThumbnailHelper
.
IsVideo
(
file
.
fileName
))
{
...
...
@@ -110,6 +127,8 @@ namespace VIZ.Package.Module
folder
.
Files
=
list
.
ToObservableCollection
();
this
.
Support
.
FileModels
=
folder
.
Files
;
log
.
Info
(
"总的结束"
);
}
catch
(
Exception
ex
)
{
...
...
VIZ.Package.Module/Resource/MediaResource/View/MediaResourceView.xaml
View file @
45d0ec7b
...
...
@@ -16,6 +16,7 @@
<MenuItem Header="创建文件夹" Command="{Binding Path=PlacementTarget.DataContext.CreateFloderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除文件夹" Command="{Binding Path=PlacementTarget.DataContext.DeleteFloderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="移入文件夹" Command="{Binding Path=PlacementTarget.DataContext.MoveFloderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="导出素材" Command="{Binding Path=PlacementTarget.DataContext.ExportFolderFilesCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</local:MediaResourcePanel.FolderContextMenu>
<local:MediaResourcePanel.FileContextMenu>
...
...
@@ -24,6 +25,7 @@
<MenuItem Header="添加文件" Command="{Binding Path=PlacementTarget.DataContext.CreateFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除文件" Command="{Binding Path=PlacementTarget.DataContext.DeleteFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="移动文件" Command="{Binding Path=PlacementTarget.DataContext.MoveFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="导出素材" Command="{Binding Path=PlacementTarget.DataContext.ExportFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<!--<Separator/>-->
</ContextMenu>
</local:MediaResourcePanel.FileContextMenu>
...
...
VIZ.Package.Module/Resource/MediaResource/ViewModel/MediaResourcePanelViewModel.cs
View file @
45d0ec7b
...
...
@@ -6,7 +6,9 @@ using System.Collections.Generic;
using
System.Collections.ObjectModel
;
using
System.Configuration
;
using
System.Drawing
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
...
...
@@ -51,6 +53,10 @@ namespace VIZ.Package.Module
this
.
MoveFileCommand
=
new
VCommand
(
this
.
MoveFile
);
this
.
MoveFloderCommand
=
new
VCommand
(
this
.
MoveFileFloder
);
this
.
ExportFileCommand
=
new
VCommand
(
this
.
ExprotFile
);
this
.
ExportFolderFilesCommand
=
new
VCommand
(
this
.
ExportFolderFiles
);
this
.
FolderExpandCommand
=
new
VCommand
<
DevExpress
.
Xpf
.
Grid
.
TreeList
.
NodeDoubleClickEventArgs
>(
this
.
FolderExpand
);
this
.
FileFilterCommand
=
new
VCommand
<
ResourceFileType
>(
this
.
FileFilter
);
this
.
FileRowFilterCommand
=
new
DevExpress
.
Mvvm
.
DelegateCommand
<
RowFilterArgs
>(
this
.
FileRowFilter
);
...
...
@@ -132,7 +138,7 @@ namespace VIZ.Package.Module
get
{
return
selectedFileModel
;
}
set
{
selectedFileModel
=
value
;
selectedFileModel
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
SelectedFileModel
));
this
.
OnSelectedFileModelChanged
?.
Invoke
(
this
,
new
MHResourceSelectedFileChangedEventArgs
{
File
=
value
});
}
...
...
@@ -449,7 +455,7 @@ namespace VIZ.Package.Module
string
[]
fileNames
=
ofd
.
FileNames
;
bool
flag
=
false
;
foreach
(
var
tempFileName
in
fileNames
)
foreach
(
var
tempFileName
in
fileNames
)
{
string
path
=
System
.
IO
.
Path
.
GetFullPath
(
tempFileName
);
string
fileName
=
ThumbnailHelper
.
GetFileFolderName
(
path
);
...
...
@@ -472,47 +478,47 @@ namespace VIZ.Package.Module
}
//if (fileResult != null && fileResult.errCode == "0")
//{
//try
//{
// //MHResourceFileModel fileModel = new MHResourceFileModel();
//if (ThumbnailHelper.IsImageByName(fileName))
//{
// Image image = ThumbnailHelper.GetImage(path, 100, 200);
// Bitmap btm = new Bitmap(image);
// fileModel.ThumbnailBitmap = btm;
// fileModel.FileType = ResourceFileType.IMAGE;
// fileModel.Name = fileName;
// this.FileModels.Add(fileModel);
//}
//else if (ThumbnailHelper.IsVideo(fileName))
//{
// string vedioImage = string.Format("{0}{1}", System.Environment.CurrentDirectory, "\\Resource\\VedioImage\\Vedio.jpeg");
// Image image = ThumbnailHelper.GetImage(vedioImage, 100, 200);
// Bitmap btm = new Bitmap(image);
// fileModel.ThumbnailBitmap = btm;
// fileModel.FileType = ResourceFileType.Video;
// fileModel.Name = fileName;
// this.FileModels.Add(fileModel);
//}
// }
//catch (Exception ex)
//{
// log.Error(ex.Message);
//}
// }
//try
//{
// //MHResourceFileModel fileModel = new MHResourceFileModel();
//if (ThumbnailHelper.IsImageByName(fileName))
//{
// Image image = ThumbnailHelper.GetImage(path, 100, 200);
// Bitmap btm = new Bitmap(image);
// fileModel.ThumbnailBitmap = btm;
// fileModel.FileType = ResourceFileType.IMAGE;
// fileModel.Name = fileName;
// this.FileModels.Add(fileModel);
//}
//else if (ThumbnailHelper.IsVideo(fileName))
//{
// string vedioImage = string.Format("{0}{1}", System.Environment.CurrentDirectory, "\\Resource\\VedioImage\\Vedio.jpeg");
// Image image = ThumbnailHelper.GetImage(vedioImage, 100, 200);
// Bitmap btm = new Bitmap(image);
// fileModel.ThumbnailBitmap = btm;
// fileModel.FileType = ResourceFileType.Video;
// fileModel.Name = fileName;
// this.FileModels.Add(fileModel);
//}
// }
//catch (Exception ex)
//{
// log.Error(ex.Message);
//}
// }
}
if
(
flag
)
if
(
flag
)
{
if
(
this
.
SelectedFolderModel
!=
null
)
if
(
this
.
SelectedFolderModel
!=
null
)
{
this
.
mediaResourceFileController
.
UpdateFileModels
(
this
.
SelectedFolderModel
);
}
}
}
}
#
endregion
创建文件
...
...
@@ -571,6 +577,104 @@ namespace VIZ.Package.Module
/// <summary>
/// 导出文件夹的素材
/// </summary>
public
VCommand
ExportFolderFilesCommand
{
get
;
set
;
}
private
void
ExportFolderFiles
()
{
if
(
SelectedFolderModel
==
null
||
FileModels
==
null
)
return
;
try
{
System
.
Windows
.
Forms
.
FolderBrowserDialog
ofd
=
new
System
.
Windows
.
Forms
.
FolderBrowserDialog
();
if
(
ofd
.
ShowDialog
()
==
System
.
Windows
.
Forms
.
DialogResult
.
OK
)
{
string
path
=
ofd
.
SelectedPath
;
foreach
(
var
fileModel
in
FileModels
)
{
string
filePath
=
String
.
Format
(
"{0}\\{1}"
,
path
,
fileModel
.
Name
);
if
(!
File
.
Exists
(
filePath
))
{
fileModel
.
OriginThumbnailBitmap
.
Save
(
filePath
);
}
}
DXMessageBox
.
Show
(
"素材导出成功"
);
}
}
catch
(
Exception
ex
)
{
DXMessageBox
.
Show
(
"素材导出失败"
);
log
.
Error
(
ex
.
Message
);
}
}
/// <summary>
/// 导入文件素材
/// </summary>
public
VCommand
ExportFileCommand
{
get
;
set
;
}
private
void
ExprotFile
()
{
//if (SelectedFileModel == null) return;
//var saveFileDialog1 = new SaveFileDialog
//{
// Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif",
// Title = "Save File"
//};
//saveFileDialog1.ShowDialog();
//if (string.IsNullOrEmpty(saveFileDialog1.FileName)) return;
//Bitmap bitmap = SelectedFileModel.ThumbnailBitmap;
//bitmap.Save(saveFileDialog1.FileName);
//using (var sw = new StreamWriter(selectedFileModel.ThumbnailBitmap))
//{
// sw.Write("Writing Text ");
// sw.WriteLine("Here we go.");
// sw.WriteLine("-------------------");
// sw.Write("Today is is: " + DateTime.Now);
// sw.WriteLine("Done");
//}
if
(
SelectedFileModel
==
null
)
return
;
try
{
System
.
Windows
.
Forms
.
FolderBrowserDialog
ofd
=
new
System
.
Windows
.
Forms
.
FolderBrowserDialog
();
if
(
ofd
.
ShowDialog
()
==
System
.
Windows
.
Forms
.
DialogResult
.
OK
)
{
string
path
=
ofd
.
SelectedPath
;
string
filePath
=
String
.
Format
(
"{0}\\{1}"
,
path
,
SelectedFileModel
.
Name
);
if
(!
File
.
Exists
(
filePath
))
{
SelectedFileModel
.
OriginThumbnailBitmap
.
Save
(
filePath
);
}
DXMessageBox
.
Show
(
"素材导出成功"
);
}
}
catch
(
Exception
ex
)
{
DXMessageBox
.
Show
(
"素材导出失败"
);
log
.
Error
(
ex
.
Message
);
}
}
public
VCommand
MoveFloderCommand
{
get
;
set
;
}
/// <summary>
...
...
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