Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
DataEditorX
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
railboo
DataEditorX
Commits
e72f147e
Commit
e72f147e
authored
Oct 21, 2017
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert
parent
716d69f1
Changes
45
Hide whitespace changes
Inline
Side-by-side
Showing
45 changed files
with
5847 additions
and
5847 deletions
+5847
-5847
DataEditorX/CodeEditForm.Designer.cs
DataEditorX/CodeEditForm.Designer.cs
+254
-254
DataEditorX/CodeEditForm.cs
DataEditorX/CodeEditForm.cs
+446
-446
DataEditorX/Common/Area.cs
DataEditorX/Common/Area.cs
+29
-29
DataEditorX/Common/CheckUpdate.cs
DataEditorX/Common/CheckUpdate.cs
+2
-2
DataEditorX/Common/ConfHelper.cs
DataEditorX/Common/ConfHelper.cs
+115
-115
DataEditorX/Common/MyBitmap.cs
DataEditorX/Common/MyBitmap.cs
+144
-144
DataEditorX/Common/MyPath.cs
DataEditorX/Common/MyPath.cs
+74
-74
DataEditorX/Common/User32.cs
DataEditorX/Common/User32.cs
+35
-35
DataEditorX/Common/XMLReader.cs
DataEditorX/Common/XMLReader.cs
+44
-44
DataEditorX/Common/ZipStorer.cs
DataEditorX/Common/ZipStorer.cs
+754
-754
DataEditorX/Config/CodeConfig.cs
DataEditorX/Config/CodeConfig.cs
+193
-193
DataEditorX/Config/DataConfig.cs
DataEditorX/Config/DataConfig.cs
+75
-75
DataEditorX/Config/DataManager.cs
DataEditorX/Config/DataManager.cs
+124
-124
DataEditorX/Config/ImageSet.cs
DataEditorX/Config/ImageSet.cs
+45
-45
DataEditorX/Config/MyConfig.cs
DataEditorX/Config/MyConfig.cs
+322
-322
DataEditorX/Config/YgoPath.cs
DataEditorX/Config/YgoPath.cs
+36
-36
DataEditorX/Controls/DFlowLayoutPanel.cs
DataEditorX/Controls/DFlowLayoutPanel.cs
+10
-10
DataEditorX/Controls/DListBox.cs
DataEditorX/Controls/DListBox.cs
+10
-10
DataEditorX/Controls/DListView.cs
DataEditorX/Controls/DListView.cs
+10
-10
DataEditorX/Controls/FastColoredTextBoxEx.cs
DataEditorX/Controls/FastColoredTextBoxEx.cs
+26
-26
DataEditorX/Controls/History.cs
DataEditorX/Controls/History.cs
+139
-139
DataEditorX/Controls/IEditForm.cs
DataEditorX/Controls/IEditForm.cs
+15
-15
DataEditorX/Controls/IMainForm.cs
DataEditorX/Controls/IMainForm.cs
+8
-8
DataEditorX/Core/Card.cs
DataEditorX/Core/Card.cs
+141
-141
DataEditorX/Core/CardEdit.cs
DataEditorX/Core/CardEdit.cs
+13
-13
DataEditorX/Core/DataBase.cs
DataEditorX/Core/DataBase.cs
+16
-16
DataEditorX/Core/IDataForm.cs
DataEditorX/Core/IDataForm.cs
+15
-15
DataEditorX/Core/Info/CardAttribute.cs
DataEditorX/Core/Info/CardAttribute.cs
+34
-34
DataEditorX/Core/Info/CardRace.cs
DataEditorX/Core/Info/CardRace.cs
+57
-57
DataEditorX/Core/Info/CardRule.cs
DataEditorX/Core/Info/CardRule.cs
+13
-13
DataEditorX/Core/Info/CardType.cs
DataEditorX/Core/Info/CardType.cs
+28
-28
DataEditorX/Core/LuaFunction.cs
DataEditorX/Core/LuaFunction.cs
+59
-59
DataEditorX/Core/Mse/MSECons.cs
DataEditorX/Core/Mse/MSECons.cs
+67
-67
DataEditorX/Core/Mse/MseMaker.cs
DataEditorX/Core/Mse/MseMaker.cs
+12
-12
DataEditorX/Core/MyTask.cs
DataEditorX/Core/MyTask.cs
+20
-20
DataEditorX/Core/TaskHelper.cs
DataEditorX/Core/TaskHelper.cs
+1
-1
DataEditorX/Core/YGOUtil.cs
DataEditorX/Core/YGOUtil.cs
+199
-199
DataEditorX/DataEditForm.Designer.cs
DataEditorX/DataEditForm.Designer.cs
+1317
-1317
DataEditorX/DataEditForm.cs
DataEditorX/DataEditForm.cs
+43
-43
DataEditorX/Language/LMsg.cs
DataEditorX/Language/LMsg.cs
+77
-77
DataEditorX/Language/LanguageHelper.cs
DataEditorX/Language/LanguageHelper.cs
+266
-266
DataEditorX/Language/MyMsg.cs
DataEditorX/Language/MyMsg.cs
+62
-62
DataEditorX/MainForm.Designer.cs
DataEditorX/MainForm.Designer.cs
+2
-2
DataEditorX/MainForm.cs
DataEditorX/MainForm.cs
+456
-456
DataEditorX/Program.cs
DataEditorX/Program.cs
+39
-39
No files found.
DataEditorX/CodeEditForm.Designer.cs
View file @
e72f147e
...
@@ -35,257 +35,257 @@ protected override void Dispose(bool disposing)
...
@@ -35,257 +35,257 @@ protected override void Dispose(bool disposing)
/// </summary>
/// </summary>
private
void
InitializeComponent
()
private
void
InitializeComponent
()
{
{
this
.
components
=
new
System
.
ComponentModel
.
Container
();
this
.
components
=
new
System
.
ComponentModel
.
Container
();
System
.
ComponentModel
.
ComponentResourceManager
resources
=
new
System
.
ComponentModel
.
ComponentResourceManager
(
typeof
(
CodeEditForm
));
System
.
ComponentModel
.
ComponentResourceManager
resources
=
new
System
.
ComponentModel
.
ComponentResourceManager
(
typeof
(
CodeEditForm
));
this
.
mainMenu
=
new
System
.
Windows
.
Forms
.
MenuStrip
();
this
.
mainMenu
=
new
System
.
Windows
.
Forms
.
MenuStrip
();
this
.
menuitem_file
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_file
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_open
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_open
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_save
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_save
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_saveas
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_saveas
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
toolStripSeparator1
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
toolStripSeparator1
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
menuitem_quit
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_quit
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_setting
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_setting
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_showmap
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_showmap
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_showinput
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_showinput
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_find
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_find
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_replace
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_replace
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_setcard
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_setcard
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_help
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_help
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_about
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
menuitem_about
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
tb_input
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tb_input
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
backgroundWorker1
=
new
System
.
ComponentModel
.
BackgroundWorker
();
this
.
backgroundWorker1
=
new
System
.
ComponentModel
.
BackgroundWorker
();
this
.
toolTip1
=
new
System
.
Windows
.
Forms
.
ToolTip
(
this
.
components
);
this
.
toolTip1
=
new
System
.
Windows
.
Forms
.
ToolTip
(
this
.
components
);
this
.
fctb
=
new
FastColoredTextBoxNS
.
FastColoredTextBoxEx
();
this
.
fctb
=
new
FastColoredTextBoxNS
.
FastColoredTextBoxEx
();
this
.
documentMap1
=
new
FastColoredTextBoxNS
.
DocumentMap
();
this
.
documentMap1
=
new
FastColoredTextBoxNS
.
DocumentMap
();
this
.
mainMenu
.
SuspendLayout
();
this
.
mainMenu
.
SuspendLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
fctb
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
fctb
)).
BeginInit
();
this
.
SuspendLayout
();
this
.
SuspendLayout
();
//
//
// mainMenu
// mainMenu
//
//
this
.
mainMenu
.
Items
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
mainMenu
.
Items
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
menuitem_file
,
this
.
menuitem_file
,
this
.
menuitem_setting
,
this
.
menuitem_setting
,
this
.
menuitem_help
});
this
.
menuitem_help
});
this
.
mainMenu
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
mainMenu
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
mainMenu
.
Name
=
"mainMenu"
;
this
.
mainMenu
.
Name
=
"mainMenu"
;
this
.
mainMenu
.
Size
=
new
System
.
Drawing
.
Size
(
705
,
25
);
this
.
mainMenu
.
Size
=
new
System
.
Drawing
.
Size
(
705
,
25
);
this
.
mainMenu
.
TabIndex
=
0
;
this
.
mainMenu
.
TabIndex
=
0
;
this
.
mainMenu
.
Text
=
"mainMenu"
;
this
.
mainMenu
.
Text
=
"mainMenu"
;
//
//
// menuitem_file
// menuitem_file
//
//
this
.
menuitem_file
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
menuitem_file
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
menuitem_open
,
this
.
menuitem_open
,
this
.
menuitem_save
,
this
.
menuitem_save
,
this
.
menuitem_saveas
,
this
.
menuitem_saveas
,
this
.
toolStripSeparator1
,
this
.
toolStripSeparator1
,
this
.
menuitem_quit
});
this
.
menuitem_quit
});
this
.
menuitem_file
.
Name
=
"menuitem_file"
;
this
.
menuitem_file
.
Name
=
"menuitem_file"
;
this
.
menuitem_file
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
21
);
this
.
menuitem_file
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
21
);
this
.
menuitem_file
.
Text
=
"File(&F)"
;
this
.
menuitem_file
.
Text
=
"File(&F)"
;
//
//
// menuitem_open
// menuitem_open
//
//
this
.
menuitem_open
.
Name
=
"menuitem_open"
;
this
.
menuitem_open
.
Name
=
"menuitem_open"
;
this
.
menuitem_open
.
ShortcutKeys
=
((
System
.
Windows
.
Forms
.
Keys
)((
System
.
Windows
.
Forms
.
Keys
.
Control
|
System
.
Windows
.
Forms
.
Keys
.
O
)));
this
.
menuitem_open
.
ShortcutKeys
=
((
System
.
Windows
.
Forms
.
Keys
)((
System
.
Windows
.
Forms
.
Keys
.
Control
|
System
.
Windows
.
Forms
.
Keys
.
O
)));
this
.
menuitem_open
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
22
);
this
.
menuitem_open
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
22
);
this
.
menuitem_open
.
Text
=
"Open"
;
this
.
menuitem_open
.
Text
=
"Open"
;
this
.
menuitem_open
.
Click
+=
new
System
.
EventHandler
(
this
.
Menuitem_openClick
);
this
.
menuitem_open
.
Click
+=
new
System
.
EventHandler
(
this
.
Menuitem_openClick
);
//
//
// menuitem_save
// menuitem_save
//
//
this
.
menuitem_save
.
Name
=
"menuitem_save"
;
this
.
menuitem_save
.
Name
=
"menuitem_save"
;
this
.
menuitem_save
.
ShortcutKeys
=
((
System
.
Windows
.
Forms
.
Keys
)((
System
.
Windows
.
Forms
.
Keys
.
Control
|
System
.
Windows
.
Forms
.
Keys
.
S
)));
this
.
menuitem_save
.
ShortcutKeys
=
((
System
.
Windows
.
Forms
.
Keys
)((
System
.
Windows
.
Forms
.
Keys
.
Control
|
System
.
Windows
.
Forms
.
Keys
.
S
)));
this
.
menuitem_save
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
22
);
this
.
menuitem_save
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
22
);
this
.
menuitem_save
.
Text
=
"Save"
;
this
.
menuitem_save
.
Text
=
"Save"
;
this
.
menuitem_save
.
Click
+=
new
System
.
EventHandler
(
this
.
SaveToolStripMenuItemClick
);
this
.
menuitem_save
.
Click
+=
new
System
.
EventHandler
(
this
.
SaveToolStripMenuItemClick
);
//
//
// menuitem_saveas
// menuitem_saveas
//
//
this
.
menuitem_saveas
.
Name
=
"menuitem_saveas"
;
this
.
menuitem_saveas
.
Name
=
"menuitem_saveas"
;
this
.
menuitem_saveas
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
22
);
this
.
menuitem_saveas
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
22
);
this
.
menuitem_saveas
.
Text
=
"Save As"
;
this
.
menuitem_saveas
.
Text
=
"Save As"
;
this
.
menuitem_saveas
.
Click
+=
new
System
.
EventHandler
(
this
.
SaveAsToolStripMenuItemClick
);
this
.
menuitem_saveas
.
Click
+=
new
System
.
EventHandler
(
this
.
SaveAsToolStripMenuItemClick
);
//
//
// toolStripSeparator1
// toolStripSeparator1
//
//
this
.
toolStripSeparator1
.
Name
=
"toolStripSeparator1"
;
this
.
toolStripSeparator1
.
Name
=
"toolStripSeparator1"
;
this
.
toolStripSeparator1
.
Size
=
new
System
.
Drawing
.
Size
(
152
,
6
);
this
.
toolStripSeparator1
.
Size
=
new
System
.
Drawing
.
Size
(
152
,
6
);
//
//
// menuitem_quit
// menuitem_quit
//
//
this
.
menuitem_quit
.
Name
=
"menuitem_quit"
;
this
.
menuitem_quit
.
Name
=
"menuitem_quit"
;
this
.
menuitem_quit
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
22
);
this
.
menuitem_quit
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
22
);
this
.
menuitem_quit
.
Text
=
"Quit"
;
this
.
menuitem_quit
.
Text
=
"Quit"
;
this
.
menuitem_quit
.
Click
+=
new
System
.
EventHandler
(
this
.
QuitToolStripMenuItemClick
);
this
.
menuitem_quit
.
Click
+=
new
System
.
EventHandler
(
this
.
QuitToolStripMenuItemClick
);
//
//
// menuitem_setting
// menuitem_setting
//
//
this
.
menuitem_setting
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
menuitem_setting
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
menuitem_showmap
,
this
.
menuitem_showmap
,
this
.
menuitem_showinput
,
this
.
menuitem_showinput
,
this
.
menuitem_find
,
this
.
menuitem_find
,
this
.
menuitem_replace
,
this
.
menuitem_replace
,
this
.
menuitem_setcard
});
this
.
menuitem_setcard
});
this
.
menuitem_setting
.
Name
=
"menuitem_setting"
;
this
.
menuitem_setting
.
Name
=
"menuitem_setting"
;
this
.
menuitem_setting
.
Size
=
new
System
.
Drawing
.
Size
(
67
,
21
);
this
.
menuitem_setting
.
Size
=
new
System
.
Drawing
.
Size
(
67
,
21
);
this
.
menuitem_setting
.
Text
=
"Tools(&S)"
;
this
.
menuitem_setting
.
Text
=
"Tools(&S)"
;
//
//
// menuitem_showmap
// menuitem_showmap
//
//
this
.
menuitem_showmap
.
Name
=
"menuitem_showmap"
;
this
.
menuitem_showmap
.
Name
=
"menuitem_showmap"
;
this
.
menuitem_showmap
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_showmap
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_showmap
.
Text
=
"Show/Hide Map"
;
this
.
menuitem_showmap
.
Text
=
"Show/Hide Map"
;
this
.
menuitem_showmap
.
Click
+=
new
System
.
EventHandler
(
this
.
ShowMapToolStripMenuItemClick
);
this
.
menuitem_showmap
.
Click
+=
new
System
.
EventHandler
(
this
.
ShowMapToolStripMenuItemClick
);
//
//
// menuitem_showinput
// menuitem_showinput
//
//
this
.
menuitem_showinput
.
Checked
=
true
;
this
.
menuitem_showinput
.
Checked
=
true
;
this
.
menuitem_showinput
.
CheckState
=
System
.
Windows
.
Forms
.
CheckState
.
Checked
;
this
.
menuitem_showinput
.
CheckState
=
System
.
Windows
.
Forms
.
CheckState
.
Checked
;
this
.
menuitem_showinput
.
Name
=
"menuitem_showinput"
;
this
.
menuitem_showinput
.
Name
=
"menuitem_showinput"
;
this
.
menuitem_showinput
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_showinput
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_showinput
.
Text
=
"Show/Hide InputBox"
;
this
.
menuitem_showinput
.
Text
=
"Show/Hide InputBox"
;
this
.
menuitem_showinput
.
Click
+=
new
System
.
EventHandler
(
this
.
Menuitem_showinputClick
);
this
.
menuitem_showinput
.
Click
+=
new
System
.
EventHandler
(
this
.
Menuitem_showinputClick
);
//
//
// menuitem_find
// menuitem_find
//
//
this
.
menuitem_find
.
Name
=
"menuitem_find"
;
this
.
menuitem_find
.
Name
=
"menuitem_find"
;
this
.
menuitem_find
.
ShortcutKeys
=
((
System
.
Windows
.
Forms
.
Keys
)((
System
.
Windows
.
Forms
.
Keys
.
Control
|
System
.
Windows
.
Forms
.
Keys
.
F
)));
this
.
menuitem_find
.
ShortcutKeys
=
((
System
.
Windows
.
Forms
.
Keys
)((
System
.
Windows
.
Forms
.
Keys
.
Control
|
System
.
Windows
.
Forms
.
Keys
.
F
)));
this
.
menuitem_find
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_find
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_find
.
Text
=
"Find"
;
this
.
menuitem_find
.
Text
=
"Find"
;
this
.
menuitem_find
.
Click
+=
new
System
.
EventHandler
(
this
.
Menuitem_findClick
);
this
.
menuitem_find
.
Click
+=
new
System
.
EventHandler
(
this
.
Menuitem_findClick
);
//
//
// menuitem_replace
// menuitem_replace
//
//
this
.
menuitem_replace
.
Name
=
"menuitem_replace"
;
this
.
menuitem_replace
.
Name
=
"menuitem_replace"
;
this
.
menuitem_replace
.
ShortcutKeys
=
((
System
.
Windows
.
Forms
.
Keys
)((
System
.
Windows
.
Forms
.
Keys
.
Control
|
System
.
Windows
.
Forms
.
Keys
.
H
)));
this
.
menuitem_replace
.
ShortcutKeys
=
((
System
.
Windows
.
Forms
.
Keys
)((
System
.
Windows
.
Forms
.
Keys
.
Control
|
System
.
Windows
.
Forms
.
Keys
.
H
)));
this
.
menuitem_replace
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_replace
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_replace
.
Text
=
"Replace"
;
this
.
menuitem_replace
.
Text
=
"Replace"
;
this
.
menuitem_replace
.
Click
+=
new
System
.
EventHandler
(
this
.
Menuitem_replaceClick
);
this
.
menuitem_replace
.
Click
+=
new
System
.
EventHandler
(
this
.
Menuitem_replaceClick
);
//
//
// menuitem_setcard
// menuitem_setcard
//
//
this
.
menuitem_setcard
.
Name
=
"menuitem_setcard"
;
this
.
menuitem_setcard
.
Name
=
"menuitem_setcard"
;
this
.
menuitem_setcard
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_setcard
.
Size
=
new
System
.
Drawing
.
Size
(
195
,
22
);
this
.
menuitem_setcard
.
Text
=
"Set Cards"
;
this
.
menuitem_setcard
.
Text
=
"Set Cards"
;
//
//
// menuitem_help
// menuitem_help
//
//
this
.
menuitem_help
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
menuitem_help
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
menuitem_about
});
this
.
menuitem_about
});
this
.
menuitem_help
.
Name
=
"menuitem_help"
;
this
.
menuitem_help
.
Name
=
"menuitem_help"
;
this
.
menuitem_help
.
Size
=
new
System
.
Drawing
.
Size
(
64
,
21
);
this
.
menuitem_help
.
Size
=
new
System
.
Drawing
.
Size
(
64
,
21
);
this
.
menuitem_help
.
Text
=
"Help(&H)"
;
this
.
menuitem_help
.
Text
=
"Help(&H)"
;
//
//
// menuitem_about
// menuitem_about
//
//
this
.
menuitem_about
.
Name
=
"menuitem_about"
;
this
.
menuitem_about
.
Name
=
"menuitem_about"
;
this
.
menuitem_about
.
Size
=
new
System
.
Drawing
.
Size
(
111
,
22
);
this
.
menuitem_about
.
Size
=
new
System
.
Drawing
.
Size
(
111
,
22
);
this
.
menuitem_about
.
Text
=
"About"
;
this
.
menuitem_about
.
Text
=
"About"
;
this
.
menuitem_about
.
Click
+=
new
System
.
EventHandler
(
this
.
AboutToolStripMenuItemClick
);
this
.
menuitem_about
.
Click
+=
new
System
.
EventHandler
(
this
.
AboutToolStripMenuItemClick
);
//
//
// tb_input
// tb_input
//
//
this
.
tb_input
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Control
;
this
.
tb_input
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Control
;
this
.
tb_input
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
tb_input
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
tb_input
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
394
);
this
.
tb_input
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
394
);
this
.
tb_input
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
tb_input
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
tb_input
.
Name
=
"tb_input"
;
this
.
tb_input
.
Name
=
"tb_input"
;
this
.
tb_input
.
Size
=
new
System
.
Drawing
.
Size
(
514
,
21
);
this
.
tb_input
.
Size
=
new
System
.
Drawing
.
Size
(
514
,
21
);
this
.
tb_input
.
TabIndex
=
1
;
this
.
tb_input
.
TabIndex
=
1
;
this
.
tb_input
.
KeyDown
+=
new
System
.
Windows
.
Forms
.
KeyEventHandler
(
this
.
Tb_inputKeyDown
);
this
.
tb_input
.
KeyDown
+=
new
System
.
Windows
.
Forms
.
KeyEventHandler
(
this
.
Tb_inputKeyDown
);
//
//
// backgroundWorker1
// backgroundWorker1
//
//
this
.
backgroundWorker1
.
DoWork
+=
new
System
.
ComponentModel
.
DoWorkEventHandler
(
this
.
backgroundWorker1_DoWork
);
this
.
backgroundWorker1
.
DoWork
+=
new
System
.
ComponentModel
.
DoWorkEventHandler
(
this
.
backgroundWorker1_DoWork
);
//
//
// fctb
// fctb
//
//
this
.
fctb
.
AutoCompleteBrackets
=
true
;
this
.
fctb
.
AutoCompleteBrackets
=
true
;
this
.
fctb
.
AutoCompleteBracketsList
=
new
char
[]
{
this
.
fctb
.
AutoCompleteBracketsList
=
new
char
[]
{
'('
,
'('
,
')'
,
')'
,
'{'
,
'{'
,
'}'
,
'}'
,
'['
,
'['
,
']'
,
']'
,
'\"'
,
'\"'
,
'\"'
,
'\"'
,
'\''
,
'\''
,
'\''
};
'\''
};
this
.
fctb
.
AutoIndent
=
false
;
this
.
fctb
.
AutoIndent
=
false
;
this
.
fctb
.
AutoIndentChars
=
false
;
this
.
fctb
.
AutoIndentChars
=
false
;
this
.
fctb
.
AutoIndentCharsPatterns
=
"^\\s*[\\w\\.]+(\\s\\w+)?\\s*(?<range>=)\\s*(?<range>.+)"
;
this
.
fctb
.
AutoIndentCharsPatterns
=
"^\\s*[\\w\\.]+(\\s\\w+)?\\s*(?<range>=)\\s*(?<range>.+)"
;
this
.
fctb
.
AutoIndentExistingLines
=
false
;
this
.
fctb
.
AutoIndentExistingLines
=
false
;
this
.
fctb
.
AutoScrollMinSize
=
new
System
.
Drawing
.
Size
(
0
,
22
);
this
.
fctb
.
AutoScrollMinSize
=
new
System
.
Drawing
.
Size
(
0
,
22
);
this
.
fctb
.
BackBrush
=
null
;
this
.
fctb
.
BackBrush
=
null
;
this
.
fctb
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
64
)))),
((
int
)(((
byte
)(
64
)))),
((
int
)(((
byte
)(
64
)))));
this
.
fctb
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
64
)))),
((
int
)(((
byte
)(
64
)))),
((
int
)(((
byte
)(
64
)))));
this
.
fctb
.
BracketsHighlightStrategy
=
FastColoredTextBoxNS
.
BracketsHighlightStrategy
.
Strategy2
;
this
.
fctb
.
BracketsHighlightStrategy
=
FastColoredTextBoxNS
.
BracketsHighlightStrategy
.
Strategy2
;
this
.
fctb
.
CharHeight
=
22
;
this
.
fctb
.
CharHeight
=
22
;
this
.
fctb
.
CharWidth
=
10
;
this
.
fctb
.
CharWidth
=
10
;
this
.
fctb
.
CommentPrefix
=
"--"
;
this
.
fctb
.
CommentPrefix
=
"--"
;
this
.
fctb
.
Cursor
=
System
.
Windows
.
Forms
.
Cursors
.
IBeam
;
this
.
fctb
.
Cursor
=
System
.
Windows
.
Forms
.
Cursors
.
IBeam
;
this
.
fctb
.
DisabledColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
100
)))),
((
int
)(((
byte
)(
180
)))),
((
int
)(((
byte
)(
180
)))),
((
int
)(((
byte
)(
180
)))));
this
.
fctb
.
DisabledColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
100
)))),
((
int
)(((
byte
)(
180
)))),
((
int
)(((
byte
)(
180
)))),
((
int
)(((
byte
)(
180
)))));
this
.
fctb
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
fctb
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
fctb
.
Font
=
new
System
.
Drawing
.
Font
(
"Consolas"
,
14.25F
);
this
.
fctb
.
Font
=
new
System
.
Drawing
.
Font
(
"Consolas"
,
14.25F
);
this
.
fctb
.
ForeColor
=
System
.
Drawing
.
Color
.
GhostWhite
;
this
.
fctb
.
ForeColor
=
System
.
Drawing
.
Color
.
GhostWhite
;
this
.
fctb
.
Hotkeys
=
resources
.
GetString
(
"fctb.Hotkeys"
);
this
.
fctb
.
Hotkeys
=
resources
.
GetString
(
"fctb.Hotkeys"
);
this
.
fctb
.
IndentBackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
64
)))),
((
int
)(((
byte
)(
64
)))),
((
int
)(((
byte
)(
64
)))));
this
.
fctb
.
IndentBackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
64
)))),
((
int
)(((
byte
)(
64
)))),
((
int
)(((
byte
)(
64
)))));
this
.
fctb
.
IsReplaceMode
=
false
;
this
.
fctb
.
IsReplaceMode
=
false
;
this
.
fctb
.
Language
=
FastColoredTextBoxNS
.
Language
.
Lua
;
this
.
fctb
.
Language
=
FastColoredTextBoxNS
.
Language
.
Lua
;
this
.
fctb
.
LeftBracket
=
'('
;
this
.
fctb
.
LeftBracket
=
'('
;
this
.
fctb
.
LeftBracket2
=
'{'
;
this
.
fctb
.
LeftBracket2
=
'{'
;
this
.
fctb
.
LineNumberColor
=
System
.
Drawing
.
Color
.
Gainsboro
;
this
.
fctb
.
LineNumberColor
=
System
.
Drawing
.
Color
.
Gainsboro
;
this
.
fctb
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
25
);
this
.
fctb
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
25
);
this
.
fctb
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
fctb
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
fctb
.
Name
=
"fctb"
;
this
.
fctb
.
Name
=
"fctb"
;
this
.
fctb
.
Paddings
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
fctb
.
Paddings
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
fctb
.
RightBracket
=
')'
;
this
.
fctb
.
RightBracket
=
')'
;
this
.
fctb
.
RightBracket2
=
'}'
;
this
.
fctb
.
RightBracket2
=
'}'
;
this
.
fctb
.
SelectionColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
60
)))),
((
int
)(((
byte
)(
0
)))),
((
int
)(((
byte
)(
0
)))),
((
int
)(((
byte
)(
255
)))));
this
.
fctb
.
SelectionColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
60
)))),
((
int
)(((
byte
)(
0
)))),
((
int
)(((
byte
)(
0
)))),
((
int
)(((
byte
)(
255
)))));
this
.
fctb
.
Size
=
new
System
.
Drawing
.
Size
(
514
,
369
);
this
.
fctb
.
Size
=
new
System
.
Drawing
.
Size
(
514
,
369
);
this
.
fctb
.
TabIndex
=
0
;
this
.
fctb
.
TabIndex
=
0
;
this
.
fctb
.
WordWrap
=
true
;
this
.
fctb
.
WordWrap
=
true
;
this
.
fctb
.
Zoom
=
100
;
this
.
fctb
.
Zoom
=
100
;
this
.
fctb
.
ToolTipNeeded
+=
new
System
.
EventHandler
<
FastColoredTextBoxNS
.
ToolTipNeededEventArgs
>(
this
.
FctbToolTipNeeded
);
this
.
fctb
.
ToolTipNeeded
+=
new
System
.
EventHandler
<
FastColoredTextBoxNS
.
ToolTipNeededEventArgs
>(
this
.
FctbToolTipNeeded
);
this
.
fctb
.
SelectionChangedDelayed
+=
new
System
.
EventHandler
(
this
.
FctbSelectionChangedDelayed
);
this
.
fctb
.
SelectionChangedDelayed
+=
new
System
.
EventHandler
(
this
.
FctbSelectionChangedDelayed
);
this
.
fctb
.
MouseClick
+=
new
System
.
Windows
.
Forms
.
MouseEventHandler
(
this
.
FctbMouseClick
);
this
.
fctb
.
MouseClick
+=
new
System
.
Windows
.
Forms
.
MouseEventHandler
(
this
.
FctbMouseClick
);
//
//
// documentMap1
// documentMap1
//
//
this
.
documentMap1
.
BackColor
=
System
.
Drawing
.
Color
.
DimGray
;
this
.
documentMap1
.
BackColor
=
System
.
Drawing
.
Color
.
DimGray
;
this
.
documentMap1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Right
;
this
.
documentMap1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Right
;
this
.
documentMap1
.
ForeColor
=
System
.
Drawing
.
Color
.
Maroon
;
this
.
documentMap1
.
ForeColor
=
System
.
Drawing
.
Color
.
Maroon
;
this
.
documentMap1
.
Location
=
new
System
.
Drawing
.
Point
(
514
,
25
);
this
.
documentMap1
.
Location
=
new
System
.
Drawing
.
Point
(
514
,
25
);
this
.
documentMap1
.
Name
=
"documentMap1"
;
this
.
documentMap1
.
Name
=
"documentMap1"
;
this
.
documentMap1
.
Size
=
new
System
.
Drawing
.
Size
(
191
,
390
);
this
.
documentMap1
.
Size
=
new
System
.
Drawing
.
Size
(
191
,
390
);
this
.
documentMap1
.
TabIndex
=
5
;
this
.
documentMap1
.
TabIndex
=
5
;
this
.
documentMap1
.
Target
=
this
.
fctb
;
this
.
documentMap1
.
Target
=
this
.
fctb
;
this
.
documentMap1
.
Text
=
"documentMap1"
;
this
.
documentMap1
.
Text
=
"documentMap1"
;
this
.
documentMap1
.
Visible
=
false
;
this
.
documentMap1
.
Visible
=
false
;
//
//
// CodeEditForm
// CodeEditForm
//
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
705
,
415
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
705
,
415
);
this
.
Controls
.
Add
(
this
.
fctb
);
this
.
Controls
.
Add
(
this
.
fctb
);
this
.
Controls
.
Add
(
this
.
tb_input
);
this
.
Controls
.
Add
(
this
.
tb_input
);
this
.
Controls
.
Add
(
this
.
documentMap1
);
this
.
Controls
.
Add
(
this
.
documentMap1
);
this
.
Controls
.
Add
(
this
.
mainMenu
);
this
.
Controls
.
Add
(
this
.
mainMenu
);
this
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
MainMenuStrip
=
this
.
mainMenu
;
this
.
MainMenuStrip
=
this
.
mainMenu
;
this
.
Name
=
"CodeEditForm"
;
this
.
Name
=
"CodeEditForm"
;
this
.
StartPosition
=
System
.
Windows
.
Forms
.
FormStartPosition
.
CenterScreen
;
this
.
StartPosition
=
System
.
Windows
.
Forms
.
FormStartPosition
.
CenterScreen
;
this
.
Text
=
"CodeEditor"
;
this
.
Text
=
"CodeEditor"
;
this
.
FormClosing
+=
new
System
.
Windows
.
Forms
.
FormClosingEventHandler
(
this
.
CodeEditFormFormClosing
);
this
.
FormClosing
+=
new
System
.
Windows
.
Forms
.
FormClosingEventHandler
(
this
.
CodeEditFormFormClosing
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
CodeEditFormLoad
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
CodeEditFormLoad
);
this
.
Enter
+=
new
System
.
EventHandler
(
this
.
CodeEditFormEnter
);
this
.
Enter
+=
new
System
.
EventHandler
(
this
.
CodeEditFormEnter
);
this
.
mainMenu
.
ResumeLayout
(
false
);
this
.
mainMenu
.
ResumeLayout
(
false
);
this
.
mainMenu
.
PerformLayout
();
this
.
mainMenu
.
PerformLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
fctb
)).
EndInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
fctb
)).
EndInit
();
this
.
ResumeLayout
(
false
);
this
.
ResumeLayout
(
false
);
this
.
PerformLayout
();
this
.
PerformLayout
();
}
}
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_setcard
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_setcard
;
...
@@ -305,9 +305,9 @@ private void InitializeComponent()
...
@@ -305,9 +305,9 @@ private void InitializeComponent()
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_save
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_save
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_open
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_open
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_file
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_file
;
private
System
.
Windows
.
Forms
.
MenuStrip
mainMenu
;
private
System
.
Windows
.
Forms
.
MenuStrip
mainMenu
;
private
System
.
ComponentModel
.
BackgroundWorker
backgroundWorker1
;
private
System
.
ComponentModel
.
BackgroundWorker
backgroundWorker1
;
private
System
.
Windows
.
Forms
.
ToolTip
toolTip1
;
private
System
.
Windows
.
Forms
.
ToolTip
toolTip1
;
}
}
...
...
DataEditorX/CodeEditForm.cs
View file @
e72f147e
...
@@ -21,450 +21,450 @@
...
@@ -21,450 +21,450 @@
namespace
DataEditorX
namespace
DataEditorX
{
{
/// <summary>
/// <summary>
/// Description of CodeEditForm.
/// Description of CodeEditForm.
/// </summary>
/// </summary>
public
partial
class
CodeEditForm
:
DockContent
,
IEditForm
public
partial
class
CodeEditForm
:
DockContent
,
IEditForm
{
{
#
region
Style
#
region
Style
SortedDictionary
<
long
,
string
>
cardlist
;
SortedDictionary
<
long
,
string
>
cardlist
;
MarkerStyle
SameWordsStyle
=
new
MarkerStyle
(
new
SolidBrush
(
Color
.
FromArgb
(
40
,
Color
.
White
)));
MarkerStyle
SameWordsStyle
=
new
MarkerStyle
(
new
SolidBrush
(
Color
.
FromArgb
(
40
,
Color
.
White
)));
#
endregion
#
endregion
#
region
init
函数提示菜单
#
region
init
函数提示菜单
//自动完成
//自动完成
AutocompleteMenu
popupMenu
;
AutocompleteMenu
popupMenu
;
string
nowFile
;
string
nowFile
;
string
title
;
string
title
;
string
oldtext
;
string
oldtext
;
SortedList
<
string
,
string
>
tooltipDic
;
SortedList
<
string
,
string
>
tooltipDic
;
AutocompleteItem
[]
items
;
AutocompleteItem
[]
items
;
bool
tabisspaces
=
false
;
bool
tabisspaces
=
false
;
string
nowcdb
;
string
nowcdb
;
public
CodeEditForm
()
public
CodeEditForm
()
{
{
InitForm
();
InitForm
();
}
}
void
InitForm
()
void
InitForm
()
{
{
cardlist
=
new
SortedDictionary
<
long
,
string
>();
cardlist
=
new
SortedDictionary
<
long
,
string
>();
tooltipDic
=
new
SortedList
<
string
,
string
>();
tooltipDic
=
new
SortedList
<
string
,
string
>();
InitializeComponent
();
InitializeComponent
();
//设置字体,大小
//设置字体,大小
string
fontname
=
MyConfig
.
readString
(
MyConfig
.
TAG_FONT_NAME
);
string
fontname
=
MyConfig
.
readString
(
MyConfig
.
TAG_FONT_NAME
);
float
fontsize
=
MyConfig
.
readFloat
(
MyConfig
.
TAG_FONT_SIZE
,
fctb
.
Font
.
Size
);
float
fontsize
=
MyConfig
.
readFloat
(
MyConfig
.
TAG_FONT_SIZE
,
fctb
.
Font
.
Size
);
fctb
.
Font
=
new
Font
(
fontname
,
fontsize
);
fctb
.
Font
=
new
Font
(
fontname
,
fontsize
);
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_IME
))
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_IME
))
fctb
.
ImeMode
=
ImeMode
.
On
;
fctb
.
ImeMode
=
ImeMode
.
On
;
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_WORDWRAP
))
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_WORDWRAP
))
fctb
.
WordWrap
=
true
;
fctb
.
WordWrap
=
true
;
else
else
fctb
.
WordWrap
=
false
;
fctb
.
WordWrap
=
false
;
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_TAB2SPACES
))
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_TAB2SPACES
))
tabisspaces
=
true
;
tabisspaces
=
true
;
else
else
tabisspaces
=
false
;
tabisspaces
=
false
;
Font
ft
=
new
Font
(
fctb
.
Font
.
Name
,
fctb
.
Font
.
Size
/
1.2f
,
FontStyle
.
Regular
);
Font
ft
=
new
Font
(
fctb
.
Font
.
Name
,
fctb
.
Font
.
Size
/
1.2f
,
FontStyle
.
Regular
);
popupMenu
=
new
FastColoredTextBoxNS
.
AutocompleteMenu
(
fctb
);
popupMenu
=
new
FastColoredTextBoxNS
.
AutocompleteMenu
(
fctb
);
popupMenu
.
MinFragmentLength
=
2
;
popupMenu
.
MinFragmentLength
=
2
;
popupMenu
.
Items
.
Font
=
ft
;
popupMenu
.
Items
.
Font
=
ft
;
popupMenu
.
Items
.
MaximumSize
=
new
System
.
Drawing
.
Size
(
200
,
400
);
popupMenu
.
Items
.
MaximumSize
=
new
System
.
Drawing
.
Size
(
200
,
400
);
popupMenu
.
Items
.
Width
=
300
;
popupMenu
.
Items
.
Width
=
300
;
popupMenu
.
BackColor
=
fctb
.
BackColor
;
popupMenu
.
BackColor
=
fctb
.
BackColor
;
popupMenu
.
ForeColor
=
fctb
.
ForeColor
;
popupMenu
.
ForeColor
=
fctb
.
ForeColor
;
popupMenu
.
Closed
+=
new
ToolStripDropDownClosedEventHandler
(
popupMenu_Closed
);
popupMenu
.
Closed
+=
new
ToolStripDropDownClosedEventHandler
(
popupMenu_Closed
);
popupMenu
.
SelectedColor
=
Color
.
LightGray
;
popupMenu
.
SelectedColor
=
Color
.
LightGray
;
title
=
this
.
Text
;
title
=
this
.
Text
;
}
}
void
popupMenu_Closed
(
object
sender
,
ToolStripDropDownClosedEventArgs
e
)
void
popupMenu_Closed
(
object
sender
,
ToolStripDropDownClosedEventArgs
e
)
{
{
popupMenu
.
Items
.
SetAutocompleteItems
(
items
);
popupMenu
.
Items
.
SetAutocompleteItems
(
items
);
}
}
#
endregion
#
endregion
#
region
IEditForm
接口
#
region
IEditForm
接口
public
void
SetActived
()
public
void
SetActived
()
{
{
this
.
Activate
();
this
.
Activate
();
}
}
public
bool
CanOpen
(
string
file
)
public
bool
CanOpen
(
string
file
)
{
{
return
YGOUtil
.
isScript
(
file
);
return
YGOUtil
.
isScript
(
file
);
}
}
public
string
GetOpenFile
()
public
string
GetOpenFile
()
{
{
return
nowFile
;
return
nowFile
;
}
}
public
bool
Create
(
string
file
)
public
bool
Create
(
string
file
)
{
{
return
Open
(
file
);
return
Open
(
file
);
}
}
public
bool
Save
()
public
bool
Save
()
{
{
return
savefile
(
string
.
IsNullOrEmpty
(
nowFile
));
return
savefile
(
string
.
IsNullOrEmpty
(
nowFile
));
}
}
public
bool
Open
(
string
file
)
public
bool
Open
(
string
file
)
{
{
if
(!
string
.
IsNullOrEmpty
(
file
))
if
(!
string
.
IsNullOrEmpty
(
file
))
{
{
if
(!
File
.
Exists
(
file
))
if
(!
File
.
Exists
(
file
))
{
{
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
);
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
);
fs
.
Close
();
fs
.
Close
();
}
}
nowFile
=
file
;
nowFile
=
file
;
string
cdb
=
MyPath
.
Combine
(
string
cdb
=
MyPath
.
Combine
(
Path
.
GetDirectoryName
(
file
),
"../cards.cdb"
);
Path
.
GetDirectoryName
(
file
),
"../cards.cdb"
);
SetCardDB
(
cdb
);
//后台加载卡片数据
SetCardDB
(
cdb
);
//后台加载卡片数据
fctb
.
OpenFile
(
nowFile
,
new
UTF8Encoding
(
false
));
fctb
.
OpenFile
(
nowFile
,
new
UTF8Encoding
(
false
));
oldtext
=
fctb
.
Text
;
oldtext
=
fctb
.
Text
;
SetTitle
();
SetTitle
();
return
true
;
return
true
;
}
}
return
false
;
return
false
;
}
}
#
endregion
#
endregion
#
region
文档视图
#
region
文档视图
//文档视图
//文档视图
void
ShowMapToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
ShowMapToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
menuitem_showmap
.
Checked
)
if
(
menuitem_showmap
.
Checked
)
{
{
documentMap1
.
Visible
=
false
;
documentMap1
.
Visible
=
false
;
menuitem_showmap
.
Checked
=
false
;
menuitem_showmap
.
Checked
=
false
;
fctb
.
Width
+=
documentMap1
.
Width
;
fctb
.
Width
+=
documentMap1
.
Width
;
}
}
else
else
{
{
documentMap1
.
Visible
=
true
;
documentMap1
.
Visible
=
true
;
menuitem_showmap
.
Checked
=
true
;
menuitem_showmap
.
Checked
=
true
;
fctb
.
Width
-=
documentMap1
.
Width
;
fctb
.
Width
-=
documentMap1
.
Width
;
}
}
}
}
#
endregion
#
endregion
#
region
设置标题
#
region
设置标题
void
SetTitle
()
void
SetTitle
()
{
{
string
str
=
title
;
string
str
=
title
;
if
(
string
.
IsNullOrEmpty
(
nowFile
))
if
(
string
.
IsNullOrEmpty
(
nowFile
))
str
=
title
;
str
=
title
;
else
else
str
=
nowFile
+
"-"
+
title
;
str
=
nowFile
+
"-"
+
title
;
if
(
this
.
MdiParent
!=
null
)
//如果父容器不为空
if
(
this
.
MdiParent
!=
null
)
//如果父容器不为空
{
{
if
(
string
.
IsNullOrEmpty
(
nowFile
))
if
(
string
.
IsNullOrEmpty
(
nowFile
))
this
.
Text
=
title
;
this
.
Text
=
title
;
else
else
this
.
Text
=
Path
.
GetFileName
(
nowFile
);
this
.
Text
=
Path
.
GetFileName
(
nowFile
);
this
.
MdiParent
.
Text
=
str
;
this
.
MdiParent
.
Text
=
str
;
}
}
else
else
this
.
Text
=
str
;
this
.
Text
=
str
;
}
}
void
CodeEditFormEnter
(
object
sender
,
EventArgs
e
)
void
CodeEditFormEnter
(
object
sender
,
EventArgs
e
)
{
{
SetTitle
();
SetTitle
();
}
}
#
endregion
#
endregion
#
region
自动完成
#
region
自动完成
public
void
LoadXml
(
string
xmlfile
)
public
void
LoadXml
(
string
xmlfile
)
{
{
fctb
.
DescriptionFile
=
xmlfile
;
fctb
.
DescriptionFile
=
xmlfile
;
}
}
public
void
InitTooltip
(
CodeConfig
codeconfig
)
public
void
InitTooltip
(
CodeConfig
codeconfig
)
{
{
this
.
tooltipDic
=
codeconfig
.
TooltipDic
;
this
.
tooltipDic
=
codeconfig
.
TooltipDic
;
items
=
codeconfig
.
Items
;
items
=
codeconfig
.
Items
;
popupMenu
.
Items
.
SetAutocompleteItems
(
items
);
popupMenu
.
Items
.
SetAutocompleteItems
(
items
);
}
}
#
endregion
#
endregion
#
region
悬停的函数说明
#
region
悬停的函数说明
//查找函数说明
//查找函数说明
string
FindTooltip
(
string
word
)
string
FindTooltip
(
string
word
)
{
{
string
desc
=
""
;
string
desc
=
""
;
foreach
(
string
v
in
tooltipDic
.
Keys
)
foreach
(
string
v
in
tooltipDic
.
Keys
)
{
{
int
t
=
v
.
IndexOf
(
"."
);
int
t
=
v
.
IndexOf
(
"."
);
string
k
=
v
;
string
k
=
v
;
if
(
t
>
0
)
if
(
t
>
0
)
k
=
v
.
Substring
(
t
+
1
);
k
=
v
.
Substring
(
t
+
1
);
if
(
word
==
k
)
if
(
word
==
k
)
desc
=
tooltipDic
[
v
];
desc
=
tooltipDic
[
v
];
}
}
return
desc
;
return
desc
;
}
}
//悬停的函数说明
//悬停的函数说明
void
FctbToolTipNeeded
(
object
sender
,
ToolTipNeededEventArgs
e
)
void
FctbToolTipNeeded
(
object
sender
,
ToolTipNeededEventArgs
e
)
{
{
if
(!
string
.
IsNullOrEmpty
(
e
.
HoveredWord
))
if
(!
string
.
IsNullOrEmpty
(
e
.
HoveredWord
))
{
{
long
tl
=
0
;
long
tl
=
0
;
string
name
=
e
.
HoveredWord
;
string
name
=
e
.
HoveredWord
;
string
desc
=
""
;
string
desc
=
""
;
if
(!
name
.
StartsWith
(
"0x"
)
&&
name
.
Length
<=
9
)
if
(!
name
.
StartsWith
(
"0x"
)
&&
name
.
Length
<=
9
)
{
{
name
=
name
.
Replace
(
"c"
,
""
);
name
=
name
.
Replace
(
"c"
,
""
);
long
.
TryParse
(
name
,
out
tl
);
long
.
TryParse
(
name
,
out
tl
);
}
}
if
(
tl
>
0
)
if
(
tl
>
0
)
{
{
//获取卡片信息
//获取卡片信息
if
(
cardlist
.
ContainsKey
(
tl
))
if
(
cardlist
.
ContainsKey
(
tl
))
desc
=
cardlist
[
tl
];
desc
=
cardlist
[
tl
];
}
}
else
else
desc
=
FindTooltip
(
e
.
HoveredWord
);
desc
=
FindTooltip
(
e
.
HoveredWord
);
if
(!
string
.
IsNullOrEmpty
(
desc
))
if
(!
string
.
IsNullOrEmpty
(
desc
))
{
{
e
.
ToolTipTitle
=
e
.
HoveredWord
;
e
.
ToolTipTitle
=
e
.
HoveredWord
;
e
.
ToolTipText
=
desc
;
e
.
ToolTipText
=
desc
;
}
}
}
}
}
}
#
endregion
#
endregion
#
region
保存文件
#
region
保存文件
bool
savefile
(
bool
saveas
)
bool
savefile
(
bool
saveas
)
{
{
string
alltext
=
fctb
.
Text
;
string
alltext
=
fctb
.
Text
;
if
(!
tabisspaces
)
if
(!
tabisspaces
)
alltext
=
alltext
.
Replace
(
"
"
,
"\t"
);
alltext
=
alltext
.
Replace
(
"
"
,
"\t"
);
if
(
saveas
)
if
(
saveas
)
{
{
using
(
SaveFileDialog
sfdlg
=
new
SaveFileDialog
())
using
(
SaveFileDialog
sfdlg
=
new
SaveFileDialog
())
{
{
sfdlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ScriptFilter
);
sfdlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ScriptFilter
);
if
(
sfdlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
sfdlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
nowFile
=
sfdlg
.
FileName
;
nowFile
=
sfdlg
.
FileName
;
SetTitle
();
SetTitle
();
}
}
else
else
return
false
;
return
false
;
}
}
}
}
oldtext
=
fctb
.
Text
;
oldtext
=
fctb
.
Text
;
File
.
WriteAllText
(
nowFile
,
alltext
,
new
UTF8Encoding
(
false
));
File
.
WriteAllText
(
nowFile
,
alltext
,
new
UTF8Encoding
(
false
));
return
true
;
return
true
;
}
}
public
bool
SaveAs
()
public
bool
SaveAs
()
{
{
return
savefile
(
true
);
return
savefile
(
true
);
}
}
void
SaveToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
SaveToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
Save
();
Save
();
}
}
void
SaveAsToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
SaveAsToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
SaveAs
();
SaveAs
();
}
}
#
endregion
#
endregion
#
region
菜单
#
region
菜单
//显示/隐藏输入框
//显示/隐藏输入框
void
Menuitem_showinputClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_showinputClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
menuitem_showinput
.
Checked
)
if
(
menuitem_showinput
.
Checked
)
{
{
menuitem_showinput
.
Checked
=
false
;
menuitem_showinput
.
Checked
=
false
;
tb_input
.
Visible
=
false
;
tb_input
.
Visible
=
false
;
}
}
else
else
{
{
menuitem_showinput
.
Checked
=
true
;
menuitem_showinput
.
Checked
=
true
;
tb_input
.
Visible
=
true
;
tb_input
.
Visible
=
true
;
}
}
}
}
//如果是作为mdi,则隐藏菜单
//如果是作为mdi,则隐藏菜单
void
HideMenu
()
void
HideMenu
()
{
{
if
(
this
.
MdiParent
==
null
)
if
(
this
.
MdiParent
==
null
)
return
;
return
;
mainMenu
.
Visible
=
false
;
mainMenu
.
Visible
=
false
;
menuitem_file
.
Visible
=
false
;
menuitem_file
.
Visible
=
false
;
menuitem_file
.
Enabled
=
false
;
menuitem_file
.
Enabled
=
false
;
}
}
void
CodeEditFormLoad
(
object
sender
,
EventArgs
e
)
void
CodeEditFormLoad
(
object
sender
,
EventArgs
e
)
{
{
HideMenu
();
HideMenu
();
fctb
.
OnTextChangedDelayed
(
fctb
.
Range
);
fctb
.
OnTextChangedDelayed
(
fctb
.
Range
);
}
}
void
Menuitem_findClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_findClick
(
object
sender
,
EventArgs
e
)
{
{
fctb
.
ShowFindDialog
();
fctb
.
ShowFindDialog
();
}
}
void
Menuitem_replaceClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_replaceClick
(
object
sender
,
EventArgs
e
)
{
{
fctb
.
ShowReplaceDialog
();
fctb
.
ShowReplaceDialog
();
}
}
void
QuitToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
QuitToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
this
.
Close
();
this
.
Close
();
}
}
void
AboutToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
AboutToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
MyMsg
.
Show
(
MyMsg
.
Show
(
LanguageHelper
.
GetMsg
(
LMSG
.
About
)
+
"\t"
+
Application
.
ProductName
+
"\n"
LanguageHelper
.
GetMsg
(
LMSG
.
About
)
+
"\t"
+
Application
.
ProductName
+
"\n"
+
LanguageHelper
.
GetMsg
(
LMSG
.
Version
)
+
"\t1.1.0.0\n"
+
LanguageHelper
.
GetMsg
(
LMSG
.
Version
)
+
"\t1.1.0.0\n"
+
LanguageHelper
.
GetMsg
(
LMSG
.
Author
)
+
"\t菜菜"
);
+
LanguageHelper
.
GetMsg
(
LMSG
.
Author
)
+
"\t菜菜"
);
}
}
void
Menuitem_openClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_openClick
(
object
sender
,
EventArgs
e
)
{
{
using
(
OpenFileDialog
sfdlg
=
new
OpenFileDialog
())
using
(
OpenFileDialog
sfdlg
=
new
OpenFileDialog
())
{
{
sfdlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ScriptFilter
);
sfdlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ScriptFilter
);
if
(
sfdlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
sfdlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
nowFile
=
sfdlg
.
FileName
;
nowFile
=
sfdlg
.
FileName
;
fctb
.
OpenFile
(
nowFile
,
new
UTF8Encoding
(
false
));
fctb
.
OpenFile
(
nowFile
,
new
UTF8Encoding
(
false
));
}
}
}
}
}
}
#
endregion
#
endregion
#
region
搜索函数
#
region
搜索函数
//搜索函数
//搜索函数
void
Tb_inputKeyDown
(
object
sender
,
KeyEventArgs
e
)
void
Tb_inputKeyDown
(
object
sender
,
KeyEventArgs
e
)
{
{
if
(
e
.
KeyCode
==
Keys
.
Enter
)
if
(
e
.
KeyCode
==
Keys
.
Enter
)
{
{
string
key
=
tb_input
.
Text
;
string
key
=
tb_input
.
Text
;
List
<
AutocompleteItem
>
list
=
new
List
<
AutocompleteItem
>();
List
<
AutocompleteItem
>
list
=
new
List
<
AutocompleteItem
>();
foreach
(
AutocompleteItem
item
in
items
)
foreach
(
AutocompleteItem
item
in
items
)
{
{
if
(
item
.
ToolTipText
.
Contains
(
key
))
if
(
item
.
ToolTipText
.
Contains
(
key
))
list
.
Add
(
item
);
list
.
Add
(
item
);
}
}
popupMenu
.
Items
.
SetAutocompleteItems
(
list
.
ToArray
());
popupMenu
.
Items
.
SetAutocompleteItems
(
list
.
ToArray
());
popupMenu
.
Show
(
true
);
popupMenu
.
Show
(
true
);
}
}
}
}
#
endregion
#
endregion
#
region
提示保存
#
region
提示保存
void
CodeEditFormFormClosing
(
object
sender
,
FormClosingEventArgs
e
)
void
CodeEditFormFormClosing
(
object
sender
,
FormClosingEventArgs
e
)
{
{
if
(!
string
.
IsNullOrEmpty
(
oldtext
))
if
(!
string
.
IsNullOrEmpty
(
oldtext
))
{
{
if
(
fctb
.
Text
!=
oldtext
)
if
(
fctb
.
Text
!=
oldtext
)
{
{
if
(
MyMsg
.
Question
(
LMSG
.
IfSaveScript
))
if
(
MyMsg
.
Question
(
LMSG
.
IfSaveScript
))
Save
();
Save
();
}
}
}
}
else
if
(
fctb
.
Text
.
Length
>
0
)
else
if
(
fctb
.
Text
.
Length
>
0
)
{
{
if
(
MyMsg
.
Question
(
LMSG
.
IfSaveScript
))
if
(
MyMsg
.
Question
(
LMSG
.
IfSaveScript
))
Save
();
Save
();
}
}
}
}
#
endregion
#
endregion
#
region
卡片提示
#
region
卡片提示
public
void
SetCDBList
(
string
[]
cdbs
)
public
void
SetCDBList
(
string
[]
cdbs
)
{
{
if
(
cdbs
==
null
)
if
(
cdbs
==
null
)
return
;
return
;
foreach
(
string
cdb
in
cdbs
)
foreach
(
string
cdb
in
cdbs
)
{
{
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
cdb
);
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
cdb
);
tsmi
.
Click
+=
MenuItem_Click
;
tsmi
.
Click
+=
MenuItem_Click
;
menuitem_setcard
.
DropDownItems
.
Add
(
tsmi
);
menuitem_setcard
.
DropDownItems
.
Add
(
tsmi
);
}
}
}
}
void
MenuItem_Click
(
object
sender
,
EventArgs
e
)
void
MenuItem_Click
(
object
sender
,
EventArgs
e
)
{
{
ToolStripMenuItem
tsmi
=
sender
as
ToolStripMenuItem
;
ToolStripMenuItem
tsmi
=
sender
as
ToolStripMenuItem
;
if
(
tsmi
!=
null
)
if
(
tsmi
!=
null
)
{
{
string
file
=
tsmi
.
Text
;
string
file
=
tsmi
.
Text
;
SetCardDB
(
file
);
SetCardDB
(
file
);
}
}
}
}
public
void
SetCardDB
(
string
name
)
public
void
SetCardDB
(
string
name
)
{
{
nowcdb
=
name
;
nowcdb
=
name
;
if
(!
backgroundWorker1
.
IsBusy
)
if
(!
backgroundWorker1
.
IsBusy
)
backgroundWorker1
.
RunWorkerAsync
();
backgroundWorker1
.
RunWorkerAsync
();
}
}
private
void
backgroundWorker1_DoWork
(
object
sender
,
System
.
ComponentModel
.
DoWorkEventArgs
e
)
private
void
backgroundWorker1_DoWork
(
object
sender
,
System
.
ComponentModel
.
DoWorkEventArgs
e
)
{
{
if
(
nowcdb
!=
null
&&
File
.
Exists
(
nowcdb
))
if
(
nowcdb
!=
null
&&
File
.
Exists
(
nowcdb
))
SetCards
(
DataBase
.
Read
(
nowcdb
,
true
,
""
));
SetCards
(
DataBase
.
Read
(
nowcdb
,
true
,
""
));
}
}
public
void
SetCards
(
Card
[]
cards
)
public
void
SetCards
(
Card
[]
cards
)
{
{
if
(
cards
==
null
)
if
(
cards
==
null
)
return
;
return
;
cardlist
.
Clear
();
cardlist
.
Clear
();
foreach
(
Card
c
in
cards
)
foreach
(
Card
c
in
cards
)
{
{
cardlist
.
Add
(
c
.
id
,
c
.
ToString
());
cardlist
.
Add
(
c
.
id
,
c
.
ToString
());
}
}
}
}
#
endregion
#
endregion
#
region
选择高亮
#
region
选择高亮
void
FctbSelectionChangedDelayed
(
object
sender
,
EventArgs
e
)
void
FctbSelectionChangedDelayed
(
object
sender
,
EventArgs
e
)
{
{
tb_input
.
Text
=
fctb
.
SelectedText
;
tb_input
.
Text
=
fctb
.
SelectedText
;
fctb
.
VisibleRange
.
ClearStyle
(
SameWordsStyle
);
fctb
.
VisibleRange
.
ClearStyle
(
SameWordsStyle
);
if
(!
fctb
.
Selection
.
IsEmpty
)
if
(!
fctb
.
Selection
.
IsEmpty
)
return
;
//user selected diapason
return
;
//user selected diapason
//get fragment around caret
//get fragment around caret
var
fragment
=
fctb
.
Selection
.
GetFragment
(
@"\w"
);
var
fragment
=
fctb
.
Selection
.
GetFragment
(
@"\w"
);
string
text
=
fragment
.
Text
;
string
text
=
fragment
.
Text
;
if
(
text
.
Length
==
0
)
if
(
text
.
Length
==
0
)
return
;
return
;
//highlight same words
//highlight same words
var
ranges
=
fctb
.
VisibleRange
.
GetRanges
(
"\\b"
+
text
+
"\\b"
);
var
ranges
=
fctb
.
VisibleRange
.
GetRanges
(
"\\b"
+
text
+
"\\b"
);
foreach
(
var
r
in
ranges
)
foreach
(
var
r
in
ranges
)
r
.
SetStyle
(
SameWordsStyle
);
r
.
SetStyle
(
SameWordsStyle
);
}
}
#
endregion
#
endregion
#
region
调转函数
#
region
调转函数
void
FctbMouseClick
(
object
sender
,
MouseEventArgs
e
)
void
FctbMouseClick
(
object
sender
,
MouseEventArgs
e
)
{
{
var
fragment
=
fctb
.
Selection
.
GetFragment
(
@"\w"
);
var
fragment
=
fctb
.
Selection
.
GetFragment
(
@"\w"
);
string
text
=
fragment
.
Text
;
string
text
=
fragment
.
Text
;
if
(
text
.
Length
==
0
)
if
(
text
.
Length
==
0
)
return
;
return
;
if
(
e
.
Button
==
MouseButtons
.
Left
&&
Control
.
ModifierKeys
==
Keys
.
Control
)
if
(
e
.
Button
==
MouseButtons
.
Left
&&
Control
.
ModifierKeys
==
Keys
.
Control
)
{
{
List
<
int
>
linenums
=
fctb
.
FindLines
(
@"function\s+?\S+?\."
+
text
+
@"\("
,
RegexOptions
.
Singleline
);
List
<
int
>
linenums
=
fctb
.
FindLines
(
@"function\s+?\S+?\."
+
text
+
@"\("
,
RegexOptions
.
Singleline
);
if
(
linenums
.
Count
>
0
)
if
(
linenums
.
Count
>
0
)
{
{
fctb
.
Navigate
(
linenums
[
0
]);
fctb
.
Navigate
(
linenums
[
0
]);
//MessageBox.Show(linenums[0].ToString());
//MessageBox.Show(linenums[0].ToString());
}
}
}
}
}
}
#
endregion
#
endregion
}
}
}
}
DataEditorX/Common/Area.cs
View file @
e72f147e
namespace
DataEditorX.Common
namespace
DataEditorX.Common
{
{
/// <summary>
/// <summary>
/// 区域
/// 区域
/// </summary>
/// </summary>
public
class
Area
public
class
Area
{
{
public
Area
()
public
Area
()
{
{
left
=
0
;
left
=
0
;
top
=
0
;
top
=
0
;
width
=
0
;
width
=
0
;
height
=
0
;
height
=
0
;
}
}
/// <summary>
/// <summary>
/// 左
/// 左
/// </summary>
/// </summary>
public
int
left
;
public
int
left
;
/// <summary>
/// <summary>
/// 顶
/// 顶
/// </summary>
/// </summary>
public
int
top
;
public
int
top
;
/// <summary>
/// <summary>
/// 宽
/// 宽
/// </summary>
/// </summary>
public
int
width
;
public
int
width
;
/// <summary>
/// <summary>
/// 高
/// 高
/// </summary>
/// </summary>
public
int
height
;
public
int
height
;
}
}
}
}
DataEditorX/Common/CheckUpdate.cs
View file @
e72f147e
...
@@ -112,12 +112,12 @@ public static string GetHtmlContentByUrl(string url)
...
@@ -112,12 +112,12 @@ public static string GetHtmlContentByUrl(string url)
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
httpWebRequest
.
Timeout
=
15000
;
httpWebRequest
.
Timeout
=
15000
;
using
(
HttpWebResponse
httpWebResponse
=
using
(
HttpWebResponse
httpWebResponse
=
(
HttpWebResponse
)
httpWebRequest
.
GetResponse
())
(
HttpWebResponse
)
httpWebRequest
.
GetResponse
())
{
{
using
(
Stream
stream
=
httpWebResponse
.
GetResponseStream
())
using
(
Stream
stream
=
httpWebResponse
.
GetResponseStream
())
{
{
using
(
StreamReader
streamReader
=
using
(
StreamReader
streamReader
=
new
StreamReader
(
stream
,
Encoding
.
UTF8
))
new
StreamReader
(
stream
,
Encoding
.
UTF8
))
{
{
htmlContent
=
streamReader
.
ReadToEnd
();
htmlContent
=
streamReader
.
ReadToEnd
();
streamReader
.
Close
();
streamReader
.
Close
();
...
...
DataEditorX/Common/ConfHelper.cs
View file @
e72f147e
...
@@ -5,119 +5,119 @@
...
@@ -5,119 +5,119 @@
namespace
DataEditorX.Common
namespace
DataEditorX.Common
{
{
public
class
ConfHelper
public
class
ConfHelper
{
{
/// <summary>
/// <summary>
/// 内容分隔符
/// 内容分隔符
/// </summary>
/// </summary>
public
const
string
SEP_LINE
=
" "
;
public
const
string
SEP_LINE
=
" "
;
/// <summary>
/// <summary>
/// 从行获取值
/// 从行获取值
/// </summary>
/// </summary>
/// <param name="line"></param>
/// <param name="line"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
getValue
(
string
line
)
public
static
string
getValue
(
string
line
)
{
{
int
t
=
line
.
IndexOf
(
'='
);
int
t
=
line
.
IndexOf
(
'='
);
if
(
t
>
0
)
if
(
t
>
0
)
return
line
.
Substring
(
t
+
1
).
Trim
();
return
line
.
Substring
(
t
+
1
).
Trim
();
return
""
;
return
""
;
}
}
/// <summary>
/// <summary>
/// 从词中获取第一个值
/// 从词中获取第一个值
/// </summary>
/// </summary>
/// <param name="word"></param>
/// <param name="word"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
getValue1
(
string
word
)
public
static
string
getValue1
(
string
word
)
{
{
int
i
=
word
.
IndexOf
(
SEP_LINE
);
int
i
=
word
.
IndexOf
(
SEP_LINE
);
if
(
i
>
0
)
if
(
i
>
0
)
return
word
.
Substring
(
0
,
i
);
return
word
.
Substring
(
0
,
i
);
return
word
;
return
word
;
}
}
/// <summary>
/// <summary>
/// 从词中获取第二个值
/// 从词中获取第二个值
/// </summary>
/// </summary>
/// <param name="word"></param>
/// <param name="word"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
getValue2
(
string
word
)
public
static
string
getValue2
(
string
word
)
{
{
int
i
=
word
.
IndexOf
(
SEP_LINE
);
int
i
=
word
.
IndexOf
(
SEP_LINE
);
if
(
i
>
0
)
if
(
i
>
0
)
return
word
.
Substring
(
i
+
SEP_LINE
.
Length
);
return
word
.
Substring
(
i
+
SEP_LINE
.
Length
);
return
""
;
return
""
;
}
}
/// <summary>
/// <summary>
/// 获取多行值,替换\n \t
/// 获取多行值,替换\n \t
/// </summary>
/// </summary>
/// <param name="line"></param>
/// <param name="line"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
getMultLineValue
(
string
line
)
public
static
string
getMultLineValue
(
string
line
)
{
{
return
getRegex
(
getValue
(
line
));
return
getRegex
(
getValue
(
line
));
}
}
/// <summary>
/// <summary>
/// 替换特殊符
/// 替换特殊符
/// </summary>
/// </summary>
/// <param name="word"></param>
/// <param name="word"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
getRegex
(
string
word
)
public
static
string
getRegex
(
string
word
)
{
{
StringBuilder
sb
=
new
StringBuilder
(
word
);
StringBuilder
sb
=
new
StringBuilder
(
word
);
sb
.
Replace
(
"\\r"
,
"\r"
);
sb
.
Replace
(
"\\r"
,
"\r"
);
sb
.
Replace
(
"\\n"
,
"\n"
);
sb
.
Replace
(
"\\n"
,
"\n"
);
sb
.
Replace
(
"\\t"
,
"\t"
);
sb
.
Replace
(
"\\t"
,
"\t"
);
sb
.
Replace
(
"[:space:]"
,
" "
);
sb
.
Replace
(
"[:space:]"
,
" "
);
return
sb
.
ToString
();
return
sb
.
ToString
();
}
}
/// <summary>
/// <summary>
/// 获取boolean值
/// 获取boolean值
/// </summary>
/// </summary>
/// <param name="line"></param>
/// <param name="line"></param>
/// <returns></returns>
/// <returns></returns>
public
static
bool
getBooleanValue
(
string
line
)
public
static
bool
getBooleanValue
(
string
line
)
{
{
if
(
getValue
(
line
).
ToLower
()
==
"true"
)
if
(
getValue
(
line
).
ToLower
()
==
"true"
)
return
true
;
return
true
;
else
else
return
false
;
return
false
;
}
}
/// <summary>
/// <summary>
/// 获取int值
/// 获取int值
/// </summary>
/// </summary>
/// <param name="line"></param>
/// <param name="line"></param>
/// <param name="defalut">失败的值</param>
/// <param name="defalut">失败的值</param>
/// <returns></returns>
/// <returns></returns>
public
static
int
getIntegerValue
(
string
line
,
int
defalut
)
public
static
int
getIntegerValue
(
string
line
,
int
defalut
)
{
{
int
i
;
int
i
;
try
try
{
{
i
=
int
.
Parse
(
getValue
(
line
));
i
=
int
.
Parse
(
getValue
(
line
));
return
i
;
return
i
;
}
}
catch
{}
catch
{}
return
defalut
;
return
defalut
;
}
}
/// <summary>
/// <summary>
/// 从行获取内容添加到字典
/// 从行获取内容添加到字典
/// race 0x1 xxx
/// race 0x1 xxx
/// </summary>
/// </summary>
/// <param name="dic"></param>
/// <param name="dic"></param>
/// <param name="line"></param>
/// <param name="line"></param>
public
static
void
DicAdd
(
SortedList
<
long
,
string
>
dic
,
string
line
)
public
static
void
DicAdd
(
SortedList
<
long
,
string
>
dic
,
string
line
)
{
{
int
i
=
line
.
IndexOf
(
"0x"
);
int
i
=
line
.
IndexOf
(
"0x"
);
int
j
=
(
i
>
0
)
?
line
.
IndexOf
(
SEP_LINE
,
i
+
1
)
:
-
1
;
int
j
=
(
i
>
0
)
?
line
.
IndexOf
(
SEP_LINE
,
i
+
1
)
:
-
1
;
if
(
j
>
0
)
if
(
j
>
0
)
{
{
string
strkey
=
line
.
Substring
(
i
+
2
,
j
-
i
-
1
);
string
strkey
=
line
.
Substring
(
i
+
2
,
j
-
i
-
1
);
string
strval
=
line
.
Substring
(
j
+
1
);
string
strval
=
line
.
Substring
(
j
+
1
);
long
key
;
long
key
;
long
.
TryParse
(
strkey
,
NumberStyles
.
HexNumber
,
null
,
out
key
);
long
.
TryParse
(
strkey
,
NumberStyles
.
HexNumber
,
null
,
out
key
);
if
(!
dic
.
ContainsKey
(
key
))
if
(!
dic
.
ContainsKey
(
key
))
dic
.
Add
(
key
,
strval
.
Trim
());
dic
.
Add
(
key
,
strval
.
Trim
());
}
}
}
}
}
}
}
}
DataEditorX/Common/MyBitmap.cs
View file @
e72f147e
...
@@ -9,153 +9,153 @@
...
@@ -9,153 +9,153 @@
namespace
DataEditorX.Common
namespace
DataEditorX.Common
{
{
/// <summary>
/// <summary>
/// 图片裁剪,缩放,保存高质量jpg
/// 图片裁剪,缩放,保存高质量jpg
/// </summary>
/// </summary>
public
static
class
MyBitmap
public
static
class
MyBitmap
{
{
public
static
Bitmap
readImage
(
string
file
)
public
static
Bitmap
readImage
(
string
file
)
{
{
if
(!
File
.
Exists
(
file
))
if
(!
File
.
Exists
(
file
))
return
null
;
return
null
;
MemoryStream
ms
=
new
MemoryStream
(
File
.
ReadAllBytes
(
file
));
MemoryStream
ms
=
new
MemoryStream
(
File
.
ReadAllBytes
(
file
));
return
(
Bitmap
)
Image
.
FromStream
(
ms
);
return
(
Bitmap
)
Image
.
FromStream
(
ms
);
}
}
#
region
缩放
#
region
缩放
/// <summary>
/// <summary>
/// 缩放图像
/// 缩放图像
/// </summary>
/// </summary>
/// <param name="img">源图像</param>
/// <param name="img">源图像</param>
/// <param name="newW">新宽度</param>
/// <param name="newW">新宽度</param>
/// <param name="newH">新高度</param>
/// <param name="newH">新高度</param>
/// <returns>处理好的图像</returns>
/// <returns>处理好的图像</returns>
public
static
Bitmap
Zoom
(
Bitmap
sourceBitmap
,
int
newWidth
,
int
newHeight
)
public
static
Bitmap
Zoom
(
Bitmap
sourceBitmap
,
int
newWidth
,
int
newHeight
)
{
{
if
(
sourceBitmap
!=
null
)
if
(
sourceBitmap
!=
null
)
{
{
Bitmap
b
=
new
Bitmap
(
newWidth
,
newHeight
);
Bitmap
b
=
new
Bitmap
(
newWidth
,
newHeight
);
Graphics
graphics
=
Graphics
.
FromImage
(
b
);
Graphics
graphics
=
Graphics
.
FromImage
(
b
);
//合成:高质量,低速度
//合成:高质量,低速度
graphics
.
CompositingQuality
=
CompositingQuality
.
HighQuality
;
graphics
.
CompositingQuality
=
CompositingQuality
.
HighQuality
;
//去除锯齿
//去除锯齿
graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
//偏移:高质量,低速度
//偏移:高质量,低速度
graphics
.
PixelOffsetMode
=
PixelOffsetMode
.
HighQuality
;
graphics
.
PixelOffsetMode
=
PixelOffsetMode
.
HighQuality
;
//插补算法
//插补算法
graphics
.
InterpolationMode
=
InterpolationMode
.
HighQualityBicubic
;
graphics
.
InterpolationMode
=
InterpolationMode
.
HighQualityBicubic
;
Rectangle
newRect
=
new
Rectangle
(
0
,
0
,
newWidth
,
newHeight
);
Rectangle
newRect
=
new
Rectangle
(
0
,
0
,
newWidth
,
newHeight
);
Rectangle
srcRect
=
new
Rectangle
(
0
,
0
,
sourceBitmap
.
Width
,
sourceBitmap
.
Height
);
Rectangle
srcRect
=
new
Rectangle
(
0
,
0
,
sourceBitmap
.
Width
,
sourceBitmap
.
Height
);
graphics
.
DrawImage
(
sourceBitmap
,
newRect
,
srcRect
,
GraphicsUnit
.
Pixel
);
graphics
.
DrawImage
(
sourceBitmap
,
newRect
,
srcRect
,
GraphicsUnit
.
Pixel
);
graphics
.
Dispose
();
graphics
.
Dispose
();
return
b
;
return
b
;
}
}
return
sourceBitmap
;
return
sourceBitmap
;
}
}
#
endregion
#
endregion
#
region
裁剪
#
region
裁剪
/// <summary>
/// <summary>
/// 裁剪图片
/// 裁剪图片
/// </summary>
/// </summary>
/// <param name="sourceBitmap">图片源</param>
/// <param name="sourceBitmap">图片源</param>
/// <param name="area">区域</param>
/// <param name="area">区域</param>
/// <returns></returns>
/// <returns></returns>
public
static
Bitmap
Cut
(
Bitmap
sourceBitmap
,
Area
area
)
public
static
Bitmap
Cut
(
Bitmap
sourceBitmap
,
Area
area
)
{
{
return
Cut
(
sourceBitmap
,
area
.
left
,
area
.
top
,
area
.
width
,
area
.
height
);
return
Cut
(
sourceBitmap
,
area
.
left
,
area
.
top
,
area
.
width
,
area
.
height
);
}
}
/// <summary>
/// <summary>
/// 裁剪图像
/// 裁剪图像
/// </summary>
/// </summary>
/// <param name="img">源图像</param>
/// <param name="img">源图像</param>
/// <param name="StartX">开始x</param>
/// <param name="StartX">开始x</param>
/// <param name="StartY">开始y</param>
/// <param name="StartY">开始y</param>
/// <param name="iWidth">裁剪宽</param>
/// <param name="iWidth">裁剪宽</param>
/// <param name="iHeight">裁剪高</param>
/// <param name="iHeight">裁剪高</param>
/// <returns>处理好的图像</returns>
/// <returns>处理好的图像</returns>
public
static
Bitmap
Cut
(
Bitmap
sourceBitmap
,
int
StartX
,
int
StartY
,
int
cutWidth
,
int
cutHeight
)
public
static
Bitmap
Cut
(
Bitmap
sourceBitmap
,
int
StartX
,
int
StartY
,
int
cutWidth
,
int
cutHeight
)
{
{
if
(
sourceBitmap
!=
null
)
if
(
sourceBitmap
!=
null
)
{
{
int
w
=
sourceBitmap
.
Width
;
int
w
=
sourceBitmap
.
Width
;
int
h
=
sourceBitmap
.
Height
;
int
h
=
sourceBitmap
.
Height
;
//裁剪的区域宽度调整
//裁剪的区域宽度调整
if
(
(
StartX
+
cutWidth
)
>
w
)
if
(
(
StartX
+
cutWidth
)
>
w
)
{
{
cutWidth
=
w
-
StartX
;
cutWidth
=
w
-
StartX
;
}
}
//裁剪的区域高度调整
//裁剪的区域高度调整
if
(
(
StartY
+
cutHeight
)
>
h
)
if
(
(
StartY
+
cutHeight
)
>
h
)
{
{
cutHeight
=
h
-
StartY
;
cutHeight
=
h
-
StartY
;
}
}
Bitmap
bitmap
=
new
Bitmap
(
cutWidth
,
cutHeight
);
Bitmap
bitmap
=
new
Bitmap
(
cutWidth
,
cutHeight
);
Graphics
graphics
=
Graphics
.
FromImage
(
bitmap
);
Graphics
graphics
=
Graphics
.
FromImage
(
bitmap
);
//合成:高质量,低速度
//合成:高质量,低速度
graphics
.
CompositingQuality
=
CompositingQuality
.
HighQuality
;
graphics
.
CompositingQuality
=
CompositingQuality
.
HighQuality
;
//去除锯齿
//去除锯齿
graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
//偏移:高质量,低速度
//偏移:高质量,低速度
graphics
.
PixelOffsetMode
=
PixelOffsetMode
.
HighQuality
;
graphics
.
PixelOffsetMode
=
PixelOffsetMode
.
HighQuality
;
//插补算法
//插补算法
graphics
.
InterpolationMode
=
InterpolationMode
.
HighQualityBicubic
;
graphics
.
InterpolationMode
=
InterpolationMode
.
HighQualityBicubic
;
Rectangle
cutRect
=
new
Rectangle
(
0
,
0
,
cutWidth
,
cutHeight
);
Rectangle
cutRect
=
new
Rectangle
(
0
,
0
,
cutWidth
,
cutHeight
);
Rectangle
srcRect
=
new
Rectangle
(
StartX
,
StartY
,
cutWidth
,
cutHeight
);
Rectangle
srcRect
=
new
Rectangle
(
StartX
,
StartY
,
cutWidth
,
cutHeight
);
graphics
.
DrawImage
(
sourceBitmap
,
cutRect
,
srcRect
,
GraphicsUnit
.
Pixel
);
graphics
.
DrawImage
(
sourceBitmap
,
cutRect
,
srcRect
,
GraphicsUnit
.
Pixel
);
graphics
.
Dispose
();
graphics
.
Dispose
();
return
bitmap
;
return
bitmap
;
}
}
return
sourceBitmap
;
return
sourceBitmap
;
}
}
#
endregion
#
endregion
#
region
保存
#
region
保存
/// <summary>
/// <summary>
/// 保存jpg图像
/// 保存jpg图像
/// </summary>
/// </summary>
/// <param name="bmp">源图像</param>
/// <param name="bmp">源图像</param>
/// <param name="filename">保存路径</param>
/// <param name="filename">保存路径</param>
/// <param name="quality">质量</param>
/// <param name="quality">质量</param>
/// <returns>是否保存成功</returns>
/// <returns>是否保存成功</returns>
public
static
bool
SaveAsJPEG
(
Bitmap
bitmap
,
string
filename
,
int
quality
=
90
)
public
static
bool
SaveAsJPEG
(
Bitmap
bitmap
,
string
filename
,
int
quality
=
90
)
{
{
if
(
bitmap
!=
null
)
if
(
bitmap
!=
null
)
{
{
string
path
=
Path
.
GetDirectoryName
(
filename
);
string
path
=
Path
.
GetDirectoryName
(
filename
);
if
(!
Directory
.
Exists
(
path
))
//创建文件夹
if
(!
Directory
.
Exists
(
path
))
//创建文件夹
Directory
.
CreateDirectory
(
path
);
Directory
.
CreateDirectory
(
path
);
if
(
File
.
Exists
(
filename
))
//删除旧文件
if
(
File
.
Exists
(
filename
))
//删除旧文件
File
.
Delete
(
filename
);
File
.
Delete
(
filename
);
ImageCodecInfo
[]
codecs
=
ImageCodecInfo
.
GetImageEncoders
();
ImageCodecInfo
[]
codecs
=
ImageCodecInfo
.
GetImageEncoders
();
ImageCodecInfo
ici
=
null
;
ImageCodecInfo
ici
=
null
;
foreach
(
ImageCodecInfo
codec
in
codecs
)
foreach
(
ImageCodecInfo
codec
in
codecs
)
{
{
if
(
codec
.
MimeType
.
IndexOf
(
"jpeg"
)
>
-
1
)
if
(
codec
.
MimeType
.
IndexOf
(
"jpeg"
)
>
-
1
)
{
{
ici
=
codec
;
ici
=
codec
;
break
;
break
;
}
}
}
}
if
(
quality
<
0
||
quality
>
100
)
if
(
quality
<
0
||
quality
>
100
)
quality
=
60
;
quality
=
60
;
EncoderParameters
encoderParams
=
new
EncoderParameters
();
EncoderParameters
encoderParams
=
new
EncoderParameters
();
encoderParams
.
Param
[
0
]
=
new
EncoderParameter
(
Encoder
.
Quality
,
(
long
)
quality
);
encoderParams
.
Param
[
0
]
=
new
EncoderParameter
(
Encoder
.
Quality
,
(
long
)
quality
);
if
(
ici
!=
null
)
if
(
ici
!=
null
)
{
{
bitmap
.
Save
(
filename
,
ici
,
encoderParams
);
bitmap
.
Save
(
filename
,
ici
,
encoderParams
);
bitmap
.
Dispose
();
bitmap
.
Dispose
();
return
true
;
return
true
;
}
}
else
else
{
{
return
false
;
return
false
;
}
}
}
}
return
false
;
return
false
;
}
}
#
endregion
#
endregion
}
}
}
}
DataEditorX/Common/MyPath.cs
View file @
e72f147e
...
@@ -16,26 +16,26 @@ namespace System.IO
...
@@ -16,26 +16,26 @@ namespace System.IO
/// </summary>
/// </summary>
public
class
MyPath
public
class
MyPath
{
{
/// <summary>
/// <summary>
/// 从相对路径获取真实路径
/// 从相对路径获取真实路径
/// </summary>
/// </summary>
/// <param name="dir"></param>
/// <param name="dir"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
GetRealPath
(
string
dir
)
public
static
string
GetRealPath
(
string
dir
)
{
{
string
path
=
Application
.
StartupPath
;
string
path
=
Application
.
StartupPath
;
if
(
dir
.
StartsWith
(
"."
))
if
(
dir
.
StartsWith
(
"."
))
{
{
dir
=
MyPath
.
Combine
(
path
,
dir
.
Substring
(
2
));
dir
=
MyPath
.
Combine
(
path
,
dir
.
Substring
(
2
));
}
}
return
dir
;
return
dir
;
}
}
/// <summary>
/// <summary>
/// 合并路径
/// 合并路径
/// </summary>
/// </summary>
/// <param name="paths"></param>
/// <param name="paths"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
Combine
(
params
string
[]
paths
)
public
static
string
Combine
(
params
string
[]
paths
)
{
{
if
(
paths
.
Length
==
0
)
if
(
paths
.
Length
==
0
)
{
{
...
@@ -78,64 +78,64 @@ public static string Combine(params string[] paths)
...
@@ -78,64 +78,64 @@ public static string Combine(params string[] paths)
return
builder
.
ToString
();
return
builder
.
ToString
();
}
}
}
}
/// <summary>
/// <summary>
/// 检查目录是否合法
/// 检查目录是否合法
/// </summary>
/// </summary>
/// <param name="dir">目录</param>
/// <param name="dir">目录</param>
/// <param name="defalut">不合法时,采取的目录</param>
/// <param name="defalut">不合法时,采取的目录</param>
/// <returns></returns>
/// <returns></returns>
public
static
string
CheckDir
(
string
dir
,
string
defalut
)
public
static
string
CheckDir
(
string
dir
,
string
defalut
)
{
{
DirectoryInfo
fo
;
DirectoryInfo
fo
;
try
try
{
{
fo
=
new
DirectoryInfo
(
MyPath
.
GetRealPath
(
dir
));
fo
=
new
DirectoryInfo
(
MyPath
.
GetRealPath
(
dir
));
}
}
catch
{
catch
{
//路径不合法
//路径不合法
fo
=
new
DirectoryInfo
(
defalut
);
fo
=
new
DirectoryInfo
(
defalut
);
}
}
if
(!
fo
.
Exists
)
if
(!
fo
.
Exists
)
fo
.
Create
();
fo
.
Create
();
dir
=
fo
.
FullName
;
dir
=
fo
.
FullName
;
return
dir
;
return
dir
;
}
}
/// <summary>
/// <summary>
/// 根据tag获取文件名
/// 根据tag获取文件名
/// tag_lang.txt
/// tag_lang.txt
/// </summary>
/// </summary>
/// <param name="tag">前面</param>
/// <param name="tag">前面</param>
/// <param name="lang"></param>
/// <param name="lang"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
getFileName
(
string
tag
,
string
lang
)
public
static
string
getFileName
(
string
tag
,
string
lang
)
{
{
return
tag
+
"_"
+
lang
+
".txt"
;
return
tag
+
"_"
+
lang
+
".txt"
;
}
}
/// <summary>
/// <summary>
/// 由tag和lang获取文件名
/// 由tag和lang获取文件名
/// </summary>
/// </summary>
/// <param name="tag"></param>
/// <param name="tag"></param>
/// <param name="file"></param>
/// <param name="file"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
getFullFileName
(
string
tag
,
string
file
)
public
static
string
getFullFileName
(
string
tag
,
string
file
)
{
{
string
name
=
Path
.
GetFileNameWithoutExtension
(
file
);
string
name
=
Path
.
GetFileNameWithoutExtension
(
file
);
if
(!
name
.
StartsWith
(
tag
+
"_"
))
if
(!
name
.
StartsWith
(
tag
+
"_"
))
return
""
;
return
""
;
else
else
return
name
.
Replace
(
tag
+
"_"
,
""
);
return
name
.
Replace
(
tag
+
"_"
,
""
);
}
}
public
static
void
CreateDir
(
string
dir
)
public
static
void
CreateDir
(
string
dir
)
{
{
if
(!
Directory
.
Exists
(
dir
))
if
(!
Directory
.
Exists
(
dir
))
Directory
.
CreateDirectory
(
dir
);
Directory
.
CreateDirectory
(
dir
);
}
}
public
static
void
CreateDirByFile
(
string
file
)
public
static
void
CreateDirByFile
(
string
file
)
{
{
string
dir
=
Path
.
GetDirectoryName
(
file
);
string
dir
=
Path
.
GetDirectoryName
(
file
);
if
(!
Directory
.
Exists
(
dir
))
if
(!
Directory
.
Exists
(
dir
))
Directory
.
CreateDirectory
(
dir
);
Directory
.
CreateDirectory
(
dir
);
}
}
}
}
}
}
DataEditorX/Common/User32.cs
View file @
e72f147e
...
@@ -10,39 +10,39 @@
...
@@ -10,39 +10,39 @@
namespace
System
namespace
System
{
{
/// <summary>
/// <summary>
/// Description of User32.
/// Description of User32.
/// </summary>
/// </summary>
public
class
User32
public
class
User32
{
{
/// <summary>
/// <summary>
/// 发送窗口消息
/// 发送窗口消息
/// </summary>
/// </summary>
/// <param name="hWnd"></param>
/// <param name="hWnd"></param>
/// <param name="msg"></param>
/// <param name="msg"></param>
/// <param name="wParam"></param>
/// <param name="wParam"></param>
/// <param name="lParam"></param>
/// <param name="lParam"></param>
/// <returns></returns>
/// <returns></returns>
[
DllImport
(
"User32.dll"
,
EntryPoint
=
"SendMessage"
)]
[
DllImport
(
"User32.dll"
,
EntryPoint
=
"SendMessage"
)]
public
static
extern
int
SendMessage
(
IntPtr
hWnd
,
int
msg
,
uint
wParam
,
uint
lParam
);
public
static
extern
int
SendMessage
(
IntPtr
hWnd
,
int
msg
,
uint
wParam
,
uint
lParam
);
/// <summary>
/// <summary>
/// 设置窗口的位置
/// 设置窗口的位置
/// </summary>
/// </summary>
/// <param name="hWnd"></param>
/// <param name="hWnd"></param>
/// <param name="hWndInsertAfter"></param>
/// <param name="hWndInsertAfter"></param>
/// <param name="x"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="y"></param>
/// <param name="Width"></param>
/// <param name="Width"></param>
/// <param name="Height"></param>
/// <param name="Height"></param>
/// <param name="flags"></param>
/// <param name="flags"></param>
/// <returns></returns>
/// <returns></returns>
[
DllImport
(
"user32.dll"
,
CharSet
=
CharSet
.
Auto
)]
[
DllImport
(
"user32.dll"
,
CharSet
=
CharSet
.
Auto
)]
public
static
extern
int
SetWindowPos
(
IntPtr
hWnd
,
int
hWndInsertAfter
,
int
x
,
int
y
,
int
Width
,
int
Height
,
int
flags
);
public
static
extern
int
SetWindowPos
(
IntPtr
hWnd
,
int
hWndInsertAfter
,
int
x
,
int
y
,
int
Width
,
int
Height
,
int
flags
);
/// <summary>
/// <summary>
/// 得到当前活动的窗口
/// 得到当前活动的窗口
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
[
DllImport
(
"user32.dll"
,
CharSet
=
CharSet
.
Auto
)]
[
DllImport
(
"user32.dll"
,
CharSet
=
CharSet
.
Auto
)]
public
static
extern
System
.
IntPtr
GetForegroundWindow
();
public
static
extern
System
.
IntPtr
GetForegroundWindow
();
}
}
}
}
\ No newline at end of file
DataEditorX/Common/XMLReader.cs
View file @
e72f147e
...
@@ -8,53 +8,53 @@
...
@@ -8,53 +8,53 @@
namespace
DataEditorX.Common
namespace
DataEditorX.Common
{
{
public
class
XMLReader
public
class
XMLReader
{
{
#
region
XML
操作
config
#
region
XML
操作
config
/// <summary>
/// <summary>
/// 保存值
/// 保存值
/// </summary>
/// </summary>
/// <param name="appKey"></param>
/// <param name="appKey"></param>
/// <param name="appValue"></param>
/// <param name="appValue"></param>
public
static
void
Save
(
string
appKey
,
string
appValue
)
public
static
void
Save
(
string
appKey
,
string
appValue
)
{
{
XmlDocument
xDoc
=
new
XmlDocument
();
XmlDocument
xDoc
=
new
XmlDocument
();
xDoc
.
Load
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
xDoc
.
Load
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
XmlNode
xNode
=
xDoc
.
SelectSingleNode
(
"//appSettings"
);
XmlNode
xNode
=
xDoc
.
SelectSingleNode
(
"//appSettings"
);
XmlElement
xElem
=
(
XmlElement
)
xNode
.
SelectSingleNode
(
"//add[@key='"
+
appKey
+
"']"
);
XmlElement
xElem
=
(
XmlElement
)
xNode
.
SelectSingleNode
(
"//add[@key='"
+
appKey
+
"']"
);
if
(
xElem
!=
null
)
//存在,则更新
if
(
xElem
!=
null
)
//存在,则更新
xElem
.
SetAttribute
(
"value"
,
appValue
);
xElem
.
SetAttribute
(
"value"
,
appValue
);
else
//不存在,则插入
else
//不存在,则插入
{
{
XmlElement
xNewElem
=
xDoc
.
CreateElement
(
"add"
);
XmlElement
xNewElem
=
xDoc
.
CreateElement
(
"add"
);
xNewElem
.
SetAttribute
(
"key"
,
appKey
);
xNewElem
.
SetAttribute
(
"key"
,
appKey
);
xNewElem
.
SetAttribute
(
"value"
,
appValue
);
xNewElem
.
SetAttribute
(
"value"
,
appValue
);
xNode
.
AppendChild
(
xNewElem
);
xNode
.
AppendChild
(
xNewElem
);
}
}
xDoc
.
Save
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
xDoc
.
Save
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
}
}
/// <summary>
/// <summary>
/// 获取值
/// 获取值
/// </summary>
/// </summary>
/// <param name="appKey"></param>
/// <param name="appKey"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
GetAppConfig
(
string
appKey
)
public
static
string
GetAppConfig
(
string
appKey
)
{
{
XmlDocument
xDoc
=
new
XmlDocument
();
XmlDocument
xDoc
=
new
XmlDocument
();
xDoc
.
Load
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
xDoc
.
Load
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
XmlNode
xNode
=
xDoc
.
SelectSingleNode
(
"//appSettings"
);
XmlNode
xNode
=
xDoc
.
SelectSingleNode
(
"//appSettings"
);
XmlElement
xElem
=
(
XmlElement
)
xNode
.
SelectSingleNode
(
"//add[@key='"
+
appKey
+
"']"
);
XmlElement
xElem
=
(
XmlElement
)
xNode
.
SelectSingleNode
(
"//add[@key='"
+
appKey
+
"']"
);
if
(
xElem
!=
null
)
if
(
xElem
!=
null
)
{
{
return
xElem
.
Attributes
[
"value"
].
Value
;
return
xElem
.
Attributes
[
"value"
].
Value
;
}
}
return
string
.
Empty
;
return
string
.
Empty
;
}
}
#
endregion
#
endregion
}
}
}
}
DataEditorX/Common/ZipStorer.cs
View file @
e72f147e
...
@@ -7,758 +7,758 @@
...
@@ -7,758 +7,758 @@
namespace
System.IO.Compression
namespace
System.IO.Compression
{
{
/// <summary>
/// <summary>
/// Unique class for compression/decompression file. Represents a Zip file.
/// Unique class for compression/decompression file. Represents a Zip file.
/// </summary>
/// </summary>
public
class
ZipStorer
:
IDisposable
public
class
ZipStorer
:
IDisposable
{
{
/// <summary>
/// <summary>
/// Compression method enumeration
/// Compression method enumeration
/// </summary>
/// </summary>
public
enum
Compression
:
ushort
{
public
enum
Compression
:
ushort
{
/// <summary>Uncompressed storage</summary>
/// <summary>Uncompressed storage</summary>
Store
=
0
,
Store
=
0
,
/// <summary>Deflate compression method</summary>
/// <summary>Deflate compression method</summary>
Deflate
=
8
}
Deflate
=
8
}
#
region
ZipFileEntry
#
region
ZipFileEntry
/// <summary>
/// <summary>
/// Represents an entry in Zip file directory
/// Represents an entry in Zip file directory
/// </summary>
/// </summary>
public
struct
ZipFileEntry
public
struct
ZipFileEntry
{
{
/// <summary>Compression method</summary>
/// <summary>Compression method</summary>
public
Compression
Method
;
public
Compression
Method
;
/// <summary>Full path and filename as stored in Zip</summary>
/// <summary>Full path and filename as stored in Zip</summary>
public
string
FilenameInZip
;
public
string
FilenameInZip
;
/// <summary>Original file size</summary>
/// <summary>Original file size</summary>
public
uint
FileSize
;
public
uint
FileSize
;
/// <summary>Compressed file size</summary>
/// <summary>Compressed file size</summary>
public
uint
CompressedSize
;
public
uint
CompressedSize
;
/// <summary>Offset of header information inside Zip storage</summary>
/// <summary>Offset of header information inside Zip storage</summary>
public
uint
HeaderOffset
;
public
uint
HeaderOffset
;
/// <summary>Offset of file inside Zip storage</summary>
/// <summary>Offset of file inside Zip storage</summary>
public
uint
FileOffset
;
public
uint
FileOffset
;
/// <summary>Size of header information</summary>
/// <summary>Size of header information</summary>
public
uint
HeaderSize
;
public
uint
HeaderSize
;
/// <summary>32-bit checksum of entire file</summary>
/// <summary>32-bit checksum of entire file</summary>
public
uint
Crc32
;
public
uint
Crc32
;
/// <summary>Last modification time of file</summary>
/// <summary>Last modification time of file</summary>
public
DateTime
ModifyTime
;
public
DateTime
ModifyTime
;
/// <summary>User comment for file</summary>
/// <summary>User comment for file</summary>
public
string
Comment
;
public
string
Comment
;
/// <summary>True if UTF8 encoding for filename and comments, false if default (CP 437)</summary>
/// <summary>True if UTF8 encoding for filename and comments, false if default (CP 437)</summary>
public
bool
EncodeUTF8
;
public
bool
EncodeUTF8
;
/// <summary>Overriden method</summary>
/// <summary>Overriden method</summary>
/// <returns>Filename in Zip</returns>
/// <returns>Filename in Zip</returns>
public
override
string
ToString
()
public
override
string
ToString
()
{
{
return
this
.
FilenameInZip
;
return
this
.
FilenameInZip
;
}
}
}
}
#
endregion
#
endregion
#
region
Public
fields
#
region
Public
fields
/// <summary>True if UTF8 encoding for filename and comments, false if default (CP 437)</summary>
/// <summary>True if UTF8 encoding for filename and comments, false if default (CP 437)</summary>
public
bool
EncodeUTF8
=
true
;
public
bool
EncodeUTF8
=
true
;
/// <summary>Force deflate algotithm even if it inflates the stored file. Off by default.</summary>
/// <summary>Force deflate algotithm even if it inflates the stored file. Off by default.</summary>
public
bool
ForceDeflating
=
false
;
public
bool
ForceDeflating
=
false
;
#
endregion
#
endregion
#
region
Private
fields
#
region
Private
fields
// List of files to store
// List of files to store
private
List
<
ZipFileEntry
>
Files
=
new
List
<
ZipFileEntry
>();
private
List
<
ZipFileEntry
>
Files
=
new
List
<
ZipFileEntry
>();
// Filename of storage file
// Filename of storage file
private
string
FileName
;
private
string
FileName
;
// Stream object of storage file
// Stream object of storage file
private
Stream
ZipFileStream
;
private
Stream
ZipFileStream
;
// General comment
// General comment
private
string
Comment
=
""
;
private
string
Comment
=
""
;
// Central dir image
// Central dir image
private
byte
[]
CentralDirImage
=
null
;
private
byte
[]
CentralDirImage
=
null
;
// Existing files in zip
// Existing files in zip
private
ushort
ExistingFiles
=
0
;
private
ushort
ExistingFiles
=
0
;
// File access for Open method
// File access for Open method
private
FileAccess
Access
;
private
FileAccess
Access
;
// Static CRC32 Table
// Static CRC32 Table
private
static
UInt32
[]
CrcTable
=
null
;
private
static
UInt32
[]
CrcTable
=
null
;
// Default filename encoder
// Default filename encoder
private
static
Encoding
DefaultEncoding
=
Encoding
.
GetEncoding
(
437
);
private
static
Encoding
DefaultEncoding
=
Encoding
.
GetEncoding
(
437
);
#
endregion
#
endregion
#
region
Public
methods
#
region
Public
methods
// Static constructor. Just invoked once in order to create the CRC32 lookup table.
// Static constructor. Just invoked once in order to create the CRC32 lookup table.
static
ZipStorer
()
static
ZipStorer
()
{
{
// Generate CRC32 table
// Generate CRC32 table
CrcTable
=
new
UInt32
[
256
];
CrcTable
=
new
UInt32
[
256
];
for
(
int
i
=
0
;
i
<
CrcTable
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
CrcTable
.
Length
;
i
++)
{
{
UInt32
c
=
(
UInt32
)
i
;
UInt32
c
=
(
UInt32
)
i
;
for
(
int
j
=
0
;
j
<
8
;
j
++)
for
(
int
j
=
0
;
j
<
8
;
j
++)
{
{
if
((
c
&
1
)
!=
0
)
if
((
c
&
1
)
!=
0
)
c
=
3988292384
^
(
c
>>
1
);
c
=
3988292384
^
(
c
>>
1
);
else
else
c
>>=
1
;
c
>>=
1
;
}
}
CrcTable
[
i
]
=
c
;
CrcTable
[
i
]
=
c
;
}
}
}
}
/// <summary>
/// <summary>
/// Method to create a new storage file
/// Method to create a new storage file
/// </summary>
/// </summary>
/// <param name="_filename">Full path of Zip file to create</param>
/// <param name="_filename">Full path of Zip file to create</param>
/// <param name="_comment">General comment for Zip file</param>
/// <param name="_comment">General comment for Zip file</param>
/// <returns>A valid ZipStorer object</returns>
/// <returns>A valid ZipStorer object</returns>
public
static
ZipStorer
Create
(
string
_filename
,
string
_comment
)
public
static
ZipStorer
Create
(
string
_filename
,
string
_comment
)
{
{
Stream
stream
=
new
FileStream
(
_filename
,
FileMode
.
Create
,
FileAccess
.
ReadWrite
);
Stream
stream
=
new
FileStream
(
_filename
,
FileMode
.
Create
,
FileAccess
.
ReadWrite
);
ZipStorer
zip
=
Create
(
stream
,
_comment
);
ZipStorer
zip
=
Create
(
stream
,
_comment
);
zip
.
Comment
=
_comment
;
zip
.
Comment
=
_comment
;
zip
.
FileName
=
_filename
;
zip
.
FileName
=
_filename
;
return
zip
;
return
zip
;
}
}
/// <summary>
/// <summary>
/// Method to create a new zip storage in a stream
/// Method to create a new zip storage in a stream
/// </summary>
/// </summary>
/// <param name="_stream"></param>
/// <param name="_stream"></param>
/// <param name="_comment"></param>
/// <param name="_comment"></param>
/// <returns>A valid ZipStorer object</returns>
/// <returns>A valid ZipStorer object</returns>
public
static
ZipStorer
Create
(
Stream
_stream
,
string
_comment
)
public
static
ZipStorer
Create
(
Stream
_stream
,
string
_comment
)
{
{
ZipStorer
zip
=
new
ZipStorer
();
ZipStorer
zip
=
new
ZipStorer
();
zip
.
Comment
=
_comment
;
zip
.
Comment
=
_comment
;
zip
.
ZipFileStream
=
_stream
;
zip
.
ZipFileStream
=
_stream
;
zip
.
Access
=
FileAccess
.
Write
;
zip
.
Access
=
FileAccess
.
Write
;
return
zip
;
return
zip
;
}
}
/// <summary>
/// <summary>
/// Method to open an existing storage file
/// Method to open an existing storage file
/// </summary>
/// </summary>
/// <param name="_filename">Full path of Zip file to open</param>
/// <param name="_filename">Full path of Zip file to open</param>
/// <param name="_access">File access mode as used in FileStream constructor</param>
/// <param name="_access">File access mode as used in FileStream constructor</param>
/// <returns>A valid ZipStorer object</returns>
/// <returns>A valid ZipStorer object</returns>
public
static
ZipStorer
Open
(
string
_filename
,
FileAccess
_access
)
public
static
ZipStorer
Open
(
string
_filename
,
FileAccess
_access
)
{
{
Stream
stream
=
(
Stream
)
new
FileStream
(
_filename
,
FileMode
.
Open
,
_access
==
FileAccess
.
Read
?
FileAccess
.
Read
:
FileAccess
.
ReadWrite
);
Stream
stream
=
(
Stream
)
new
FileStream
(
_filename
,
FileMode
.
Open
,
_access
==
FileAccess
.
Read
?
FileAccess
.
Read
:
FileAccess
.
ReadWrite
);
ZipStorer
zip
=
Open
(
stream
,
_access
);
ZipStorer
zip
=
Open
(
stream
,
_access
);
zip
.
FileName
=
_filename
;
zip
.
FileName
=
_filename
;
return
zip
;
return
zip
;
}
}
/// <summary>
/// <summary>
/// Method to open an existing storage from stream
/// Method to open an existing storage from stream
/// </summary>
/// </summary>
/// <param name="_stream">Already opened stream with zip contents</param>
/// <param name="_stream">Already opened stream with zip contents</param>
/// <param name="_access">File access mode for stream operations</param>
/// <param name="_access">File access mode for stream operations</param>
/// <returns>A valid ZipStorer object</returns>
/// <returns>A valid ZipStorer object</returns>
public
static
ZipStorer
Open
(
Stream
_stream
,
FileAccess
_access
)
public
static
ZipStorer
Open
(
Stream
_stream
,
FileAccess
_access
)
{
{
if
(!
_stream
.
CanSeek
&&
_access
!=
FileAccess
.
Read
)
if
(!
_stream
.
CanSeek
&&
_access
!=
FileAccess
.
Read
)
throw
new
InvalidOperationException
(
"Stream cannot seek"
);
throw
new
InvalidOperationException
(
"Stream cannot seek"
);
ZipStorer
zip
=
new
ZipStorer
();
ZipStorer
zip
=
new
ZipStorer
();
//zip.FileName = _filename;
//zip.FileName = _filename;
zip
.
ZipFileStream
=
_stream
;
zip
.
ZipFileStream
=
_stream
;
zip
.
Access
=
_access
;
zip
.
Access
=
_access
;
if
(
zip
.
ReadFileInfo
())
if
(
zip
.
ReadFileInfo
())
return
zip
;
return
zip
;
throw
new
System
.
IO
.
InvalidDataException
();
throw
new
System
.
IO
.
InvalidDataException
();
}
}
/// <summary>
/// <summary>
/// Add full contents of a file into the Zip storage
/// Add full contents of a file into the Zip storage
/// </summary>
/// </summary>
/// <param name="_method">Compression method</param>
/// <param name="_method">Compression method</param>
/// <param name="_pathname">Full path of file to add to Zip storage</param>
/// <param name="_pathname">Full path of file to add to Zip storage</param>
/// <param name="_filenameInZip">Filename and path as desired in Zip directory</param>
/// <param name="_filenameInZip">Filename and path as desired in Zip directory</param>
/// <param name="_comment">Comment for stored file</param>
/// <param name="_comment">Comment for stored file</param>
public
void
AddFile
(
string
_pathname
,
string
_filenameInZip
,
string
_comment
)
public
void
AddFile
(
string
_pathname
,
string
_filenameInZip
,
string
_comment
)
{
{
Compression
_method
=
Compression
.
Deflate
;
Compression
_method
=
Compression
.
Deflate
;
if
(
Access
==
FileAccess
.
Read
)
if
(
Access
==
FileAccess
.
Read
)
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
FileStream
stream
=
new
FileStream
(
_pathname
,
FileMode
.
Open
,
FileAccess
.
Read
);
FileStream
stream
=
new
FileStream
(
_pathname
,
FileMode
.
Open
,
FileAccess
.
Read
);
AddStream
(
_method
,
_filenameInZip
,
stream
,
File
.
GetLastWriteTime
(
_pathname
),
_comment
);
AddStream
(
_method
,
_filenameInZip
,
stream
,
File
.
GetLastWriteTime
(
_pathname
),
_comment
);
stream
.
Close
();
stream
.
Close
();
}
}
/// <summary>
/// <summary>
/// Add full contents of a file into the Zip storage
/// Add full contents of a file into the Zip storage
/// </summary>
/// </summary>
/// <param name="_method">Compression method</param>
/// <param name="_method">Compression method</param>
/// <param name="_pathname">Full path of file to add to Zip storage</param>
/// <param name="_pathname">Full path of file to add to Zip storage</param>
/// <param name="_filenameInZip">Filename and path as desired in Zip directory</param>
/// <param name="_filenameInZip">Filename and path as desired in Zip directory</param>
/// <param name="_comment">Comment for stored file</param>
/// <param name="_comment">Comment for stored file</param>
public
void
AddFile
(
Compression
_method
,
string
_pathname
,
string
_filenameInZip
,
string
_comment
)
public
void
AddFile
(
Compression
_method
,
string
_pathname
,
string
_filenameInZip
,
string
_comment
)
{
{
if
(
Access
==
FileAccess
.
Read
)
if
(
Access
==
FileAccess
.
Read
)
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
FileStream
stream
=
new
FileStream
(
_pathname
,
FileMode
.
Open
,
FileAccess
.
Read
);
FileStream
stream
=
new
FileStream
(
_pathname
,
FileMode
.
Open
,
FileAccess
.
Read
);
AddStream
(
_method
,
_filenameInZip
,
stream
,
File
.
GetLastWriteTime
(
_pathname
),
_comment
);
AddStream
(
_method
,
_filenameInZip
,
stream
,
File
.
GetLastWriteTime
(
_pathname
),
_comment
);
stream
.
Close
();
stream
.
Close
();
}
}
/// <summary>
/// <summary>
/// Add full contents of a stream into the Zip storage
/// Add full contents of a stream into the Zip storage
/// </summary>
/// </summary>
/// <param name="_method">Compression method</param>
/// <param name="_method">Compression method</param>
/// <param name="_filenameInZip">Filename and path as desired in Zip directory</param>
/// <param name="_filenameInZip">Filename and path as desired in Zip directory</param>
/// <param name="_source">Stream object containing the data to store in Zip</param>
/// <param name="_source">Stream object containing the data to store in Zip</param>
/// <param name="_modTime">Modification time of the data to store</param>
/// <param name="_modTime">Modification time of the data to store</param>
/// <param name="_comment">Comment for stored file</param>
/// <param name="_comment">Comment for stored file</param>
public
void
AddStream
(
Compression
_method
,
string
_filenameInZip
,
Stream
_source
,
DateTime
_modTime
,
string
_comment
)
public
void
AddStream
(
Compression
_method
,
string
_filenameInZip
,
Stream
_source
,
DateTime
_modTime
,
string
_comment
)
{
{
if
(
Access
==
FileAccess
.
Read
)
if
(
Access
==
FileAccess
.
Read
)
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
long
offset
;
long
offset
;
if
(
this
.
Files
.
Count
==
0
)
if
(
this
.
Files
.
Count
==
0
)
offset
=
0
;
offset
=
0
;
else
else
{
{
ZipFileEntry
last
=
this
.
Files
[
this
.
Files
.
Count
-
1
];
ZipFileEntry
last
=
this
.
Files
[
this
.
Files
.
Count
-
1
];
offset
=
last
.
HeaderOffset
+
last
.
HeaderSize
;
offset
=
last
.
HeaderOffset
+
last
.
HeaderSize
;
}
}
// Prepare the fileinfo
// Prepare the fileinfo
ZipFileEntry
zfe
=
new
ZipFileEntry
();
ZipFileEntry
zfe
=
new
ZipFileEntry
();
zfe
.
Method
=
_method
;
zfe
.
Method
=
_method
;
zfe
.
EncodeUTF8
=
this
.
EncodeUTF8
;
zfe
.
EncodeUTF8
=
this
.
EncodeUTF8
;
zfe
.
FilenameInZip
=
NormalizedFilename
(
_filenameInZip
);
zfe
.
FilenameInZip
=
NormalizedFilename
(
_filenameInZip
);
zfe
.
Comment
=
(
_comment
==
null
?
""
:
_comment
);
zfe
.
Comment
=
(
_comment
==
null
?
""
:
_comment
);
// Even though we write the header now, it will have to be rewritten, since we don't know compressed size or crc.
// Even though we write the header now, it will have to be rewritten, since we don't know compressed size or crc.
zfe
.
Crc32
=
0
;
// to be updated later
zfe
.
Crc32
=
0
;
// to be updated later
zfe
.
HeaderOffset
=
(
uint
)
this
.
ZipFileStream
.
Position
;
// offset within file of the start of this local record
zfe
.
HeaderOffset
=
(
uint
)
this
.
ZipFileStream
.
Position
;
// offset within file of the start of this local record
zfe
.
ModifyTime
=
_modTime
;
zfe
.
ModifyTime
=
_modTime
;
// Write local header
// Write local header
WriteLocalHeader
(
ref
zfe
);
WriteLocalHeader
(
ref
zfe
);
zfe
.
FileOffset
=
(
uint
)
this
.
ZipFileStream
.
Position
;
zfe
.
FileOffset
=
(
uint
)
this
.
ZipFileStream
.
Position
;
// Write file to zip (store)
// Write file to zip (store)
Store
(
ref
zfe
,
_source
);
Store
(
ref
zfe
,
_source
);
_source
.
Close
();
_source
.
Close
();
this
.
UpdateCrcAndSizes
(
ref
zfe
);
this
.
UpdateCrcAndSizes
(
ref
zfe
);
Files
.
Add
(
zfe
);
Files
.
Add
(
zfe
);
}
}
/// <summary>
/// <summary>
/// Updates central directory (if pertinent) and close the Zip storage
/// Updates central directory (if pertinent) and close the Zip storage
/// </summary>
/// </summary>
/// <remarks>This is a required step, unless automatic dispose is used</remarks>
/// <remarks>This is a required step, unless automatic dispose is used</remarks>
public
void
Close
()
public
void
Close
()
{
{
if
(
this
.
Access
!=
FileAccess
.
Read
)
if
(
this
.
Access
!=
FileAccess
.
Read
)
{
{
uint
centralOffset
=
(
uint
)
this
.
ZipFileStream
.
Position
;
uint
centralOffset
=
(
uint
)
this
.
ZipFileStream
.
Position
;
uint
centralSize
=
0
;
uint
centralSize
=
0
;
if
(
this
.
CentralDirImage
!=
null
)
if
(
this
.
CentralDirImage
!=
null
)
this
.
ZipFileStream
.
Write
(
CentralDirImage
,
0
,
CentralDirImage
.
Length
);
this
.
ZipFileStream
.
Write
(
CentralDirImage
,
0
,
CentralDirImage
.
Length
);
for
(
int
i
=
0
;
i
<
Files
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
Files
.
Count
;
i
++)
{
{
long
pos
=
this
.
ZipFileStream
.
Position
;
long
pos
=
this
.
ZipFileStream
.
Position
;
this
.
WriteCentralDirRecord
(
Files
[
i
]);
this
.
WriteCentralDirRecord
(
Files
[
i
]);
centralSize
+=
(
uint
)(
this
.
ZipFileStream
.
Position
-
pos
);
centralSize
+=
(
uint
)(
this
.
ZipFileStream
.
Position
-
pos
);
}
}
if
(
this
.
CentralDirImage
!=
null
)
if
(
this
.
CentralDirImage
!=
null
)
this
.
WriteEndRecord
(
centralSize
+
(
uint
)
CentralDirImage
.
Length
,
centralOffset
);
this
.
WriteEndRecord
(
centralSize
+
(
uint
)
CentralDirImage
.
Length
,
centralOffset
);
else
else
this
.
WriteEndRecord
(
centralSize
,
centralOffset
);
this
.
WriteEndRecord
(
centralSize
,
centralOffset
);
}
}
if
(
this
.
ZipFileStream
!=
null
)
if
(
this
.
ZipFileStream
!=
null
)
{
{
this
.
ZipFileStream
.
Flush
();
this
.
ZipFileStream
.
Flush
();
this
.
ZipFileStream
.
Dispose
();
this
.
ZipFileStream
.
Dispose
();
this
.
ZipFileStream
=
null
;
this
.
ZipFileStream
=
null
;
}
}
}
}
/// <summary>
/// <summary>
/// Read all the file records in the central directory
/// Read all the file records in the central directory
/// </summary>
/// </summary>
/// <returns>List of all entries in directory</returns>
/// <returns>List of all entries in directory</returns>
public
List
<
ZipFileEntry
>
ReadCentralDir
()
public
List
<
ZipFileEntry
>
ReadCentralDir
()
{
{
if
(
this
.
CentralDirImage
==
null
)
if
(
this
.
CentralDirImage
==
null
)
throw
new
InvalidOperationException
(
"Central directory currently does not exist"
);
throw
new
InvalidOperationException
(
"Central directory currently does not exist"
);
List
<
ZipFileEntry
>
result
=
new
List
<
ZipFileEntry
>();
List
<
ZipFileEntry
>
result
=
new
List
<
ZipFileEntry
>();
for
(
int
pointer
=
0
;
pointer
<
this
.
CentralDirImage
.
Length
;
)
for
(
int
pointer
=
0
;
pointer
<
this
.
CentralDirImage
.
Length
;
)
{
{
uint
signature
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
);
uint
signature
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
);
if
(
signature
!=
0x02014b50
)
if
(
signature
!=
0x02014b50
)
break
;
break
;
bool
encodeUTF8
=
(
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
8
)
&
0x0800
)
!=
0
;
bool
encodeUTF8
=
(
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
8
)
&
0x0800
)
!=
0
;
ushort
method
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
10
);
ushort
method
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
10
);
uint
modifyTime
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
12
);
uint
modifyTime
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
12
);
uint
crc32
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
16
);
uint
crc32
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
16
);
uint
comprSize
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
20
);
uint
comprSize
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
20
);
uint
fileSize
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
24
);
uint
fileSize
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
24
);
ushort
filenameSize
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
28
);
ushort
filenameSize
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
28
);
ushort
extraSize
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
30
);
ushort
extraSize
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
30
);
ushort
commentSize
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
32
);
ushort
commentSize
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
32
);
uint
headerOffset
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
42
);
uint
headerOffset
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
42
);
uint
headerSize
=
(
uint
)(
46
+
filenameSize
+
extraSize
+
commentSize
);
uint
headerSize
=
(
uint
)(
46
+
filenameSize
+
extraSize
+
commentSize
);
Encoding
encoder
=
encodeUTF8
?
Encoding
.
UTF8
:
DefaultEncoding
;
Encoding
encoder
=
encodeUTF8
?
Encoding
.
UTF8
:
DefaultEncoding
;
ZipFileEntry
zfe
=
new
ZipFileEntry
();
ZipFileEntry
zfe
=
new
ZipFileEntry
();
zfe
.
Method
=
(
Compression
)
method
;
zfe
.
Method
=
(
Compression
)
method
;
zfe
.
FilenameInZip
=
encoder
.
GetString
(
CentralDirImage
,
pointer
+
46
,
filenameSize
);
zfe
.
FilenameInZip
=
encoder
.
GetString
(
CentralDirImage
,
pointer
+
46
,
filenameSize
);
zfe
.
FileOffset
=
GetFileOffset
(
headerOffset
);
zfe
.
FileOffset
=
GetFileOffset
(
headerOffset
);
zfe
.
FileSize
=
fileSize
;
zfe
.
FileSize
=
fileSize
;
zfe
.
CompressedSize
=
comprSize
;
zfe
.
CompressedSize
=
comprSize
;
zfe
.
HeaderOffset
=
headerOffset
;
zfe
.
HeaderOffset
=
headerOffset
;
zfe
.
HeaderSize
=
headerSize
;
zfe
.
HeaderSize
=
headerSize
;
zfe
.
Crc32
=
crc32
;
zfe
.
Crc32
=
crc32
;
zfe
.
ModifyTime
=
DosTimeToDateTime
(
modifyTime
);
zfe
.
ModifyTime
=
DosTimeToDateTime
(
modifyTime
);
if
(
commentSize
>
0
)
if
(
commentSize
>
0
)
zfe
.
Comment
=
encoder
.
GetString
(
CentralDirImage
,
pointer
+
46
+
filenameSize
+
extraSize
,
commentSize
);
zfe
.
Comment
=
encoder
.
GetString
(
CentralDirImage
,
pointer
+
46
+
filenameSize
+
extraSize
,
commentSize
);
result
.
Add
(
zfe
);
result
.
Add
(
zfe
);
pointer
+=
(
46
+
filenameSize
+
extraSize
+
commentSize
);
pointer
+=
(
46
+
filenameSize
+
extraSize
+
commentSize
);
}
}
return
result
;
return
result
;
}
}
/// <summary>
/// <summary>
/// Copy the contents of a stored file into a physical file
/// Copy the contents of a stored file into a physical file
/// </summary>
/// </summary>
/// <param name="_zfe">Entry information of file to extract</param>
/// <param name="_zfe">Entry information of file to extract</param>
/// <param name="_filename">Name of file to store uncompressed data</param>
/// <param name="_filename">Name of file to store uncompressed data</param>
/// <returns>True if success, false if not.</returns>
/// <returns>True if success, false if not.</returns>
/// <remarks>Unique compression methods are Store and Deflate</remarks>
/// <remarks>Unique compression methods are Store and Deflate</remarks>
public
bool
ExtractFile
(
ZipFileEntry
_zfe
,
string
_filename
)
public
bool
ExtractFile
(
ZipFileEntry
_zfe
,
string
_filename
)
{
{
// Make sure the parent directory exist
// Make sure the parent directory exist
string
path
=
System
.
IO
.
Path
.
GetDirectoryName
(
_filename
);
string
path
=
System
.
IO
.
Path
.
GetDirectoryName
(
_filename
);
if
(!
Directory
.
Exists
(
path
))
if
(!
Directory
.
Exists
(
path
))
Directory
.
CreateDirectory
(
path
);
Directory
.
CreateDirectory
(
path
);
// Check it is directory. If so, do nothing
// Check it is directory. If so, do nothing
if
(
Directory
.
Exists
(
_filename
))
if
(
Directory
.
Exists
(
_filename
))
return
true
;
return
true
;
Stream
output
=
new
FileStream
(
_filename
,
FileMode
.
Create
,
FileAccess
.
Write
);
Stream
output
=
new
FileStream
(
_filename
,
FileMode
.
Create
,
FileAccess
.
Write
);
bool
result
=
ExtractFile
(
_zfe
,
output
);
bool
result
=
ExtractFile
(
_zfe
,
output
);
if
(
result
)
if
(
result
)
output
.
Close
();
output
.
Close
();
File
.
SetCreationTime
(
_filename
,
_zfe
.
ModifyTime
);
File
.
SetCreationTime
(
_filename
,
_zfe
.
ModifyTime
);
File
.
SetLastWriteTime
(
_filename
,
_zfe
.
ModifyTime
);
File
.
SetLastWriteTime
(
_filename
,
_zfe
.
ModifyTime
);
return
result
;
return
result
;
}
}
/// <summary>
/// <summary>
/// Copy the contents of a stored file into an opened stream
/// Copy the contents of a stored file into an opened stream
/// </summary>
/// </summary>
/// <param name="_zfe">Entry information of file to extract</param>
/// <param name="_zfe">Entry information of file to extract</param>
/// <param name="_stream">Stream to store the uncompressed data</param>
/// <param name="_stream">Stream to store the uncompressed data</param>
/// <returns>True if success, false if not.</returns>
/// <returns>True if success, false if not.</returns>
/// <remarks>Unique compression methods are Store and Deflate</remarks>
/// <remarks>Unique compression methods are Store and Deflate</remarks>
public
bool
ExtractFile
(
ZipFileEntry
_zfe
,
Stream
_stream
)
public
bool
ExtractFile
(
ZipFileEntry
_zfe
,
Stream
_stream
)
{
{
if
(!
_stream
.
CanWrite
)
if
(!
_stream
.
CanWrite
)
throw
new
InvalidOperationException
(
"Stream cannot be written"
);
throw
new
InvalidOperationException
(
"Stream cannot be written"
);
// check signature
// check signature
byte
[]
signature
=
new
byte
[
4
];
byte
[]
signature
=
new
byte
[
4
];
this
.
ZipFileStream
.
Seek
(
_zfe
.
HeaderOffset
,
SeekOrigin
.
Begin
);
this
.
ZipFileStream
.
Seek
(
_zfe
.
HeaderOffset
,
SeekOrigin
.
Begin
);
this
.
ZipFileStream
.
Read
(
signature
,
0
,
4
);
this
.
ZipFileStream
.
Read
(
signature
,
0
,
4
);
if
(
BitConverter
.
ToUInt32
(
signature
,
0
)
!=
0x04034b50
)
if
(
BitConverter
.
ToUInt32
(
signature
,
0
)
!=
0x04034b50
)
return
false
;
return
false
;
// Select input stream for inflating or just reading
// Select input stream for inflating or just reading
Stream
inStream
;
Stream
inStream
;
if
(
_zfe
.
Method
==
Compression
.
Store
)
if
(
_zfe
.
Method
==
Compression
.
Store
)
inStream
=
this
.
ZipFileStream
;
inStream
=
this
.
ZipFileStream
;
else
if
(
_zfe
.
Method
==
Compression
.
Deflate
)
else
if
(
_zfe
.
Method
==
Compression
.
Deflate
)
inStream
=
new
DeflateStream
(
this
.
ZipFileStream
,
CompressionMode
.
Decompress
,
true
);
inStream
=
new
DeflateStream
(
this
.
ZipFileStream
,
CompressionMode
.
Decompress
,
true
);
else
else
return
false
;
return
false
;
// Buffered copy
// Buffered copy
byte
[]
buffer
=
new
byte
[
16384
];
byte
[]
buffer
=
new
byte
[
16384
];
this
.
ZipFileStream
.
Seek
(
_zfe
.
FileOffset
,
SeekOrigin
.
Begin
);
this
.
ZipFileStream
.
Seek
(
_zfe
.
FileOffset
,
SeekOrigin
.
Begin
);
uint
bytesPending
=
_zfe
.
FileSize
;
uint
bytesPending
=
_zfe
.
FileSize
;
while
(
bytesPending
>
0
)
while
(
bytesPending
>
0
)
{
{
int
bytesRead
=
inStream
.
Read
(
buffer
,
0
,
(
int
)
Math
.
Min
(
bytesPending
,
buffer
.
Length
));
int
bytesRead
=
inStream
.
Read
(
buffer
,
0
,
(
int
)
Math
.
Min
(
bytesPending
,
buffer
.
Length
));
_stream
.
Write
(
buffer
,
0
,
bytesRead
);
_stream
.
Write
(
buffer
,
0
,
bytesRead
);
bytesPending
-=
(
uint
)
bytesRead
;
bytesPending
-=
(
uint
)
bytesRead
;
}
}
_stream
.
Flush
();
_stream
.
Flush
();
if
(
_zfe
.
Method
==
Compression
.
Deflate
)
if
(
_zfe
.
Method
==
Compression
.
Deflate
)
inStream
.
Dispose
();
inStream
.
Dispose
();
return
true
;
return
true
;
}
}
/// <summary>
/// <summary>
/// Removes one of many files in storage. It creates a new Zip file.
/// Removes one of many files in storage. It creates a new Zip file.
/// </summary>
/// </summary>
/// <param name="_zip">Reference to the current Zip object</param>
/// <param name="_zip">Reference to the current Zip object</param>
/// <param name="_zfes">List of Entries to remove from storage</param>
/// <param name="_zfes">List of Entries to remove from storage</param>
/// <returns>True if success, false if not</returns>
/// <returns>True if success, false if not</returns>
/// <remarks>This method only works for storage of type FileStream</remarks>
/// <remarks>This method only works for storage of type FileStream</remarks>
public
static
bool
RemoveEntries
(
ref
ZipStorer
_zip
,
List
<
ZipFileEntry
>
_zfes
)
public
static
bool
RemoveEntries
(
ref
ZipStorer
_zip
,
List
<
ZipFileEntry
>
_zfes
)
{
{
if
(!(
_zip
.
ZipFileStream
is
FileStream
))
if
(!(
_zip
.
ZipFileStream
is
FileStream
))
throw
new
InvalidOperationException
(
"RemoveEntries is allowed just over streams of type FileStream"
);
throw
new
InvalidOperationException
(
"RemoveEntries is allowed just over streams of type FileStream"
);
//Get full list of entries
//Get full list of entries
List
<
ZipFileEntry
>
fullList
=
_zip
.
ReadCentralDir
();
List
<
ZipFileEntry
>
fullList
=
_zip
.
ReadCentralDir
();
//In order to delete we need to create a copy of the zip file excluding the selected items
//In order to delete we need to create a copy of the zip file excluding the selected items
string
tempZipName
=
Path
.
GetTempFileName
();
string
tempZipName
=
Path
.
GetTempFileName
();
string
tempEntryName
=
Path
.
GetTempFileName
();
string
tempEntryName
=
Path
.
GetTempFileName
();
try
try
{
{
ZipStorer
tempZip
=
ZipStorer
.
Create
(
tempZipName
,
string
.
Empty
);
ZipStorer
tempZip
=
ZipStorer
.
Create
(
tempZipName
,
string
.
Empty
);
foreach
(
ZipFileEntry
zfe
in
fullList
)
foreach
(
ZipFileEntry
zfe
in
fullList
)
{
{
if
(!
_zfes
.
Contains
(
zfe
))
if
(!
_zfes
.
Contains
(
zfe
))
{
{
if
(
_zip
.
ExtractFile
(
zfe
,
tempEntryName
))
if
(
_zip
.
ExtractFile
(
zfe
,
tempEntryName
))
{
{
tempZip
.
AddFile
(
zfe
.
Method
,
tempEntryName
,
zfe
.
FilenameInZip
,
zfe
.
Comment
);
tempZip
.
AddFile
(
zfe
.
Method
,
tempEntryName
,
zfe
.
FilenameInZip
,
zfe
.
Comment
);
}
}
}
}
}
}
_zip
.
Close
();
_zip
.
Close
();
tempZip
.
Close
();
tempZip
.
Close
();
File
.
Delete
(
_zip
.
FileName
);
File
.
Delete
(
_zip
.
FileName
);
File
.
Move
(
tempZipName
,
_zip
.
FileName
);
File
.
Move
(
tempZipName
,
_zip
.
FileName
);
_zip
=
ZipStorer
.
Open
(
_zip
.
FileName
,
_zip
.
Access
);
_zip
=
ZipStorer
.
Open
(
_zip
.
FileName
,
_zip
.
Access
);
}
}
catch
catch
{
{
return
false
;
return
false
;
}
}
finally
finally
{
{
if
(
File
.
Exists
(
tempZipName
))
if
(
File
.
Exists
(
tempZipName
))
File
.
Delete
(
tempZipName
);
File
.
Delete
(
tempZipName
);
if
(
File
.
Exists
(
tempEntryName
))
if
(
File
.
Exists
(
tempEntryName
))
File
.
Delete
(
tempEntryName
);
File
.
Delete
(
tempEntryName
);
}
}
return
true
;
return
true
;
}
}
#
endregion
#
endregion
#
region
Private
methods
#
region
Private
methods
// Calculate the file offset by reading the corresponding local header
// Calculate the file offset by reading the corresponding local header
private
uint
GetFileOffset
(
uint
_headerOffset
)
private
uint
GetFileOffset
(
uint
_headerOffset
)
{
{
byte
[]
buffer
=
new
byte
[
2
];
byte
[]
buffer
=
new
byte
[
2
];
this
.
ZipFileStream
.
Seek
(
_headerOffset
+
26
,
SeekOrigin
.
Begin
);
this
.
ZipFileStream
.
Seek
(
_headerOffset
+
26
,
SeekOrigin
.
Begin
);
this
.
ZipFileStream
.
Read
(
buffer
,
0
,
2
);
this
.
ZipFileStream
.
Read
(
buffer
,
0
,
2
);
ushort
filenameSize
=
BitConverter
.
ToUInt16
(
buffer
,
0
);
ushort
filenameSize
=
BitConverter
.
ToUInt16
(
buffer
,
0
);
this
.
ZipFileStream
.
Read
(
buffer
,
0
,
2
);
this
.
ZipFileStream
.
Read
(
buffer
,
0
,
2
);
ushort
extraSize
=
BitConverter
.
ToUInt16
(
buffer
,
0
);
ushort
extraSize
=
BitConverter
.
ToUInt16
(
buffer
,
0
);
return
(
uint
)(
30
+
filenameSize
+
extraSize
+
_headerOffset
);
return
(
uint
)(
30
+
filenameSize
+
extraSize
+
_headerOffset
);
}
}
/* Local file header:
/* Local file header:
local file header signature
4 bytes (0x04034b50)
local file header signature
4 bytes (0x04034b50)
version needed to extract
2 bytes
version needed to extract
2 bytes
general purpose bit flag
2 bytes
general purpose bit flag
2 bytes
compression method
2 bytes
compression method
2 bytes
last mod file time
2 bytes
last mod file time
2 bytes
last mod file date
2 bytes
last mod file date
2 bytes
crc-32
4 bytes
crc-32
4 bytes
compressed size
4 bytes
compressed size
4 bytes
uncompressed size
4 bytes
uncompressed size
4 bytes
filename length
2 bytes
filename length
2 bytes
extra field length
2 bytes
extra field length
2 bytes
filename (variable size)
filename (variable size)
extra field (variable size)
extra field (variable size)
*/
*/
private
void
WriteLocalHeader
(
ref
ZipFileEntry
_zfe
)
private
void
WriteLocalHeader
(
ref
ZipFileEntry
_zfe
)
{
{
long
pos
=
this
.
ZipFileStream
.
Position
;
long
pos
=
this
.
ZipFileStream
.
Position
;
Encoding
encoder
=
_zfe
.
EncodeUTF8
?
Encoding
.
UTF8
:
DefaultEncoding
;
Encoding
encoder
=
_zfe
.
EncodeUTF8
?
Encoding
.
UTF8
:
DefaultEncoding
;
byte
[]
encodedFilename
=
encoder
.
GetBytes
(
_zfe
.
FilenameInZip
);
byte
[]
encodedFilename
=
encoder
.
GetBytes
(
_zfe
.
FilenameInZip
);
this
.
ZipFileStream
.
Write
(
new
byte
[]
{
80
,
75
,
3
,
4
,
20
,
0
},
0
,
6
);
// No extra header
this
.
ZipFileStream
.
Write
(
new
byte
[]
{
80
,
75
,
3
,
4
,
20
,
0
},
0
,
6
);
// No extra header
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)(
_zfe
.
EncodeUTF8
?
0x0800
:
0
)),
0
,
2
);
// filename and comment encoding
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)(
_zfe
.
EncodeUTF8
?
0x0800
:
0
)),
0
,
2
);
// filename and comment encoding
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
_zfe
.
Method
),
0
,
2
);
// zipping method
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
_zfe
.
Method
),
0
,
2
);
// zipping method
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
DateTimeToDosTime
(
_zfe
.
ModifyTime
)),
0
,
4
);
// zipping date and time
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
DateTimeToDosTime
(
_zfe
.
ModifyTime
)),
0
,
4
);
// zipping date and time
this
.
ZipFileStream
.
Write
(
new
byte
[]
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},
0
,
12
);
// unused CRC, un/compressed size, updated later
this
.
ZipFileStream
.
Write
(
new
byte
[]
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},
0
,
12
);
// unused CRC, un/compressed size, updated later
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
encodedFilename
.
Length
),
0
,
2
);
// filename length
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
encodedFilename
.
Length
),
0
,
2
);
// filename length
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// extra length
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// extra length
this
.
ZipFileStream
.
Write
(
encodedFilename
,
0
,
encodedFilename
.
Length
);
this
.
ZipFileStream
.
Write
(
encodedFilename
,
0
,
encodedFilename
.
Length
);
_zfe
.
HeaderSize
=
(
uint
)(
this
.
ZipFileStream
.
Position
-
pos
);
_zfe
.
HeaderSize
=
(
uint
)(
this
.
ZipFileStream
.
Position
-
pos
);
}
}
/* Central directory's File header:
/* Central directory's File header:
central file header signature 4 bytes (0x02014b50)
central file header signature 4 bytes (0x02014b50)
version made by
2 bytes
version made by
2 bytes
version needed to extract
2 bytes
version needed to extract
2 bytes
general purpose bit flag
2 bytes
general purpose bit flag
2 bytes
compression method
2 bytes
compression method
2 bytes
last mod file time
2 bytes
last mod file time
2 bytes
last mod file date
2 bytes
last mod file date
2 bytes
crc-32
4 bytes
crc-32
4 bytes
compressed size
4 bytes
compressed size
4 bytes
uncompressed size
4 bytes
uncompressed size
4 bytes
filename length
2 bytes
filename length
2 bytes
extra field length
2 bytes
extra field length
2 bytes
file comment length
2 bytes
file comment length
2 bytes
disk number start
2 bytes
disk number start
2 bytes
internal file attributes
2 bytes
internal file attributes
2 bytes
external file attributes
4 bytes
external file attributes
4 bytes
relative offset of local header 4 bytes
relative offset of local header 4 bytes
filename (variable size)
filename (variable size)
extra field (variable size)
extra field (variable size)
file comment (variable size)
file comment (variable size)
*/
*/
private
void
WriteCentralDirRecord
(
ZipFileEntry
_zfe
)
private
void
WriteCentralDirRecord
(
ZipFileEntry
_zfe
)
{
{
Encoding
encoder
=
_zfe
.
EncodeUTF8
?
Encoding
.
UTF8
:
DefaultEncoding
;
Encoding
encoder
=
_zfe
.
EncodeUTF8
?
Encoding
.
UTF8
:
DefaultEncoding
;
byte
[]
encodedFilename
=
encoder
.
GetBytes
(
_zfe
.
FilenameInZip
);
byte
[]
encodedFilename
=
encoder
.
GetBytes
(
_zfe
.
FilenameInZip
);
byte
[]
encodedComment
=
encoder
.
GetBytes
(
_zfe
.
Comment
);
byte
[]
encodedComment
=
encoder
.
GetBytes
(
_zfe
.
Comment
);
this
.
ZipFileStream
.
Write
(
new
byte
[]
{
80
,
75
,
1
,
2
,
23
,
0xB
,
20
,
0
},
0
,
8
);
this
.
ZipFileStream
.
Write
(
new
byte
[]
{
80
,
75
,
1
,
2
,
23
,
0xB
,
20
,
0
},
0
,
8
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)(
_zfe
.
EncodeUTF8
?
0x0800
:
0
)),
0
,
2
);
// filename and comment encoding
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)(
_zfe
.
EncodeUTF8
?
0x0800
:
0
)),
0
,
2
);
// filename and comment encoding
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
_zfe
.
Method
),
0
,
2
);
// zipping method
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
_zfe
.
Method
),
0
,
2
);
// zipping method
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
DateTimeToDosTime
(
_zfe
.
ModifyTime
)),
0
,
4
);
// zipping date and time
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
DateTimeToDosTime
(
_zfe
.
ModifyTime
)),
0
,
4
);
// zipping date and time
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
Crc32
),
0
,
4
);
// file CRC
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
Crc32
),
0
,
4
);
// file CRC
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
CompressedSize
),
0
,
4
);
// compressed file size
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
CompressedSize
),
0
,
4
);
// compressed file size
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
FileSize
),
0
,
4
);
// uncompressed file size
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
FileSize
),
0
,
4
);
// uncompressed file size
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
encodedFilename
.
Length
),
0
,
2
);
// Filename in zip
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
encodedFilename
.
Length
),
0
,
2
);
// Filename in zip
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// extra length
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// extra length
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
encodedComment
.
Length
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
encodedComment
.
Length
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// disk=0
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// disk=0
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// file type: binary
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// file type: binary
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// Internal file attributes
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0
),
0
,
2
);
// Internal file attributes
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0x8100
),
0
,
2
);
// External file attributes (normal/readable)
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
0x8100
),
0
,
2
);
// External file attributes (normal/readable)
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
HeaderOffset
),
0
,
4
);
// Offset of header
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
HeaderOffset
),
0
,
4
);
// Offset of header
this
.
ZipFileStream
.
Write
(
encodedFilename
,
0
,
encodedFilename
.
Length
);
this
.
ZipFileStream
.
Write
(
encodedFilename
,
0
,
encodedFilename
.
Length
);
this
.
ZipFileStream
.
Write
(
encodedComment
,
0
,
encodedComment
.
Length
);
this
.
ZipFileStream
.
Write
(
encodedComment
,
0
,
encodedComment
.
Length
);
}
}
/* End of central dir record:
/* End of central dir record:
end of central dir signature
4 bytes (0x06054b50)
end of central dir signature
4 bytes (0x06054b50)
number of this disk
2 bytes
number of this disk
2 bytes
number of the disk with the
number of the disk with the
start of the central directory 2 bytes
start of the central directory 2 bytes
total number of entries in
total number of entries in
the central dir on this disk
2 bytes
the central dir on this disk
2 bytes
total number of entries in
total number of entries in
the central dir
2 bytes
the central dir
2 bytes
size of the central directory 4 bytes
size of the central directory 4 bytes
offset of start of central
offset of start of central
directory with respect to
directory with respect to
the starting disk number
4 bytes
the starting disk number
4 bytes
zipfile comment length
2 bytes
zipfile comment length
2 bytes
zipfile comment (variable size)
zipfile comment (variable size)
*/
*/
private
void
WriteEndRecord
(
uint
_size
,
uint
_offset
)
private
void
WriteEndRecord
(
uint
_size
,
uint
_offset
)
{
{
Encoding
encoder
=
this
.
EncodeUTF8
?
Encoding
.
UTF8
:
DefaultEncoding
;
Encoding
encoder
=
this
.
EncodeUTF8
?
Encoding
.
UTF8
:
DefaultEncoding
;
byte
[]
encodedComment
=
encoder
.
GetBytes
(
this
.
Comment
);
byte
[]
encodedComment
=
encoder
.
GetBytes
(
this
.
Comment
);
this
.
ZipFileStream
.
Write
(
new
byte
[]
{
80
,
75
,
5
,
6
,
0
,
0
,
0
,
0
},
0
,
8
);
this
.
ZipFileStream
.
Write
(
new
byte
[]
{
80
,
75
,
5
,
6
,
0
,
0
,
0
,
0
},
0
,
8
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
Files
.
Count
+
ExistingFiles
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
Files
.
Count
+
ExistingFiles
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
Files
.
Count
+
ExistingFiles
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
Files
.
Count
+
ExistingFiles
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_size
),
0
,
4
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_size
),
0
,
4
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_offset
),
0
,
4
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_offset
),
0
,
4
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
encodedComment
.
Length
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
encodedComment
.
Length
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
encodedComment
,
0
,
encodedComment
.
Length
);
this
.
ZipFileStream
.
Write
(
encodedComment
,
0
,
encodedComment
.
Length
);
}
}
// Copies all source file into storage file
// Copies all source file into storage file
private
void
Store
(
ref
ZipFileEntry
_zfe
,
Stream
_source
)
private
void
Store
(
ref
ZipFileEntry
_zfe
,
Stream
_source
)
{
{
byte
[]
buffer
=
new
byte
[
16384
];
byte
[]
buffer
=
new
byte
[
16384
];
int
bytesRead
;
int
bytesRead
;
uint
totalRead
=
0
;
uint
totalRead
=
0
;
Stream
outStream
;
Stream
outStream
;
long
posStart
=
this
.
ZipFileStream
.
Position
;
long
posStart
=
this
.
ZipFileStream
.
Position
;
long
sourceStart
=
_source
.
Position
;
long
sourceStart
=
_source
.
Position
;
if
(
_zfe
.
Method
==
Compression
.
Store
)
if
(
_zfe
.
Method
==
Compression
.
Store
)
outStream
=
this
.
ZipFileStream
;
outStream
=
this
.
ZipFileStream
;
else
else
outStream
=
new
DeflateStream
(
this
.
ZipFileStream
,
CompressionMode
.
Compress
,
true
);
outStream
=
new
DeflateStream
(
this
.
ZipFileStream
,
CompressionMode
.
Compress
,
true
);
_zfe
.
Crc32
=
0
^
0xffffffff
;
_zfe
.
Crc32
=
0
^
0xffffffff
;
do
do
{
{
bytesRead
=
_source
.
Read
(
buffer
,
0
,
buffer
.
Length
);
bytesRead
=
_source
.
Read
(
buffer
,
0
,
buffer
.
Length
);
totalRead
+=
(
uint
)
bytesRead
;
totalRead
+=
(
uint
)
bytesRead
;
if
(
bytesRead
>
0
)
if
(
bytesRead
>
0
)
{
{
outStream
.
Write
(
buffer
,
0
,
bytesRead
);
outStream
.
Write
(
buffer
,
0
,
bytesRead
);
for
(
uint
i
=
0
;
i
<
bytesRead
;
i
++)
for
(
uint
i
=
0
;
i
<
bytesRead
;
i
++)
{
{
_zfe
.
Crc32
=
ZipStorer
.
CrcTable
[(
_zfe
.
Crc32
^
buffer
[
i
])
&
0xFF
]
^
(
_zfe
.
Crc32
>>
8
);
_zfe
.
Crc32
=
ZipStorer
.
CrcTable
[(
_zfe
.
Crc32
^
buffer
[
i
])
&
0xFF
]
^
(
_zfe
.
Crc32
>>
8
);
}
}
}
}
}
while
(
bytesRead
==
buffer
.
Length
);
}
while
(
bytesRead
==
buffer
.
Length
);
outStream
.
Flush
();
outStream
.
Flush
();
if
(
_zfe
.
Method
==
Compression
.
Deflate
)
if
(
_zfe
.
Method
==
Compression
.
Deflate
)
outStream
.
Dispose
();
outStream
.
Dispose
();
_zfe
.
Crc32
^=
0xffffffff
;
_zfe
.
Crc32
^=
0xffffffff
;
_zfe
.
FileSize
=
totalRead
;
_zfe
.
FileSize
=
totalRead
;
_zfe
.
CompressedSize
=
(
uint
)(
this
.
ZipFileStream
.
Position
-
posStart
);
_zfe
.
CompressedSize
=
(
uint
)(
this
.
ZipFileStream
.
Position
-
posStart
);
// Verify for real compression
// Verify for real compression
if
(
_zfe
.
Method
==
Compression
.
Deflate
&&
!
this
.
ForceDeflating
&&
_source
.
CanSeek
&&
_zfe
.
CompressedSize
>
_zfe
.
FileSize
)
if
(
_zfe
.
Method
==
Compression
.
Deflate
&&
!
this
.
ForceDeflating
&&
_source
.
CanSeek
&&
_zfe
.
CompressedSize
>
_zfe
.
FileSize
)
{
{
// Start operation again with Store algorithm
// Start operation again with Store algorithm
_zfe
.
Method
=
Compression
.
Store
;
_zfe
.
Method
=
Compression
.
Store
;
this
.
ZipFileStream
.
Position
=
posStart
;
this
.
ZipFileStream
.
Position
=
posStart
;
this
.
ZipFileStream
.
SetLength
(
posStart
);
this
.
ZipFileStream
.
SetLength
(
posStart
);
_source
.
Position
=
sourceStart
;
_source
.
Position
=
sourceStart
;
this
.
Store
(
ref
_zfe
,
_source
);
this
.
Store
(
ref
_zfe
,
_source
);
}
}
}
}
/* DOS Date and time:
/* DOS Date and time:
MS-DOS date. The date is a packed value with the following format. Bits Description
MS-DOS date. The date is a packed value with the following format. Bits Description
0-4 Day of the month (1?1)
0-4 Day of the month (1?1)
5-8 Month (1 = January, 2 = February, and so on)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get actual year)
9-15 Year offset from 1980 (add 1980 to get actual year)
MS-DOS time. The time is a packed value with the following format. Bits Description
MS-DOS time. The time is a packed value with the following format. Bits Description
0-4 Second divided by 2
0-4 Second divided by 2
5-10 Minute (0?9)
5-10 Minute (0?9)
11-15 Hour (0?3 on a 24-hour clock)
11-15 Hour (0?3 on a 24-hour clock)
*/
*/
private
uint
DateTimeToDosTime
(
DateTime
_dt
)
private
uint
DateTimeToDosTime
(
DateTime
_dt
)
{
{
return
(
uint
)(
return
(
uint
)(
(
_dt
.
Second
/
2
)
|
(
_dt
.
Minute
<<
5
)
|
(
_dt
.
Hour
<<
11
)
|
(
_dt
.
Second
/
2
)
|
(
_dt
.
Minute
<<
5
)
|
(
_dt
.
Hour
<<
11
)
|
(
_dt
.
Day
<<
16
)
|
(
_dt
.
Month
<<
21
)
|
((
_dt
.
Year
-
1980
)
<<
25
));
(
_dt
.
Day
<<
16
)
|
(
_dt
.
Month
<<
21
)
|
((
_dt
.
Year
-
1980
)
<<
25
));
}
}
private
DateTime
DosTimeToDateTime
(
uint
_dt
)
private
DateTime
DosTimeToDateTime
(
uint
_dt
)
{
{
return
new
DateTime
(
return
new
DateTime
(
(
int
)(
_dt
>>
25
)
+
1980
,
(
int
)(
_dt
>>
25
)
+
1980
,
(
int
)(
_dt
>>
21
)
&
15
,
(
int
)(
_dt
>>
21
)
&
15
,
(
int
)(
_dt
>>
16
)
&
31
,
(
int
)(
_dt
>>
16
)
&
31
,
(
int
)(
_dt
>>
11
)
&
31
,
(
int
)(
_dt
>>
11
)
&
31
,
(
int
)(
_dt
>>
5
)
&
63
,
(
int
)(
_dt
>>
5
)
&
63
,
(
int
)(
_dt
&
31
)
*
2
);
(
int
)(
_dt
&
31
)
*
2
);
}
}
/* CRC32 algorithm
/* CRC32 algorithm
The 'magic number' for the CRC is 0xdebb20e3.
The 'magic number' for the CRC is 0xdebb20e3.
The proper CRC pre and post conditioning
The proper CRC pre and post conditioning
is used, meaning that the CRC register is
is used, meaning that the CRC register is
pre-conditioned with all ones (a starting value
pre-conditioned with all ones (a starting value
of 0xffffffff) and the value is post-conditioned by
of 0xffffffff) and the value is post-conditioned by
taking the one's complement of the CRC residual.
taking the one's complement of the CRC residual.
If bit 3 of the general purpose flag is set, this
If bit 3 of the general purpose flag is set, this
field is set to zero in the local header and the correct
field is set to zero in the local header and the correct
value is put in the data descriptor and in the central
value is put in the data descriptor and in the central
directory.
directory.
*/
*/
private
void
UpdateCrcAndSizes
(
ref
ZipFileEntry
_zfe
)
private
void
UpdateCrcAndSizes
(
ref
ZipFileEntry
_zfe
)
{
{
long
lastPos
=
this
.
ZipFileStream
.
Position
;
// remember position
long
lastPos
=
this
.
ZipFileStream
.
Position
;
// remember position
this
.
ZipFileStream
.
Position
=
_zfe
.
HeaderOffset
+
8
;
this
.
ZipFileStream
.
Position
=
_zfe
.
HeaderOffset
+
8
;
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
_zfe
.
Method
),
0
,
2
);
// zipping method
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
_zfe
.
Method
),
0
,
2
);
// zipping method
this
.
ZipFileStream
.
Position
=
_zfe
.
HeaderOffset
+
14
;
this
.
ZipFileStream
.
Position
=
_zfe
.
HeaderOffset
+
14
;
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
Crc32
),
0
,
4
);
// Update CRC
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
Crc32
),
0
,
4
);
// Update CRC
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
CompressedSize
),
0
,
4
);
// Compressed size
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
CompressedSize
),
0
,
4
);
// Compressed size
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
FileSize
),
0
,
4
);
// Uncompressed size
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_zfe
.
FileSize
),
0
,
4
);
// Uncompressed size
this
.
ZipFileStream
.
Position
=
lastPos
;
// restore position
this
.
ZipFileStream
.
Position
=
lastPos
;
// restore position
}
}
// Replaces backslashes with slashes to store in zip header
// Replaces backslashes with slashes to store in zip header
private
string
NormalizedFilename
(
string
_filename
)
private
string
NormalizedFilename
(
string
_filename
)
{
{
string
filename
=
_filename
.
Replace
(
'\\'
,
'/'
);
string
filename
=
_filename
.
Replace
(
'\\'
,
'/'
);
int
pos
=
filename
.
IndexOf
(
':'
);
int
pos
=
filename
.
IndexOf
(
':'
);
if
(
pos
>=
0
)
if
(
pos
>=
0
)
filename
=
filename
.
Remove
(
0
,
pos
+
1
);
filename
=
filename
.
Remove
(
0
,
pos
+
1
);
return
filename
.
Trim
(
'/'
);
return
filename
.
Trim
(
'/'
);
}
}
// Reads the end-of-central-directory record
// Reads the end-of-central-directory record
private
bool
ReadFileInfo
()
private
bool
ReadFileInfo
()
{
{
if
(
this
.
ZipFileStream
.
Length
<
22
)
if
(
this
.
ZipFileStream
.
Length
<
22
)
return
false
;
return
false
;
try
try
{
{
this
.
ZipFileStream
.
Seek
(-
17
,
SeekOrigin
.
End
);
this
.
ZipFileStream
.
Seek
(-
17
,
SeekOrigin
.
End
);
BinaryReader
br
=
new
BinaryReader
(
this
.
ZipFileStream
);
BinaryReader
br
=
new
BinaryReader
(
this
.
ZipFileStream
);
do
do
{
{
this
.
ZipFileStream
.
Seek
(-
5
,
SeekOrigin
.
Current
);
this
.
ZipFileStream
.
Seek
(-
5
,
SeekOrigin
.
Current
);
UInt32
sig
=
br
.
ReadUInt32
();
UInt32
sig
=
br
.
ReadUInt32
();
if
(
sig
==
0x06054b50
)
if
(
sig
==
0x06054b50
)
{
{
this
.
ZipFileStream
.
Seek
(
6
,
SeekOrigin
.
Current
);
this
.
ZipFileStream
.
Seek
(
6
,
SeekOrigin
.
Current
);
UInt16
entries
=
br
.
ReadUInt16
();
UInt16
entries
=
br
.
ReadUInt16
();
Int32
centralSize
=
br
.
ReadInt32
();
Int32
centralSize
=
br
.
ReadInt32
();
UInt32
centralDirOffset
=
br
.
ReadUInt32
();
UInt32
centralDirOffset
=
br
.
ReadUInt32
();
UInt16
commentSize
=
br
.
ReadUInt16
();
UInt16
commentSize
=
br
.
ReadUInt16
();
// check if comment field is the very last data in file
// check if comment field is the very last data in file
if
(
this
.
ZipFileStream
.
Position
+
commentSize
!=
this
.
ZipFileStream
.
Length
)
if
(
this
.
ZipFileStream
.
Position
+
commentSize
!=
this
.
ZipFileStream
.
Length
)
return
false
;
return
false
;
// Copy entire central directory to a memory buffer
// Copy entire central directory to a memory buffer
this
.
ExistingFiles
=
entries
;
this
.
ExistingFiles
=
entries
;
this
.
CentralDirImage
=
new
byte
[
centralSize
];
this
.
CentralDirImage
=
new
byte
[
centralSize
];
this
.
ZipFileStream
.
Seek
(
centralDirOffset
,
SeekOrigin
.
Begin
);
this
.
ZipFileStream
.
Seek
(
centralDirOffset
,
SeekOrigin
.
Begin
);
this
.
ZipFileStream
.
Read
(
this
.
CentralDirImage
,
0
,
centralSize
);
this
.
ZipFileStream
.
Read
(
this
.
CentralDirImage
,
0
,
centralSize
);
// Leave the pointer at the begining of central dir, to append new files
// Leave the pointer at the begining of central dir, to append new files
this
.
ZipFileStream
.
Seek
(
centralDirOffset
,
SeekOrigin
.
Begin
);
this
.
ZipFileStream
.
Seek
(
centralDirOffset
,
SeekOrigin
.
Begin
);
return
true
;
return
true
;
}
}
}
while
(
this
.
ZipFileStream
.
Position
>
0
);
}
while
(
this
.
ZipFileStream
.
Position
>
0
);
}
}
catch
{
}
catch
{
}
return
false
;
return
false
;
}
}
#
endregion
#
endregion
#
region
IDisposable
Members
#
region
IDisposable
Members
/// <summary>
/// <summary>
/// Closes the Zip file stream
/// Closes the Zip file stream
/// </summary>
/// </summary>
public
void
Dispose
()
public
void
Dispose
()
{
{
this
.
Close
();
this
.
Close
();
}
}
#
endregion
#
endregion
}
}
}
}
DataEditorX/Config/CodeConfig.cs
View file @
e72f147e
...
@@ -6,205 +6,205 @@
...
@@ -6,205 +6,205 @@
namespace
DataEditorX.Config
namespace
DataEditorX.Config
{
{
/// <summary>
/// <summary>
/// CodeEditor的配置
/// CodeEditor的配置
/// </summary>
/// </summary>
public
class
CodeConfig
public
class
CodeConfig
{
{
#
region
成员
#
region
成员
public
CodeConfig
()
public
CodeConfig
()
{
{
tooltipDic
=
new
SortedList
<
string
,
string
>();
tooltipDic
=
new
SortedList
<
string
,
string
>();
longTooltipDic
=
new
SortedList
<
string
,
string
>();
longTooltipDic
=
new
SortedList
<
string
,
string
>();
items
=
new
List
<
AutocompleteItem
>();
items
=
new
List
<
AutocompleteItem
>();
}
}
//函数提示
//函数提示
SortedList
<
string
,
string
>
tooltipDic
;
SortedList
<
string
,
string
>
tooltipDic
;
SortedList
<
string
,
string
>
longTooltipDic
;
SortedList
<
string
,
string
>
longTooltipDic
;
List
<
AutocompleteItem
>
items
;
List
<
AutocompleteItem
>
items
;
/// <summary>
/// <summary>
/// 输入提示
/// 输入提示
/// </summary>
/// </summary>
public
SortedList
<
string
,
string
>
TooltipDic
public
SortedList
<
string
,
string
>
TooltipDic
{
{
get
{
return
tooltipDic
;
}
get
{
return
tooltipDic
;
}
}
}
public
SortedList
<
string
,
string
>
LongTooltipDic
public
SortedList
<
string
,
string
>
LongTooltipDic
{
{
get
{
return
longTooltipDic
;
}
get
{
return
longTooltipDic
;
}
}
}
public
AutocompleteItem
[]
Items
public
AutocompleteItem
[]
Items
{
{
get
{
return
items
.
ToArray
();
}
get
{
return
items
.
ToArray
();
}
}
}
#
endregion
#
endregion
#
region
系列名
/
指示物
#
region
系列名
/
指示物
/// <summary>
/// <summary>
/// 设置系列名
/// 设置系列名
/// </summary>
/// </summary>
/// <param name="dic"></param>
/// <param name="dic"></param>
public
void
SetNames
(
Dictionary
<
long
,
string
>
dic
)
public
void
SetNames
(
Dictionary
<
long
,
string
>
dic
)
{
{
foreach
(
long
k
in
dic
.
Keys
)
foreach
(
long
k
in
dic
.
Keys
)
{
{
string
key
=
"0x"
+
k
.
ToString
(
"x"
);
string
key
=
"0x"
+
k
.
ToString
(
"x"
);
if
(!
tooltipDic
.
ContainsKey
(
key
))
if
(!
tooltipDic
.
ContainsKey
(
key
))
{
{
AddToolIipDic
(
key
,
dic
[
k
]);
AddToolIipDic
(
key
,
dic
[
k
]);
}
}
}
}
}
}
/// <summary>
/// <summary>
/// 读取指示物
/// 读取指示物
/// </summary>
/// </summary>
/// <param name="file"></param>
/// <param name="file"></param>
public
void
AddStrings
(
string
file
)
public
void
AddStrings
(
string
file
)
{
{
if
(
File
.
Exists
(
file
))
if
(
File
.
Exists
(
file
))
{
{
string
[]
lines
=
File
.
ReadAllLines
(
file
);
string
[]
lines
=
File
.
ReadAllLines
(
file
);
foreach
(
string
line
in
lines
)
foreach
(
string
line
in
lines
)
{
{
//特殊胜利和指示物
//特殊胜利和指示物
if
(
line
.
StartsWith
(
"!victory"
)
if
(
line
.
StartsWith
(
"!victory"
)
||
line
.
StartsWith
(
"!counter"
))
||
line
.
StartsWith
(
"!counter"
))
{
{
string
[]
ws
=
line
.
Split
(
' '
);
string
[]
ws
=
line
.
Split
(
' '
);
if
(
ws
.
Length
>
2
)
if
(
ws
.
Length
>
2
)
{
{
AddToolIipDic
(
ws
[
1
],
ws
[
2
]);
AddToolIipDic
(
ws
[
1
],
ws
[
2
]);
}
}
}
}
}
}
}
}
}
}
#
endregion
#
endregion
#
region
function
#
region
function
public
void
AddFunction
(
string
funtxt
)
public
void
AddFunction
(
string
funtxt
)
{
{
if
(!
File
.
Exists
(
funtxt
))
if
(!
File
.
Exists
(
funtxt
))
return
;
return
;
string
[]
lines
=
File
.
ReadAllLines
(
funtxt
);
string
[]
lines
=
File
.
ReadAllLines
(
funtxt
);
bool
isFind
=
false
;
bool
isFind
=
false
;
string
name
=
""
;
string
name
=
""
;
string
desc
=
""
;
string
desc
=
""
;
foreach
(
string
line
in
lines
)
foreach
(
string
line
in
lines
)
{
{
if
(
string
.
IsNullOrEmpty
(
line
)
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"=="
)
||
line
.
StartsWith
(
"=="
)
||
line
.
StartsWith
(
"#"
))
||
line
.
StartsWith
(
"#"
))
continue
;
continue
;
if
(
line
.
StartsWith
(
"●"
))
if
(
line
.
StartsWith
(
"●"
))
{
{
//add
//add
AddToolIipDic
(
name
,
desc
);
AddToolIipDic
(
name
,
desc
);
int
w
=
line
.
IndexOf
(
"("
);
int
w
=
line
.
IndexOf
(
"("
);
int
t
=
line
.
IndexOf
(
" "
);
int
t
=
line
.
IndexOf
(
" "
);
if
(
t
<
w
&&
t
>
0
)
if
(
t
<
w
&&
t
>
0
)
{
{
//找到函数
//找到函数
name
=
line
.
Substring
(
t
+
1
,
w
-
t
-
1
);
name
=
line
.
Substring
(
t
+
1
,
w
-
t
-
1
);
isFind
=
true
;
isFind
=
true
;
desc
=
line
;
desc
=
line
;
}
}
}
}
else
if
(
isFind
)
else
if
(
isFind
)
{
{
desc
+=
Environment
.
NewLine
+
line
;
desc
+=
Environment
.
NewLine
+
line
;
}
}
}
}
AddToolIipDic
(
name
,
desc
);
AddToolIipDic
(
name
,
desc
);
}
}
#
endregion
#
endregion
#
region
常量
#
region
常量
public
void
AddConstant
(
string
conlua
)
public
void
AddConstant
(
string
conlua
)
{
{
//conList.Add("con");
//conList.Add("con");
if
(!
File
.
Exists
(
conlua
))
if
(!
File
.
Exists
(
conlua
))
return
;
return
;
string
[]
lines
=
File
.
ReadAllLines
(
conlua
);
string
[]
lines
=
File
.
ReadAllLines
(
conlua
);
foreach
(
string
line
in
lines
)
foreach
(
string
line
in
lines
)
{
{
if
(
line
.
StartsWith
(
"--"
))
if
(
line
.
StartsWith
(
"--"
))
continue
;
continue
;
string
k
=
line
,
desc
=
line
;
string
k
=
line
,
desc
=
line
;
int
t
=
line
.
IndexOf
(
"="
);
int
t
=
line
.
IndexOf
(
"="
);
int
t2
=
line
.
IndexOf
(
"--"
);
int
t2
=
line
.
IndexOf
(
"--"
);
//常量 = 0x1 ---注释
//常量 = 0x1 ---注释
k
=
(
t
>
0
)
?
line
.
Substring
(
0
,
t
).
TrimEnd
(
new
char
[]
{
' '
,
'\t'
})
k
=
(
t
>
0
)
?
line
.
Substring
(
0
,
t
).
TrimEnd
(
new
char
[]
{
' '
,
'\t'
})
:
line
;
:
line
;
desc
=
(
t
>
0
)
?
line
.
Substring
(
t
+
1
).
Replace
(
"--"
,
"\n"
)
desc
=
(
t
>
0
)
?
line
.
Substring
(
t
+
1
).
Replace
(
"--"
,
"\n"
)
:
line
;
:
line
;
AddToolIipDic
(
k
,
desc
);
AddToolIipDic
(
k
,
desc
);
}
}
}
}
#
endregion
#
endregion
#
region
处理
#
region
处理
public
void
InitAutoMenus
()
public
void
InitAutoMenus
()
{
{
items
.
Clear
();
items
.
Clear
();
foreach
(
string
k
in
tooltipDic
.
Keys
)
foreach
(
string
k
in
tooltipDic
.
Keys
)
{
{
AutocompleteItem
item
=
new
AutocompleteItem
(
k
);
AutocompleteItem
item
=
new
AutocompleteItem
(
k
);
item
.
ToolTipTitle
=
k
;
item
.
ToolTipTitle
=
k
;
item
.
ToolTipText
=
tooltipDic
[
k
];
item
.
ToolTipText
=
tooltipDic
[
k
];
items
.
Add
(
item
);
items
.
Add
(
item
);
}
}
foreach
(
string
k
in
longTooltipDic
.
Keys
)
foreach
(
string
k
in
longTooltipDic
.
Keys
)
{
{
if
(
tooltipDic
.
ContainsKey
(
k
))
if
(
tooltipDic
.
ContainsKey
(
k
))
continue
;
continue
;
AutocompleteItem
item
=
new
AutocompleteItem
(
k
);
AutocompleteItem
item
=
new
AutocompleteItem
(
k
);
item
.
ToolTipTitle
=
k
;
item
.
ToolTipTitle
=
k
;
item
.
ToolTipText
=
longTooltipDic
[
k
];
item
.
ToolTipText
=
longTooltipDic
[
k
];
items
.
Add
(
item
);
items
.
Add
(
item
);
}
}
}
}
string
GetShortName
(
string
name
)
string
GetShortName
(
string
name
)
{
{
int
t
=
name
.
IndexOf
(
"."
);
int
t
=
name
.
IndexOf
(
"."
);
if
(
t
>
0
)
if
(
t
>
0
)
return
name
.
Substring
(
t
+
1
);
return
name
.
Substring
(
t
+
1
);
else
else
return
name
;
return
name
;
}
}
void
AddToolIipDic
(
string
key
,
string
val
)
void
AddToolIipDic
(
string
key
,
string
val
)
{
{
string
skey
=
GetShortName
(
key
);
string
skey
=
GetShortName
(
key
);
if
(
tooltipDic
.
ContainsKey
(
skey
))
//存在
if
(
tooltipDic
.
ContainsKey
(
skey
))
//存在
{
{
string
nval
=
tooltipDic
[
skey
];
string
nval
=
tooltipDic
[
skey
];
if
(!
nval
.
EndsWith
(
Environment
.
NewLine
))
if
(!
nval
.
EndsWith
(
Environment
.
NewLine
))
nval
+=
Environment
.
NewLine
;
nval
+=
Environment
.
NewLine
;
nval
+=
Environment
.
NewLine
+
val
;
nval
+=
Environment
.
NewLine
+
val
;
tooltipDic
[
skey
]
=
nval
;
tooltipDic
[
skey
]
=
nval
;
}
}
else
else
tooltipDic
.
Add
(
skey
,
val
);
tooltipDic
.
Add
(
skey
,
val
);
//
//
AddLongToolIipDic
(
key
,
val
);
AddLongToolIipDic
(
key
,
val
);
}
}
void
AddLongToolIipDic
(
string
key
,
string
val
)
void
AddLongToolIipDic
(
string
key
,
string
val
)
{
{
if
(
longTooltipDic
.
ContainsKey
(
key
))
//存在
if
(
longTooltipDic
.
ContainsKey
(
key
))
//存在
{
{
string
nval
=
longTooltipDic
[
key
];
string
nval
=
longTooltipDic
[
key
];
if
(!
nval
.
EndsWith
(
Environment
.
NewLine
))
if
(!
nval
.
EndsWith
(
Environment
.
NewLine
))
nval
+=
Environment
.
NewLine
;
nval
+=
Environment
.
NewLine
;
nval
+=
Environment
.
NewLine
+
val
;
nval
+=
Environment
.
NewLine
+
val
;
longTooltipDic
[
key
]
=
nval
;
longTooltipDic
[
key
]
=
nval
;
}
}
else
else
longTooltipDic
.
Add
(
key
,
val
);
longTooltipDic
.
Add
(
key
,
val
);
}
}
#
endregion
#
endregion
}
}
}
}
DataEditorX/Config/DataConfig.cs
View file @
e72f147e
...
@@ -11,81 +11,81 @@
...
@@ -11,81 +11,81 @@
namespace
DataEditorX.Config
namespace
DataEditorX.Config
{
{
/// <summary>
/// <summary>
/// DataEditor的数据
/// DataEditor的数据
/// </summary>
/// </summary>
public
class
DataConfig
public
class
DataConfig
{
{
public
DataConfig
()
public
DataConfig
()
{
{
InitMember
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_CARDINFO
+
".txt"
));
InitMember
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_CARDINFO
+
".txt"
));
}
}
public
DataConfig
(
string
conf
)
public
DataConfig
(
string
conf
)
{
{
InitMember
(
conf
);
InitMember
(
conf
);
}
}
/// <summary>
/// <summary>
/// 初始化成员
/// 初始化成员
/// </summary>
/// </summary>
/// <param name="conf"></param>
/// <param name="conf"></param>
public
void
InitMember
(
string
conf
)
public
void
InitMember
(
string
conf
)
{
{
//conf = MyPath.Combine(datapath, MyConfig.FILE_INFO);
//conf = MyPath.Combine(datapath, MyConfig.FILE_INFO);
if
(!
File
.
Exists
(
conf
))
if
(!
File
.
Exists
(
conf
))
{
{
dicCardRules
=
new
Dictionary
<
long
,
string
>();
dicCardRules
=
new
Dictionary
<
long
,
string
>();
dicSetnames
=
new
Dictionary
<
long
,
string
>();
dicSetnames
=
new
Dictionary
<
long
,
string
>();
dicCardTypes
=
new
Dictionary
<
long
,
string
>();
dicCardTypes
=
new
Dictionary
<
long
,
string
>();
dicLinkMarkers
=
new
Dictionary
<
long
,
string
>();
dicLinkMarkers
=
new
Dictionary
<
long
,
string
>();
dicCardcategorys
=
new
Dictionary
<
long
,
string
>();
dicCardcategorys
=
new
Dictionary
<
long
,
string
>();
dicCardAttributes
=
new
Dictionary
<
long
,
string
>();
dicCardAttributes
=
new
Dictionary
<
long
,
string
>();
dicCardRaces
=
new
Dictionary
<
long
,
string
>();
dicCardRaces
=
new
Dictionary
<
long
,
string
>();
dicCardLevels
=
new
Dictionary
<
long
,
string
>();
dicCardLevels
=
new
Dictionary
<
long
,
string
>();
return
;
return
;
}
}
//提取内容
//提取内容
string
text
=
File
.
ReadAllText
(
conf
);
string
text
=
File
.
ReadAllText
(
conf
);
dicCardRules
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_RULE
);
dicCardRules
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_RULE
);
dicSetnames
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_SETNAME
);
dicSetnames
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_SETNAME
);
dicCardTypes
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_TYPE
);
dicCardTypes
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_TYPE
);
dicLinkMarkers
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_MARKER
);
dicLinkMarkers
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_MARKER
);
dicCardcategorys
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_CATEGORY
);
dicCardcategorys
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_CATEGORY
);
dicCardAttributes
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_ATTRIBUTE
);
dicCardAttributes
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_ATTRIBUTE
);
dicCardRaces
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_RACE
);
dicCardRaces
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_RACE
);
dicCardLevels
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_LEVEL
);
dicCardLevels
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_LEVEL
);
}
}
/// <summary>
/// <summary>
/// 规则
/// 规则
/// </summary>
/// </summary>
public
Dictionary
<
long
,
string
>
dicCardRules
=
null
;
public
Dictionary
<
long
,
string
>
dicCardRules
=
null
;
/// <summary>
/// <summary>
/// 属性
/// 属性
/// </summary>
/// </summary>
public
Dictionary
<
long
,
string
>
dicCardAttributes
=
null
;
public
Dictionary
<
long
,
string
>
dicCardAttributes
=
null
;
/// <summary>
/// <summary>
/// 种族
/// 种族
/// </summary>
/// </summary>
public
Dictionary
<
long
,
string
>
dicCardRaces
=
null
;
public
Dictionary
<
long
,
string
>
dicCardRaces
=
null
;
/// <summary>
/// <summary>
/// 等级
/// 等级
/// </summary>
/// </summary>
public
Dictionary
<
long
,
string
>
dicCardLevels
=
null
;
public
Dictionary
<
long
,
string
>
dicCardLevels
=
null
;
/// <summary>
/// <summary>
/// 系列名
/// 系列名
/// </summary>
/// </summary>
public
Dictionary
<
long
,
string
>
dicSetnames
=
null
;
public
Dictionary
<
long
,
string
>
dicSetnames
=
null
;
/// <summary>
/// <summary>
/// 卡片类型
/// 卡片类型
/// </summary>
/// </summary>
public
Dictionary
<
long
,
string
>
dicCardTypes
=
null
;
public
Dictionary
<
long
,
string
>
dicCardTypes
=
null
;
/// <summary>
/// <summary>
/// 连接标志
/// 连接标志
/// </summary>
/// </summary>
public
Dictionary
<
long
,
string
>
dicLinkMarkers
=
null
;
public
Dictionary
<
long
,
string
>
dicLinkMarkers
=
null
;
/// <summary>
/// <summary>
/// 效果类型
/// 效果类型
/// </summary>
/// </summary>
public
Dictionary
<
long
,
string
>
dicCardcategorys
=
null
;
public
Dictionary
<
long
,
string
>
dicCardcategorys
=
null
;
}
}
}
}
DataEditorX/Config/DataManager.cs
View file @
e72f147e
...
@@ -14,131 +14,131 @@
...
@@ -14,131 +14,131 @@
namespace
DataEditorX.Config
namespace
DataEditorX.Config
{
{
public
class
DataManager
public
class
DataManager
{
{
/// <summary>
/// <summary>
/// 内容开头
/// 内容开头
/// </summary>
/// </summary>
public
const
string
TAG_START
=
"##"
;
public
const
string
TAG_START
=
"##"
;
/// <summary>
/// <summary>
/// 内容结尾
/// 内容结尾
/// </summary>
/// </summary>
public
const
string
TAG_END
=
"#"
;
public
const
string
TAG_END
=
"#"
;
/// <summary>
/// <summary>
/// 行分隔符
/// 行分隔符
/// </summary>
/// </summary>
public
const
char
SEP_LINE
=
'\t'
;
public
const
char
SEP_LINE
=
'\t'
;
#
region
根据
tag
获取内容
#
region
根据
tag
获取内容
static
string
reReturn
(
string
content
)
static
string
reReturn
(
string
content
)
{
{
string
text
=
content
.
Replace
(
"\r\n"
,
"\n"
);
string
text
=
content
.
Replace
(
"\r\n"
,
"\n"
);
text
=
text
.
Replace
(
"\r"
,
"\n"
);
text
=
text
.
Replace
(
"\r"
,
"\n"
);
return
text
;
return
text
;
}
}
public
static
string
subString
(
string
content
,
string
tag
)
public
static
string
subString
(
string
content
,
string
tag
)
{
{
Regex
reg
=
new
Regex
(
string
.
Format
(
@"{0}{1}\n([\S\s]*?)\n{2}"
,
TAG_START
,
tag
,
TAG_END
),
RegexOptions
.
Multiline
);
Regex
reg
=
new
Regex
(
string
.
Format
(
@"{0}{1}\n([\S\s]*?)\n{2}"
,
TAG_START
,
tag
,
TAG_END
),
RegexOptions
.
Multiline
);
Match
mac
=
reg
.
Match
(
reReturn
(
content
));
Match
mac
=
reg
.
Match
(
reReturn
(
content
));
if
(
mac
.
Success
)
//把相应的内容提取出来
if
(
mac
.
Success
)
//把相应的内容提取出来
{
{
return
mac
.
Groups
[
1
].
Value
.
Replace
(
"\n"
,
Environment
.
NewLine
);
return
mac
.
Groups
[
1
].
Value
.
Replace
(
"\n"
,
Environment
.
NewLine
);
}
}
return
""
;
return
""
;
}
}
#
endregion
#
endregion
#
region
读取
#
region
读取
/// <summary>
/// <summary>
/// 从字符串中,按tag来分割内容,并读取内容
/// 从字符串中,按tag来分割内容,并读取内容
/// </summary>
/// </summary>
/// <param name="content">字符串</param>
/// <param name="content">字符串</param>
/// <param name="tag">开始的标志</param>
/// <param name="tag">开始的标志</param>
/// <returns></returns>
/// <returns></returns>
public
static
Dictionary
<
long
,
string
>
Read
(
string
content
,
string
tag
)
public
static
Dictionary
<
long
,
string
>
Read
(
string
content
,
string
tag
)
{
{
return
Read
(
subString
(
content
,
tag
));
return
Read
(
subString
(
content
,
tag
));
}
}
/// <summary>
/// <summary>
/// 从文件读取内容,按行读取
/// 从文件读取内容,按行读取
/// </summary>
/// </summary>
/// <param name="strFile"></param>
/// <param name="strFile"></param>
/// <param name="encode"></param>
/// <param name="encode"></param>
/// <returns></returns>
/// <returns></returns>
public
static
Dictionary
<
long
,
string
>
Read
(
string
strFile
,
Encoding
encode
)
public
static
Dictionary
<
long
,
string
>
Read
(
string
strFile
,
Encoding
encode
)
{
{
return
Read
(
File
.
ReadAllLines
(
strFile
,
encode
));
return
Read
(
File
.
ReadAllLines
(
strFile
,
encode
));
}
}
/// <summary>
/// <summary>
/// 从字符串中读取内容,需要分行
/// 从字符串中读取内容,需要分行
/// </summary>
/// </summary>
/// <param name="content"></param>
/// <param name="content"></param>
/// <returns></returns>
/// <returns></returns>
public
static
Dictionary
<
long
,
string
>
Read
(
string
content
)
public
static
Dictionary
<
long
,
string
>
Read
(
string
content
)
{
{
string
text
=
reReturn
(
content
);
string
text
=
reReturn
(
content
);
return
Read
(
text
.
Split
(
'\n'
));
return
Read
(
text
.
Split
(
'\n'
));
}
}
/// <summary>
/// <summary>
/// 从行读取内容
/// 从行读取内容
/// </summary>
/// </summary>
/// <param name="lines"></param>
/// <param name="lines"></param>
/// <returns></returns>
/// <returns></returns>
public
static
Dictionary
<
long
,
string
>
Read
(
string
[]
lines
)
public
static
Dictionary
<
long
,
string
>
Read
(
string
[]
lines
)
{
{
Dictionary
<
long
,
string
>
tempDic
=
new
Dictionary
<
long
,
string
>();
Dictionary
<
long
,
string
>
tempDic
=
new
Dictionary
<
long
,
string
>();
long
lkey
;
long
lkey
;
foreach
(
string
line
in
lines
)
foreach
(
string
line
in
lines
)
{
{
if
(
line
.
StartsWith
(
"#"
))
if
(
line
.
StartsWith
(
"#"
))
continue
;
continue
;
string
[]
words
=
line
.
Split
(
SEP_LINE
);
string
[]
words
=
line
.
Split
(
SEP_LINE
);
if
(
words
.
Length
<
2
)
if
(
words
.
Length
<
2
)
continue
;
continue
;
if
(
words
[
0
].
StartsWith
(
"0x"
))
if
(
words
[
0
].
StartsWith
(
"0x"
))
long
.
TryParse
(
words
[
0
].
Replace
(
"0x"
,
""
),
NumberStyles
.
HexNumber
,
null
,
out
lkey
);
long
.
TryParse
(
words
[
0
].
Replace
(
"0x"
,
""
),
NumberStyles
.
HexNumber
,
null
,
out
lkey
);
else
else
long
.
TryParse
(
words
[
0
],
out
lkey
);
long
.
TryParse
(
words
[
0
],
out
lkey
);
// N/A 的数据不显示
// N/A 的数据不显示
if
(!
tempDic
.
ContainsKey
(
lkey
)
&&
words
[
1
]
!=
"N/A"
)
if
(!
tempDic
.
ContainsKey
(
lkey
)
&&
words
[
1
]
!=
"N/A"
)
tempDic
.
Add
(
lkey
,
words
[
1
]);
tempDic
.
Add
(
lkey
,
words
[
1
]);
}
}
return
tempDic
;
return
tempDic
;
}
}
#
endregion
#
endregion
#
region
查找
#
region
查找
public
static
List
<
long
>
GetKeys
(
Dictionary
<
long
,
string
>
dic
)
public
static
List
<
long
>
GetKeys
(
Dictionary
<
long
,
string
>
dic
)
{
{
List
<
long
>
list
=
new
List
<
long
>();
List
<
long
>
list
=
new
List
<
long
>();
foreach
(
long
l
in
dic
.
Keys
)
foreach
(
long
l
in
dic
.
Keys
)
{
{
list
.
Add
(
l
);
list
.
Add
(
l
);
}
}
return
list
;
return
list
;
}
}
public
static
string
[]
GetValues
(
Dictionary
<
long
,
string
>
dic
)
public
static
string
[]
GetValues
(
Dictionary
<
long
,
string
>
dic
)
{
{
List
<
string
>
list
=
new
List
<
string
>();
List
<
string
>
list
=
new
List
<
string
>();
foreach
(
long
l
in
dic
.
Keys
)
foreach
(
long
l
in
dic
.
Keys
)
{
{
list
.
Add
(
dic
[
l
]);
list
.
Add
(
dic
[
l
]);
}
}
return
list
.
ToArray
();
return
list
.
ToArray
();
}
}
/// <summary>
/// <summary>
/// 获取值
/// 获取值
/// </summary>
/// </summary>
/// <param name="dic"></param>
/// <param name="dic"></param>
/// <param name="key"></param>
/// <param name="key"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
GetValue
(
Dictionary
<
long
,
string
>
dic
,
long
key
)
public
static
string
GetValue
(
Dictionary
<
long
,
string
>
dic
,
long
key
)
{
{
if
(
dic
.
ContainsKey
(
key
))
if
(
dic
.
ContainsKey
(
key
))
return
dic
[
key
].
Trim
();
return
dic
[
key
].
Trim
();
return
key
.
ToString
(
"x"
);
return
key
.
ToString
(
"x"
);
}
}
#
endregion
#
endregion
}
}
}
}
DataEditorX/Config/ImageSet.cs
View file @
e72f147e
...
@@ -12,63 +12,63 @@
...
@@ -12,63 +12,63 @@
namespace
DataEditorX.Config
namespace
DataEditorX.Config
{
{
/// <summary>
/// <summary>
/// 裁剪图片是、配置
/// 裁剪图片是、配置
/// </summary>
/// </summary>
public
class
ImageSet
public
class
ImageSet
{
{
public
ImageSet
(){
public
ImageSet
(){
Init
();
Init
();
}
}
//初始化
//初始化
void
Init
()
void
Init
()
{
{
this
.
normalArea
=
MyConfig
.
readArea
(
MyConfig
.
TAG_IMAGE_OTHER
);
this
.
normalArea
=
MyConfig
.
readArea
(
MyConfig
.
TAG_IMAGE_OTHER
);
this
.
xyzArea
=
MyConfig
.
readArea
(
MyConfig
.
TAG_IMAGE_XYZ
);
this
.
xyzArea
=
MyConfig
.
readArea
(
MyConfig
.
TAG_IMAGE_XYZ
);
this
.
pendulumArea
=
MyConfig
.
readArea
(
MyConfig
.
TAG_IMAGE_PENDULUM
);
this
.
pendulumArea
=
MyConfig
.
readArea
(
MyConfig
.
TAG_IMAGE_PENDULUM
);
int
[]
ints
=
MyConfig
.
readIntegers
(
MyConfig
.
TAG_IMAGE_SIZE
,
4
);
int
[]
ints
=
MyConfig
.
readIntegers
(
MyConfig
.
TAG_IMAGE_SIZE
,
4
);
this
.
w
=
ints
[
0
];
this
.
w
=
ints
[
0
];
this
.
h
=
ints
[
1
];
this
.
h
=
ints
[
1
];
this
.
W
=
ints
[
2
];
this
.
W
=
ints
[
2
];
this
.
H
=
ints
[
3
];
this
.
H
=
ints
[
3
];
this
.
quilty
=
MyConfig
.
readInteger
(
MyConfig
.
TAG_IMAGE_QUILTY
,
95
);
this
.
quilty
=
MyConfig
.
readInteger
(
MyConfig
.
TAG_IMAGE_QUILTY
,
95
);
}
}
/// <summary>
/// <summary>
/// jpeg质量
/// jpeg质量
/// </summary>
/// </summary>
public
int
quilty
;
public
int
quilty
;
/// <summary>
/// <summary>
/// 小图的宽
/// 小图的宽
/// </summary>
/// </summary>
public
int
w
;
public
int
w
;
/// <summary>
/// <summary>
/// 小图的高
/// 小图的高
/// </summary>
/// </summary>
public
int
h
;
public
int
h
;
/// <summary>
/// <summary>
/// 大图的宽
/// 大图的宽
/// </summary>
/// </summary>
public
int
W
;
public
int
W
;
/// <summary>
/// <summary>
/// 大图的高
/// 大图的高
/// </summary>
/// </summary>
public
int
H
;
public
int
H
;
/// <summary>
/// <summary>
/// 怪兽的中间图
/// 怪兽的中间图
/// </summary>
/// </summary>
public
Area
normalArea
;
public
Area
normalArea
;
/// <summary>
/// <summary>
/// xyz怪兽的中间图
/// xyz怪兽的中间图
/// </summary>
/// </summary>
public
Area
xyzArea
;
public
Area
xyzArea
;
/// <summary>
/// <summary>
/// p怪的中间图
/// p怪的中间图
/// </summary>
/// </summary>
public
Area
pendulumArea
;
public
Area
pendulumArea
;
}
}
}
}
DataEditorX/Config/MyConfig.cs
View file @
e72f147e
...
@@ -9,273 +9,273 @@
...
@@ -9,273 +9,273 @@
namespace
DataEditorX.Config
namespace
DataEditorX.Config
{
{
/// <summary>
/// <summary>
/// 配置
/// 配置
/// </summary>
/// </summary>
public
class
MyConfig
:
XMLReader
public
class
MyConfig
:
XMLReader
{
{
#
region
常量
#
region
常量
public
const
string
TAG_SAVE_LAGN
=
"-savelanguage"
;
public
const
string
TAG_SAVE_LAGN
=
"-savelanguage"
;
public
const
string
TAG_SAVE_LAGN2
=
"-sl"
;
public
const
string
TAG_SAVE_LAGN2
=
"-sl"
;
public
const
string
TAG_MSE_PATH
=
"mse_path"
;
public
const
string
TAG_MSE_PATH
=
"mse_path"
;
public
const
string
TAG_MSE_EXPORT
=
"mse_exprotpath"
;
public
const
string
TAG_MSE_EXPORT
=
"mse_exprotpath"
;
public
const
string
TAG_AUTO_LEN
=
"autolength"
;
public
const
string
TAG_AUTO_LEN
=
"autolength"
;
/// <summary>
/// <summary>
/// 窗口消息 打开文件
/// 窗口消息 打开文件
/// </summary>
/// </summary>
public
const
int
WM_OPEN
=
0x0401
;
public
const
int
WM_OPEN
=
0x0401
;
/// <summary>
/// <summary>
/// 最大历史数量
/// 最大历史数量
/// </summary>
/// </summary>
public
const
int
MAX_HISTORY
=
0x10
;
public
const
int
MAX_HISTORY
=
0x10
;
/// <summary>
/// <summary>
/// 数据目录
/// 数据目录
/// </summary>
/// </summary>
public
const
string
TAG_DATA
=
"data"
;
public
const
string
TAG_DATA
=
"data"
;
/// <summary>
/// <summary>
/// 将要打开
/// 将要打开
/// </summary>
/// </summary>
//public const string TAG_OPEN = "open";
//public const string TAG_OPEN = "open";
/// <summary>
/// <summary>
/// MSE
/// MSE
/// </summary>
/// </summary>
public
const
string
TAG_MSE
=
"mse"
;
public
const
string
TAG_MSE
=
"mse"
;
/// <summary>
/// <summary>
/// 卡片信息
/// 卡片信息
/// </summary>
/// </summary>
public
const
string
TAG_CARDINFO
=
"cardinfo"
;
public
const
string
TAG_CARDINFO
=
"cardinfo"
;
/// <summary>
/// <summary>
/// 语言
/// 语言
/// </summary>
/// </summary>
public
const
string
TAG_LANGUAGE
=
"language"
;
public
const
string
TAG_LANGUAGE
=
"language"
;
/// <summary>
/// <summary>
/// 临时文件
/// 临时文件
/// </summary>
/// </summary>
public
const
string
FILE_TEMP
=
"open.tmp"
;
public
const
string
FILE_TEMP
=
"open.tmp"
;
/// <summary>
/// <summary>
/// 历史记录
/// 历史记录
/// </summary>
/// </summary>
public
const
string
FILE_HISTORY
=
"history.txt"
;
public
const
string
FILE_HISTORY
=
"history.txt"
;
/// <summary>
/// <summary>
/// 函数
/// 函数
/// </summary>
/// </summary>
public
const
string
FILE_FUNCTION
=
"_functions.txt"
;
public
const
string
FILE_FUNCTION
=
"_functions.txt"
;
/// <summary>
/// <summary>
/// 常量
/// 常量
/// </summary>
/// </summary>
public
const
string
FILE_CONSTANT
=
"constant.lua"
;
public
const
string
FILE_CONSTANT
=
"constant.lua"
;
/// <summary>
/// <summary>
/// 指示物,胜利提示
/// 指示物,胜利提示
/// </summary>
/// </summary>
public
const
string
FILE_STRINGS
=
"strings.conf"
;
public
const
string
FILE_STRINGS
=
"strings.conf"
;
/// <summary>
/// <summary>
/// 源码链接
/// 源码链接
/// </summary>
/// </summary>
public
const
string
TAG_SOURCE_URL
=
"sourceURL"
;
public
const
string
TAG_SOURCE_URL
=
"sourceURL"
;
/// <summary>
/// <summary>
/// 升级链接
/// 升级链接
/// </summary>
/// </summary>
public
const
string
TAG_UPDATE_URL
=
"updateURL"
;
public
const
string
TAG_UPDATE_URL
=
"updateURL"
;
/// <summary>
/// <summary>
/// 删除卡片的时候,删除图片脚本
/// 删除卡片的时候,删除图片脚本
/// </summary>
/// </summary>
public
const
string
TAG_DELETE_WITH
=
"opera_with_cards_file"
;
public
const
string
TAG_DELETE_WITH
=
"opera_with_cards_file"
;
/// <summary>
/// <summary>
/// 异步加载数据
/// 异步加载数据
/// </summary>
/// </summary>
public
const
string
TAG_ASYNC
=
"async"
;
public
const
string
TAG_ASYNC
=
"async"
;
/// <summary>
/// <summary>
/// 用本程序打开文件
/// 用本程序打开文件
/// </summary>
/// </summary>
public
const
string
TAG_OPEN_IN_THIS
=
"open_file_in_this"
;
public
const
string
TAG_OPEN_IN_THIS
=
"open_file_in_this"
;
/// <summary>
/// <summary>
/// 自动检查更新
/// 自动检查更新
/// </summary>
/// </summary>
public
const
string
TAG_AUTO_CHECK_UPDATE
=
"auto_check_update"
;
public
const
string
TAG_AUTO_CHECK_UPDATE
=
"auto_check_update"
;
/// <summary>
/// <summary>
/// add require automatically
/// add require automatically
/// </summary>
/// </summary>
public
const
string
TAG_ADD_REQUIRE
=
"add_require"
;
public
const
string
TAG_ADD_REQUIRE
=
"add_require"
;
/// <summary>
/// <summary>
/// 检查系统语言
/// 检查系统语言
/// </summary>
/// </summary>
public
const
string
TAG_CHECK_SYSLANG
=
"check_system_language"
;
public
const
string
TAG_CHECK_SYSLANG
=
"check_system_language"
;
/// <summary>
/// <summary>
/// 一般的裁剪
/// 一般的裁剪
/// </summary>
/// </summary>
public
const
string
TAG_IMAGE_OTHER
=
"image_other"
;
public
const
string
TAG_IMAGE_OTHER
=
"image_other"
;
/// <summary>
/// <summary>
/// xyz的裁剪
/// xyz的裁剪
/// </summary>
/// </summary>
public
const
string
TAG_IMAGE_XYZ
=
"image_xyz"
;
public
const
string
TAG_IMAGE_XYZ
=
"image_xyz"
;
/// <summary>
/// <summary>
/// Pendulum的裁剪
/// Pendulum的裁剪
/// </summary>
/// </summary>
public
const
string
TAG_IMAGE_PENDULUM
=
"image_pendulum"
;
public
const
string
TAG_IMAGE_PENDULUM
=
"image_pendulum"
;
/// <summary>
/// <summary>
/// 图片的宽高,小图w,h大图W,H,共4个
/// 图片的宽高,小图w,h大图W,H,共4个
/// </summary>
/// </summary>
public
const
string
TAG_IMAGE_SIZE
=
"image"
;
public
const
string
TAG_IMAGE_SIZE
=
"image"
;
/// <summary>
/// <summary>
/// 图片质量
/// 图片质量
/// </summary>
/// </summary>
public
const
string
TAG_IMAGE_QUILTY
=
"image_quilty"
;
public
const
string
TAG_IMAGE_QUILTY
=
"image_quilty"
;
//CodeEditor
//CodeEditor
/// <summary>
/// <summary>
/// 字体名
/// 字体名
/// </summary>
/// </summary>
public
const
string
TAG_FONT_NAME
=
"fontname"
;
public
const
string
TAG_FONT_NAME
=
"fontname"
;
/// <summary>
/// <summary>
/// 字体大小
/// 字体大小
/// </summary>
/// </summary>
public
const
string
TAG_FONT_SIZE
=
"fontsize"
;
public
const
string
TAG_FONT_SIZE
=
"fontsize"
;
/// <summary>
/// <summary>
/// 支持中文
/// 支持中文
/// </summary>
/// </summary>
public
const
string
TAG_IME
=
"IME"
;
public
const
string
TAG_IME
=
"IME"
;
/// <summary>
/// <summary>
/// 自动换行
/// 自动换行
/// </summary>
/// </summary>
public
const
string
TAG_WORDWRAP
=
"wordwrap"
;
public
const
string
TAG_WORDWRAP
=
"wordwrap"
;
/// <summary>
/// <summary>
/// tab替换为空格
/// tab替换为空格
/// </summary>
/// </summary>
public
const
string
TAG_TAB2SPACES
=
"tabisspace"
;
public
const
string
TAG_TAB2SPACES
=
"tabisspace"
;
/// <summary>
/// <summary>
/// 规则
/// 规则
/// </summary>
/// </summary>
public
const
string
TAG_RULE
=
"rule"
;
public
const
string
TAG_RULE
=
"rule"
;
/// <summary>
/// <summary>
/// 种族
/// 种族
/// </summary>
/// </summary>
public
const
string
TAG_RACE
=
"race"
;
public
const
string
TAG_RACE
=
"race"
;
/// <summary>
/// <summary>
/// 属性
/// 属性
/// </summary>
/// </summary>
public
const
string
TAG_ATTRIBUTE
=
"attribute"
;
public
const
string
TAG_ATTRIBUTE
=
"attribute"
;
/// <summary>
/// <summary>
/// 等级
/// 等级
/// </summary>
/// </summary>
public
const
string
TAG_LEVEL
=
"level"
;
public
const
string
TAG_LEVEL
=
"level"
;
/// <summary>
/// <summary>
/// 效果分类
/// 效果分类
/// </summary>
/// </summary>
public
const
string
TAG_CATEGORY
=
"category"
;
public
const
string
TAG_CATEGORY
=
"category"
;
/// <summary>
/// <summary>
/// 类型
/// 类型
/// </summary>
/// </summary>
public
const
string
TAG_TYPE
=
"type"
;
public
const
string
TAG_TYPE
=
"type"
;
/// <summary>
/// <summary>
/// 系列名
/// 系列名
/// </summary>
/// </summary>
public
const
string
TAG_SETNAME
=
"setname"
;
public
const
string
TAG_SETNAME
=
"setname"
;
/// <summary>
/// <summary>
/// 连接标志
/// 连接标志
/// </summary>
/// </summary>
public
const
string
TAG_MARKER
=
"link marker"
;
public
const
string
TAG_MARKER
=
"link marker"
;
#
endregion
#
endregion
#
region
读取内容
#
region
读取内容
/// <summary>
/// <summary>
/// 读取字符串值
/// 读取字符串值
/// </summary>
/// </summary>
/// <param name="key"></param>
/// <param name="key"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
readString
(
string
key
)
public
static
string
readString
(
string
key
)
{
{
return
GetAppConfig
(
key
);
return
GetAppConfig
(
key
);
}
}
/// <summary>
/// <summary>
/// 读取int值
/// 读取int值
/// </summary>
/// </summary>
/// <param name="key"></param>
/// <param name="key"></param>
/// <param name="def"></param>
/// <param name="def"></param>
/// <returns></returns>
/// <returns></returns>
public
static
int
readInteger
(
string
key
,
int
def
)
public
static
int
readInteger
(
string
key
,
int
def
)
{
{
int
i
;
int
i
;
if
(
int
.
TryParse
(
readString
(
key
),
out
i
))
if
(
int
.
TryParse
(
readString
(
key
),
out
i
))
return
i
;
return
i
;
return
def
;
return
def
;
}
}
/// <summary>
/// <summary>
/// 读取float值
/// 读取float值
/// </summary>
/// </summary>
/// <param name="key"></param>
/// <param name="key"></param>
/// <param name="def"></param>
/// <param name="def"></param>
/// <returns></returns>
/// <returns></returns>
public
static
float
readFloat
(
string
key
,
float
def
)
public
static
float
readFloat
(
string
key
,
float
def
)
{
{
float
i
;
float
i
;
if
(
float
.
TryParse
(
readString
(
key
),
out
i
))
if
(
float
.
TryParse
(
readString
(
key
),
out
i
))
return
i
;
return
i
;
return
def
;
return
def
;
}
}
/// <summary>
/// <summary>
/// 读取int数组
/// 读取int数组
/// </summary>
/// </summary>
/// <param name="key"></param>
/// <param name="key"></param>
/// <param name="length"></param>
/// <param name="length"></param>
/// <returns></returns>
/// <returns></returns>
public
static
int
[]
readIntegers
(
string
key
,
int
length
)
public
static
int
[]
readIntegers
(
string
key
,
int
length
)
{
{
string
temp
=
readString
(
key
);
string
temp
=
readString
(
key
);
int
[]
ints
=
new
int
[
length
];
int
[]
ints
=
new
int
[
length
];
string
[]
ws
=
string
.
IsNullOrEmpty
(
temp
)
?
null
:
temp
.
Split
(
','
);
string
[]
ws
=
string
.
IsNullOrEmpty
(
temp
)
?
null
:
temp
.
Split
(
','
);
if
(
ws
!=
null
&&
ws
.
Length
>
0
&&
ws
.
Length
<=
length
)
if
(
ws
!=
null
&&
ws
.
Length
>
0
&&
ws
.
Length
<=
length
)
{
{
for
(
int
i
=
0
;
i
<
ws
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
ws
.
Length
;
i
++)
{
{
int
.
TryParse
(
ws
[
i
],
out
ints
[
i
]);
int
.
TryParse
(
ws
[
i
],
out
ints
[
i
]);
}
}
}
}
return
ints
;
return
ints
;
}
}
/// <summary>
/// <summary>
/// 读取区域
/// 读取区域
/// </summary>
/// </summary>
/// <param name="key"></param>
/// <param name="key"></param>
/// <returns></returns>
/// <returns></returns>
public
static
Area
readArea
(
string
key
)
public
static
Area
readArea
(
string
key
)
{
{
int
[]
ints
=
readIntegers
(
key
,
4
);
int
[]
ints
=
readIntegers
(
key
,
4
);
Area
a
=
new
Area
();
Area
a
=
new
Area
();
if
(
ints
!=
null
)
if
(
ints
!=
null
)
{
{
a
.
left
=
ints
[
0
];
a
.
left
=
ints
[
0
];
a
.
top
=
ints
[
1
];
a
.
top
=
ints
[
1
];
a
.
width
=
ints
[
2
];
a
.
width
=
ints
[
2
];
a
.
height
=
ints
[
3
];
a
.
height
=
ints
[
3
];
}
}
return
a
;
return
a
;
}
}
/// <summary>
/// <summary>
/// 读取boolean
/// 读取boolean
/// </summary>
/// </summary>
/// <param name="key"></param>
/// <param name="key"></param>
/// <returns></returns>
/// <returns></returns>
public
static
bool
readBoolean
(
string
key
,
bool
def
=
false
)
public
static
bool
readBoolean
(
string
key
,
bool
def
=
false
)
{
{
string
val
=
readString
(
key
);
string
val
=
readString
(
key
);
if
(
"true"
.
Equals
(
val
,
StringComparison
.
OrdinalIgnoreCase
)){
if
(
"true"
.
Equals
(
val
,
StringComparison
.
OrdinalIgnoreCase
)){
return
true
;
return
true
;
}
}
if
(
"false"
.
Equals
(
val
,
StringComparison
.
OrdinalIgnoreCase
)){
if
(
"false"
.
Equals
(
val
,
StringComparison
.
OrdinalIgnoreCase
)){
return
false
;
return
false
;
}
}
return
def
;
return
def
;
}
}
#
endregion
#
endregion
/// <summary>
/// <summary>
/// 语言配置文件名
/// 语言配置文件名
/// </summary>
/// </summary>
/// <param name="path"></param>
/// <param name="path"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
GetLanguageFile
(
string
path
)
public
static
string
GetLanguageFile
(
string
path
)
{
{
if
(
readBoolean
(
TAG_CHECK_SYSLANG
)
&&
Directory
.
Exists
(
path
))
if
(
readBoolean
(
TAG_CHECK_SYSLANG
)
&&
Directory
.
Exists
(
path
))
{
{
Save
(
TAG_CHECK_SYSLANG
,
"false"
);
Save
(
TAG_CHECK_SYSLANG
,
"false"
);
...
@@ -294,67 +294,67 @@ public static string GetLanguageFile(string path)
...
@@ -294,67 +294,67 @@ public static string GetLanguageFile(string path)
}
}
}
}
}
}
return
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MyConfig
.
TAG_LANGUAGE
,
GetAppConfig
(
TAG_LANGUAGE
)));
return
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MyConfig
.
TAG_LANGUAGE
,
GetAppConfig
(
TAG_LANGUAGE
)));
}
}
/// <summary>
/// <summary>
/// 卡片信息配置文件名
/// 卡片信息配置文件名
/// </summary>
/// </summary>
/// <param name="path"></param>
/// <param name="path"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
GetCardInfoFile
(
string
path
)
public
static
string
GetCardInfoFile
(
string
path
)
{
{
return
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MyConfig
.
TAG_CARDINFO
,
GetAppConfig
(
TAG_LANGUAGE
)));
return
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MyConfig
.
TAG_CARDINFO
,
GetAppConfig
(
TAG_LANGUAGE
)));
}
}
/// <summary>
/// <summary>
/// 发送消息打开文件
/// 发送消息打开文件
/// </summary>
/// </summary>
/// <param name="file"></param>
/// <param name="file"></param>
public
static
bool
OpenOnExistForm
(
string
file
)
public
static
bool
OpenOnExistForm
(
string
file
)
{
{
Process
instance
=
RunningInstance
(
Assembly
.
GetExecutingAssembly
().
Location
.
Process
instance
=
RunningInstance
(
Assembly
.
GetExecutingAssembly
().
Location
.
Replace
(
'/'
,
Path
.
DirectorySeparatorChar
));
Replace
(
'/'
,
Path
.
DirectorySeparatorChar
));
if
(
instance
==
null
)
if
(
instance
==
null
)
{
{
return
false
;
return
false
;
}
}
else
else
{
{
//把需要打开的文件写入临时文件
//把需要打开的文件写入临时文件
string
tmpfile
=
Path
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
FILE_TEMP
);
string
tmpfile
=
Path
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
FILE_TEMP
);
File
.
WriteAllText
(
tmpfile
,
file
);
File
.
WriteAllText
(
tmpfile
,
file
);
//发送消息
//发送消息
User32
.
SendMessage
(
instance
.
MainWindowHandle
,
MyConfig
.
WM_OPEN
,
0
,
0
);
User32
.
SendMessage
(
instance
.
MainWindowHandle
,
MyConfig
.
WM_OPEN
,
0
,
0
);
return
true
;
return
true
;
}
}
}
}
public
static
void
OpenFileInThis
(
string
file
)
public
static
void
OpenFileInThis
(
string
file
)
{
{
//把需要打开的文件写入临时文件
//把需要打开的文件写入临时文件
string
tmpfile
=
Path
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
FILE_TEMP
);
string
tmpfile
=
Path
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
FILE_TEMP
);
File
.
WriteAllText
(
tmpfile
,
file
);
File
.
WriteAllText
(
tmpfile
,
file
);
//发送消息
//发送消息
User32
.
SendMessage
(
Process
.
GetCurrentProcess
().
MainWindowHandle
,
MyConfig
.
WM_OPEN
,
0
,
0
);
User32
.
SendMessage
(
Process
.
GetCurrentProcess
().
MainWindowHandle
,
MyConfig
.
WM_OPEN
,
0
,
0
);
}
}
public
static
Process
RunningInstance
(
string
filename
)
public
static
Process
RunningInstance
(
string
filename
)
{
{
Process
current
=
Process
.
GetCurrentProcess
();
Process
current
=
Process
.
GetCurrentProcess
();
Process
[]
processes
=
Process
.
GetProcessesByName
(
current
.
ProcessName
);
Process
[]
processes
=
Process
.
GetProcessesByName
(
current
.
ProcessName
);
//遍历与当前进程名称相同的进程列表
//遍历与当前进程名称相同的进程列表
foreach
(
Process
process
in
processes
)
foreach
(
Process
process
in
processes
)
{
{
//如果实例已经存在则忽略当前进程
//如果实例已经存在则忽略当前进程
if
(
process
.
Id
!=
current
.
Id
)
if
(
process
.
Id
!=
current
.
Id
)
{
{
//保证要打开的进程同已经存在的进程来自同一文件路径
//保证要打开的进程同已经存在的进程来自同一文件路径
if
(
filename
==
current
.
MainModule
.
FileName
)
if
(
filename
==
current
.
MainModule
.
FileName
)
{
{
//返回已经存在的进程
//返回已经存在的进程
return
process
;
return
process
;
}
}
}
}
}
}
return
null
;
return
null
;
}
}
}
}
}
}
DataEditorX/Config/YgoPath.cs
View file @
e72f147e
...
@@ -5,39 +5,39 @@
...
@@ -5,39 +5,39 @@
namespace
DataEditorX.Config
namespace
DataEditorX.Config
{
{
public
class
YgoPath
public
class
YgoPath
{
{
public
YgoPath
(
string
gamepath
)
public
YgoPath
(
string
gamepath
)
{
{
SetPath
(
gamepath
);
SetPath
(
gamepath
);
}
}
public
void
SetPath
(
string
gamepath
)
public
void
SetPath
(
string
gamepath
)
{
{
this
.
gamepath
=
gamepath
;
this
.
gamepath
=
gamepath
;
picpath
=
MyPath
.
Combine
(
gamepath
,
"pics"
);
picpath
=
MyPath
.
Combine
(
gamepath
,
"pics"
);
fieldpath
=
MyPath
.
Combine
(
picpath
,
"field"
);
fieldpath
=
MyPath
.
Combine
(
picpath
,
"field"
);
picpath2
=
MyPath
.
Combine
(
picpath
,
"thumbnail"
);
picpath2
=
MyPath
.
Combine
(
picpath
,
"thumbnail"
);
luapath
=
MyPath
.
Combine
(
gamepath
,
"script"
);
luapath
=
MyPath
.
Combine
(
gamepath
,
"script"
);
ydkpath
=
MyPath
.
Combine
(
gamepath
,
"deck"
);
ydkpath
=
MyPath
.
Combine
(
gamepath
,
"deck"
);
replaypath
=
MyPath
.
Combine
(
gamepath
,
"replay"
);
replaypath
=
MyPath
.
Combine
(
gamepath
,
"replay"
);
}
}
/// <summary>游戏目录</summary>
/// <summary>游戏目录</summary>
public
string
gamepath
;
public
string
gamepath
;
/// <summary>大图目录</summary>
/// <summary>大图目录</summary>
public
string
picpath
;
public
string
picpath
;
/// <summary>小图目录</summary>
/// <summary>小图目录</summary>
public
string
picpath2
;
public
string
picpath2
;
/// <summary>场地图目录</summary>
/// <summary>场地图目录</summary>
public
string
fieldpath
;
public
string
fieldpath
;
/// <summary>脚本目录</summary>
/// <summary>脚本目录</summary>
public
string
luapath
;
public
string
luapath
;
/// <summary>卡组目录</summary>
/// <summary>卡组目录</summary>
public
string
ydkpath
;
public
string
ydkpath
;
/// <summary>录像目录</summary>
/// <summary>录像目录</summary>
public
string
replaypath
;
public
string
replaypath
;
public
string
GetImage
(
long
id
)
public
string
GetImage
(
long
id
)
{
{
return
GetImage
(
id
.
ToString
());
return
GetImage
(
id
.
ToString
());
}
}
//public string GetImageThum(long id)
//public string GetImageThum(long id)
...
@@ -45,11 +45,11 @@ public string GetImage(long id)
...
@@ -45,11 +45,11 @@ public string GetImage(long id)
// return GetImageThum(id.ToString());
// return GetImageThum(id.ToString());
//}
//}
public
string
GetImageField
(
long
id
)
public
string
GetImageField
(
long
id
)
{
{
return
GetImageField
(
id
.
ToString
());
//场地图
return
GetImageField
(
id
.
ToString
());
//场地图
}
}
public
string
GetScript
(
long
id
)
public
string
GetScript
(
long
id
)
{
{
return
GetScript
(
id
.
ToString
());
return
GetScript
(
id
.
ToString
());
}
}
public
string
GetYdk
(
string
name
)
public
string
GetYdk
(
string
name
)
...
@@ -66,9 +66,9 @@ public string GetImage(string id)
...
@@ -66,9 +66,9 @@ public string GetImage(string id)
// return MyPath.Combine(picpath2, id + ".jpg");
// return MyPath.Combine(picpath2, id + ".jpg");
//}
//}
public
string
GetImageField
(
string
id
)
public
string
GetImageField
(
string
id
)
{
{
return
MyPath
.
Combine
(
fieldpath
,
id
+
".png"
);
//场地图
return
MyPath
.
Combine
(
fieldpath
,
id
+
".png"
);
//场地图
}
}
public
string
GetScript
(
string
id
)
public
string
GetScript
(
string
id
)
{
{
return
MyPath
.
Combine
(
luapath
,
"c"
+
id
+
".lua"
);
return
MyPath
.
Combine
(
luapath
,
"c"
+
id
+
".lua"
);
...
...
DataEditorX/Controls/DFlowLayoutPanel.cs
View file @
e72f147e
...
@@ -5,14 +5,14 @@
...
@@ -5,14 +5,14 @@
namespace
DataEditorX
namespace
DataEditorX
{
{
public
class
DFlowLayoutPanel
:
FlowLayoutPanel
public
class
DFlowLayoutPanel
:
FlowLayoutPanel
{
{
public
DFlowLayoutPanel
()
public
DFlowLayoutPanel
()
{
{
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
ControlStyles
.
AllPaintingInWmPaint
,
ControlStyles
.
AllPaintingInWmPaint
,
true
);
true
);
UpdateStyles
();
UpdateStyles
();
}
}
}
}
}
}
DataEditorX/Controls/DListBox.cs
View file @
e72f147e
...
@@ -5,14 +5,14 @@
...
@@ -5,14 +5,14 @@
namespace
DataEditorX
namespace
DataEditorX
{
{
public
class
DListBox
:
ListBox
public
class
DListBox
:
ListBox
{
{
public
DListBox
()
public
DListBox
()
{
{
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
ControlStyles
.
AllPaintingInWmPaint
,
ControlStyles
.
AllPaintingInWmPaint
,
true
);
true
);
UpdateStyles
();
UpdateStyles
();
}
}
}
}
}
}
DataEditorX/Controls/DListView.cs
View file @
e72f147e
...
@@ -5,14 +5,14 @@
...
@@ -5,14 +5,14 @@
namespace
DataEditorX
namespace
DataEditorX
{
{
public
class
DListView
:
ListView
public
class
DListView
:
ListView
{
{
public
DListView
()
public
DListView
()
{
{
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
ControlStyles
.
AllPaintingInWmPaint
,
ControlStyles
.
AllPaintingInWmPaint
,
true
);
true
);
UpdateStyles
();
UpdateStyles
();
}
}
}
}
}
}
DataEditorX/Controls/FastColoredTextBoxEx.cs
View file @
e72f147e
...
@@ -19,8 +19,8 @@ public class FastColoredTextBoxEx : FastColoredTextBox
...
@@ -19,8 +19,8 @@ public class FastColoredTextBoxEx : FastColoredTextBox
public
FastColoredTextBoxEx
()
:
base
()
public
FastColoredTextBoxEx
()
:
base
()
{
{
this
.
SyntaxHighlighter
=
new
MySyntaxHighlighter
();
this
.
SyntaxHighlighter
=
new
MySyntaxHighlighter
();
this
.
TextChangedDelayed
+=
FctbTextChangedDelayed
;
this
.
TextChangedDelayed
+=
FctbTextChangedDelayed
;
}
}
public
new
event
EventHandler
<
ToolTipNeededEventArgs
>
ToolTipNeeded
;
public
new
event
EventHandler
<
ToolTipNeededEventArgs
>
ToolTipNeeded
;
...
@@ -43,7 +43,7 @@ protected override void OnToolTip()
...
@@ -43,7 +43,7 @@ protected override void OnToolTip()
//check distance
//check distance
Point
p
=
PlaceToPoint
(
place
);
Point
p
=
PlaceToPoint
(
place
);
if
(
Math
.
Abs
(
p
.
X
-
lastMouseCoord
.
X
)
>
CharWidth
*
2
||
if
(
Math
.
Abs
(
p
.
X
-
lastMouseCoord
.
X
)
>
CharWidth
*
2
||
Math
.
Abs
(
p
.
Y
-
lastMouseCoord
.
Y
)
>
CharHeight
*
2
)
Math
.
Abs
(
p
.
Y
-
lastMouseCoord
.
Y
)
>
CharHeight
*
2
)
return
;
return
;
//get word under mouse
//get word under mouse
var
r
=
new
Range
(
this
,
place
,
place
);
var
r
=
new
Range
(
this
,
place
,
place
);
...
@@ -61,30 +61,30 @@ protected override void OnToolTip()
...
@@ -61,30 +61,30 @@ protected override void OnToolTip()
ToolTip
.
Show
(
ea
.
ToolTipText
,
this
,
new
Point
(
lastMouseCoord
.
X
,
lastMouseCoord
.
Y
+
CharHeight
));
ToolTip
.
Show
(
ea
.
ToolTipText
,
this
,
new
Point
(
lastMouseCoord
.
X
,
lastMouseCoord
.
Y
+
CharHeight
));
}
}
}
}
//高亮当前词
//高亮当前词
void
FctbTextChangedDelayed
(
object
sender
,
TextChangedEventArgs
e
)
void
FctbTextChangedDelayed
(
object
sender
,
TextChangedEventArgs
e
)
{
{
//delete all markers
//delete all markers
this
.
Range
.
ClearFoldingMarkers
();
this
.
Range
.
ClearFoldingMarkers
();
var
currentIndent
=
0
;
var
currentIndent
=
0
;
var
lastNonEmptyLine
=
0
;
var
lastNonEmptyLine
=
0
;
for
(
int
i
=
0
;
i
<
this
.
LinesCount
;
i
++)
for
(
int
i
=
0
;
i
<
this
.
LinesCount
;
i
++)
{
{
var
line
=
this
[
i
];
var
line
=
this
[
i
];
var
spacesCount
=
line
.
StartSpacesCount
;
var
spacesCount
=
line
.
StartSpacesCount
;
if
(
spacesCount
==
line
.
Count
)
//empty line
if
(
spacesCount
==
line
.
Count
)
//empty line
continue
;
continue
;
if
(
currentIndent
<
spacesCount
)
if
(
currentIndent
<
spacesCount
)
//append start folding marker
//append start folding marker
this
[
lastNonEmptyLine
].
FoldingStartMarker
=
"m"
+
currentIndent
;
this
[
lastNonEmptyLine
].
FoldingStartMarker
=
"m"
+
currentIndent
;
else
if
(
currentIndent
>
spacesCount
)
else
if
(
currentIndent
>
spacesCount
)
//append end folding marker
//append end folding marker
this
[
lastNonEmptyLine
].
FoldingEndMarker
=
"m"
+
spacesCount
;
this
[
lastNonEmptyLine
].
FoldingEndMarker
=
"m"
+
spacesCount
;
currentIndent
=
spacesCount
;
currentIndent
=
spacesCount
;
lastNonEmptyLine
=
i
;
lastNonEmptyLine
=
i
;
}
}
}
}
}
}
}
}
DataEditorX/Controls/History.cs
View file @
e72f147e
...
@@ -9,143 +9,143 @@
...
@@ -9,143 +9,143 @@
namespace
DataEditorX.Controls
namespace
DataEditorX.Controls
{
{
public
class
History
public
class
History
{
{
IMainForm
mainForm
;
IMainForm
mainForm
;
string
historyFile
;
string
historyFile
;
List
<
string
>
cdbhistory
;
List
<
string
>
cdbhistory
;
List
<
string
>
luahistory
;
List
<
string
>
luahistory
;
public
string
[]
GetcdbHistory
()
public
string
[]
GetcdbHistory
()
{
{
return
cdbhistory
.
ToArray
();
return
cdbhistory
.
ToArray
();
}
}
public
string
[]
GetluaHistory
()
public
string
[]
GetluaHistory
()
{
{
return
luahistory
.
ToArray
();
return
luahistory
.
ToArray
();
}
}
public
History
(
IMainForm
mainForm
)
public
History
(
IMainForm
mainForm
)
{
{
this
.
mainForm
=
mainForm
;
this
.
mainForm
=
mainForm
;
cdbhistory
=
new
List
<
string
>();
cdbhistory
=
new
List
<
string
>();
luahistory
=
new
List
<
string
>();
luahistory
=
new
List
<
string
>();
}
}
//读取历史记录
//读取历史记录
public
void
ReadHistory
(
string
historyFile
)
public
void
ReadHistory
(
string
historyFile
)
{
{
this
.
historyFile
=
historyFile
;
this
.
historyFile
=
historyFile
;
if
(!
File
.
Exists
(
historyFile
))
if
(!
File
.
Exists
(
historyFile
))
return
;
return
;
string
[]
lines
=
File
.
ReadAllLines
(
historyFile
);
string
[]
lines
=
File
.
ReadAllLines
(
historyFile
);
AddHistorys
(
lines
);
AddHistorys
(
lines
);
}
}
//添加历史记录
//添加历史记录
void
AddHistorys
(
string
[]
lines
)
void
AddHistorys
(
string
[]
lines
)
{
{
luahistory
.
Clear
();
luahistory
.
Clear
();
cdbhistory
.
Clear
();
cdbhistory
.
Clear
();
foreach
(
string
line
in
lines
)
foreach
(
string
line
in
lines
)
{
{
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"#"
))
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"#"
))
continue
;
continue
;
if
(
File
.
Exists
(
line
))
if
(
File
.
Exists
(
line
))
{
{
if
(
YGOUtil
.
isScript
(
line
))
if
(
YGOUtil
.
isScript
(
line
))
{
{
if
(
luahistory
.
Count
<
MyConfig
.
MAX_HISTORY
if
(
luahistory
.
Count
<
MyConfig
.
MAX_HISTORY
&&
luahistory
.
IndexOf
(
line
)
<
0
)
&&
luahistory
.
IndexOf
(
line
)
<
0
)
luahistory
.
Add
(
line
);
luahistory
.
Add
(
line
);
}
}
else
else
{
{
if
(
cdbhistory
.
Count
<
MyConfig
.
MAX_HISTORY
if
(
cdbhistory
.
Count
<
MyConfig
.
MAX_HISTORY
&&
cdbhistory
.
IndexOf
(
line
)
<
0
)
&&
cdbhistory
.
IndexOf
(
line
)
<
0
)
cdbhistory
.
Add
(
line
);
cdbhistory
.
Add
(
line
);
}
}
}
}
}
}
}
}
public
void
AddHistory
(
string
file
)
public
void
AddHistory
(
string
file
)
{
{
List
<
string
>
tmplist
=
new
List
<
string
>();
List
<
string
>
tmplist
=
new
List
<
string
>();
//添加到开始
//添加到开始
tmplist
.
Add
(
file
);
tmplist
.
Add
(
file
);
//添加旧记录
//添加旧记录
tmplist
.
AddRange
(
cdbhistory
.
ToArray
());
tmplist
.
AddRange
(
cdbhistory
.
ToArray
());
tmplist
.
AddRange
(
luahistory
.
ToArray
());
tmplist
.
AddRange
(
luahistory
.
ToArray
());
//
//
AddHistorys
(
tmplist
.
ToArray
());
AddHistorys
(
tmplist
.
ToArray
());
SaveHistory
();
SaveHistory
();
MenuHistory
();
MenuHistory
();
}
}
//保存历史
//保存历史
void
SaveHistory
()
void
SaveHistory
()
{
{
string
texts
=
"# database history"
;
string
texts
=
"# database history"
;
foreach
(
string
str
in
cdbhistory
)
foreach
(
string
str
in
cdbhistory
)
{
{
if
(
File
.
Exists
(
str
))
if
(
File
.
Exists
(
str
))
texts
+=
Environment
.
NewLine
+
str
;
texts
+=
Environment
.
NewLine
+
str
;
}
}
texts
+=
Environment
.
NewLine
+
"# script history"
;
texts
+=
Environment
.
NewLine
+
"# script history"
;
foreach
(
string
str
in
luahistory
)
foreach
(
string
str
in
luahistory
)
{
{
if
(
File
.
Exists
(
str
))
if
(
File
.
Exists
(
str
))
texts
+=
Environment
.
NewLine
+
str
;
texts
+=
Environment
.
NewLine
+
str
;
}
}
if
(
File
.
Exists
(
historyFile
))
if
(
File
.
Exists
(
historyFile
))
File
.
Delete
(
historyFile
);
File
.
Delete
(
historyFile
);
File
.
WriteAllText
(
historyFile
,
texts
);
File
.
WriteAllText
(
historyFile
,
texts
);
}
}
//添加历史记录菜单
//添加历史记录菜单
public
void
MenuHistory
()
public
void
MenuHistory
()
{
{
//cdb历史
//cdb历史
mainForm
.
CdbMenuClear
();
mainForm
.
CdbMenuClear
();
foreach
(
string
str
in
cdbhistory
)
foreach
(
string
str
in
cdbhistory
)
{
{
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
str
);
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
str
);
tsmi
.
Click
+=
MenuHistoryItem_Click
;
tsmi
.
Click
+=
MenuHistoryItem_Click
;
mainForm
.
AddCdbMenu
(
tsmi
);
mainForm
.
AddCdbMenu
(
tsmi
);
}
}
mainForm
.
AddCdbMenu
(
new
ToolStripSeparator
());
mainForm
.
AddCdbMenu
(
new
ToolStripSeparator
());
ToolStripMenuItem
tsmiclear
=
new
ToolStripMenuItem
(
LanguageHelper
.
GetMsg
(
LMSG
.
ClearHistory
));
ToolStripMenuItem
tsmiclear
=
new
ToolStripMenuItem
(
LanguageHelper
.
GetMsg
(
LMSG
.
ClearHistory
));
tsmiclear
.
Click
+=
MenuHistoryClear_Click
;
tsmiclear
.
Click
+=
MenuHistoryClear_Click
;
mainForm
.
AddCdbMenu
(
tsmiclear
);
mainForm
.
AddCdbMenu
(
tsmiclear
);
//lua历史
//lua历史
mainForm
.
LuaMenuClear
();
mainForm
.
LuaMenuClear
();
foreach
(
string
str
in
luahistory
)
foreach
(
string
str
in
luahistory
)
{
{
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
str
);
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
str
);
tsmi
.
Click
+=
MenuHistoryItem_Click
;
tsmi
.
Click
+=
MenuHistoryItem_Click
;
mainForm
.
AddLuaMenu
(
tsmi
);
mainForm
.
AddLuaMenu
(
tsmi
);
}
}
mainForm
.
AddLuaMenu
(
new
ToolStripSeparator
());
mainForm
.
AddLuaMenu
(
new
ToolStripSeparator
());
ToolStripMenuItem
tsmiclear2
=
new
ToolStripMenuItem
(
LanguageHelper
.
GetMsg
(
LMSG
.
ClearHistory
));
ToolStripMenuItem
tsmiclear2
=
new
ToolStripMenuItem
(
LanguageHelper
.
GetMsg
(
LMSG
.
ClearHistory
));
tsmiclear2
.
Click
+=
MenuHistoryClear2_Click
;
tsmiclear2
.
Click
+=
MenuHistoryClear2_Click
;
mainForm
.
AddLuaMenu
(
tsmiclear2
);
mainForm
.
AddLuaMenu
(
tsmiclear2
);
}
}
void
MenuHistoryClear2_Click
(
object
sender
,
EventArgs
e
)
void
MenuHistoryClear2_Click
(
object
sender
,
EventArgs
e
)
{
{
luahistory
.
Clear
();
luahistory
.
Clear
();
MenuHistory
();
MenuHistory
();
SaveHistory
();
SaveHistory
();
}
}
void
MenuHistoryClear_Click
(
object
sender
,
EventArgs
e
)
void
MenuHistoryClear_Click
(
object
sender
,
EventArgs
e
)
{
{
cdbhistory
.
Clear
();
cdbhistory
.
Clear
();
MenuHistory
();
MenuHistory
();
SaveHistory
();
SaveHistory
();
}
}
void
MenuHistoryItem_Click
(
object
sender
,
EventArgs
e
)
void
MenuHistoryItem_Click
(
object
sender
,
EventArgs
e
)
{
{
ToolStripMenuItem
tsmi
=
sender
as
ToolStripMenuItem
;
ToolStripMenuItem
tsmi
=
sender
as
ToolStripMenuItem
;
if
(
tsmi
!=
null
)
if
(
tsmi
!=
null
)
{
{
string
file
=
tsmi
.
Text
;
string
file
=
tsmi
.
Text
;
if
(
File
.
Exists
(
file
))
if
(
File
.
Exists
(
file
))
mainForm
.
Open
(
file
);
mainForm
.
Open
(
file
);
}
}
}
}
}
}
}
}
DataEditorX/Controls/IEditForm.cs
View file @
e72f147e
...
@@ -4,19 +4,19 @@
...
@@ -4,19 +4,19 @@
namespace
DataEditorX.Controls
namespace
DataEditorX.Controls
{
{
public
interface
IEditForm
public
interface
IEditForm
{
{
//获取打开的文件路径
//获取打开的文件路径
string
GetOpenFile
();
string
GetOpenFile
();
//创建文件
//创建文件
bool
Create
(
string
file
);
bool
Create
(
string
file
);
//打开文件
//打开文件
bool
Open
(
string
file
);
bool
Open
(
string
file
);
//是否能打开某个文件
//是否能打开某个文件
bool
CanOpen
(
string
file
);
bool
CanOpen
(
string
file
);
//保存
//保存
bool
Save
();
bool
Save
();
//设置为活动窗口
//设置为活动窗口
void
SetActived
();
void
SetActived
();
}
}
}
}
DataEditorX/Controls/IMainForm.cs
View file @
e72f147e
...
@@ -2,12 +2,12 @@
...
@@ -2,12 +2,12 @@
namespace
DataEditorX.Controls
namespace
DataEditorX.Controls
{
{
public
interface
IMainForm
public
interface
IMainForm
{
{
void
CdbMenuClear
();
void
CdbMenuClear
();
void
LuaMenuClear
();
void
LuaMenuClear
();
void
AddCdbMenu
(
ToolStripItem
item
);
void
AddCdbMenu
(
ToolStripItem
item
);
void
AddLuaMenu
(
ToolStripItem
item
);
void
AddLuaMenu
(
ToolStripItem
item
);
void
Open
(
string
file
);
void
Open
(
string
file
);
}
}
}
}
DataEditorX/Core/Card.cs
View file @
e72f147e
...
@@ -12,8 +12,8 @@ namespace DataEditorX.Core
...
@@ -12,8 +12,8 @@ namespace DataEditorX.Core
{
{
public
struct
Card
:
IEquatable
<
Card
>
public
struct
Card
:
IEquatable
<
Card
>
{
{
public
const
int
STR_MAX
=
0x10
;
public
const
int
STR_MAX
=
0x10
;
public
const
int
SETCODE_MAX
=
4
;
public
const
int
SETCODE_MAX
=
4
;
#
region
构造
#
region
构造
/// <summary>
/// <summary>
...
@@ -23,22 +23,22 @@ public struct Card : IEquatable<Card>
...
@@ -23,22 +23,22 @@ public struct Card : IEquatable<Card>
/// <param name="cardName">名字</param>
/// <param name="cardName">名字</param>
public
Card
(
long
cardCode
)
public
Card
(
long
cardCode
)
{
{
this
.
id
=
cardCode
;
this
.
id
=
cardCode
;
this
.
name
=
""
;
this
.
name
=
""
;
this
.
ot
=
0
;
this
.
ot
=
0
;
this
.
alias
=
0
;
this
.
alias
=
0
;
this
.
setcode
=
0
;
this
.
setcode
=
0
;
this
.
type
=
0
;
this
.
type
=
0
;
this
.
atk
=
0
;
this
.
atk
=
0
;
this
.
def
=
0
;
this
.
def
=
0
;
this
.
level
=
0
;
this
.
level
=
0
;
this
.
race
=
0
;
this
.
race
=
0
;
this
.
attribute
=
0
;
this
.
attribute
=
0
;
this
.
category
=
0
;
this
.
category
=
0
;
this
.
desc
=
""
;
this
.
desc
=
""
;
this
.
str
=
new
string
[
STR_MAX
];
this
.
str
=
new
string
[
STR_MAX
];
for
(
int
i
=
0
;
i
<
STR_MAX
;
i
++)
for
(
int
i
=
0
;
i
<
STR_MAX
;
i
++)
this
.
str
[
i
]
=
""
;
this
.
str
[
i
]
=
""
;
}
}
#
endregion
#
endregion
...
@@ -69,58 +69,58 @@ public Card(long cardCode)
...
@@ -69,58 +69,58 @@ public Card(long cardCode)
public
string
name
;
public
string
name
;
/// <summary>描述文本</summary>
/// <summary>描述文本</summary>
public
string
desc
;
public
string
desc
;
string
[]
str
;
string
[]
str
;
/// <summary>脚本文件文字</summary>
/// <summary>脚本文件文字</summary>
public
string
[]
Str
public
string
[]
Str
{
{
get
{
get
{
if
(
this
.
str
==
null
)
if
(
this
.
str
==
null
)
{
{
this
.
str
=
new
string
[
STR_MAX
];
this
.
str
=
new
string
[
STR_MAX
];
for
(
int
i
=
0
;
i
<
STR_MAX
;
i
++)
for
(
int
i
=
0
;
i
<
STR_MAX
;
i
++)
this
.
str
[
i
]
=
""
;
this
.
str
[
i
]
=
""
;
}
}
return
this
.
str
;
return
this
.
str
;
}
}
set
{
this
.
str
=
value
;
}
set
{
this
.
str
=
value
;
}
}
}
public
long
[]
GetSetCode
()
public
long
[]
GetSetCode
()
{
{
long
[]
setcodes
=
new
long
[
SETCODE_MAX
];
long
[]
setcodes
=
new
long
[
SETCODE_MAX
];
for
(
int
i
=
0
,
k
=
0
;
i
<
SETCODE_MAX
;
k
+=
0x10
,
i
++)
for
(
int
i
=
0
,
k
=
0
;
i
<
SETCODE_MAX
;
k
+=
0x10
,
i
++)
{
{
setcodes
[
i
]
=
(
this
.
setcode
>>
k
)
&
0xffff
;
setcodes
[
i
]
=
(
this
.
setcode
>>
k
)
&
0xffff
;
}
}
return
setcodes
;
return
setcodes
;
}
}
public
void
SetSetCode
(
params
long
[]
setcodes
)
public
void
SetSetCode
(
params
long
[]
setcodes
)
{
{
int
i
=
0
;
int
i
=
0
;
this
.
setcode
=
0
;
this
.
setcode
=
0
;
if
(
setcodes
!=
null
)
if
(
setcodes
!=
null
)
{
{
foreach
(
long
sc
in
setcodes
)
foreach
(
long
sc
in
setcodes
)
{
{
this
.
setcode
+=
(
sc
<<
i
);
this
.
setcode
+=
(
sc
<<
i
);
i
+=
0x10
;
i
+=
0x10
;
}
}
}
}
}
}
public
void
SetSetCode
(
params
string
[]
setcodes
)
public
void
SetSetCode
(
params
string
[]
setcodes
)
{
{
int
i
=
0
;
int
i
=
0
;
this
.
setcode
=
0
;
this
.
setcode
=
0
;
long
temp
;
long
temp
;
if
(
setcodes
!=
null
)
if
(
setcodes
!=
null
)
{
{
foreach
(
string
sc
in
setcodes
)
foreach
(
string
sc
in
setcodes
)
{
{
long
.
TryParse
(
sc
,
NumberStyles
.
HexNumber
,
null
,
out
temp
);
long
.
TryParse
(
sc
,
NumberStyles
.
HexNumber
,
null
,
out
temp
);
this
.
setcode
+=
(
temp
<<
i
);
this
.
setcode
+=
(
temp
<<
i
);
i
+=
0x10
;
i
+=
0x10
;
}
}
}
}
}
}
public
long
GetLeftScale
()
public
long
GetLeftScale
()
{
{
return
(
this
.
level
>>
24
)
&
0xff
;
return
(
this
.
level
>>
24
)
&
0xff
;
...
@@ -129,7 +129,7 @@ public long GetRightScale()
...
@@ -129,7 +129,7 @@ public long GetRightScale()
{
{
return
(
this
.
level
>>
16
)
&
0xff
;
return
(
this
.
level
>>
16
)
&
0xff
;
}
}
#
endregion
#
endregion
#
region
比较、哈希值、操作符
#
region
比较、哈希值、操作符
/// <summary>
/// <summary>
...
@@ -149,7 +149,7 @@ public override bool Equals(object obj)
...
@@ -149,7 +149,7 @@ public override bool Equals(object obj)
/// </summary>
/// </summary>
/// <param name="other"></param>
/// <param name="other"></param>
/// <returns></returns>
/// <returns></returns>
public
bool
EqualsData
(
Card
other
)
public
bool
EqualsData
(
Card
other
)
{
{
bool
equalBool
=
true
;
bool
equalBool
=
true
;
if
(
this
.
id
!=
other
.
id
)
if
(
this
.
id
!=
other
.
id
)
...
@@ -223,33 +223,33 @@ public override int GetHashCode()
...
@@ -223,33 +223,33 @@ public override int GetHashCode()
{
{
return
left
.
Equals
(
right
);
return
left
.
Equals
(
right
);
}
}
/// <summary>
/// <summary>
/// 是否是某类型
/// 是否是某类型
/// </summary>
/// </summary>
/// <param name="type"></param>
/// <param name="type"></param>
/// <returns></returns>
/// <returns></returns>
public
bool
IsType
(
CardType
type
){
public
bool
IsType
(
CardType
type
){
if
((
this
.
type
&
(
long
)
type
)
==
(
long
)
type
)
if
((
this
.
type
&
(
long
)
type
)
==
(
long
)
type
)
return
true
;
return
true
;
return
false
;
return
false
;
}
}
/// <summary>
/// <summary>
/// 是否是某系列
/// 是否是某系列
/// </summary>
/// </summary>
/// <param name="sc"></param>
/// <param name="sc"></param>
/// <returns></returns>
/// <returns></returns>
public
bool
IsSetCode
(
long
sc
)
public
bool
IsSetCode
(
long
sc
)
{
{
long
settype
=
sc
&
0xfff
;
long
settype
=
sc
&
0xfff
;
long
setsubtype
=
sc
&
0xf000
;
long
setsubtype
=
sc
&
0xf000
;
long
setcode
=
this
.
setcode
;
long
setcode
=
this
.
setcode
;
while
(
setcode
!=
0
)
while
(
setcode
!=
0
)
{
{
if
((
setcode
&
0xfff
)
==
settype
&&
(
setcode
&
0xf000
&
setsubtype
)
==
setsubtype
)
if
((
setcode
&
0xfff
)
==
settype
&&
(
setcode
&
0xf000
&
setsubtype
)
==
setsubtype
)
return
true
;
return
true
;
setcode
=
setcode
>>
0x10
;
setcode
=
setcode
>>
0x10
;
}
}
return
false
;
return
false
;
}
}
/// <summary>
/// <summary>
/// 卡片是否不相等
/// 卡片是否不相等
...
@@ -260,56 +260,56 @@ public bool IsSetCode(long sc)
...
@@ -260,56 +260,56 @@ public bool IsSetCode(long sc)
}
}
#
endregion
#
endregion
#
region
卡片文字信息
#
region
卡片文字信息
/// <summary>
/// <summary>
/// 密码字符串
/// 密码字符串
/// </summary>
/// </summary>
public
string
idString
public
string
idString
{
{
get
{
return
id
.
ToString
(
"00000000"
);
}
get
{
return
id
.
ToString
(
"00000000"
);
}
}
}
/// <summary>
/// <summary>
/// 字符串化
/// 字符串化
/// </summary>
/// </summary>
public
override
string
ToString
()
public
override
string
ToString
()
{
{
string
str
=
""
;
string
str
=
""
;
if
(
IsType
(
CardType
.
TYPE_MONSTER
)){
if
(
IsType
(
CardType
.
TYPE_MONSTER
)){
str
=
name
+
"["
+
idString
+
"]\n["
str
=
name
+
"["
+
idString
+
"]\n["
+
YGOUtil
.
GetTypeString
(
type
)
+
"] "
+
YGOUtil
.
GetTypeString
(
type
)
+
"] "
+
YGOUtil
.
GetRace
(
race
)
+
"/"
+
YGOUtil
.
GetAttributeString
(
attribute
)
+
YGOUtil
.
GetRace
(
race
)
+
"/"
+
YGOUtil
.
GetAttributeString
(
attribute
)
+
"\n"
+
levelString
()
+
" "
+
atk
+
"/"
+
def
+
"\n"
+
redesc
();
+
"\n"
+
levelString
()
+
" "
+
atk
+
"/"
+
def
+
"\n"
+
redesc
();
}
else
}
else
str
=
name
+
"["
+
idString
+
"]\n["
+
YGOUtil
.
GetTypeString
(
type
)+
"]\n"
+
redesc
();
str
=
name
+
"["
+
idString
+
"]\n["
+
YGOUtil
.
GetTypeString
(
type
)+
"]\n"
+
redesc
();
return
str
;
return
str
;
}
}
public
string
ToShortString
(){
public
string
ToShortString
(){
return
this
.
name
+
" ["
+
idString
+
"]"
;
return
this
.
name
+
" ["
+
idString
+
"]"
;
}
}
public
string
ToLongString
(){
public
string
ToLongString
(){
return
ToString
();
return
ToString
();
}
}
string
levelString
()
string
levelString
()
{
{
string
star
=
"["
;
string
star
=
"["
;
long
i
=
0
,
j
=
level
&
0xff
;
long
i
=
0
,
j
=
level
&
0xff
;
for
(
i
=
0
;
i
<
j
;
i
++)
for
(
i
=
0
;
i
<
j
;
i
++)
{
{
if
(
i
>
0
&&
(
i
%
4
)
==
0
)
if
(
i
>
0
&&
(
i
%
4
)
==
0
)
star
+=
" "
;
star
+=
" "
;
star
+=
"★"
;
star
+=
"★"
;
}
}
return
star
+
"]"
;
return
star
+
"]"
;
}
}
string
redesc
()
string
redesc
()
{
{
string
str
=
desc
.
Replace
(
Environment
.
NewLine
,
"\n"
);
string
str
=
desc
.
Replace
(
Environment
.
NewLine
,
"\n"
);
str
=
Regex
.
Replace
(
str
,
"([。|?|?])"
,
"$1\n"
);
str
=
Regex
.
Replace
(
str
,
"([。|?|?])"
,
"$1\n"
);
str
=
str
.
Replace
(
"\n\n"
,
"\n"
);
str
=
str
.
Replace
(
"\n\n"
,
"\n"
);
return
str
;
return
str
;
}
}
#
endregion
#
endregion
}
}
}
}
DataEditorX/Core/CardEdit.cs
View file @
e72f147e
...
@@ -8,25 +8,25 @@
...
@@ -8,25 +8,25 @@
namespace
DataEditorX.Core
namespace
DataEditorX.Core
{
{
public
class
CardEdit
public
class
CardEdit
{
{
IDataForm
dataform
;
IDataForm
dataform
;
public
AddCommand
addCard
;
public
AddCommand
addCard
;
public
ModCommand
modCard
;
public
ModCommand
modCard
;
public
DelCommand
delCard
;
public
DelCommand
delCard
;
public
CopyCommand
copyCard
;
public
CopyCommand
copyCard
;
public
CardEdit
(
IDataForm
dataform
)
public
CardEdit
(
IDataForm
dataform
)
{
{
this
.
dataform
=
dataform
;
this
.
dataform
=
dataform
;
this
.
addCard
=
new
AddCommand
(
this
);
this
.
addCard
=
new
AddCommand
(
this
);
this
.
modCard
=
new
ModCommand
(
this
);
this
.
modCard
=
new
ModCommand
(
this
);
this
.
delCard
=
new
DelCommand
(
this
);
this
.
delCard
=
new
DelCommand
(
this
);
this
.
copyCard
=
new
CopyCommand
(
this
);
this
.
copyCard
=
new
CopyCommand
(
this
);
}
}
#
region
添加
#
region
添加
//添加
//添加
public
class
AddCommand
:
IBackableCommand
public
class
AddCommand
:
IBackableCommand
{
{
private
string
_undoSQL
;
private
string
_undoSQL
;
...
@@ -186,10 +186,10 @@ public object Clone()
...
@@ -186,10 +186,10 @@ public object Clone()
return
this
.
MemberwiseClone
();
return
this
.
MemberwiseClone
();
}
}
}
}
#
endregion
#
endregion
#
region
删除
#
region
删除
//删除
//删除
public
class
DelCommand
:
IBackableCommand
public
class
DelCommand
:
IBackableCommand
{
{
private
string
_undoSQL
;
private
string
_undoSQL
;
...
@@ -249,7 +249,7 @@ public object Clone()
...
@@ -249,7 +249,7 @@ public object Clone()
return
this
.
MemberwiseClone
();
return
this
.
MemberwiseClone
();
}
}
}
}
#
endregion
#
endregion
#
region
打开脚本
#
region
打开脚本
//打开脚本
//打开脚本
...
...
DataEditorX/Core/DataBase.cs
View file @
e72f147e
...
@@ -342,11 +342,11 @@ public static string GetSelectSQL(Card c)
...
@@ -342,11 +342,11 @@ public static string GetSelectSQL(Card c)
sb
.
Append
(
" and datas.attribute = "
+
c
.
attribute
.
ToString
());
sb
.
Append
(
" and datas.attribute = "
+
c
.
attribute
.
ToString
());
if
((
c
.
level
&
0xff
)
>
0
)
if
((
c
.
level
&
0xff
)
>
0
)
sb
.
Append
(
" and (datas.level & 255) = "
+
toInt
(
c
.
level
&
0xff
));
sb
.
Append
(
" and (datas.level & 255) = "
+
toInt
(
c
.
level
&
0xff
));
if
((
c
.
level
&
0xff000000
)
>
0
)
if
((
c
.
level
&
0xff000000
)
>
0
)
sb
.
Append
(
" and (datas.level & 4278190080) = "
+
toInt
(
c
.
level
&
0xff000000
));
sb
.
Append
(
" and (datas.level & 4278190080) = "
+
toInt
(
c
.
level
&
0xff000000
));
if
((
c
.
level
&
0xff0000
)
>
0
)
if
((
c
.
level
&
0xff0000
)
>
0
)
sb
.
Append
(
" and (datas.level & 16711680) = "
+
toInt
(
c
.
level
&
0xff0000
));
sb
.
Append
(
" and (datas.level & 16711680) = "
+
toInt
(
c
.
level
&
0xff0000
));
if
(
c
.
race
>
0
)
if
(
c
.
race
>
0
)
sb
.
Append
(
" and datas.race = "
+
toInt
(
c
.
race
));
sb
.
Append
(
" and datas.race = "
+
toInt
(
c
.
race
));
if
(
c
.
type
>
0
)
if
(
c
.
type
>
0
)
sb
.
Append
(
" and datas.type & "
+
toInt
(
c
.
type
)+
" = "
+
toInt
(
c
.
type
));
sb
.
Append
(
" and datas.type & "
+
toInt
(
c
.
type
)+
" = "
+
toInt
(
c
.
type
));
...
@@ -357,17 +357,17 @@ public static string GetSelectSQL(Card c)
...
@@ -357,17 +357,17 @@ public static string GetSelectSQL(Card c)
sb
.
Append
(
" and datas.type & 1 = 1 and datas.atk = 0"
);
sb
.
Append
(
" and datas.type & 1 = 1 and datas.atk = 0"
);
else
if
(
c
.
atk
<
0
||
c
.
atk
>
0
)
else
if
(
c
.
atk
<
0
||
c
.
atk
>
0
)
sb
.
Append
(
" and datas.atk = "
+
c
.
atk
.
ToString
());
sb
.
Append
(
" and datas.atk = "
+
c
.
atk
.
ToString
());
if
(
c
.
IsType
(
Info
.
CardType
.
TYPE_LINK
))
if
(
c
.
IsType
(
Info
.
CardType
.
TYPE_LINK
))
{
{
sb
.
Append
(
" and datas.def &"
+
c
.
def
.
ToString
()
+
"="
+
c
.
def
.
ToString
());
sb
.
Append
(
" and datas.def &"
+
c
.
def
.
ToString
()
+
"="
+
c
.
def
.
ToString
());
}
}
else
else
{
{
if
(
c
.
def
==
-
1
)
if
(
c
.
def
==
-
1
)
sb
.
Append
(
" and datas.type & 1 = 1 and datas.def = 0"
);
sb
.
Append
(
" and datas.type & 1 = 1 and datas.def = 0"
);
else
if
(
c
.
def
<
0
||
c
.
def
>
0
)
else
if
(
c
.
def
<
0
||
c
.
def
>
0
)
sb
.
Append
(
" and datas.def = "
+
c
.
def
.
ToString
());
sb
.
Append
(
" and datas.def = "
+
c
.
def
.
ToString
());
}
}
if
(
c
.
id
>
0
&&
c
.
alias
>
0
)
if
(
c
.
id
>
0
&&
c
.
alias
>
0
)
sb
.
Append
(
" and datas.id BETWEEN "
+
c
.
alias
.
ToString
()+
" and "
+
c
.
id
.
ToString
());
sb
.
Append
(
" and datas.id BETWEEN "
+
c
.
alias
.
ToString
()+
" and "
+
c
.
id
.
ToString
());
...
...
DataEditorX/Core/IDataForm.cs
View file @
e72f147e
...
@@ -3,19 +3,19 @@
...
@@ -3,19 +3,19 @@
namespace
DataEditorX.Core
namespace
DataEditorX.Core
{
{
public
interface
IDataForm
:
IEditForm
public
interface
IDataForm
:
IEditForm
{
{
YgoPath
GetPath
();
YgoPath
GetPath
();
Card
[]
GetCardList
(
bool
onlyselect
);
Card
[]
GetCardList
(
bool
onlyselect
);
bool
CheckOpen
();
bool
CheckOpen
();
void
Reset
();
void
Reset
();
void
SetImage
(
long
id
);
void
SetImage
(
long
id
);
void
SetImage
(
string
id
);
void
SetImage
(
string
id
);
void
Search
(
bool
isfresh
);
void
Search
(
bool
isfresh
);
Card
GetOldCard
();
Card
GetOldCard
();
Card
GetCard
();
Card
GetCard
();
void
SetCard
(
Card
c
);
void
SetCard
(
Card
c
);
void
SaveCards
(
Card
[]
cards
);
void
SaveCards
(
Card
[]
cards
);
void
CompareCards
(
string
cdbfile
,
bool
checktext
);
void
CompareCards
(
string
cdbfile
,
bool
checktext
);
}
}
}
}
DataEditorX/Core/Info/CardAttribute.cs
View file @
e72f147e
...
@@ -9,38 +9,38 @@
...
@@ -9,38 +9,38 @@
namespace
DataEditorX.Core.Info
namespace
DataEditorX.Core.Info
{
{
/// <summary>
/// <summary>
/// 卡片属性
/// 卡片属性
/// </summary>
/// </summary>
public
enum
CardAttribute
:
int
public
enum
CardAttribute
:
int
{
{
/// <summary>
/// <summary>
/// 地
/// 地
/// </summary>
/// </summary>
ATTRIBUTE_EARTH
=
0x01
,
ATTRIBUTE_EARTH
=
0x01
,
/// <summary>
/// <summary>
/// 水
/// 水
/// </summary>
/// </summary>
ATTRIBUTE_WATER
=
0x02
,
ATTRIBUTE_WATER
=
0x02
,
/// <summary>
/// <summary>
/// 炎
/// 炎
/// </summary>
/// </summary>
ATTRIBUTE_FIRE
=
0x04
,
ATTRIBUTE_FIRE
=
0x04
,
/// <summary>
/// <summary>
/// 风
/// 风
/// </summary>
/// </summary>
ATTRIBUTE_WIND
=
0x08
,
ATTRIBUTE_WIND
=
0x08
,
/// <summary>
/// <summary>
/// 光
/// 光
/// </summary>
/// </summary>
ATTRIBUTE_LIGHT
=
0x10
,
ATTRIBUTE_LIGHT
=
0x10
,
/// <summary>
/// <summary>
/// 暗
/// 暗
/// </summary>
/// </summary>
ATTRIBUTE_DARK
=
0x20
,
ATTRIBUTE_DARK
=
0x20
,
/// <summary>
/// <summary>
/// 神
/// 神
/// </summary>
/// </summary>
ATTRIBUTE_DEVINE
=
0x40
,
ATTRIBUTE_DEVINE
=
0x40
,
}
}
}
}
DataEditorX/Core/Info/CardRace.cs
View file @
e72f147e
...
@@ -9,61 +9,61 @@
...
@@ -9,61 +9,61 @@
namespace
DataEditorX.Core.Info
namespace
DataEditorX.Core.Info
{
{
/// <summary>
/// <summary>
/// 卡片种族
/// 卡片种族
/// </summary>
/// </summary>
public
enum
CardRace
:
long
public
enum
CardRace
:
long
{
{
RACE_NONE
=
0
,
RACE_NONE
=
0
,
///<summary>战士</summary>
///<summary>战士</summary>
RACE_WARRIOR
=
0x1
,
RACE_WARRIOR
=
0x1
,
///<summary>魔法师</summary>
///<summary>魔法师</summary>
RACE_SPELLCASTER
=
0x2
,
RACE_SPELLCASTER
=
0x2
,
///<summary>天使</summary>
///<summary>天使</summary>
RACE_FAIRY
=
0x4
,
RACE_FAIRY
=
0x4
,
///<summary>恶魔</summary>
///<summary>恶魔</summary>
RACE_FIEND
=
0x8
,
RACE_FIEND
=
0x8
,
///<summary>不死</summary>
///<summary>不死</summary>
RACE_ZOMBIE
=
0x10
,
RACE_ZOMBIE
=
0x10
,
///<summary>机械</summary>
///<summary>机械</summary>
RACE_MACHINE
=
0x20
,
RACE_MACHINE
=
0x20
,
///<summary>水</summary>
///<summary>水</summary>
RACE_AQUA
=
0x40
,
RACE_AQUA
=
0x40
,
///<summary>炎</summary>
///<summary>炎</summary>
RACE_PYRO
=
0x80
,
RACE_PYRO
=
0x80
,
///<summary>岩石</summary>
///<summary>岩石</summary>
RACE_ROCK
=
0x100
,
RACE_ROCK
=
0x100
,
///<summary>鸟兽</summary>
///<summary>鸟兽</summary>
RACE_WINDBEAST
=
0x200
,
RACE_WINDBEAST
=
0x200
,
///<summary>植物</summary>
///<summary>植物</summary>
RACE_PLANT
=
0x400
,
RACE_PLANT
=
0x400
,
///<summary>昆虫</summary>
///<summary>昆虫</summary>
RACE_INSECT
=
0x800
,
RACE_INSECT
=
0x800
,
///<summary>雷</summary>
///<summary>雷</summary>
RACE_THUNDER
=
0x1000
,
RACE_THUNDER
=
0x1000
,
///<summary>龙</summary>
///<summary>龙</summary>
RACE_DRAGON
=
0x2000
,
RACE_DRAGON
=
0x2000
,
///<summary>兽</summary>
///<summary>兽</summary>
RACE_BEAST
=
0x4000
,
RACE_BEAST
=
0x4000
,
///<summary>兽战士</summary>
///<summary>兽战士</summary>
RACE_BEASTWARRIOR
=
0x8000
,
RACE_BEASTWARRIOR
=
0x8000
,
///<summary>恐龙</summary>
///<summary>恐龙</summary>
RACE_DINOSAUR
=
0x10000
,
RACE_DINOSAUR
=
0x10000
,
///<summary>鱼</summary>
///<summary>鱼</summary>
RACE_FISH
=
0x20000
,
RACE_FISH
=
0x20000
,
///<summary>海龙</summary>
///<summary>海龙</summary>
RACE_SEASERPENT
=
0x40000
,
RACE_SEASERPENT
=
0x40000
,
///<summary>爬虫</summary>
///<summary>爬虫</summary>
RACE_REPTILE
=
0x80000
,
RACE_REPTILE
=
0x80000
,
///<summary>念动力</summary>
///<summary>念动力</summary>
RACE_PSYCHO
=
0x100000
,
RACE_PSYCHO
=
0x100000
,
///<summary>幻神兽</summary>
///<summary>幻神兽</summary>
RACE_DEVINE
=
0x200000
,
RACE_DEVINE
=
0x200000
,
///<summary>创造神</summary>
///<summary>创造神</summary>
RACE_CREATORGOD
=
0x400000
,
RACE_CREATORGOD
=
0x400000
,
///<summary>幻龙</summary>
///<summary>幻龙</summary>
RACE_WYRM
=
0x800000
,
RACE_WYRM
=
0x800000
,
///<summary>电子界</summary>
///<summary>电子界</summary>
RACE_CYBERSE
=
0x1000000
,
RACE_CYBERSE
=
0x1000000
,
}
}
}
}
DataEditorX/Core/Info/CardRule.cs
View file @
e72f147e
namespace
DataEditorX.Core.Info
namespace
DataEditorX.Core.Info
{
{
public
enum
CardRule
:
int
public
enum
CardRule
:
int
{
{
/// <summary>无</summary>
/// <summary>无</summary>
NONE
=
0
,
NONE
=
0
,
/// <summary>OCG</summary>
/// <summary>OCG</summary>
OCG
=
1
,
OCG
=
1
,
/// <summary>TCG</summary>
/// <summary>TCG</summary>
TCG
=
2
,
TCG
=
2
,
/// <summary>OT</summary>
/// <summary>OT</summary>
OCGTCG
=
3
,
OCGTCG
=
3
,
/// <summary>DIY,原创卡</summary>
/// <summary>DIY,原创卡</summary>
DIY
=
4
,
DIY
=
4
,
}
}
}
}
DataEditorX/Core/Info/CardType.cs
View file @
e72f147e
...
@@ -14,56 +14,56 @@ namespace DataEditorX.Core.Info
...
@@ -14,56 +14,56 @@ namespace DataEditorX.Core.Info
/// </summary>
/// </summary>
public
enum
CardType
:
long
public
enum
CardType
:
long
{
{
///<summary>怪兽卡</summary>
///<summary>怪兽卡</summary>
TYPE_MONSTER
=
0x1
,
TYPE_MONSTER
=
0x1
,
///<summary>魔法卡</summary>
///<summary>魔法卡</summary>
TYPE_SPELL
=
0x2
,
TYPE_SPELL
=
0x2
,
///<summary>陷阱卡</summary>
///<summary>陷阱卡</summary>
TYPE_TRAP
=
0x4
,
TYPE_TRAP
=
0x4
,
///<summary>通常</summary>
///<summary>通常</summary>
TYPE_NORMAL
=
0x10
,
TYPE_NORMAL
=
0x10
,
///<summary>效果</summary>
///<summary>效果</summary>
TYPE_EFFECT
=
0x20
,
TYPE_EFFECT
=
0x20
,
///<summary>融合</summary>
///<summary>融合</summary>
TYPE_FUSION
=
0x40
,
TYPE_FUSION
=
0x40
,
///<summary>仪式</summary>
///<summary>仪式</summary>
TYPE_RITUAL
=
0x80
,
TYPE_RITUAL
=
0x80
,
///<summary>陷阱怪兽</summary>
///<summary>陷阱怪兽</summary>
TYPE_TRAPMONSTER
=
0x100
,
TYPE_TRAPMONSTER
=
0x100
,
///<summary>灵魂</summary>
///<summary>灵魂</summary>
TYPE_SPIRIT
=
0x200
,
TYPE_SPIRIT
=
0x200
,
///<summary>同盟</summary>
///<summary>同盟</summary>
TYPE_UNION
=
0x400
,
TYPE_UNION
=
0x400
,
///<summary>二重</summary>
///<summary>二重</summary>
TYPE_DUAL
=
0x800
,
TYPE_DUAL
=
0x800
,
///<summary>调整</summary>
///<summary>调整</summary>
TYPE_TUNER
=
0x1000
,
TYPE_TUNER
=
0x1000
,
///<summary>同调</summary>
///<summary>同调</summary>
TYPE_SYNCHRO
=
0x2000
,
TYPE_SYNCHRO
=
0x2000
,
///<summary>衍生物</summary>
///<summary>衍生物</summary>
TYPE_TOKEN
=
0x4000
,
TYPE_TOKEN
=
0x4000
,
///<summary>速攻</summary>
///<summary>速攻</summary>
TYPE_QUICKPLAY
=
0x10000
,
TYPE_QUICKPLAY
=
0x10000
,
///<summary>永续</summary>
///<summary>永续</summary>
TYPE_CONTINUOUS
=
0x20000
,
TYPE_CONTINUOUS
=
0x20000
,
///<summary>装备</summary>
///<summary>装备</summary>
TYPE_EQUIP
=
0x40000
,
TYPE_EQUIP
=
0x40000
,
///<summary>场地</summary>
///<summary>场地</summary>
TYPE_FIELD
=
0x80000
,
TYPE_FIELD
=
0x80000
,
///<summary>反击</summary>
///<summary>反击</summary>
TYPE_COUNTER
=
0x100000
,
TYPE_COUNTER
=
0x100000
,
///<summary>反转</summary>
///<summary>反转</summary>
TYPE_FLIP
=
0x200000
,
TYPE_FLIP
=
0x200000
,
///<summary>卡通</summary>
///<summary>卡通</summary>
TYPE_TOON
=
0x400000
,
TYPE_TOON
=
0x400000
,
///<summary>超量</summary>
///<summary>超量</summary>
TYPE_XYZ
=
0x800000
,
TYPE_XYZ
=
0x800000
,
///<summary>灵摆</summary>
///<summary>灵摆</summary>
TYPE_PENDULUM
=
0x1000000
,
TYPE_PENDULUM
=
0x1000000
,
///<summary>特殊召唤</summary>
///<summary>特殊召唤</summary>
TYPE_SPSUMMON
=
0x2000000
,
TYPE_SPSUMMON
=
0x2000000
,
///<summary>连接</summary>
///<summary>连接</summary>
TYPE_LINK
=
0x4000000
,
TYPE_LINK
=
0x4000000
,
}
}
}
}
DataEditorX/Core/LuaFunction.cs
View file @
e72f147e
...
@@ -30,12 +30,12 @@ static void Log(string str)
...
@@ -30,12 +30,12 @@ static void Log(string str)
#
endregion
#
endregion
#
region
old
functions
#
region
old
functions
static
string
oldfun
;
static
string
oldfun
;
static
string
logtxt
;
static
string
logtxt
;
static
string
funclisttxt
;
static
string
funclisttxt
;
static
SortedList
<
string
,
string
>
funclist
=
new
SortedList
<
string
,
string
>();
static
SortedList
<
string
,
string
>
funclist
=
new
SortedList
<
string
,
string
>();
//读取旧函数
//读取旧函数
public
static
void
Read
(
string
funtxt
)
public
static
void
Read
(
string
funtxt
)
{
{
funclist
.
Clear
();
funclist
.
Clear
();
oldfun
=
funtxt
;
oldfun
=
funtxt
;
...
@@ -54,7 +54,7 @@ public static void Read(string funtxt)
...
@@ -54,7 +54,7 @@ public static void Read(string funtxt)
if
(
line
.
StartsWith
(
"●"
))
if
(
line
.
StartsWith
(
"●"
))
{
{
//添加之前的函数
//添加之前的函数
AddOldFun
(
name
,
desc
);
AddOldFun
(
name
,
desc
);
int
w
=
line
.
IndexOf
(
"("
);
int
w
=
line
.
IndexOf
(
"("
);
int
t
=
line
.
IndexOf
(
" "
);
int
t
=
line
.
IndexOf
(
" "
);
//获取当前名字
//获取当前名字
...
@@ -68,32 +68,32 @@ public static void Read(string funtxt)
...
@@ -68,32 +68,32 @@ public static void Read(string funtxt)
desc
+=
Environment
.
NewLine
+
line
;
desc
+=
Environment
.
NewLine
+
line
;
}
}
}
}
AddOldFun
(
name
,
desc
);
AddOldFun
(
name
,
desc
);
}
}
//return list;
//return list;
}
}
static
void
AddOldFun
(
string
name
,
string
desc
)
static
void
AddOldFun
(
string
name
,
string
desc
)
{
{
if
(!
string
.
IsNullOrEmpty
(
name
))
if
(!
string
.
IsNullOrEmpty
(
name
))
{
{
if
(
funclist
.
ContainsKey
(
name
))
//存在,则添加注释
if
(
funclist
.
ContainsKey
(
name
))
//存在,则添加注释
{
{
funclist
[
name
]
+=
Environment
.
NewLine
+
desc
;
funclist
[
name
]
+=
Environment
.
NewLine
+
desc
;
}
}
else
else
{
//不存在,则添加函数
{
//不存在,则添加函数
funclist
.
Add
(
name
,
desc
);
funclist
.
Add
(
name
,
desc
);
}
}
}
}
}
}
#
endregion
#
endregion
#
region
find
libs
#
region
find
libs
/// <summary>
/// <summary>
/// 查找lua函数
/// 查找lua函数
/// </summary>
/// </summary>
/// <param name="path"></param>
/// <param name="path"></param>
/// <returns></returns>
/// <returns></returns>
public
static
bool
Find
(
string
path
)
public
static
bool
Find
(
string
path
)
{
{
string
name
=
"interpreter.cpp"
;
string
name
=
"interpreter.cpp"
;
...
@@ -116,7 +116,7 @@ public static bool Find(string path)
...
@@ -116,7 +116,7 @@ public static bool Find(string path)
}
}
string
texts
=
File
.
ReadAllText
(
file
);
string
texts
=
File
.
ReadAllText
(
file
);
Regex
libRex
=
new
Regex
(
@"\sluaL_Reg\s([a-z]*?)lib\[\]([\s\S]*?)^\}"
Regex
libRex
=
new
Regex
(
@"\sluaL_Reg\s([a-z]*?)lib\[\]([\s\S]*?)^\}"
,
RegexOptions
.
Multiline
);
,
RegexOptions
.
Multiline
);
MatchCollection
libsMatch
=
libRex
.
Matches
(
texts
);
MatchCollection
libsMatch
=
libRex
.
Matches
(
texts
);
Log
(
"log:count "
+
libsMatch
.
Count
.
ToString
());
Log
(
"log:count "
+
libsMatch
.
Count
.
ToString
());
foreach
(
Match
m
in
libsMatch
)
//获取lib函数库
foreach
(
Match
m
in
libsMatch
)
//获取lib函数库
...
@@ -124,32 +124,32 @@ public static bool Find(string path)
...
@@ -124,32 +124,32 @@ public static bool Find(string path)
if
(
m
.
Groups
.
Count
>
2
){
if
(
m
.
Groups
.
Count
>
2
){
string
word
=
m
.
Groups
[
1
].
Value
;
string
word
=
m
.
Groups
[
1
].
Value
;
Log
(
"log:find "
+
word
);
Log
(
"log:find "
+
word
);
//分别去获取函数库的函数
//分别去获取函数库的函数
GetFunctions
(
word
,
m
.
Groups
[
2
].
Value
,
GetFunctions
(
word
,
m
.
Groups
[
2
].
Value
,
Path
.
Combine
(
path
,
"lib"
+
word
+
".cpp"
));
Path
.
Combine
(
path
,
"lib"
+
word
+
".cpp"
));
}
}
}
}
Save
();
Save
();
return
true
;
return
true
;
}
}
//保存
//保存
static
void
Save
()
static
void
Save
()
{
{
if
(
string
.
IsNullOrEmpty
(
oldfun
))
if
(
string
.
IsNullOrEmpty
(
oldfun
))
return
;
return
;
using
(
FileStream
fs
=
new
FileStream
(
oldfun
+
"_sort.txt"
,
using
(
FileStream
fs
=
new
FileStream
(
oldfun
+
"_sort.txt"
,
FileMode
.
Create
,
FileMode
.
Create
,
FileAccess
.
Write
))
FileAccess
.
Write
))
{
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
foreach
(
string
k
in
funclist
.
Keys
)
foreach
(
string
k
in
funclist
.
Keys
)
{
{
sw
.
WriteLine
(
"●"
+
funclist
[
k
]);
sw
.
WriteLine
(
"●"
+
funclist
[
k
]);
}
}
sw
.
Close
();
sw
.
Close
();
}
}
}
}
#
endregion
#
endregion
#
region
find
function
name
#
region
find
function
name
...
@@ -157,7 +157,7 @@ static string ToTitle(string str)
...
@@ -157,7 +157,7 @@ static string ToTitle(string str)
{
{
return
str
.
Substring
(
0
,
1
).
ToUpper
()+
str
.
Substring
(
1
);
return
str
.
Substring
(
0
,
1
).
ToUpper
()+
str
.
Substring
(
1
);
}
}
//获取函数库的lua函数名,和对应的c++函数
//获取函数库的lua函数名,和对应的c++函数
static
Dictionary
<
string
,
string
>
GetFunctionNames
(
string
texts
,
string
name
)
static
Dictionary
<
string
,
string
>
GetFunctionNames
(
string
texts
,
string
name
)
{
{
Dictionary
<
string
,
string
>
dic
=
new
Dictionary
<
string
,
string
>();
Dictionary
<
string
,
string
>
dic
=
new
Dictionary
<
string
,
string
>();
...
@@ -179,12 +179,12 @@ static string ToTitle(string str)
...
@@ -179,12 +179,12 @@ static string ToTitle(string str)
#
endregion
#
endregion
#
region
find
code
#
region
find
code
//查找c++代码
//查找c++代码
static
string
FindCode
(
string
texts
,
string
name
)
static
string
FindCode
(
string
texts
,
string
name
)
{
{
Regex
reg
=
new
Regex
(
@"int32\s+?"
+
name
Regex
reg
=
new
Regex
(
@"int32\s+?"
+
name
+
@"[\s\S]+?\{([\s\S]*?^)\}"
,
+
@"[\s\S]+?\{([\s\S]*?^)\}"
,
RegexOptions
.
Multiline
);
RegexOptions
.
Multiline
);
Match
mc
=
reg
.
Match
(
texts
);
Match
mc
=
reg
.
Match
(
texts
);
if
(
mc
.
Success
)
if
(
mc
.
Success
)
{
{
...
@@ -199,7 +199,7 @@ static string FindCode(string texts,string name)
...
@@ -199,7 +199,7 @@ static string FindCode(string texts,string name)
#
endregion
#
endregion
#
region
find
return
#
region
find
return
//查找返回类型
//查找返回类型
static
string
FindReturn
(
string
texts
,
string
name
)
static
string
FindReturn
(
string
texts
,
string
name
)
{
{
string
restr
=
""
;
string
restr
=
""
;
...
@@ -231,7 +231,7 @@ static string FindReturn(string texts,string name)
...
@@ -231,7 +231,7 @@ static string FindReturn(string texts,string name)
#
endregion
#
endregion
#
region
find
args
#
region
find
args
//查找参数
//查找参数
static
string
getUserType
(
string
str
)
static
string
getUserType
(
string
str
)
{
{
if
(
str
.
IndexOf
(
"card"
)>=
0
)
if
(
str
.
IndexOf
(
"card"
)>=
0
)
...
@@ -283,8 +283,8 @@ static string FindArgs(string texts,string name)
...
@@ -283,8 +283,8 @@ static string FindArgs(string texts,string name)
}
}
//function
//function
AddArgs
(
texts
AddArgs
(
texts
,
@"interpreter::get_function_handle\(L,\s+(\d+)\)"
,
@"interpreter::get_function_handle\(L,\s+(\d+)\)"
,
"function"
,
dic
);
,
"function"
,
dic
);
//int
//int
AddArgs
(
texts
,
@"lua_tointeger\(L,\s+(\d+)\)"
,
"integer"
,
dic
);
AddArgs
(
texts
,
@"lua_tointeger\(L,\s+(\d+)\)"
,
"integer"
,
dic
);
//string
//string
...
@@ -305,7 +305,7 @@ static string FindArgs(string texts,string name)
...
@@ -305,7 +305,7 @@ static string FindArgs(string texts,string name)
#
endregion
#
endregion
#
region
find
old
#
region
find
old
//查找旧函数的描述
//查找旧函数的描述
static
string
FindOldDesc
(
string
name
)
static
string
FindOldDesc
(
string
name
)
{
{
if
(
funclist
.
ContainsKey
(
name
))
if
(
funclist
.
ContainsKey
(
name
))
...
@@ -315,7 +315,7 @@ static string FindOldDesc(string name)
...
@@ -315,7 +315,7 @@ static string FindOldDesc(string name)
#
endregion
#
endregion
#
region
Save
Functions
#
region
Save
Functions
//保存函数
//保存函数
public
static
void
GetFunctions
(
string
name
,
string
texts
,
string
file
)
public
static
void
GetFunctions
(
string
name
,
string
texts
,
string
file
)
{
{
if
(!
File
.
Exists
(
file
)){
if
(!
File
.
Exists
(
file
)){
...
@@ -332,12 +332,12 @@ public static void GetFunctions(string name,string texts,string file)
...
@@ -332,12 +332,12 @@ public static void GetFunctions(string name,string texts,string file)
Log
(
"log: find functions "
+
name
+
":"
+
fun
.
Count
.
ToString
());
Log
(
"log: find functions "
+
name
+
":"
+
fun
.
Count
.
ToString
());
using
(
FileStream
fs
=
new
FileStream
(
file
+
".txt"
,
using
(
FileStream
fs
=
new
FileStream
(
file
+
".txt"
,
FileMode
.
Create
,
FileMode
.
Create
,
FileAccess
.
Write
))
FileAccess
.
Write
))
{
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
sw
.
WriteLine
(
"========== "
+
name
+
" =========="
);
sw
.
WriteLine
(
"========== "
+
name
+
" =========="
);
File
.
AppendAllText
(
funclisttxt
,
"========== "
+
name
+
" =========="
+
Environment
.
NewLine
);
File
.
AppendAllText
(
funclisttxt
,
"========== "
+
name
+
" =========="
+
Environment
.
NewLine
);
foreach
(
string
k
in
fun
.
Keys
)
foreach
(
string
k
in
fun
.
Keys
)
{
{
string
v
=
fun
[
k
];
string
v
=
fun
[
k
];
...
...
DataEditorX/Core/Mse/MSECons.cs
View file @
e72f147e
...
@@ -4,71 +4,71 @@
...
@@ -4,71 +4,71 @@
namespace
DataEditorX.Core.Mse
namespace
DataEditorX.Core.Mse
{
{
public
class
MseAttribute
public
class
MseAttribute
{
{
/// <summary>无</summary>
/// <summary>无</summary>
public
const
string
NONE
=
"none"
;
public
const
string
NONE
=
"none"
;
/// <summary>暗</summary>
/// <summary>暗</summary>
public
const
string
DARK
=
"dark"
;
public
const
string
DARK
=
"dark"
;
/// <summary>神</summary>
/// <summary>神</summary>
public
const
string
DIVINE
=
"divine"
;
public
const
string
DIVINE
=
"divine"
;
/// <summary>地</summary>
/// <summary>地</summary>
public
const
string
EARTH
=
"earth"
;
public
const
string
EARTH
=
"earth"
;
/// <summary>火</summary>
/// <summary>火</summary>
public
const
string
FIRE
=
"fire"
;
public
const
string
FIRE
=
"fire"
;
/// <summary>光</summary>
/// <summary>光</summary>
public
const
string
LIGHT
=
"light"
;
public
const
string
LIGHT
=
"light"
;
/// <summary>水</summary>
/// <summary>水</summary>
public
const
string
WATER
=
"water"
;
public
const
string
WATER
=
"water"
;
/// <summary>风</summary>
/// <summary>风</summary>
public
const
string
WIND
=
"wind"
;
public
const
string
WIND
=
"wind"
;
/// <summary>魔法</summary>
/// <summary>魔法</summary>
public
const
string
SPELL
=
"spell"
;
public
const
string
SPELL
=
"spell"
;
/// <summary>陷阱</summary>
/// <summary>陷阱</summary>
public
const
string
TRAP
=
"trap"
;
public
const
string
TRAP
=
"trap"
;
}
}
public
class
MseSpellTrap
public
class
MseSpellTrap
{
{
/// <summary>装备</summary>
/// <summary>装备</summary>
public
const
string
EQUIP
=
"+"
;
public
const
string
EQUIP
=
"+"
;
/// <summary>速攻</summary>
/// <summary>速攻</summary>
public
const
string
QUICKPLAY
=
"$"
;
public
const
string
QUICKPLAY
=
"$"
;
/// <summary>场地</summary>
/// <summary>场地</summary>
public
const
string
FIELD
=
"&"
;
public
const
string
FIELD
=
"&"
;
/// <summary>永续</summary>
/// <summary>永续</summary>
public
const
string
CONTINUOUS
=
"%"
;
public
const
string
CONTINUOUS
=
"%"
;
/// <summary>仪式</summary>
/// <summary>仪式</summary>
public
const
string
RITUAL
=
"#"
;
public
const
string
RITUAL
=
"#"
;
/// <summary>反击</summary>
/// <summary>反击</summary>
public
const
string
COUNTER
=
"!"
;
public
const
string
COUNTER
=
"!"
;
/// <summary>通常</summary>
/// <summary>通常</summary>
public
const
string
NORMAL
=
"^"
;
public
const
string
NORMAL
=
"^"
;
}
}
public
class
MseCardType
public
class
MseCardType
{
{
/// <summary>通常</summary>
/// <summary>通常</summary>
public
const
string
CARD_NORMAL
=
"normal monster"
;
public
const
string
CARD_NORMAL
=
"normal monster"
;
/// <summary>效果</summary>
/// <summary>效果</summary>
public
const
string
CARD_EFFECT
=
"effect monster"
;
public
const
string
CARD_EFFECT
=
"effect monster"
;
/// <summary>超量</summary>
/// <summary>超量</summary>
public
const
string
CARD_XYZ
=
"xyz monster"
;
public
const
string
CARD_XYZ
=
"xyz monster"
;
/// <summary>仪式</summary>
/// <summary>仪式</summary>
public
const
string
CARD_RITUAL
=
"ritual monster"
;
public
const
string
CARD_RITUAL
=
"ritual monster"
;
/// <summary>融合</summary>
/// <summary>融合</summary>
public
const
string
CARD_FUSION
=
"fusion monster"
;
public
const
string
CARD_FUSION
=
"fusion monster"
;
/// <summary>衍生物</summary>
/// <summary>衍生物</summary>
public
const
string
CARD_TOKEN
=
"token monster"
;
public
const
string
CARD_TOKEN
=
"token monster"
;
/// <summary>衍生物无种族</summary>
/// <summary>衍生物无种族</summary>
public
const
string
CARD_TOKEN2
=
"token card"
;
public
const
string
CARD_TOKEN2
=
"token card"
;
/// <summary>同调</summary>
/// <summary>同调</summary>
public
const
string
CARD_SYNCHRO
=
"synchro monster"
;
public
const
string
CARD_SYNCHRO
=
"synchro monster"
;
/// <summary>魔法</summary>
/// <summary>魔法</summary>
public
const
string
CARD_SPELL
=
"spell card"
;
public
const
string
CARD_SPELL
=
"spell card"
;
/// <summary>陷阱</summary>
/// <summary>陷阱</summary>
public
const
string
CARD_TRAP
=
"trap card"
;
public
const
string
CARD_TRAP
=
"trap card"
;
/// <summary>
/// <summary>
/// link
/// link
/// </summary>
/// </summary>
public
const
string
CARD_LINK
=
"link monster"
;
public
const
string
CARD_LINK
=
"link monster"
;
}
}
}
}
DataEditorX/Core/Mse/MseMaker.cs
View file @
e72f147e
...
@@ -233,7 +233,7 @@ public static string GetDesc(string cdesc, string regx)
...
@@ -233,7 +233,7 @@ public static string GetDesc(string cdesc, string regx)
Match
mc
=
regex
.
Match
(
desc
);
Match
mc
=
regex
.
Match
(
desc
);
if
(
mc
.
Success
)
if
(
mc
.
Success
)
return
((
mc
.
Groups
.
Count
>
1
)
?
return
((
mc
.
Groups
.
Count
>
1
)
?
mc
.
Groups
[
1
].
Value
:
mc
.
Groups
[
0
].
Value
);
mc
.
Groups
[
1
].
Value
:
mc
.
Groups
[
0
].
Value
);
return
""
;
return
""
;
}
}
...
@@ -318,10 +318,10 @@ public string[] GetTypes(Card c)
...
@@ -318,10 +318,10 @@ public string[] GetTypes(Card c)
types
[
0
]
=
MseCardType
.
CARD_NORMAL
;
types
[
0
]
=
MseCardType
.
CARD_NORMAL
;
//同调
//同调
if
(
types
[
0
]
==
MseCardType
.
CARD_SYNCHRO
if
(
types
[
0
]
==
MseCardType
.
CARD_SYNCHRO
||
types
[
0
]
==
MseCardType
.
CARD_TOKEN
)
||
types
[
0
]
==
MseCardType
.
CARD_TOKEN
)
{
{
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
)
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
)
&&
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
&&
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
//调整效果
{
//调整效果
types
[
2
]
=
GetType
(
CardType
.
TYPE_TUNER
);
types
[
2
]
=
GetType
(
CardType
.
TYPE_TUNER
);
types
[
3
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
types
[
3
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
...
@@ -389,7 +389,7 @@ public string[] GetTypes(Card c)
...
@@ -389,7 +389,7 @@ public string[] GetTypes(Card c)
Dictionary
<
Card
,
string
>
list
=
new
Dictionary
<
Card
,
string
>();
Dictionary
<
Card
,
string
>
list
=
new
Dictionary
<
Card
,
string
>();
string
pic
=
cfg
.
imagepath
;
string
pic
=
cfg
.
imagepath
;
using
(
FileStream
fs
=
new
FileStream
(
file
,
using
(
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
,
FileAccess
.
Write
))
FileMode
.
Create
,
FileAccess
.
Write
))
{
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
sw
.
WriteLine
(
cfg
.
head
);
sw
.
WriteLine
(
cfg
.
head
);
...
@@ -700,14 +700,14 @@ public Card ReadCard(string content, out string img)
...
@@ -700,14 +700,14 @@ public Card ReadCard(string content, out string img)
c
.
race
=
GetRaceInt
(
GetValue
(
content
,
TAG_TYPE1
));
c
.
race
=
GetRaceInt
(
GetValue
(
content
,
TAG_TYPE1
));
//卡片类型
//卡片类型
c
.
type
=
GetCardType
(
GetValue
(
content
,
TAG_CARDTYPE
),
tmp
,
c
.
type
=
GetCardType
(
GetValue
(
content
,
TAG_CARDTYPE
),
tmp
,
GetValue
(
content
,
TAG_TYPE2
),
GetValue
(
content
,
TAG_TYPE2
),
GetValue
(
content
,
TAG_TYPE3
),
GetValue
(
content
,
TAG_TYPE3
),
GetValue
(
content
,
TAG_TYPE4
),
GetValue
(
content
,
TAG_TYPE4
),
GetValue
(
content
,
TAG_TYPE5
));
GetValue
(
content
,
TAG_TYPE5
));
long
t
=
GetSpellTrapType
(
GetValue
(
content
,
TAG_LEVEL
));
long
t
=
GetSpellTrapType
(
GetValue
(
content
,
TAG_LEVEL
));
//不是魔法,陷阱卡片的星数
//不是魔法,陷阱卡片的星数
if
(!(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
if
(!(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
&&
t
==
0
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
&&
t
==
0
)
c
.
level
=
GetValue
(
content
,
TAG_LEVEL
).
Length
;
c
.
level
=
GetValue
(
content
,
TAG_LEVEL
).
Length
;
//属性
//属性
...
@@ -732,9 +732,9 @@ public Card ReadCard(string content, out string img)
...
@@ -732,9 +732,9 @@ public Card ReadCard(string content, out string img)
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
{
//根据预设的模版,替换内容
{
//根据预设的模版,替换内容
tmp
=
cfg
.
temp_text
.
Replace
(
TAG_REP_TEXT
,
tmp
=
cfg
.
temp_text
.
Replace
(
TAG_REP_TEXT
,
GetMultiValue
(
content
,
TAG_TEXT
));
GetMultiValue
(
content
,
TAG_TEXT
));
tmp
=
tmp
.
Replace
(
TAG_REP_PTEXT
,
tmp
=
tmp
.
Replace
(
TAG_REP_PTEXT
,
GetMultiValue
(
content
,
TAG_PEND_TEXT
));
GetMultiValue
(
content
,
TAG_PEND_TEXT
));
c
.
desc
=
tmp
;
c
.
desc
=
tmp
;
}
}
else
else
...
@@ -755,7 +755,7 @@ public Card[] ReadCards(string set, bool repalceOld)
...
@@ -755,7 +755,7 @@ public Card[] ReadCards(string set, bool repalceOld)
string
allcontent
=
File
.
ReadAllText
(
set
,
Encoding
.
UTF8
);
string
allcontent
=
File
.
ReadAllText
(
set
,
Encoding
.
UTF8
);
Regex
regx
=
new
Regex
(
@"^card:[\S\s]+?gamecode:[\S\s]+?$"
,
Regex
regx
=
new
Regex
(
@"^card:[\S\s]+?gamecode:[\S\s]+?$"
,
RegexOptions
.
Multiline
);
RegexOptions
.
Multiline
);
MatchCollection
matchs
=
regx
.
Matches
(
allcontent
);
MatchCollection
matchs
=
regx
.
Matches
(
allcontent
);
int
i
=
0
;
int
i
=
0
;
...
...
DataEditorX/Core/MyTask.cs
View file @
e72f147e
namespace
DataEditorX.Core
namespace
DataEditorX.Core
{
{
/// <summary>
/// <summary>
/// 任务
/// 任务
/// </summary>
/// </summary>
public
enum
MyTask
public
enum
MyTask
{
{
///<summary>空</summary>
///<summary>空</summary>
NONE
,
NONE
,
///<summary>检查更新</summary>
///<summary>检查更新</summary>
CheckUpdate
,
CheckUpdate
,
///<summary>导出数据</summary>
///<summary>导出数据</summary>
ExportData
,
ExportData
,
///<summary>保存为MSE存档</summary>
///<summary>保存为MSE存档</summary>
SaveAsMSE
,
SaveAsMSE
,
///<summary>裁剪图片</summary>
///<summary>裁剪图片</summary>
CutImages
,
CutImages
,
///<summary>转换图片</summary>
///<summary>转换图片</summary>
ConvertImages
,
ConvertImages
,
///<summary>读取MSE存档</summary>
///<summary>读取MSE存档</summary>
ReadMSE
,
ReadMSE
,
}
}
}
}
DataEditorX/Core/TaskHelper.cs
View file @
e72f147e
...
@@ -234,7 +234,7 @@ public void ConvertImages(string imgpath, string gamepath, bool isreplace)
...
@@ -234,7 +234,7 @@ public void ConvertImages(string imgpath, string gamepath, bool isreplace)
{
{
MyBitmap
.
SaveAsJPEG
(
MyBitmap
.
Zoom
(
bmp
,
imgSet
.
W
,
imgSet
.
H
),
MyBitmap
.
SaveAsJPEG
(
MyBitmap
.
Zoom
(
bmp
,
imgSet
.
W
,
imgSet
.
H
),
jpg_b
,
imgSet
.
quilty
);
jpg_b
,
imgSet
.
quilty
);
}
}
//小图,如果替换,或者不存在
//小图,如果替换,或者不存在
//if (isreplace || !File.Exists(jpg_s))
//if (isreplace || !File.Exists(jpg_s))
...
...
DataEditorX/Core/YGOUtil.cs
View file @
e72f147e
...
@@ -11,228 +11,228 @@
...
@@ -11,228 +11,228 @@
namespace
DataEditorX.Core
namespace
DataEditorX.Core
{
{
static
class
YGOUtil
static
class
YGOUtil
{
{
static
DataConfig
datacfg
;
static
DataConfig
datacfg
;
static
YGOUtil
()
static
YGOUtil
()
{
{
datacfg
=
new
DataConfig
();
datacfg
=
new
DataConfig
();
}
}
public
static
void
SetConfig
(
DataConfig
dcfg
)
public
static
void
SetConfig
(
DataConfig
dcfg
)
{
{
datacfg
=
dcfg
;
datacfg
=
dcfg
;
}
}
#
region
判断文件类型
#
region
判断文件类型
public
static
bool
isScript
(
string
file
)
public
static
bool
isScript
(
string
file
)
{
{
if
(
file
!=
null
&&
file
.
EndsWith
(
".lua"
,
StringComparison
.
OrdinalIgnoreCase
))
if
(
file
!=
null
&&
file
.
EndsWith
(
".lua"
,
StringComparison
.
OrdinalIgnoreCase
))
return
true
;
return
true
;
return
false
;
return
false
;
}
}
public
static
bool
isDataBase
(
string
file
)
public
static
bool
isDataBase
(
string
file
)
{
{
if
(
file
!=
null
&&
file
.
EndsWith
(
".cdb"
,
StringComparison
.
OrdinalIgnoreCase
))
if
(
file
!=
null
&&
file
.
EndsWith
(
".cdb"
,
StringComparison
.
OrdinalIgnoreCase
))
return
true
;
return
true
;
return
false
;
return
false
;
}
}
#
endregion
#
endregion
#
region
获取属性,种族
#
region
获取属性,种族
public
static
string
GetAttributeString
(
int
attr
)
public
static
string
GetAttributeString
(
int
attr
)
{
{
return
DataManager
.
GetValue
(
datacfg
.
dicCardAttributes
,
attr
);
return
DataManager
.
GetValue
(
datacfg
.
dicCardAttributes
,
attr
);
}
}
public
static
string
GetRace
(
long
race
)
public
static
string
GetRace
(
long
race
)
{
{
return
DataManager
.
GetValue
(
datacfg
.
dicCardRaces
,
race
);
return
DataManager
.
GetValue
(
datacfg
.
dicCardRaces
,
race
);
}
}
#
endregion
#
endregion
#
region
获取卡片类型
#
region
获取卡片类型
public
static
string
GetCardType
(
Card
c
)
public
static
string
GetCardType
(
Card
c
)
{
{
string
str
=
"???"
;
string
str
=
"???"
;
if
(
c
.
IsType
(
CardType
.
TYPE_MONSTER
))
if
(
c
.
IsType
(
CardType
.
TYPE_MONSTER
))
{
//卡片类型和第1效果
{
//卡片类型和第1效果
if
(
c
.
IsType
(
CardType
.
TYPE_XYZ
))
if
(
c
.
IsType
(
CardType
.
TYPE_XYZ
))
{
{
str
=
GetType
(
CardType
.
TYPE_XYZ
);
str
=
GetType
(
CardType
.
TYPE_XYZ
);
}
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_TOKEN
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_TOKEN
))
{
{
str
=
GetType
(
CardType
.
TYPE_TOKEN
);
str
=
GetType
(
CardType
.
TYPE_TOKEN
);
}
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
{
{
str
=
GetType
(
CardType
.
TYPE_RITUAL
);
str
=
GetType
(
CardType
.
TYPE_RITUAL
);
}
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_FUSION
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_FUSION
))
{
{
str
=
GetType
(
CardType
.
TYPE_FUSION
);
str
=
GetType
(
CardType
.
TYPE_FUSION
);
}
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_SYNCHRO
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_SYNCHRO
))
{
{
str
=
GetType
(
CardType
.
TYPE_SYNCHRO
);
str
=
GetType
(
CardType
.
TYPE_SYNCHRO
);
}
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
{
str
=
GetType
(
CardType
.
TYPE_EFFECT
);
str
=
GetType
(
CardType
.
TYPE_EFFECT
);
}
}
else
else
str
=
GetType
(
CardType
.
TYPE_NORMAL
);
str
=
GetType
(
CardType
.
TYPE_NORMAL
);
str
+=
GetType
(
CardType
.
TYPE_MONSTER
);
str
+=
GetType
(
CardType
.
TYPE_MONSTER
);
}
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_SPELL
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_SPELL
))
{
{
if
(
c
.
IsType
(
CardType
.
TYPE_EQUIP
))
if
(
c
.
IsType
(
CardType
.
TYPE_EQUIP
))
str
=
GetType
(
CardType
.
TYPE_EQUIP
);
str
=
GetType
(
CardType
.
TYPE_EQUIP
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_QUICKPLAY
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_QUICKPLAY
))
str
=
GetType
(
CardType
.
TYPE_QUICKPLAY
);
str
=
GetType
(
CardType
.
TYPE_QUICKPLAY
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_FIELD
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_FIELD
))
str
=
GetType
(
CardType
.
TYPE_FIELD
);
str
=
GetType
(
CardType
.
TYPE_FIELD
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_CONTINUOUS
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_CONTINUOUS
))
str
=
GetType
(
CardType
.
TYPE_CONTINUOUS
);
str
=
GetType
(
CardType
.
TYPE_CONTINUOUS
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
str
=
GetType
(
CardType
.
TYPE_RITUAL
);
str
=
GetType
(
CardType
.
TYPE_RITUAL
);
else
else
str
=
GetType
(
CardType
.
TYPE_NORMAL
);
str
=
GetType
(
CardType
.
TYPE_NORMAL
);
str
+=
GetType
(
CardType
.
TYPE_SPELL
);
str
+=
GetType
(
CardType
.
TYPE_SPELL
);
}
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_TRAP
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_TRAP
))
{
{
if
(
c
.
IsType
(
CardType
.
TYPE_CONTINUOUS
))
if
(
c
.
IsType
(
CardType
.
TYPE_CONTINUOUS
))
str
=
GetType
(
CardType
.
TYPE_CONTINUOUS
);
str
=
GetType
(
CardType
.
TYPE_CONTINUOUS
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_COUNTER
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_COUNTER
))
str
=
GetType
(
CardType
.
TYPE_COUNTER
);
str
=
GetType
(
CardType
.
TYPE_COUNTER
);
else
else
str
=
GetType
(
CardType
.
TYPE_NORMAL
);
str
=
GetType
(
CardType
.
TYPE_NORMAL
);
str
+=
GetType
(
CardType
.
TYPE_TRAP
);
str
+=
GetType
(
CardType
.
TYPE_TRAP
);
}
}
return
str
.
Replace
(
" "
,
""
);
return
str
.
Replace
(
" "
,
""
);
}
}
static
string
GetType
(
CardType
type
)
static
string
GetType
(
CardType
type
)
{
{
return
DataManager
.
GetValue
(
datacfg
.
dicCardTypes
,
(
long
)
type
);
return
DataManager
.
GetValue
(
datacfg
.
dicCardTypes
,
(
long
)
type
);
}
}
public
static
string
GetTypeString
(
long
type
)
public
static
string
GetTypeString
(
long
type
)
{
{
string
str
=
""
;
string
str
=
""
;
foreach
(
long
k
in
datacfg
.
dicCardTypes
.
Keys
)
foreach
(
long
k
in
datacfg
.
dicCardTypes
.
Keys
)
{
{
if
((
type
&
k
)
==
k
)
if
((
type
&
k
)
==
k
)
str
+=
GetType
((
CardType
)
k
)
+
"|"
;
str
+=
GetType
((
CardType
)
k
)
+
"|"
;
}
}
if
(
str
.
Length
>
0
)
if
(
str
.
Length
>
0
)
str
=
str
.
Substring
(
0
,
str
.
Length
-
1
);
str
=
str
.
Substring
(
0
,
str
.
Length
-
1
);
else
else
str
=
"???"
;
str
=
"???"
;
return
str
;
return
str
;
}
}
#
endregion
#
endregion
#
region
系列名
#
region
系列名
public
static
string
GetSetNameString
(
long
setcode
)
public
static
string
GetSetNameString
(
long
setcode
)
{
{
long
sc1
=
setcode
&
0xffff
;
long
sc1
=
setcode
&
0xffff
;
long
sc2
=
(
setcode
>>
0x10
)
&
0xffff
;
long
sc2
=
(
setcode
>>
0x10
)
&
0xffff
;
long
sc3
=
(
setcode
>>
0x20
)
&
0xffff
;
long
sc3
=
(
setcode
>>
0x20
)
&
0xffff
;
long
sc4
=
(
setcode
>>
0x30
)
&
0xffff
;
long
sc4
=
(
setcode
>>
0x30
)
&
0xffff
;
string
setname
=
DataManager
.
GetValue
(
datacfg
.
dicSetnames
,
sc1
)
string
setname
=
DataManager
.
GetValue
(
datacfg
.
dicSetnames
,
sc1
)
+
" "
+
DataManager
.
GetValue
(
datacfg
.
dicSetnames
,
sc2
)
+
" "
+
DataManager
.
GetValue
(
datacfg
.
dicSetnames
,
sc2
)
+
" "
+
DataManager
.
GetValue
(
datacfg
.
dicSetnames
,
sc3
)
+
" "
+
DataManager
.
GetValue
(
datacfg
.
dicSetnames
,
sc3
)
+
" "
+
DataManager
.
GetValue
(
datacfg
.
dicSetnames
,
sc4
);
+
" "
+
DataManager
.
GetValue
(
datacfg
.
dicSetnames
,
sc4
);
return
setname
;
return
setname
;
}
}
#
endregion
#
endregion
#
region
根据文件读取数据库
#
region
根据文件读取数据库
/// <summary>
/// <summary>
/// 读取ydk文件为密码数组
/// 读取ydk文件为密码数组
/// </summary>
/// </summary>
/// <param name="file">ydk文件</param>
/// <param name="file">ydk文件</param>
/// <returns>密码数组</returns>
/// <returns>密码数组</returns>
public
static
string
[]
ReadYDK
(
string
ydkfile
)
public
static
string
[]
ReadYDK
(
string
ydkfile
)
{
{
string
str
;
string
str
;
List
<
string
>
IDs
=
new
List
<
string
>();
List
<
string
>
IDs
=
new
List
<
string
>();
if
(
File
.
Exists
(
ydkfile
))
if
(
File
.
Exists
(
ydkfile
))
{
{
using
(
FileStream
f
=
new
FileStream
(
ydkfile
,
FileMode
.
Open
,
FileAccess
.
Read
))
using
(
FileStream
f
=
new
FileStream
(
ydkfile
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
{
StreamReader
sr
=
new
StreamReader
(
f
,
Encoding
.
Default
);
StreamReader
sr
=
new
StreamReader
(
f
,
Encoding
.
Default
);
str
=
sr
.
ReadLine
();
str
=
sr
.
ReadLine
();
while
(
str
!=
null
)
while
(
str
!=
null
)
{
{
if
(!
str
.
StartsWith
(
"!"
)
&&
!
str
.
StartsWith
(
"#"
)
&&
str
.
Length
>
0
)
if
(!
str
.
StartsWith
(
"!"
)
&&
!
str
.
StartsWith
(
"#"
)
&&
str
.
Length
>
0
)
{
{
if
(
IDs
.
IndexOf
(
str
)
<
0
)
if
(
IDs
.
IndexOf
(
str
)
<
0
)
IDs
.
Add
(
str
);
IDs
.
Add
(
str
);
}
}
str
=
sr
.
ReadLine
();
str
=
sr
.
ReadLine
();
}
}
sr
.
Close
();
sr
.
Close
();
f
.
Close
();
f
.
Close
();
}
}
}
}
if
(
IDs
.
Count
==
0
)
if
(
IDs
.
Count
==
0
)
return
null
;
return
null
;
return
IDs
.
ToArray
();
return
IDs
.
ToArray
();
}
}
#
endregion
#
endregion
#
region
图像
#
region
图像
public
static
string
[]
ReadImage
(
string
path
)
public
static
string
[]
ReadImage
(
string
path
)
{
{
List
<
string
>
list
=
new
List
<
string
>();
List
<
string
>
list
=
new
List
<
string
>();
string
[]
files
=
Directory
.
GetFiles
(
path
,
"*.*"
);
string
[]
files
=
Directory
.
GetFiles
(
path
,
"*.*"
);
int
n
=
files
.
Length
;
int
n
=
files
.
Length
;
for
(
int
i
=
0
;
i
<
n
;
i
++)
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
{
string
ex
=
Path
.
GetExtension
(
files
[
i
]).
ToLower
();
string
ex
=
Path
.
GetExtension
(
files
[
i
]).
ToLower
();
if
(
ex
==
".jpg"
||
ex
==
".png"
||
ex
==
".bmp"
)
if
(
ex
==
".jpg"
||
ex
==
".png"
||
ex
==
".bmp"
)
list
.
Add
(
Path
.
GetFileNameWithoutExtension
(
files
[
i
]));
list
.
Add
(
Path
.
GetFileNameWithoutExtension
(
files
[
i
]));
}
}
return
list
.
ToArray
();
return
list
.
ToArray
();
}
}
#
endregion
#
endregion
#
region
删除资源
#
region
删除资源
//删除资源
//删除资源
public
static
void
CardDelete
(
long
id
,
YgoPath
ygopath
)
public
static
void
CardDelete
(
long
id
,
YgoPath
ygopath
)
{
{
string
[]
files
=
ygopath
.
GetCardfiles
(
id
);
string
[]
files
=
ygopath
.
GetCardfiles
(
id
);
for
(
int
i
=
0
;
i
<
files
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
files
.
Length
;
i
++)
{
{
if
(
FileSystem
.
FileExists
(
files
[
i
]))
if
(
FileSystem
.
FileExists
(
files
[
i
]))
FileSystem
.
DeleteFile
(
files
[
i
],
UIOption
.
OnlyErrorDialogs
,
RecycleOption
.
SendToRecycleBin
);
FileSystem
.
DeleteFile
(
files
[
i
],
UIOption
.
OnlyErrorDialogs
,
RecycleOption
.
SendToRecycleBin
);
}
}
}
}
#
endregion
#
endregion
#
region
资源改名
#
region
资源改名
//资源改名
//资源改名
public
static
void
CardRename
(
long
newid
,
long
oldid
,
YgoPath
ygopath
)
public
static
void
CardRename
(
long
newid
,
long
oldid
,
YgoPath
ygopath
)
{
{
string
[]
newfiles
=
ygopath
.
GetCardfiles
(
newid
);
string
[]
newfiles
=
ygopath
.
GetCardfiles
(
newid
);
string
[]
oldfiles
=
ygopath
.
GetCardfiles
(
oldid
);
string
[]
oldfiles
=
ygopath
.
GetCardfiles
(
oldid
);
for
(
int
i
=
0
;
i
<
oldfiles
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
oldfiles
.
Length
;
i
++)
{
{
if
(
File
.
Exists
(
oldfiles
[
i
]))
if
(
File
.
Exists
(
oldfiles
[
i
]))
{
{
try
{
try
{
File
.
Move
(
oldfiles
[
i
],
newfiles
[
i
]);
File
.
Move
(
oldfiles
[
i
],
newfiles
[
i
]);
}
}
catch
{
}
catch
{
}
}
}
}
}
}
}
#
endregion
#
endregion
#
region
复制资源
#
region
复制资源
...
...
DataEditorX/DataEditForm.Designer.cs
View file @
e72f147e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
DataEditorX/DataEditForm.cs
View file @
e72f147e
...
@@ -21,11 +21,11 @@
...
@@ -21,11 +21,11 @@
namespace
DataEditorX
namespace
DataEditorX
{
{
public
partial
class
DataEditForm
:
DockContent
,
IDataForm
public
partial
class
DataEditForm
:
DockContent
,
IDataForm
{
{
public
string
addrequire
;
public
string
addrequire
;
#
region
成员变量
/
构造
#
region
成员变量
/
构造
TaskHelper
tasker
=
null
;
TaskHelper
tasker
=
null
;
string
taskname
;
string
taskname
;
//目录
//目录
YgoPath
ygopath
;
YgoPath
ygopath
;
...
@@ -63,7 +63,7 @@ public partial class DataEditForm : DockContent, IDataForm
...
@@ -63,7 +63,7 @@ public partial class DataEditForm : DockContent, IDataForm
string
datapath
,
confcover
;
string
datapath
,
confcover
;
public
DataEditForm
(
string
datapath
,
string
cdbfile
)
public
DataEditForm
(
string
datapath
,
string
cdbfile
)
{
{
Initialize
(
datapath
);
Initialize
(
datapath
);
nowCdbFile
=
cdbfile
;
nowCdbFile
=
cdbfile
;
...
@@ -125,11 +125,11 @@ public bool Save()
...
@@ -125,11 +125,11 @@ public bool Save()
{
{
return
true
;
return
true
;
}
}
#
endregion
#
endregion
#
region
窗体
#
region
窗体
//窗体第一次加载
//窗体第一次加载
void
DataEditFormLoad
(
object
sender
,
EventArgs
e
)
void
DataEditFormLoad
(
object
sender
,
EventArgs
e
)
{
{
//InitListRows();//调整卡片列表的函数
//InitListRows();//调整卡片列表的函数
HideMenu
();
//是否需要隐藏菜单
HideMenu
();
//是否需要隐藏菜单
...
@@ -146,10 +146,10 @@ void DataEditFormLoad(object sender, EventArgs e)
...
@@ -146,10 +146,10 @@ void DataEditFormLoad(object sender, EventArgs e)
menuitem_openfileinthis
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_OPEN_IN_THIS
);
menuitem_openfileinthis
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_OPEN_IN_THIS
);
//自动检查更新
//自动检查更新
menuitem_autocheckupdate
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
);
menuitem_autocheckupdate
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
);
//add require automatically
//add require automatically
addrequire
=
MyConfig
.
readString
(
MyConfig
.
TAG_ADD_REQUIRE
);
addrequire
=
MyConfig
.
readString
(
MyConfig
.
TAG_ADD_REQUIRE
);
menuitem_addrequire
.
Checked
=
(
addrequire
.
Length
>
0
);
menuitem_addrequire
.
Checked
=
(
addrequire
.
Length
>
0
);
if
(
nowCdbFile
!=
null
&&
File
.
Exists
(
nowCdbFile
))
if
(
nowCdbFile
!=
null
&&
File
.
Exists
(
nowCdbFile
))
Open
(
nowCdbFile
);
Open
(
nowCdbFile
);
//获取MSE配菜单
//获取MSE配菜单
AddMenuItemFormMSE
();
AddMenuItemFormMSE
();
...
@@ -338,7 +338,7 @@ private void _cbox_CheckedChanged(object sender, EventArgs e)
...
@@ -338,7 +338,7 @@ private void _cbox_CheckedChanged(object sender, EventArgs e)
void
InitComboBox
(
ComboBox
cb
,
Dictionary
<
long
,
string
>
tempdic
)
void
InitComboBox
(
ComboBox
cb
,
Dictionary
<
long
,
string
>
tempdic
)
{
{
InitComboBox
(
cb
,
DataManager
.
GetKeys
(
tempdic
),
InitComboBox
(
cb
,
DataManager
.
GetKeys
(
tempdic
),
DataManager
.
GetValues
(
tempdic
));
DataManager
.
GetValues
(
tempdic
));
}
}
//初始化ComboBox
//初始化ComboBox
void
InitComboBox
(
ComboBox
cb
,
List
<
long
>
keys
,
string
[]
values
)
void
InitComboBox
(
ComboBox
cb
,
List
<
long
>
keys
,
string
[]
values
)
...
@@ -771,7 +771,7 @@ void Search(Card c, bool isfresh)
...
@@ -771,7 +771,7 @@ void Search(Card c, bool isfresh)
if
(
tmpCodes
.
Count
>
0
)
if
(
tmpCodes
.
Count
>
0
)
{
{
Card
[]
mcards
=
DataBase
.
Read
(
nowCdbFile
,
Card
[]
mcards
=
DataBase
.
Read
(
nowCdbFile
,
true
,
tmpCodes
.
ToArray
());
true
,
tmpCodes
.
ToArray
());
SetCards
(
getCompCards
(),
true
);
SetCards
(
getCompCards
(),
true
);
}
}
else
else
...
@@ -1016,7 +1016,7 @@ void Menuitem_readydkClick(object sender, EventArgs e)
...
@@ -1016,7 +1016,7 @@ void Menuitem_readydkClick(object sender, EventArgs e)
string
[]
ids
=
YGOUtil
.
ReadYDK
(
dlg
.
FileName
);
string
[]
ids
=
YGOUtil
.
ReadYDK
(
dlg
.
FileName
);
tmpCodes
.
AddRange
(
ids
);
tmpCodes
.
AddRange
(
ids
);
SetCards
(
DataBase
.
Read
(
nowCdbFile
,
true
,
SetCards
(
DataBase
.
Read
(
nowCdbFile
,
true
,
ids
),
false
);
ids
),
false
);
}
}
}
}
}
}
...
@@ -1034,7 +1034,7 @@ void Menuitem_readimagesClick(object sender, EventArgs e)
...
@@ -1034,7 +1034,7 @@ void Menuitem_readimagesClick(object sender, EventArgs e)
string
[]
ids
=
YGOUtil
.
ReadImage
(
fdlg
.
SelectedPath
);
string
[]
ids
=
YGOUtil
.
ReadImage
(
fdlg
.
SelectedPath
);
tmpCodes
.
AddRange
(
ids
);
tmpCodes
.
AddRange
(
ids
);
SetCards
(
DataBase
.
Read
(
nowCdbFile
,
true
,
SetCards
(
DataBase
.
Read
(
nowCdbFile
,
true
,
ids
),
false
);
ids
),
false
);
}
}
}
}
}
}
...
@@ -1074,10 +1074,10 @@ void BgWorker1DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
...
@@ -1074,10 +1074,10 @@ void BgWorker1DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
void
BgWorker1ProgressChanged
(
object
sender
,
System
.
ComponentModel
.
ProgressChangedEventArgs
e
)
void
BgWorker1ProgressChanged
(
object
sender
,
System
.
ComponentModel
.
ProgressChangedEventArgs
e
)
{
{
title
=
string
.
Format
(
"{0} ({1}-{2})"
,
title
=
string
.
Format
(
"{0} ({1}-{2})"
,
RemoveTag
(
title
),
RemoveTag
(
title
),
taskname
,
taskname
,
// e.ProgressPercentage,
// e.ProgressPercentage,
e
.
UserState
);
e
.
UserState
);
SetTitle
();
SetTitle
();
}
}
//任务完成
//任务完成
...
@@ -1215,7 +1215,7 @@ void Menuitem_cutimagesClick(object sender, EventArgs e)
...
@@ -1215,7 +1215,7 @@ void Menuitem_cutimagesClick(object sender, EventArgs e)
return
;
return
;
bool
isreplace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
bool
isreplace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
tasker
.
SetTask
(
MyTask
.
CutImages
,
cardlist
.
ToArray
(),
tasker
.
SetTask
(
MyTask
.
CutImages
,
cardlist
.
ToArray
(),
ygopath
.
picpath
,
isreplace
.
ToString
());
ygopath
.
picpath
,
isreplace
.
ToString
());
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
CutImage
));
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
CutImage
));
}
}
void
Menuitem_saveasmse_selectClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_saveasmse_selectClick
(
object
sender
,
EventArgs
e
)
...
@@ -1250,7 +1250,7 @@ void SaveAsMSE(bool onlyselect)
...
@@ -1250,7 +1250,7 @@ void SaveAsMSE(bool onlyselect)
isUpdate
=
MyMsg
.
Question
(
LMSG
.
OnlySet
);
isUpdate
=
MyMsg
.
Question
(
LMSG
.
OnlySet
);
#
endif
#
endif
tasker
.
SetTask
(
MyTask
.
SaveAsMSE
,
cards
,
tasker
.
SetTask
(
MyTask
.
SaveAsMSE
,
cards
,
dlg
.
FileName
,
isUpdate
.
ToString
());
dlg
.
FileName
,
isUpdate
.
ToString
());
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
SaveMse
));
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
SaveMse
));
}
}
}
}
...
@@ -1302,7 +1302,7 @@ void ImportImage(string file, string tid)
...
@@ -1302,7 +1302,7 @@ void ImportImage(string file, string tid)
{
{
string
f
;
string
f
;
if
(
pl_image
.
BackgroundImage
!=
null
if
(
pl_image
.
BackgroundImage
!=
null
&&
pl_image
.
BackgroundImage
!=
m_cover
)
&&
pl_image
.
BackgroundImage
!=
m_cover
)
{
//释放图片资源
{
//释放图片资源
pl_image
.
BackgroundImage
.
Dispose
();
pl_image
.
BackgroundImage
.
Dispose
();
pl_image
.
BackgroundImage
=
m_cover
;
pl_image
.
BackgroundImage
=
m_cover
;
...
@@ -1359,7 +1359,7 @@ void Menuitem_convertimageClick(object sender, EventArgs e)
...
@@ -1359,7 +1359,7 @@ void Menuitem_convertimageClick(object sender, EventArgs e)
{
{
bool
isreplace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
bool
isreplace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
tasker
.
SetTask
(
MyTask
.
ConvertImages
,
null
,
tasker
.
SetTask
(
MyTask
.
ConvertImages
,
null
,
fdlg
.
SelectedPath
,
ygopath
.
gamepath
,
isreplace
.
ToString
());
fdlg
.
SelectedPath
,
ygopath
.
gamepath
,
isreplace
.
ToString
());
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ConvertImage
));
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ConvertImage
));
}
}
}
}
...
@@ -1380,10 +1380,10 @@ void Menuitem_exportdataClick(object sender, EventArgs e)
...
@@ -1380,10 +1380,10 @@ void Menuitem_exportdataClick(object sender, EventArgs e)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
tasker
.
SetTask
(
MyTask
.
ExportData
,
tasker
.
SetTask
(
MyTask
.
ExportData
,
GetCardList
(
false
),
GetCardList
(
false
),
ygopath
.
gamepath
,
ygopath
.
gamepath
,
dlg
.
FileName
,
dlg
.
FileName
,
GetOpenFile
(),
GetOpenFile
(),
addrequire
);
addrequire
);
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ExportData
));
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ExportData
));
}
}
...
@@ -1590,7 +1590,7 @@ private void menuitem_readmse_Click(object sender, EventArgs e)
...
@@ -1590,7 +1590,7 @@ private void menuitem_readmse_Click(object sender, EventArgs e)
bool
isUpdate
=
false
;
//是否替换存在的图片
bool
isUpdate
=
false
;
//是否替换存在的图片
isUpdate
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
isUpdate
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
tasker
.
SetTask
(
MyTask
.
ReadMSE
,
null
,
tasker
.
SetTask
(
MyTask
.
ReadMSE
,
null
,
dlg
.
FileName
,
isUpdate
.
ToString
());
dlg
.
FileName
,
isUpdate
.
ToString
());
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ReadMSE
));
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ReadMSE
));
}
}
}
}
...
@@ -1626,17 +1626,17 @@ private void menuitem_autocheckupdate_Click(object sender, EventArgs e)
...
@@ -1626,17 +1626,17 @@ private void menuitem_autocheckupdate_Click(object sender, EventArgs e)
menuitem_autocheckupdate
.
Checked
=
!
menuitem_autocheckupdate
.
Checked
;
menuitem_autocheckupdate
.
Checked
=
!
menuitem_autocheckupdate
.
Checked
;
MyConfig
.
Save
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
,
menuitem_autocheckupdate
.
Checked
.
ToString
().
ToLower
());
MyConfig
.
Save
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
,
menuitem_autocheckupdate
.
Checked
.
ToString
().
ToLower
());
}
}
//add require automatically
//add require automatically
private
void
menuitem_addrequire_Click
(
object
sender
,
EventArgs
e
)
private
void
menuitem_addrequire_Click
(
object
sender
,
EventArgs
e
)
{
{
addrequire
=
Microsoft
.
VisualBasic
.
Interaction
.
InputBox
(
"Module script?\n\nPress \"Cancel\" to remove module script."
,
""
,
addrequire
);
addrequire
=
Microsoft
.
VisualBasic
.
Interaction
.
InputBox
(
"Module script?\n\nPress \"Cancel\" to remove module script."
,
""
,
addrequire
);
menuitem_addrequire
.
Checked
=
(
addrequire
.
Length
>
0
);
menuitem_addrequire
.
Checked
=
(
addrequire
.
Length
>
0
);
MyConfig
.
Save
(
MyConfig
.
TAG_ADD_REQUIRE
,
addrequire
);
MyConfig
.
Save
(
MyConfig
.
TAG_ADD_REQUIRE
,
addrequire
);
}
}
#
endregion
#
endregion
#
region
语言菜单
#
region
语言菜单
void
GetLanguageItem
()
void
GetLanguageItem
()
{
{
if
(!
Directory
.
Exists
(
datapath
))
if
(!
Directory
.
Exists
(
datapath
))
return
;
return
;
...
@@ -1699,8 +1699,8 @@ void Menuitem_exportMSEimageClick(object sender, EventArgs e)
...
@@ -1699,8 +1699,8 @@ void Menuitem_exportMSEimageClick(object sender, EventArgs e)
string
mseset
=
dlg
.
FileName
;
string
mseset
=
dlg
.
FileName
;
string
exportpath
=
MyPath
.
GetRealPath
(
MyConfig
.
readString
(
MyConfig
.
TAG_MSE_EXPORT
));
string
exportpath
=
MyPath
.
GetRealPath
(
MyConfig
.
readString
(
MyConfig
.
TAG_MSE_EXPORT
));
MseMaker
.
exportSet
(
msepath
,
mseset
,
exportpath
,
delegate
{
MseMaker
.
exportSet
(
msepath
,
mseset
,
exportpath
,
delegate
{
menuitem_exportMSEimage
.
Checked
=
false
;
menuitem_exportMSEimage
.
Checked
=
false
;
});
});
menuitem_exportMSEimage
.
Checked
=
true
;
menuitem_exportMSEimage
.
Checked
=
true
;
}
else
{
}
else
{
menuitem_exportMSEimage
.
Checked
=
false
;
menuitem_exportMSEimage
.
Checked
=
false
;
...
@@ -1778,7 +1778,7 @@ void Tb_linkTextChanged(object sender, EventArgs e)
...
@@ -1778,7 +1778,7 @@ void Tb_linkTextChanged(object sender, EventArgs e)
text2LinkMarks
(
tb_link
.
Text
);
text2LinkMarks
(
tb_link
.
Text
);
}
}
void
Tb_linkKeyPress
(
object
sender
,
KeyPressEventArgs
e
)
void
Tb_linkKeyPress
(
object
sender
,
KeyPressEventArgs
e
)
{
{
if
(
e
.
KeyChar
!=
'0'
&&
e
.
KeyChar
!=
'1'
&&
e
.
KeyChar
!=
1
&&
e
.
KeyChar
!=
22
&&
e
.
KeyChar
!=
3
&&
e
.
KeyChar
!=
8
){
if
(
e
.
KeyChar
!=
'0'
&&
e
.
KeyChar
!=
'1'
&&
e
.
KeyChar
!=
1
&&
e
.
KeyChar
!=
22
&&
e
.
KeyChar
!=
3
&&
e
.
KeyChar
!=
8
){
// MessageBox.Show("key="+(int)e.KeyChar);
// MessageBox.Show("key="+(int)e.KeyChar);
...
...
DataEditorX/Language/LMsg.cs
View file @
e72f147e
...
@@ -9,91 +9,91 @@
...
@@ -9,91 +9,91 @@
namespace
DataEditorX.Language
namespace
DataEditorX.Language
{
{
public
enum
LMSG
:
uint
public
enum
LMSG
:
uint
{
{
titleInfo
=
0
,
titleInfo
=
0
,
titleError
=
0x1
,
titleError
=
0x1
,
titleWarning
=
0x2
,
titleWarning
=
0x2
,
titleQuestion
=
0x3
,
titleQuestion
=
0x3
,
CreateSucceed
=
0x4
,
CreateSucceed
=
0x4
,
CreateFail
=
0x5
,
CreateFail
=
0x5
,
AddSucceed
=
0x6
,
AddSucceed
=
0x6
,
AddFail
=
0x7
,
AddFail
=
0x7
,
CodeCanNotIsZero
=
0x8
,
CodeCanNotIsZero
=
0x8
,
ItIsExists
=
0x9
,
ItIsExists
=
0x9
,
ItIsNotChanged
=
0xa
,
ItIsNotChanged
=
0xa
,
IfDeleteCard
=
0xb
,
IfDeleteCard
=
0xb
,
IfCreateScript
=
0xc
,
IfCreateScript
=
0xc
,
IfOpenDataBase
=
0xd
,
IfOpenDataBase
=
0xd
,
IfReplaceExistingCard
=
0xe
,
IfReplaceExistingCard
=
0xe
,
NowIsNewVersion
=
0xf
,
NowIsNewVersion
=
0xf
,
CheckUpdateFail
=
0x10
,
CheckUpdateFail
=
0x10
,
HaveNewVersion
=
0x11
,
HaveNewVersion
=
0x11
,
FileIsNotExists
=
0x12
,
FileIsNotExists
=
0x12
,
NotSelectDataBase
=
0x13
,
NotSelectDataBase
=
0x13
,
SelectDataBasePath
=
0x14
,
SelectDataBasePath
=
0x14
,
SelectYdkPath
=
0x15
,
SelectYdkPath
=
0x15
,
SelectImagePath
=
0x16
,
SelectImagePath
=
0x16
,
DownloadSucceed
=
0x17
,
DownloadSucceed
=
0x17
,
DownloadFail
=
0x18
,
DownloadFail
=
0x18
,
NotSelectScriptText
=
0x19
,
NotSelectScriptText
=
0x19
,
DeleteSucceed
=
0x1a
,
DeleteSucceed
=
0x1a
,
DeleteFail
=
0x1b
,
DeleteFail
=
0x1b
,
ModifySucceed
=
0x1c
,
ModifySucceed
=
0x1c
,
ModifyFail
=
0x1d
,
ModifyFail
=
0x1d
,
About
=
0x1e
,
About
=
0x1e
,
Version
=
0x1f
,
Version
=
0x1f
,
Author
=
0x20
,
Author
=
0x20
,
CdbType
=
0x21
,
CdbType
=
0x21
,
ydkType
=
0x22
,
ydkType
=
0x22
,
Setcode_error
=
0x23
,
Setcode_error
=
0x23
,
SelectImage
=
0x24
,
SelectImage
=
0x24
,
ImageType
=
0x25
,
ImageType
=
0x25
,
RunError
=
0x26
,
RunError
=
0x26
,
checkUpdate
=
0x27
,
checkUpdate
=
0x27
,
CopyCardsToDB
=
0x28
,
CopyCardsToDB
=
0x28
,
CopyCardsToDBIsOK
=
0x29
,
CopyCardsToDBIsOK
=
0x29
,
selectMseset
=
0x2a
,
selectMseset
=
0x2a
,
MseType
=
0x2b
,
MseType
=
0x2b
,
SaveMse
=
0x2c
,
SaveMse
=
0x2c
,
SaveMseOK
=
0x2d
,
SaveMseOK
=
0x2d
,
CutImage
=
0x2e
,
CutImage
=
0x2e
,
CutImageOK
=
0x2f
,
CutImageOK
=
0x2f
,
NoSelectCard
=
0x30
,
NoSelectCard
=
0x30
,
IfReplaceExistingImage
=
0x31
,
IfReplaceExistingImage
=
0x31
,
ConvertImage
=
0x32
,
ConvertImage
=
0x32
,
ConvertImageOK
=
0x33
,
ConvertImageOK
=
0x33
,
CompDBOK
=
0x34
,
CompDBOK
=
0x34
,
OnlySet
=
0x35
,
OnlySet
=
0x35
,
CancelTask
=
0x36
,
CancelTask
=
0x36
,
PauseTask
=
0x37
,
PauseTask
=
0x37
,
ResumeTask
=
0x38
,
ResumeTask
=
0x38
,
TaskError
=
0x39
,
TaskError
=
0x39
,
IfCancelTask
=
0x3a
,
IfCancelTask
=
0x3a
,
CopyCards
=
0x3b
,
CopyCards
=
0x3b
,
PasteCards
=
0x3c
,
PasteCards
=
0x3c
,
ClearHistory
=
0x3d
,
ClearHistory
=
0x3d
,
ExportData
=
0x3e
,
ExportData
=
0x3e
,
ExportDataOK
=
0x3f
,
ExportDataOK
=
0x3f
,
CheckText
=
0x40
,
CheckText
=
0x40
,
CompareOK
=
0x41
,
CompareOK
=
0x41
,
OpenFile
=
0x42
,
OpenFile
=
0x42
,
ScriptFilter
=
0x43
,
ScriptFilter
=
0x43
,
NewFile
=
0x44
,
NewFile
=
0x44
,
SaveFileOK
=
0x45
,
SaveFileOK
=
0x45
,
IfSaveScript
=
0x46
,
IfSaveScript
=
0x46
,
ReadMSE
=
0x47
,
ReadMSE
=
0x47
,
ReadMSEisOK
=
0x48
,
ReadMSEisOK
=
0x48
,
PlzRestart
=
0x49
,
PlzRestart
=
0x49
,
exportMseImages
=
0x4a
,
exportMseImages
=
0x4a
,
exportMseImagesErr
=
0x4b
,
exportMseImagesErr
=
0x4b
,
COUNT
,
COUNT
,
}
}
}
}
DataEditorX/Language/LanguageHelper.cs
View file @
e72f147e
...
@@ -14,288 +14,288 @@
...
@@ -14,288 +14,288 @@
namespace
DataEditorX.Language
namespace
DataEditorX.Language
{
{
/// <summary>
/// <summary>
/// Description of Language.
/// Description of Language.
/// </summary>
/// </summary>
public
class
LanguageHelper
public
class
LanguageHelper
{
{
static
Dictionary
<
string
,
string
>
gWordsList
=
new
Dictionary
<
string
,
string
>();
static
Dictionary
<
string
,
string
>
gWordsList
=
new
Dictionary
<
string
,
string
>();
static
SortedList
<
LMSG
,
string
>
gMsgList
=
new
SortedList
<
LMSG
,
string
>();
static
SortedList
<
LMSG
,
string
>
gMsgList
=
new
SortedList
<
LMSG
,
string
>();
const
char
SEP_CONTROL
=
'.'
;
const
char
SEP_CONTROL
=
'.'
;
const
char
SEP_LINE
=
'\t'
;
const
char
SEP_LINE
=
'\t'
;
Dictionary
<
string
,
string
>
mWordslist
=
new
Dictionary
<
string
,
string
>();
Dictionary
<
string
,
string
>
mWordslist
=
new
Dictionary
<
string
,
string
>();
#
region
获取消息文字
#
region
获取消息文字
public
static
string
GetMsg
(
LMSG
lMsg
)
public
static
string
GetMsg
(
LMSG
lMsg
)
{
{
if
(
gMsgList
.
IndexOfKey
(
lMsg
)
>=
0
)
if
(
gMsgList
.
IndexOfKey
(
lMsg
)
>=
0
)
return
gMsgList
[
lMsg
];
return
gMsgList
[
lMsg
];
else
else
return
lMsg
.
ToString
().
Replace
(
"_"
,
" "
);
return
lMsg
.
ToString
().
Replace
(
"_"
,
" "
);
}
}
#
endregion
#
endregion
#
region
设置控件信息
#
region
设置控件信息
/// <summary>
/// <summary>
/// 设置控件文字
/// 设置控件文字
/// </summary>
/// </summary>
/// <param name="fm"></param>
/// <param name="fm"></param>
public
static
void
SetFormLabel
(
Form
fm
)
public
static
void
SetFormLabel
(
Form
fm
)
{
{
if
(
fm
==
null
)
if
(
fm
==
null
)
return
;
return
;
// fm.SuspendLayout();
// fm.SuspendLayout();
fm
.
ResumeLayout
(
true
);
fm
.
ResumeLayout
(
true
);
SetControlLabel
(
fm
,
""
,
fm
.
Name
);
SetControlLabel
(
fm
,
""
,
fm
.
Name
);
fm
.
ResumeLayout
(
false
);
fm
.
ResumeLayout
(
false
);
//fm.PerformLayout();
//fm.PerformLayout();
}
}
static
bool
GetLabel
(
string
key
,
out
string
title
)
static
bool
GetLabel
(
string
key
,
out
string
title
)
{
{
string
v
;
string
v
;
if
(
gWordsList
.
TryGetValue
(
key
,
out
v
))
if
(
gWordsList
.
TryGetValue
(
key
,
out
v
))
{
{
title
=
v
;
title
=
v
;
return
true
;
return
true
;
}
}
title
=
null
;
title
=
null
;
return
false
;
return
false
;
}
}
static
void
SetControlLabel
(
Control
c
,
string
pName
,
string
formName
)
static
void
SetControlLabel
(
Control
c
,
string
pName
,
string
formName
)
{
{
if
(!
string
.
IsNullOrEmpty
(
pName
))
if
(!
string
.
IsNullOrEmpty
(
pName
))
pName
+=
SEP_CONTROL
;
pName
+=
SEP_CONTROL
;
pName
+=
c
.
Name
;
pName
+=
c
.
Name
;
string
title
;
string
title
;
if
(
c
is
ListView
)
if
(
c
is
ListView
)
{
{
ListView
lv
=
(
ListView
)
c
;
ListView
lv
=
(
ListView
)
c
;
int
i
,
count
=
lv
.
Columns
.
Count
;
int
i
,
count
=
lv
.
Columns
.
Count
;
for
(
i
=
0
;
i
<
count
;
i
++)
for
(
i
=
0
;
i
<
count
;
i
++)
{
{
ColumnHeader
ch
=
lv
.
Columns
[
i
];
ColumnHeader
ch
=
lv
.
Columns
[
i
];
if
(
GetLabel
(
pName
+
SEP_CONTROL
+
i
.
ToString
(),
out
title
))
if
(
GetLabel
(
pName
+
SEP_CONTROL
+
i
.
ToString
(),
out
title
))
ch
.
Text
=
title
;
ch
.
Text
=
title
;
}
}
}
}
else
if
(
c
is
ToolStrip
)
else
if
(
c
is
ToolStrip
)
{
{
ToolStrip
ms
=
(
ToolStrip
)
c
;
ToolStrip
ms
=
(
ToolStrip
)
c
;
foreach
(
ToolStripItem
tsi
in
ms
.
Items
)
foreach
(
ToolStripItem
tsi
in
ms
.
Items
)
{
{
SetMenuItem
(
formName
+
SEP_CONTROL
+
ms
.
Name
,
tsi
);
SetMenuItem
(
formName
+
SEP_CONTROL
+
ms
.
Name
,
tsi
);
}
}
}
}
else
else
{
{
if
(
GetLabel
(
pName
,
out
title
))
if
(
GetLabel
(
pName
,
out
title
))
c
.
Text
=
title
;
c
.
Text
=
title
;
}
}
if
(
c
.
Controls
.
Count
>
0
)
if
(
c
.
Controls
.
Count
>
0
)
{
{
foreach
(
Control
sc
in
c
.
Controls
)
foreach
(
Control
sc
in
c
.
Controls
)
{
{
SetControlLabel
(
sc
,
pName
,
formName
);
SetControlLabel
(
sc
,
pName
,
formName
);
}
}
}
}
ContextMenuStrip
conms
=
c
.
ContextMenuStrip
;
ContextMenuStrip
conms
=
c
.
ContextMenuStrip
;
if
(
conms
!=
null
)
if
(
conms
!=
null
)
{
{
foreach
(
ToolStripItem
ts
in
conms
.
Items
)
foreach
(
ToolStripItem
ts
in
conms
.
Items
)
{
{
SetMenuItem
(
formName
+
SEP_CONTROL
+
conms
.
Name
,
ts
);
SetMenuItem
(
formName
+
SEP_CONTROL
+
conms
.
Name
,
ts
);
}
}
}
}
}
}
static
void
SetMenuItem
(
string
pName
,
ToolStripItem
tsi
)
static
void
SetMenuItem
(
string
pName
,
ToolStripItem
tsi
)
{
{
string
title
;
string
title
;
if
(
tsi
is
ToolStripMenuItem
)
if
(
tsi
is
ToolStripMenuItem
)
{
{
ToolStripMenuItem
tsmi
=
(
ToolStripMenuItem
)
tsi
;
ToolStripMenuItem
tsmi
=
(
ToolStripMenuItem
)
tsi
;
if
(
GetLabel
(
pName
+
SEP_CONTROL
+
tsmi
.
Name
,
out
title
))
if
(
GetLabel
(
pName
+
SEP_CONTROL
+
tsmi
.
Name
,
out
title
))
tsmi
.
Text
=
title
;
tsmi
.
Text
=
title
;
if
(
tsmi
.
HasDropDownItems
)
if
(
tsmi
.
HasDropDownItems
)
{
{
foreach
(
ToolStripItem
subtsi
in
tsmi
.
DropDownItems
)
foreach
(
ToolStripItem
subtsi
in
tsmi
.
DropDownItems
)
{
{
SetMenuItem
(
pName
,
subtsi
);
SetMenuItem
(
pName
,
subtsi
);
}
}
}
}
}
}
else
if
(
tsi
is
ToolStripLabel
)
else
if
(
tsi
is
ToolStripLabel
)
{
{
ToolStripLabel
tlbl
=
(
ToolStripLabel
)
tsi
;
ToolStripLabel
tlbl
=
(
ToolStripLabel
)
tsi
;
if
(
GetLabel
(
pName
+
SEP_CONTROL
+
tlbl
.
Name
,
out
title
))
if
(
GetLabel
(
pName
+
SEP_CONTROL
+
tlbl
.
Name
,
out
title
))
tlbl
.
Text
=
title
;
tlbl
.
Text
=
title
;
}
}
}
}
#
endregion
#
endregion
#
region
获取控件信息
#
region
获取控件信息
public
void
GetFormLabel
(
Form
fm
)
public
void
GetFormLabel
(
Form
fm
)
{
{
if
(
fm
==
null
)
if
(
fm
==
null
)
return
;
return
;
// fm.SuspendLayout();
// fm.SuspendLayout();
//fm.ResumeLayout(true);
//fm.ResumeLayout(true);
GetControlLabel
(
fm
,
""
,
fm
.
Name
);
GetControlLabel
(
fm
,
""
,
fm
.
Name
);
//fm.ResumeLayout(false);
//fm.ResumeLayout(false);
//fm.PerformLayout();
//fm.PerformLayout();
}
}
void
AddLabel
(
string
key
,
string
title
)
void
AddLabel
(
string
key
,
string
title
)
{
{
if
(!
mWordslist
.
ContainsKey
(
key
))
if
(!
mWordslist
.
ContainsKey
(
key
))
mWordslist
.
Add
(
key
,
title
);
mWordslist
.
Add
(
key
,
title
);
}
}
void
GetControlLabel
(
Control
c
,
string
pName
,
void
GetControlLabel
(
Control
c
,
string
pName
,
string
formName
)
string
formName
)
{
{
if
(!
string
.
IsNullOrEmpty
(
pName
))
if
(!
string
.
IsNullOrEmpty
(
pName
))
pName
+=
SEP_CONTROL
;
pName
+=
SEP_CONTROL
;
if
(
string
.
IsNullOrEmpty
(
c
.
Name
))
if
(
string
.
IsNullOrEmpty
(
c
.
Name
))
return
;
return
;
pName
+=
c
.
Name
;
pName
+=
c
.
Name
;
if
(
c
is
ListView
)
if
(
c
is
ListView
)
{
{
ListView
lv
=
(
ListView
)
c
;
ListView
lv
=
(
ListView
)
c
;
int
i
,
count
=
lv
.
Columns
.
Count
;
int
i
,
count
=
lv
.
Columns
.
Count
;
for
(
i
=
0
;
i
<
count
;
i
++)
for
(
i
=
0
;
i
<
count
;
i
++)
{
{
AddLabel
(
pName
+
SEP_CONTROL
+
i
.
ToString
(),
AddLabel
(
pName
+
SEP_CONTROL
+
i
.
ToString
(),
lv
.
Columns
[
i
].
Text
);
lv
.
Columns
[
i
].
Text
);
}
}
}
}
else
if
(
c
is
ToolStrip
)
else
if
(
c
is
ToolStrip
)
{
{
ToolStrip
ms
=
(
ToolStrip
)
c
;
ToolStrip
ms
=
(
ToolStrip
)
c
;
foreach
(
ToolStripItem
tsi
in
ms
.
Items
)
foreach
(
ToolStripItem
tsi
in
ms
.
Items
)
{
{
GetMenuItem
(
formName
+
SEP_CONTROL
+
ms
.
Name
,
tsi
);
GetMenuItem
(
formName
+
SEP_CONTROL
+
ms
.
Name
,
tsi
);
}
}
}
}
else
else
{
{
AddLabel
(
pName
,
c
.
Text
);
AddLabel
(
pName
,
c
.
Text
);
}
}
if
(
c
.
Controls
.
Count
>
0
)
if
(
c
.
Controls
.
Count
>
0
)
{
{
foreach
(
Control
sc
in
c
.
Controls
)
foreach
(
Control
sc
in
c
.
Controls
)
{
{
GetControlLabel
(
sc
,
pName
,
formName
);
GetControlLabel
(
sc
,
pName
,
formName
);
}
}
}
}
ContextMenuStrip
conms
=
c
.
ContextMenuStrip
;
ContextMenuStrip
conms
=
c
.
ContextMenuStrip
;
if
(
conms
!=
null
)
if
(
conms
!=
null
)
{
{
foreach
(
ToolStripItem
ts
in
conms
.
Items
)
foreach
(
ToolStripItem
ts
in
conms
.
Items
)
{
{
GetMenuItem
(
formName
+
SEP_CONTROL
+
conms
.
Text
,
ts
);
GetMenuItem
(
formName
+
SEP_CONTROL
+
conms
.
Text
,
ts
);
}
}
}
}
}
}
void
GetMenuItem
(
string
pName
,
ToolStripItem
tsi
)
void
GetMenuItem
(
string
pName
,
ToolStripItem
tsi
)
{
{
if
(
string
.
IsNullOrEmpty
(
tsi
.
Name
))
if
(
string
.
IsNullOrEmpty
(
tsi
.
Name
))
return
;
return
;
if
(
tsi
is
ToolStripMenuItem
)
if
(
tsi
is
ToolStripMenuItem
)
{
{
ToolStripMenuItem
tsmi
=
(
ToolStripMenuItem
)
tsi
;
ToolStripMenuItem
tsmi
=
(
ToolStripMenuItem
)
tsi
;
AddLabel
(
pName
+
SEP_CONTROL
+
tsmi
.
Name
,
tsmi
.
Text
);
AddLabel
(
pName
+
SEP_CONTROL
+
tsmi
.
Name
,
tsmi
.
Text
);
if
(
tsmi
.
HasDropDownItems
)
if
(
tsmi
.
HasDropDownItems
)
{
{
foreach
(
ToolStripItem
subtsi
in
tsmi
.
DropDownItems
)
foreach
(
ToolStripItem
subtsi
in
tsmi
.
DropDownItems
)
{
{
GetMenuItem
(
pName
,
subtsi
);
GetMenuItem
(
pName
,
subtsi
);
}
}
}
}
}
}
else
if
(
tsi
is
ToolStripLabel
)
else
if
(
tsi
is
ToolStripLabel
)
{
{
ToolStripLabel
tlbl
=
(
ToolStripLabel
)
tsi
;
ToolStripLabel
tlbl
=
(
ToolStripLabel
)
tsi
;
AddLabel
(
pName
+
SEP_CONTROL
+
tlbl
.
Name
,
tlbl
.
Text
);
AddLabel
(
pName
+
SEP_CONTROL
+
tlbl
.
Name
,
tlbl
.
Text
);
}
}
}
}
#
endregion
#
endregion
#
region
保存语言文件
#
region
保存语言文件
public
bool
SaveLanguage
(
string
conf
)
public
bool
SaveLanguage
(
string
conf
)
{
{
using
(
FileStream
fs
=
new
FileStream
(
conf
,
FileMode
.
Create
,
FileAccess
.
Write
))
using
(
FileStream
fs
=
new
FileStream
(
conf
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
foreach
(
string
k
in
mWordslist
.
Keys
)
foreach
(
string
k
in
mWordslist
.
Keys
)
{
{
sw
.
WriteLine
(
k
+
SEP_LINE
+
mWordslist
[
k
]);
sw
.
WriteLine
(
k
+
SEP_LINE
+
mWordslist
[
k
]);
}
}
sw
.
WriteLine
(
"#"
);
sw
.
WriteLine
(
"#"
);
foreach
(
LMSG
k
in
gMsgList
.
Keys
)
foreach
(
LMSG
k
in
gMsgList
.
Keys
)
{
{
//记得替换换行符
//记得替换换行符
sw
.
WriteLine
(
"0x"
+
((
uint
)
k
).
ToString
(
"x"
)
+
SEP_LINE
+
gMsgList
[
k
].
Replace
(
"\n"
,
"\\n"
));
sw
.
WriteLine
(
"0x"
+
((
uint
)
k
).
ToString
(
"x"
)
+
SEP_LINE
+
gMsgList
[
k
].
Replace
(
"\n"
,
"\\n"
));
}
}
foreach
(
LMSG
k
in
Enum
.
GetValues
(
typeof
(
LMSG
)))
foreach
(
LMSG
k
in
Enum
.
GetValues
(
typeof
(
LMSG
)))
{
{
if
(!
gMsgList
.
ContainsKey
(
k
))
if
(!
gMsgList
.
ContainsKey
(
k
))
sw
.
WriteLine
(
"0x"
+
((
uint
)
k
).
ToString
(
"x"
)
+
SEP_LINE
+
k
.
ToString
());
sw
.
WriteLine
(
"0x"
+
((
uint
)
k
).
ToString
(
"x"
)
+
SEP_LINE
+
k
.
ToString
());
}
}
sw
.
Close
();
sw
.
Close
();
fs
.
Close
();
fs
.
Close
();
}
}
return
true
;
return
true
;
}
}
#
endregion
#
endregion
#
region
加载语言文件
#
region
加载语言文件
public
static
void
LoadFormLabels
(
string
f
)
public
static
void
LoadFormLabels
(
string
f
)
{
{
if
(!
File
.
Exists
(
f
))
if
(!
File
.
Exists
(
f
))
return
;
return
;
gWordsList
.
Clear
();
gWordsList
.
Clear
();
gMsgList
.
Clear
();
gMsgList
.
Clear
();
using
(
FileStream
fs
=
new
FileStream
(
f
,
FileMode
.
Open
,
FileAccess
.
Read
))
using
(
FileStream
fs
=
new
FileStream
(
f
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
{
StreamReader
sr
=
new
StreamReader
(
fs
,
Encoding
.
UTF8
);
StreamReader
sr
=
new
StreamReader
(
fs
,
Encoding
.
UTF8
);
string
line
;
string
line
;
uint
utemp
;
uint
utemp
;
LMSG
ltemp
;
LMSG
ltemp
;
while
((
line
=
sr
.
ReadLine
())
!=
null
)
while
((
line
=
sr
.
ReadLine
())
!=
null
)
{
{
if
(
line
.
Length
==
0
)
if
(
line
.
Length
==
0
)
continue
;
continue
;
string
[]
words
=
line
.
Split
(
SEP_LINE
);
string
[]
words
=
line
.
Split
(
SEP_LINE
);
if
(
words
.
Length
<
2
)
if
(
words
.
Length
<
2
)
continue
;
continue
;
if
(
line
.
StartsWith
(
"0x"
))
//加载消息文字
if
(
line
.
StartsWith
(
"0x"
))
//加载消息文字
{
{
uint
.
TryParse
(
words
[
0
].
Replace
(
"0x"
,
""
),
NumberStyles
.
HexNumber
,
null
,
out
utemp
);
uint
.
TryParse
(
words
[
0
].
Replace
(
"0x"
,
""
),
NumberStyles
.
HexNumber
,
null
,
out
utemp
);
ltemp
=
(
LMSG
)
utemp
;
ltemp
=
(
LMSG
)
utemp
;
if
(
gMsgList
.
IndexOfKey
(
ltemp
)
<
0
)
//记得替换换行符
if
(
gMsgList
.
IndexOfKey
(
ltemp
)
<
0
)
//记得替换换行符
gMsgList
.
Add
(
ltemp
,
words
[
1
].
Replace
(
"\\n"
,
"\n"
));
gMsgList
.
Add
(
ltemp
,
words
[
1
].
Replace
(
"\\n"
,
"\n"
));
}
}
else
if
(!
line
.
StartsWith
(
"#"
))
//加载界面语言
else
if
(!
line
.
StartsWith
(
"#"
))
//加载界面语言
{
{
if
(!
gWordsList
.
ContainsKey
(
words
[
0
]))
if
(!
gWordsList
.
ContainsKey
(
words
[
0
]))
gWordsList
.
Add
(
words
[
0
],
words
[
1
]);
gWordsList
.
Add
(
words
[
0
],
words
[
1
]);
}
}
}
}
sr
.
Close
();
sr
.
Close
();
fs
.
Close
();
fs
.
Close
();
}
}
}
}
#
endregion
#
endregion
}
}
}
}
DataEditorX/Language/MyMsg.cs
View file @
e72f147e
...
@@ -14,66 +14,66 @@
...
@@ -14,66 +14,66 @@
namespace
DataEditorX.Language
namespace
DataEditorX.Language
{
{
/// <summary>
/// <summary>
/// 消息
/// 消息
/// </summary>
/// </summary>
public
static
class
MyMsg
public
static
class
MyMsg
{
{
static
string
info
,
warning
,
error
,
question
;
static
string
info
,
warning
,
error
,
question
;
static
MyMsg
()
static
MyMsg
()
{
{
info
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleInfo
);
info
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleInfo
);
warning
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleWarning
);
warning
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleWarning
);
error
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleError
);
error
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleError
);
question
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleQuestion
);
question
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleQuestion
);
}
}
public
static
void
Show
(
string
strMsg
)
public
static
void
Show
(
string
strMsg
)
{
{
MessageBox
.
Show
(
strMsg
,
info
,
MessageBox
.
Show
(
strMsg
,
info
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Information
);
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Information
);
}
}
public
static
void
Warning
(
string
strWarn
)
public
static
void
Warning
(
string
strWarn
)
{
{
MessageBox
.
Show
(
strWarn
,
warning
,
MessageBox
.
Show
(
strWarn
,
warning
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
);
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
);
}
}
public
static
void
Error
(
string
strError
)
public
static
void
Error
(
string
strError
)
{
{
MessageBox
.
Show
(
strError
,
error
,
MessageBox
.
Show
(
strError
,
error
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
}
}
public
static
bool
Question
(
string
strQues
)
public
static
bool
Question
(
string
strQues
)
{
{
if
(
MessageBox
.
Show
(
strQues
,
question
,
if
(
MessageBox
.
Show
(
strQues
,
question
,
MessageBoxButtons
.
OKCancel
,
MessageBoxButtons
.
OKCancel
,
MessageBoxIcon
.
Question
)==
DialogResult
.
OK
)
MessageBoxIcon
.
Question
)==
DialogResult
.
OK
)
return
true
;
return
true
;
else
else
return
false
;
return
false
;
}
}
public
static
void
Show
(
LMSG
msg
)
public
static
void
Show
(
LMSG
msg
)
{
{
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
info
,
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
info
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Information
);
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Information
);
}
}
public
static
void
Warning
(
LMSG
msg
)
public
static
void
Warning
(
LMSG
msg
)
{
{
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
warning
,
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
warning
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
);
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
);
}
}
public
static
void
Error
(
LMSG
msg
)
public
static
void
Error
(
LMSG
msg
)
{
{
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
error
,
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
error
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
}
}
public
static
bool
Question
(
LMSG
msg
)
public
static
bool
Question
(
LMSG
msg
)
{
{
if
(
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
question
,
if
(
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
question
,
MessageBoxButtons
.
OKCancel
,
MessageBoxButtons
.
OKCancel
,
MessageBoxIcon
.
Question
)==
DialogResult
.
OK
)
MessageBoxIcon
.
Question
)==
DialogResult
.
OK
)
return
true
;
return
true
;
else
else
return
false
;
return
false
;
}
}
}
}
}
}
DataEditorX/MainForm.Designer.cs
View file @
e72f147e
...
@@ -374,8 +374,8 @@ private void InitializeComponent()
...
@@ -374,8 +374,8 @@ private void InitializeComponent()
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_file
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_file
;
private
System
.
Windows
.
Forms
.
MenuStrip
mainMenu
;
private
System
.
Windows
.
Forms
.
MenuStrip
mainMenu
;
private
WeifenLuo
.
WinFormsUI
.
Docking
.
DockPanel
dockPanel1
;
private
WeifenLuo
.
WinFormsUI
.
Docking
.
DockPanel
dockPanel1
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_shistory
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
menuitem_shistory
;
private
System
.
ComponentModel
.
BackgroundWorker
bgWorker1
;
private
System
.
ComponentModel
.
BackgroundWorker
bgWorker1
;
}
}
}
}
DataEditorX/MainForm.cs
View file @
e72f147e
...
@@ -19,483 +19,483 @@
...
@@ -19,483 +19,483 @@
namespace
DataEditorX
namespace
DataEditorX
{
{
public
partial
class
MainForm
:
Form
,
IMainForm
public
partial
class
MainForm
:
Form
,
IMainForm
{
{
#
region
member
#
region
member
//历史
//历史
History
history
;
History
history
;
//数据目录
//数据目录
string
datapath
;
string
datapath
;
//语言配置
//语言配置
string
conflang
;
string
conflang
;
//数据库对比
//数据库对比
DataEditForm
compare1
,
compare2
;
DataEditForm
compare1
,
compare2
;
//临时卡片
//临时卡片
Card
[]
tCards
;
Card
[]
tCards
;
//编辑器配置
//编辑器配置
DataConfig
datacfg
=
null
;
DataConfig
datacfg
=
null
;
CodeConfig
codecfg
=
null
;
CodeConfig
codecfg
=
null
;
//将要打开的文件
//将要打开的文件
string
openfile
;
string
openfile
;
#
endregion
#
endregion
#
region
设置界面,消息语言
#
region
设置界面,消息语言
public
MainForm
()
public
MainForm
()
{
{
//初始化控件
//初始化控件
InitializeComponent
();
InitializeComponent
();
}
}
public
void
SetDataPath
(
string
datapath
)
public
void
SetDataPath
(
string
datapath
)
{
{
//判断是否合法
//判断是否合法
if
(
string
.
IsNullOrEmpty
(
datapath
))
if
(
string
.
IsNullOrEmpty
(
datapath
))
return
;
return
;
tCards
=
null
;
tCards
=
null
;
//数据目录
//数据目录
this
.
datapath
=
datapath
;
this
.
datapath
=
datapath
;
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_ASYNC
))
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_ASYNC
))
{
{
//后台加载数据
//后台加载数据
bgWorker1
.
RunWorkerAsync
();
bgWorker1
.
RunWorkerAsync
();
}
}
else
else
{
{
Init
();
Init
();
InitForm
();
InitForm
();
}
}
}
}
void
CheckUpdate
()
void
CheckUpdate
()
{
{
TaskHelper
.
CheckVersion
(
false
);
TaskHelper
.
CheckVersion
(
false
);
}
}
public
void
setOpenFile
(
string
file
)
public
void
setOpenFile
(
string
file
)
{
{
this
.
openfile
=
file
;
this
.
openfile
=
file
;
}
}
void
Init
()
void
Init
()
{
{
//文件路径
//文件路径
conflang
=
MyConfig
.
GetLanguageFile
(
datapath
);
conflang
=
MyConfig
.
GetLanguageFile
(
datapath
);
//游戏数据,MSE数据
//游戏数据,MSE数据
datacfg
=
new
DataConfig
(
MyConfig
.
GetCardInfoFile
(
datapath
));
datacfg
=
new
DataConfig
(
MyConfig
.
GetCardInfoFile
(
datapath
));
//初始化YGOUtil的数据
//初始化YGOUtil的数据
YGOUtil
.
SetConfig
(
datacfg
);
YGOUtil
.
SetConfig
(
datacfg
);
//代码提示
//代码提示
string
funtxt
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_FUNCTION
);
string
funtxt
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_FUNCTION
);
string
conlua
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_CONSTANT
);
string
conlua
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_CONSTANT
);
string
confstring
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_STRINGS
);
string
confstring
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_STRINGS
);
codecfg
=
new
CodeConfig
();
codecfg
=
new
CodeConfig
();
//添加函数
//添加函数
codecfg
.
AddFunction
(
funtxt
);
codecfg
.
AddFunction
(
funtxt
);
//添加指示物
//添加指示物
codecfg
.
AddStrings
(
confstring
);
codecfg
.
AddStrings
(
confstring
);
//添加常量
//添加常量
codecfg
.
AddConstant
(
conlua
);
codecfg
.
AddConstant
(
conlua
);
codecfg
.
SetNames
(
datacfg
.
dicSetnames
);
codecfg
.
SetNames
(
datacfg
.
dicSetnames
);
//生成菜单
//生成菜单
codecfg
.
InitAutoMenus
();
codecfg
.
InitAutoMenus
();
history
=
new
History
(
this
);
history
=
new
History
(
this
);
//读取历史记录
//读取历史记录
history
.
ReadHistory
(
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_HISTORY
));
history
.
ReadHistory
(
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_HISTORY
));
//加载多语言
//加载多语言
LanguageHelper
.
LoadFormLabels
(
conflang
);
LanguageHelper
.
LoadFormLabels
(
conflang
);
}
}
void
InitForm
()
void
InitForm
()
{
{
LanguageHelper
.
SetFormLabel
(
this
);
LanguageHelper
.
SetFormLabel
(
this
);
//设置所有窗口的语言
//设置所有窗口的语言
DockContentCollection
contents
=
dockPanel1
.
Contents
;
DockContentCollection
contents
=
dockPanel1
.
Contents
;
foreach
(
DockContent
dc
in
contents
)
foreach
(
DockContent
dc
in
contents
)
{
{
if
(
dc
is
Form
)
if
(
dc
is
Form
)
{
{
LanguageHelper
.
SetFormLabel
((
Form
)
dc
);
LanguageHelper
.
SetFormLabel
((
Form
)
dc
);
}
}
}
}
//添加历史菜单
//添加历史菜单
history
.
MenuHistory
();
history
.
MenuHistory
();
//如果没有将要打开的文件,则打开一个空数据库标签
//如果没有将要打开的文件,则打开一个空数据库标签
if
(
string
.
IsNullOrEmpty
(
openfile
))
if
(
string
.
IsNullOrEmpty
(
openfile
))
OpenDataBase
(
null
);
OpenDataBase
(
null
);
else
else
Open
(
openfile
);
Open
(
openfile
);
}
}
#
endregion
#
endregion
#
region
打开历史
#
region
打开历史
//清除cdb历史
//清除cdb历史
public
void
CdbMenuClear
()
public
void
CdbMenuClear
()
{
{
menuitem_history
.
DropDownItems
.
Clear
();
menuitem_history
.
DropDownItems
.
Clear
();
}
}
//清除lua历史
//清除lua历史
public
void
LuaMenuClear
()
public
void
LuaMenuClear
()
{
{
menuitem_shistory
.
DropDownItems
.
Clear
();
menuitem_shistory
.
DropDownItems
.
Clear
();
}
}
//添加cdb历史
//添加cdb历史
public
void
AddCdbMenu
(
ToolStripItem
item
)
public
void
AddCdbMenu
(
ToolStripItem
item
)
{
{
menuitem_history
.
DropDownItems
.
Add
(
item
);
menuitem_history
.
DropDownItems
.
Add
(
item
);
}
}
//添加lua历史
//添加lua历史
public
void
AddLuaMenu
(
ToolStripItem
item
)
public
void
AddLuaMenu
(
ToolStripItem
item
)
{
{
menuitem_shistory
.
DropDownItems
.
Add
(
item
);
menuitem_shistory
.
DropDownItems
.
Add
(
item
);
}
}
#
endregion
#
endregion
#
region
处理窗口消息
#
region
处理窗口消息
protected
override
void
DefWndProc
(
ref
System
.
Windows
.
Forms
.
Message
m
)
protected
override
void
DefWndProc
(
ref
System
.
Windows
.
Forms
.
Message
m
)
{
{
string
file
=
null
;
string
file
=
null
;
switch
(
m
.
Msg
)
switch
(
m
.
Msg
)
{
{
case
MyConfig
.
WM_OPEN
:
//处理消息
case
MyConfig
.
WM_OPEN
:
//处理消息
file
=
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
FILE_TEMP
);
file
=
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
FILE_TEMP
);
if
(
File
.
Exists
(
file
))
if
(
File
.
Exists
(
file
))
{
{
this
.
Activate
();
this
.
Activate
();
String
openfile
=
File
.
ReadAllText
(
file
);
String
openfile
=
File
.
ReadAllText
(
file
);
//获取需要打开的文件路径
//获取需要打开的文件路径
Open
(
openfile
);
Open
(
openfile
);
//File.Delete(file);
//File.Delete(file);
}
}
break
;
break
;
default
:
default
:
base
.
DefWndProc
(
ref
m
);
base
.
DefWndProc
(
ref
m
);
break
;
break
;
}
}
}
}
#
endregion
#
endregion
#
region
打开文件
#
region
打开文件
//打开脚本
//打开脚本
void
OpenScript
(
string
file
)
void
OpenScript
(
string
file
)
{
{
CodeEditForm
cf
=
new
CodeEditForm
();
CodeEditForm
cf
=
new
CodeEditForm
();
//设置界面语言
//设置界面语言
LanguageHelper
.
SetFormLabel
(
cf
);
LanguageHelper
.
SetFormLabel
(
cf
);
//设置cdb列表
//设置cdb列表
cf
.
SetCDBList
(
history
.
GetcdbHistory
());
cf
.
SetCDBList
(
history
.
GetcdbHistory
());
//初始化函数提示
//初始化函数提示
cf
.
InitTooltip
(
codecfg
);
cf
.
InitTooltip
(
codecfg
);
//打开文件
//打开文件
cf
.
Open
(
file
);
cf
.
Open
(
file
);
cf
.
Show
(
dockPanel1
,
DockState
.
Document
);
cf
.
Show
(
dockPanel1
,
DockState
.
Document
);
}
}
//打开数据库
//打开数据库
void
OpenDataBase
(
string
file
)
void
OpenDataBase
(
string
file
)
{
{
DataEditForm
def
;
DataEditForm
def
;
if
(
string
.
IsNullOrEmpty
(
file
)
||
!
File
.
Exists
(
file
))
if
(
string
.
IsNullOrEmpty
(
file
)
||
!
File
.
Exists
(
file
))
def
=
new
DataEditForm
(
datapath
);
def
=
new
DataEditForm
(
datapath
);
else
else
def
=
new
DataEditForm
(
datapath
,
file
);
def
=
new
DataEditForm
(
datapath
,
file
);
//设置语言
//设置语言
LanguageHelper
.
SetFormLabel
(
def
);
LanguageHelper
.
SetFormLabel
(
def
);
//初始化界面数据
//初始化界面数据
def
.
InitControl
(
datacfg
);
def
.
InitControl
(
datacfg
);
def
.
Show
(
dockPanel1
,
DockState
.
Document
);
def
.
Show
(
dockPanel1
,
DockState
.
Document
);
}
}
//打开文件
//打开文件
public
void
Open
(
string
file
)
public
void
Open
(
string
file
)
{
{
if
(
string
.
IsNullOrEmpty
(
file
)
||
!
File
.
Exists
(
file
))
if
(
string
.
IsNullOrEmpty
(
file
)
||
!
File
.
Exists
(
file
))
{
{
return
;
return
;
}
}
//添加历史
//添加历史
history
.
AddHistory
(
file
);
history
.
AddHistory
(
file
);
//检查是否已经打开
//检查是否已经打开
if
(
FindEditForm
(
file
,
true
))
if
(
FindEditForm
(
file
,
true
))
return
;
return
;
//检查可用的
//检查可用的
if
(
FindEditForm
(
file
,
false
))
if
(
FindEditForm
(
file
,
false
))
return
;
return
;
if
(
YGOUtil
.
isScript
(
file
))
if
(
YGOUtil
.
isScript
(
file
))
OpenScript
(
file
);
OpenScript
(
file
);
else
if
(
YGOUtil
.
isDataBase
(
file
))
else
if
(
YGOUtil
.
isDataBase
(
file
))
OpenDataBase
(
file
);
OpenDataBase
(
file
);
}
}
//检查是否打开
//检查是否打开
bool
FindEditForm
(
string
file
,
bool
isOpen
)
bool
FindEditForm
(
string
file
,
bool
isOpen
)
{
{
DockContentCollection
contents
=
dockPanel1
.
Contents
;
DockContentCollection
contents
=
dockPanel1
.
Contents
;
//遍历所有标签
//遍历所有标签
foreach
(
DockContent
dc
in
contents
)
foreach
(
DockContent
dc
in
contents
)
{
{
IEditForm
edform
=
(
IEditForm
)
dc
;
IEditForm
edform
=
(
IEditForm
)
dc
;
if
(
edform
==
null
)
if
(
edform
==
null
)
continue
;
continue
;
if
(
isOpen
)
//是否检查打开
if
(
isOpen
)
//是否检查打开
{
{
if
(
file
!=
null
&&
file
.
Equals
(
edform
.
GetOpenFile
()))
if
(
file
!=
null
&&
file
.
Equals
(
edform
.
GetOpenFile
()))
{
{
edform
.
SetActived
();
edform
.
SetActived
();
return
true
;
return
true
;
}
}
}
}
else
//检查是否空白,如果为空,则打开文件
else
//检查是否空白,如果为空,则打开文件
{
{
if
(
string
.
IsNullOrEmpty
(
edform
.
GetOpenFile
())
&&
edform
.
CanOpen
(
file
))
if
(
string
.
IsNullOrEmpty
(
edform
.
GetOpenFile
())
&&
edform
.
CanOpen
(
file
))
{
{
edform
.
Open
(
file
);
edform
.
Open
(
file
);
edform
.
SetActived
();
edform
.
SetActived
();
return
true
;
return
true
;
}
}
}
}
}
}
return
false
;
return
false
;
}
}
#
endregion
#
endregion
#
region
窗口管理
#
region
窗口管理
//关闭当前
//关闭当前
void
CloseToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
CloseToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
dockPanel1
.
ActiveContent
.
DockHandler
!=
null
)
if
(
dockPanel1
.
ActiveContent
.
DockHandler
!=
null
)
dockPanel1
.
ActiveContent
.
DockHandler
.
Close
();
dockPanel1
.
ActiveContent
.
DockHandler
.
Close
();
}
}
//打开脚本编辑
//打开脚本编辑
void
Menuitem_codeeditorClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_codeeditorClick
(
object
sender
,
EventArgs
e
)
{
{
OpenScript
(
null
);
OpenScript
(
null
);
}
}
//新建DataEditorX
//新建DataEditorX
void
DataEditorToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
DataEditorToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
OpenDataBase
(
null
);
OpenDataBase
(
null
);
}
}
//关闭其他或者所有
//关闭其他或者所有
void
CloseMdi
(
bool
isall
)
void
CloseMdi
(
bool
isall
)
{
{
DockContentCollection
contents
=
dockPanel1
.
Contents
;
DockContentCollection
contents
=
dockPanel1
.
Contents
;
int
num
=
contents
.
Count
-
1
;
int
num
=
contents
.
Count
-
1
;
try
try
{
{
while
(
num
>=
0
)
while
(
num
>=
0
)
{
{
if
(
contents
[
num
].
DockHandler
.
DockState
==
DockState
.
Document
)
if
(
contents
[
num
].
DockHandler
.
DockState
==
DockState
.
Document
)
{
{
if
(
isall
)
if
(
isall
)
contents
[
num
].
DockHandler
.
Close
();
contents
[
num
].
DockHandler
.
Close
();
else
if
(
dockPanel1
.
ActiveContent
!=
contents
[
num
])
else
if
(
dockPanel1
.
ActiveContent
!=
contents
[
num
])
contents
[
num
].
DockHandler
.
Close
();
contents
[
num
].
DockHandler
.
Close
();
}
}
num
--;
num
--;
}
}
}
}
catch
{
}
catch
{
}
}
}
//关闭其他
//关闭其他
void
CloseOtherToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
CloseOtherToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
CloseMdi
(
false
);
CloseMdi
(
false
);
}
}
//关闭所有
//关闭所有
void
CloseAllToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
CloseAllToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
CloseMdi
(
true
);
CloseMdi
(
true
);
}
}
#
endregion
#
endregion
#
region
文件菜单
#
region
文件菜单
//得到当前的数据编辑
//得到当前的数据编辑
DataEditForm
GetActive
()
DataEditForm
GetActive
()
{
{
DataEditForm
df
=
dockPanel1
.
ActiveContent
as
DataEditForm
;
DataEditForm
df
=
dockPanel1
.
ActiveContent
as
DataEditForm
;
return
df
;
return
df
;
}
}
//打开文件
//打开文件
void
Menuitem_openClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_openClick
(
object
sender
,
EventArgs
e
)
{
{
using
(
OpenFileDialog
dlg
=
new
OpenFileDialog
())
using
(
OpenFileDialog
dlg
=
new
OpenFileDialog
())
{
{
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
OpenFile
);
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
OpenFile
);
if
(
GetActive
()
!=
null
||
dockPanel1
.
Contents
.
Count
==
0
)
//判断当前窗口是不是DataEditor
if
(
GetActive
()
!=
null
||
dockPanel1
.
Contents
.
Count
==
0
)
//判断当前窗口是不是DataEditor
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
else
else
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ScriptFilter
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ScriptFilter
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
string
file
=
dlg
.
FileName
;
string
file
=
dlg
.
FileName
;
Open
(
file
);
Open
(
file
);
}
}
}
}
}
}
//退出
//退出
void
QuitToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
QuitToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
this
.
Close
();
this
.
Close
();
}
}
//新建文件
//新建文件
void
Menuitem_newClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_newClick
(
object
sender
,
EventArgs
e
)
{
{
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
{
{
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
NewFile
);
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
NewFile
);
if
(
GetActive
()
!=
null
)
//判断当前窗口是不是DataEditor
if
(
GetActive
()
!=
null
)
//判断当前窗口是不是DataEditor
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
else
else
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ScriptFilter
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ScriptFilter
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
string
file
=
dlg
.
FileName
;
string
file
=
dlg
.
FileName
;
if
(
File
.
Exists
(
file
))
if
(
File
.
Exists
(
file
))
File
.
Delete
(
file
);
File
.
Delete
(
file
);
//是否是数据库
//是否是数据库
if
(
YGOUtil
.
isDataBase
(
file
))
if
(
YGOUtil
.
isDataBase
(
file
))
{
{
if
(
DataBase
.
Create
(
file
))
//是否创建成功
if
(
DataBase
.
Create
(
file
))
//是否创建成功
{
{
if
(
MyMsg
.
Question
(
LMSG
.
IfOpenDataBase
))
//是否打开新建的数据库
if
(
MyMsg
.
Question
(
LMSG
.
IfOpenDataBase
))
//是否打开新建的数据库
Open
(
file
);
Open
(
file
);
}
}
}
}
else
else
{
{
Open
(
file
);
Open
(
file
);
}
}
}
}
}
}
}
}
//保存文件
//保存文件
void
Menuitem_saveClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_saveClick
(
object
sender
,
EventArgs
e
)
{
{
IEditForm
cf
=
dockPanel1
.
ActiveContent
as
IEditForm
;
IEditForm
cf
=
dockPanel1
.
ActiveContent
as
IEditForm
;
if
(
cf
!=
null
)
if
(
cf
!=
null
)
{
{
if
(
cf
.
Save
())
//是否保存成功
if
(
cf
.
Save
())
//是否保存成功
MyMsg
.
Show
(
LMSG
.
SaveFileOK
);
MyMsg
.
Show
(
LMSG
.
SaveFileOK
);
}
}
}
}
#
endregion
#
endregion
#
region
卡片复制粘贴
#
region
卡片复制粘贴
//复制选中
//复制选中
void
Menuitem_copyselecttoClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_copyselecttoClick
(
object
sender
,
EventArgs
e
)
{
{
DataEditForm
df
=
GetActive
();
//获取当前的数据库编辑
DataEditForm
df
=
GetActive
();
//获取当前的数据库编辑
if
(
df
!=
null
)
if
(
df
!=
null
)
{
{
tCards
=
df
.
GetCardList
(
true
);
//获取选中的卡片
tCards
=
df
.
GetCardList
(
true
);
//获取选中的卡片
if
(
tCards
!=
null
)
if
(
tCards
!=
null
)
{
{
SetCopyNumber
(
tCards
.
Length
);
//显示复制卡片的数量
SetCopyNumber
(
tCards
.
Length
);
//显示复制卡片的数量
MyMsg
.
Show
(
LMSG
.
CopyCards
);
MyMsg
.
Show
(
LMSG
.
CopyCards
);
}
}
}
}
}
}
//复制当前结果
//复制当前结果
void
Menuitem_copyallClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_copyallClick
(
object
sender
,
EventArgs
e
)
{
{
DataEditForm
df
=
GetActive
();
//获取当前的数据库编辑
DataEditForm
df
=
GetActive
();
//获取当前的数据库编辑
if
(
df
!=
null
)
if
(
df
!=
null
)
{
{
tCards
=
df
.
GetCardList
(
false
);
//获取结果的所有卡片
tCards
=
df
.
GetCardList
(
false
);
//获取结果的所有卡片
if
(
tCards
!=
null
)
if
(
tCards
!=
null
)
{
{
SetCopyNumber
(
tCards
.
Length
);
//显示复制卡片的数量
SetCopyNumber
(
tCards
.
Length
);
//显示复制卡片的数量
MyMsg
.
Show
(
LMSG
.
CopyCards
);
MyMsg
.
Show
(
LMSG
.
CopyCards
);
}
}
}
}
}
}
//显示复制卡片的数量
//显示复制卡片的数量
void
SetCopyNumber
(
int
c
)
void
SetCopyNumber
(
int
c
)
{
{
string
tmp
=
menuitem_pastecards
.
Text
;
string
tmp
=
menuitem_pastecards
.
Text
;
int
t
=
tmp
.
LastIndexOf
(
" ("
);
int
t
=
tmp
.
LastIndexOf
(
" ("
);
if
(
t
>
0
)
if
(
t
>
0
)
tmp
=
tmp
.
Substring
(
0
,
t
);
tmp
=
tmp
.
Substring
(
0
,
t
);
tmp
=
tmp
+
" ("
+
c
.
ToString
()
+
")"
;
tmp
=
tmp
+
" ("
+
c
.
ToString
()
+
")"
;
menuitem_pastecards
.
Text
=
tmp
;
menuitem_pastecards
.
Text
=
tmp
;
}
}
//粘贴卡片
//粘贴卡片
void
Menuitem_pastecardsClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_pastecardsClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
tCards
==
null
)
if
(
tCards
==
null
)
return
;
return
;
DataEditForm
df
=
GetActive
();
DataEditForm
df
=
GetActive
();
if
(
df
==
null
)
if
(
df
==
null
)
return
;
return
;
df
.
SaveCards
(
tCards
);
//保存卡片
df
.
SaveCards
(
tCards
);
//保存卡片
MyMsg
.
Show
(
LMSG
.
PasteCards
);
MyMsg
.
Show
(
LMSG
.
PasteCards
);
}
}
#
endregion
#
endregion
#
region
数据对比
#
region
数据对比
//设置数据库1
//设置数据库1
void
Menuitem_comp1Click
(
object
sender
,
EventArgs
e
)
void
Menuitem_comp1Click
(
object
sender
,
EventArgs
e
)
{
{
compare1
=
GetActive
();
compare1
=
GetActive
();
if
(
compare1
!=
null
&&
!
string
.
IsNullOrEmpty
(
compare1
.
GetOpenFile
()))
if
(
compare1
!=
null
&&
!
string
.
IsNullOrEmpty
(
compare1
.
GetOpenFile
()))
{
{
menuitem_comp2
.
Enabled
=
true
;
menuitem_comp2
.
Enabled
=
true
;
CompareDB
();
CompareDB
();
}
}
}
}
//设置数据库2
//设置数据库2
void
Menuitem_comp2Click
(
object
sender
,
EventArgs
e
)
void
Menuitem_comp2Click
(
object
sender
,
EventArgs
e
)
{
{
compare2
=
GetActive
();
compare2
=
GetActive
();
if
(
compare2
!=
null
&&
!
string
.
IsNullOrEmpty
(
compare2
.
GetOpenFile
()))
if
(
compare2
!=
null
&&
!
string
.
IsNullOrEmpty
(
compare2
.
GetOpenFile
()))
{
{
CompareDB
();
CompareDB
();
}
}
}
}
//对比数据库
//对比数据库
void
CompareDB
()
void
CompareDB
()
{
{
if
(
compare1
==
null
||
compare2
==
null
)
if
(
compare1
==
null
||
compare2
==
null
)
return
;
return
;
string
cdb1
=
compare1
.
GetOpenFile
();
string
cdb1
=
compare1
.
GetOpenFile
();
string
cdb2
=
compare2
.
GetOpenFile
();
string
cdb2
=
compare2
.
GetOpenFile
();
if
(
string
.
IsNullOrEmpty
(
cdb1
)
if
(
string
.
IsNullOrEmpty
(
cdb1
)
||
string
.
IsNullOrEmpty
(
cdb2
)
||
string
.
IsNullOrEmpty
(
cdb2
)
||
cdb1
==
cdb2
)
||
cdb1
==
cdb2
)
return
;
return
;
bool
checktext
=
MyMsg
.
Question
(
LMSG
.
CheckText
);
bool
checktext
=
MyMsg
.
Question
(
LMSG
.
CheckText
);
//分别对比数据库
//分别对比数据库
compare1
.
CompareCards
(
cdb2
,
checktext
);
compare1
.
CompareCards
(
cdb2
,
checktext
);
compare2
.
CompareCards
(
cdb1
,
checktext
);
compare2
.
CompareCards
(
cdb1
,
checktext
);
MyMsg
.
Show
(
LMSG
.
CompareOK
);
MyMsg
.
Show
(
LMSG
.
CompareOK
);
menuitem_comp2
.
Enabled
=
false
;
menuitem_comp2
.
Enabled
=
false
;
compare1
=
null
;
compare1
=
null
;
compare2
=
null
;
compare2
=
null
;
}
}
#
endregion
#
endregion
#
region
后台加载数据
#
region
后台加载数据
private
void
bgWorker1_DoWork
(
object
sender
,
System
.
ComponentModel
.
DoWorkEventArgs
e
)
private
void
bgWorker1_DoWork
(
object
sender
,
System
.
ComponentModel
.
DoWorkEventArgs
e
)
{
{
Init
();
Init
();
}
}
private
void
bgWorker1_RunWorkerCompleted
(
object
sender
,
System
.
ComponentModel
.
RunWorkerCompletedEventArgs
e
)
private
void
bgWorker1_RunWorkerCompleted
(
object
sender
,
System
.
ComponentModel
.
RunWorkerCompletedEventArgs
e
)
{
{
//更新UI
//更新UI
InitForm
();
InitForm
();
}
}
#
endregion
#
endregion
private
void
MainForm_Load
(
object
sender
,
EventArgs
e
)
private
void
MainForm_Load
(
object
sender
,
EventArgs
e
)
{
{
//检查更新
//检查更新
if
(!
MyConfig
.
readBoolean
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
))
if
(!
MyConfig
.
readBoolean
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
))
return
;
return
;
Thread
th
=
new
Thread
(
CheckUpdate
);
Thread
th
=
new
Thread
(
CheckUpdate
);
th
.
IsBackground
=
true
;
//如果exe结束,则线程终止
th
.
IsBackground
=
true
;
//如果exe结束,则线程终止
th
.
Start
();
th
.
Start
();
}
}
}
}
}
}
DataEditorX/Program.cs
View file @
e72f147e
...
@@ -22,48 +22,48 @@ internal sealed class Program
...
@@ -22,48 +22,48 @@ internal sealed class Program
[
STAThread
]
[
STAThread
]
private
static
void
Main
(
string
[]
args
)
private
static
void
Main
(
string
[]
args
)
{
{
string
arg
=
(
args
.
Length
>
0
)
?
args
[
0
]
:
""
;
string
arg
=
(
args
.
Length
>
0
)
?
args
[
0
]
:
""
;
if
(
arg
==
MyConfig
.
TAG_SAVE_LAGN
||
arg
==
MyConfig
.
TAG_SAVE_LAGN2
)
if
(
arg
==
MyConfig
.
TAG_SAVE_LAGN
||
arg
==
MyConfig
.
TAG_SAVE_LAGN2
)
{
{
//保存语言
//保存语言
SaveLanguage
();
SaveLanguage
();
MessageBox
.
Show
(
"Save Language OK."
);
MessageBox
.
Show
(
"Save Language OK."
);
Environment
.
Exit
(
1
);
Environment
.
Exit
(
1
);
}
}
if
(
MyConfig
.
OpenOnExistForm
(
arg
))
//在已经存在的窗口打开文件
if
(
MyConfig
.
OpenOnExistForm
(
arg
))
//在已经存在的窗口打开文件
Environment
.
Exit
(
1
);
Environment
.
Exit
(
1
);
else
//新建窗口
else
//新建窗口
{
{
Application
.
EnableVisualStyles
();
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
SetCompatibleTextRenderingDefault
(
false
);
MainForm
mainForm
=
new
MainForm
();
MainForm
mainForm
=
new
MainForm
();
//设置将要打开的文件
//设置将要打开的文件
mainForm
.
setOpenFile
(
arg
);
mainForm
.
setOpenFile
(
arg
);
//数据目录
//数据目录
mainForm
.
SetDataPath
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_DATA
));
mainForm
.
SetDataPath
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_DATA
));
Application
.
Run
(
mainForm
);
Application
.
Run
(
mainForm
);
}
}
}
}
static
void
SaveLanguage
()
static
void
SaveLanguage
()
{
{
string
datapath
=
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_DATA
);
string
datapath
=
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_DATA
);
string
conflang
=
MyConfig
.
GetLanguageFile
(
datapath
);
string
conflang
=
MyConfig
.
GetLanguageFile
(
datapath
);
LanguageHelper
.
LoadFormLabels
(
conflang
);
LanguageHelper
.
LoadFormLabels
(
conflang
);
LanguageHelper
langhelper
=
new
LanguageHelper
();
LanguageHelper
langhelper
=
new
LanguageHelper
();
MainForm
form1
=
new
MainForm
();
MainForm
form1
=
new
MainForm
();
LanguageHelper
.
SetFormLabel
(
form1
);
LanguageHelper
.
SetFormLabel
(
form1
);
langhelper
.
GetFormLabel
(
form1
);
langhelper
.
GetFormLabel
(
form1
);
DataEditForm
form2
=
new
DataEditForm
();
DataEditForm
form2
=
new
DataEditForm
();
LanguageHelper
.
SetFormLabel
(
form2
);
LanguageHelper
.
SetFormLabel
(
form2
);
langhelper
.
GetFormLabel
(
form2
);
langhelper
.
GetFormLabel
(
form2
);
CodeEditForm
form3
=
new
CodeEditForm
();
CodeEditForm
form3
=
new
CodeEditForm
();
LanguageHelper
.
SetFormLabel
(
form3
);
LanguageHelper
.
SetFormLabel
(
form3
);
langhelper
.
GetFormLabel
(
form3
);
langhelper
.
GetFormLabel
(
form3
);
// LANG.GetFormLabel(this);
// LANG.GetFormLabel(this);
//获取窗体文字
//获取窗体文字
langhelper
.
SaveLanguage
(
conflang
+
".bak"
);
langhelper
.
SaveLanguage
(
conflang
+
".bak"
);
}
}
}
}
}
}
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