Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
3b7b11a9
Commit
3b7b11a9
authored
May 27, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 layout的多个备份,直接保存整个layout文件夹
parent
715ebee6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
55 deletions
+93
-55
WdLoadFile.xaml.cs
MultiLayout/MainEdit/WdLoadFile.xaml.cs
+90
-52
WdSaveFile.xaml
MultiLayout/MainEdit/WdSaveFile.xaml
+3
-3
No files found.
MultiLayout/MainEdit/WdLoadFile.xaml.cs
View file @
3b7b11a9
...
...
@@ -32,82 +32,120 @@ namespace MultiLayout.MainEdit
{
this
.
listview_profile
.
ItemsSource
=
mList
;
//查找
layout/graphcustoms 下的全部文件
名
string
dirPath
=
System
.
IO
.
Path
.
Combine
(
FlyLayout
.
BasePath
,
"graphcustoms
"
);
//查找
default/layout.default 下的全部文件夹
名
string
dirPath
=
System
.
IO
.
Path
.
Combine
(
"default"
,
"layout.default
"
);
DirectoryInfo
directoryInfo
=
new
DirectoryInfo
(
dirPath
);
if
(!
directoryInfo
.
Exists
)
{
return
;
}
var
files
=
directoryInfo
.
GetFiles
(
"*.json"
);
foreach
(
var
file
in
files
)
{
mList
.
Add
(
System
.
IO
.
Path
.
GetFileNameWithoutExtension
(
file
.
Name
));
var
directoryInfos
=
directoryInfo
.
GetDirectories
();
foreach
(
var
dirInfo
in
directoryInfos
)
{
//检查这个文件夹是否正确
string
filePath
=
System
.
IO
.
Path
.
Combine
(
dirInfo
.
FullName
,
"graphcustom.json"
);
if
(
File
.
Exists
(
filePath
))
{
//正确
mList
.
Add
(
dirInfo
.
Name
);
}
}
}
private
void
button_read_Click
(
object
sender
,
RoutedEventArgs
e
)
{
if
(
listview_profile
.
SelectedItem
!=
null
)
{
string
strTipRebootForExecute
=
"需要重启,才能生效"
;
if
(
FLY
.
ControlLibrary
.
MyMessageBox
.
Show
(
strTipRebootForExecute
)
==
true
)
{
string
filename
=
listview_profile
.
SelectedItem
as
string
;
string
filePath
=
System
.
IO
.
Path
.
Combine
(
FlyLayout
.
BasePath
,
"graphcustoms"
,
filename
+
".json"
);
string
destPath
=
System
.
IO
.
Path
.
Combine
(
FlyLayout
.
BasePath
,
"graphcustom.json"
);
File
.
Copy
(
filePath
,
destPath
,
true
);
System
.
Windows
.
Forms
.
Application
.
Restart
();
Application
.
Current
.
Shutdown
();
}
if
(
listview_profile
.
SelectedItem
==
null
)
return
;
string
strTipRebootForExecute
=
"需要重启,才能生效"
;
if
(
FLY
.
ControlLibrary
.
MyMessageBox
.
Show
(
strTipRebootForExecute
)
!=
true
)
return
;
string
dirname
=
listview_profile
.
SelectedItem
as
string
;
string
srcDirPath
=
System
.
IO
.
Path
.
Combine
(
"default"
,
"layout.default"
,
dirname
);
//把 srcDirPath 下的全部文件 复制到 FlyLayout.BasePath 下
DirectoryInfo
srcDirInfo
=
new
DirectoryInfo
(
srcDirPath
);
var
fileInfos
=
srcDirInfo
.
GetFiles
();
foreach
(
var
fileInfo
in
fileInfos
)
{
string
filePath
=
fileInfo
.
FullName
;
string
destPath
=
System
.
IO
.
Path
.
Combine
(
FlyLayout
.
BasePath
,
fileInfo
.
Name
);
File
.
Copy
(
filePath
,
destPath
,
true
);
}
System
.
Windows
.
Forms
.
Application
.
Restart
();
Application
.
Current
.
Shutdown
();
}
private
void
button_del_Click
(
object
sender
,
RoutedEventArgs
e
)
{
if
(
listview_profile
.
SelectedItem
!=
null
)
{
string
filename
=
listview_profile
.
SelectedItem
as
string
;
string
filePath
=
System
.
IO
.
Path
.
Combine
(
FlyLayout
.
BasePath
,
"graphcustoms"
,
filename
+
".json"
);
File
.
Delete
(
filePath
);
mList
.
Remove
(
filename
);
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"删除成功"
,
filename
,
TimeSpan
.
FromSeconds
(
2
));
}
if
(
listview_profile
.
SelectedItem
==
null
)
return
;
string
dirname
=
listview_profile
.
SelectedItem
as
string
;
if
(
FLY
.
ControlLibrary
.
MyMessageBox
.
Show
(
$"将要删除
{
dirname
}
,是否确定?"
)
!=
true
)
return
;
string
srcDirPath
=
System
.
IO
.
Path
.
Combine
(
"default"
,
"layout.default"
,
dirname
);
Directory
.
Delete
(
srcDirPath
,
true
);
mList
.
Remove
(
dirname
);
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"删除成功"
,
dirname
,
TimeSpan
.
FromSeconds
(
2
));
}
private
void
button_save_Click
(
object
sender
,
RoutedEventArgs
e
)
{
WdSaveFile
w
=
new
WdSaveFile
();
if
(
listview_profile
.
SelectedItem
!=
null
)
w
.
FileName
=
listview_profile
.
SelectedItem
as
string
;
w
.
Owner
=
FLY
.
ControlLibrary
.
COMMON
.
GetWindow
(
this
);
if
(
w
.
ShowDialog
()
==
true
)
{
if
(
mList
.
Contains
(
w
.
FileName
))
{
if
(
FLY
.
ControlLibrary
.
MyMessageBox
.
Show
(
"文件已经存在,是否覆盖?"
)!=
true
)
{
return
;
}
}
string
dirPath
=
System
.
IO
.
Path
.
Combine
(
FlyLayout
.
BasePath
,
"graphcustoms"
);
if
(!
Directory
.
Exists
(
dirPath
))
Directory
.
CreateDirectory
(
dirPath
);
string
filename
=
w
.
FileName
;
string
destPath
=
System
.
IO
.
Path
.
Combine
(
FlyLayout
.
BasePath
,
"graphcustoms"
,
filename
+
".json"
);
string
srcPath
=
System
.
IO
.
Path
.
Combine
(
FlyLayout
.
BasePath
,
"graphcustom.json"
);
File
.
Copy
(
srcPath
,
destPath
,
true
);
if
(!
mList
.
Contains
(
w
.
FileName
))
{
mList
.
Add
(
filename
);
}
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"保存成功"
,
filename
,
TimeSpan
.
FromSeconds
(
2
));
if
(
w
.
ShowDialog
()
!=
true
)
return
;
if
(
mList
.
Contains
(
w
.
FileName
))
{
if
(
FLY
.
ControlLibrary
.
MyMessageBox
.
Show
(
"布局文件已经存在,是否覆盖?"
)!=
true
)
return
;
}
string
dirname
=
w
.
FileName
;
string
destDirPath
=
System
.
IO
.
Path
.
Combine
(
"default"
,
"layout.default"
,
dirname
);
string
srcDirPath
=
FlyLayout
.
BasePath
;
if
(!
Directory
.
Exists
(
destDirPath
))
Directory
.
CreateDirectory
(
destDirPath
);
//把 srcDirPath 下的全部文件 复制到 destDirPath 下
DirectoryInfo
srcDirInfo
=
new
DirectoryInfo
(
srcDirPath
);
var
fileInfos
=
srcDirInfo
.
GetFiles
();
foreach
(
var
fileInfo
in
fileInfos
)
{
string
filePath
=
fileInfo
.
FullName
;
string
destPath
=
System
.
IO
.
Path
.
Combine
(
destDirPath
,
fileInfo
.
Name
);
File
.
Copy
(
filePath
,
destPath
,
true
);
}
if
(!
mList
.
Contains
(
w
.
FileName
))
mList
.
Add
(
w
.
FileName
);
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"保存成功"
,
w
.
FileName
,
TimeSpan
.
FromSeconds
(
2
));
}
}
}
MultiLayout/MainEdit/WdSaveFile.xaml
View file @
3b7b11a9
...
...
@@ -16,9 +16,9 @@
<StackPanel Margin="5,20">
<StackPanel Grid.Column="1" Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="请输入布局名称:" />
<
StackPanel Orientation="Horizontal"
>
<TextBox Style="{StaticResource
ResourceKey=
TextBoxStyle_FieldContent}" Name="textbox_productname" Tag="Full" MinWidth="300"/>
</
StackPanel
>
<
Viewbox
>
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Name="textbox_productname" Tag="Full" MinWidth="300"/>
</
Viewbox
>
</StackPanel>
<StackPanel Orientation="Horizontal"></StackPanel>
<Button Content="保存" Style="{StaticResource ButtonStyle2}" Margin="5" Width="auto" Click="button_save_Click" />
...
...
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