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
608a27bc
Commit
608a27bc
authored
Apr 12, 2023
by
wangonghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面布局保存功能开发
parent
f61fe3cb
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
720 additions
and
41 deletions
+720
-41
VIZ.Package.Domain/Enum/ViewServiceKeys.cs
+5
-0
VIZ.Package.Domain/Model/Menu/MenuItemModel.cs
+18
-2
VIZ.Package.Module/Main/Service/IMainTopViewService.cs
+18
-0
VIZ.Package.Module/Main/Service/IMainViewService.cs
+4
-4
VIZ.Package.Module/Main/View/MainTopView.xaml
+1
-1
VIZ.Package.Module/Main/View/ManagerLayoutView.xaml
+48
-0
VIZ.Package.Module/Main/View/ManagerLayoutView.xaml.cs
+30
-0
VIZ.Package.Module/Main/View/SaveLayoutView.xaml
+30
-0
VIZ.Package.Module/Main/View/SaveLayoutView.xaml.cs
+29
-0
VIZ.Package.Module/Main/ViewModel/MainTopViewModel.cs
+105
-20
VIZ.Package.Module/Main/ViewModel/MainViewModel.cs
+44
-14
VIZ.Package.Module/Main/ViewModel/ManagerLayoutViewModel.cs
+154
-0
VIZ.Package.Module/Main/ViewModel/SaveLayoutViewModel.cs
+217
-0
VIZ.Package.Module/VIZ.Package.Module.csproj
+17
-0
No files found.
VIZ.Package.Domain/Enum/ViewServiceKeys.cs
View file @
608a27bc
...
...
@@ -60,5 +60,10 @@ namespace VIZ.Package.Domain
/// 包装任务服务
/// </summary>
public
const
string
PACKAGE_TASK_SERVICE
=
"PACKAGE_TASK_SERVICE"
;
/// <summary>
/// 主视图Top服务
/// </summary>
public
const
string
MAIN_TOPVIEW_SERVICE
=
"MAIN_TOPVIEW_SERVICE"
;
}
}
VIZ.Package.Domain/Model/Menu/MenuItemModel.cs
View file @
608a27bc
...
...
@@ -68,18 +68,34 @@ namespace VIZ.Package.Domain.Model
#
endregion
#
region
文件路径
private
string
filePath
;
/// <summary>
/// 文件路径
/// </summary>
public
string
FilePath
{
get
{
return
filePath
;
}
set
{
filePath
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
FilePath
));
}
}
#
endregion
#
region
Command
--
命令
private
VCommand
command
;
private
VCommand
<
string
>
command
;
/// <summary>
/// 命令
/// </summary>
public
VCommand
Command
public
VCommand
<
string
>
Command
{
get
{
return
command
;
}
set
{
command
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
Command
));
}
}
#
endregion
}
}
VIZ.Package.Module/Main/Service/IMainTopViewService.cs
0 → 100644
View file @
608a27bc
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Core
;
using
VIZ.Package.Domain.Model
;
namespace
VIZ.Package.Module
{
public
interface
IMainTopViewService
:
IService
{
ObservableCollection
<
MenuItemModel
>
ItemsSource
{
get
;
set
;
}
VCommand
<
string
>
ImportLayoutCommand
{
get
;
set
;
}
}
}
VIZ.Package.Module/Main/Service/IMainViewService.cs
View file @
608a27bc
...
...
@@ -29,13 +29,13 @@ namespace VIZ.Package.Module
void
SetIsEnabled
(
bool
isEnabled
);
/// <summary>
///
保存位置
///
导出布局
/// </summary>
void
SaveLayout1
(
);
void
ExportLayout
(
string
param
);
/// <summary>
/// 加载
位置
/// 加载
布局
/// </summary>
void
LoadLayout1
(
);
void
ImportLayout
(
string
param
);
}
}
VIZ.Package.Module/Main/View/MainTopView.xaml
View file @
608a27bc
...
...
@@ -23,7 +23,7 @@
<DataTemplate>
<ContentControl>
<dxb:BarButtonItem Glyph="{Binding Icon}" Content="{Binding Header}"
Command="{Binding Path=Command}"></dxb:BarButtonItem>
Command="{Binding Path=Command}"
CommandParameter="{Binding Path=FilePath}"
></dxb:BarButtonItem>
</ContentControl>
</DataTemplate>
</local:MainTopViewMenuDataTemplateSelector.ButtonDataTemplate>
...
...
VIZ.Package.Module/Main/View/ManagerLayoutView.xaml
0 → 100644
View file @
608a27bc
<dx:ThemedWindow
x:Class="VIZ.Package.Module.ManagerLayoutView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
ResizeMode="NoResize" WindowStartupLocation="CenterScreen"
Title="管理窗口布局" Height="300" Width="400" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<TextBlock Text="已保存的布局:" VerticalAlignment="Center" Margin="5"/>
<ListBox Name="saveLayoutBox" Grid.Row="1" Margin="5,0,0,0" ItemsSource="{Binding Path=ItemsSource}" SelectedItem="{Binding SelectItem}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Header}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="5,0,0,0">
<Button Content="重命名" Width="60" Command="{Binding ReNameCommand}" Margin="0,0,5,0"/>
<Button Content="删除" Width="60" Command="{Binding DeleteCommand}"/>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" >
<Button Content="关闭" Width="60" Command="{Binding CloseCommand}"/>
</StackPanel>
</Grid>
</dx:ThemedWindow>
VIZ.Package.Module/Main/View/ManagerLayoutView.xaml.cs
0 → 100644
View file @
608a27bc
using
DevExpress.Xpf.Core
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
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.Shapes
;
using
VIZ.Framework.Core
;
namespace
VIZ.Package.Module
{
/// <summary>
/// Interaction logic for ManagerLayout.xaml
/// </summary>
public
partial
class
ManagerLayoutView
:
ThemedWindow
{
public
ManagerLayoutView
()
{
InitializeComponent
();
WPFHelper
.
BindingViewModel
(
this
,
new
ManagerLayoutViewModel
());
}
}
}
VIZ.Package.Module/Main/View/SaveLayoutView.xaml
0 → 100644
View file @
608a27bc
<dx:ThemedWindow
x:Class="VIZ.Package.Module.SaveLayoutView"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
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:local="clr-namespace:VIZ.Package.Module"
Title="{Binding Path=TitleName}"
mc:Ignorable="d"
Width="300" Height="160" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="布局名称:" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,10,0" Grid.Row="0"></TextBlock>
<TextBox Text="{Binding Path=FolderName,Mode=TwoWay}" Grid.Row="1" VerticalContentAlignment="Center" HorizontalAlignment="Left" HorizontalContentAlignment="Left"
AcceptsReturn="False" TextWrapping="NoWrap" Height="30" Margin="10,0,10,0" Width="275"></TextBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="确定" Width="80" Height="30" Margin="10" Command="{Binding EnterCommand}"></Button>
<Button Content="取消" Width="80" Height="30" Margin="10" Command="{Binding CancelCommand}"></Button>
</StackPanel>
</Grid>
</dx:ThemedWindow>
VIZ.Package.Module/Main/View/SaveLayoutView.xaml.cs
0 → 100644
View file @
608a27bc
using
DevExpress.Xpf.Core
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
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.Shapes
;
using
VIZ.Framework.Core
;
namespace
VIZ.Package.Module
{
/// <summary>
/// Interaction logic for SaveLayout.xaml
/// </summary>
public
partial
class
SaveLayoutView
:
ThemedWindow
{
public
SaveLayoutView
()
{
InitializeComponent
();
WPFHelper
.
BindingViewModel
(
this
,
new
SaveLayoutViewModel
());
}
}
}
VIZ.Package.Module/Main/ViewModel/MainTopViewModel.cs
View file @
608a27bc
...
...
@@ -4,6 +4,7 @@ using log4net;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.IO
;
using
System.Linq
;
using
System.Security.Cryptography
;
using
System.Text
;
...
...
@@ -21,7 +22,7 @@ namespace VIZ.Package.Module
/// <summary>
/// 主视图顶部视图模型
/// </summary>
public
class
MainTopViewModel
:
ViewModelBase
public
class
MainTopViewModel
:
ViewModelBase
,
IMainTopViewService
{
/// <summary>
/// 日志
...
...
@@ -35,6 +36,9 @@ namespace VIZ.Package.Module
// 初始化消息
this
.
InitMessage
();
// 注册服务
ApplicationDomainEx
.
ServiceManager
.
AddService
(
ViewServiceKeys
.
MAIN_TOPVIEW_SERVICE
,
this
);
}
/// <summary>
...
...
@@ -50,14 +54,16 @@ namespace VIZ.Package.Module
this
.
CloseProjectCommand
=
new
VCommand
(
this
.
CloseProject
,
this
.
CanCloseProject
);
this
.
SettingCommand
=
new
VCommand
(
this
.
Setting
);
this
.
ResetLayoutCommand
=
new
VCommand
(
this
.
ResetLayout
);
this
.
ResetLayoutCommand
=
new
VCommand
<
string
>
(
this
.
ResetLayout
);
this
.
AboutCommand
=
new
VCommand
(
this
.
About
);
this
.
AboutCustomControlFieldCommand
=
new
VCommand
(
this
.
AboutCustomControlField
);
this
.
AboutPageCommandCommand
=
new
VCommand
(
this
.
AboutPageCommand
);
this
.
ExportLayoutCommand
=
new
VCommand
(
this
.
ExportLayout
);
this
.
ExportLayoutCommand
=
new
VCommand
<
string
>(
this
.
ExportLayout
);
this
.
ImportLayoutCommand
=
new
VCommand
<
string
>(
this
.
ImportLayout
);
this
.
ImportLayoutCommand
=
new
VCommand
(
this
.
Import
Layout
);
this
.
ManageLayoutCommand
=
new
VCommand
<
string
>(
this
.
Manage
Layout
);
}
/// <summary>
...
...
@@ -163,29 +169,65 @@ namespace VIZ.Package.Module
}).
ToList
();
items
.
Add
(
new
MenuItemModel
{
Type
=
MenuItemType
.
Separator
});
string
path
=
GetLayoutPath
();
items
.
Add
(
new
MenuItemModel
{
Header
=
"
重置
布局"
,
Header
=
"
保存
布局"
,
Icon
=
"/VIZ.Package.Module.Resource;component/Icons/top_icon_layout_20x20.png"
,
Type
=
MenuItemType
.
Button
,
Command
=
this
.
ResetLayoutCommand
FilePath
=
path
,
Command
=
this
.
ExportLayoutCommand
});
items
.
Add
(
new
MenuItemModel
{
Header
=
"
导入
布局"
,
Header
=
"
管理
布局"
,
Icon
=
"/VIZ.Package.Module.Resource;component/Icons/top_icon_layout_20x20.png"
,
Type
=
MenuItemType
.
Button
,
Command
=
this
.
ExportLayoutCommand
// FilePath = path,
Command
=
this
.
ManageLayoutCommand
});
items
.
Add
(
new
MenuItemModel
{
Header
=
"
导出
布局"
,
Header
=
"
重置
布局"
,
Icon
=
"/VIZ.Package.Module.Resource;component/Icons/top_icon_layout_20x20.png"
,
Type
=
MenuItemType
.
Button
,
Command
=
this
.
Impor
tLayoutCommand
Command
=
this
.
Rese
tLayoutCommand
});
items
.
Add
(
new
MenuItemModel
{
Type
=
MenuItemType
.
Separator
});
//读取文件中配置文件
if
(
Directory
.
Exists
(
path
))
{
string
[]
files
=
Directory
.
GetFiles
(
path
);
foreach
(
var
file
in
files
)
{
MenuItemModel
menuItemModel
=
new
MenuItemModel
();
menuItemModel
.
Header
=
Path
.
GetFileNameWithoutExtension
(
file
);
if
(
Convert
.
ToString
(
menuItemModel
.
Header
)
!=
"layout"
&&
(
Convert
.
ToString
(
menuItemModel
.
Header
)
!=
"default_layout"
))
{
menuItemModel
.
Type
=
MenuItemType
.
Button
;
menuItemModel
.
FilePath
=
file
;
menuItemModel
.
Command
=
this
.
ImportLayoutCommand
;
items
.
Add
(
menuItemModel
);
}
}
}
this
.
ItemsSource
=
items
.
ToObservableCollection
();
}
...
...
@@ -428,12 +470,12 @@ namespace VIZ.Package.Module
/// <summary>
/// 重置布局命令
/// </summary>
public
VCommand
ResetLayoutCommand
{
get
;
set
;
}
public
VCommand
<
string
>
ResetLayoutCommand
{
get
;
set
;
}
/// <summary>
/// 重置布局
/// </summary>
private
void
ResetLayout
()
private
void
ResetLayout
(
string
param
)
{
IMainViewService
service
=
ApplicationDomainEx
.
ServiceManager
.
GetService
<
IMainViewService
>(
ViewServiceKeys
.
MAIN_VIEW_SERVICE
);
if
(
service
==
null
)
...
...
@@ -450,11 +492,11 @@ namespace VIZ.Package.Module
#
region
ImportLayoutCommand
--
导入布局
public
VCommand
ImportLayoutCommand
{
get
;
set
;
}
public
VCommand
<
string
>
ImportLayoutCommand
{
get
;
set
;
}
private
void
ImportLayout
()
private
void
ImportLayout
(
string
param
)
{
IMainViewService
service
=
ApplicationDomainEx
.
ServiceManager
.
GetService
<
IMainViewService
>(
ViewServiceKeys
.
MAIN_VIEW_SERVICE
);
if
(
service
==
null
)
return
;
...
...
@@ -462,19 +504,41 @@ namespace VIZ.Package.Module
// 记录操作日志
this
.
recordLogService
.
AppendLog
(
ApplicationConstants
.
APPLICATION_GROUP_NAME
,
RecordLogOperate
.
Operate
,
RecordLogTrigger
.
Human
,
"导入布局"
);
service
.
LoadLayout1
(
);
service
.
ImportLayout
(
param
);
}
/// <summary>
/// 获取布局文件路径
/// </summary>
/// <returns>布局文件路径</returns>
private
string
GetLayoutPath
()
{
string
path
;
if
(
string
.
IsNullOrWhiteSpace
(
ApplicationDomainEx
.
VizConfig
.
PluginGroup
))
{
path
=
System
.
IO
.
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"layout"
);
}
else
{
path
=
System
.
IO
.
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"layout"
,
ApplicationDomainEx
.
VizConfig
.
PluginGroup
);
}
return
path
;
}
#
endregion
#
region
ExportLayoutCommand
---
导出布局
public
VCommand
ExportLayoutCommand
{
get
;
set
;
}
public
VCommand
<
string
>
ExportLayoutCommand
{
get
;
set
;
}
private
void
ExportLayout
()
private
void
ExportLayout
(
string
param
)
{
IMainViewService
service
=
ApplicationDomainEx
.
ServiceManager
.
GetService
<
IMainViewService
>(
ViewServiceKeys
.
MAIN_VIEW_SERVICE
);
...
...
@@ -484,10 +548,31 @@ namespace VIZ.Package.Module
// 记录操作日志
this
.
recordLogService
.
AppendLog
(
ApplicationConstants
.
APPLICATION_GROUP_NAME
,
RecordLogOperate
.
Operate
,
RecordLogTrigger
.
Human
,
"导出布局"
);
service
.
SaveLayout1
();
service
.
ExportLayout
(
param
);
}
#
endregion
#
region
ManageLayoutCommand
---
管理布局
public
VCommand
<
string
>
ManageLayoutCommand
{
get
;
set
;
}
private
void
ManageLayout
(
string
param
)
{
ManagerLayoutView
managerLayout
=
new
ManagerLayoutView
();
ManagerLayoutViewModel
vm
=
managerLayout
.
DataContext
as
ManagerLayoutViewModel
;
vm
.
ItemsSource
=
ItemsSource
.
Where
(
a
=>
!
string
.
IsNullOrEmpty
(
a
.
FilePath
)&&
Convert
.
ToString
(
a
.
Header
)!=
"保存布局"
).
ToObservableCollection
();
managerLayout
.
ShowDialog
();
}
#
endregion
#
endregion
#
region
AboutCommand
--
关于命令
...
...
VIZ.Package.Module/Main/ViewModel/MainViewModel.cs
View file @
608a27bc
using
DevExpress.Xpf.Docking
;
using
DevExpress.Xpf.Core
;
using
DevExpress.Xpf.Docking
;
using
Gma.System.MouseKeyHook
;
using
log4net
;
using
Microsoft.Win32
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
System.Windows.Shapes
;
using
VIZ.Framework.Common
;
using
VIZ.Framework.Core
;
using
VIZ.Package.Domain
;
...
...
@@ -312,31 +316,57 @@ namespace VIZ.Package.Module
}
const
string
filter
=
"Configuration (*.xml)|*.xml|All files (*.*)|*.*"
;
//
const string filter = "Configuration (*.xml)|*.xml|All files (*.*)|*.*";
public
void
SaveLayout1
()
/// <summary>
/// 导出窗口布局
/// </summary>
/// <param name="param"></param>
public
void
ExportLayout
(
string
param
)
{
MainView
view
=
this
.
GetView
<
MainView
>();
if
(
view
==
null
)
return
;
OpenFileDialog
openFileDialog
=
new
OpenFileDialog
()
{
Filter
=
filter
};
var
openResult
=
openFileDialog
.
ShowDialog
();
if
(
openResult
.
HasValue
&&
openResult
.
Value
)
view
.
dockLayoutManager
.
RestoreLayoutFromXml
(
openFileDialog
.
FileName
);
//SaveFileDialog saveFileDialog = new SaveFileDialog() { Filter = filter }; //RestoreLayoutFromXml
//var saveResult = saveFileDialog.ShowDialog();
//if (saveResult.HasValue && saveResult.Value)
// view.dockLayoutManager.SaveLayoutToXml(saveFileDialog.FileName);
SaveLayoutView
saveLayout
=
new
SaveLayoutView
();
SaveLayoutViewModel
vm
=
saveLayout
.
DataContext
as
SaveLayoutViewModel
;
vm
.
TitleName
=
"保存窗口布局"
;
vm
.
view
=
view
;
// string createPath = "";
//createPath = System.IO.Path.Combine(param, vm.FolderName + ".xml");
vm
.
createPath
=
param
;
saveLayout
.
ShowDialog
();
}
public
void
LoadLayout1
()
/// <summary>
/// 导入窗体布局
/// </summary>
/// <param name="param"></param>
public
void
ImportLayout
(
string
param
)
{
MainView
view
=
this
.
GetView
<
MainView
>();
if
(
view
==
null
)
return
;
SaveFileDialog
saveFileDialog
=
new
SaveFileDialog
()
{
Filter
=
filter
};
var
saveResult
=
saveFileDialog
.
ShowDialog
();
if
(
saveResult
.
HasValue
&&
saveResult
.
Value
)
view
.
dockLayoutManager
.
SaveLayoutToXml
(
saveFileDialog
.
FileName
);
if
(
File
.
Exists
(
param
))
{
view
.
dockLayoutManager
.
RestoreLayoutFromXml
(
param
);
}
}
}
}
VIZ.Package.Module/Main/ViewModel/ManagerLayoutViewModel.cs
0 → 100644
View file @
608a27bc
using
DevExpress.Xpf.Core
;
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Core
;
using
VIZ.Package.Domain
;
using
VIZ.Package.Domain.Model
;
using
VIZ.Package.Service
;
using
VIZ.Package.Storage
;
using
static
System
.
Net
.
WebRequestMethods
;
using
File
=
System
.
IO
.
File
;
namespace
VIZ.Package.Module
{
/// <summary>
/// 管理布局菜单实体类
/// </summary>
public
class
ManagerLayoutViewModel
:
ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private
readonly
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
ManagerLayoutViewModel
));
//获取topViewService服务
//IMainTopViewService service;
public
ManagerLayoutViewModel
()
{
//service = ApplicationDomainEx.ServiceManager.GetService<IMainTopViewService>(ViewServiceKeys.MAIN_TOPVIEW_SERVICE);
// itemsSource = service.ItemsSource.Where(a=> !string.IsNullOrEmpty(a.FilePath)).ToObservableCollection();
//初始化命令
this
.
ReNameCommand
=
new
VCommand
(
this
.
ReName
);
this
.
DeleteCommand
=
new
VCommand
(
this
.
Delete
);
this
.
CloseCommand
=
new
VCommand
(
this
.
Close
);
}
/// <summary>
/// 操作日志服务
/// </summary>
private
RecordLogService
recordLogService
=
new
RecordLogService
();
#
region
视图集合
/// <summary>
/// 选中视图集合
/// </summary>
private
MenuItemModel
selectItem
;
public
MenuItemModel
SelectItem
{
get
{
return
selectItem
;
}
set
{
selectItem
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
SelectItem
));
}
}
/// <summary>
/// 视图项的集合
/// </summary>
private
ObservableCollection
<
MenuItemModel
>
itemsSource
;
/// <summary>
/// 视图项
/// </summary>
public
ObservableCollection
<
MenuItemModel
>
ItemsSource
{
get
{
return
itemsSource
;
}
set
{
itemsSource
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
ItemsSource
));
}
}
#
endregion
#
region
Command
命令
/// <summary>
/// 重命名命令
/// </summary>
public
VCommand
ReNameCommand
{
get
;
set
;
}
private
void
ReName
()
{
if
(
selectItem
==
null
)
return
;
this
.
recordLogService
.
AppendLog
(
ApplicationConstants
.
APPLICATION_GROUP_NAME
,
RecordLogOperate
.
Operate
,
RecordLogTrigger
.
Human
,
"重命名布局"
);
SaveLayoutView
saveLayout
=
new
SaveLayoutView
();
SaveLayoutViewModel
vm
=
saveLayout
.
DataContext
as
SaveLayoutViewModel
;
vm
.
TitleName
=
"重命名窗口布局"
;
vm
.
FolderName
=
SelectItem
.
Header
.
ToString
();
vm
.
SelectItem
=
SelectItem
;
vm
.
ItemsSource
=
ItemsSource
;
saveLayout
.
ShowDialog
();
}
/// <summary>
/// 删除命令
/// </summary>
public
VCommand
DeleteCommand
{
get
;
set
;
}
private
void
Delete
()
{
if
(
SelectItem
==
null
)
return
;
this
.
recordLogService
.
AppendLog
(
ApplicationConstants
.
APPLICATION_GROUP_NAME
,
RecordLogOperate
.
Operate
,
RecordLogTrigger
.
Human
,
"删除布局"
);
if
(
DXMessageBox
.
Show
(
"是否替确定要删除布局 "
+
SelectItem
.
Header
,
"提示"
,
System
.
Windows
.
MessageBoxButton
.
YesNo
)
==
System
.
Windows
.
MessageBoxResult
.
Yes
)
{
MenuItemModel
tempSelectItem
=
SelectItem
;
if
(
File
.
Exists
(
SelectItem
.
FilePath
))
{
File
.
Delete
(
SelectItem
.
FilePath
);
ItemsSource
.
Remove
(
SelectItem
);
IMainTopViewService
service
=
ApplicationDomainEx
.
ServiceManager
.
GetService
<
IMainTopViewService
>(
ViewServiceKeys
.
MAIN_TOPVIEW_SERVICE
);
service
.
ItemsSource
.
Remove
(
tempSelectItem
);
}
}
}
/// <summary>
/// 关闭命令
/// </summary>
public
VCommand
CloseCommand
{
get
;
set
;
}
private
void
Close
()
{
ManagerLayoutView
view
=
this
.
GetView
<
ManagerLayoutView
>();
if
(
view
==
null
)
return
;
view
.
Close
();
}
#
endregion
}
}
VIZ.Package.Module/Main/ViewModel/SaveLayoutViewModel.cs
0 → 100644
View file @
608a27bc
using
DevExpress.Xpf.Core
;
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Core
;
using
VIZ.Package.Domain
;
using
VIZ.Package.Domain.Model
;
namespace
VIZ.Package.Module
{
public
class
SaveLayoutViewModel
:
ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
CreateFolderViewModel
));
/// <summary>
/// 初始化
/// </summary>
public
SaveLayoutViewModel
()
{
EnterCommand
=
new
VCommand
(
Enter
);
CancelCommand
=
new
VCommand
(
Cancel
);
}
public
MainView
view
{
get
;
set
;
}
public
string
createPath
{
get
;
set
;
}
/// <summary>
/// 窗口布局名称
/// </summary>
private
string
titleName
;
public
string
TitleName
{
get
{
return
titleName
;
}
set
{
titleName
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
TitleName
));
}
}
private
string
folderName
;
/// <summary>
/// 文件夹名称
/// </summary>
public
string
FolderName
{
get
{
return
folderName
;
}
set
{
folderName
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
FolderName
));
}
}
private
bool
isEnter
;
/// <summary>
/// 是否确定
/// </summary>
public
bool
IsEnter
{
get
{
return
isEnter
;
}
set
{
isEnter
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
IsEnter
));
}
}
public
VCommand
EnterCommand
{
get
;
set
;
}
public
VCommand
CancelCommand
{
get
;
set
;
}
/// <summary>
/// 确定
/// </summary>
private
void
Enter
()
{
if
(
string
.
IsNullOrWhiteSpace
(
this
.
FolderName
))
{
DXMessageBox
.
Show
(
"请输入文件名"
);
return
;
}
//this.IsEnter = true;
//this.GetWindow()?.Close();
if
(
TitleName
==
"保存窗口布局"
)
{
SaveLayout
();
}
else
if
(
TitleName
==
"重命名窗口布局"
)
{
ReName
();
}
}
private
void
SaveLayout
()
{
createPath
=
System
.
IO
.
Path
.
Combine
(
createPath
,
FolderName
+
".xml"
);
//判断此文件路径是否存在不存在就创建
string
dir
=
System
.
IO
.
Path
.
GetDirectoryName
(
createPath
);
if
(!
System
.
IO
.
Directory
.
Exists
(
dir
))
{
System
.
IO
.
Directory
.
CreateDirectory
(
dir
);
}
if
(
File
.
Exists
(
createPath
))
{
if
(
DXMessageBox
.
Show
(
"是否替换当前存在布局"
,
"提示"
,
System
.
Windows
.
MessageBoxButton
.
YesNo
)
==
System
.
Windows
.
MessageBoxResult
.
Yes
)
{
view
.
dockLayoutManager
.
SaveLayoutToXml
(
createPath
);
this
.
GetWindow
()?.
Close
();
}
}
else
{
view
.
dockLayoutManager
.
SaveLayoutToXml
(
createPath
);
IMainTopViewService
service
=
ApplicationDomainEx
.
ServiceManager
.
GetService
<
IMainTopViewService
>(
ViewServiceKeys
.
MAIN_TOPVIEW_SERVICE
);
service
.
ItemsSource
.
Add
(
new
Domain
.
Model
.
MenuItemModel
()
{
Header
=
FolderName
,
Type
=
MenuItemType
.
Button
,
FilePath
=
createPath
,
Command
=
service
.
ImportLayoutCommand
});
this
.
GetWindow
()?.
Close
();
}
}
public
MenuItemModel
SelectItem
{
get
;
set
;
}
public
ObservableCollection
<
MenuItemModel
>
ItemsSource
{
get
;
set
;
}
private
void
ReName
()
{
if
(
File
.
Exists
(
SelectItem
.
FilePath
))
{
IMainTopViewService
service
=
ApplicationDomainEx
.
ServiceManager
.
GetService
<
IMainTopViewService
>(
ViewServiceKeys
.
MAIN_TOPVIEW_SERVICE
);
MenuItemModel
tempSelectItem
=
SelectItem
;
//得到没有扩展的文件名称
string
fileName
=
Path
.
GetFileNameWithoutExtension
(
SelectItem
.
FilePath
);
//D:\Projects\VIZ.Package\VIZ.Package\bin\x64\Debug\layout\CBA\556.xml
int
index
=
SelectItem
.
FilePath
.
LastIndexOf
(
"\\"
);
//返回“//”最后一次出现的位置
string
filepath
=
SelectItem
.
FilePath
.
Substring
(
0
,
index
);
string
newFilePath
=
filepath
+
"\\"
+
FolderName
+
".xml"
;
if
(
File
.
Exists
(
newFilePath
))
{
if
(
DXMessageBox
.
Show
(
"是否替换当前存在布局"
,
"提示"
,
System
.
Windows
.
MessageBoxButton
.
YesNo
)
==
System
.
Windows
.
MessageBoxResult
.
Yes
)
{
File
.
Delete
(
newFilePath
);
if
(
System
.
IO
.
File
.
Exists
(
SelectItem
.
FilePath
))
{
FileInfo
fi
=
new
FileInfo
(
SelectItem
.
FilePath
);
fi
.
MoveTo
(
newFilePath
);
}
//文件管理页面对应的移除
ItemsSource
.
Remove
(
SelectItem
);
//视频导航菜单移除
service
.
ItemsSource
.
Remove
(
tempSelectItem
);
this
.
GetWindow
()?.
Close
();
}
}
else
{
if
(
System
.
IO
.
File
.
Exists
(
SelectItem
.
FilePath
))
{
FileInfo
fi
=
new
FileInfo
(
SelectItem
.
FilePath
);
fi
.
MoveTo
(
newFilePath
);
}
SelectItem
.
Header
=
FolderName
;
SelectItem
.
FilePath
=
newFilePath
;
this
.
GetWindow
()?.
Close
();
}
}
}
/// <summary>
/// 取消
/// </summary>
private
void
Cancel
()
{
this
.
IsEnter
=
false
;
this
.
GetWindow
()?.
Close
();
}
}
}
VIZ.Package.Module/VIZ.Package.Module.csproj
View file @
608a27bc
...
...
@@ -156,6 +156,15 @@
<Compile Include="Log\ViewModel\VizCommandWindowModel.cs" />
<Compile Include="Main\Controller\HotkeyController.cs" />
<Compile Include="Main\Core\MainTopViewMenuDataTemplateSelector.cs" />
<Compile Include="Main\Service\IMainTopViewService.cs" />
<Compile Include="Main\ViewModel\ManagerLayoutViewModel.cs" />
<Compile Include="Main\ViewModel\SaveLayoutViewModel.cs" />
<Compile Include="Main\View\ManagerLayoutView.xaml.cs">
<DependentUpon>ManagerLayoutView.xaml</DependentUpon>
</Compile>
<Compile Include="Main\View\SaveLayoutView.xaml.cs">
<DependentUpon>SaveLayoutView.xaml</DependentUpon>
</Compile>
<Compile Include="PageCommand\Controller\PageCommandController.cs" />
<Compile Include="PageCommand\PageCommandLifeCycle.cs" />
<Compile Include="PageCommand\Service\IPageCommandService.cs" />
...
...
@@ -503,6 +512,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Main\View\ManagerLayoutView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Main\View\SaveLayoutView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PageCommand\View\PageCommandView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
...
...
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