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
聖園ミカ
DataEditorX
Commits
bc0829bf
Commit
bc0829bf
authored
Jun 08, 2020
by
JoyJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code format
parent
c95bd343
Changes
41
Hide whitespace changes
Inline
Side-by-side
Showing
41 changed files
with
3169 additions
and
1863 deletions
+3169
-1863
DataEditorX/CodeEditForm.cs
DataEditorX/CodeEditForm.cs
+178
-110
DataEditorX/Common/Area.cs
DataEditorX/Common/Area.cs
+4
-4
DataEditorX/Common/CheckUpdate.cs
DataEditorX/Common/CheckUpdate.cs
+22
-17
DataEditorX/Common/ConfHelper.cs
DataEditorX/Common/ConfHelper.cs
+16
-2
DataEditorX/Common/MyBitmap.cs
DataEditorX/Common/MyBitmap.cs
+15
-3
DataEditorX/Common/MyPath.cs
DataEditorX/Common/MyPath.cs
+13
-2
DataEditorX/Common/MySortList.cs
DataEditorX/Common/MySortList.cs
+5
-3
DataEditorX/Common/StrUtil.cs
DataEditorX/Common/StrUtil.cs
+16
-8
DataEditorX/Common/XMLReader.cs
DataEditorX/Common/XMLReader.cs
+2
-0
DataEditorX/Common/ZipStorer.cs
DataEditorX/Common/ZipStorer.cs
+141
-69
DataEditorX/Config/CodeConfig.cs
DataEditorX/Config/CodeConfig.cs
+74
-42
DataEditorX/Config/DataConfig.cs
DataEditorX/Config/DataConfig.cs
+18
-18
DataEditorX/Config/DataManager.cs
DataEditorX/Config/DataManager.cs
+22
-4
DataEditorX/Config/ImageSet.cs
DataEditorX/Config/ImageSet.cs
+1
-1
DataEditorX/Config/MyConfig.cs
DataEditorX/Config/MyConfig.cs
+13
-6
DataEditorX/Config/YgoPath.cs
DataEditorX/Config/YgoPath.cs
+21
-21
DataEditorX/Controls/DFlowLayoutPanel.cs
DataEditorX/Controls/DFlowLayoutPanel.cs
+2
-2
DataEditorX/Controls/DListBox.cs
DataEditorX/Controls/DListBox.cs
+2
-2
DataEditorX/Controls/DListView.cs
DataEditorX/Controls/DListView.cs
+2
-2
DataEditorX/Controls/FastColoredTextBoxEx.cs
DataEditorX/Controls/FastColoredTextBoxEx.cs
+34
-19
DataEditorX/Controls/History.cs
DataEditorX/Controls/History.cs
+69
-51
DataEditorX/Controls/MySyntaxHighlighter.cs
DataEditorX/Controls/MySyntaxHighlighter.cs
+20
-19
DataEditorX/Core/Card.cs
DataEditorX/Core/Card.cs
+107
-56
DataEditorX/Core/CardEdit.cs
DataEditorX/Core/CardEdit.cs
+134
-88
DataEditorX/Core/CommandManager.cs
DataEditorX/Core/CommandManager.cs
+19
-15
DataEditorX/Core/DataBase.cs
DataEditorX/Core/DataBase.cs
+213
-134
DataEditorX/Core/LuaFunction.cs
DataEditorX/Core/LuaFunction.cs
+120
-68
DataEditorX/Core/Mse/CardPack.cs
DataEditorX/Core/Mse/CardPack.cs
+5
-2
DataEditorX/Core/Mse/MSEConfig.cs
DataEditorX/Core/Mse/MSEConfig.cs
+79
-53
DataEditorX/Core/Mse/MseMaker.cs
DataEditorX/Core/Mse/MseMaker.cs
+331
-217
DataEditorX/Core/TCGEditor/CardSet.cs
DataEditorX/Core/TCGEditor/CardSet.cs
+1
-1
DataEditorX/Core/TaskHelper.cs
DataEditorX/Core/TaskHelper.cs
+201
-134
DataEditorX/Core/YGOUtil.cs
DataEditorX/Core/YGOUtil.cs
+60
-15
DataEditorX/DataEditForm.Designer.cs
DataEditorX/DataEditForm.Designer.cs
+14
-13
DataEditorX/DataEditForm.cs
DataEditorX/DataEditForm.cs
+883
-513
DataEditorX/Language/LanguageHelper.cs
DataEditorX/Language/LanguageHelper.cs
+72
-36
DataEditorX/Language/MyMsg.cs
DataEditorX/Language/MyMsg.cs
+9
-1
DataEditorX/MainForm.cs
DataEditorX/MainForm.cs
+162
-100
DataEditorX/Program.cs
DataEditorX/Program.cs
+3
-1
DataEditorX/changed.txt
DataEditorX/changed.txt
+2
-0
DataEditorX/data/strings.conf
DataEditorX/data/strings.conf
+64
-11
No files found.
DataEditorX/CodeEditForm.cs
View file @
bc0829bf
...
@@ -28,7 +28,7 @@ public partial class CodeEditForm : DockContent, IEditForm
...
@@ -28,7 +28,7 @@ public partial class CodeEditForm : DockContent, IEditForm
{
{
#
region
Style
#
region
Style
SortedDictionary
<
long
,
string
>
cardlist
;
SortedDictionary
<
long
,
string
>
cardlist
;
MarkerStyle
S
ameWordsStyle
=
new
MarkerStyle
(
new
SolidBrush
(
Color
.
FromArgb
(
40
,
Color
.
White
)));
readonly
MarkerStyle
s
ameWordsStyle
=
new
MarkerStyle
(
new
SolidBrush
(
Color
.
FromArgb
(
40
,
Color
.
White
)));
#
endregion
#
endregion
#
region
init
函数提示菜单
#
region
init
函数提示菜单
...
@@ -43,46 +43,60 @@ public partial class CodeEditForm : DockContent, IEditForm
...
@@ -43,46 +43,60 @@ public partial class CodeEditForm : DockContent, IEditForm
string
nowcdb
;
string
nowcdb
;
public
CodeEditForm
()
public
CodeEditForm
()
{
{
InitForm
();
this
.
InitForm
();
}
}
void
InitForm
()
void
InitForm
()
{
{
cardlist
=
new
SortedDictionary
<
long
,
string
>();
this
.
cardlist
=
new
SortedDictionary
<
long
,
string
>();
tooltipDic
=
new
SortedList
<
string
,
string
>();
t
his
.
t
ooltipDic
=
new
SortedList
<
string
,
string
>();
InitializeComponent
();
this
.
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
,
this
.
fctb
.
Font
.
Size
);
fctb
.
Font
=
new
Font
(
fontname
,
fontsize
);
this
.
fctb
.
Font
=
new
Font
(
fontname
,
fontsize
);
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_IME
))
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_IME
))
fctb
.
ImeMode
=
ImeMode
.
On
;
{
this
.
fctb
.
ImeMode
=
ImeMode
.
On
;
}
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_WORDWRAP
))
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_WORDWRAP
))
fctb
.
WordWrap
=
true
;
{
this
.
fctb
.
WordWrap
=
true
;
}
else
else
fctb
.
WordWrap
=
false
;
{
this
.
fctb
.
WordWrap
=
false
;
}
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_TAB2SPACES
))
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_TAB2SPACES
))
tabisspaces
=
true
;
{
this
.
tabisspaces
=
true
;
}
else
else
tabisspaces
=
false
;
{
this
.
tabisspaces
=
false
;
}
Font
ft
=
new
Font
(
fctb
.
Font
.
Name
,
fctb
.
Font
.
Size
/
1.2f
,
FontStyle
.
Regular
);
Font
ft
=
new
Font
(
this
.
fctb
.
Font
.
Name
,
this
.
fctb
.
Font
.
Size
/
1.2f
,
FontStyle
.
Regular
);
popupMenu
=
new
FastColoredTextBoxNS
.
AutocompleteMenu
(
fctb
);
this
.
popupMenu
=
new
FastColoredTextBoxNS
.
AutocompleteMenu
(
this
.
fctb
)
popupMenu
.
MinFragmentLength
=
2
;
{
popupMenu
.
Items
.
Font
=
ft
;
MinFragmentLength
=
2
popupMenu
.
Items
.
MaximumSize
=
new
System
.
Drawing
.
Size
(
200
,
400
);
};
popupMenu
.
Items
.
Width
=
300
;
this
.
popupMenu
.
Items
.
Font
=
ft
;
popupMenu
.
BackColor
=
fctb
.
BackColor
;
this
.
popupMenu
.
Items
.
MaximumSize
=
new
System
.
Drawing
.
Size
(
200
,
400
);
popupMenu
.
ForeColor
=
fctb
.
ForeColor
;
this
.
popupMenu
.
Items
.
Width
=
300
;
popupMenu
.
Closed
+=
new
ToolStripDropDownClosedEventHandler
(
popupMenu_Closed
);
this
.
popupMenu
.
BackColor
=
this
.
fctb
.
BackColor
;
this
.
popupMenu
.
ForeColor
=
this
.
fctb
.
ForeColor
;
this
.
popupMenu
.
Closed
+=
new
ToolStripDropDownClosedEventHandler
(
this
.
popupMenu_Closed
);
popupMenu
.
SelectedColor
=
Color
.
LightGray
;
this
.
popupMenu
.
SelectedColor
=
Color
.
LightGray
;
title
=
this
.
Text
;
t
his
.
t
itle
=
this
.
Text
;
}
}
void
popupMenu_Closed
(
object
sender
,
ToolStripDropDownClosedEventArgs
e
)
void
popupMenu_Closed
(
object
sender
,
ToolStripDropDownClosedEventArgs
e
)
{
{
popupMenu
.
Items
.
SetAutocompleteItems
(
items
);
this
.
popupMenu
.
Items
.
SetAutocompleteItems
(
this
.
items
);
}
}
#
endregion
#
endregion
...
@@ -93,19 +107,19 @@ public void SetActived()
...
@@ -93,19 +107,19 @@ public void SetActived()
}
}
public
bool
CanOpen
(
string
file
)
public
bool
CanOpen
(
string
file
)
{
{
return
YGOUtil
.
i
sScript
(
file
);
return
YGOUtil
.
I
sScript
(
file
);
}
}
public
string
GetOpenFile
()
public
string
GetOpenFile
()
{
{
return
nowFile
;
return
this
.
nowFile
;
}
}
public
bool
Create
(
string
file
)
public
bool
Create
(
string
file
)
{
{
return
Open
(
file
);
return
this
.
Open
(
file
);
}
}
public
bool
Save
()
public
bool
Save
()
{
{
return
savefile
(
string
.
IsNullOrEmpty
(
nowFile
));
return
this
.
savefile
(
string
.
IsNullOrEmpty
(
this
.
nowFile
));
}
}
public
bool
Open
(
string
file
)
public
bool
Open
(
string
file
)
{
{
...
@@ -116,13 +130,13 @@ public bool Open(string file)
...
@@ -116,13 +130,13 @@ public bool Open(string file)
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
);
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
);
fs
.
Close
();
fs
.
Close
();
}
}
nowFile
=
file
;
this
.
nowFile
=
file
;
string
cdb
=
MyPath
.
Combine
(
string
cdb
=
MyPath
.
Combine
(
Path
.
GetDirectoryName
(
file
),
"../cards.cdb"
);
Path
.
GetDirectoryName
(
file
),
"../cards.cdb"
);
SetCardDB
(
cdb
);
//后台加载卡片数据
this
.
SetCardDB
(
cdb
);
//后台加载卡片数据
fctb
.
OpenFile
(
nowFile
,
new
UTF8Encoding
(
false
));
this
.
fctb
.
OpenFile
(
this
.
nowFile
,
new
UTF8Encoding
(
false
));
oldtext
=
fctb
.
Text
;
this
.
oldtext
=
this
.
fctb
.
Text
;
SetTitle
();
this
.
SetTitle
();
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -134,17 +148,17 @@ public bool Open(string file)
...
@@ -134,17 +148,17 @@ public bool Open(string file)
//文档视图
//文档视图
void
ShowMapToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
ShowMapToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
menuitem_showmap
.
Checked
)
if
(
this
.
menuitem_showmap
.
Checked
)
{
{
documentMap1
.
Visible
=
false
;
this
.
documentMap1
.
Visible
=
false
;
menuitem_showmap
.
Checked
=
false
;
this
.
menuitem_showmap
.
Checked
=
false
;
fctb
.
Width
+=
documentMap1
.
Width
;
this
.
fctb
.
Width
+=
this
.
documentMap1
.
Width
;
}
}
else
else
{
{
documentMap1
.
Visible
=
true
;
this
.
documentMap1
.
Visible
=
true
;
menuitem_showmap
.
Checked
=
true
;
this
.
menuitem_showmap
.
Checked
=
true
;
fctb
.
Width
-=
documentMap1
.
Width
;
this
.
fctb
.
Width
-=
this
.
documentMap1
.
Width
;
}
}
}
}
#
endregion
#
endregion
...
@@ -152,39 +166,51 @@ void ShowMapToolStripMenuItemClick(object sender, EventArgs e)
...
@@ -152,39 +166,51 @@ void ShowMapToolStripMenuItemClick(object sender, EventArgs e)
#
region
设置标题
#
region
设置标题
void
SetTitle
()
void
SetTitle
()
{
{
string
str
=
title
;
string
str
;
if
(
string
.
IsNullOrEmpty
(
nowFile
))
if
(
string
.
IsNullOrEmpty
(
this
.
nowFile
))
str
=
title
;
{
str
=
this
.
title
;
}
else
else
str
=
nowFile
+
"-"
+
title
;
{
str
=
this
.
nowFile
+
"-"
+
this
.
title
;
}
if
(
this
.
MdiParent
!=
null
)
//如果父容器不为空
if
(
this
.
MdiParent
!=
null
)
//如果父容器不为空
{
{
if
(
string
.
IsNullOrEmpty
(
nowFile
))
if
(
string
.
IsNullOrEmpty
(
this
.
nowFile
))
this
.
Text
=
title
;
{
this
.
Text
=
this
.
title
;
}
else
else
this
.
Text
=
Path
.
GetFileName
(
nowFile
);
{
this
.
Text
=
Path
.
GetFileName
(
this
.
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
();
this
.
SetTitle
();
}
}
#
endregion
#
endregion
#
region
自动完成
#
region
自动完成
public
void
LoadXml
(
string
xmlfile
)
public
void
LoadXml
(
string
xmlfile
)
{
{
fctb
.
DescriptionFile
=
xmlfile
;
this
.
fctb
.
DescriptionFile
=
xmlfile
;
}
}
public
void
InitTooltip
(
CodeConfig
codeconfig
)
public
void
InitTooltip
(
CodeConfig
codeconfig
)
{
{
this
.
tooltipDic
=
codeconfig
.
TooltipDic
;
this
.
tooltipDic
=
codeconfig
.
TooltipDic
;
items
=
codeconfig
.
Items
;
this
.
items
=
codeconfig
.
Items
;
popupMenu
.
Items
.
SetAutocompleteItems
(
items
);
this
.
popupMenu
.
Items
.
SetAutocompleteItems
(
this
.
items
);
}
}
#
endregion
#
endregion
...
@@ -193,14 +219,19 @@ public void InitTooltip(CodeConfig codeconfig)
...
@@ -193,14 +219,19 @@ public void InitTooltip(CodeConfig codeconfig)
string
FindTooltip
(
string
word
)
string
FindTooltip
(
string
word
)
{
{
string
desc
=
""
;
string
desc
=
""
;
foreach
(
string
v
in
tooltipDic
.
Keys
)
foreach
(
string
v
in
t
his
.
t
ooltipDic
.
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
=
this
.
tooltipDic
[
v
];
}
}
}
return
desc
;
return
desc
;
}
}
...
@@ -222,11 +253,16 @@ void FctbToolTipNeeded(object sender, ToolTipNeededEventArgs e)
...
@@ -222,11 +253,16 @@ void FctbToolTipNeeded(object sender, ToolTipNeededEventArgs e)
if
(
tl
>
0
)
if
(
tl
>
0
)
{
{
//获取卡片信息
//获取卡片信息
if
(
cardlist
.
ContainsKey
(
tl
))
if
(
this
.
cardlist
.
ContainsKey
(
tl
))
desc
=
cardlist
[
tl
];
{
desc
=
this
.
cardlist
[
tl
];
}
}
}
else
else
desc
=
FindTooltip
(
e
.
HoveredWord
);
{
desc
=
this
.
FindTooltip
(
e
.
HoveredWord
);
}
if
(!
string
.
IsNullOrEmpty
(
desc
))
if
(!
string
.
IsNullOrEmpty
(
desc
))
{
{
e
.
ToolTipTitle
=
e
.
HoveredWord
;
e
.
ToolTipTitle
=
e
.
HoveredWord
;
...
@@ -239,9 +275,12 @@ void FctbToolTipNeeded(object sender, ToolTipNeededEventArgs e)
...
@@ -239,9 +275,12 @@ void FctbToolTipNeeded(object sender, ToolTipNeededEventArgs e)
#
region
保存文件
#
region
保存文件
bool
savefile
(
bool
saveas
)
bool
savefile
(
bool
saveas
)
{
{
string
alltext
=
fctb
.
Text
;
string
alltext
=
this
.
fctb
.
Text
;
if
(!
tabisspaces
)
if
(!
this
.
tabisspaces
)
{
alltext
=
alltext
.
Replace
(
" "
,
"\t"
);
alltext
=
alltext
.
Replace
(
" "
,
"\t"
);
}
if
(
saveas
)
if
(
saveas
)
{
{
using
(
SaveFileDialog
sfdlg
=
new
SaveFileDialog
())
using
(
SaveFileDialog
sfdlg
=
new
SaveFileDialog
())
...
@@ -249,30 +288,32 @@ bool savefile(bool saveas)
...
@@ -249,30 +288,32 @@ bool savefile(bool saveas)
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
;
this
.
nowFile
=
sfdlg
.
FileName
;
SetTitle
();
this
.
SetTitle
();
}
}
else
else
{
return
false
;
return
false
;
}
}
}
}
}
oldtext
=
fctb
.
Text
;
this
.
oldtext
=
this
.
fctb
.
Text
;
File
.
WriteAllText
(
nowFile
,
alltext
,
new
UTF8Encoding
(
false
));
File
.
WriteAllText
(
this
.
nowFile
,
alltext
,
new
UTF8Encoding
(
false
));
return
true
;
return
true
;
}
}
public
bool
SaveAs
()
public
bool
SaveAs
()
{
{
return
savefile
(
true
);
return
this
.
savefile
(
true
);
}
}
void
SaveToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
SaveToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
Save
();
this
.
Save
();
}
}
void
SaveAsToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
SaveAsToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
SaveAs
();
this
.
SaveAs
();
}
}
#
endregion
#
endregion
...
@@ -280,40 +321,43 @@ void SaveAsToolStripMenuItemClick(object sender, EventArgs e)
...
@@ -280,40 +321,43 @@ void SaveAsToolStripMenuItemClick(object sender, EventArgs e)
//显示/隐藏输入框
//显示/隐藏输入框
void
Menuitem_showinputClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_showinputClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
menuitem_showinput
.
Checked
)
if
(
this
.
menuitem_showinput
.
Checked
)
{
{
menuitem_showinput
.
Checked
=
false
;
this
.
menuitem_showinput
.
Checked
=
false
;
tb_input
.
Visible
=
false
;
t
his
.
t
b_input
.
Visible
=
false
;
}
}
else
else
{
{
menuitem_showinput
.
Checked
=
true
;
this
.
menuitem_showinput
.
Checked
=
true
;
tb_input
.
Visible
=
true
;
t
his
.
t
b_input
.
Visible
=
true
;
}
}
}
}
//如果是作为mdi,则隐藏菜单
//如果是作为mdi,则隐藏菜单
void
HideMenu
()
void
HideMenu
()
{
{
if
(
this
.
MdiParent
==
null
)
if
(
this
.
MdiParent
==
null
)
{
return
;
return
;
mainMenu
.
Visible
=
false
;
}
menuitem_file
.
Visible
=
false
;
menuitem_file
.
Enabled
=
false
;
this
.
mainMenu
.
Visible
=
false
;
this
.
menuitem_file
.
Visible
=
false
;
this
.
menuitem_file
.
Enabled
=
false
;
}
}
void
CodeEditFormLoad
(
object
sender
,
EventArgs
e
)
void
CodeEditFormLoad
(
object
sender
,
EventArgs
e
)
{
{
HideMenu
();
this
.
HideMenu
();
fctb
.
OnTextChangedDelayed
(
fctb
.
Range
);
this
.
fctb
.
OnTextChangedDelayed
(
this
.
fctb
.
Range
);
}
}
void
Menuitem_findClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_findClick
(
object
sender
,
EventArgs
e
)
{
{
fctb
.
ShowFindDialog
();
this
.
fctb
.
ShowFindDialog
();
}
}
void
Menuitem_replaceClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_replaceClick
(
object
sender
,
EventArgs
e
)
{
{
fctb
.
ShowReplaceDialog
();
this
.
fctb
.
ShowReplaceDialog
();
}
}
void
QuitToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
QuitToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
...
@@ -326,7 +370,7 @@ void AboutToolStripMenuItemClick(object sender, EventArgs e)
...
@@ -326,7 +370,7 @@ 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
Nanahira
"
);
+
LanguageHelper
.
GetMsg
(
LMSG
.
Author
)
+
"\t
菜菜
"
);
}
}
void
Menuitem_openClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_openClick
(
object
sender
,
EventArgs
e
)
...
@@ -336,8 +380,8 @@ void Menuitem_openClick(object sender, EventArgs e)
...
@@ -336,8 +380,8 @@ void Menuitem_openClick(object sender, EventArgs e)
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
;
this
.
nowFile
=
sfdlg
.
FileName
;
fctb
.
OpenFile
(
nowFile
,
new
UTF8Encoding
(
false
));
this
.
fctb
.
OpenFile
(
this
.
nowFile
,
new
UTF8Encoding
(
false
));
}
}
}
}
}
}
...
@@ -350,15 +394,17 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
...
@@ -350,15 +394,17 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
{
{
if
(
e
.
KeyCode
==
Keys
.
Enter
)
if
(
e
.
KeyCode
==
Keys
.
Enter
)
{
{
string
key
=
tb_input
.
Text
;
string
key
=
t
his
.
t
b_input
.
Text
;
List
<
AutocompleteItem
>
list
=
new
List
<
AutocompleteItem
>();
List
<
AutocompleteItem
>
list
=
new
List
<
AutocompleteItem
>();
foreach
(
AutocompleteItem
item
in
items
)
foreach
(
AutocompleteItem
item
in
this
.
items
)
{
{
if
(
item
.
ToolTipText
.
Contains
(
key
))
if
(
item
.
ToolTipText
.
Contains
(
key
))
{
list
.
Add
(
item
);
list
.
Add
(
item
);
}
}
}
popupMenu
.
Items
.
SetAutocompleteItems
(
list
.
ToArray
());
this
.
popupMenu
.
Items
.
SetAutocompleteItems
(
list
.
ToArray
());
popupMenu
.
Show
(
true
);
this
.
popupMenu
.
Show
(
true
);
}
}
}
}
#
endregion
#
endregion
...
@@ -366,18 +412,22 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
...
@@ -366,18 +412,22 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
#
region
提示保存
#
region
提示保存
void
CodeEditFormFormClosing
(
object
sender
,
FormClosingEventArgs
e
)
void
CodeEditFormFormClosing
(
object
sender
,
FormClosingEventArgs
e
)
{
{
if
(!
string
.
IsNullOrEmpty
(
oldtext
))
if
(!
string
.
IsNullOrEmpty
(
this
.
oldtext
))
{
{
if
(
fctb
.
Text
!=
oldtext
)
if
(
this
.
fctb
.
Text
!=
this
.
oldtext
)
{
{
if
(
MyMsg
.
Question
(
LMSG
.
IfSaveScript
))
if
(
MyMsg
.
Question
(
LMSG
.
IfSaveScript
))
Save
();
{
this
.
Save
();
}
}
}
}
}
else
if
(
fctb
.
Text
.
Length
>
0
)
else
if
(
this
.
fctb
.
Text
.
Length
>
0
)
{
{
if
(
MyMsg
.
Question
(
LMSG
.
IfSaveScript
))
if
(
MyMsg
.
Question
(
LMSG
.
IfSaveScript
))
Save
();
{
this
.
Save
();
}
}
}
}
}
#
endregion
#
endregion
...
@@ -386,43 +436,52 @@ void CodeEditFormFormClosing(object sender, FormClosingEventArgs e)
...
@@ -386,43 +436,52 @@ void CodeEditFormFormClosing(object sender, FormClosingEventArgs e)
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
+=
this
.
MenuItem_Click
;
menuitem_setcard
.
DropDownItems
.
Add
(
tsmi
);
this
.
menuitem_setcard
.
DropDownItems
.
Add
(
tsmi
);
}
}
}
}
void
MenuItem_Click
(
object
sender
,
EventArgs
e
)
void
MenuItem_Click
(
object
sender
,
EventArgs
e
)
{
{
ToolStripMenuItem
tsmi
=
sender
as
ToolStripMenuItem
;
if
(
sender
is
ToolStripMenuItem
tsmi
)
if
(
tsmi
!=
null
)
{
{
string
file
=
tsmi
.
Text
;
string
file
=
tsmi
.
Text
;
SetCardDB
(
file
);
this
.
SetCardDB
(
file
);
}
}
}
}
public
void
SetCardDB
(
string
name
)
public
void
SetCardDB
(
string
name
)
{
{
nowcdb
=
name
;
this
.
nowcdb
=
name
;
if
(!
backgroundWorker1
.
IsBusy
)
if
(!
this
.
backgroundWorker1
.
IsBusy
)
backgroundWorker1
.
RunWorkerAsync
();
{
this
.
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
(
this
.
nowcdb
!=
null
&&
File
.
Exists
(
this
.
nowcdb
))
SetCards
(
DataBase
.
Read
(
nowcdb
,
true
,
""
));
{
this
.
SetCards
(
DataBase
.
Read
(
this
.
nowcdb
,
true
,
""
));
}
}
}
public
void
SetCards
(
Card
[]
cards
)
public
void
SetCards
(
Card
[]
cards
)
{
{
if
(
cards
==
null
)
if
(
cards
==
null
)
{
return
;
return
;
cardlist
.
Clear
();
}
this
.
cardlist
.
Clear
();
foreach
(
Card
c
in
cards
)
foreach
(
Card
c
in
cards
)
{
{
cardlist
.
Add
(
c
.
id
,
c
.
ToString
());
this
.
cardlist
.
Add
(
c
.
id
,
c
.
ToString
());
}
}
}
}
#
endregion
#
endregion
...
@@ -430,36 +489,45 @@ public void SetCards(Card[] cards)
...
@@ -430,36 +489,45 @@ public void SetCards(Card[] cards)
#
region
选择高亮
#
region
选择高亮
void
FctbSelectionChangedDelayed
(
object
sender
,
EventArgs
e
)
void
FctbSelectionChangedDelayed
(
object
sender
,
EventArgs
e
)
{
{
tb_input
.
Text
=
fctb
.
SelectedText
;
this
.
tb_input
.
Text
=
this
.
fctb
.
SelectedText
;
fctb
.
VisibleRange
.
ClearStyle
(
SameWordsStyle
);
this
.
fctb
.
VisibleRange
.
ClearStyle
(
this
.
sameWordsStyle
);
if
(!
fctb
.
Selection
.
IsEmpty
)
if
(!
this
.
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
=
this
.
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
=
this
.
fctb
.
VisibleRange
.
GetRanges
(
"\\b"
+
text
+
"\\b"
);
foreach
(
var
r
in
ranges
)
foreach
(
var
r
in
ranges
)
r
.
SetStyle
(
SameWordsStyle
);
{
r
.
SetStyle
(
this
.
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
=
this
.
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
=
this
.
fctb
.
FindLines
(
@"function\s+?\S+?\."
+
text
+
@"\("
,
RegexOptions
.
Singleline
);
if
(
linenums
.
Count
>
0
)
if
(
linenums
.
Count
>
0
)
{
{
fctb
.
Navigate
(
linenums
[
0
]);
this
.
fctb
.
Navigate
(
linenums
[
0
]);
//MessageBox.Show(linenums[0].ToString());
//MessageBox.Show(linenums[0].ToString());
}
}
}
}
...
...
DataEditorX/Common/Area.cs
View file @
bc0829bf
...
@@ -8,10 +8,10 @@ public class Area
...
@@ -8,10 +8,10 @@ public class Area
{
{
public
Area
()
public
Area
()
{
{
left
=
0
;
this
.
left
=
0
;
top
=
0
;
t
his
.
t
op
=
0
;
width
=
0
;
this
.
width
=
0
;
height
=
0
;
this
.
height
=
0
;
}
}
/// <summary>
/// <summary>
/// 左
/// 左
...
...
DataEditorX/Common/CheckUpdate.cs
View file @
bc0829bf
...
@@ -78,21 +78,23 @@ public static bool CheckVersion(string ver, string oldver)
...
@@ -78,21 +78,23 @@ public static bool CheckVersion(string ver, string oldver)
string
[]
oldvers
=
oldver
.
Split
(
'.'
);
string
[]
oldvers
=
oldver
.
Split
(
'.'
);
if
(
vers
.
Length
==
oldvers
.
Length
)
if
(
vers
.
Length
==
oldvers
.
Length
)
{
{
int
j
,
k
;
//从左到右比较数字
//从左到右比较数字
for
(
int
i
=
0
;
i
<
oldvers
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
oldvers
.
Length
;
i
++)
{
{
int
.
TryParse
(
vers
[
i
],
out
j
);
int
.
TryParse
(
vers
[
i
],
out
int
j
);
int
.
TryParse
(
oldvers
[
i
],
out
k
);
int
.
TryParse
(
oldvers
[
i
],
out
int
k
);
if
(
j
>
k
)
//新的版本号大于旧的
if
(
j
>
k
)
//新的版本号大于旧的
{
{
hasNew
=
true
;
hasNew
=
true
;
break
;
break
;
}
else
if
(
j
<
k
){
}
hasNew
=
false
;
else
if
(
j
<
k
)
break
;
{
}
hasNew
=
false
;
}
break
;
}
}
}
}
return
hasNew
;
return
hasNew
;
}
}
#
endregion
#
endregion
...
@@ -147,8 +149,11 @@ public static bool DownLoad(string filename)
...
@@ -147,8 +149,11 @@ public static bool DownLoad(string filename)
try
try
{
{
if
(
File
.
Exists
(
filename
))
if
(
File
.
Exists
(
filename
))
File
.
Delete
(
filename
);
{
HttpWebRequest
Myrq
=
(
HttpWebRequest
)
System
.
Net
.
HttpWebRequest
.
Create
(
URL
);
File
.
Delete
(
filename
);
}
HttpWebRequest
Myrq
=
(
HttpWebRequest
)
System
.
Net
.
HttpWebRequest
.
Create
(
URL
);
HttpWebResponse
myrp
=
(
HttpWebResponse
)
Myrq
.
GetResponse
();
HttpWebResponse
myrp
=
(
HttpWebResponse
)
Myrq
.
GetResponse
();
long
totalBytes
=
myrp
.
ContentLength
;
long
totalBytes
=
myrp
.
ContentLength
;
...
...
DataEditorX/Common/ConfHelper.cs
View file @
bc0829bf
...
@@ -20,7 +20,10 @@ public static string getValue(string line)
...
@@ -20,7 +20,10 @@ 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>
...
@@ -32,7 +35,10 @@ public static string getValue1(string word)
...
@@ -32,7 +35,10 @@ 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>
...
@@ -44,7 +50,10 @@ public static string getValue2(string word)
...
@@ -44,7 +50,10 @@ 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>
...
@@ -78,9 +87,13 @@ public static string getRegex(string word)
...
@@ -78,9 +87,13 @@ public static string getRegex(string word)
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值
...
@@ -113,10 +126,11 @@ public static void DicAdd(SortedList<long, string> dic, string line)
...
@@ -113,10 +126,11 @@ public static void DicAdd(SortedList<long, string> dic, string line)
{
{
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
.
TryParse
(
strkey
,
NumberStyles
.
HexNumber
,
null
,
out
long
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 @
bc0829bf
...
@@ -17,7 +17,10 @@ public static class MyBitmap
...
@@ -17,7 +17,10 @@ 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
);
}
}
...
@@ -124,9 +127,15 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
...
@@ -124,9 +127,15 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
{
{
string
path
=
Path
.
GetDirectoryName
(
filename
);
string
path
=
Path
.
GetDirectoryName
(
filename
);
if
(!
Directory
.
Exists
(
path
))
//创建文件夹
if
(!
Directory
.
Exists
(
path
))
//创建文件夹
Directory
.
CreateDirectory
(
path
);
{
if
(
File
.
Exists
(
filename
))
//删除旧文件
Directory
.
CreateDirectory
(
path
);
File
.
Delete
(
filename
);
}
if
(
File
.
Exists
(
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
)
...
@@ -138,7 +147,10 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
...
@@ -138,7 +147,10 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
}
}
}
}
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
)
...
...
DataEditorX/Common/MyPath.cs
View file @
bc0829bf
...
@@ -52,7 +52,7 @@ public static string Combine(params string[] paths)
...
@@ -52,7 +52,7 @@ public static string Combine(params string[] paths)
}
}
if
(!
firstPath
.
EndsWith
(
spliter
))
if
(!
firstPath
.
EndsWith
(
spliter
))
{
{
firstPath
=
firstPath
+
spliter
;
firstPath
+=
spliter
;
}
}
builder
.
Append
(
firstPath
);
builder
.
Append
(
firstPath
);
for
(
int
i
=
1
;
i
<
paths
.
Length
;
i
++)
for
(
int
i
=
1
;
i
<
paths
.
Length
;
i
++)
...
@@ -70,7 +70,7 @@ public static string Combine(params string[] paths)
...
@@ -70,7 +70,7 @@ public static string Combine(params string[] paths)
}
}
else
else
{
{
nextPath
=
nextPath
+
spliter
;
nextPath
+=
spliter
;
}
}
}
}
builder
.
Append
(
nextPath
);
builder
.
Append
(
nextPath
);
...
@@ -96,7 +96,10 @@ public static string CheckDir(string dir,string defalut)
...
@@ -96,7 +96,10 @@ public static string CheckDir(string dir,string defalut)
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
;
}
}
...
@@ -121,21 +124,29 @@ public static string getFullFileName(string tag, string file)
...
@@ -121,21 +124,29 @@ 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/MySortList.cs
View file @
bc0829bf
...
@@ -32,9 +32,11 @@ public new void Add(K key, V value)
...
@@ -32,9 +32,11 @@ public new void Add(K key, V value)
}
}
}
}
if
(
flag
==
1
)
if
(
flag
==
1
)
return
;
//跳出函数
{
//否则就加入
return
;
//跳出函数
base
.
Add
(
key
,
value
);
}
//否则就加入
base
.
Add
(
key
,
value
);
}
}
}
}
}
}
DataEditorX/Common/StrUtil.cs
View file @
bc0829bf
...
@@ -9,22 +9,30 @@ public class StrUtil
...
@@ -9,22 +9,30 @@ public class StrUtil
public
static
string
AutoEnter
(
string
str
,
int
lineNum
,
char
re
)
public
static
string
AutoEnter
(
string
str
,
int
lineNum
,
char
re
)
{
{
if
(
str
==
null
||
str
.
Length
==
0
)
if
(
str
==
null
||
str
.
Length
==
0
)
return
""
;
{
str
=
" "
+
str
.
Replace
(
"\r\n"
,
"\n"
);
return
""
;
}
str
=
" "
+
str
.
Replace
(
"\r\n"
,
"\n"
);
char
[]
ch
=
str
.
ToCharArray
();
char
[]
ch
=
str
.
ToCharArray
();
int
count
=
ch
.
Length
;
_
=
ch
.
Length
;
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
int
i
=
0
;
int
i
=
0
;
foreach
(
char
c
in
ch
)
foreach
(
char
c
in
ch
)
{
{
int
ic
=
c
;
int
ic
=
c
;
if
(
ic
>
128
)
if
(
ic
>
128
)
i
+=
2
;
{
else
i
+=
2
;
i
+=
1
;
}
if
(
c
==
'\n'
||
c
==
'\r'
)
else
{
i
+=
1
;
}
if
(
c
==
'\n'
||
c
==
'\r'
)
{
{
sb
.
Append
(
re
);
sb
.
Append
(
re
);
i
=
0
;
i
=
0
;
...
...
DataEditorX/Common/XMLReader.cs
View file @
bc0829bf
...
@@ -25,7 +25,9 @@ public static void Save(string appKey, string appValue)
...
@@ -25,7 +25,9 @@ public static void Save(string appKey, string appValue)
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"
);
...
...
DataEditorX/Common/ZipStorer.cs
View file @
bc0829bf
...
@@ -68,7 +68,7 @@ public override string ToString()
...
@@ -68,7 +68,7 @@ public override string ToString()
#
region
Private
fields
#
region
Private
fields
// List of files to store
// List of files to store
private
List
<
ZipFileEntry
>
Files
=
new
List
<
ZipFileEntry
>();
private
readonly
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
...
@@ -82,9 +82,9 @@ public override string ToString()
...
@@ -82,9 +82,9 @@ public override string ToString()
// 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
readonly
uint
[]
CrcTable
=
null
;
// Default filename encoder
// Default filename encoder
private
static
Encoding
DefaultEncoding
=
Encoding
.
GetEncoding
(
437
);
private
static
readonly
Encoding
DefaultEncoding
=
Encoding
.
GetEncoding
(
437
);
#
endregion
#
endregion
#
region
Public
methods
#
region
Public
methods
...
@@ -92,16 +92,20 @@ public override string ToString()
...
@@ -92,16 +92,20 @@ public override string ToString()
static
ZipStorer
()
static
ZipStorer
()
{
{
// Generate CRC32 table
// Generate CRC32 table
CrcTable
=
new
UInt32
[
256
];
CrcTable
=
new
uint
[
256
];
for
(
int
i
=
0
;
i
<
CrcTable
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
CrcTable
.
Length
;
i
++)
{
{
UInt32
c
=
(
UInt32
)
i
;
uint
c
=
(
uint
)
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
;
}
}
...
@@ -130,10 +134,12 @@ public static ZipStorer Create(string _filename, string _comment)
...
@@ -130,10 +134,12 @@ public static ZipStorer Create(string _filename, string _comment)
/// <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
.
ZipFileStream
=
_stream
;
Comment
=
_comment
,
zip
.
Access
=
FileAccess
.
Write
;
ZipFileStream
=
_stream
,
Access
=
FileAccess
.
Write
};
return
zip
;
return
zip
;
}
}
...
@@ -161,15 +167,21 @@ public static ZipStorer Open(string _filename, FileAccess _access)
...
@@ -161,15 +167,21 @@ public static ZipStorer Open(string _filename, FileAccess _access)
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
.
ZipFileStream
=
_stream
;
//zip.FileName = _filename;
zip
.
Access
=
_access
;
ZipFileStream
=
_stream
,
Access
=
_access
};
if
(
zip
.
ReadFileInfo
())
if
(
zip
.
ReadFileInfo
())
{
return
zip
;
return
zip
;
}
throw
new
System
.
IO
.
InvalidDataException
();
throw
new
System
.
IO
.
InvalidDataException
();
}
}
...
@@ -183,11 +195,13 @@ public static ZipStorer Open(Stream _stream, FileAccess _access)
...
@@ -183,11 +195,13 @@ public static ZipStorer Open(Stream _stream, FileAccess _access)
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
(
this
.
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
);
this
.
AddStream
(
_method
,
_filenameInZip
,
stream
,
File
.
GetLastWriteTime
(
_pathname
),
_comment
);
stream
.
Close
();
stream
.
Close
();
}
}
/// <summary>
/// <summary>
...
@@ -199,11 +213,13 @@ public void AddFile(string _pathname, string _filenameInZip, string _comment)
...
@@ -199,11 +213,13 @@ public void AddFile(string _pathname, string _filenameInZip, string _comment)
/// <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
(
this
.
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
);
this
.
AddStream
(
_method
,
_filenameInZip
,
stream
,
File
.
GetLastWriteTime
(
_pathname
),
_comment
);
stream
.
Close
();
stream
.
Close
();
}
}
/// <summary>
/// <summary>
...
@@ -216,41 +232,45 @@ public void AddFile(Compression _method, string _pathname, string _filenameInZip
...
@@ -216,41 +232,45 @@ public void AddFile(Compression _method, string _pathname, string _filenameInZip
/// <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
(
this
.
Access
==
FileAccess
.
Read
)
{
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
}
long
offset
;
if
(
this
.
Files
.
Count
==
0
)
if
(
this
.
Files
.
Count
==
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
;
_
=
last
.
HeaderOffset
+
last
.
HeaderSize
;
}
}
// Prepare the fileinfo
// Prepare the fileinfo
ZipFileEntry
zfe
=
new
ZipFileEntry
();
ZipFileEntry
zfe
=
new
ZipFileEntry
zfe
.
Method
=
_method
;
{
zfe
.
EncodeUTF8
=
this
.
EncodeUTF8
;
Method
=
_method
,
zfe
.
FilenameInZip
=
NormalizedFilename
(
_filenameInZip
);
EncodeUTF8
=
this
.
EncodeUTF8
,
zfe
.
Comment
=
(
_comment
==
null
?
""
:
_comment
);
FilenameInZip
=
this
.
NormalizedFilename
(
_filenameInZip
),
Comment
=
(
_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
Crc32
=
0
,
// to be updated later
zfe
.
HeaderOffset
=
(
uint
)
this
.
ZipFileStream
.
Position
;
// offset within file of the start of this local record
HeaderOffset
=
(
uint
)
this
.
ZipFileStream
.
Position
,
// offset within file of the start of this local record
zfe
.
ModifyTime
=
_modTime
;
ModifyTime
=
_modTime
};
// Write local header
// Write local header
WriteLocalHeader
(
ref
zfe
);
this
.
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
);
this
.
Store
(
ref
zfe
,
_source
);
_source
.
Close
();
_source
.
Close
();
this
.
UpdateCrcAndSizes
(
ref
zfe
);
this
.
UpdateCrcAndSizes
(
ref
zfe
);
Files
.
Add
(
zfe
);
this
.
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
...
@@ -264,19 +284,25 @@ public void Close()
...
@@ -264,19 +284,25 @@ public void Close()
uint
centralSize
=
0
;
uint
centralSize
=
0
;
if
(
this
.
CentralDirImage
!=
null
)
if
(
this
.
CentralDirImage
!=
null
)
this
.
ZipFileStream
.
Write
(
CentralDirImage
,
0
,
CentralDirImage
.
Length
);
{
this
.
ZipFileStream
.
Write
(
this
.
CentralDirImage
,
0
,
this
.
CentralDirImage
.
Length
);
}
for
(
int
i
=
0
;
i
<
Files
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
this
.
Files
.
Count
;
i
++)
{
{
long
pos
=
this
.
ZipFileStream
.
Position
;
long
pos
=
this
.
ZipFileStream
.
Position
;
this
.
WriteCentralDirRecord
(
Files
[
i
]);
this
.
WriteCentralDirRecord
(
this
.
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
)
this
.
CentralDirImage
.
Length
,
centralOffset
);
}
else
else
{
this
.
WriteEndRecord
(
centralSize
,
centralOffset
);
this
.
WriteEndRecord
(
centralSize
,
centralOffset
);
}
}
}
if
(
this
.
ZipFileStream
!=
null
)
if
(
this
.
ZipFileStream
!=
null
)
...
@@ -293,42 +319,50 @@ public void Close()
...
@@ -293,42 +319,50 @@ public void Close()
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
(
this
.
CentralDirImage
,
pointer
);
if
(
signature
!=
0x02014b50
)
if
(
signature
!=
0x02014b50
)
{
break
;
break
;
}
bool
encodeUTF8
=
(
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
8
)
&
0x0800
)
!=
0
;
bool
encodeUTF8
=
(
BitConverter
.
ToUInt16
(
this
.
CentralDirImage
,
pointer
+
8
)
&
0x0800
)
!=
0
;
ushort
method
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
10
);
ushort
method
=
BitConverter
.
ToUInt16
(
this
.
CentralDirImage
,
pointer
+
10
);
uint
modifyTime
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
12
);
uint
modifyTime
=
BitConverter
.
ToUInt32
(
this
.
CentralDirImage
,
pointer
+
12
);
uint
crc32
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
16
);
uint
crc32
=
BitConverter
.
ToUInt32
(
this
.
CentralDirImage
,
pointer
+
16
);
uint
comprSize
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
20
);
uint
comprSize
=
BitConverter
.
ToUInt32
(
this
.
CentralDirImage
,
pointer
+
20
);
uint
fileSize
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
24
);
uint
fileSize
=
BitConverter
.
ToUInt32
(
this
.
CentralDirImage
,
pointer
+
24
);
ushort
filenameSize
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
28
);
ushort
filenameSize
=
BitConverter
.
ToUInt16
(
this
.
CentralDirImage
,
pointer
+
28
);
ushort
extraSize
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
30
);
ushort
extraSize
=
BitConverter
.
ToUInt16
(
this
.
CentralDirImage
,
pointer
+
30
);
ushort
commentSize
=
BitConverter
.
ToUInt16
(
CentralDirImage
,
pointer
+
32
);
ushort
commentSize
=
BitConverter
.
ToUInt16
(
this
.
CentralDirImage
,
pointer
+
32
);
uint
headerOffset
=
BitConverter
.
ToUInt32
(
CentralDirImage
,
pointer
+
42
);
uint
headerOffset
=
BitConverter
.
ToUInt32
(
this
.
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
.
FilenameInZip
=
encoder
.
GetString
(
CentralDirImage
,
pointer
+
46
,
filenameSize
);
Method
=
(
Compression
)
method
,
zfe
.
FileOffset
=
GetFileOffset
(
headerOffset
);
FilenameInZip
=
encoder
.
GetString
(
this
.
CentralDirImage
,
pointer
+
46
,
filenameSize
),
zfe
.
FileSize
=
fileSize
;
FileOffset
=
this
.
GetFileOffset
(
headerOffset
),
zfe
.
CompressedSize
=
comprSize
;
FileSize
=
fileSize
,
zfe
.
HeaderOffset
=
headerOffset
;
CompressedSize
=
comprSize
,
zfe
.
HeaderSize
=
headerSize
;
HeaderOffset
=
headerOffset
,
zfe
.
Crc32
=
crc32
;
HeaderSize
=
headerSize
,
zfe
.
ModifyTime
=
DosTimeToDateTime
(
modifyTime
);
Crc32
=
crc32
,
ModifyTime
=
this
.
DosTimeToDateTime
(
modifyTime
)
};
if
(
commentSize
>
0
)
if
(
commentSize
>
0
)
zfe
.
Comment
=
encoder
.
GetString
(
CentralDirImage
,
pointer
+
46
+
filenameSize
+
extraSize
,
commentSize
);
{
zfe
.
Comment
=
encoder
.
GetString
(
this
.
CentralDirImage
,
pointer
+
46
+
filenameSize
+
extraSize
,
commentSize
);
}
result
.
Add
(
zfe
);
result
.
Add
(
zfe
);
pointer
+=
(
46
+
filenameSize
+
extraSize
+
commentSize
);
pointer
+=
(
46
+
filenameSize
+
extraSize
+
commentSize
);
...
@@ -349,15 +383,21 @@ public bool ExtractFile(ZipFileEntry _zfe, string _filename)
...
@@ -349,15 +383,21 @@ public bool ExtractFile(ZipFileEntry _zfe, string _filename)
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
=
this
.
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
);
...
@@ -374,23 +414,33 @@ public bool ExtractFile(ZipFileEntry _zfe, string _filename)
...
@@ -374,23 +414,33 @@ public bool ExtractFile(ZipFileEntry _zfe, string _filename)
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
];
...
@@ -405,7 +455,10 @@ public bool ExtractFile(ZipFileEntry _zfe, Stream _stream)
...
@@ -405,7 +455,10 @@ public bool ExtractFile(ZipFileEntry _zfe, Stream _stream)
_stream
.
Flush
();
_stream
.
Flush
();
if
(
_zfe
.
Method
==
Compression
.
Deflate
)
if
(
_zfe
.
Method
==
Compression
.
Deflate
)
{
inStream
.
Dispose
();
inStream
.
Dispose
();
}
return
true
;
return
true
;
}
}
/// <summary>
/// <summary>
...
@@ -418,7 +471,9 @@ public bool ExtractFile(ZipFileEntry _zfe, Stream _stream)
...
@@ -418,7 +471,9 @@ public bool ExtractFile(ZipFileEntry _zfe, Stream _stream)
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
...
@@ -457,9 +512,14 @@ public static bool RemoveEntries(ref ZipStorer _zip, List<ZipFileEntry> _zfes)
...
@@ -457,9 +512,14 @@ public static bool RemoveEntries(ref ZipStorer _zip, List<ZipFileEntry> _zfes)
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
;
}
}
...
@@ -504,7 +564,7 @@ private void WriteLocalHeader(ref ZipFileEntry _zfe)
...
@@ -504,7 +564,7 @@ private void WriteLocalHeader(ref ZipFileEntry _zfe)
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
(
this
.
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
...
@@ -544,7 +604,7 @@ private void WriteCentralDirRecord(ZipFileEntry _zfe)
...
@@ -544,7 +604,7 @@ private void WriteCentralDirRecord(ZipFileEntry _zfe)
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
(
this
.
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
...
@@ -583,8 +643,8 @@ private void WriteEndRecord(uint _size, uint _offset)
...
@@ -583,8 +643,8 @@ private void WriteEndRecord(uint _size, uint _offset)
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
)
this
.
Files
.
Count
+
this
.
ExistingFiles
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
Files
.
Count
+
ExistingFiles
),
0
,
2
);
this
.
ZipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
this
.
Files
.
Count
+
this
.
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
);
...
@@ -602,9 +662,13 @@ private void Store(ref ZipFileEntry _zfe, Stream _source)
...
@@ -602,9 +662,13 @@ private void Store(ref ZipFileEntry _zfe, Stream _source)
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
;
...
@@ -625,7 +689,9 @@ private void Store(ref ZipFileEntry _zfe, Stream _source)
...
@@ -625,7 +689,9 @@ private void Store(ref ZipFileEntry _zfe, Stream _source)
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
;
...
@@ -702,7 +768,9 @@ private string NormalizedFilename(string _filename)
...
@@ -702,7 +768,9 @@ private string NormalizedFilename(string _filename)
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
(
'/'
);
}
}
...
@@ -710,7 +778,9 @@ private string NormalizedFilename(string _filename)
...
@@ -710,7 +778,9 @@ private string NormalizedFilename(string _filename)
private
bool
ReadFileInfo
()
private
bool
ReadFileInfo
()
{
{
if
(
this
.
ZipFileStream
.
Length
<
22
)
if
(
this
.
ZipFileStream
.
Length
<
22
)
{
return
false
;
return
false
;
}
try
try
{
{
...
@@ -719,19 +789,21 @@ private bool ReadFileInfo()
...
@@ -719,19 +789,21 @@ private bool ReadFileInfo()
do
do
{
{
this
.
ZipFileStream
.
Seek
(-
5
,
SeekOrigin
.
Current
);
this
.
ZipFileStream
.
Seek
(-
5
,
SeekOrigin
.
Current
);
UInt32
sig
=
br
.
ReadUInt32
();
uint
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
();
ushort
entries
=
br
.
ReadUInt16
();
Int32
centralSize
=
br
.
ReadInt32
();
int
centralSize
=
br
.
ReadInt32
();
UInt32
centralDirOffset
=
br
.
ReadUInt32
();
uint
centralDirOffset
=
br
.
ReadUInt32
();
UInt16
commentSize
=
br
.
ReadUInt16
();
ushort
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
;
...
...
DataEditorX/Config/CodeConfig.cs
View file @
bc0829bf
...
@@ -15,29 +15,29 @@ public class CodeConfig
...
@@ -15,29 +15,29 @@ public class CodeConfig
#
region
成员
#
region
成员
public
CodeConfig
()
public
CodeConfig
()
{
{
tooltipDic
=
new
SortedList
<
string
,
string
>();
t
his
.
t
ooltipDic
=
new
SortedList
<
string
,
string
>();
longTooltipDic
=
new
SortedList
<
string
,
string
>();
this
.
longTooltipDic
=
new
SortedList
<
string
,
string
>();
items
=
new
List
<
AutocompleteItem
>();
this
.
items
=
new
List
<
AutocompleteItem
>();
}
}
//函数提示
//函数提示
SortedList
<
string
,
string
>
tooltipDic
;
readonly
SortedList
<
string
,
string
>
tooltipDic
;
SortedList
<
string
,
string
>
longTooltipDic
;
readonly
SortedList
<
string
,
string
>
longTooltipDic
;
List
<
AutocompleteItem
>
items
;
readonly
List
<
AutocompleteItem
>
items
;
/// <summary>
/// <summary>
/// 输入提示
/// 输入提示
/// </summary>
/// </summary>
public
SortedList
<
string
,
string
>
TooltipDic
public
SortedList
<
string
,
string
>
TooltipDic
{
{
get
{
return
tooltipDic
;
}
get
{
return
t
his
.
t
ooltipDic
;
}
}
}
public
SortedList
<
string
,
string
>
LongTooltipDic
public
SortedList
<
string
,
string
>
LongTooltipDic
{
{
get
{
return
longTooltipDic
;
}
get
{
return
this
.
longTooltipDic
;
}
}
}
public
AutocompleteItem
[]
Items
public
AutocompleteItem
[]
Items
{
{
get
{
return
items
.
ToArray
();
}
get
{
return
this
.
items
.
ToArray
();
}
}
}
#
endregion
#
endregion
...
@@ -51,9 +51,9 @@ public void SetNames(Dictionary<long, string> dic)
...
@@ -51,9 +51,9 @@ 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
(!
t
his
.
t
ooltipDic
.
ContainsKey
(
key
))
{
{
AddToolIipDic
(
key
,
dic
[
k
]);
this
.
AddToolIipDic
(
key
,
dic
[
k
]);
}
}
}
}
}
}
...
@@ -75,7 +75,7 @@ public void AddStrings(string file)
...
@@ -75,7 +75,7 @@ public void AddStrings(string file)
string
[]
ws
=
line
.
Split
(
' '
);
string
[]
ws
=
line
.
Split
(
' '
);
if
(
ws
.
Length
>
2
)
if
(
ws
.
Length
>
2
)
{
{
AddToolIipDic
(
ws
[
1
],
ws
[
2
]);
this
.
AddToolIipDic
(
ws
[
1
],
ws
[
2
]);
}
}
}
}
}
}
...
@@ -88,7 +88,10 @@ public void AddStrings(string file)
...
@@ -88,7 +88,10 @@ public void AddStrings(string file)
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
=
""
;
...
@@ -98,11 +101,14 @@ public void AddFunction(string funtxt)
...
@@ -98,11 +101,14 @@ public void AddFunction(string funtxt)
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
);
this
.
AddToolIipDic
(
name
,
desc
);
int
w
=
line
.
IndexOf
(
"("
);
int
w
=
line
.
IndexOf
(
"("
);
int
t
=
line
.
IndexOf
(
" "
);
int
t
=
line
.
IndexOf
(
" "
);
...
@@ -119,7 +125,7 @@ public void AddFunction(string funtxt)
...
@@ -119,7 +125,7 @@ public void AddFunction(string funtxt)
desc
+=
Environment
.
NewLine
+
line
;
desc
+=
Environment
.
NewLine
+
line
;
}
}
}
}
AddToolIipDic
(
name
,
desc
);
this
.
AddToolIipDic
(
name
,
desc
);
}
}
#
endregion
#
endregion
...
@@ -128,21 +134,26 @@ public void AddConstant(string conlua)
...
@@ -128,21 +134,26 @@ 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
;
}
int
t
=
line
.
IndexOf
(
"="
);
int
t
=
line
.
IndexOf
(
"="
);
int
t2
=
line
.
IndexOf
(
"--"
);
_
=
line
.
IndexOf
(
"--"
);
//常量 = 0x1 ---注释
//常量 = 0x1 ---注释
k
=
(
t
>
0
)
?
line
.
Substring
(
0
,
t
).
TrimEnd
(
new
char
[]
{
' '
,
'\t'
})
string
k
=
(
t
>
0
)
?
line
.
Substring
(
0
,
t
).
TrimEnd
(
new
char
[]
{
' '
,
'\t'
})
:
line
;
:
line
;
desc
=
(
t
>
0
)
?
line
.
Substring
(
t
+
1
).
Replace
(
"--"
,
"\n"
)
string
desc
=
(
t
>
0
)
?
line
.
Substring
(
t
+
1
).
Replace
(
"--"
,
"\n"
)
:
line
;
:
line
;
AddToolIipDic
(
k
,
desc
);
this
.
AddToolIipDic
(
k
,
desc
);
}
}
}
}
#
endregion
#
endregion
...
@@ -150,60 +161,81 @@ public void AddConstant(string conlua)
...
@@ -150,60 +161,81 @@ public void AddConstant(string conlua)
#
region
处理
#
region
处理
public
void
InitAutoMenus
()
public
void
InitAutoMenus
()
{
{
items
.
Clear
();
this
.
items
.
Clear
();
foreach
(
string
k
in
tooltipDic
.
Keys
)
foreach
(
string
k
in
t
his
.
t
ooltipDic
.
Keys
)
{
{
AutocompleteItem
item
=
new
AutocompleteItem
(
k
);
AutocompleteItem
item
=
new
AutocompleteItem
(
k
)
item
.
ToolTipTitle
=
k
;
{
item
.
ToolTipText
=
tooltipDic
[
k
];
ToolTipTitle
=
k
,
items
.
Add
(
item
);
ToolTipText
=
this
.
tooltipDic
[
k
]
};
this
.
items
.
Add
(
item
);
}
}
foreach
(
string
k
in
longTooltipDic
.
Keys
)
foreach
(
string
k
in
this
.
longTooltipDic
.
Keys
)
{
{
if
(
tooltipDic
.
ContainsKey
(
k
))
if
(
this
.
tooltipDic
.
ContainsKey
(
k
))
{
continue
;
continue
;
AutocompleteItem
item
=
new
AutocompleteItem
(
k
);
}
item
.
ToolTipTitle
=
k
;
item
.
ToolTipText
=
longTooltipDic
[
k
];
AutocompleteItem
item
=
new
AutocompleteItem
(
k
)
items
.
Add
(
item
);
{
ToolTipTitle
=
k
,
ToolTipText
=
this
.
longTooltipDic
[
k
]
};
this
.
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
=
this
.
GetShortName
(
key
);
if
(
tooltipDic
.
ContainsKey
(
skey
))
//存在
if
(
t
his
.
t
ooltipDic
.
ContainsKey
(
skey
))
//存在
{
{
string
nval
=
tooltipDic
[
skey
];
string
nval
=
t
his
.
t
ooltipDic
[
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
;
t
his
.
t
ooltipDic
[
skey
]
=
nval
;
}
}
else
else
tooltipDic
.
Add
(
skey
,
val
);
{
this
.
tooltipDic
.
Add
(
skey
,
val
);
}
//
//
AddLongToolIipDic
(
key
,
val
);
this
.
AddLongToolIipDic
(
key
,
val
);
}
}
void
AddLongToolIipDic
(
string
key
,
string
val
)
void
AddLongToolIipDic
(
string
key
,
string
val
)
{
{
if
(
longTooltipDic
.
ContainsKey
(
key
))
//存在
if
(
this
.
longTooltipDic
.
ContainsKey
(
key
))
//存在
{
{
string
nval
=
longTooltipDic
[
key
];
string
nval
=
this
.
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
;
this
.
longTooltipDic
[
key
]
=
nval
;
}
}
else
else
longTooltipDic
.
Add
(
key
,
val
);
{
this
.
longTooltipDic
.
Add
(
key
,
val
);
}
}
}
#
endregion
#
endregion
}
}
...
...
DataEditorX/Config/DataConfig.cs
View file @
bc0829bf
...
@@ -18,11 +18,11 @@ public class DataConfig
...
@@ -18,11 +18,11 @@ public class DataConfig
{
{
public
DataConfig
()
public
DataConfig
()
{
{
InitMember
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_CARDINFO
+
".txt"
));
this
.
InitMember
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_CARDINFO
+
".txt"
));
}
}
public
DataConfig
(
string
conf
)
public
DataConfig
(
string
conf
)
{
{
InitMember
(
conf
);
this
.
InitMember
(
conf
);
}
}
/// <summary>
/// <summary>
/// 初始化成员
/// 初始化成员
...
@@ -33,26 +33,26 @@ public void InitMember(string conf)
...
@@ -33,26 +33,26 @@ 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
>();
this
.
dicCardRules
=
new
Dictionary
<
long
,
string
>();
dicSetnames
=
new
Dictionary
<
long
,
string
>();
this
.
dicSetnames
=
new
Dictionary
<
long
,
string
>();
dicCardTypes
=
new
Dictionary
<
long
,
string
>();
this
.
dicCardTypes
=
new
Dictionary
<
long
,
string
>();
dicLinkMarkers
=
new
Dictionary
<
long
,
string
>();
this
.
dicLinkMarkers
=
new
Dictionary
<
long
,
string
>();
dicCardcategorys
=
new
Dictionary
<
long
,
string
>();
this
.
dicCardcategorys
=
new
Dictionary
<
long
,
string
>();
dicCardAttributes
=
new
Dictionary
<
long
,
string
>();
this
.
dicCardAttributes
=
new
Dictionary
<
long
,
string
>();
dicCardRaces
=
new
Dictionary
<
long
,
string
>();
this
.
dicCardRaces
=
new
Dictionary
<
long
,
string
>();
dicCardLevels
=
new
Dictionary
<
long
,
string
>();
this
.
dicCardLevels
=
new
Dictionary
<
long
,
string
>();
return
;
return
;
}
}
//提取内容
//提取内容
string
text
=
File
.
ReadAllText
(
conf
);
string
text
=
File
.
ReadAllText
(
conf
);
dicCardRules
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_RULE
);
this
.
dicCardRules
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_RULE
);
dicSetnames
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_SETNAME
);
this
.
dicSetnames
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_SETNAME
);
dicCardTypes
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_TYPE
);
this
.
dicCardTypes
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_TYPE
);
dicLinkMarkers
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_MARKER
);
this
.
dicLinkMarkers
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_MARKER
);
dicCardcategorys
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_CATEGORY
);
this
.
dicCardcategorys
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_CATEGORY
);
dicCardAttributes
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_ATTRIBUTE
);
this
.
dicCardAttributes
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_ATTRIBUTE
);
dicCardRaces
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_RACE
);
this
.
dicCardRaces
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_RACE
);
dicCardLevels
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_LEVEL
);
this
.
dicCardLevels
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_LEVEL
);
}
}
/// <summary>
/// <summary>
...
...
DataEditorX/Config/DataManager.cs
View file @
bc0829bf
...
@@ -77,6 +77,8 @@ public static string subString(string content, string tag)
...
@@ -77,6 +77,8 @@ public static string subString(string content, string tag)
public
static
Dictionary
<
long
,
string
>
Read
(
string
content
)
public
static
Dictionary
<
long
,
string
>
Read
(
string
content
)
{
{
string
text
=
reReturn
(
content
);
string
text
=
reReturn
(
content
);
text
=
text
.
Replace
(
"\r"
,
"\n"
);
text
=
text
.
Replace
(
"\n\n"
,
"\n"
);
//Linux & MacOS 适配 190324 by JoyJ
return
Read
(
text
.
Split
(
'\n'
));
return
Read
(
text
.
Split
(
'\n'
));
}
}
/// <summary>
/// <summary>
...
@@ -90,18 +92,31 @@ public static string subString(string content, string tag)
...
@@ -90,18 +92,31 @@ public static string subString(string content, string tag)
long
lkey
;
long
lkey
;
foreach
(
string
line
in
lines
)
foreach
(
string
line
in
lines
)
{
{
if
(
line
.
StartsWith
(
"#"
))
string
l
=
line
.
Trim
();
//姑且做一下Trim 190324 by JoyJ
if
(
l
.
StartsWith
(
"#"
))
{
continue
;
continue
;
string
[]
words
=
line
.
Split
(
SEP_LINE
);
}
string
[]
words
=
l
.
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
;
}
}
...
@@ -136,8 +151,11 @@ public static string[] GetValues(Dictionary<long, string> dic)
...
@@ -136,8 +151,11 @@ public static string[] GetValues(Dictionary<long, string> dic)
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
key
.
ToString
(
"x"
);
return
dic
[
key
].
Trim
();
}
return
key
.
ToString
(
"x"
);
}
}
#
endregion
#
endregion
}
}
...
...
DataEditorX/Config/ImageSet.cs
View file @
bc0829bf
...
@@ -18,7 +18,7 @@ namespace DataEditorX.Config
...
@@ -18,7 +18,7 @@ namespace DataEditorX.Config
public
class
ImageSet
public
class
ImageSet
{
{
public
ImageSet
(){
public
ImageSet
(){
Init
();
this
.
Init
();
}
}
//初始化
//初始化
void
Init
()
void
Init
()
...
...
DataEditorX/Config/MyConfig.cs
View file @
bc0829bf
...
@@ -193,9 +193,11 @@ public static string readString(string key)
...
@@ -193,9 +193,11 @@ public static string readString(string key)
/// <returns></returns>
/// <returns></returns>
public
static
int
readInteger
(
string
key
,
int
def
)
public
static
int
readInteger
(
string
key
,
int
def
)
{
{
i
nt
i
;
i
f
(
int
.
TryParse
(
readString
(
key
),
out
int
i
))
if
(
int
.
TryParse
(
readString
(
key
),
out
i
))
{
return
i
;
return
i
;
}
return
def
;
return
def
;
}
}
/// <summary>
/// <summary>
...
@@ -206,9 +208,11 @@ public static int readInteger(string key, int def)
...
@@ -206,9 +208,11 @@ public static int readInteger(string key, int def)
/// <returns></returns>
/// <returns></returns>
public
static
float
readFloat
(
string
key
,
float
def
)
public
static
float
readFloat
(
string
key
,
float
def
)
{
{
float
i
;
if
(
float
.
TryParse
(
readString
(
key
),
out
float
i
))
if
(
float
.
TryParse
(
readString
(
key
),
out
i
))
{
return
i
;
return
i
;
}
return
def
;
return
def
;
}
}
/// <summary>
/// <summary>
...
@@ -286,8 +290,11 @@ public static string GetLanguageFile(string path)
...
@@ -286,8 +290,11 @@ public static string GetLanguageFile(string path)
{
{
string
name
=
MyPath
.
getFullFileName
(
MyConfig
.
TAG_LANGUAGE
,
file
);
string
name
=
MyPath
.
getFullFileName
(
MyConfig
.
TAG_LANGUAGE
,
file
);
if
(
string
.
IsNullOrEmpty
(
name
))
if
(
string
.
IsNullOrEmpty
(
name
))
continue
;
{
if
(
syslang
.
Equals
(
name
,
StringComparison
.
OrdinalIgnoreCase
))
continue
;
}
if
(
syslang
.
Equals
(
name
,
StringComparison
.
OrdinalIgnoreCase
))
{
{
Save
(
MyConfig
.
TAG_LANGUAGE
,
syslang
);
Save
(
MyConfig
.
TAG_LANGUAGE
,
syslang
);
break
;
break
;
...
...
DataEditorX/Config/YgoPath.cs
View file @
bc0829bf
...
@@ -9,17 +9,17 @@ public class YgoPath
...
@@ -9,17 +9,17 @@ public class YgoPath
{
{
public
YgoPath
(
string
gamepath
)
public
YgoPath
(
string
gamepath
)
{
{
SetPath
(
gamepath
);
this
.
SetPath
(
gamepath
);
}
}
public
void
SetPath
(
string
gamepath
)
public
void
SetPath
(
string
gamepath
)
{
{
this
.
gamepath
=
gamepath
;
this
.
gamepath
=
gamepath
;
picpath
=
MyPath
.
Combine
(
gamepath
,
"pics"
);
this
.
picpath
=
MyPath
.
Combine
(
gamepath
,
"pics"
);
fieldpath
=
MyPath
.
Combine
(
picpath
,
"field"
);
this
.
fieldpath
=
MyPath
.
Combine
(
this
.
picpath
,
"field"
);
picpath2
=
MyPath
.
Combine
(
picpath
,
"thumbnail"
);
this
.
picpath2
=
MyPath
.
Combine
(
this
.
picpath
,
"thumbnail"
);
luapath
=
MyPath
.
Combine
(
gamepath
,
"script"
);
this
.
luapath
=
MyPath
.
Combine
(
gamepath
,
"script"
);
ydkpath
=
MyPath
.
Combine
(
gamepath
,
"deck"
);
this
.
ydkpath
=
MyPath
.
Combine
(
gamepath
,
"deck"
);
replaypath
=
MyPath
.
Combine
(
gamepath
,
"replay"
);
this
.
replaypath
=
MyPath
.
Combine
(
gamepath
,
"replay"
);
}
}
/// <summary>游戏目录</summary>
/// <summary>游戏目录</summary>
public
string
gamepath
;
public
string
gamepath
;
...
@@ -38,7 +38,7 @@ public void SetPath(string gamepath)
...
@@ -38,7 +38,7 @@ public void SetPath(string gamepath)
public
string
GetImage
(
long
id
)
public
string
GetImage
(
long
id
)
{
{
return
GetImage
(
id
.
ToString
());
return
this
.
GetImage
(
id
.
ToString
());
}
}
//public string GetImageThum(long id)
//public string GetImageThum(long id)
//{
//{
...
@@ -46,20 +46,20 @@ public string GetImage(long id)
...
@@ -46,20 +46,20 @@ public string GetImage(long id)
//}
//}
public
string
GetImageField
(
long
id
)
public
string
GetImageField
(
long
id
)
{
{
return
GetImageField
(
id
.
ToString
());
//场地图
return
this
.
GetImageField
(
id
.
ToString
());
//场地图
}
}
public
string
GetScript
(
long
id
)
public
string
GetScript
(
long
id
)
{
{
return
GetScript
(
id
.
ToString
());
return
this
.
GetScript
(
id
.
ToString
());
}
}
public
string
GetYdk
(
string
name
)
public
string
GetYdk
(
string
name
)
{
{
return
MyPath
.
Combine
(
ydkpath
,
name
+
".ydk"
);
return
MyPath
.
Combine
(
this
.
ydkpath
,
name
+
".ydk"
);
}
}
//字符串id
//字符串id
public
string
GetImage
(
string
id
)
public
string
GetImage
(
string
id
)
{
{
return
MyPath
.
Combine
(
picpath
,
id
+
".jpg"
);
return
MyPath
.
Combine
(
this
.
picpath
,
id
+
".jpg"
);
}
}
//public string GetImageThum(string id)
//public string GetImageThum(string id)
//{
//{
...
@@ -67,34 +67,34 @@ public string GetImage(string id)
...
@@ -67,34 +67,34 @@ public string GetImage(string id)
//}
//}
public
string
GetImageField
(
string
id
)
public
string
GetImageField
(
string
id
)
{
{
return
MyPath
.
Combine
(
fieldpath
,
id
+
".png"
);
//场地图
return
MyPath
.
Combine
(
this
.
fieldpath
,
id
+
".png"
);
//场地图
}
}
public
string
GetScript
(
string
id
)
public
string
GetScript
(
string
id
)
{
{
return
MyPath
.
Combine
(
luapath
,
"c"
+
id
+
".lua"
);
return
MyPath
.
Combine
(
this
.
luapath
,
"c"
+
id
+
".lua"
);
}
}
public
string
GetModuleScript
(
string
modulescript
)
public
string
GetModuleScript
(
string
modulescript
)
{
{
return
MyPath
.
Combine
(
luapath
,
modulescript
+
".lua"
);
return
MyPath
.
Combine
(
this
.
luapath
,
modulescript
+
".lua"
);
}
}
public
string
[]
GetCardfiles
(
long
id
)
public
string
[]
GetCardfiles
(
long
id
)
{
{
string
[]
files
=
new
string
[]{
string
[]
files
=
new
string
[]{
GetImage
(
id
),
//大图
this
.
GetImage
(
id
),
//大图
//GetImageThum(id),//小图
//GetImageThum(id),//小图
GetImageField
(
id
),
//场地图
this
.
GetImageField
(
id
),
//场地图
GetScript
(
id
)
this
.
GetScript
(
id
)
};
};
return
files
;
return
files
;
}
}
public
string
[]
GetCardfiles
(
string
id
)
public
string
[]
GetCardfiles
(
string
id
)
{
{
string
[]
files
=
new
string
[]{
string
[]
files
=
new
string
[]{
GetImage
(
id
),
//大图
this
.
GetImage
(
id
),
//大图
//GetImageThum(id),//小图
//GetImageThum(id),//小图
GetImageField
(
id
),
//场地图
this
.
GetImageField
(
id
),
//场地图
GetScript
(
id
)
this
.
GetScript
(
id
)
};
};
return
files
;
return
files
;
}
}
...
...
DataEditorX/Controls/DFlowLayoutPanel.cs
View file @
bc0829bf
...
@@ -9,10 +9,10 @@ public class DFlowLayoutPanel : FlowLayoutPanel
...
@@ -9,10 +9,10 @@ public class DFlowLayoutPanel : FlowLayoutPanel
{
{
public
DFlowLayoutPanel
()
public
DFlowLayoutPanel
()
{
{
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
this
.
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
ControlStyles
.
AllPaintingInWmPaint
,
ControlStyles
.
AllPaintingInWmPaint
,
true
);
true
);
UpdateStyles
();
this
.
UpdateStyles
();
}
}
}
}
}
}
DataEditorX/Controls/DListBox.cs
View file @
bc0829bf
...
@@ -9,10 +9,10 @@ public class DListBox : ListBox
...
@@ -9,10 +9,10 @@ public class DListBox : ListBox
{
{
public
DListBox
()
public
DListBox
()
{
{
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
this
.
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
ControlStyles
.
AllPaintingInWmPaint
,
ControlStyles
.
AllPaintingInWmPaint
,
true
);
true
);
UpdateStyles
();
this
.
UpdateStyles
();
}
}
}
}
}
}
DataEditorX/Controls/DListView.cs
View file @
bc0829bf
...
@@ -9,10 +9,10 @@ public class DListView : ListView
...
@@ -9,10 +9,10 @@ public class DListView : ListView
{
{
public
DListView
()
public
DListView
()
{
{
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
this
.
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
ControlStyles
.
AllPaintingInWmPaint
,
ControlStyles
.
AllPaintingInWmPaint
,
true
);
true
);
UpdateStyles
();
this
.
UpdateStyles
();
}
}
}
}
}
}
DataEditorX/Controls/FastColoredTextBoxEx.cs
View file @
bc0829bf
...
@@ -20,33 +20,40 @@ public class FastColoredTextBoxEx : FastColoredTextBox
...
@@ -20,33 +20,40 @@ public class FastColoredTextBoxEx : FastColoredTextBox
public
FastColoredTextBoxEx
()
:
base
()
public
FastColoredTextBoxEx
()
:
base
()
{
{
this
.
SyntaxHighlighter
=
new
MySyntaxHighlighter
();
this
.
SyntaxHighlighter
=
new
MySyntaxHighlighter
();
this
.
TextChangedDelayed
+=
FctbTextChangedDelayed
;
this
.
TextChangedDelayed
+=
this
.
FctbTextChangedDelayed
;
}
}
public
new
event
EventHandler
<
ToolTipNeededEventArgs
>
ToolTipNeeded
;
public
new
event
EventHandler
<
ToolTipNeededEventArgs
>
ToolTipNeeded
;
protected
override
void
OnMouseMove
(
MouseEventArgs
e
)
protected
override
void
OnMouseMove
(
MouseEventArgs
e
)
{
{
base
.
OnMouseMove
(
e
);
base
.
OnMouseMove
(
e
);
lastMouseCoord
=
e
.
Location
;
this
.
lastMouseCoord
=
e
.
Location
;
}
}
//函数悬停提示
//函数悬停提示
protected
override
void
OnToolTip
()
protected
override
void
OnToolTip
()
{
{
if
(
ToolTip
==
null
)
if
(
this
.
ToolTip
==
null
)
return
;
{
if
(
ToolTipNeeded
==
null
)
return
;
return
;
}
if
(
ToolTipNeeded
==
null
)
{
return
;
}
//get place under mouse
//get place under mouse
Place
place
=
PointToPlace
(
lastMouseCoord
);
Place
place
=
this
.
PointToPlace
(
this
.
lastMouseCoord
);
//check distance
//check distance
Point
p
=
PlaceToPoint
(
place
);
Point
p
=
this
.
PlaceToPoint
(
place
);
if
(
Math
.
Abs
(
p
.
X
-
lastMouseCoord
.
X
)
>
CharWidth
*
2
||
if
(
Math
.
Abs
(
p
.
X
-
this
.
lastMouseCoord
.
X
)
>
this
.
CharWidth
*
2
||
Math
.
Abs
(
p
.
Y
-
lastMouseCoord
.
Y
)
>
CharHeight
*
2
)
Math
.
Abs
(
p
.
Y
-
this
.
lastMouseCoord
.
Y
)
>
this
.
CharHeight
*
2
)
return
;
{
//get word under mouse
return
;
var
r
=
new
Range
(
this
,
place
,
place
);
}
//get word under mouse
var
r
=
new
Range
(
this
,
place
,
place
);
string
hoveredWord
=
r
.
GetFragment
(
"[a-zA-Z0-9_]"
).
Text
;
string
hoveredWord
=
r
.
GetFragment
(
"[a-zA-Z0-9_]"
).
Text
;
//event handler
//event handler
var
ea
=
new
ToolTipNeededEventArgs
(
place
,
hoveredWord
);
var
ea
=
new
ToolTipNeededEventArgs
(
place
,
hoveredWord
);
...
@@ -54,11 +61,11 @@ protected override void OnToolTip()
...
@@ -54,11 +61,11 @@ protected override void OnToolTip()
if
(
ea
.
ToolTipText
!=
null
)
if
(
ea
.
ToolTipText
!=
null
)
{
{
//show tooltip
//show tooltip
ToolTip
.
ToolTipTitle
=
ea
.
ToolTipTitle
;
this
.
ToolTip
.
ToolTipTitle
=
ea
.
ToolTipTitle
;
ToolTip
.
ToolTipIcon
=
ea
.
ToolTipIcon
;
this
.
ToolTip
.
ToolTipIcon
=
ea
.
ToolTipIcon
;
//ToolTip.SetToolTip(this, ea.ToolTipText);
//ToolTip.SetToolTip(this, ea.ToolTipText);
ToolTip
.
Show
(
ea
.
ToolTipText
,
this
,
new
Point
(
lastMouseCoord
.
X
,
lastMouseCoord
.
Y
+
CharHeight
));
this
.
ToolTip
.
Show
(
ea
.
ToolTipText
,
this
,
new
Point
(
this
.
lastMouseCoord
.
X
,
this
.
lastMouseCoord
.
Y
+
this
.
CharHeight
));
}
}
}
}
//高亮当前词
//高亮当前词
...
@@ -75,13 +82,21 @@ void FctbTextChangedDelayed(object sender, TextChangedEventArgs e)
...
@@ -75,13 +82,21 @@ void FctbTextChangedDelayed(object sender, TextChangedEventArgs e)
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 @
bc0829bf
...
@@ -11,55 +11,65 @@ namespace DataEditorX.Controls
...
@@ -11,55 +11,65 @@ namespace DataEditorX.Controls
public
class
History
public
class
History
{
{
IMainForm
mainForm
;
readonly
IMainForm
mainForm
;
string
historyFile
;
string
historyFile
;
List
<
string
>
cdbhistory
;
readonly
List
<
string
>
cdbhistory
;
List
<
string
>
luahistory
;
readonly
List
<
string
>
luahistory
;
public
string
[]
GetcdbHistory
()
public
string
[]
GetcdbHistory
()
{
{
return
cdbhistory
.
ToArray
();
return
this
.
cdbhistory
.
ToArray
();
}
}
public
string
[]
GetluaHistory
()
public
string
[]
GetluaHistory
()
{
{
return
luahistory
.
ToArray
();
return
this
.
luahistory
.
ToArray
();
}
}
public
History
(
IMainForm
mainForm
)
public
History
(
IMainForm
mainForm
)
{
{
this
.
mainForm
=
mainForm
;
this
.
mainForm
=
mainForm
;
cdbhistory
=
new
List
<
string
>();
this
.
cdbhistory
=
new
List
<
string
>();
luahistory
=
new
List
<
string
>();
this
.
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
);
this
.
AddHistorys
(
lines
);
}
}
//添加历史记录
//添加历史记录
void
AddHistorys
(
string
[]
lines
)
void
AddHistorys
(
string
[]
lines
)
{
{
luahistory
.
Clear
();
this
.
luahistory
.
Clear
();
cdbhistory
.
Clear
();
this
.
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
.
i
sScript
(
line
))
if
(
YGOUtil
.
I
sScript
(
line
))
{
{
if
(
luahistory
.
Count
<
MyConfig
.
MAX_HISTORY
if
(
this
.
luahistory
.
Count
<
MyConfig
.
MAX_HISTORY
&&
luahistory
.
IndexOf
(
line
)
<
0
)
&&
this
.
luahistory
.
IndexOf
(
line
)
<
0
)
luahistory
.
Add
(
line
);
{
this
.
luahistory
.
Add
(
line
);
}
}
}
else
else
{
{
if
(
cdbhistory
.
Count
<
MyConfig
.
MAX_HISTORY
if
(
this
.
cdbhistory
.
Count
<
MyConfig
.
MAX_HISTORY
&&
cdbhistory
.
IndexOf
(
line
)
<
0
)
&&
this
.
cdbhistory
.
IndexOf
(
line
)
<
0
)
cdbhistory
.
Add
(
line
);
{
this
.
cdbhistory
.
Add
(
line
);
}
}
}
}
}
}
}
...
@@ -70,81 +80,89 @@ public void AddHistory(string file)
...
@@ -70,81 +80,89 @@ public void AddHistory(string file)
//添加到开始
//添加到开始
tmplist
.
Add
(
file
);
tmplist
.
Add
(
file
);
//添加旧记录
//添加旧记录
tmplist
.
AddRange
(
cdbhistory
.
ToArray
());
tmplist
.
AddRange
(
this
.
cdbhistory
.
ToArray
());
tmplist
.
AddRange
(
luahistory
.
ToArray
());
tmplist
.
AddRange
(
this
.
luahistory
.
ToArray
());
//
//
AddHistorys
(
tmplist
.
ToArray
());
this
.
AddHistorys
(
tmplist
.
ToArray
());
SaveHistory
();
this
.
SaveHistory
();
MenuHistory
();
this
.
MenuHistory
();
}
}
//保存历史
//保存历史
void
SaveHistory
()
void
SaveHistory
()
{
{
string
texts
=
"# database history"
;
string
texts
=
"# database history"
;
foreach
(
string
str
in
cdbhistory
)
foreach
(
string
str
in
this
.
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
this
.
luahistory
)
{
{
if
(
File
.
Exists
(
str
))
if
(
File
.
Exists
(
str
))
{
texts
+=
Environment
.
NewLine
+
str
;
texts
+=
Environment
.
NewLine
+
str
;
}
}
if
(
File
.
Exists
(
this
.
historyFile
))
{
File
.
Delete
(
this
.
historyFile
);
}
}
if
(
File
.
Exists
(
historyFile
))
File
.
Delete
(
historyFile
);
File
.
WriteAllText
(
this
.
historyFile
,
texts
);
File
.
WriteAllText
(
historyFile
,
texts
);
}
}
//添加历史记录菜单
//添加历史记录菜单
public
void
MenuHistory
()
public
void
MenuHistory
()
{
{
//cdb历史
//cdb历史
mainForm
.
CdbMenuClear
();
this
.
mainForm
.
CdbMenuClear
();
foreach
(
string
str
in
cdbhistory
)
foreach
(
string
str
in
this
.
cdbhistory
)
{
{
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
str
);
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
str
);
tsmi
.
Click
+=
MenuHistoryItem_Click
;
tsmi
.
Click
+=
this
.
MenuHistoryItem_Click
;
mainForm
.
AddCdbMenu
(
tsmi
);
this
.
mainForm
.
AddCdbMenu
(
tsmi
);
}
}
mainForm
.
AddCdbMenu
(
new
ToolStripSeparator
());
this
.
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
+=
this
.
MenuHistoryClear_Click
;
mainForm
.
AddCdbMenu
(
tsmiclear
);
this
.
mainForm
.
AddCdbMenu
(
tsmiclear
);
//lua历史
//lua历史
mainForm
.
LuaMenuClear
();
this
.
mainForm
.
LuaMenuClear
();
foreach
(
string
str
in
luahistory
)
foreach
(
string
str
in
this
.
luahistory
)
{
{
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
str
);
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
str
);
tsmi
.
Click
+=
MenuHistoryItem_Click
;
tsmi
.
Click
+=
this
.
MenuHistoryItem_Click
;
mainForm
.
AddLuaMenu
(
tsmi
);
this
.
mainForm
.
AddLuaMenu
(
tsmi
);
}
}
mainForm
.
AddLuaMenu
(
new
ToolStripSeparator
());
this
.
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
+=
this
.
MenuHistoryClear2_Click
;
mainForm
.
AddLuaMenu
(
tsmiclear2
);
this
.
mainForm
.
AddLuaMenu
(
tsmiclear2
);
}
}
void
MenuHistoryClear2_Click
(
object
sender
,
EventArgs
e
)
void
MenuHistoryClear2_Click
(
object
sender
,
EventArgs
e
)
{
{
luahistory
.
Clear
();
this
.
luahistory
.
Clear
();
MenuHistory
();
this
.
MenuHistory
();
SaveHistory
();
this
.
SaveHistory
();
}
}
void
MenuHistoryClear_Click
(
object
sender
,
EventArgs
e
)
void
MenuHistoryClear_Click
(
object
sender
,
EventArgs
e
)
{
{
cdbhistory
.
Clear
();
this
.
cdbhistory
.
Clear
();
MenuHistory
();
this
.
MenuHistory
();
SaveHistory
();
this
.
SaveHistory
();
}
}
void
MenuHistoryItem_Click
(
object
sender
,
EventArgs
e
)
void
MenuHistoryItem_Click
(
object
sender
,
EventArgs
e
)
{
{
ToolStripMenuItem
tsmi
=
sender
as
ToolStripMenuItem
;
if
(
sender
is
ToolStripMenuItem
tsmi
)
if
(
tsmi
!=
null
)
{
{
string
file
=
tsmi
.
Text
;
string
file
=
tsmi
.
Text
;
if
(
File
.
Exists
(
file
))
if
(
File
.
Exists
(
file
))
mainForm
.
Open
(
file
);
{
this
.
mainForm
.
Open
(
file
);
}
}
}
}
}
}
}
...
...
DataEditorX/Controls/MySyntaxHighlighter.cs
View file @
bc0829bf
...
@@ -20,13 +20,12 @@ namespace FastColoredTextBoxNS
...
@@ -20,13 +20,12 @@ namespace FastColoredTextBoxNS
/// </summary>
/// </summary>
public
class
MySyntaxHighlighter
:
SyntaxHighlighter
public
class
MySyntaxHighlighter
:
SyntaxHighlighter
{
{
TextStyle
mBoldStyle
=
new
TextStyle
(
Brushes
.
MediumSlateBlue
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mNumberStyle
=
new
TextStyle
(
Brushes
.
Orange
,
null
,
FontStyle
.
Regular
);
TextStyle
mNumberStyle
=
new
TextStyle
(
Brushes
.
Orange
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mStrStyle
=
new
TextStyle
(
Brushes
.
Gold
,
null
,
FontStyle
.
Regular
);
TextStyle
mStrStyle
=
new
TextStyle
(
Brushes
.
Gold
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
conStyle
=
new
TextStyle
(
Brushes
.
YellowGreen
,
null
,
FontStyle
.
Regular
);
TextStyle
ConStyle
=
new
TextStyle
(
Brushes
.
YellowGreen
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mKeywordStyle
=
new
TextStyle
(
Brushes
.
DeepSkyBlue
,
null
,
FontStyle
.
Regular
);
TextStyle
mKeywordStyle
=
new
TextStyle
(
Brushes
.
DeepSkyBlue
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mGrayStyle
=
new
TextStyle
(
Brushes
.
Gray
,
null
,
FontStyle
.
Regular
);
TextStyle
mGrayStyle
=
new
TextStyle
(
Brushes
.
Gray
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mFunStyle
=
new
TextStyle
(
Brushes
.
LightGray
,
null
,
FontStyle
.
Bold
);
TextStyle
mFunStyle
=
new
TextStyle
(
Brushes
.
LightGray
,
null
,
FontStyle
.
Bold
);
/// <summary>
/// <summary>
...
@@ -46,26 +45,28 @@ public override void LuaSyntaxHighlight(Range range)
...
@@ -46,26 +45,28 @@ public override void LuaSyntaxHighlight(Range range)
=
@"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>.+)"
;
=
@"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>.+)"
;
//clear style of changed range
//clear style of changed range
range
.
ClearStyle
(
mStrStyle
,
mGrayStyle
,
ConStyle
,
mNumberStyle
,
mKeywordStyle
,
mFunStyle
);
range
.
ClearStyle
(
this
.
mStrStyle
,
this
.
mGrayStyle
,
this
.
conStyle
,
this
.
mNumberStyle
,
this
.
mKeywordStyle
,
this
.
mFunStyle
);
//
//
if
(
base
.
LuaStringRegex
==
null
)
if
(
base
.
LuaStringRegex
==
null
)
base
.
InitLuaRegex
();
{
//string highlighting
base
.
InitLuaRegex
();
range
.
SetStyle
(
mStrStyle
,
base
.
LuaStringRegex
);
}
//string highlighting
range
.
SetStyle
(
this
.
mStrStyle
,
base
.
LuaStringRegex
);
//comment highlighting
//comment highlighting
range
.
SetStyle
(
mGrayStyle
,
base
.
LuaCommentRegex1
);
range
.
SetStyle
(
this
.
mGrayStyle
,
base
.
LuaCommentRegex1
);
range
.
SetStyle
(
mGrayStyle
,
base
.
LuaCommentRegex2
);
range
.
SetStyle
(
this
.
mGrayStyle
,
base
.
LuaCommentRegex2
);
range
.
SetStyle
(
mGrayStyle
,
base
.
LuaCommentRegex3
);
range
.
SetStyle
(
this
.
mGrayStyle
,
base
.
LuaCommentRegex3
);
//number highlighting
//number highlighting
range
.
SetStyle
(
mNumberStyle
,
base
.
LuaNumberRegex
);
range
.
SetStyle
(
this
.
mNumberStyle
,
base
.
LuaNumberRegex
);
//keyword highlighting
//keyword highlighting
range
.
SetStyle
(
mKeywordStyle
,
base
.
LuaKeywordRegex
);
range
.
SetStyle
(
this
.
mKeywordStyle
,
base
.
LuaKeywordRegex
);
//functions highlighting
//functions highlighting
range
.
SetStyle
(
mFunStyle
,
base
.
LuaFunctionsRegex
);
range
.
SetStyle
(
this
.
mFunStyle
,
base
.
LuaFunctionsRegex
);
range
.
SetStyle
(
mNumberStyle
,
@"\bc\d+\b"
);
range
.
SetStyle
(
this
.
mNumberStyle
,
@"\bc\d+\b"
);
range
.
SetStyle
(
C
onStyle
,
@"[\s|\(|+|,]{0,1}(?<range>[A-Z_]+?)[\)|+|\s|,|;]"
);
range
.
SetStyle
(
this
.
c
onStyle
,
@"[\s|\(|+|,]{0,1}(?<range>[A-Z_]+?)[\)|+|\s|,|;]"
);
//range.SetStyle(mFunStyle, @"[:|\.|\s](?<range>[a-zA-Z0-9_]*?)[\(|\)|\s]");
//range.SetStyle(mFunStyle, @"[:|\.|\s](?<range>[a-zA-Z0-9_]*?)[\(|\)|\s]");
//clear folding markers
//clear folding markers
...
...
DataEditorX/Core/Card.cs
View file @
bc0829bf
...
@@ -38,8 +38,10 @@ public Card(long cardCode)
...
@@ -38,8 +38,10 @@ public Card(long cardCode)
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
#
region
成员
#
region
成员
...
@@ -78,8 +80,10 @@ public string[] Str
...
@@ -78,8 +80,10 @@ public string[] Str
{
{
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
;
}
...
@@ -110,12 +114,11 @@ public void SetSetCode(params string[] setcodes)
...
@@ -110,12 +114,11 @@ public void SetSetCode(params string[] setcodes)
{
{
int
i
=
0
;
int
i
=
0
;
this
.
setcode
=
0
;
this
.
setcode
=
0
;
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
long
temp
);
this
.
setcode
+=
(
temp
<<
i
);
this
.
setcode
+=
(
temp
<<
i
);
i
+=
0x10
;
i
+=
0x10
;
}
}
...
@@ -140,10 +143,14 @@ public long GetRightScale()
...
@@ -140,10 +143,14 @@ public long GetRightScale()
public
override
bool
Equals
(
object
obj
)
public
override
bool
Equals
(
object
obj
)
{
{
if
(
obj
is
Card
)
if
(
obj
is
Card
)
return
Equals
((
Card
)
obj
);
// use Equals method below
{
else
return
this
.
Equals
((
Card
)
obj
);
// use Equals method below
return
false
;
}
}
else
{
return
false
;
}
}
/// <summary>
/// <summary>
/// 比较卡片,除脚本提示文本
/// 比较卡片,除脚本提示文本
/// </summary>
/// </summary>
...
@@ -153,32 +160,59 @@ public bool EqualsData(Card other)
...
@@ -153,32 +160,59 @@ public bool EqualsData(Card other)
{
{
bool
equalBool
=
true
;
bool
equalBool
=
true
;
if
(
this
.
id
!=
other
.
id
)
if
(
this
.
id
!=
other
.
id
)
equalBool
=
false
;
{
else
if
(
this
.
ot
!=
other
.
ot
)
equalBool
=
false
;
equalBool
=
false
;
}
else
if
(
this
.
alias
!=
other
.
alias
)
else
if
(
this
.
ot
!=
other
.
ot
)
equalBool
=
false
;
{
else
if
(
this
.
setcode
!=
other
.
setcode
)
equalBool
=
false
;
equalBool
=
false
;
}
else
if
(
this
.
type
!=
other
.
type
)
else
if
(
this
.
alias
!=
other
.
alias
)
equalBool
=
false
;
{
else
if
(
this
.
atk
!=
other
.
atk
)
equalBool
=
false
;
equalBool
=
false
;
}
else
if
(
this
.
def
!=
other
.
def
)
else
if
(
this
.
setcode
!=
other
.
setcode
)
equalBool
=
false
;
{
else
if
(
this
.
level
!=
other
.
level
)
equalBool
=
false
;
equalBool
=
false
;
}
else
if
(
this
.
race
!=
other
.
race
)
else
if
(
this
.
type
!=
other
.
type
)
equalBool
=
false
;
{
else
if
(
this
.
attribute
!=
other
.
attribute
)
equalBool
=
false
;
equalBool
=
false
;
}
else
if
(
this
.
category
!=
other
.
category
)
else
if
(
this
.
atk
!=
other
.
atk
)
equalBool
=
false
;
{
else
if
(!
this
.
name
.
Equals
(
other
.
name
))
equalBool
=
false
;
equalBool
=
false
;
}
else
if
(!
this
.
desc
.
Equals
(
other
.
desc
))
else
if
(
this
.
def
!=
other
.
def
)
equalBool
=
false
;
{
return
equalBool
;
equalBool
=
false
;
}
else
if
(
this
.
level
!=
other
.
level
)
{
equalBool
=
false
;
}
else
if
(
this
.
race
!=
other
.
race
)
{
equalBool
=
false
;
}
else
if
(
this
.
attribute
!=
other
.
attribute
)
{
equalBool
=
false
;
}
else
if
(
this
.
category
!=
other
.
category
)
{
equalBool
=
false
;
}
else
if
(!
this
.
name
.
Equals
(
other
.
name
))
{
equalBool
=
false
;
}
else
if
(!
this
.
desc
.
Equals
(
other
.
desc
))
{
equalBool
=
false
;
}
return
equalBool
;
}
}
/// <summary>
/// <summary>
/// 比较卡片是否一致?
/// 比较卡片是否一致?
...
@@ -187,12 +221,16 @@ public bool EqualsData(Card other)
...
@@ -187,12 +221,16 @@ public bool EqualsData(Card other)
/// <returns>结果</returns>
/// <returns>结果</returns>
public
bool
Equals
(
Card
other
)
public
bool
Equals
(
Card
other
)
{
{
bool
equalBool
=
EqualsData
(
other
);
bool
equalBool
=
this
.
EqualsData
(
other
);
if
(!
equalBool
)
if
(!
equalBool
)
return
false
;
{
else
if
(
this
.
str
.
Length
!=
other
.
str
.
Length
)
return
false
;
equalBool
=
false
;
}
else
else
if
(
this
.
str
.
Length
!=
other
.
str
.
Length
)
{
equalBool
=
false
;
}
else
{
{
int
l
=
this
.
str
.
Length
;
int
l
=
this
.
str
.
Length
;
for
(
int
i
=
0
;
i
<
l
;
i
++)
for
(
int
i
=
0
;
i
<
l
;
i
++)
...
@@ -213,7 +251,7 @@ public bool Equals(Card other)
...
@@ -213,7 +251,7 @@ public bool Equals(Card other)
public
override
int
GetHashCode
()
public
override
int
GetHashCode
()
{
{
// combine the hash codes of all members here (e.g. with XOR operator ^)
// combine the hash codes of all members here (e.g. with XOR operator ^)
int
hashCode
=
id
.
GetHashCode
()
+
name
.
GetHashCode
();
int
hashCode
=
this
.
id
.
GetHashCode
()
+
this
.
name
.
GetHashCode
();
return
hashCode
;
//member.GetHashCode();
return
hashCode
;
//member.GetHashCode();
}
}
/// <summary>
/// <summary>
...
@@ -230,8 +268,11 @@ public override int GetHashCode()
...
@@ -230,8 +268,11 @@ public override int GetHashCode()
/// <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
false
;
return
true
;
}
return
false
;
}
}
/// <summary>
/// <summary>
/// 是否是某系列
/// 是否是某系列
...
@@ -246,8 +287,11 @@ public bool IsSetCode(long sc)
...
@@ -246,8 +287,11 @@ public bool IsSetCode(long sc)
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
>>=
0x10
;
}
}
return
false
;
return
false
;
}
}
...
@@ -264,47 +308,54 @@ public bool IsSetCode(long sc)
...
@@ -264,47 +308,54 @@ public bool IsSetCode(long sc)
/// <summary>
/// <summary>
/// 密码字符串
/// 密码字符串
/// </summary>
/// </summary>
public
string
i
dString
public
string
I
dString
{
{
get
{
return
id
.
ToString
(
"00000000"
);
}
get
{
return
this
.
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
(
this
.
IsType
(
CardType
.
TYPE_MONSTER
)){
str
=
name
+
"["
+
i
dString
+
"]\n["
str
=
this
.
name
+
"["
+
this
.
I
dString
+
"]\n["
+
YGOUtil
.
GetTypeString
(
type
)
+
"] "
+
YGOUtil
.
GetTypeString
(
t
his
.
t
ype
)
+
"] "
+
YGOUtil
.
GetRace
(
race
)
+
"/"
+
YGOUtil
.
GetAttributeString
(
attribute
)
+
YGOUtil
.
GetRace
(
this
.
race
)
+
"/"
+
YGOUtil
.
GetAttributeString
(
this
.
attribute
)
+
"\n"
+
levelString
()
+
" "
+
atk
+
"/"
+
def
+
"\n"
+
redesc
();
+
"\n"
+
this
.
levelString
()
+
" "
+
this
.
atk
+
"/"
+
this
.
def
+
"\n"
+
this
.
redesc
();
}
else
}
else
str
=
name
+
"["
+
idString
+
"]\n["
+
YGOUtil
.
GetTypeString
(
type
)+
"]\n"
+
redesc
();
{
str
=
this
.
name
+
"["
+
this
.
IdString
+
"]\n["
+
YGOUtil
.
GetTypeString
(
this
.
type
)+
"]\n"
+
this
.
redesc
();
}
return
str
;
return
str
;
}
}
public
string
ToShortString
(){
public
string
ToShortString
(){
return
this
.
name
+
" ["
+
idString
+
"]"
;
return
this
.
name
+
" ["
+
this
.
IdString
+
"]"
;
}
}
public
string
ToLongString
(){
public
string
ToLongString
(){
return
ToString
();
return
this
.
ToString
();
}
}
string
levelString
()
string
levelString
()
{
{
string
star
=
"["
;
string
star
=
"["
;
long
i
=
0
,
j
=
level
&
0xff
;
long
j
=
this
.
level
&
0xff
;
long
i
;
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
=
this
.
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
;
...
...
DataEditorX/Core/CardEdit.cs
View file @
bc0829bf
...
@@ -10,7 +10,7 @@ namespace DataEditorX.Core
...
@@ -10,7 +10,7 @@ namespace DataEditorX.Core
{
{
public
class
CardEdit
public
class
CardEdit
{
{
IDataForm
dataform
;
readonly
IDataForm
dataform
;
public
AddCommand
addCard
;
public
AddCommand
addCard
;
public
ModCommand
modCard
;
public
ModCommand
modCard
;
public
DelCommand
delCard
;
public
DelCommand
delCard
;
...
@@ -30,9 +30,8 @@ public CardEdit(IDataForm dataform)
...
@@ -30,9 +30,8 @@ public CardEdit(IDataForm dataform)
public
class
AddCommand
:
IBackableCommand
public
class
AddCommand
:
IBackableCommand
{
{
private
string
_undoSQL
;
private
string
_undoSQL
;
readonly
CardEdit
cardedit
;
CardEdit
cardedit
;
readonly
IDataForm
dataform
;
IDataForm
dataform
;
public
AddCommand
(
CardEdit
cardedit
)
public
AddCommand
(
CardEdit
cardedit
)
{
{
this
.
cardedit
=
cardedit
;
this
.
cardedit
=
cardedit
;
...
@@ -41,15 +40,18 @@ public AddCommand(CardEdit cardedit)
...
@@ -41,15 +40,18 @@ public AddCommand(CardEdit cardedit)
public
bool
Excute
(
params
object
[]
args
)
public
bool
Excute
(
params
object
[]
args
)
{
{
if
(!
dataform
.
CheckOpen
())
if
(!
this
.
dataform
.
CheckOpen
())
return
false
;
{
Card
c
=
dataform
.
GetCard
();
return
false
;
}
Card
c
=
this
.
dataform
.
GetCard
();
if
(
c
.
id
<=
0
)
//卡片密码不能小于等于0
if
(
c
.
id
<=
0
)
//卡片密码不能小于等于0
{
{
MyMsg
.
Error
(
LMSG
.
CodeCanNotIsZero
);
MyMsg
.
Error
(
LMSG
.
CodeCanNotIsZero
);
return
false
;
return
false
;
}
}
Card
[]
cards
=
dataform
.
GetCardList
(
false
);
Card
[]
cards
=
this
.
dataform
.
GetCardList
(
false
);
foreach
(
Card
ckey
in
cards
)
//卡片id存在
foreach
(
Card
ckey
in
cards
)
//卡片id存在
{
{
if
(
c
.
id
==
ckey
.
id
)
if
(
c
.
id
==
ckey
.
id
)
...
@@ -58,13 +60,13 @@ public bool Excute(params object[] args)
...
@@ -58,13 +60,13 @@ public bool Excute(params object[] args)
return
false
;
return
false
;
}
}
}
}
if
(
DataBase
.
Command
(
dataform
.
GetOpenFile
(),
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
DataBase
.
GetInsertSQL
(
c
,
true
))
>=
2
)
DataBase
.
GetInsertSQL
(
c
,
true
))
>=
2
)
{
{
MyMsg
.
Show
(
LMSG
.
AddSucceed
);
MyMsg
.
Show
(
LMSG
.
AddSucceed
);
_undoSQL
=
DataBase
.
GetDeleteSQL
(
c
);
this
.
_undoSQL
=
DataBase
.
GetDeleteSQL
(
c
);
dataform
.
Search
(
true
);
this
.
dataform
.
Search
(
true
);
dataform
.
SetCard
(
c
);
this
.
dataform
.
SetCard
(
c
);
return
true
;
return
true
;
}
}
MyMsg
.
Error
(
LMSG
.
AddFail
);
MyMsg
.
Error
(
LMSG
.
AddFail
);
...
@@ -72,7 +74,7 @@ public bool Excute(params object[] args)
...
@@ -72,7 +74,7 @@ public bool Excute(params object[] args)
}
}
public
void
Undo
()
public
void
Undo
()
{
{
DataBase
.
Command
(
dataform
.
GetOpenFile
(),
_undoSQL
);
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
this
.
_undoSQL
);
}
}
public
object
Clone
()
public
object
Clone
()
...
@@ -91,9 +93,8 @@ public class ModCommand: IBackableCommand
...
@@ -91,9 +93,8 @@ public class ModCommand: IBackableCommand
private
long
oldid
;
private
long
oldid
;
private
long
newid
;
private
long
newid
;
private
bool
delold
;
private
bool
delold
;
readonly
CardEdit
cardedit
;
CardEdit
cardedit
;
readonly
IDataForm
dataform
;
IDataForm
dataform
;
public
ModCommand
(
CardEdit
cardedit
)
public
ModCommand
(
CardEdit
cardedit
)
{
{
this
.
cardedit
=
cardedit
;
this
.
cardedit
=
cardedit
;
...
@@ -102,12 +103,15 @@ public ModCommand(CardEdit cardedit)
...
@@ -102,12 +103,15 @@ public ModCommand(CardEdit cardedit)
public
bool
Excute
(
params
object
[]
args
)
public
bool
Excute
(
params
object
[]
args
)
{
{
if
(!
dataform
.
CheckOpen
())
if
(!
this
.
dataform
.
CheckOpen
())
return
false
;
{
bool
modfiles
=
(
bool
)
args
[
0
];
return
false
;
}
Card
c
=
dataform
.
GetCard
();
bool
modfiles
=
(
bool
)
args
[
0
];
Card
oldCard
=
dataform
.
GetOldCard
();
Card
c
=
this
.
dataform
.
GetCard
();
Card
oldCard
=
this
.
dataform
.
GetOldCard
();
if
(
c
.
Equals
(
oldCard
))
//没有修改
if
(
c
.
Equals
(
oldCard
))
//没有修改
{
{
MyMsg
.
Show
(
LMSG
.
ItIsNotChanged
);
MyMsg
.
Show
(
LMSG
.
ItIsNotChanged
);
...
@@ -125,7 +129,7 @@ public bool Excute(params object[] args)
...
@@ -125,7 +129,7 @@ public bool Excute(params object[] args)
bool
delold
=
MyMsg
.
Question
(
LMSG
.
IfDeleteCard
);
bool
delold
=
MyMsg
.
Question
(
LMSG
.
IfDeleteCard
);
if
(
delold
)
//是否删除旧卡片
if
(
delold
)
//是否删除旧卡片
{
{
if
(
DataBase
.
Command
(
dataform
.
GetOpenFile
(),
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
DataBase
.
GetDeleteSQL
(
oldCard
))
<
2
)
DataBase
.
GetDeleteSQL
(
oldCard
))
<
2
)
{
{
//删除失败
//删除失败
...
@@ -134,19 +138,26 @@ public bool Excute(params object[] args)
...
@@ -134,19 +138,26 @@ public bool Excute(params object[] args)
}
}
else
else
{
//删除成功,添加还原sql
{
//删除成功,添加还原sql
_undoSQL
=
DataBase
.
GetDeleteSQL
(
c
)
+
DataBase
.
GetInsertSQL
(
oldCard
,
false
);
this
.
_undoSQL
=
DataBase
.
GetDeleteSQL
(
c
)
+
DataBase
.
GetInsertSQL
(
oldCard
,
false
);
}
}
}
}
else
else
_undoSQL
=
DataBase
.
GetDeleteSQL
(
c
);
//还原就是删除
{
//如果删除旧卡片,则把资源修改名字,否则复制资源
this
.
_undoSQL
=
DataBase
.
GetDeleteSQL
(
c
);
//还原就是删除
if
(
modfiles
)
}
//如果删除旧卡片,则把资源修改名字,否则复制资源
if
(
modfiles
)
{
{
if
(
delold
)
if
(
delold
)
YGOUtil
.
CardRename
(
c
.
id
,
oldCard
.
id
,
dataform
.
GetPath
());
{
else
YGOUtil
.
CardRename
(
c
.
id
,
oldCard
.
id
,
this
.
dataform
.
GetPath
());
YGOUtil
.
CardCopy
(
c
.
id
,
oldCard
.
id
,
dataform
.
GetPath
());
}
this
.
modifiled
=
true
;
else
{
YGOUtil
.
CardCopy
(
c
.
id
,
oldCard
.
id
,
this
.
dataform
.
GetPath
());
}
this
.
modifiled
=
true
;
this
.
oldid
=
oldCard
.
id
;
this
.
oldid
=
oldCard
.
id
;
this
.
newid
=
c
.
id
;
this
.
newid
=
c
.
id
;
this
.
delold
=
delold
;
this
.
delold
=
delold
;
...
@@ -155,30 +166,37 @@ public bool Excute(params object[] args)
...
@@ -155,30 +166,37 @@ public bool Excute(params object[] args)
else
else
{
//更新数据
{
//更新数据
sql
=
DataBase
.
GetUpdateSQL
(
c
);
sql
=
DataBase
.
GetUpdateSQL
(
c
);
_undoSQL
=
DataBase
.
GetUpdateSQL
(
oldCard
);
this
.
_undoSQL
=
DataBase
.
GetUpdateSQL
(
oldCard
);
}
}
if
(
DataBase
.
Command
(
dataform
.
GetOpenFile
(),
sql
)
>
0
)
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
sql
)
>
0
)
{
{
MyMsg
.
Show
(
LMSG
.
ModifySucceed
);
MyMsg
.
Show
(
LMSG
.
ModifySucceed
);
dataform
.
Search
(
true
);
this
.
dataform
.
Search
(
true
);
dataform
.
SetCard
(
c
);
this
.
dataform
.
SetCard
(
c
);
return
true
;
return
true
;
}
}
else
else
MyMsg
.
Error
(
LMSG
.
ModifyFail
);
{
return
false
;
MyMsg
.
Error
(
LMSG
.
ModifyFail
);
}
return
false
;
}
}
public
void
Undo
()
public
void
Undo
()
{
{
DataBase
.
Command
(
dataform
.
GetOpenFile
(),
_undoSQL
);
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
this
.
_undoSQL
);
if
(
this
.
modifiled
)
if
(
this
.
modifiled
)
{
{
if
(
this
.
delold
)
if
(
this
.
delold
)
YGOUtil
.
CardRename
(
this
.
oldid
,
this
.
newid
,
dataform
.
GetPath
());
{
else
YGOUtil
.
CardRename
(
this
.
oldid
,
this
.
newid
,
this
.
dataform
.
GetPath
());
YGOUtil
.
CardDelete
(
this
.
newid
,
dataform
.
GetPath
());
}
}
else
{
YGOUtil
.
CardDelete
(
this
.
newid
,
this
.
dataform
.
GetPath
());
}
}
}
}
public
object
Clone
()
public
object
Clone
()
...
@@ -193,9 +211,8 @@ public object Clone()
...
@@ -193,9 +211,8 @@ public object Clone()
public
class
DelCommand
:
IBackableCommand
public
class
DelCommand
:
IBackableCommand
{
{
private
string
_undoSQL
;
private
string
_undoSQL
;
readonly
CardEdit
cardedit
;
CardEdit
cardedit
;
readonly
IDataForm
dataform
;
IDataForm
dataform
;
public
DelCommand
(
CardEdit
cardedit
)
public
DelCommand
(
CardEdit
cardedit
)
{
{
this
.
cardedit
=
cardedit
;
this
.
cardedit
=
cardedit
;
...
@@ -204,17 +221,26 @@ public DelCommand(CardEdit cardedit)
...
@@ -204,17 +221,26 @@ public DelCommand(CardEdit cardedit)
public
bool
Excute
(
params
object
[]
args
)
public
bool
Excute
(
params
object
[]
args
)
{
{
if
(!
dataform
.
CheckOpen
())
if
(!
this
.
dataform
.
CheckOpen
())
return
false
;
{
bool
deletefiles
=
(
bool
)
args
[
0
];
return
false
;
}
Card
[]
cards
=
dataform
.
GetCardList
(
true
);
bool
deletefiles
=
(
bool
)
args
[
0
];
Card
[]
cards
=
this
.
dataform
.
GetCardList
(
true
);
if
(
cards
==
null
||
cards
.
Length
==
0
)
if
(
cards
==
null
||
cards
.
Length
==
0
)
return
false
;
{
string
undo
=
""
;
return
false
;
}
string
undo
=
""
;
if
(!
MyMsg
.
Question
(
LMSG
.
IfDeleteCard
))
if
(!
MyMsg
.
Question
(
LMSG
.
IfDeleteCard
))
return
false
;
{
List
<
string
>
sql
=
new
List
<
string
>();
return
false
;
}
List
<
string
>
sql
=
new
List
<
string
>();
foreach
(
Card
c
in
cards
)
foreach
(
Card
c
in
cards
)
{
{
sql
.
Add
(
DataBase
.
GetDeleteSQL
(
c
));
//删除
sql
.
Add
(
DataBase
.
GetDeleteSQL
(
c
));
//删除
...
@@ -222,26 +248,26 @@ public bool Excute(params object[] args)
...
@@ -222,26 +248,26 @@ public bool Excute(params object[] args)
//删除资源
//删除资源
if
(
deletefiles
)
if
(
deletefiles
)
{
{
YGOUtil
.
CardDelete
(
c
.
id
,
dataform
.
GetPath
());
YGOUtil
.
CardDelete
(
c
.
id
,
this
.
dataform
.
GetPath
());
}
}
}
}
if
(
DataBase
.
Command
(
dataform
.
GetOpenFile
(),
sql
.
ToArray
())
>=
(
sql
.
Count
*
2
))
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
sql
.
ToArray
())
>=
(
sql
.
Count
*
2
))
{
{
MyMsg
.
Show
(
LMSG
.
DeleteSucceed
);
MyMsg
.
Show
(
LMSG
.
DeleteSucceed
);
dataform
.
Search
(
true
);
this
.
dataform
.
Search
(
true
);
_undoSQL
=
undo
;
this
.
_undoSQL
=
undo
;
return
true
;
return
true
;
}
}
else
else
{
{
MyMsg
.
Error
(
LMSG
.
DeleteFail
);
MyMsg
.
Error
(
LMSG
.
DeleteFail
);
dataform
.
Search
(
true
);
this
.
dataform
.
Search
(
true
);
}
}
return
false
;
return
false
;
}
}
public
void
Undo
()
public
void
Undo
()
{
{
DataBase
.
Command
(
dataform
.
GetOpenFile
(),
_undoSQL
);
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
this
.
_undoSQL
);
}
}
public
object
Clone
()
public
object
Clone
()
...
@@ -255,15 +281,18 @@ public object Clone()
...
@@ -255,15 +281,18 @@ public object Clone()
//打开脚本
//打开脚本
public
bool
OpenScript
(
bool
openinthis
,
string
addrequire
)
public
bool
OpenScript
(
bool
openinthis
,
string
addrequire
)
{
{
if
(!
dataform
.
CheckOpen
())
if
(!
this
.
dataform
.
CheckOpen
())
return
false
;
{
Card
c
=
dataform
.
GetCard
();
return
false
;
}
Card
c
=
this
.
dataform
.
GetCard
();
long
id
=
c
.
id
;
long
id
=
c
.
id
;
string
lua
;
string
lua
;
if
(
c
.
id
>
0
)
{
if
(
c
.
id
>
0
)
{
lua
=
dataform
.
GetPath
().
GetScript
(
id
);
lua
=
this
.
dataform
.
GetPath
().
GetScript
(
id
);
}
else
if
(
addrequire
.
Length
>
0
)
{
}
else
if
(
addrequire
.
Length
>
0
)
{
lua
=
dataform
.
GetPath
().
GetModuleScript
(
addrequire
);
lua
=
this
.
dataform
.
GetPath
().
GetModuleScript
(
addrequire
);
}
else
{
}
else
{
return
false
;
return
false
;
}
}
...
@@ -307,10 +336,15 @@ public bool OpenScript(bool openinthis, string addrequire)
...
@@ -307,10 +336,15 @@ public bool OpenScript(bool openinthis, string addrequire)
if
(
File
.
Exists
(
lua
))
//如果存在,则打开文件
if
(
File
.
Exists
(
lua
))
//如果存在,则打开文件
{
{
if
(
openinthis
)
//是否用本程序打开
if
(
openinthis
)
//是否用本程序打开
MyConfig
.
OpenFileInThis
(
lua
);
{
else
MyConfig
.
OpenFileInThis
(
lua
);
System
.
Diagnostics
.
Process
.
Start
(
lua
);
}
return
true
;
else
{
System
.
Diagnostics
.
Process
.
Start
(
lua
);
}
return
true
;
}
}
return
false
;
return
false
;
}
}
...
@@ -323,9 +357,8 @@ public class CopyCommand : IBackableCommand
...
@@ -323,9 +357,8 @@ public class CopyCommand : IBackableCommand
Card
[]
NewCards
;
Card
[]
NewCards
;
bool
replace
;
bool
replace
;
Card
[]
OldCards
;
Card
[]
OldCards
;
readonly
CardEdit
cardedit
;
CardEdit
cardedit
;
readonly
IDataForm
dataform
;
IDataForm
dataform
;
public
CopyCommand
(
CardEdit
cardedit
)
public
CopyCommand
(
CardEdit
cardedit
)
{
{
this
.
cardedit
=
cardedit
;
this
.
cardedit
=
cardedit
;
...
@@ -334,14 +367,20 @@ public CopyCommand(CardEdit cardedit)
...
@@ -334,14 +367,20 @@ public CopyCommand(CardEdit cardedit)
public
bool
Excute
(
params
object
[]
args
)
public
bool
Excute
(
params
object
[]
args
)
{
{
if
(!
dataform
.
CheckOpen
())
if
(!
this
.
dataform
.
CheckOpen
())
return
false
;
{
Card
[]
cards
=
(
Card
[])
args
[
0
];
return
false
;
}
Card
[]
cards
=
(
Card
[])
args
[
0
];
if
(
cards
==
null
||
cards
.
Length
==
0
)
if
(
cards
==
null
||
cards
.
Length
==
0
)
return
false
;
{
bool
replace
=
false
;
return
false
;
Card
[]
oldcards
=
DataBase
.
Read
(
dataform
.
GetOpenFile
(),
true
,
""
);
}
bool
replace
=
false
;
Card
[]
oldcards
=
DataBase
.
Read
(
this
.
dataform
.
GetOpenFile
(),
true
,
""
);
if
(
oldcards
!=
null
&&
oldcards
.
Length
!=
0
)
if
(
oldcards
!=
null
&&
oldcards
.
Length
!=
0
)
{
{
int
i
=
0
;
int
i
=
0
;
...
@@ -360,10 +399,12 @@ public bool Excute(params object[] args)
...
@@ -360,10 +399,12 @@ public bool Excute(params object[] args)
}
}
}
}
if
(
i
>
0
)
if
(
i
>
0
)
break
;
{
}
break
;
}
}
}
}
DataBase
.
CopyDB
(
dataform
.
GetOpenFile
(),
!
replace
,
cards
);
DataBase
.
CopyDB
(
this
.
dataform
.
GetOpenFile
(),
!
replace
,
cards
);
this
.
copied
=
true
;
this
.
copied
=
true
;
this
.
NewCards
=
cards
;
this
.
NewCards
=
cards
;
this
.
replace
=
replace
;
this
.
replace
=
replace
;
...
@@ -372,19 +413,24 @@ public bool Excute(params object[] args)
...
@@ -372,19 +413,24 @@ public bool Excute(params object[] args)
}
}
public
void
Undo
()
public
void
Undo
()
{
{
DataBase
.
DeleteDB
(
dataform
.
GetOpenFile
(),
this
.
NewCards
);
DataBase
.
DeleteDB
(
this
.
dataform
.
GetOpenFile
(),
this
.
NewCards
);
DataBase
.
CopyDB
(
dataform
.
GetOpenFile
(),
!
this
.
replace
,
this
.
OldCards
);
DataBase
.
CopyDB
(
this
.
dataform
.
GetOpenFile
(),
!
this
.
replace
,
this
.
OldCards
);
}
}
public
object
Clone
()
public
object
Clone
()
{
{
CopyCommand
replica
=
new
CopyCommand
(
cardedit
);
CopyCommand
replica
=
new
CopyCommand
(
this
.
cardedit
)
replica
.
copied
=
this
.
copied
;
{
replica
.
NewCards
=
(
Card
[])
this
.
NewCards
.
Clone
();
copied
=
this
.
copied
,
replica
.
replace
=
this
.
replace
;
NewCards
=
(
Card
[])
this
.
NewCards
.
Clone
(),
if
(
this
.
OldCards
!=
null
)
replace
=
this
.
replace
replica
.
OldCards
=
(
Card
[])
this
.
OldCards
.
Clone
();
};
return
replica
;
if
(
this
.
OldCards
!=
null
)
{
replica
.
OldCards
=
(
Card
[])
this
.
OldCards
.
Clone
();
}
return
replica
;
}
}
}
}
#
endregion
#
endregion
...
...
DataEditorX/Core/CommandManager.cs
View file @
bc0829bf
...
@@ -22,15 +22,15 @@ public interface ICommandManager
...
@@ -22,15 +22,15 @@ public interface ICommandManager
}
}
public
class
CommandManager
:
ICommandManager
public
class
CommandManager
:
ICommandManager
{
{
private
Stack
<
ICommand
>
undoStack
=
new
Stack
<
ICommand
>();
private
readonly
Stack
<
ICommand
>
undoStack
=
new
Stack
<
ICommand
>();
private
Stack
<
ICommand
>
reverseStack
=
new
Stack
<
ICommand
>();
private
readonly
Stack
<
ICommand
>
reverseStack
=
new
Stack
<
ICommand
>();
public
event
StatusBool
UndoStateChanged
;
public
event
StatusBool
UndoStateChanged
;
public
CommandManager
()
public
CommandManager
()
{
{
UndoStateChanged
+=
new
StatusBool
(
CommandManager_UndoStateChanged
);
UndoStateChanged
+=
new
StatusBool
(
this
.
CommandManager_UndoStateChanged
);
UndoStateChanged
+=
new
StatusBool
(
CommandManager_ReverseUndoStateChanged
);
UndoStateChanged
+=
new
StatusBool
(
this
.
CommandManager_ReverseUndoStateChanged
);
}
}
private
void
CommandManager_UndoStateChanged
(
bool
val
)
private
void
CommandManager_UndoStateChanged
(
bool
val
)
...
@@ -46,48 +46,52 @@ private void CommandManager_ReverseUndoStateChanged(bool val)
...
@@ -46,48 +46,52 @@ private void CommandManager_ReverseUndoStateChanged(bool val)
#
region
ICommandManager
成员
#
region
ICommandManager
成员
public
void
ExcuteCommand
(
ICommand
command
,
params
object
[]
args
)
public
void
ExcuteCommand
(
ICommand
command
,
params
object
[]
args
)
{
{
if
(!
command
.
Excute
(
args
))
return
;
if
(!
command
.
Excute
(
args
))
reverseStack
.
Clear
();
{
return
;
}
this
.
reverseStack
.
Clear
();
if
(
command
is
IBackableCommand
)
if
(
command
is
IBackableCommand
)
{
{
undoStack
.
Push
((
ICommand
)
command
.
Clone
());
this
.
undoStack
.
Push
((
ICommand
)
command
.
Clone
());
}
}
else
else
{
{
undoStack
.
Clear
();
this
.
undoStack
.
Clear
();
}
}
UndoStateChanged
(
undoStack
.
Count
>
0
);
UndoStateChanged
(
this
.
undoStack
.
Count
>
0
);
}
}
public
void
Undo
()
public
void
Undo
()
{
{
IBackableCommand
command
=
(
IBackableCommand
)
undoStack
.
Pop
();
IBackableCommand
command
=
(
IBackableCommand
)
this
.
undoStack
.
Pop
();
if
(
command
==
null
)
if
(
command
==
null
)
{
{
return
;
return
;
}
}
command
.
Undo
();
command
.
Undo
();
reverseStack
.
Push
((
ICommand
)
command
.
Clone
());
this
.
reverseStack
.
Push
((
ICommand
)
command
.
Clone
());
UndoStateChanged
(
undoStack
.
Count
>
0
);
UndoStateChanged
(
this
.
undoStack
.
Count
>
0
);
//UndoStateChanged(reverseStack.Count > 0);
//UndoStateChanged(reverseStack.Count > 0);
}
}
public
void
ReverseUndo
()
public
void
ReverseUndo
()
{
{
IBackableCommand
command
=
(
IBackableCommand
)
reverseStack
.
Pop
();
IBackableCommand
command
=
(
IBackableCommand
)
this
.
reverseStack
.
Pop
();
if
(
command
==
null
)
if
(
command
==
null
)
{
{
return
;
return
;
}
}
command
.
Excute
();
command
.
Excute
();
undoStack
.
Push
((
ICommand
)
command
.
Clone
());
this
.
undoStack
.
Push
((
ICommand
)
command
.
Clone
());
UndoStateChanged
(
undoStack
.
Count
>
0
);
UndoStateChanged
(
this
.
undoStack
.
Count
>
0
);
}
}
#
endregion
#
endregion
}
}
...
...
DataEditorX/Core/DataBase.cs
View file @
bc0829bf
...
@@ -19,12 +19,12 @@ namespace DataEditorX.Core
...
@@ -19,12 +19,12 @@ namespace DataEditorX.Core
public
static
class
DataBase
public
static
class
DataBase
{
{
#
region
默认
#
region
默认
static
string
defaultSQL
;
static
readonly
string
_
defaultSQL
;
static
string
defaultTableSQL
;
static
readonly
string
_
defaultTableSQL
;
static
DataBase
()
static
DataBase
()
{
{
defaultSQL
=
_
defaultSQL
=
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "
;
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "
;
StringBuilder
st
=
new
StringBuilder
();
StringBuilder
st
=
new
StringBuilder
();
st
.
Append
(
@"CREATE TABLE texts(id integer primary key,name text,desc text"
);
st
.
Append
(
@"CREATE TABLE texts(id integer primary key,name text,desc text"
);
...
@@ -39,24 +39,27 @@ static DataBase()
...
@@ -39,24 +39,27 @@ static DataBase()
st
.
Append
(
"id integer primary key,ot integer,alias integer,"
);
st
.
Append
(
"id integer primary key,ot integer,alias integer,"
);
st
.
Append
(
"setcode integer,type integer,atk integer,def integer,"
);
st
.
Append
(
"setcode integer,type integer,atk integer,def integer,"
);
st
.
Append
(
"level integer,race integer,attribute integer,category integer) "
);
st
.
Append
(
"level integer,race integer,attribute integer,category integer) "
);
defaultTableSQL
=
st
.
ToString
();
_
defaultTableSQL
=
st
.
ToString
();
st
.
Remove
(
0
,
st
.
Length
);
st
.
Remove
(
0
,
st
.
Length
);
st
=
null
;
}
}
#
endregion
#
endregion
#
region
创建数据库
#
region
创建数据库
/// <summary>
/// <summary>
/// 创建数据库
/// 创建数据库
/// </summary>
/// </summary>
/// <param name="Db">新数据库路径</param>
/// <param name="Db">新数据库路径</param>
public
static
bool
Create
(
string
Db
)
public
static
bool
Create
(
string
Db
)
{
{
if
(
File
.
Exists
(
Db
)
)
if
(
File
.
Exists
(
Db
)
)
File
.
Delete
(
Db
);
{
try
{
File
.
Delete
(
Db
);
}
try
{
SQLiteConnection
.
CreateFile
(
Db
);
SQLiteConnection
.
CreateFile
(
Db
);
Command
(
Db
,
defaultTableSQL
);
Command
(
Db
,
_
defaultTableSQL
);
}
}
catch
catch
{
{
...
@@ -67,7 +70,7 @@ public static bool Create(string Db)
...
@@ -67,7 +70,7 @@ public static bool Create(string Db)
public
static
bool
CheckTable
(
string
db
)
public
static
bool
CheckTable
(
string
db
)
{
{
try
{
try
{
Command
(
db
,
defaultTableSQL
);
Command
(
db
,
_
defaultTableSQL
);
}
}
catch
catch
{
{
...
@@ -125,28 +128,32 @@ public static int Command(string DB, params string[] SQLs)
...
@@ -125,28 +128,32 @@ public static int Command(string DB, params string[] SQLs)
#
region
根据
SQL
读取
#
region
根据
SQL
读取
static
Card
ReadCard
(
SQLiteDataReader
reader
,
bool
reNewLine
)
static
Card
ReadCard
(
SQLiteDataReader
reader
,
bool
reNewLine
)
{
{
Card
c
=
new
Card
(
0
);
Card
c
=
new
Card
(
0
)
c
.
id
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"id"
));
{
c
.
ot
=
reader
.
GetInt32
(
reader
.
GetOrdinal
(
"ot"
));
id
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"id"
)),
c
.
alias
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"alias"
));
ot
=
reader
.
GetInt32
(
reader
.
GetOrdinal
(
"ot"
)),
c
.
setcode
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"setcode"
));
alias
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"alias"
)),
c
.
type
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"type"
));
setcode
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"setcode"
)),
c
.
atk
=
reader
.
GetInt32
(
reader
.
GetOrdinal
(
"atk"
));
type
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"type"
)),
c
.
def
=
reader
.
GetInt32
(
reader
.
GetOrdinal
(
"def"
));
atk
=
reader
.
GetInt32
(
reader
.
GetOrdinal
(
"atk"
)),
c
.
level
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"level"
));
def
=
reader
.
GetInt32
(
reader
.
GetOrdinal
(
"def"
)),
c
.
race
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"race"
));
level
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"level"
)),
c
.
attribute
=
reader
.
GetInt32
(
reader
.
GetOrdinal
(
"attribute"
));
race
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"race"
)),
c
.
category
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"category"
));
attribute
=
reader
.
GetInt32
(
reader
.
GetOrdinal
(
"attribute"
)),
c
.
name
=
reader
.
GetString
(
reader
.
GetOrdinal
(
"name"
));
category
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"category"
)),
name
=
reader
.
GetString
(
reader
.
GetOrdinal
(
"name"
)),
c
.
desc
=
reader
.
GetString
(
reader
.
GetOrdinal
(
"desc"
));
if
(
reNewLine
)
desc
=
reader
.
GetString
(
reader
.
GetOrdinal
(
"desc"
))
c
.
desc
=
Retext
(
c
.
desc
);
};
string
temp
=
null
;
if
(
reNewLine
)
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
{
c
.
desc
=
Retext
(
c
.
desc
);
}
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
{
{
temp
=
reader
.
GetString
(
reader
.
GetOrdinal
(
"str"
+(
i
+
1
).
ToString
()));
string
temp
=
reader
.
GetString
(
reader
.
GetOrdinal
(
"str"
+
(
i
+
1
).
ToString
()));
c
.
Str
[
i
]=
(
temp
==
null
)
?
""
:
temp
;
c
.
Str
[
i
]=
temp
??
""
;
}
}
return
c
;
return
c
;
}
}
...
@@ -179,54 +186,68 @@ public static Card[] Read(string DB,bool reNewLine, params string[] SQLs)
...
@@ -179,54 +186,68 @@ public static Card[] Read(string DB,bool reNewLine, params string[] SQLs)
{
{
List
<
Card
>
list
=
new
List
<
Card
>();
List
<
Card
>
list
=
new
List
<
Card
>();
List
<
long
>
idlist
=
new
List
<
long
>();
List
<
long
>
idlist
=
new
List
<
long
>();
string
SQLstr
=
""
;
if
(
File
.
Exists
(
DB
)
&&
SQLs
!=
null
)
if
(
File
.
Exists
(
DB
)
&&
SQLs
!=
null
)
{
{
using
(
SQLiteConnection
sqliteconn
=
new
SQLiteConnection
(
@"Data Source="
+
DB
))
using
(
SQLiteConnection
sqliteconn
=
new
SQLiteConnection
(
@"Data Source="
+
DB
)
)
{
{
sqliteconn
.
Open
();
sqliteconn
.
Open
();
using
(
SQLiteTransaction
trans
=
sqliteconn
.
BeginTransaction
())
using
(
SQLiteTransaction
trans
=
sqliteconn
.
BeginTransaction
()
)
{
{
using
(
SQLiteCommand
sqlitecommand
=
new
SQLiteCommand
(
sqliteconn
))
using
(
SQLiteCommand
sqlitecommand
=
new
SQLiteCommand
(
sqliteconn
)
)
{
{
foreach
(
string
str
in
SQLs
)
foreach
(
string
str
in
SQLs
)
{
{
int
.
TryParse
(
str
,
out
int
tmp
);
int
tmp
;
int
.
TryParse
(
str
,
out
tmp
);
string
SQLstr
;
if
(
string
.
IsNullOrEmpty
(
str
))
if
(
string
.
IsNullOrEmpty
(
str
)
)
{
SQLstr
=
defaultSQL
;
SQLstr
=
_defaultSQL
;
else
if
(
tmp
>
0
)
}
SQLstr
=
defaultSQL
+
" and datas.id="
+
tmp
.
ToString
();
else
if
(
tmp
>
0
)
else
if
(
str
.
StartsWith
(
"select"
,
StringComparison
.
OrdinalIgnoreCase
))
{
SQLstr
=
str
;
SQLstr
=
_defaultSQL
+
" and datas.id="
+
tmp
.
ToString
();
else
if
(
str
.
IndexOf
(
"and "
)>=
0
)
}
SQLstr
=
defaultSQL
+
str
;
else
if
(
str
.
StartsWith
(
"select"
,
StringComparison
.
OrdinalIgnoreCase
))
else
{
SQLstr
=
defaultSQL
+
" and texts.name like '%"
+
str
+
"%'"
;
SQLstr
=
str
;
sqlitecommand
.
CommandText
=
SQLstr
;
}
using
(
SQLiteDataReader
reader
=
sqlitecommand
.
ExecuteReader
()
)
else
if
(
str
.
IndexOf
(
"and "
)
>=
0
)
{
{
while
(
reader
.
Read
()
)
SQLstr
=
_defaultSQL
+
str
;
{
}
Card
c
=
ReadCard
(
reader
,
reNewLine
);
else
if
(
idlist
.
IndexOf
(
c
.
id
)<
0
){
//不存在,则添加
{
idlist
.
Add
(
c
.
id
);
SQLstr
=
_defaultSQL
+
" and texts.name like '%"
+
str
+
"%'"
;
list
.
Add
(
c
);
}
}
}
sqlitecommand
.
CommandText
=
SQLstr
;
reader
.
Close
();
using
(
SQLiteDataReader
reader
=
sqlitecommand
.
ExecuteReader
())
}
{
}
while
(
reader
.
Read
())
}
{
trans
.
Commit
();
Card
c
=
ReadCard
(
reader
,
reNewLine
);
}
if
(
idlist
.
IndexOf
(
c
.
id
)
<
0
)
sqliteconn
.
Close
();
{
//不存在,则添加
}
idlist
.
Add
(
c
.
id
);
}
list
.
Add
(
c
);
if
(
list
.
Count
==
0
)
}
return
null
;
}
return
list
.
ToArray
();
reader
.
Close
();
}
}
}
trans
.
Commit
();
}
sqliteconn
.
Close
();
}
}
if
(
list
.
Count
==
0
)
{
return
null
;
}
return
list
.
ToArray
();
}
}
#
endregion
#
endregion
...
@@ -326,37 +347,76 @@ public static string GetSelectSQL(Card c)
...
@@ -326,37 +347,76 @@ public static string GetSelectSQL(Card c)
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
Append
(
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "
);
sb
.
Append
(
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "
);
if
(
c
==
null
)
if
(
c
==
null
)
return
sb
.
ToString
();
{
if
(!
string
.
IsNullOrEmpty
(
c
.
name
)){
return
sb
.
ToString
();
}
if
(!
string
.
IsNullOrEmpty
(
c
.
name
)){
if
(
c
.
name
.
IndexOf
(
"%%"
)>=
0
)
if
(
c
.
name
.
IndexOf
(
"%%"
)>=
0
)
c
.
name
=
c
.
name
.
Replace
(
"%%"
,
"%"
);
{
else
c
.
name
=
c
.
name
.
Replace
(
"%%"
,
"%"
);
c
.
name
=
"%"
+
c
.
name
.
Replace
(
"%"
,
"/%"
).
Replace
(
"_"
,
"/_"
)+
"%"
;
}
sb
.
Append
(
" and texts.name like '"
+
c
.
name
.
Replace
(
"'"
,
"''"
)+
"' "
);
else
{
c
.
name
=
"%"
+
c
.
name
.
Replace
(
"%"
,
"/%"
).
Replace
(
"_"
,
"/_"
)+
"%"
;
}
sb
.
Append
(
" and texts.name like '"
+
c
.
name
.
Replace
(
"'"
,
"''"
)+
"' "
);
}
}
if
(!
string
.
IsNullOrEmpty
(
c
.
desc
))
if
(!
string
.
IsNullOrEmpty
(
c
.
desc
))
sb
.
Append
(
" and texts.desc like '%"
+
c
.
desc
.
Replace
(
"'"
,
"''"
)
+
"%' "
);
{
if
(
c
.
ot
>
0
)
sb
.
Append
(
" and texts.desc like '%"
+
c
.
desc
.
Replace
(
"'"
,
"''"
)
+
"%' "
);
sb
.
Append
(
" and datas.ot = "
+
c
.
ot
.
ToString
());
}
if
(
c
.
attribute
>
0
)
sb
.
Append
(
" and datas.attribute = "
+
c
.
attribute
.
ToString
());
if
(
c
.
ot
>
0
)
if
((
c
.
level
&
0xff
)
>
0
)
{
sb
.
Append
(
" and (datas.level & 255) = "
+
toInt
(
c
.
level
&
0xff
));
sb
.
Append
(
" and datas.ot = "
+
c
.
ot
.
ToString
());
}
if
(
c
.
attribute
>
0
)
{
sb
.
Append
(
" and datas.attribute = "
+
c
.
attribute
.
ToString
());
}
if
((
c
.
level
&
0xff
)
>
0
)
{
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
));
{
if
(
c
.
type
>
0
)
sb
.
Append
(
" and datas.race = "
+
toInt
(
c
.
race
));
sb
.
Append
(
" and datas.type & "
+
toInt
(
c
.
type
)+
" = "
+
toInt
(
c
.
type
));
}
if
(
c
.
category
>
0
)
sb
.
Append
(
" and datas.category & "
+
toInt
(
c
.
category
)+
" = "
+
toInt
(
c
.
category
));
if
(
c
.
type
>
0
)
{
if
(
c
.
atk
==-
1
)
sb
.
Append
(
" and datas.type & "
+
toInt
(
c
.
type
)+
" = "
+
toInt
(
c
.
type
));
sb
.
Append
(
" and datas.type & 1 = 1 and datas.atk = 0"
);
}
else
if
(
c
.
atk
<
0
||
c
.
atk
>
0
)
sb
.
Append
(
" and datas.atk = "
+
c
.
atk
.
ToString
());
if
(
c
.
category
>
0
)
{
sb
.
Append
(
" and datas.category & "
+
toInt
(
c
.
category
)+
" = "
+
toInt
(
c
.
category
));
}
if
(
c
.
atk
==-
1
)
{
sb
.
Append
(
" and datas.type & 1 = 1 and datas.atk = 0"
);
}
else
if
(
c
.
atk
<
0
||
c
.
atk
>
0
)
{
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
());
...
@@ -364,20 +424,29 @@ public static string GetSelectSQL(Card c)
...
@@ -364,20 +424,29 @@ public static string GetSelectSQL(Card c)
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
());
{
else
if
(
c
.
id
>
0
)
sb
.
Append
(
" and datas.id BETWEEN "
+
c
.
alias
.
ToString
()+
" and "
+
c
.
id
.
ToString
());
}
else
if
(
c
.
id
>
0
)
{
{
sb
.
Append
(
" and ( datas.id="
+
c
.
id
.
ToString
()+
" or datas.alias="
+
c
.
id
.
ToString
()+
") "
);
sb
.
Append
(
" and ( datas.id="
+
c
.
id
.
ToString
()+
" or datas.alias="
+
c
.
id
.
ToString
()+
") "
);
}
}
else
if
(
c
.
alias
>
0
)
else
if
(
c
.
alias
>
0
)
sb
.
Append
(
" and datas.alias= "
+
c
.
alias
.
ToString
());
{
return
sb
.
ToString
();
sb
.
Append
(
" and datas.alias= "
+
c
.
alias
.
ToString
());
}
return
sb
.
ToString
();
}
}
#
endregion
#
endregion
...
@@ -393,10 +462,15 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
...
@@ -393,10 +462,15 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
{
{
StringBuilder
st
=
new
StringBuilder
();
StringBuilder
st
=
new
StringBuilder
();
if
(
ignore
)
if
(
ignore
)
st
.
Append
(
"INSERT or ignore into datas values("
);
{
else
st
.
Append
(
"INSERT or ignore into datas values("
);
st
.
Append
(
"INSERT or replace into datas values("
);
}
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
","
);
else
{
st
.
Append
(
"INSERT or replace into datas values("
);
}
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
ot
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
ot
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
alias
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
alias
.
ToString
());
st
.
Append
(
","
);
if
(
hex
){
if
(
hex
){
...
@@ -420,10 +494,15 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
...
@@ -420,10 +494,15 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
st
.
Append
(
c
.
category
.
ToString
());
st
.
Append
(
")"
);
st
.
Append
(
c
.
category
.
ToString
());
st
.
Append
(
")"
);
}
}
if
(
ignore
)
if
(
ignore
)
st
.
Append
(
";\nINSERT or ignore into texts values("
);
{
else
st
.
Append
(
";\nINSERT or ignore into texts values("
);
st
.
Append
(
";\nINSERT or replace into texts values("
);
}
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
",'"
);
else
{
st
.
Append
(
";\nINSERT or replace into texts values("
);
}
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
",'"
);
st
.
Append
(
c
.
name
.
Replace
(
"'"
,
"''"
));
st
.
Append
(
"','"
);
st
.
Append
(
c
.
name
.
Replace
(
"'"
,
"''"
));
st
.
Append
(
"','"
);
st
.
Append
(
c
.
desc
.
Replace
(
"'"
,
"''"
));
st
.
Append
(
c
.
desc
.
Replace
(
"'"
,
"''"
));
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
...
@@ -432,8 +511,7 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
...
@@ -432,8 +511,7 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
}
}
st
.
Append
(
"');"
);
st
.
Append
(
"');"
);
string
sql
=
st
.
ToString
();
string
sql
=
st
.
ToString
();
st
=
null
;
return
sql
;
return
sql
;
}
}
#
endregion
#
endregion
...
@@ -471,8 +549,7 @@ public static string GetUpdateSQL(Card c)
...
@@ -471,8 +549,7 @@ public static string GetUpdateSQL(Card c)
st
.
Append
(
"' where id="
);
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
"' where id="
);
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
";"
);
st
.
Append
(
";"
);
string
sql
=
st
.
ToString
();
string
sql
=
st
.
ToString
();
st
=
null
;
return
sql
;
return
sql
;
}
}
#
endregion
#
endregion
...
@@ -491,7 +568,7 @@ public static string GetDeleteSQL(Card c)
...
@@ -491,7 +568,7 @@ public static string GetDeleteSQL(Card c)
#
endregion
#
endregion
public
static
void
exportSql
(
S
tring
file
,
params
Card
[]
cards
){
public
static
void
ExportSql
(
s
tring
file
,
params
Card
[]
cards
){
using
(
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
,
FileAccess
.
Write
))
using
(
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
...
@@ -503,7 +580,7 @@ public static string GetDeleteSQL(Card c)
...
@@ -503,7 +580,7 @@ public static string GetDeleteSQL(Card c)
}
}
}
}
public
static
CardPack
f
indPack
(
string
db
,
long
id
){
public
static
CardPack
F
indPack
(
string
db
,
long
id
){
CardPack
cardpack
=
null
;
CardPack
cardpack
=
null
;
if
(
File
.
Exists
(
db
)
&&
id
>=
0
)
if
(
File
.
Exists
(
db
)
&&
id
>=
0
)
{
{
...
@@ -517,12 +594,14 @@ public static string GetDeleteSQL(Card c)
...
@@ -517,12 +594,14 @@ public static string GetDeleteSQL(Card c)
{
{
if
(
reader
.
Read
())
if
(
reader
.
Read
())
{
{
cardpack
=
new
CardPack
(
id
);
cardpack
=
new
CardPack
(
id
)
cardpack
.
pack_id
=
reader
.
GetString
(
1
);
{
cardpack
.
pack_name
=
reader
.
GetString
(
2
);
pack_id
=
reader
.
GetString
(
1
),
cardpack
.
rarity
=
reader
.
GetString
(
3
);
pack_name
=
reader
.
GetString
(
2
),
cardpack
.
date
=
reader
.
GetString
(
4
);
rarity
=
reader
.
GetString
(
3
),
}
date
=
reader
.
GetString
(
4
)
};
}
reader
.
Close
();
reader
.
Close
();
}
}
}
}
...
...
DataEditorX/Core/LuaFunction.cs
View file @
bc0829bf
...
@@ -19,26 +19,26 @@ namespace DataEditorX
...
@@ -19,26 +19,26 @@ namespace DataEditorX
public
class
LuaFunction
public
class
LuaFunction
{
{
#
region
日志
log
#
region
日志
log
static
void
ResetLog
(
string
file
)
static
void
ResetLog
()
{
{
File
.
Delete
(
logtxt
);
File
.
Delete
(
_
logtxt
);
}
}
static
void
Log
(
string
str
)
static
void
Log
(
string
str
)
{
{
File
.
AppendAllText
(
logtxt
,
str
+
Environment
.
NewLine
);
File
.
AppendAllText
(
_
logtxt
,
str
+
Environment
.
NewLine
);
}
}
#
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
readonly
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
;
if
(
File
.
Exists
(
funtxt
))
if
(
File
.
Exists
(
funtxt
))
{
{
string
[]
lines
=
File
.
ReadAllLines
(
funtxt
);
string
[]
lines
=
File
.
ReadAllLines
(
funtxt
);
...
@@ -50,8 +50,11 @@ public static void Read(string funtxt)
...
@@ -50,8 +50,11 @@ public static void Read(string funtxt)
if
(
string
.
IsNullOrEmpty
(
line
)
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"=="
)
||
line
.
StartsWith
(
"=="
)
||
line
.
StartsWith
(
"#"
))
||
line
.
StartsWith
(
"#"
))
continue
;
{
if
(
line
.
StartsWith
(
"●"
))
continue
;
}
if
(
line
.
StartsWith
(
"●"
))
{
{
//添加之前的函数
//添加之前的函数
AddOldFun
(
name
,
desc
);
AddOldFun
(
name
,
desc
);
...
@@ -76,13 +79,13 @@ static void AddOldFun(string name, string desc)
...
@@ -76,13 +79,13 @@ 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
);
}
}
}
}
}
}
...
@@ -99,10 +102,10 @@ public static bool Find(string path)
...
@@ -99,10 +102,10 @@ public static bool Find(string path)
string
name
=
"interpreter.cpp"
;
string
name
=
"interpreter.cpp"
;
string
file
=
Path
.
Combine
(
path
,
name
);
string
file
=
Path
.
Combine
(
path
,
name
);
string
file2
=
Path
.
Combine
(
Path
.
Combine
(
path
,
"ocgcore"
),
name
);
string
file2
=
Path
.
Combine
(
Path
.
Combine
(
path
,
"ocgcore"
),
name
);
logtxt
=
Path
.
Combine
(
path
,
"find_functions.log"
);
_
logtxt
=
Path
.
Combine
(
path
,
"find_functions.log"
);
ResetLog
(
logtxt
);
ResetLog
();
funclisttxt
=
Path
.
Combine
(
path
,
"_functions.txt"
);
_
funclisttxt
=
Path
.
Combine
(
path
,
"_functions.txt"
);
File
.
Delete
(
funclisttxt
);
File
.
Delete
(
_
funclisttxt
);
if
(!
File
.
Exists
(
file
)){
//判断用户选择的目录
if
(!
File
.
Exists
(
file
)){
//判断用户选择的目录
Log
(
"error: no find file "
+
file
);
Log
(
"error: no find file "
+
file
);
if
(
File
.
Exists
(
file2
)){
if
(
File
.
Exists
(
file2
)){
...
@@ -135,16 +138,19 @@ public static bool Find(string path)
...
@@ -135,16 +138,19 @@ public static bool Find(string path)
//保存
//保存
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
();
}
}
...
@@ -171,8 +177,10 @@ static string ToTitle(string str)
...
@@ -171,8 +177,10 @@ static string ToTitle(string str)
string
k
=
ToTitle
(
name
)+
"."
+
m
.
Groups
[
1
].
Value
;
string
k
=
ToTitle
(
name
)+
"."
+
m
.
Groups
[
1
].
Value
;
string
v
=
m
.
Groups
[
2
].
Value
;
string
v
=
m
.
Groups
[
2
].
Value
;
if
(!
dic
.
ContainsKey
(
k
))
if
(!
dic
.
ContainsKey
(
k
))
dic
.
Add
(
k
,
v
);
{
}
dic
.
Add
(
k
,
v
);
}
}
}
}
return
dic
;
return
dic
;
}
}
...
@@ -189,41 +197,63 @@ static string FindCode(string texts,string name)
...
@@ -189,41 +197,63 @@ static string FindCode(string texts,string name)
if
(
mc
.
Success
)
if
(
mc
.
Success
)
{
{
if
(
mc
.
Groups
.
Count
>
1
)
if
(
mc
.
Groups
.
Count
>
1
)
return
mc
.
Groups
[
0
].
Value
{
return
mc
.
Groups
[
0
].
Value
.
Replace
(
"\r\n"
,
"\n"
)
.
Replace
(
"\r\n"
,
"\n"
)
.
Replace
(
"\r"
,
"\n"
)
.
Replace
(
"\r"
,
"\n"
)
.
Replace
(
"\n"
,
Environment
.
NewLine
);
.
Replace
(
"\n"
,
Environment
.
NewLine
);
}
}
}
return
""
;
return
""
;
}
}
#
endregion
#
endregion
#
region
find
return
#
region
find
return
//查找返回类型
//查找返回类型
static
string
FindReturn
(
string
texts
,
string
name
)
static
string
FindReturn
(
string
texts
)
{
{
string
restr
=
""
;
string
restr
=
""
;
if
(
texts
.
IndexOf
(
"lua_pushboolean"
)>=
0
)
if
(
texts
.
IndexOf
(
"lua_pushboolean"
)>=
0
)
return
"bool "
;
{
else
return
"bool "
;
}
else
{
{
if
(
texts
.
IndexOf
(
"interpreter::card2value"
)>=
0
)
if
(
texts
.
IndexOf
(
"interpreter::card2value"
)>=
0
)
restr
+=
"Card "
;
{
if
(
texts
.
IndexOf
(
"interpreter::group2value"
)>=
0
)
restr
+=
"Card "
;
restr
+=
"Group "
;
}
if
(
texts
.
IndexOf
(
"interpreter::effect2value"
)>=
0
)
restr
+=
"Effect "
;
if
(
texts
.
IndexOf
(
"interpreter::group2value"
)>=
0
)
else
if
(
texts
.
IndexOf
(
"interpreter::function2value"
)>=
0
)
{
restr
+=
"function "
;
restr
+=
"Group "
;
}
if
(
texts
.
IndexOf
(
"lua_pushinteger"
)>=
0
)
restr
+=
"int "
;
if
(
texts
.
IndexOf
(
"interpreter::effect2value"
)>=
0
)
if
(
texts
.
IndexOf
(
"lua_pushstring"
)>=
0
)
{
restr
+=
"string "
;
restr
+=
"Effect "
;
}
}
else
if
(
texts
.
IndexOf
(
"interpreter::function2value"
)>=
0
)
{
restr
+=
"function "
;
}
if
(
texts
.
IndexOf
(
"lua_pushinteger"
)>=
0
)
{
restr
+=
"int "
;
}
if
(
texts
.
IndexOf
(
"lua_pushstring"
)>=
0
)
{
restr
+=
"string "
;
}
}
if
(
string
.
IsNullOrEmpty
(
restr
))
if
(
string
.
IsNullOrEmpty
(
restr
))
restr
=
"void "
;
{
if
(
restr
.
IndexOf
(
" "
)
!=
restr
.
Length
-
1
){
restr
=
"void "
;
}
if
(
restr
.
IndexOf
(
" "
)
!=
restr
.
Length
-
1
){
restr
=
restr
.
Replace
(
" "
,
"|"
).
Substring
(
0
,
restr
.
Length
-
1
)+
" "
;
restr
=
restr
.
Replace
(
" "
,
"|"
).
Substring
(
0
,
restr
.
Length
-
1
)+
" "
;
}
}
return
restr
;
return
restr
;
...
@@ -235,13 +265,21 @@ static string FindReturn(string texts,string name)
...
@@ -235,13 +265,21 @@ static string FindReturn(string texts,string name)
static
string
getUserType
(
string
str
)
static
string
getUserType
(
string
str
)
{
{
if
(
str
.
IndexOf
(
"card"
)>=
0
)
if
(
str
.
IndexOf
(
"card"
)>=
0
)
return
"Card"
;
{
if
(
str
.
IndexOf
(
"effect"
)>=
0
)
return
"Card"
;
return
"Effect"
;
}
if
(
str
.
IndexOf
(
"group"
)>=
0
)
return
"Group"
;
if
(
str
.
IndexOf
(
"effect"
)>=
0
)
{
return
"Any"
;
return
"Effect"
;
}
if
(
str
.
IndexOf
(
"group"
)>=
0
)
{
return
"Group"
;
}
return
"Any"
;
}
}
static
void
AddArgs
(
string
texts
,
string
regx
,
string
arg
,
SortedList
<
int
,
string
>
dic
)
static
void
AddArgs
(
string
texts
,
string
regx
,
string
arg
,
SortedList
<
int
,
string
>
dic
)
...
@@ -256,13 +294,17 @@ static void AddArgs(string texts,string regx,string arg,SortedList<int,string> d
...
@@ -256,13 +294,17 @@ static void AddArgs(string texts,string regx,string arg,SortedList<int,string> d
string
v
=
arg
;
string
v
=
arg
;
int
k
=
int
.
Parse
(
m
.
Groups
[
1
].
Value
);
int
k
=
int
.
Parse
(
m
.
Groups
[
1
].
Value
);
if
(
dic
.
ContainsKey
(
k
))
if
(
dic
.
ContainsKey
(
k
))
dic
[
k
]
=
dic
[
k
]+
"|"
+
v
;
{
else
dic
[
k
]
=
dic
[
k
]+
"|"
+
v
;
dic
.
Add
(
k
,
v
);
}
}
else
{
dic
.
Add
(
k
,
v
);
}
}
}
}
}
}
static
string
FindArgs
(
string
texts
,
string
name
)
static
string
FindArgs
(
string
texts
)
{
{
SortedList
<
int
,
string
>
dic
=
new
SortedList
<
int
,
string
>();
SortedList
<
int
,
string
>
dic
=
new
SortedList
<
int
,
string
>();
//card effect ggroup
//card effect ggroup
...
@@ -276,10 +318,14 @@ static string FindArgs(string texts,string name)
...
@@ -276,10 +318,14 @@ static string FindArgs(string texts,string name)
v
=
getUserType
(
v
);
v
=
getUserType
(
v
);
int
k
=
int
.
Parse
(
m
.
Groups
[
2
].
Value
);
int
k
=
int
.
Parse
(
m
.
Groups
[
2
].
Value
);
if
(
dic
.
ContainsKey
(
k
))
if
(
dic
.
ContainsKey
(
k
))
dic
[
k
]
=
dic
[
k
]+
"|"
+
v
;
{
else
dic
[
k
]
=
dic
[
k
]+
"|"
+
v
;
dic
.
Add
(
k
,
v
);
}
}
else
{
dic
.
Add
(
k
,
v
);
}
}
}
}
//function
//function
AddArgs
(
texts
AddArgs
(
texts
...
@@ -298,8 +344,11 @@ static string FindArgs(string texts,string name)
...
@@ -298,8 +344,11 @@ static string FindArgs(string texts,string name)
args
+=
dic
[
i
]+
", "
;
args
+=
dic
[
i
]+
", "
;
}
}
if
(
args
.
Length
>
1
)
if
(
args
.
Length
>
1
)
args
=
args
.
Substring
(
0
,
args
.
Length
-
2
);
{
args
+=
")"
;
args
=
args
.
Substring
(
0
,
args
.
Length
-
2
);
}
args
+=
")"
;
return
args
;
return
args
;
}
}
#
endregion
#
endregion
...
@@ -308,9 +357,12 @@ static string FindArgs(string texts,string name)
...
@@ -308,9 +357,12 @@ static string FindArgs(string texts,string name)
//查找旧函数的描述
//查找旧函数的描述
static
string
FindOldDesc
(
string
name
)
static
string
FindOldDesc
(
string
name
)
{
{
if
(
funclist
.
ContainsKey
(
name
))
if
(
_funclist
.
ContainsKey
(
name
))
return
funclist
[
name
];
{
return
""
;
return
_funclist
[
name
];
}
return
""
;
}
}
#
endregion
#
endregion
...
@@ -337,19 +389,19 @@ public static void GetFunctions(string name,string texts,string file)
...
@@ -337,19 +389,19 @@ public static void GetFunctions(string name,string texts,string file)
{
{
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
];
string
code
=
FindCode
(
cpps
,
v
);
string
code
=
FindCode
(
cpps
,
v
);
string
txt
=
"●"
+
FindReturn
(
code
,
v
)+
k
+
FindArgs
(
code
,
v
)
string
txt
=
"●"
+
FindReturn
(
code
)+
k
+
FindArgs
(
code
)
+
Environment
.
NewLine
+
Environment
.
NewLine
+
FindOldDesc
(
k
)
+
FindOldDesc
(
k
)
+
Environment
.
NewLine
+
Environment
.
NewLine
+
code
;
+
code
;
sw
.
WriteLine
(
txt
);
sw
.
WriteLine
(
txt
);
File
.
AppendAllText
(
funclisttxt
,
txt
+
Environment
.
NewLine
);
File
.
AppendAllText
(
_
funclisttxt
,
txt
+
Environment
.
NewLine
);
}
}
sw
.
Close
();
sw
.
Close
();
}
}
...
...
DataEditorX/Core/Mse/CardPack.cs
View file @
bc0829bf
...
@@ -31,8 +31,11 @@ public CardPack(long id)
...
@@ -31,8 +31,11 @@ public CardPack(long id)
public
string
getMseRarity
(){
public
string
getMseRarity
(){
if
(
this
.
rarity
==
null
)
if
(
this
.
rarity
==
null
)
return
"common"
;
{
string
rarity
=
this
.
rarity
.
Trim
().
ToLower
();
return
"common"
;
}
string
rarity
=
this
.
rarity
.
Trim
().
ToLower
();
if
(
rarity
.
Equals
(
"common"
)
||
rarity
.
Equals
(
"short print"
))
if
(
rarity
.
Equals
(
"common"
)
||
rarity
.
Equals
(
"short print"
))
{
{
return
"common"
;
return
"common"
;
...
...
DataEditorX/Core/Mse/MSEConfig.cs
View file @
bc0829bf
...
@@ -63,76 +63,99 @@ public class MSEConfig
...
@@ -63,76 +63,99 @@ public class MSEConfig
#
endregion
#
endregion
public
MSEConfig
(
string
path
)
public
MSEConfig
(
string
path
)
{
{
init
(
path
);
this
.
init
(
path
);
}
}
public
void
SetConfig
(
string
config
,
string
path
)
public
void
SetConfig
(
string
config
,
string
path
)
{
{
if
(!
File
.
Exists
(
config
))
if
(!
File
.
Exists
(
config
))
return
;
{
regx_monster
=
"(\\s\\S*?)"
;
return
;
regx_pendulum
=
"(\\s\\S*?)"
;
}
//设置文件名
configName
=
MyPath
.
getFullFileName
(
MSEConfig
.
TAG
,
config
);
replaces
=
new
SortedList
<
string
,
string
>();
this
.
regx_monster
=
"(\\s\\S*?)"
;
this
.
regx_pendulum
=
"(\\s\\S*?)"
;
//设置文件名
this
.
configName
=
MyPath
.
getFullFileName
(
MSEConfig
.
TAG
,
config
);
typeDic
=
new
SortedList
<
long
,
string
>();
this
.
replaces
=
new
SortedList
<
string
,
string
>();
raceDic
=
new
SortedList
<
long
,
string
>();
this
.
typeDic
=
new
SortedList
<
long
,
string
>();
this
.
raceDic
=
new
SortedList
<
long
,
string
>();
string
[]
lines
=
File
.
ReadAllLines
(
config
,
Encoding
.
UTF8
);
string
[]
lines
=
File
.
ReadAllLines
(
config
,
Encoding
.
UTF8
);
foreach
(
string
line
in
lines
)
foreach
(
string
line
in
lines
)
{
{
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"#"
))
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"#"
))
continue
;
{
if
(
line
.
StartsWith
(
TAG_CN2TW
))
continue
;
Iscn2tw
=
ConfHelper
.
getBooleanValue
(
line
);
}
else
if
(
line
.
StartsWith
(
TAG_SPELL
))
str_spell
=
ConfHelper
.
getValue
(
line
);
if
(
line
.
StartsWith
(
TAG_CN2TW
))
else
if
(
line
.
StartsWith
(
TAG_HEAD
))
{
head
=
ConfHelper
.
getMultLineValue
(
line
);
this
.
Iscn2tw
=
ConfHelper
.
getBooleanValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_END
))
}
end
=
ConfHelper
.
getMultLineValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_SPELL
))
else
if
(
line
.
StartsWith
(
TAG_TEXT
))
{
temp_text
=
ConfHelper
.
getMultLineValue
(
line
);
this
.
str_spell
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_TRAP
))
}
str_trap
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_HEAD
))
else
if
(
line
.
StartsWith
(
TAG_REG_PENDULUM
))
{
regx_pendulum
=
ConfHelper
.
getValue
(
line
);
this
.
head
=
ConfHelper
.
getMultLineValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_REG_MONSTER
))
}
regx_monster
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_END
))
else
if
(
line
.
StartsWith
(
TAG_MAXCOUNT
))
{
maxcount
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
this
.
end
=
ConfHelper
.
getMultLineValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_WIDTH
)){
}
width
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
else
if
(
line
.
StartsWith
(
TAG_TEXT
))
{
this
.
temp_text
=
ConfHelper
.
getMultLineValue
(
line
);
}
else
if
(
line
.
StartsWith
(
TAG_TRAP
))
{
this
.
str_trap
=
ConfHelper
.
getValue
(
line
);
}
else
if
(
line
.
StartsWith
(
TAG_REG_PENDULUM
))
{
this
.
regx_pendulum
=
ConfHelper
.
getValue
(
line
);
}
else
if
(
line
.
StartsWith
(
TAG_REG_MONSTER
))
{
this
.
regx_monster
=
ConfHelper
.
getValue
(
line
);
}
else
if
(
line
.
StartsWith
(
TAG_MAXCOUNT
))
{
this
.
maxcount
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_WIDTH
)){
this
.
width
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
}
}
else
if
(
line
.
StartsWith
(
TAG_HEIGHT
)){
else
if
(
line
.
StartsWith
(
TAG_HEIGHT
)){
height
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
this
.
height
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
}
}
else
if
(
line
.
StartsWith
(
TAG_PEND_WIDTH
)){
else
if
(
line
.
StartsWith
(
TAG_PEND_WIDTH
)){
pwidth
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
this
.
pwidth
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
}
}
else
if
(
line
.
StartsWith
(
TAG_PEND_HEIGHT
)){
else
if
(
line
.
StartsWith
(
TAG_PEND_HEIGHT
)){
pheight
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
this
.
pheight
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
}
}
else
if
(
line
.
StartsWith
(
TAG_NO_TEN
)){
else
if
(
line
.
StartsWith
(
TAG_NO_TEN
)){
no10
=
ConfHelper
.
getBooleanValue
(
line
);
this
.
no10
=
ConfHelper
.
getBooleanValue
(
line
);
}
else
if
(
line
.
StartsWith
(
TAG_NO_START_CARDS
)){
}
else
if
(
line
.
StartsWith
(
TAG_NO_START_CARDS
)){
string
val
=
ConfHelper
.
getValue
(
line
);
string
val
=
ConfHelper
.
getValue
(
line
);
string
[]
cs
=
val
.
Split
(
','
);
string
[]
cs
=
val
.
Split
(
','
);
noStartCards
=
new
long
[
cs
.
Length
];
this
.
noStartCards
=
new
long
[
cs
.
Length
];
int
i
=
0
;
int
i
=
0
;
foreach
(
string
str
in
cs
){
foreach
(
string
str
in
cs
){
long
l
=
0
;
long
.
TryParse
(
str
,
out
long
l
);
long
.
TryParse
(
str
,
out
l
);
this
.
noStartCards
[
i
++]
=
l
;
noStartCards
[
i
++]
=
l
;
}
}
}
}
else
if
(
line
.
StartsWith
(
TAG_IMAGE
))
else
if
(
line
.
StartsWith
(
TAG_IMAGE
))
{
{
//如果路径不合法,则为后面的路径
//如果路径不合法,则为后面的路径
imagepath
=
MyPath
.
CheckDir
(
ConfHelper
.
getValue
(
line
),
MyPath
.
Combine
(
path
,
PATH_IMAGE
));
this
.
imagepath
=
MyPath
.
CheckDir
(
ConfHelper
.
getValue
(
line
),
MyPath
.
Combine
(
path
,
PATH_IMAGE
));
//图片缓存目录
//图片缓存目录
imagecache
=
MyPath
.
Combine
(
imagepath
,
"cache"
);
this
.
imagecache
=
MyPath
.
Combine
(
this
.
imagepath
,
"cache"
);
MyPath
.
CreateDir
(
imagecache
);
MyPath
.
CreateDir
(
this
.
imagecache
);
}
}
else
if
(
line
.
StartsWith
(
TAG_REPALCE
))
else
if
(
line
.
StartsWith
(
TAG_REPALCE
))
{
//特数字替换
{
//特数字替换
...
@@ -140,24 +163,25 @@ public void SetConfig(string config, string path)
...
@@ -140,24 +163,25 @@ public void SetConfig(string config, string path)
string
p
=
ConfHelper
.
getRegex
(
ConfHelper
.
getValue1
(
word
));
string
p
=
ConfHelper
.
getRegex
(
ConfHelper
.
getValue1
(
word
));
string
r
=
ConfHelper
.
getRegex
(
ConfHelper
.
getValue2
(
word
));
string
r
=
ConfHelper
.
getRegex
(
ConfHelper
.
getValue2
(
word
));
if
(!
string
.
IsNullOrEmpty
(
p
))
if
(!
string
.
IsNullOrEmpty
(
p
))
replaces
.
Add
(
p
,
r
);
{
this
.
replaces
.
Add
(
p
,
r
);
}
}
}
else
if
(
line
.
StartsWith
(
TAG_RACE
))
else
if
(
line
.
StartsWith
(
TAG_RACE
))
{
//种族
{
//种族
ConfHelper
.
DicAdd
(
raceDic
,
line
);
ConfHelper
.
DicAdd
(
this
.
raceDic
,
line
);
}
}
else
if
(
line
.
StartsWith
(
TAG_TYPE
))
else
if
(
line
.
StartsWith
(
TAG_TYPE
))
{
//类型
{
//类型
ConfHelper
.
DicAdd
(
typeDic
,
line
);
ConfHelper
.
DicAdd
(
t
his
.
t
ypeDic
,
line
);
}
else
if
(
line
.
StartsWith
(
TAG_REIMAGE
)){
}
else
if
(
line
.
StartsWith
(
TAG_REIMAGE
)){
reimage
=
ConfHelper
.
getBooleanValue
(
line
);
this
.
reimage
=
ConfHelper
.
getBooleanValue
(
line
);
}
}
}
}
}
}
public
void
init
(
string
path
)
public
void
init
(
string
path
)
{
{
Iscn2tw
=
false
;
this
.
Iscn2tw
=
false
;
//读取配置
//读取配置
string
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MSEConfig
.
TAG
,
MyConfig
.
readString
(
MyConfig
.
TAG_MSE
)));
string
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MSEConfig
.
TAG
,
MyConfig
.
readString
(
MyConfig
.
TAG_MSE
)));
...
@@ -166,9 +190,11 @@ public void init(string path)
...
@@ -166,9 +190,11 @@ public void init(string path)
{
{
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MSEConfig
.
TAG
,
FILE_CONFIG_NAME
));
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MSEConfig
.
TAG
,
FILE_CONFIG_NAME
));
if
(!
File
.
Exists
(
tmp
))
if
(!
File
.
Exists
(
tmp
))
return
;
//如果默认的也不存在
{
}
return
;
//如果默认的也不存在
SetConfig
(
tmp
,
path
);
}
}
this
.
SetConfig
(
tmp
,
path
);
}
}
/// <summary>
/// <summary>
/// 是否调整图片
/// 是否调整图片
...
...
DataEditorX/Core/Mse/MseMaker.cs
View file @
bc0829bf
...
@@ -73,25 +73,25 @@ public class MseMaker
...
@@ -73,25 +73,25 @@ public class MseMaker
MSEConfig
cfg
;
MSEConfig
cfg
;
public
int
MaxNum
public
int
MaxNum
{
{
get
{
return
cfg
.
maxcount
;
}
get
{
return
this
.
cfg
.
maxcount
;
}
}
}
public
string
ImagePath
public
string
ImagePath
{
{
get
{
return
cfg
.
imagepath
;
}
get
{
return
this
.
cfg
.
imagepath
;
}
}
}
public
MseMaker
(
MSEConfig
mcfg
)
public
MseMaker
(
MSEConfig
mcfg
)
{
{
SetConfig
(
mcfg
);
this
.
SetConfig
(
mcfg
);
}
}
public
void
SetConfig
(
MSEConfig
mcfg
)
public
void
SetConfig
(
MSEConfig
mcfg
)
{
{
cfg
=
mcfg
;
this
.
cfg
=
mcfg
;
}
}
public
MSEConfig
GetConfig
()
public
MSEConfig
GetConfig
()
{
{
return
cfg
;
return
this
.
cfg
;
}
}
#
endregion
#
endregion
...
@@ -102,19 +102,19 @@ public string GetLine(string key, string word)
...
@@ -102,19 +102,19 @@ public string GetLine(string key, string word)
return
" "
+
key
+
": "
+
word
;
return
" "
+
key
+
": "
+
word
;
}
}
//特殊字
//特殊字
public
string
r
eItalic
(
string
str
)
public
string
R
eItalic
(
string
str
)
{
{
str
=
cn2tw
(
str
);
str
=
this
.
CN2TW
(
str
);
foreach
(
string
rs
in
cfg
.
replaces
.
Keys
)
foreach
(
string
rs
in
this
.
cfg
.
replaces
.
Keys
)
{
{
str
=
Regex
.
Replace
(
str
,
rs
,
cfg
.
replaces
[
rs
]);
str
=
Regex
.
Replace
(
str
,
rs
,
this
.
cfg
.
replaces
[
rs
]);
}
}
return
str
;
return
str
;
}
}
//简体转繁体
//简体转繁体
public
string
cn2tw
(
string
str
)
public
string
CN2TW
(
string
str
)
{
{
if
(
cfg
.
Iscn2tw
)
if
(
this
.
cfg
.
Iscn2tw
)
{
{
str
=
Strings
.
StrConv
(
str
,
VbStrConv
.
TraditionalChinese
,
0
);
str
=
Strings
.
StrConv
(
str
,
VbStrConv
.
TraditionalChinese
,
0
);
str
=
str
.
Replace
(
"巖"
,
"岩"
);
str
=
str
.
Replace
(
"巖"
,
"岩"
);
...
@@ -126,37 +126,58 @@ public string GetSpellTrapSymbol(Card c, bool isSpell)
...
@@ -126,37 +126,58 @@ public string GetSpellTrapSymbol(Card c, bool isSpell)
{
{
string
level
;
string
level
;
if
(
c
.
IsType
(
CardType
.
TYPE_EQUIP
))
if
(
c
.
IsType
(
CardType
.
TYPE_EQUIP
))
level
=
MseSpellTrap
.
EQUIP
;
{
else
if
(
c
.
IsType
(
CardType
.
TYPE_QUICKPLAY
))
level
=
MseSpellTrap
.
EQUIP
;
level
=
MseSpellTrap
.
QUICKPLAY
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_FIELD
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_QUICKPLAY
))
level
=
MseSpellTrap
.
FIELD
;
{
else
if
(
c
.
IsType
(
CardType
.
TYPE_CONTINUOUS
))
level
=
MseSpellTrap
.
QUICKPLAY
;
level
=
MseSpellTrap
.
CONTINUOUS
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
else
if
(
c
.
IsType
(
CardType
.
TYPE_FIELD
))
level
=
MseSpellTrap
.
RITUAL
;
{
else
if
(
c
.
IsType
(
CardType
.
TYPE_COUNTER
))
level
=
MseSpellTrap
.
FIELD
;
level
=
MseSpellTrap
.
COUNTER
;
}
else
if
(
cfg
.
str_spell
==
MSEConfig
.
TAG_REP
&&
cfg
.
str_trap
==
MSEConfig
.
TAG_REP
)
else
if
(
c
.
IsType
(
CardType
.
TYPE_CONTINUOUS
))
level
=
MseSpellTrap
.
NORMAL
;
//带文字的图片
{
else
level
=
MseSpellTrap
.
CONTINUOUS
;
level
=
""
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
{
level
=
MseSpellTrap
.
RITUAL
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_COUNTER
))
{
level
=
MseSpellTrap
.
COUNTER
;
}
else
if
(
this
.
cfg
.
str_spell
==
MSEConfig
.
TAG_REP
&&
this
.
cfg
.
str_trap
==
MSEConfig
.
TAG_REP
)
{
level
=
MseSpellTrap
.
NORMAL
;
//带文字的图片
}
else
{
level
=
""
;
}
if
(
isSpell
)
if
(
isSpell
)
level
=
cfg
.
str_spell
.
Replace
(
MSEConfig
.
TAG_REP
,
level
);
{
else
level
=
this
.
cfg
.
str_spell
.
Replace
(
MSEConfig
.
TAG_REP
,
level
);
level
=
cfg
.
str_trap
.
Replace
(
MSEConfig
.
TAG_REP
,
level
);
}
return
level
;
else
{
level
=
this
.
cfg
.
str_trap
.
Replace
(
MSEConfig
.
TAG_REP
,
level
);
}
return
level
;
}
}
//获取图片路径
//获取图片路径
public
static
string
GetCardImagePath
(
string
picpath
,
Card
c
)
public
static
string
GetCardImagePath
(
string
picpath
,
Card
c
)
{
{
//密码,带0密码,卡名
//密码,带0密码,卡名
string
jpg
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".jpg"
);
string
jpg
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".jpg"
);
string
jpg2
=
MyPath
.
Combine
(
picpath
,
c
.
i
dString
+
".jpg"
);
string
jpg2
=
MyPath
.
Combine
(
picpath
,
c
.
I
dString
+
".jpg"
);
string
jpg3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".jpg"
);
string
jpg3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".jpg"
);
string
png
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".png"
);
string
png
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".png"
);
string
png2
=
MyPath
.
Combine
(
picpath
,
c
.
i
dString
+
".png"
);
string
png2
=
MyPath
.
Combine
(
picpath
,
c
.
I
dString
+
".png"
);
string
png3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".png"
);
string
png3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".png"
);
if
(
File
.
Exists
(
jpg
))
if
(
File
.
Exists
(
jpg
))
{
{
...
@@ -232,9 +253,12 @@ public static string GetDesc(string cdesc, string regx)
...
@@ -232,9 +253,12 @@ public static string GetDesc(string cdesc, string regx)
Regex
regex
=
new
Regex
(
regx
,
RegexOptions
.
Multiline
);
Regex
regex
=
new
Regex
(
regx
,
RegexOptions
.
Multiline
);
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
""
;
}
}
public
string
ReText
(
string
text
)
public
string
ReText
(
string
text
)
...
@@ -260,17 +284,23 @@ public static string GetStar(long level)
...
@@ -260,17 +284,23 @@ public static string GetStar(long level)
//获取种族
//获取种族
public
string
GetRace
(
long
race
)
public
string
GetRace
(
long
race
)
{
{
if
(
cfg
.
raceDic
.
ContainsKey
(
race
))
if
(
this
.
cfg
.
raceDic
.
ContainsKey
(
race
))
return
cfg
.
raceDic
[
race
].
Trim
();
{
return
race
.
ToString
(
"x"
);
return
this
.
cfg
.
raceDic
[
race
].
Trim
();
}
return
race
.
ToString
(
"x"
);
}
}
//获取类型文字
//获取类型文字
public
string
GetType
(
CardType
ctype
)
public
string
GetType
(
CardType
ctype
)
{
{
long
type
=
(
long
)
ctype
;
long
type
=
(
long
)
ctype
;
if
(
cfg
.
typeDic
.
ContainsKey
(
type
))
if
(
this
.
cfg
.
typeDic
.
ContainsKey
(
type
))
return
cfg
.
typeDic
[
type
].
Trim
();
{
return
type
.
ToString
(
"x"
);
return
this
.
cfg
.
typeDic
[
type
].
Trim
();
}
return
type
.
ToString
(
"x"
);
}
}
//获取卡片类型
//获取卡片类型
...
@@ -285,10 +315,10 @@ public string[] GetTypes(Card c)
...
@@ -285,10 +315,10 @@ public string[] GetTypes(Card c)
}
}
if
(
c
.
IsType
(
CardType
.
TYPE_MONSTER
))
if
(
c
.
IsType
(
CardType
.
TYPE_MONSTER
))
{
{
CardType
[]
cardTypes
=
CardTypes
.
GetMonsterTypes
(
c
.
type
,
cfg
.
no10
);
CardType
[]
cardTypes
=
CardTypes
.
GetMonsterTypes
(
c
.
type
,
this
.
cfg
.
no10
);
int
count
=
cardTypes
.
Length
;
int
count
=
cardTypes
.
Length
;
for
(
int
i
=
0
;
i
<
count
&&
i
<
MAX_TYPE
;
i
++){
for
(
int
i
=
0
;
i
<
count
&&
i
<
MAX_TYPE
;
i
++){
types
[
i
+
1
]
=
GetType
(
cardTypes
[
i
]);
types
[
i
+
1
]
=
this
.
GetType
(
cardTypes
[
i
]);
}
}
if
(
cardTypes
.
Length
>
0
){
if
(
cardTypes
.
Length
>
0
){
if
(
c
.
IsType
(
CardType
.
TYPE_LINK
)){
if
(
c
.
IsType
(
CardType
.
TYPE_LINK
)){
...
@@ -345,12 +375,12 @@ public string[] GetTypes(Card c)
...
@@ -345,12 +375,12 @@ public string[] GetTypes(Card c)
{
{
// MessageBox.Show(""+cfg.replaces.Keys[0]+"/"+cfg.replaces[cfg.replaces.Keys[0]]);
// MessageBox.Show(""+cfg.replaces.Keys[0]+"/"+cfg.replaces[cfg.replaces.Keys[0]]);
Dictionary
<
Card
,
string
>
list
=
new
Dictionary
<
Card
,
string
>();
Dictionary
<
Card
,
string
>
list
=
new
Dictionary
<
Card
,
string
>();
string
pic
=
cfg
.
imagepath
;
string
pic
=
this
.
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
(
this
.
cfg
.
head
);
foreach
(
Card
c
in
cards
)
foreach
(
Card
c
in
cards
)
{
{
string
jpg
=
GetCardImagePath
(
pic
,
c
);
string
jpg
=
GetCardImagePath
(
pic
,
c
);
...
@@ -359,13 +389,17 @@ public string[] GetTypes(Card c)
...
@@ -359,13 +389,17 @@ public string[] GetTypes(Card c)
list
.
Add
(
c
,
jpg
);
list
.
Add
(
c
,
jpg
);
jpg
=
Path
.
GetFileName
(
jpg
);
jpg
=
Path
.
GetFileName
(
jpg
);
}
}
CardPack
cardpack
=
DataBase
.
f
indPack
(
cardpack_db
,
c
.
id
);
CardPack
cardpack
=
DataBase
.
F
indPack
(
cardpack_db
,
c
.
id
);
if
(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
if
(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
sw
.
WriteLine
(
getSpellTrap
(
c
,
jpg
,
c
.
IsType
(
CardType
.
TYPE_SPELL
),
cardpack
,
rarity
));
{
else
sw
.
WriteLine
(
this
.
getSpellTrap
(
c
,
jpg
,
c
.
IsType
(
CardType
.
TYPE_SPELL
),
cardpack
,
rarity
));
sw
.
WriteLine
(
getMonster
(
c
,
jpg
,
cardpack
,
rarity
));
}
}
else
sw
.
WriteLine
(
cfg
.
end
);
{
sw
.
WriteLine
(
this
.
getMonster
(
c
,
jpg
,
cardpack
,
rarity
));
}
}
sw
.
WriteLine
(
this
.
cfg
.
end
);
sw
.
Close
();
sw
.
Close
();
}
}
...
@@ -386,15 +420,15 @@ public string[] GetTypes(Card c)
...
@@ -386,15 +420,15 @@ public string[] GetTypes(Card c)
string
getMonster
(
Card
c
,
string
img
,
CardPack
cardpack
=
null
,
bool
rarity
=
true
)
string
getMonster
(
Card
c
,
string
img
,
CardPack
cardpack
=
null
,
bool
rarity
=
true
)
{
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
string
[]
types
=
GetTypes
(
c
);
string
[]
types
=
this
.
GetTypes
(
c
);
string
race
=
GetRace
(
c
.
race
);
string
race
=
this
.
GetRace
(
c
.
race
);
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
GetLine
(
TAG_CARDTYPE
,
types
[
0
]));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CARDTYPE
,
types
[
0
]));
sb
.
AppendLine
(
GetLine
(
TAG_NAME
,
r
eItalic
(
c
.
name
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NAME
,
this
.
R
eItalic
(
c
.
name
)));
sb
.
AppendLine
(
GetLine
(
TAG_ATTRIBUTE
,
GetAttribute
(
c
.
attribute
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_ATTRIBUTE
,
GetAttribute
(
c
.
attribute
)));
bool
noStar
=
false
;
bool
noStar
=
false
;
if
(
cfg
.
noStartCards
!=
null
){
if
(
this
.
cfg
.
noStartCards
!=
null
){
foreach
(
long
id
in
cfg
.
noStartCards
){
foreach
(
long
id
in
this
.
cfg
.
noStartCards
){
if
(
c
.
alias
==
id
||
c
.
id
==
id
){
if
(
c
.
alias
==
id
||
c
.
id
==
id
){
noStar
=
true
;
noStar
=
true
;
break
;
break
;
...
@@ -402,72 +436,75 @@ string getMonster(Card c, string img,CardPack cardpack=null,bool rarity=true)
...
@@ -402,72 +436,75 @@ string getMonster(Card c, string img,CardPack cardpack=null,bool rarity=true)
}
}
}
}
if
(!
noStar
){
if
(!
noStar
){
sb
.
AppendLine
(
GetLine
(
TAG_LEVEL
,
GetStar
(
c
.
level
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_LEVEL
,
GetStar
(
c
.
level
)));
}
}
sb
.
AppendLine
(
GetLine
(
TAG_IMAGE
,
img
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_IMAGE
,
img
));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE1
,
cn2tw
(
race
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE1
,
this
.
CN2TW
(
race
)));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE2
,
cn2tw
(
types
[
1
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE2
,
this
.
CN2TW
(
types
[
1
])));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE3
,
cn2tw
(
types
[
2
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE3
,
this
.
CN2TW
(
types
[
2
])));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE4
,
cn2tw
(
types
[
3
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE4
,
this
.
CN2TW
(
types
[
3
])));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE5
,
cn2tw
(
types
[
4
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE5
,
this
.
CN2TW
(
types
[
4
])));
if
(
cardpack
!=
null
){
if
(
cardpack
!=
null
){
sb
.
AppendLine
(
GetLine
(
TAG_NUMBER
,
cardpack
.
pack_id
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NUMBER
,
cardpack
.
pack_id
));
if
(
rarity
){
if
(
rarity
){
sb
.
AppendLine
(
GetLine
(
TAG_RARITY
,
cardpack
.
getMseRarity
()));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_RARITY
,
cardpack
.
getMseRarity
()));
}
}
}
}
if
(
c
.
IsType
(
CardType
.
TYPE_LINK
)){
if
(
c
.
IsType
(
CardType
.
TYPE_LINK
)){
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
DownLeft
)){
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
DownLeft
)){
sb
.
AppendLine
(
GetLine
(
TAG_Link_Marker_DL
,
"yes"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_DL
,
"yes"
));
}
}
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
Down
)){
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
Down
)){
sb
.
AppendLine
(
GetLine
(
TAG_Link_Marker_Down
,
"yes"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Down
,
"yes"
));
}
}
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
DownRight
)){
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
DownRight
)){
sb
.
AppendLine
(
GetLine
(
TAG_Link_Marker_DR
,
"yes"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_DR
,
"yes"
));
}
}
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
UpLeft
)){
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
UpLeft
)){
sb
.
AppendLine
(
GetLine
(
TAG_Link_Marker_UL
,
"yes"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_UL
,
"yes"
));
}
}
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
Up
)){
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
Up
)){
sb
.
AppendLine
(
GetLine
(
TAG_Link_Marker_Up
,
"yes"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Up
,
"yes"
));
}
}
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
UpRight
)){
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
UpRight
)){
sb
.
AppendLine
(
GetLine
(
TAG_Link_Marker_UR
,
"yes"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_UR
,
"yes"
));
}
}
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
Left
)){
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
Left
)){
sb
.
AppendLine
(
GetLine
(
TAG_Link_Marker_Left
,
"yes"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Left
,
"yes"
));
}
}
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
Right
)){
if
(
CardLink
.
isLink
(
c
.
def
,
CardLink
.
Right
)){
sb
.
AppendLine
(
GetLine
(
TAG_Link_Marker_Right
,
"yes"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Right
,
"yes"
));
}
}
sb
.
AppendLine
(
GetLine
(
TAG_Link_Number
,
""
+
getLinkNumber
(
c
.
def
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Number
,
""
+
this
.
getLinkNumber
(
c
.
def
)));
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
ReText
(
r
eItalic
(
c
.
desc
)));
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
R
eItalic
(
c
.
desc
)));
}
else
{
}
else
{
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//P怪兽
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//P怪兽
{
{
string
text
=
GetDesc
(
c
.
desc
,
cfg
.
regx_monster
);
string
text
=
GetDesc
(
c
.
desc
,
this
.
cfg
.
regx_monster
);
if
(
string
.
IsNullOrEmpty
(
text
))
if
(
string
.
IsNullOrEmpty
(
text
))
text
=
c
.
desc
;
{
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
text
=
c
.
desc
;
}
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
//sb.AppendLine(cfg.regx_monster + ":" + cfg.regx_pendulum);
//sb.AppendLine(cfg.regx_monster + ":" + cfg.regx_pendulum);
sb
.
AppendLine
(
" "
+
ReText
(
r
eItalic
(
text
)));
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
R
eItalic
(
text
)));
sb
.
AppendLine
(
GetLine
(
TAG_PENDULUM
,
"medium"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_PENDULUM
,
"medium"
));
sb
.
AppendLine
(
GetLine
(
TAG_PSCALE1
,
((
c
.
level
>>
0x18
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_PSCALE1
,
((
c
.
level
>>
0x18
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
GetLine
(
TAG_PSCALE2
,
((
c
.
level
>>
0x10
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_PSCALE2
,
((
c
.
level
>>
0x10
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
" "
+
TAG_PEND_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
TAG_PEND_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
ReText
(
reItalic
(
GetDesc
(
c
.
desc
,
cfg
.
regx_pendulum
))));
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
GetDesc
(
c
.
desc
,
this
.
cfg
.
regx_pendulum
))));
}
else
//一般怪兽
}
else
//一般怪兽
{
{
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
ReText
(
r
eItalic
(
c
.
desc
)));
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
R
eItalic
(
c
.
desc
)));
}
}
sb
.
AppendLine
(
GetLine
(
TAG_DEF
,
(
c
.
def
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
def
.
ToString
()));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_DEF
,
(
c
.
def
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
def
.
ToString
()));
}
}
sb
.
AppendLine
(
GetLine
(
TAG_ATK
,
(
c
.
atk
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
atk
.
ToString
()));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_ATK
,
(
c
.
atk
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
atk
.
ToString
()));
sb
.
AppendLine
(
GetLine
(
TAG_CODE
,
c
.
i
dString
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CODE
,
c
.
I
dString
));
return
sb
.
ToString
();
return
sb
.
ToString
();
}
}
//魔法陷阱
//魔法陷阱
...
@@ -475,20 +512,20 @@ string getSpellTrap(Card c, string img, bool isSpell,CardPack cardpack=null,bool
...
@@ -475,20 +512,20 @@ string getSpellTrap(Card c, string img, bool isSpell,CardPack cardpack=null,bool
{
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
GetLine
(
TAG_CARDTYPE
,
isSpell
?
"spell card"
:
"trap card"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CARDTYPE
,
isSpell
?
"spell card"
:
"trap card"
));
sb
.
AppendLine
(
GetLine
(
TAG_NAME
,
r
eItalic
(
c
.
name
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NAME
,
this
.
R
eItalic
(
c
.
name
)));
sb
.
AppendLine
(
GetLine
(
TAG_ATTRIBUTE
,
isSpell
?
"spell"
:
"trap"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_ATTRIBUTE
,
isSpell
?
"spell"
:
"trap"
));
sb
.
AppendLine
(
GetLine
(
TAG_LEVEL
,
GetSpellTrapSymbol
(
c
,
isSpell
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_LEVEL
,
this
.
GetSpellTrapSymbol
(
c
,
isSpell
)));
sb
.
AppendLine
(
GetLine
(
TAG_IMAGE
,
img
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_IMAGE
,
img
));
if
(
cardpack
!=
null
){
if
(
cardpack
!=
null
){
sb
.
AppendLine
(
GetLine
(
TAG_NUMBER
,
cardpack
.
pack_id
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NUMBER
,
cardpack
.
pack_id
));
if
(
rarity
){
if
(
rarity
){
sb
.
AppendLine
(
GetLine
(
TAG_RARITY
,
cardpack
.
getMseRarity
()));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_RARITY
,
cardpack
.
getMseRarity
()));
}
}
}
}
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
ReText
(
r
eItalic
(
c
.
desc
)));
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
R
eItalic
(
c
.
desc
)));
sb
.
AppendLine
(
GetLine
(
TAG_CODE
,
c
.
i
dString
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CODE
,
c
.
I
dString
));
return
sb
.
ToString
();
return
sb
.
ToString
();
}
}
#
endregion
#
endregion
...
@@ -527,11 +564,13 @@ long GetRaceInt(string race)
...
@@ -527,11 +564,13 @@ long GetRaceInt(string race)
{
{
if
(!
string
.
IsNullOrEmpty
(
race
))
if
(!
string
.
IsNullOrEmpty
(
race
))
{
{
foreach
(
long
key
in
cfg
.
raceDic
.
Keys
)
foreach
(
long
key
in
this
.
cfg
.
raceDic
.
Keys
)
{
{
if
(
race
.
Equals
(
cfg
.
raceDic
[
key
]))
if
(
race
.
Equals
(
this
.
cfg
.
raceDic
[
key
]))
return
key
;
{
}
return
key
;
}
}
}
}
return
(
long
)
CardRace
.
RACE_NONE
;
return
(
long
)
CardRace
.
RACE_NONE
;
}
}
...
@@ -539,11 +578,13 @@ long GetTypeInt(string type)
...
@@ -539,11 +578,13 @@ long GetTypeInt(string type)
{
{
if
(!
string
.
IsNullOrEmpty
(
type
))
if
(!
string
.
IsNullOrEmpty
(
type
))
{
{
foreach
(
long
key
in
cfg
.
typeDic
.
Keys
)
foreach
(
long
key
in
this
.
cfg
.
typeDic
.
Keys
)
{
{
if
(
type
.
Equals
(
cfg
.
typeDic
[
key
]))
if
(
type
.
Equals
(
this
.
cfg
.
typeDic
[
key
]))
return
key
;
{
}
return
key
;
}
}
}
}
return
0
;
return
0
;
}
}
...
@@ -554,8 +595,10 @@ static string GetValue(string content, string tag)
...
@@ -554,8 +595,10 @@ static string GetValue(string content, string tag)
if
(
m
.
Success
)
if
(
m
.
Success
)
{
{
if
(
m
.
Groups
.
Count
>=
2
)
if
(
m
.
Groups
.
Count
>=
2
)
return
RemoveTag
(
m
.
Groups
[
1
].
Value
);
{
}
return
RemoveTag
(
m
.
Groups
[
1
].
Value
);
}
}
return
""
;
return
""
;
}
}
//多行
//多行
...
@@ -580,28 +623,50 @@ long GetSpellTrapType(string level)
...
@@ -580,28 +623,50 @@ long GetSpellTrapType(string level)
long
type
=
0
;
long
type
=
0
;
//魔法陷阱
//魔法陷阱
if
(
level
.
Contains
(
MseSpellTrap
.
EQUIP
))
if
(
level
.
Contains
(
MseSpellTrap
.
EQUIP
))
type
=
(
long
)
CardType
.
TYPE_EQUIP
;
{
if
(
level
.
Contains
(
MseSpellTrap
.
QUICKPLAY
))
type
=
(
long
)
CardType
.
TYPE_EQUIP
;
type
=
(
long
)
CardType
.
TYPE_QUICKPLAY
;
}
if
(
level
.
Contains
(
MseSpellTrap
.
FIELD
))
type
=
(
long
)
CardType
.
TYPE_FIELD
;
if
(
level
.
Contains
(
MseSpellTrap
.
QUICKPLAY
))
if
(
level
.
Contains
(
MseSpellTrap
.
CONTINUOUS
))
{
type
=
(
long
)
CardType
.
TYPE_CONTINUOUS
;
type
=
(
long
)
CardType
.
TYPE_QUICKPLAY
;
if
(
level
.
Contains
(
MseSpellTrap
.
RITUAL
))
}
type
=
(
long
)
CardType
.
TYPE_RITUAL
;
if
(
level
.
Contains
(
MseSpellTrap
.
COUNTER
))
if
(
level
.
Contains
(
MseSpellTrap
.
FIELD
))
type
=
(
long
)
CardType
.
TYPE_COUNTER
;
{
return
type
;
type
=
(
long
)
CardType
.
TYPE_FIELD
;
}
if
(
level
.
Contains
(
MseSpellTrap
.
CONTINUOUS
))
{
type
=
(
long
)
CardType
.
TYPE_CONTINUOUS
;
}
if
(
level
.
Contains
(
MseSpellTrap
.
RITUAL
))
{
type
=
(
long
)
CardType
.
TYPE_RITUAL
;
}
if
(
level
.
Contains
(
MseSpellTrap
.
COUNTER
))
{
type
=
(
long
)
CardType
.
TYPE_COUNTER
;
}
return
type
;
}
}
long
GetMonsterType
(
string
cardtype
)
long
GetMonsterType
(
string
cardtype
)
{
{
long
type
=
0
;
long
type
;
if
(
cardtype
.
Equals
(
MseCardType
.
CARD_SPELL
))
if
(
cardtype
.
Equals
(
MseCardType
.
CARD_SPELL
))
type
=
(
long
)
CardType
.
TYPE_SPELL
;
{
else
if
(
cardtype
.
Equals
(
MseCardType
.
CARD_TRAP
))
type
=
(
long
)
CardType
.
TYPE_SPELL
;
type
=
(
long
)
CardType
.
TYPE_TRAP
;
}
else
else
if
(
cardtype
.
Equals
(
MseCardType
.
CARD_TRAP
))
{
type
=
(
long
)
CardType
.
TYPE_TRAP
;
}
else
{
{
type
=
(
long
)
CardType
.
TYPE_MONSTER
;
type
=
(
long
)
CardType
.
TYPE_MONSTER
;
switch
(
cardtype
)
switch
(
cardtype
)
...
@@ -640,13 +705,16 @@ long GetCardType(string cardtype, string level, params string[] types)
...
@@ -640,13 +705,16 @@ long GetCardType(string cardtype, string level, params string[] types)
{
{
long
type
=
0
;
long
type
=
0
;
//魔法陷阱
//魔法陷阱
type
|=
GetSpellTrapType
(
level
);
type
|=
this
.
GetSpellTrapType
(
level
);
//怪兽
//怪兽
type
|=
GetMonsterType
(
cardtype
);
type
|=
this
.
GetMonsterType
(
cardtype
);
//types是识别怪兽效果类型
//types是识别怪兽效果类型
foreach
(
string
typ
in
types
)
foreach
(
string
typ
in
types
)
type
|=
GetTypeInt
(
typ
);
{
return
type
;
type
|=
this
.
GetTypeInt
(
typ
);
}
return
type
;
}
}
static
string
RemoveTag
(
string
word
)
static
string
RemoveTag
(
string
word
)
...
@@ -659,57 +727,70 @@ static string RemoveTag(string word)
...
@@ -659,57 +727,70 @@ static string RemoveTag(string word)
public
Card
ReadCard
(
string
content
,
out
string
img
)
public
Card
ReadCard
(
string
content
,
out
string
img
)
{
{
string
tmp
;
string
tmp
;
int
itmp
;
Card
c
=
new
Card
Card
c
=
new
Card
();
{
c
.
ot
=
(
int
)
CardRule
.
OCGTCG
;
ot
=
(
int
)
CardRule
.
OCGTCG
,
//卡名
//卡名
c
.
name
=
GetValue
(
content
,
TAG_NAME
);
name
=
GetValue
(
content
,
TAG_NAME
)
tmp
=
GetValue
(
content
,
TAG_LEVEL
);
};
tmp
=
GetValue
(
content
,
TAG_LEVEL
);
//卡片种族
//卡片种族
c
.
race
=
GetRaceInt
(
GetValue
(
content
,
TAG_TYPE1
));
c
.
race
=
this
.
GetRaceInt
(
GetValue
(
content
,
TAG_TYPE1
));
//卡片类型
//卡片类型
c
.
type
=
GetCardType
(
GetValue
(
content
,
TAG_CARDTYPE
),
tmp
,
c
.
type
=
this
.
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
=
this
.
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
;
}
//属性
//属性
c
.
attribute
=
GetAttributeInt
(
GetValue
(
content
,
TAG_ATTRIBUTE
));
c
.
attribute
=
GetAttributeInt
(
GetValue
(
content
,
TAG_ATTRIBUTE
));
//密码
//密码
long
.
TryParse
(
GetValue
(
content
,
TAG_CODE
),
out
c
.
id
);
long
.
TryParse
(
GetValue
(
content
,
TAG_CODE
),
out
c
.
id
);
//ATK
//ATK
tmp
=
GetValue
(
content
,
TAG_ATK
);
tmp
=
GetValue
(
content
,
TAG_ATK
);
if
(
tmp
==
UNKNOWN_ATKDEF
)
if
(
tmp
==
UNKNOWN_ATKDEF
)
c
.
atk
=
UNKNOWN_ATKDEF_VALUE
;
{
else
c
.
atk
=
UNKNOWN_ATKDEF_VALUE
;
int
.
TryParse
(
tmp
,
out
c
.
atk
);
}
//DEF
else
tmp
=
GetValue
(
content
,
TAG_DEF
);
{
int
.
TryParse
(
tmp
,
out
c
.
atk
);
}
//DEF
tmp
=
GetValue
(
content
,
TAG_DEF
);
if
(
tmp
==
UNKNOWN_ATKDEF
)
if
(
tmp
==
UNKNOWN_ATKDEF
)
c
.
def
=
UNKNOWN_ATKDEF_VALUE
;
{
else
c
.
def
=
UNKNOWN_ATKDEF_VALUE
;
int
.
TryParse
(
tmp
,
out
c
.
def
);
}
//图片
else
img
=
GetValue
(
content
,
TAG_IMAGE
);
{
int
.
TryParse
(
tmp
,
out
c
.
def
);
}
//图片
img
=
GetValue
(
content
,
TAG_IMAGE
);
//摇摆
//摇摆
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
{
//根据预设的模版,替换内容
{
//根据预设的模版,替换内容
tmp
=
cfg
.
temp_text
.
Replace
(
TAG_REP_TEXT
,
tmp
=
this
.
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
c
.
desc
=
GetMultiValue
(
content
,
TAG_TEXT
);
{
//摇摆刻度
c
.
desc
=
GetMultiValue
(
content
,
TAG_TEXT
);
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE1
),
out
itmp
);
}
//摇摆刻度
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE1
),
out
int
itmp
);
c
.
level
+=
(
itmp
<<
0x18
);
c
.
level
+=
(
itmp
<<
0x18
);
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE2
),
out
itmp
);
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE2
),
out
itmp
);
c
.
level
+=
(
itmp
<<
0x10
);
c
.
level
+=
(
itmp
<<
0x10
);
...
@@ -720,8 +801,11 @@ public Card[] ReadCards(string set, bool repalceOld)
...
@@ -720,8 +801,11 @@ public Card[] ReadCards(string set, bool repalceOld)
{
{
List
<
Card
>
cards
=
new
List
<
Card
>();
List
<
Card
>
cards
=
new
List
<
Card
>();
if
(!
File
.
Exists
(
set
))
if
(!
File
.
Exists
(
set
))
return
null
;
{
string
allcontent
=
File
.
ReadAllText
(
set
,
Encoding
.
UTF8
);
return
null
;
}
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
);
...
@@ -732,21 +816,27 @@ public Card[] ReadCards(string set, bool repalceOld)
...
@@ -732,21 +816,27 @@ public Card[] ReadCards(string set, bool repalceOld)
{
{
string
content
=
match
.
Groups
[
0
].
Value
;
string
content
=
match
.
Groups
[
0
].
Value
;
i
++;
i
++;
string
img
;
Card
c
=
this
.
ReadCard
(
content
,
out
string
img
);
Card
c
=
ReadCard
(
content
,
out
img
);
if
(
c
.
id
<=
0
)
if
(
c
.
id
<=
0
)
{
c
.
id
=
i
;
c
.
id
=
i
;
//添加卡片
}
cards
.
Add
(
c
);
//添加卡片
cards
.
Add
(
c
);
//已经解压出来的图片
//已经解压出来的图片
string
saveimg
=
MyPath
.
Combine
(
cfg
.
imagepath
,
img
);
string
saveimg
=
MyPath
.
Combine
(
this
.
cfg
.
imagepath
,
img
);
if
(!
File
.
Exists
(
saveimg
))
//没有解压相应的图片
if
(!
File
.
Exists
(
saveimg
))
//没有解压相应的图片
continue
;
{
//改名后的图片
continue
;
img
=
MyPath
.
Combine
(
cfg
.
imagepath
,
c
.
idString
+
".jpg"
);
}
//改名后的图片
img
=
MyPath
.
Combine
(
this
.
cfg
.
imagepath
,
c
.
IdString
+
".jpg"
);
if
(
img
==
saveimg
)
//文件名相同
if
(
img
==
saveimg
)
//文件名相同
continue
;
{
if
(
File
.
Exists
(
img
))
continue
;
}
if
(
File
.
Exists
(
img
))
{
{
if
(
repalceOld
)
//如果存在,则备份原图
if
(
repalceOld
)
//如果存在,则备份原图
{
{
...
@@ -756,8 +846,10 @@ public Card[] ReadCards(string set, bool repalceOld)
...
@@ -756,8 +846,10 @@ public Card[] ReadCards(string set, bool repalceOld)
}
}
}
}
else
else
File
.
Move
(
saveimg
,
img
);
{
}
File
.
Move
(
saveimg
,
img
);
}
}
File
.
Delete
(
set
);
File
.
Delete
(
set
);
return
cards
.
ToArray
();
return
cards
.
ToArray
();
}
}
...
@@ -770,33 +862,38 @@ public Card[] ReadCards(string set, bool repalceOld)
...
@@ -770,33 +862,38 @@ public Card[] ReadCards(string set, bool repalceOld)
/// <param name="img"></param>
/// <param name="img"></param>
/// <param name="card"></param>
/// <param name="card"></param>
/// <returns></returns>
/// <returns></returns>
public
string
g
etImageCache
(
string
img
,
Card
card
){
public
string
G
etImageCache
(
string
img
,
Card
card
){
if
(!
cfg
.
reimage
){
if
(!
this
.
cfg
.
reimage
){
//不需要调整
//不需要调整
return
img
;
return
img
;
}
}
bool
isPendulum
=
card
.
IsType
(
CardType
.
TYPE_PENDULUM
);
bool
isPendulum
=
card
.
IsType
(
CardType
.
TYPE_PENDULUM
);
if
(
isPendulum
){
if
(
isPendulum
){
if
(
cfg
.
pwidth
<=
0
&&
cfg
.
pheight
<=
0
)
if
(
this
.
cfg
.
pwidth
<=
0
&&
this
.
cfg
.
pheight
<=
0
)
return
img
;
{
}
else
{
return
img
;
if
(
cfg
.
width
<=
0
&&
cfg
.
height
<=
0
)
}
return
img
;
}
}
else
{
if
(
this
.
cfg
.
width
<=
0
&&
this
.
cfg
.
height
<=
0
)
{
return
img
;
}
}
string
md5
=
MyUtils
.
GetMD5HashFromFile
(
img
);
string
md5
=
MyUtils
.
GetMD5HashFromFile
(
img
);
if
(
MyUtils
.
Md5isEmpty
(
md5
)||
cfg
.
imagecache
==
null
){
if
(
MyUtils
.
Md5isEmpty
(
md5
)||
this
.
cfg
.
imagecache
==
null
){
//md5为空
//md5为空
return
img
;
return
img
;
}
}
string
file
=
MyPath
.
Combine
(
cfg
.
imagecache
,
md5
);
string
file
=
MyPath
.
Combine
(
this
.
cfg
.
imagecache
,
md5
);
if
(!
File
.
Exists
(
file
)){
if
(!
File
.
Exists
(
file
)){
//生成缓存
//生成缓存
Bitmap
bmp
=
MyBitmap
.
readImage
(
img
);
Bitmap
bmp
=
MyBitmap
.
readImage
(
img
);
//缩放
//缩放
if
(
isPendulum
){
if
(
isPendulum
){
bmp
=
MyBitmap
.
Zoom
(
bmp
,
cfg
.
pwidth
,
cfg
.
pheight
);
bmp
=
MyBitmap
.
Zoom
(
bmp
,
this
.
cfg
.
pwidth
,
this
.
cfg
.
pheight
);
}
else
{
}
else
{
bmp
=
MyBitmap
.
Zoom
(
bmp
,
cfg
.
width
,
cfg
.
height
);
bmp
=
MyBitmap
.
Zoom
(
bmp
,
this
.
cfg
.
width
,
this
.
cfg
.
height
);
}
}
//保存文件
//保存文件
MyBitmap
.
SaveAsJPEG
(
bmp
,
file
,
100
);
MyBitmap
.
SaveAsJPEG
(
bmp
,
file
,
100
);
...
@@ -806,8 +903,8 @@ public Card[] ReadCards(string set, bool repalceOld)
...
@@ -806,8 +903,8 @@ public Card[] ReadCards(string set, bool repalceOld)
#
endregion
#
endregion
#
region
export
#
region
export
static
System
.
Diagnostics
.
Process
mseProcess
;
static
System
.
Diagnostics
.
Process
_
mseProcess
;
static
EventHandler
exitHandler
;
static
EventHandler
_
exitHandler
;
private
static
void
exportSetThread
(
object
obj
){
private
static
void
exportSetThread
(
object
obj
){
string
[]
args
=(
string
[])
obj
;
string
[]
args
=(
string
[])
obj
;
if
(
args
==
null
||
args
.
Length
<
3
){
if
(
args
==
null
||
args
.
Length
<
3
){
...
@@ -822,19 +919,19 @@ public Card[] ReadCards(string set, bool repalceOld)
...
@@ -822,19 +919,19 @@ public Card[] ReadCards(string set, bool repalceOld)
return
;
return
;
}
else
{
}
else
{
string
cmd
=
" --export "
+
setfile
.
Replace
(
"\\\\"
,
"\\"
).
Replace
(
"\\"
,
"/"
)+
" {card.gamecode}.png"
;
string
cmd
=
" --export "
+
setfile
.
Replace
(
"\\\\"
,
"\\"
).
Replace
(
"\\"
,
"/"
)+
" {card.gamecode}.png"
;
mseProcess
=
new
System
.
Diagnostics
.
Process
();
_
mseProcess
=
new
System
.
Diagnostics
.
Process
();
mseProcess
.
StartInfo
.
FileName
=
mse_path
;
_
mseProcess
.
StartInfo
.
FileName
=
mse_path
;
mseProcess
.
StartInfo
.
Arguments
=
cmd
;
_
mseProcess
.
StartInfo
.
Arguments
=
cmd
;
mseProcess
.
StartInfo
.
WorkingDirectory
=
path
;
_
mseProcess
.
StartInfo
.
WorkingDirectory
=
path
;
mseProcess
.
EnableRaisingEvents
=
true
;
_
mseProcess
.
EnableRaisingEvents
=
true
;
MyPath
.
CreateDir
(
path
);
MyPath
.
CreateDir
(
path
);
try
{
try
{
mseProcess
.
Start
();
_
mseProcess
.
Start
();
//等待结束,需要把当前方法放到线程里面
//等待结束,需要把当前方法放到线程里面
mseProcess
.
WaitForExit
();
_
mseProcess
.
WaitForExit
();
mseProcess
.
Exited
+=
new
EventHandler
(
exitHandler
);
_mseProcess
.
Exited
+=
new
EventHandler
(
_
exitHandler
);
mseProcess
.
Close
();
_
mseProcess
.
Close
();
mseProcess
=
null
;
_
mseProcess
=
null
;
System
.
Windows
.
Forms
.
MessageBox
.
Show
(
Language
.
LanguageHelper
.
GetMsg
(
LMSG
.
exportMseImages
));
System
.
Windows
.
Forms
.
MessageBox
.
Show
(
Language
.
LanguageHelper
.
GetMsg
(
LMSG
.
exportMseImages
));
}
catch
{
}
catch
{
...
@@ -843,37 +940,39 @@ public Card[] ReadCards(string set, bool repalceOld)
...
@@ -843,37 +940,39 @@ public Card[] ReadCards(string set, bool repalceOld)
}
}
public
static
bool
MseIsRunning
(){
public
static
bool
MseIsRunning
(){
return
mseProcess
!=
null
;
return
_
mseProcess
!=
null
;
}
}
public
static
void
MseStop
(){
public
static
void
MseStop
(){
try
{
try
{
mseProcess
.
Kill
();
_
mseProcess
.
Kill
();
mseProcess
.
Close
();
_
mseProcess
.
Close
();
}
catch
{}
}
catch
{}
}
}
public
static
void
e
xportSet
(
string
mse_path
,
string
setfile
,
string
path
,
EventHandler
handler
){
public
static
void
E
xportSet
(
string
mse_path
,
string
setfile
,
string
path
,
EventHandler
handler
){
if
(
string
.
IsNullOrEmpty
(
mse_path
)||
setfile
==
null
||
setfile
.
Length
==
0
){
if
(
string
.
IsNullOrEmpty
(
mse_path
)||
setfile
==
null
||
setfile
.
Length
==
0
){
return
;
return
;
}
}
ParameterizedThreadStart
ParStart
=
new
ParameterizedThreadStart
(
exportSetThread
);
ParameterizedThreadStart
ParStart
=
new
ParameterizedThreadStart
(
exportSetThread
);
Thread
myThread
=
new
Thread
(
ParStart
);
Thread
myThread
=
new
Thread
(
ParStart
)
myThread
.
IsBackground
=
true
;
{
myThread
.
Start
(
new
string
[]{
mse_path
,
setfile
,
path
});
IsBackground
=
true
exitHandler
=
handler
;
};
myThread
.
Start
(
new
string
[]{
mse_path
,
setfile
,
path
});
_exitHandler
=
handler
;
}
}
#
endregion
#
endregion
public
void
t
estPendulum
(
string
desc
)
public
void
T
estPendulum
(
string
desc
)
{
{
List
<
string
>
table
=
GetMPText
(
desc
);
List
<
string
>
table
=
this
.
GetMPText
(
desc
);
if
(
table
==
null
&&
table
.
Count
!=
2
)
if
(
table
==
null
&&
table
.
Count
!=
2
)
{
{
MessageBox
.
Show
(
"desc is null"
,
"info"
);
MessageBox
.
Show
(
"desc is null"
,
"info"
);
}
}
else
else
{
{
MessageBox
.
Show
(
r
eItalic
(
table
[
0
]),
"Monster Effect"
);
MessageBox
.
Show
(
this
.
R
eItalic
(
table
[
0
]),
"Monster Effect"
);
MessageBox
.
Show
(
r
eItalic
(
table
[
1
]),
"Pendulum Effect"
);
MessageBox
.
Show
(
this
.
R
eItalic
(
table
[
1
]),
"Pendulum Effect"
);
}
}
}
}
...
@@ -886,8 +985,8 @@ public List<string> GetMPText(string desc)
...
@@ -886,8 +985,8 @@ public List<string> GetMPText(string desc)
}
}
else
else
{
{
string
ptext
=
null
;
string
ptext
;
string
text
=
null
;
string
text
;
if
(
Regex
.
IsMatch
(
desc
,
"【灵摆】"
))
if
(
Regex
.
IsMatch
(
desc
,
"【灵摆】"
))
{
{
ptext
=
GetDesc
(
desc
,
@"\A←[ ]*\d*[ ]*【灵摆】[ ]*\d*[ ]*→[\r\n]*([\S\s]*?)[\r\n]*【"
);
ptext
=
GetDesc
(
desc
,
@"\A←[ ]*\d*[ ]*【灵摆】[ ]*\d*[ ]*→[\r\n]*([\S\s]*?)[\r\n]*【"
);
...
@@ -899,11 +998,16 @@ public List<string> GetMPText(string desc)
...
@@ -899,11 +998,16 @@ public List<string> GetMPText(string desc)
text
=
GetDesc
(
desc
,
@"\A([\S\s]*?)[\r\n]*【灵摆效果】[\r\n]*[\S\s]*?\z"
);
text
=
GetDesc
(
desc
,
@"\A([\S\s]*?)[\r\n]*【灵摆效果】[\r\n]*[\S\s]*?\z"
);
}
}
if
(
string
.
IsNullOrEmpty
(
text
))
if
(
string
.
IsNullOrEmpty
(
text
))
{
text
=
desc
;
text
=
desc
;
List
<
string
>
val
=
new
List
<
string
>();
}
val
.
Add
(
text
);
val
.
Add
(
ptext
);
List
<
string
>
val
=
new
List
<
string
>
return
val
;
{
text
,
ptext
};
return
val
;
}
}
}
}
...
@@ -911,17 +1015,25 @@ public string ConvertPTextOld(string text, string ptext, bool normal, int pscale
...
@@ -911,17 +1015,25 @@ public string ConvertPTextOld(string text, string ptext, bool normal, int pscale
{
{
string
str
=
normal
?
"【怪兽描述】"
:
"【怪兽效果】"
;
string
str
=
normal
?
"【怪兽描述】"
:
"【怪兽效果】"
;
if
(
string
.
IsNullOrEmpty
(
ptext
))
if
(
string
.
IsNullOrEmpty
(
ptext
))
{
return
string
.
Format
(
"←{0} 【灵摆】 {1}→\r\n{2}\r\n{3}"
,
pscale_l
,
pscale_r
,
str
,
text
);
return
string
.
Format
(
"←{0} 【灵摆】 {1}→\r\n{2}\r\n{3}"
,
pscale_l
,
pscale_r
,
str
,
text
);
}
else
else
{
return
string
.
Format
(
"←{0} 【灵摆】 {1}→\r\n{2}\r\n{3}\r\n{4}"
,
pscale_l
,
pscale_r
,
ptext
,
str
,
text
);
return
string
.
Format
(
"←{0} 【灵摆】 {1}→\r\n{2}\r\n{3}\r\n{4}"
,
pscale_l
,
pscale_r
,
ptext
,
str
,
text
);
}
}
}
public
string
ConvertPTextNew
(
string
text
,
string
ptext
)
public
string
ConvertPTextNew
(
string
text
,
string
ptext
)
{
{
if
(
string
.
IsNullOrEmpty
(
ptext
))
if
(
string
.
IsNullOrEmpty
(
ptext
))
{
return
text
;
return
text
;
}
else
else
{
return
string
.
Format
(
"{0}\r\n\r\n【灵摆效果】\r\n{1}"
,
text
,
ptext
);
return
string
.
Format
(
"{0}\r\n\r\n【灵摆效果】\r\n{1}"
,
text
,
ptext
);
}
}
}
public
string
ReplaceText
(
string
text
,
string
name
)
public
string
ReplaceText
(
string
text
,
string
name
)
...
@@ -929,9 +1041,11 @@ public string ReplaceText(string text, string name)
...
@@ -929,9 +1041,11 @@ public string ReplaceText(string text, string name)
// pendulum format
// pendulum format
if
(
Regex
.
IsMatch
(
text
,
@"【灵摆】"
))
if
(
Regex
.
IsMatch
(
text
,
@"【灵摆】"
))
{
{
List
<
string
>
table
=
GetMPText
(
text
);
List
<
string
>
table
=
this
.
GetMPText
(
text
);
if
(
table
!=
null
)
if
(
table
!=
null
)
text
=
ConvertPTextNew
(
table
[
0
],
table
[
1
]);
{
text
=
this
.
ConvertPTextNew
(
table
[
0
],
table
[
1
]);
}
}
}
// give
// give
...
...
DataEditorX/Core/TCGEditor/CardSet.cs
View file @
bc0829bf
...
@@ -43,7 +43,7 @@ public class CardInfo{
...
@@ -43,7 +43,7 @@ public class CardInfo{
public
string
copyright
;
public
string
copyright
;
public
override
string
ToString
()
public
override
string
ToString
()
{
{
return
string
.
Format
(
"[CardInfo Title={0}, Artwork={1}, Artwork_crop={2}, Background={3}, Rarity={4}, Attribute={5}, Level={6}, Icon={7}, Description={8}, Pendulum_description={9}, Pendulum_scales={10}, Subtypes={11}, Atk={12}, Def={13}, Edition={14}, Set={15}, Card_number={16}, Limitation={17}, Sticker={18}, Copyright={19}]"
,
t
itle
,
artwork
,
artwork_crop
,
background
,
rarity
,
attribute
,
level
,
icon
,
description
,
pendulum_description
,
pendulum_scales
,
subtypes
,
atk
,
def
,
edition
,
set
,
card_number
,
limitation
,
sticker
,
copyright
);
return
string
.
Format
(
"[CardInfo Title={0}, Artwork={1}, Artwork_crop={2}, Background={3}, Rarity={4}, Attribute={5}, Level={6}, Icon={7}, Description={8}, Pendulum_description={9}, Pendulum_scales={10}, Subtypes={11}, Atk={12}, Def={13}, Edition={14}, Set={15}, Card_number={16}, Limitation={17}, Sticker={18}, Copyright={19}]"
,
t
his
.
title
,
this
.
artwork
,
this
.
artwork_crop
,
this
.
background
,
this
.
rarity
,
this
.
attribute
,
this
.
level
,
this
.
icon
,
this
.
description
,
this
.
pendulum_description
,
this
.
pendulum_scales
,
this
.
subtypes
,
this
.
atk
,
this
.
def
,
this
.
edition
,
this
.
set
,
this
.
card_number
,
this
.
limitation
,
this
.
sticker
,
this
.
copyright
);
}
}
}
}
...
...
DataEditorX/Core/TaskHelper.cs
View file @
bc0829bf
...
@@ -47,7 +47,7 @@ public class TaskHelper
...
@@ -47,7 +47,7 @@ public class TaskHelper
/// </summary>
/// </summary>
public
Card
[]
CardList
public
Card
[]
CardList
{
{
get
{
return
cardlist
;
}
get
{
return
this
.
cardlist
;
}
}
}
/// <summary>
/// <summary>
/// 任务参数
/// 任务参数
...
@@ -56,11 +56,11 @@ public Card[] CardList
...
@@ -56,11 +56,11 @@ public Card[] CardList
/// <summary>
/// <summary>
/// 图片设置
/// 图片设置
/// </summary>
/// </summary>
private
ImageSet
imgSet
;
private
readonly
ImageSet
imgSet
;
/// <summary>
/// <summary>
/// MSE转换
/// MSE转换
/// </summary>
/// </summary>
private
MseMaker
mseHelper
;
private
readonly
MseMaker
mseHelper
;
/// <summary>
/// <summary>
/// 是否取消
/// 是否取消
/// </summary>
/// </summary>
...
@@ -72,38 +72,38 @@ public Card[] CardList
...
@@ -72,38 +72,38 @@ public Card[] CardList
/// <summary>
/// <summary>
/// 后台工作线程
/// 后台工作线程
/// </summary>
/// </summary>
private
BackgroundWorker
worker
;
private
readonly
BackgroundWorker
worker
;
public
TaskHelper
(
string
datapath
,
BackgroundWorker
worker
,
MSEConfig
mcfg
)
public
TaskHelper
(
string
datapath
,
BackgroundWorker
worker
,
MSEConfig
mcfg
)
{
{
this
.
worker
=
worker
;
this
.
worker
=
worker
;
mseHelper
=
new
MseMaker
(
mcfg
);
this
.
mseHelper
=
new
MseMaker
(
mcfg
);
imgSet
=
new
ImageSet
();
this
.
imgSet
=
new
ImageSet
();
}
}
public
MseMaker
MseHelper
public
MseMaker
MseHelper
{
{
get
{
return
mseHelper
;
}
get
{
return
this
.
mseHelper
;
}
}
}
public
bool
IsRuning
()
public
bool
IsRuning
()
{
{
return
isRun
;
return
this
.
isRun
;
}
}
public
bool
IsCancel
()
public
bool
IsCancel
()
{
{
return
isCancel
;
return
this
.
isCancel
;
}
}
public
void
Cancel
()
public
void
Cancel
()
{
{
isRun
=
false
;
this
.
isRun
=
false
;
isCancel
=
true
;
this
.
isCancel
=
true
;
}
}
public
MyTask
getLastTask
()
public
MyTask
getLastTask
()
{
{
return
lastTask
;
return
this
.
lastTask
;
}
}
public
void
testPendulumText
(
string
desc
){
public
void
testPendulumText
(
string
desc
){
mseHelper
.
t
estPendulum
(
desc
);
this
.
mseHelper
.
T
estPendulum
(
desc
);
}
}
#
endregion
#
endregion
...
@@ -111,19 +111,22 @@ public MyTask getLastTask()
...
@@ -111,19 +111,22 @@ public MyTask getLastTask()
//设置任务
//设置任务
public
void
SetTask
(
MyTask
myTask
,
Card
[]
cards
,
params
string
[]
args
)
public
void
SetTask
(
MyTask
myTask
,
Card
[]
cards
,
params
string
[]
args
)
{
{
nowTask
=
myTask
;
this
.
nowTask
=
myTask
;
cardlist
=
cards
;
this
.
cardlist
=
cards
;
mArgs
=
args
;
this
.
mArgs
=
args
;
}
}
//转换图片
//转换图片
//public void ToImg(string img, string saveimg1, string saveimg2)
//public void ToImg(string img, string saveimg1, string saveimg2)
public
void
ToImg
(
string
img
,
string
saveimg1
)
public
void
ToImg
(
string
img
,
string
saveimg1
)
{
{
if
(!
File
.
Exists
(
img
))
if
(!
File
.
Exists
(
img
))
return
;
{
Bitmap
bmp
=
new
Bitmap
(
img
);
return
;
MyBitmap
.
SaveAsJPEG
(
MyBitmap
.
Zoom
(
bmp
,
imgSet
.
W
,
imgSet
.
H
),
}
saveimg1
,
imgSet
.
quilty
);
Bitmap
bmp
=
new
Bitmap
(
img
);
MyBitmap
.
SaveAsJPEG
(
MyBitmap
.
Zoom
(
bmp
,
this
.
imgSet
.
W
,
this
.
imgSet
.
H
),
saveimg1
,
this
.
imgSet
.
quilty
);
//MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
//MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
// saveimg2, imgSet.quilty);
// saveimg2, imgSet.quilty);
bmp
.
Dispose
();
bmp
.
Dispose
();
...
@@ -137,30 +140,44 @@ public static void CheckVersion(bool showNew)
...
@@ -137,30 +140,44 @@ public static void CheckVersion(bool showNew)
if
(
newver
==
CheckUpdate
.
DEFALUT
)
if
(
newver
==
CheckUpdate
.
DEFALUT
)
{
//检查失败
{
//检查失败
if
(!
showNew
)
if
(!
showNew
)
return
;
{
MyMsg
.
Error
(
LMSG
.
CheckUpdateFail
);
return
;
}
MyMsg
.
Error
(
LMSG
.
CheckUpdateFail
);
return
;
return
;
}
}
if
(
CheckUpdate
.
CheckVersion
(
newver
,
Application
.
ProductVersion
))
if
(
CheckUpdate
.
CheckVersion
(
newver
,
Application
.
ProductVersion
))
{
//有最新版本
{
//有最新版本
if
(!
MyMsg
.
Question
(
LMSG
.
HaveNewVersion
))
if
(!
MyMsg
.
Question
(
LMSG
.
HaveNewVersion
))
return
;
{
}
return
;
}
}
else
else
{
//现在就是最新版本
{
//现在就是最新版本
if
(!
showNew
)
if
(!
showNew
)
return
;
{
if
(!
MyMsg
.
Question
(
LMSG
.
NowIsNewVersion
))
return
;
return
;
}
}
if
(!
MyMsg
.
Question
(
LMSG
.
NowIsNewVersion
))
{
return
;
}
}
//下载文件
//下载文件
if
(
CheckUpdate
.
DownLoad
(
if
(
CheckUpdate
.
DownLoad
(
MyPath
.
Combine
(
Application
.
StartupPath
,
newver
+
".zip"
)))
MyPath
.
Combine
(
Application
.
StartupPath
,
newver
+
".zip"
)))
MyMsg
.
Show
(
LMSG
.
DownloadSucceed
);
{
else
MyMsg
.
Show
(
LMSG
.
DownloadSucceed
);
MyMsg
.
Show
(
LMSG
.
DownloadFail
);
}
}
else
{
MyMsg
.
Show
(
LMSG
.
DownloadFail
);
}
}
public
void
OnCheckUpdate
(
bool
showNew
)
public
void
OnCheckUpdate
(
bool
showNew
)
{
{
TaskHelper
.
CheckVersion
(
showNew
);
TaskHelper
.
CheckVersion
(
showNew
);
...
@@ -170,34 +187,37 @@ public void OnCheckUpdate(bool showNew)
...
@@ -170,34 +187,37 @@ public void OnCheckUpdate(bool showNew)
#
region
裁剪图片
#
region
裁剪图片
public
void
CutImages
(
string
imgpath
,
bool
isreplace
)
public
void
CutImages
(
string
imgpath
,
bool
isreplace
)
{
{
int
count
=
cardlist
.
Length
;
int
count
=
this
.
cardlist
.
Length
;
int
i
=
0
;
int
i
=
0
;
foreach
(
Card
c
in
cardlist
)
foreach
(
Card
c
in
this
.
cardlist
)
{
{
if
(
isCancel
)
if
(
this
.
isCancel
)
break
;
{
i
++;
break
;
worker
.
ReportProgress
((
i
/
count
),
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
}
i
++;
this
.
worker
.
ReportProgress
((
i
/
count
),
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
string
jpg
=
MyPath
.
Combine
(
imgpath
,
c
.
id
+
".jpg"
);
string
jpg
=
MyPath
.
Combine
(
imgpath
,
c
.
id
+
".jpg"
);
string
savejpg
=
MyPath
.
Combine
(
mseHelper
.
ImagePath
,
c
.
id
+
".jpg"
);
string
savejpg
=
MyPath
.
Combine
(
this
.
mseHelper
.
ImagePath
,
c
.
id
+
".jpg"
);
if
(
File
.
Exists
(
jpg
)
&&
(
isreplace
||
!
File
.
Exists
(
savejpg
)))
if
(
File
.
Exists
(
jpg
)
&&
(
isreplace
||
!
File
.
Exists
(
savejpg
)))
{
{
Bitmap
bp
=
new
Bitmap
(
jpg
);
Bitmap
bp
=
new
Bitmap
(
jpg
);
Bitmap
bmp
=
null
;
Bitmap
bmp
;
if
(
c
.
IsType
(
CardType
.
TYPE_XYZ
))
//超量
if
(
c
.
IsType
(
CardType
.
TYPE_XYZ
))
//超量
{
{
bmp
=
MyBitmap
.
Cut
(
bp
,
imgSet
.
xyzArea
);
bmp
=
MyBitmap
.
Cut
(
bp
,
this
.
imgSet
.
xyzArea
);
}
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//P怪兽
else
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//P怪兽
{
{
bmp
=
MyBitmap
.
Cut
(
bp
,
imgSet
.
pendulumArea
);
bmp
=
MyBitmap
.
Cut
(
bp
,
this
.
imgSet
.
pendulumArea
);
}
}
else
//一般
else
//一般
{
{
bmp
=
MyBitmap
.
Cut
(
bp
,
imgSet
.
normalArea
);
bmp
=
MyBitmap
.
Cut
(
bp
,
this
.
imgSet
.
normalArea
);
}
}
bp
.
Dispose
();
bp
.
Dispose
();
MyBitmap
.
SaveAsJPEG
(
bmp
,
savejpg
,
imgSet
.
quilty
);
MyBitmap
.
SaveAsJPEG
(
bmp
,
savejpg
,
this
.
imgSet
.
quilty
);
//bmp.Save(savejpg, ImageFormat.Png);
//bmp.Save(savejpg, ImageFormat.Png);
}
}
}
}
...
@@ -216,10 +236,13 @@ public void ConvertImages(string imgpath, string gamepath, bool isreplace)
...
@@ -216,10 +236,13 @@ public void ConvertImages(string imgpath, string gamepath, bool isreplace)
foreach
(
string
f
in
files
)
foreach
(
string
f
in
files
)
{
{
if
(
isCancel
)
if
(
this
.
isCancel
)
break
;
{
i
++;
break
;
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
}
i
++;
this
.
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
string
ex
=
Path
.
GetExtension
(
f
).
ToLower
();
string
ex
=
Path
.
GetExtension
(
f
).
ToLower
();
string
name
=
Path
.
GetFileNameWithoutExtension
(
f
);
string
name
=
Path
.
GetFileNameWithoutExtension
(
f
);
string
jpg_b
=
MyPath
.
Combine
(
picspath
,
name
+
".jpg"
);
string
jpg_b
=
MyPath
.
Combine
(
picspath
,
name
+
".jpg"
);
...
@@ -233,8 +256,8 @@ public void ConvertImages(string imgpath, string gamepath, bool isreplace)
...
@@ -233,8 +256,8 @@ public void ConvertImages(string imgpath, string gamepath, bool isreplace)
if
(
isreplace
||
!
File
.
Exists
(
jpg_b
))
if
(
isreplace
||
!
File
.
Exists
(
jpg_b
))
{
{
MyBitmap
.
SaveAsJPEG
(
MyBitmap
.
Zoom
(
bmp
,
imgSet
.
W
,
imgSet
.
H
),
MyBitmap
.
SaveAsJPEG
(
MyBitmap
.
Zoom
(
bmp
,
this
.
imgSet
.
W
,
this
.
imgSet
.
H
),
jpg_b
,
imgSet
.
quilty
);
jpg_b
,
this
.
imgSet
.
quilty
);
}
}
//小图,如果替换,或者不存在
//小图,如果替换,或者不存在
//if (isreplace || !File.Exists(jpg_s))
//if (isreplace || !File.Exists(jpg_s))
...
@@ -252,50 +275,63 @@ public void ConvertImages(string imgpath, string gamepath, bool isreplace)
...
@@ -252,50 +275,63 @@ public void ConvertImages(string imgpath, string gamepath, bool isreplace)
#
region
MSE
存档
#
region
MSE
存档
public
string
MSEImagePath
public
string
MSEImagePath
{
{
get
{
return
mseHelper
.
ImagePath
;
}
get
{
return
this
.
mseHelper
.
ImagePath
;
}
}
}
public
void
SaveMSEs
(
string
file
,
Card
[]
cards
,
bool
isUpdate
)
public
void
SaveMSEs
(
string
file
,
Card
[]
cards
,
bool
isUpdate
)
{
{
if
(
cards
==
null
)
if
(
cards
==
null
)
return
;
{
string
pack_db
=
MyPath
.
GetRealPath
(
MyConfig
.
readString
(
"pack_db"
));
return
;
}
string
pack_db
=
MyPath
.
GetRealPath
(
MyConfig
.
readString
(
"pack_db"
));
bool
rarity
=
MyConfig
.
readBoolean
(
"mse_auto_rarity"
,
false
);
bool
rarity
=
MyConfig
.
readBoolean
(
"mse_auto_rarity"
,
false
);
#
if
DEBUG
#
if
DEBUG
MessageBox
.
Show
(
"db = "
+
pack_db
+
",auto rarity="
+
rarity
);
MessageBox
.
Show
(
"db = "
+
pack_db
+
",auto rarity="
+
rarity
);
#
endif
#
endif
int
c
=
cards
.
Length
;
int
c
=
cards
.
Length
;
//不分开,或者卡片数小于单个存档的最大值
//不分开,或者卡片数小于单个存档的最大值
if
(
mseHelper
.
MaxNum
==
0
||
c
<
mseHelper
.
MaxNum
)
if
(
this
.
mseHelper
.
MaxNum
==
0
||
c
<
this
.
mseHelper
.
MaxNum
)
SaveMSE
(
1
,
file
,
cards
,
pack_db
,
rarity
,
isUpdate
);
{
else
this
.
SaveMSE
(
1
,
file
,
cards
,
pack_db
,
rarity
,
isUpdate
);
}
else
{
{
int
nums
=
c
/
mseHelper
.
MaxNum
;
int
nums
=
c
/
this
.
mseHelper
.
MaxNum
;
if
(
nums
*
mseHelper
.
MaxNum
<
c
)
//计算需要分多少个存档
if
(
nums
*
this
.
mseHelper
.
MaxNum
<
c
)
//计算需要分多少个存档
nums
++;
{
List
<
Card
>
clist
=
new
List
<
Card
>();
nums
++;
}
List
<
Card
>
clist
=
new
List
<
Card
>();
for
(
int
i
=
0
;
i
<
nums
;
i
++)
//分别生成存档
for
(
int
i
=
0
;
i
<
nums
;
i
++)
//分别生成存档
{
{
clist
.
Clear
();
clist
.
Clear
();
for
(
int
j
=
0
;
j
<
mseHelper
.
MaxNum
;
j
++)
for
(
int
j
=
0
;
j
<
this
.
mseHelper
.
MaxNum
;
j
++)
{
{
int
index
=
i
*
mseHelper
.
MaxNum
+
j
;
int
index
=
i
*
this
.
mseHelper
.
MaxNum
+
j
;
if
(
index
<
c
)
if
(
index
<
c
)
clist
.
Add
(
cards
[
index
]);
{
}
clist
.
Add
(
cards
[
index
]);
}
}
int
t
=
file
.
LastIndexOf
(
".mse-set"
);
int
t
=
file
.
LastIndexOf
(
".mse-set"
);
string
fname
=
(
t
>
0
)
?
file
.
Substring
(
0
,
t
)
:
file
;
string
fname
=
(
t
>
0
)
?
file
.
Substring
(
0
,
t
)
:
file
;
fname
=
fname
+
string
.
Format
(
"_{0}.mse-set"
,
i
+
1
);
fname
+=
string
.
Format
(
"_{0}.mse-set"
,
i
+
1
);
SaveMSE
(
i
+
1
,
fname
,
clist
.
ToArray
(),
pack_db
,
rarity
,
isUpdate
);
this
.
SaveMSE
(
i
+
1
,
fname
,
clist
.
ToArray
(),
pack_db
,
rarity
,
isUpdate
);
}
}
}
}
}
}
public
void
SaveMSE
(
int
num
,
string
file
,
Card
[]
cards
,
string
pack_db
,
bool
rarity
,
bool
isUpdate
)
public
void
SaveMSE
(
int
num
,
string
file
,
Card
[]
cards
,
string
pack_db
,
bool
rarity
,
bool
isUpdate
)
{
{
string
setFile
=
file
+
".txt"
;
string
setFile
=
file
+
".txt"
;
Dictionary
<
Card
,
string
>
images
=
mseHelper
.
WriteSet
(
setFile
,
cards
,
pack_db
,
rarity
);
Dictionary
<
Card
,
string
>
images
=
this
.
mseHelper
.
WriteSet
(
setFile
,
cards
,
pack_db
,
rarity
);
if
(
isUpdate
)
//仅更新文字
if
(
isUpdate
)
//仅更新文字
return
;
{
int
i
=
0
;
return
;
}
int
i
=
0
;
int
count
=
images
.
Count
;
int
count
=
images
.
Count
;
using
(
ZipStorer
zips
=
ZipStorer
.
Create
(
file
,
""
))
using
(
ZipStorer
zips
=
ZipStorer
.
Create
(
file
,
""
))
{
{
...
@@ -304,12 +340,15 @@ public void SaveMSE(int num, string file, Card[] cards,string pack_db,bool rarit
...
@@ -304,12 +340,15 @@ public void SaveMSE(int num, string file, Card[] cards,string pack_db,bool rarit
foreach
(
Card
c
in
images
.
Keys
)
foreach
(
Card
c
in
images
.
Keys
)
{
{
string
img
=
images
[
c
];
string
img
=
images
[
c
];
if
(
isCancel
)
if
(
this
.
isCancel
)
break
;
{
i
++;
break
;
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}-{2}"
,
i
,
count
,
num
));
}
i
++;
this
.
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}-{2}"
,
i
,
count
,
num
));
//TODO 先裁剪图片
//TODO 先裁剪图片
zips
.
AddFile
(
mseHelper
.
g
etImageCache
(
img
,
c
),
Path
.
GetFileName
(
img
),
""
);
zips
.
AddFile
(
this
.
mseHelper
.
G
etImageCache
(
img
,
c
),
Path
.
GetFileName
(
img
),
""
);
}
}
}
}
File
.
Delete
(
setFile
);
File
.
Delete
(
setFile
);
...
@@ -325,13 +364,13 @@ public Card[] ReadMSE(string mseset, bool repalceOld)
...
@@ -325,13 +364,13 @@ public Card[] ReadMSE(string mseset, bool repalceOld)
int
i
=
0
;
int
i
=
0
;
foreach
(
ZipStorer
.
ZipFileEntry
file
in
files
)
foreach
(
ZipStorer
.
ZipFileEntry
file
in
files
)
{
{
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
this
.
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
string
savefilename
=
MyPath
.
Combine
(
mseHelper
.
ImagePath
,
file
.
FilenameInZip
);
string
savefilename
=
MyPath
.
Combine
(
this
.
mseHelper
.
ImagePath
,
file
.
FilenameInZip
);
zips
.
ExtractFile
(
file
,
savefilename
);
zips
.
ExtractFile
(
file
,
savefilename
);
}
}
}
}
string
setfile
=
MyPath
.
Combine
(
mseHelper
.
ImagePath
,
"set"
);
string
setfile
=
MyPath
.
Combine
(
this
.
mseHelper
.
ImagePath
,
"set"
);
return
mseHelper
.
ReadCards
(
setfile
,
repalceOld
);
return
this
.
mseHelper
.
ReadCards
(
setfile
,
repalceOld
);
}
}
#
endregion
#
endregion
...
@@ -339,10 +378,13 @@ public Card[] ReadMSE(string mseset, bool repalceOld)
...
@@ -339,10 +378,13 @@ public Card[] ReadMSE(string mseset, bool repalceOld)
public
void
ExportData
(
string
path
,
string
zipname
,
string
_cdbfile
,
string
modulescript
)
public
void
ExportData
(
string
path
,
string
zipname
,
string
_cdbfile
,
string
modulescript
)
{
{
int
i
=
0
;
int
i
=
0
;
Card
[]
cards
=
cardlist
;
Card
[]
cards
=
this
.
cardlist
;
if
(
cards
==
null
||
cards
.
Length
==
0
)
if
(
cards
==
null
||
cards
.
Length
==
0
)
return
;
{
int
count
=
cards
.
Length
;
return
;
}
int
count
=
cards
.
Length
;
YgoPath
ygopath
=
new
YgoPath
(
path
);
YgoPath
ygopath
=
new
YgoPath
(
path
);
string
name
=
Path
.
GetFileNameWithoutExtension
(
zipname
);
string
name
=
Path
.
GetFileNameWithoutExtension
(
zipname
);
//数据库
//数据库
...
@@ -354,30 +396,44 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
...
@@ -354,30 +396,44 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
//module scripts
//module scripts
string
extra_script
=
""
;
string
extra_script
=
""
;
if
(
modulescript
.
Length
>
0
)
if
(
modulescript
.
Length
>
0
)
extra_script
=
ygopath
.
GetModuleScript
(
modulescript
);
{
extra_script
=
ygopath
.
GetModuleScript
(
modulescript
);
File
.
Delete
(
cdbfile
);
}
File
.
Delete
(
cdbfile
);
DataBase
.
Create
(
cdbfile
);
DataBase
.
Create
(
cdbfile
);
DataBase
.
CopyDB
(
cdbfile
,
false
,
cardlist
);
DataBase
.
CopyDB
(
cdbfile
,
false
,
this
.
cardlist
);
if
(
File
.
Exists
(
zipname
))
if
(
File
.
Exists
(
zipname
))
File
.
Delete
(
zipname
);
{
using
(
ZipStorer
zips
=
ZipStorer
.
Create
(
zipname
,
""
))
File
.
Delete
(
zipname
);
}
using
(
ZipStorer
zips
=
ZipStorer
.
Create
(
zipname
,
""
))
{
{
zips
.
AddFile
(
cdbfile
,
Path
.
GetFileNameWithoutExtension
(
_cdbfile
)
+
".cdb"
,
""
);
zips
.
AddFile
(
cdbfile
,
Path
.
GetFileNameWithoutExtension
(
_cdbfile
)
+
".cdb"
,
""
);
if
(
File
.
Exists
(
readme
))
if
(
File
.
Exists
(
readme
))
zips
.
AddFile
(
readme
,
"readme_"
+
name
+
".txt"
,
""
);
{
if
(
File
.
Exists
(
deckydk
))
zips
.
AddFile
(
readme
,
"readme_"
+
name
+
".txt"
,
""
);
zips
.
AddFile
(
deckydk
,
"deck/"
+
name
+
".ydk"
,
""
);
}
if
(
modulescript
.
Length
>
0
&&
File
.
Exists
(
extra_script
))
zips
.
AddFile
(
extra_script
,
extra_script
.
Replace
(
path
,
""
),
""
);
if
(
File
.
Exists
(
deckydk
))
foreach
(
Card
c
in
cards
)
{
zips
.
AddFile
(
deckydk
,
"deck/"
+
name
+
".ydk"
,
""
);
}
if
(
modulescript
.
Length
>
0
&&
File
.
Exists
(
extra_script
))
{
zips
.
AddFile
(
extra_script
,
extra_script
.
Replace
(
path
,
""
),
""
);
}
foreach
(
Card
c
in
cards
)
{
{
i
++;
i
++;
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
this
.
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
string
[]
files
=
ygopath
.
GetCardfiles
(
c
.
id
);
string
[]
files
=
ygopath
.
GetCardfiles
(
c
.
id
);
foreach
(
string
file
in
files
)
foreach
(
string
file
in
files
)
{
{
if
(!
S
tring
.
Equals
(
file
,
extra_script
)
&&
File
.
Exists
(
file
))
if
(!
s
tring
.
Equals
(
file
,
extra_script
)
&&
File
.
Exists
(
file
))
{
{
zips
.
AddFile
(
file
,
file
.
Replace
(
path
,
""
),
""
);
zips
.
AddFile
(
file
,
file
.
Replace
(
path
,
""
),
""
);
}
}
...
@@ -391,81 +447,92 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
...
@@ -391,81 +447,92 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
#
region
运行
#
region
运行
public
void
Run
()
public
void
Run
()
{
{
isCancel
=
false
;
this
.
isCancel
=
false
;
isRun
=
true
;
this
.
isRun
=
true
;
bool
replace
;
bool
replace
;
bool
showNew
;
bool
showNew
;
switch
(
nowTask
)
switch
(
this
.
nowTask
)
{
{
case
MyTask
.
ExportData
:
case
MyTask
.
ExportData
:
if
(
mArgs
!=
null
&&
mArgs
.
Length
>=
3
)
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
3
)
{
{
ExportData
(
mArgs
[
0
],
mArgs
[
1
],
mArgs
[
2
],
mArgs
[
3
]);
this
.
ExportData
(
this
.
mArgs
[
0
],
this
.
mArgs
[
1
],
this
.
mArgs
[
2
],
this
.
mArgs
[
3
]);
}
}
break
;
break
;
case
MyTask
.
CheckUpdate
:
case
MyTask
.
CheckUpdate
:
showNew
=
false
;
showNew
=
false
;
if
(
mArgs
!=
null
&&
mArgs
.
Length
>=
1
)
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
1
)
{
{
showNew
=
(
mArgs
[
0
]
==
Boolean
.
TrueString
)
?
true
:
false
;
showNew
=
(
this
.
mArgs
[
0
]
==
bool
.
TrueString
)
?
true
:
false
;
}
}
OnCheckUpdate
(
showNew
);
this
.
OnCheckUpdate
(
showNew
);
break
;
break
;
case
MyTask
.
CutImages
:
case
MyTask
.
CutImages
:
if
(
mArgs
!=
null
&&
mArgs
.
Length
>=
2
)
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
{
replace
=
true
;
replace
=
true
;
if
(
mArgs
.
Length
>=
2
)
if
(
this
.
mArgs
.
Length
>=
2
)
{
{
if
(
mArgs
[
1
]
==
Boolean
.
FalseString
)
if
(
this
.
mArgs
[
1
]
==
bool
.
FalseString
)
replace
=
false
;
{
}
replace
=
false
;
CutImages
(
mArgs
[
0
],
replace
);
}
}
this
.
CutImages
(
this
.
mArgs
[
0
],
replace
);
}
}
break
;
break
;
case
MyTask
.
SaveAsMSE
:
case
MyTask
.
SaveAsMSE
:
if
(
mArgs
!=
null
&&
mArgs
.
Length
>=
2
)
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
{
replace
=
false
;
replace
=
false
;
if
(
mArgs
.
Length
>=
2
)
if
(
this
.
mArgs
.
Length
>=
2
)
{
{
if
(
mArgs
[
1
]
==
Boolean
.
TrueString
)
if
(
this
.
mArgs
[
1
]
==
bool
.
TrueString
)
replace
=
true
;
{
}
replace
=
true
;
SaveMSEs
(
mArgs
[
0
],
cardlist
,
replace
);
}
}
this
.
SaveMSEs
(
this
.
mArgs
[
0
],
this
.
cardlist
,
replace
);
}
}
break
;
break
;
case
MyTask
.
ReadMSE
:
case
MyTask
.
ReadMSE
:
if
(
mArgs
!=
null
&&
mArgs
.
Length
>=
2
)
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
{
replace
=
false
;
replace
=
false
;
if
(
mArgs
.
Length
>=
2
)
if
(
this
.
mArgs
.
Length
>=
2
)
{
{
if
(
mArgs
[
1
]
==
Boolean
.
TrueString
)
if
(
this
.
mArgs
[
1
]
==
bool
.
TrueString
)
replace
=
true
;
{
}
replace
=
true
;
cardlist
=
ReadMSE
(
mArgs
[
0
],
replace
);
}
}
this
.
cardlist
=
this
.
ReadMSE
(
this
.
mArgs
[
0
],
replace
);
}
}
break
;
break
;
case
MyTask
.
ConvertImages
:
case
MyTask
.
ConvertImages
:
if
(
mArgs
!=
null
&&
mArgs
.
Length
>=
2
)
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
{
replace
=
true
;
replace
=
true
;
if
(
mArgs
.
Length
>=
3
)
if
(
this
.
mArgs
.
Length
>=
3
)
{
{
if
(
mArgs
[
2
]
==
Boolean
.
FalseString
)
if
(
this
.
mArgs
[
2
]
==
bool
.
FalseString
)
replace
=
false
;
{
}
replace
=
false
;
ConvertImages
(
mArgs
[
0
],
mArgs
[
1
],
replace
);
}
}
this
.
ConvertImages
(
this
.
mArgs
[
0
],
this
.
mArgs
[
1
],
replace
);
}
}
break
;
break
;
}
}
isRun
=
false
;
this
.
isRun
=
false
;
lastTask
=
nowTask
;
this
.
lastTask
=
this
.
nowTask
;
nowTask
=
MyTask
.
NONE
;
this
.
nowTask
=
MyTask
.
NONE
;
if
(
lastTask
!=
MyTask
.
ReadMSE
)
if
(
this
.
lastTask
!=
MyTask
.
ReadMSE
)
cardlist
=
null
;
{
mArgs
=
null
;
this
.
cardlist
=
null
;
}
this
.
mArgs
=
null
;
}
}
#
endregion
#
endregion
}
}
...
...
DataEditorX/Core/YGOUtil.cs
View file @
bc0829bf
...
@@ -13,27 +13,33 @@ namespace DataEditorX.Core
...
@@ -13,27 +13,33 @@ 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
i
sScript
(
string
file
)
public
static
bool
I
sScript
(
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
i
sDataBase
(
string
file
)
public
static
bool
I
sDataBase
(
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
...
@@ -41,13 +47,13 @@ public static bool isDataBase(string file)
...
@@ -41,13 +47,13 @@ public static bool isDataBase(string file)
#
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
...
@@ -82,33 +88,56 @@ public static string GetCardType(Card c)
...
@@ -82,33 +88,56 @@ public static string GetCardType(Card c)
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
(
" "
,
""
);
...
@@ -116,21 +145,28 @@ public static string GetCardType(Card c)
...
@@ -116,21 +145,28 @@ public static string GetCardType(Card c)
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
...
@@ -142,10 +178,10 @@ public static string GetSetNameString(long setcode)
...
@@ -142,10 +178,10 @@ public static string GetSetNameString(long setcode)
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
;
}
}
...
@@ -172,7 +208,9 @@ public static string[] ReadYDK(string ydkfile)
...
@@ -172,7 +208,9 @@ public static string[] ReadYDK(string ydkfile)
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
();
}
}
...
@@ -181,7 +219,10 @@ public static string[] ReadYDK(string ydkfile)
...
@@ -181,7 +219,10 @@ public static string[] ReadYDK(string ydkfile)
}
}
}
}
if
(
IDs
.
Count
==
0
)
if
(
IDs
.
Count
==
0
)
{
return
null
;
return
null
;
}
return
IDs
.
ToArray
();
return
IDs
.
ToArray
();
}
}
#
endregion
#
endregion
...
@@ -196,7 +237,9 @@ public static string[] ReadImage(string path)
...
@@ -196,7 +237,9 @@ public static string[] ReadImage(string path)
{
{
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
();
}
}
...
@@ -210,8 +253,10 @@ public static void CardDelete(long id, YgoPath ygopath)
...
@@ -210,8 +253,10 @@ public static void CardDelete(long id, YgoPath ygopath)
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
...
...
DataEditorX/DataEditForm.Designer.cs
View file @
bc0829bf
...
@@ -520,7 +520,7 @@ private void InitializeComponent()
...
@@ -520,7 +520,7 @@ private void InitializeComponent()
this
.
tb_cardname
.
Location
=
new
System
.
Drawing
.
Point
(
5
,
3
);
this
.
tb_cardname
.
Location
=
new
System
.
Drawing
.
Point
(
5
,
3
);
this
.
tb_cardname
.
Name
=
"tb_cardname"
;
this
.
tb_cardname
.
Name
=
"tb_cardname"
;
this
.
tb_cardname
.
Size
=
new
System
.
Drawing
.
Size
(
339
,
21
);
this
.
tb_cardname
.
Size
=
new
System
.
Drawing
.
Size
(
339
,
21
);
this
.
tb_cardname
.
TabIndex
=
4
;
this
.
tb_cardname
.
TabIndex
=
1
;
this
.
tb_cardname
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
this
.
tb_cardname
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
this
.
tb_cardname
.
KeyDown
+=
new
System
.
Windows
.
Forms
.
KeyEventHandler
(
this
.
Tb_cardnameKeyDown
);
this
.
tb_cardname
.
KeyDown
+=
new
System
.
Windows
.
Forms
.
KeyEventHandler
(
this
.
Tb_cardnameKeyDown
);
//
//
...
@@ -643,7 +643,8 @@ private void InitializeComponent()
...
@@ -643,7 +643,8 @@ private void InitializeComponent()
this
.
tb_cardtext
.
Name
=
"tb_cardtext"
;
this
.
tb_cardtext
.
Name
=
"tb_cardtext"
;
this
.
tb_cardtext
.
ScrollBars
=
System
.
Windows
.
Forms
.
ScrollBars
.
Vertical
;
this
.
tb_cardtext
.
ScrollBars
=
System
.
Windows
.
Forms
.
ScrollBars
.
Vertical
;
this
.
tb_cardtext
.
Size
=
new
System
.
Drawing
.
Size
(
340
,
200
);
this
.
tb_cardtext
.
Size
=
new
System
.
Drawing
.
Size
(
340
,
200
);
this
.
tb_cardtext
.
TabIndex
=
4
;
this
.
tb_cardtext
.
TabIndex
=
121
;
this
.
tb_cardtext
.
KeyDown
+=
new
System
.
Windows
.
Forms
.
KeyEventHandler
(
this
.
tb_cardtext_KeyDown
);
//
//
// tb_edittext
// tb_edittext
//
//
...
@@ -675,7 +676,7 @@ private void InitializeComponent()
...
@@ -675,7 +676,7 @@ private void InitializeComponent()
this
.
tb_pleft
.
MaxLength
=
12
;
this
.
tb_pleft
.
MaxLength
=
12
;
this
.
tb_pleft
.
Name
=
"tb_pleft"
;
this
.
tb_pleft
.
Name
=
"tb_pleft"
;
this
.
tb_pleft
.
Size
=
new
System
.
Drawing
.
Size
(
40
,
21
);
this
.
tb_pleft
.
Size
=
new
System
.
Drawing
.
Size
(
40
,
21
);
this
.
tb_pleft
.
TabIndex
=
8
;
this
.
tb_pleft
.
TabIndex
=
115
;
this
.
tb_pleft
.
Text
=
"0"
;
this
.
tb_pleft
.
Text
=
"0"
;
this
.
tb_pleft
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
this
.
tb_pleft
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
//
//
...
@@ -685,7 +686,7 @@ private void InitializeComponent()
...
@@ -685,7 +686,7 @@ private void InitializeComponent()
this
.
tb_pright
.
MaxLength
=
12
;
this
.
tb_pright
.
MaxLength
=
12
;
this
.
tb_pright
.
Name
=
"tb_pright"
;
this
.
tb_pright
.
Name
=
"tb_pright"
;
this
.
tb_pright
.
Size
=
new
System
.
Drawing
.
Size
(
40
,
21
);
this
.
tb_pright
.
Size
=
new
System
.
Drawing
.
Size
(
40
,
21
);
this
.
tb_pright
.
TabIndex
=
8
;
this
.
tb_pright
.
TabIndex
=
116
;
this
.
tb_pright
.
Text
=
"0"
;
this
.
tb_pright
.
Text
=
"0"
;
this
.
tb_pright
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
this
.
tb_pright
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
//
//
...
@@ -780,7 +781,7 @@ private void InitializeComponent()
...
@@ -780,7 +781,7 @@ private void InitializeComponent()
this
.
tb_atk
.
MaxLength
=
12
;
this
.
tb_atk
.
MaxLength
=
12
;
this
.
tb_atk
.
Name
=
"tb_atk"
;
this
.
tb_atk
.
Name
=
"tb_atk"
;
this
.
tb_atk
.
Size
=
new
System
.
Drawing
.
Size
(
40
,
21
);
this
.
tb_atk
.
Size
=
new
System
.
Drawing
.
Size
(
40
,
21
);
this
.
tb_atk
.
TabIndex
=
8
;
this
.
tb_atk
.
TabIndex
=
117
;
this
.
tb_atk
.
Text
=
"0"
;
this
.
tb_atk
.
Text
=
"0"
;
this
.
tb_atk
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
this
.
tb_atk
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
//
//
...
@@ -790,7 +791,7 @@ private void InitializeComponent()
...
@@ -790,7 +791,7 @@ private void InitializeComponent()
this
.
tb_def
.
MaxLength
=
12
;
this
.
tb_def
.
MaxLength
=
12
;
this
.
tb_def
.
Name
=
"tb_def"
;
this
.
tb_def
.
Name
=
"tb_def"
;
this
.
tb_def
.
Size
=
new
System
.
Drawing
.
Size
(
40
,
21
);
this
.
tb_def
.
Size
=
new
System
.
Drawing
.
Size
(
40
,
21
);
this
.
tb_def
.
TabIndex
=
8
;
this
.
tb_def
.
TabIndex
=
11
8
;
this
.
tb_def
.
Text
=
"0"
;
this
.
tb_def
.
Text
=
"0"
;
this
.
tb_def
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
this
.
tb_def
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Center
;
//
//
...
@@ -801,7 +802,7 @@ private void InitializeComponent()
...
@@ -801,7 +802,7 @@ private void InitializeComponent()
this
.
tb_cardcode
.
MaxLength
=
12
;
this
.
tb_cardcode
.
MaxLength
=
12
;
this
.
tb_cardcode
.
Name
=
"tb_cardcode"
;
this
.
tb_cardcode
.
Name
=
"tb_cardcode"
;
this
.
tb_cardcode
.
Size
=
new
System
.
Drawing
.
Size
(
67
,
21
);
this
.
tb_cardcode
.
Size
=
new
System
.
Drawing
.
Size
(
67
,
21
);
this
.
tb_cardcode
.
TabIndex
=
8
;
this
.
tb_cardcode
.
TabIndex
=
120
;
this
.
tb_cardcode
.
Text
=
"0"
;
this
.
tb_cardcode
.
Text
=
"0"
;
this
.
tb_cardcode
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_cardcode
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_cardcode
.
KeyPress
+=
new
System
.
Windows
.
Forms
.
KeyPressEventHandler
(
this
.
Tb_cardcodeKeyPress
);
this
.
tb_cardcode
.
KeyPress
+=
new
System
.
Windows
.
Forms
.
KeyPressEventHandler
(
this
.
Tb_cardcodeKeyPress
);
...
@@ -823,7 +824,7 @@ private void InitializeComponent()
...
@@ -823,7 +824,7 @@ private void InitializeComponent()
this
.
tb_cardalias
.
MaxLength
=
12
;
this
.
tb_cardalias
.
MaxLength
=
12
;
this
.
tb_cardalias
.
Name
=
"tb_cardalias"
;
this
.
tb_cardalias
.
Name
=
"tb_cardalias"
;
this
.
tb_cardalias
.
Size
=
new
System
.
Drawing
.
Size
(
67
,
21
);
this
.
tb_cardalias
.
Size
=
new
System
.
Drawing
.
Size
(
67
,
21
);
this
.
tb_cardalias
.
TabIndex
=
8
;
this
.
tb_cardalias
.
TabIndex
=
119
;
this
.
tb_cardalias
.
Text
=
"0"
;
this
.
tb_cardalias
.
Text
=
"0"
;
this
.
tb_cardalias
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_cardalias
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
//
//
...
@@ -984,7 +985,7 @@ private void InitializeComponent()
...
@@ -984,7 +985,7 @@ private void InitializeComponent()
this
.
tb_setcode1
.
MaxLength
=
4
;
this
.
tb_setcode1
.
MaxLength
=
4
;
this
.
tb_setcode1
.
Name
=
"tb_setcode1"
;
this
.
tb_setcode1
.
Name
=
"tb_setcode1"
;
this
.
tb_setcode1
.
Size
=
new
System
.
Drawing
.
Size
(
30
,
21
);
this
.
tb_setcode1
.
Size
=
new
System
.
Drawing
.
Size
(
30
,
21
);
this
.
tb_setcode1
.
TabIndex
=
1
8
;
this
.
tb_setcode1
.
TabIndex
=
1
11
;
this
.
tb_setcode1
.
Text
=
"0"
;
this
.
tb_setcode1
.
Text
=
"0"
;
this
.
tb_setcode1
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_setcode1
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_setcode1
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
tb_setcode1_TextChanged
);
this
.
tb_setcode1
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
tb_setcode1_TextChanged
);
...
@@ -996,7 +997,7 @@ private void InitializeComponent()
...
@@ -996,7 +997,7 @@ private void InitializeComponent()
this
.
tb_setcode2
.
MaxLength
=
4
;
this
.
tb_setcode2
.
MaxLength
=
4
;
this
.
tb_setcode2
.
Name
=
"tb_setcode2"
;
this
.
tb_setcode2
.
Name
=
"tb_setcode2"
;
this
.
tb_setcode2
.
Size
=
new
System
.
Drawing
.
Size
(
30
,
21
);
this
.
tb_setcode2
.
Size
=
new
System
.
Drawing
.
Size
(
30
,
21
);
this
.
tb_setcode2
.
TabIndex
=
1
8
;
this
.
tb_setcode2
.
TabIndex
=
1
12
;
this
.
tb_setcode2
.
Text
=
"0"
;
this
.
tb_setcode2
.
Text
=
"0"
;
this
.
tb_setcode2
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_setcode2
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_setcode2
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
tb_setcode2_TextChanged
);
this
.
tb_setcode2
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
tb_setcode2_TextChanged
);
...
@@ -1008,7 +1009,7 @@ private void InitializeComponent()
...
@@ -1008,7 +1009,7 @@ private void InitializeComponent()
this
.
tb_setcode3
.
MaxLength
=
4
;
this
.
tb_setcode3
.
MaxLength
=
4
;
this
.
tb_setcode3
.
Name
=
"tb_setcode3"
;
this
.
tb_setcode3
.
Name
=
"tb_setcode3"
;
this
.
tb_setcode3
.
Size
=
new
System
.
Drawing
.
Size
(
30
,
21
);
this
.
tb_setcode3
.
Size
=
new
System
.
Drawing
.
Size
(
30
,
21
);
this
.
tb_setcode3
.
TabIndex
=
1
8
;
this
.
tb_setcode3
.
TabIndex
=
1
13
;
this
.
tb_setcode3
.
Text
=
"0"
;
this
.
tb_setcode3
.
Text
=
"0"
;
this
.
tb_setcode3
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_setcode3
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_setcode3
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
tb_setcode3_TextChanged
);
this
.
tb_setcode3
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
tb_setcode3_TextChanged
);
...
@@ -1020,7 +1021,7 @@ private void InitializeComponent()
...
@@ -1020,7 +1021,7 @@ private void InitializeComponent()
this
.
tb_setcode4
.
MaxLength
=
4
;
this
.
tb_setcode4
.
MaxLength
=
4
;
this
.
tb_setcode4
.
Name
=
"tb_setcode4"
;
this
.
tb_setcode4
.
Name
=
"tb_setcode4"
;
this
.
tb_setcode4
.
Size
=
new
System
.
Drawing
.
Size
(
30
,
21
);
this
.
tb_setcode4
.
Size
=
new
System
.
Drawing
.
Size
(
30
,
21
);
this
.
tb_setcode4
.
TabIndex
=
1
8
;
this
.
tb_setcode4
.
TabIndex
=
1
14
;
this
.
tb_setcode4
.
Text
=
"0"
;
this
.
tb_setcode4
.
Text
=
"0"
;
this
.
tb_setcode4
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_setcode4
.
TextAlign
=
System
.
Windows
.
Forms
.
HorizontalAlignment
.
Right
;
this
.
tb_setcode4
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
tb_setcode4_TextChanged
);
this
.
tb_setcode4
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
tb_setcode4_TextChanged
);
...
@@ -1248,7 +1249,7 @@ private void InitializeComponent()
...
@@ -1248,7 +1249,7 @@ private void InitializeComponent()
this
.
StartPosition
=
System
.
Windows
.
Forms
.
FormStartPosition
.
CenterScreen
;
this
.
StartPosition
=
System
.
Windows
.
Forms
.
FormStartPosition
.
CenterScreen
;
this
.
Text
=
"DataEditorX"
;
this
.
Text
=
"DataEditorX"
;
this
.
FormClosing
+=
new
System
.
Windows
.
Forms
.
FormClosingEventHandler
(
this
.
DataEditFormFormClosing
);
this
.
FormClosing
+=
new
System
.
Windows
.
Forms
.
FormClosingEventHandler
(
this
.
DataEditFormFormClosing
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
DataEditFormLoad
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
DataEditForm
_
Load
);
this
.
SizeChanged
+=
new
System
.
EventHandler
(
this
.
DataEditFormSizeChanged
);
this
.
SizeChanged
+=
new
System
.
EventHandler
(
this
.
DataEditFormSizeChanged
);
this
.
Enter
+=
new
System
.
EventHandler
(
this
.
DataEditFormEnter
);
this
.
Enter
+=
new
System
.
EventHandler
(
this
.
DataEditFormEnter
);
this
.
KeyDown
+=
new
System
.
Windows
.
Forms
.
KeyEventHandler
(
this
.
DataEditForm_KeyDown
);
this
.
KeyDown
+=
new
System
.
Windows
.
Forms
.
KeyEventHandler
(
this
.
DataEditForm_KeyDown
);
...
...
DataEditorX/DataEditForm.cs
View file @
bc0829bf
...
@@ -25,23 +25,27 @@ public partial class DataEditForm : DockContent, IDataForm
...
@@ -25,23 +25,27 @@ public partial class DataEditForm : DockContent, IDataForm
{
{
private
string
addrequire_str
;
private
string
addrequire_str
;
public
string
a
ddrequire
public
string
A
ddrequire
{
{
get
get
{
{
if
(!
string
.
IsNullOrEmpty
(
addrequire_str
))
if
(!
string
.
IsNullOrEmpty
(
this
.
addrequire_str
))
return
addrequire_str
;
{
else
return
this
.
addrequire_str
;
}
else
{
{
string
cdbName
=
Path
.
GetFileNameWithoutExtension
(
nowCdbFile
);
string
cdbName
=
Path
.
GetFileNameWithoutExtension
(
this
.
nowCdbFile
);
if
(
cdbName
.
Length
>
0
&&
File
.
Exists
(
GetPath
().
GetModuleScript
(
cdbName
)))
if
(
cdbName
.
Length
>
0
&&
File
.
Exists
(
this
.
GetPath
().
GetModuleScript
(
cdbName
)))
return
cdbName
;
{
}
return
cdbName
;
}
}
return
""
;
return
""
;
}
}
set
set
{
{
addrequire_str
=
value
;
this
.
addrequire_str
=
value
;
}
}
}
}
...
@@ -64,35 +68,36 @@ public string addrequire
...
@@ -64,35 +68,36 @@ public string addrequire
//初始标题
//初始标题
string
title
;
string
title
;
string
nowCdbFile
=
""
;
string
nowCdbFile
=
""
;
int
M
axRow
=
20
;
int
m
axRow
=
20
;
int
page
=
1
,
pageNum
=
1
;
int
page
=
1
,
pageNum
=
1
;
/// <summary>
/// <summary>
/// 卡片总数
/// 卡片总数
/// </summary>
/// </summary>
int
cardcount
;
int
cardcount
;
/// <summary>
/// <summary>
/// 搜索结果
/// 搜索结果
/// </summary>
/// </summary>
List
<
Card
>
cardlist
=
new
List
<
Card
>();
readonly
List
<
Card
>
cardlist
=
new
List
<
Card
>();
//setcode正在输入
bool
[]
setcodeIsedit
=
new
bool
[
5
];
CommandManager
cmdManager
=
new
CommandManager
();
//setcode正在输入
readonly
bool
[]
setcodeIsedit
=
new
bool
[
5
];
readonly
CommandManager
cmdManager
=
new
CommandManager
();
Image
m_
cover
;
Image
cover
;
MSEConfig
msecfg
;
MSEConfig
msecfg
;
string
datapath
,
confcover
;
string
datapath
,
confcover
;
public
DataEditForm
(
string
datapath
,
string
cdbfile
)
public
DataEditForm
(
string
datapath
,
string
cdbfile
)
{
{
Initialize
(
datapath
);
this
.
Initialize
(
datapath
);
nowCdbFile
=
cdbfile
;
this
.
nowCdbFile
=
cdbfile
;
}
}
public
DataEditForm
(
string
datapath
)
public
DataEditForm
(
string
datapath
)
{
{
Initialize
(
datapath
);
this
.
Initialize
(
datapath
);
}
}
public
DataEditForm
()
public
DataEditForm
()
{
//默认启动
{
//默认启动
...
@@ -101,25 +106,29 @@ public DataEditForm()
...
@@ -101,25 +106,29 @@ public DataEditForm()
{
{
Application
.
Exit
();
Application
.
Exit
();
}
}
datapath
=
MyPath
.
Combine
(
Application
.
StartupPath
,
dir
);
this
.
datapath
=
MyPath
.
Combine
(
Application
.
StartupPath
,
dir
);
Initialize
(
datapath
);
this
.
Initialize
(
this
.
datapath
);
}
}
void
Initialize
(
string
datapath
)
void
Initialize
(
string
datapath
)
{
{
cardedit
=
new
CardEdit
(
this
);
this
.
cardedit
=
new
CardEdit
(
this
);
tmpCodes
=
new
List
<
string
>();
t
his
.
t
mpCodes
=
new
List
<
string
>();
ygopath
=
new
YgoPath
(
Application
.
StartupPath
);
this
.
ygopath
=
new
YgoPath
(
Application
.
StartupPath
);
InitPath
(
datapath
);
this
.
InitPath
(
datapath
);
InitializeComponent
();
this
.
InitializeComponent
();
title
=
this
.
Text
;
t
his
.
t
itle
=
this
.
Text
;
nowCdbFile
=
""
;
this
.
nowCdbFile
=
""
;
cmdManager
.
UndoStateChanged
+=
delegate
(
bool
val
)
this
.
cmdManager
.
UndoStateChanged
+=
delegate
(
bool
val
)
{
{
if
(
val
)
if
(
val
)
btn_undo
.
Enabled
=
true
;
{
this
.
btn_undo
.
Enabled
=
true
;
}
else
else
btn_undo
.
Enabled
=
false
;
{
this
.
btn_undo
.
Enabled
=
false
;
}
};
};
}
}
...
@@ -132,15 +141,15 @@ public void SetActived()
...
@@ -132,15 +141,15 @@ public void SetActived()
}
}
public
string
GetOpenFile
()
public
string
GetOpenFile
()
{
{
return
nowCdbFile
;
return
this
.
nowCdbFile
;
}
}
public
bool
CanOpen
(
string
file
)
public
bool
CanOpen
(
string
file
)
{
{
return
YGOUtil
.
i
sDataBase
(
file
);
return
YGOUtil
.
I
sDataBase
(
file
);
}
}
public
bool
Create
(
string
file
)
public
bool
Create
(
string
file
)
{
{
return
Open
(
file
);
return
this
.
Open
(
file
);
}
}
public
bool
Save
()
public
bool
Save
()
{
{
...
@@ -153,38 +162,40 @@ public bool Save()
...
@@ -153,38 +162,40 @@ public bool Save()
void
DataEditFormLoad
(
object
sender
,
EventArgs
e
)
void
DataEditFormLoad
(
object
sender
,
EventArgs
e
)
{
{
//InitListRows();//调整卡片列表的函数
//InitListRows();//调整卡片列表的函数
HideMenu
();
//是否需要隐藏菜单
this
.
HideMenu
();
//是否需要隐藏菜单
SetTitle
();
//设置标题
this
.
SetTitle
();
//设置标题
//加载
//加载
msecfg
=
new
MSEConfig
(
datapath
);
this
.
msecfg
=
new
MSEConfig
(
this
.
datapath
);
t
asker
=
new
TaskHelper
(
datapath
,
bgWorker1
,
msecfg
);
t
his
.
tasker
=
new
TaskHelper
(
this
.
datapath
,
this
.
bgWorker1
,
this
.
msecfg
);
//设置空白卡片
//设置空白卡片
oldCard
=
new
Card
(
0
);
this
.
oldCard
=
new
Card
(
0
);
SetCard
(
oldCard
);
this
.
SetCard
(
this
.
oldCard
);
//删除资源
//删除资源
menuitem_operacardsfile
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_DELETE_WITH
);
this
.
menuitem_operacardsfile
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_DELETE_WITH
);
//用CodeEditor打开脚本
//用CodeEditor打开脚本
menuitem_openfileinthis
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_OPEN_IN_THIS
);
this
.
menuitem_openfileinthis
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_OPEN_IN_THIS
);
//自动检查更新
//自动检查更新
menuitem_autocheckupdate
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
);
this
.
menuitem_autocheckupdate
.
Checked
=
MyConfig
.
readBoolean
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
);
//add require automatically
//add require automatically
addrequire
=
MyConfig
.
readString
(
MyConfig
.
TAG_ADD_REQUIRE
);
this
.
Addrequire
=
MyConfig
.
readString
(
MyConfig
.
TAG_ADD_REQUIRE
);
menuitem_addrequire
.
Checked
=
(
addrequire
.
Length
>
0
);
this
.
menuitem_addrequire
.
Checked
=
(
this
.
Addrequire
.
Length
>
0
);
if
(
nowCdbFile
!=
null
&&
File
.
Exists
(
nowCdbFile
))
if
(
this
.
nowCdbFile
!=
null
&&
File
.
Exists
(
this
.
nowCdbFile
))
Open
(
nowCdbFile
);
{
this
.
Open
(
this
.
nowCdbFile
);
}
//获取MSE配菜单
//获取MSE配菜单
AddMenuItemFormMSE
();
this
.
AddMenuItemFormMSE
();
//
//
GetLanguageItem
();
this
.
GetLanguageItem
();
// CheckUpdate(false);//检查更新
// CheckUpdate(false);//检查更新
}
}
//窗体关闭
//窗体关闭
void
DataEditFormFormClosing
(
object
sender
,
FormClosingEventArgs
e
)
void
DataEditFormFormClosing
(
object
sender
,
FormClosingEventArgs
e
)
{
{
//当前有任务执行,是否结束
//当前有任务执行,是否结束
if
(
t
asker
!=
null
&&
tasker
.
IsRuning
())
if
(
t
his
.
tasker
!=
null
&&
this
.
tasker
.
IsRuning
())
{
{
if
(!
CancelTask
())
if
(!
this
.
CancelTask
())
{
{
e
.
Cancel
=
true
;
e
.
Cancel
=
true
;
return
;
return
;
...
@@ -194,7 +205,7 @@ void DataEditFormFormClosing(object sender, FormClosingEventArgs e)
...
@@ -194,7 +205,7 @@ void DataEditFormFormClosing(object sender, FormClosingEventArgs e)
//窗体激活
//窗体激活
void
DataEditFormEnter
(
object
sender
,
EventArgs
e
)
void
DataEditFormEnter
(
object
sender
,
EventArgs
e
)
{
{
SetTitle
();
this
.
SetTitle
();
}
}
#
endregion
#
endregion
...
@@ -203,16 +214,22 @@ void DataEditFormEnter(object sender, EventArgs e)
...
@@ -203,16 +214,22 @@ void DataEditFormEnter(object sender, EventArgs e)
void
HideMenu
()
void
HideMenu
()
{
{
if
(
this
.
MdiParent
==
null
)
if
(
this
.
MdiParent
==
null
)
{
return
;
return
;
mainMenu
.
Visible
=
false
;
}
menuitem_file
.
Visible
=
false
;
menuitem_file
.
Enabled
=
false
;
this
.
mainMenu
.
Visible
=
false
;
this
.
menuitem_file
.
Visible
=
false
;
this
.
menuitem_file
.
Enabled
=
false
;
//this.SuspendLayout();
//this.SuspendLayout();
this
.
ResumeLayout
(
true
);
this
.
ResumeLayout
(
true
);
foreach
(
Control
c
in
this
.
Controls
)
foreach
(
Control
c
in
this
.
Controls
)
{
{
if
(
c
.
GetType
()
==
typeof
(
MenuStrip
))
if
(
c
.
GetType
()
==
typeof
(
MenuStrip
))
{
continue
;
continue
;
}
Point
p
=
c
.
Location
;
Point
p
=
c
.
Location
;
c
.
Location
=
new
Point
(
p
.
X
,
p
.
Y
-
25
);
c
.
Location
=
new
Point
(
p
.
X
,
p
.
Y
-
25
);
}
}
...
@@ -232,78 +249,169 @@ string RemoveTag(string text)
...
@@ -232,78 +249,169 @@ string RemoveTag(string text)
//设置标题
//设置标题
void
SetTitle
()
void
SetTitle
()
{
{
string
str
=
title
;
string
str
=
t
his
.
t
itle
;
string
str2
=
RemoveTag
(
title
);
string
str2
=
this
.
RemoveTag
(
this
.
title
);
if
(!
string
.
IsNullOrEmpty
(
nowCdbFile
))
if
(!
string
.
IsNullOrEmpty
(
this
.
nowCdbFile
))
{
{
str
=
nowCdbFile
+
"-"
+
str
;
str
=
this
.
nowCdbFile
+
"-"
+
str
;
str2
=
Path
.
GetFileName
(
nowCdbFile
);
str2
=
Path
.
GetFileName
(
this
.
nowCdbFile
);
}
}
if
(
this
.
MdiParent
!=
null
)
//父容器不为空
if
(
this
.
MdiParent
!=
null
)
//父容器不为空
{
{
this
.
Text
=
str2
;
this
.
Text
=
str2
;
if
(
t
asker
!=
null
&&
tasker
.
IsRuning
())
if
(
t
his
.
tasker
!=
null
&&
this
.
tasker
.
IsRuning
())
{
{
if
(
DockPanel
.
ActiveContent
==
this
)
if
(
this
.
DockPanel
.
ActiveContent
==
this
)
{
this
.
MdiParent
.
Text
=
str
;
this
.
MdiParent
.
Text
=
str
;
}
}
}
else
else
{
this
.
MdiParent
.
Text
=
str
;
this
.
MdiParent
.
Text
=
str
;
}
}
}
else
else
{
this
.
Text
=
str
;
this
.
Text
=
str
;
}
}
}
//按cdb路径设置目录
//按cdb路径设置目录
void
SetCDB
(
string
cdb
)
void
SetCDB
(
string
cdb
)
{
{
this
.
nowCdbFile
=
cdb
;
this
.
nowCdbFile
=
cdb
;
SetTitle
();
this
.
SetTitle
();
string
path
=
Application
.
StartupPath
;
string
path
=
Application
.
StartupPath
;
if
(
cdb
.
Length
>
0
)
if
(
cdb
.
Length
>
0
)
{
{
path
=
Path
.
GetDirectoryName
(
cdb
);
path
=
Path
.
GetDirectoryName
(
cdb
);
}
}
ygopath
.
SetPath
(
path
);
this
.
ygopath
.
SetPath
(
path
);
}
}
//初始化文件路径
//初始化文件路径
void
InitPath
(
string
datapath
)
void
InitPath
(
string
datapath
)
{
{
this
.
datapath
=
datapath
;
this
.
datapath
=
datapath
;
confcover
=
MyPath
.
Combine
(
datapath
,
"cover.jpg"
);
this
.
confcover
=
MyPath
.
Combine
(
datapath
,
"cover.jpg"
);
if
(
File
.
Exists
(
confcover
))
if
(
File
.
Exists
(
this
.
confcover
))
m_cover
=
MyBitmap
.
readImage
(
confcover
);
{
this
.
cover
=
MyBitmap
.
readImage
(
this
.
confcover
);
}
else
else
m_cover
=
null
;
{
this
.
cover
=
null
;
}
}
}
#
endregion
#
endregion
#
region
界面控件
#
region
界面控件
//初始化控件
//初始化控件
public
void
InitControl
(
DataConfig
datacfg
)
public
void
InitControl
(
DataConfig
datacfg
)
{
{
if
(
datacfg
==
null
)
//为了进行错误定位而进行改造 190324 by JoyJ
if
(
datacfg
==
null
)
{
return
;
return
;
//选择框
}
InitComboBox
(
cb_cardrace
,
datacfg
.
dicCardRaces
);
InitComboBox
(
cb_cardattribute
,
datacfg
.
dicCardAttributes
);
try
InitComboBox
(
cb_cardrule
,
datacfg
.
dicCardRules
);
{
InitComboBox
(
cb_cardlevel
,
datacfg
.
dicCardLevels
);
this
.
InitComboBox
(
this
.
cb_cardrace
,
datacfg
.
dicCardRaces
);
//卡片类型
}
InitCheckPanel
(
pl_cardtype
,
datacfg
.
dicCardTypes
);
catch
(
Exception
ex
)
//连接标记
{
InitCheckPanel
(
pl_markers
,
datacfg
.
dicLinkMarkers
);
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-cb_cardrace"
);
SetEnabled
(
pl_markers
,
false
);
}
//效果类型
try
InitCheckPanel
(
pl_category
,
datacfg
.
dicCardcategorys
);
{
//系列名
this
.
InitComboBox
(
this
.
cb_cardattribute
,
datacfg
.
dicCardAttributes
);
List
<
long
>
setcodes
=
DataManager
.
GetKeys
(
datacfg
.
dicSetnames
);
}
string
[]
setnames
=
DataManager
.
GetValues
(
datacfg
.
dicSetnames
);
catch
(
Exception
ex
)
InitComboBox
(
cb_setname1
,
setcodes
,
setnames
);
{
InitComboBox
(
cb_setname2
,
setcodes
,
setnames
);
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-cb_cardattribute"
);
InitComboBox
(
cb_setname3
,
setcodes
,
setnames
);
}
InitComboBox
(
cb_setname4
,
setcodes
,
setnames
);
try
//
{
this
.
InitComboBox
(
this
.
cb_cardrule
,
datacfg
.
dicCardRules
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-cb_cardrule"
);
}
try
{
this
.
InitComboBox
(
this
.
cb_cardlevel
,
datacfg
.
dicCardLevels
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-cb_cardlevel"
);
}
try
{
this
.
InitCheckPanel
(
this
.
pl_cardtype
,
datacfg
.
dicCardTypes
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-pl_cardtype"
);
}
try
{
this
.
InitCheckPanel
(
this
.
pl_markers
,
datacfg
.
dicLinkMarkers
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-pl_markers"
);
}
try
{
this
.
InitCheckPanel
(
this
.
pl_category
,
datacfg
.
dicCardcategorys
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-pl_category"
);
}
try
{
this
.
SetEnabled
(
this
.
pl_markers
,
false
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-pl_markers"
);
}
List
<
long
>
setcodes
=
DataManager
.
GetKeys
(
datacfg
.
dicSetnames
);
string
[]
setnames
=
DataManager
.
GetValues
(
datacfg
.
dicSetnames
);
try
{
this
.
InitComboBox
(
this
.
cb_setname1
,
setcodes
,
setnames
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-cb_setname1"
);
}
try
{
this
.
InitComboBox
(
this
.
cb_setname2
,
setcodes
,
setnames
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-cb_setname2"
);
}
try
{
this
.
InitComboBox
(
this
.
cb_setname3
,
setcodes
,
setnames
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-cb_setname3"
);
}
try
{
this
.
InitComboBox
(
this
.
cb_setname4
,
setcodes
,
setnames
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误-cb_setname4"
);
}
}
}
//初始化FlowLayoutPanel
//初始化FlowLayoutPanel
void
InitCheckPanel
(
FlowLayoutPanel
fpanel
,
Dictionary
<
long
,
string
>
dic
)
void
InitCheckPanel
(
FlowLayoutPanel
fpanel
,
Dictionary
<
long
,
string
>
dic
)
...
@@ -324,13 +432,15 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic)
...
@@ -324,13 +432,15 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic)
lab
.
Margin
=
fpanel
.
Margin
;
lab
.
Margin
=
fpanel
.
Margin
;
fpanel
.
Controls
.
Add
(
lab
);
fpanel
.
Controls
.
Add
(
lab
);
}
else
{
}
else
{
CheckBox
_cbox
=
new
CheckBox
();
CheckBox
_cbox
=
new
CheckBox
//_cbox.Name = fpanel.Name + key.ToString("x");
{
_cbox
.
Tag
=
key
;
//绑定值
//_cbox.Name = fpanel.Name + key.ToString("x");
_cbox
.
Text
=
value
;
Tag
=
key
,
//绑定值
_cbox
.
AutoSize
=
true
;
Text
=
value
,
_cbox
.
Margin
=
fpanel
.
Margin
;
AutoSize
=
true
,
_cbox
.
CheckedChanged
+=
_cbox_CheckedChanged
;
Margin
=
fpanel
.
Margin
};
_cbox
.
CheckedChanged
+=
this
.
_cbox_CheckedChanged
;
//_cbox.Click += PanelOnCheckClick;
//_cbox.Click += PanelOnCheckClick;
fpanel
.
Controls
.
Add
(
_cbox
);
fpanel
.
Controls
.
Add
(
_cbox
);
}
}
...
@@ -341,24 +451,13 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic)
...
@@ -341,24 +451,13 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic)
private
void
_cbox_CheckedChanged
(
object
sender
,
EventArgs
e
)
private
void
_cbox_CheckedChanged
(
object
sender
,
EventArgs
e
)
{
{
CheckBox
cbox
=
(
CheckBox
)
sender
;
if
(
cbox
.
Parent
==
pl_cardtype
)
{
if
((
long
)
cbox
.
Tag
==
(
long
)
Core
.
Info
.
CardType
.
TYPE_LINK
)
{
SetEnabled
(
pl_markers
,
cbox
.
Checked
);
tb_def
.
ReadOnly
=
cbox
.
Checked
;
tb_link
.
ReadOnly
=
!
cbox
.
Checked
;
}
}
else
if
(
cbox
.
Parent
==
pl_markers
){
setLinkMarks
(
GetCheck
(
pl_markers
));
}
}
}
//初始化ComboBox
//初始化ComboBox
void
InitComboBox
(
ComboBox
cb
,
Dictionary
<
long
,
string
>
tempdic
)
void
InitComboBox
(
ComboBox
cb
,
Dictionary
<
long
,
string
>
tempdic
)
{
{
InitComboBox
(
cb
,
DataManager
.
GetKeys
(
tempdic
),
this
.
InitComboBox
(
cb
,
DataManager
.
GetKeys
(
tempdic
),
DataManager
.
GetValues
(
tempdic
));
DataManager
.
GetValues
(
tempdic
));
}
}
//初始化ComboBox
//初始化ComboBox
...
@@ -366,34 +465,42 @@ void InitComboBox(ComboBox cb, List<long> keys, string[] values)
...
@@ -366,34 +465,42 @@ void InitComboBox(ComboBox cb, List<long> keys, string[] values)
{
{
cb
.
Items
.
Clear
();
cb
.
Items
.
Clear
();
cb
.
Tag
=
keys
;
cb
.
Tag
=
keys
;
cb
.
Items
.
AddRange
(
values
);
//Improve 190324 by JoyJ
cb
.
SelectedIndex
=
0
;
if
(
cb
.
Items
.
Count
>
0
)
{
cb
.
Items
.
AddRange
(
values
);
cb
.
SelectedIndex
=
0
;
}
}
}
//计算list最大行数
//计算list最大行数
void
InitListRows
()
void
InitListRows
()
{
{
bool
addTest
=
lv_cardlist
.
Items
.
Count
==
0
;
bool
addTest
=
this
.
lv_cardlist
.
Items
.
Count
==
0
;
if
(
addTest
)
if
(
addTest
)
{
{
ListViewItem
item
=
new
ListViewItem
();
ListViewItem
item
=
new
ListViewItem
item
.
Text
=
"Test"
;
{
lv_cardlist
.
Items
.
Add
(
item
);
Text
=
"Test"
};
this
.
lv_cardlist
.
Items
.
Add
(
item
);
}
}
int
headH
=
lv_cardlist
.
Items
[
0
].
GetBounds
(
ItemBoundsPortion
.
ItemOnly
).
Y
;
int
headH
=
this
.
lv_cardlist
.
Items
[
0
].
GetBounds
(
ItemBoundsPortion
.
ItemOnly
).
Y
;
int
itemH
=
lv_cardlist
.
Items
[
0
].
GetBounds
(
ItemBoundsPortion
.
ItemOnly
).
Height
;
int
itemH
=
this
.
lv_cardlist
.
Items
[
0
].
GetBounds
(
ItemBoundsPortion
.
ItemOnly
).
Height
;
if
(
itemH
>
0
)
if
(
itemH
>
0
)
{
{
int
n
=
(
lv_cardlist
.
Height
-
headH
)
/
itemH
;
int
n
=
(
this
.
lv_cardlist
.
Height
-
headH
)
/
itemH
;
if
(
n
>
0
){
if
(
n
>
0
){
M
axRow
=
n
;
this
.
m
axRow
=
n
;
}
}
//MessageBox.Show("height="+lv_cardlist.Height+",item="+itemH+",head="+headH+",max="+MaxRow);
//MessageBox.Show("height="+lv_cardlist.Height+",item="+itemH+",head="+headH+",max="+MaxRow);
}
}
if
(
addTest
){
if
(
addTest
){
lv_cardlist
.
Items
.
Clear
();
this
.
lv_cardlist
.
Items
.
Clear
();
}
if
(
this
.
maxRow
<
10
)
{
this
.
maxRow
=
20
;
}
}
if
(
MaxRow
<
10
)
MaxRow
=
20
;
}
}
//设置checkbox
//设置checkbox
void
SetCheck
(
FlowLayoutPanel
fpl
,
long
number
)
void
SetCheck
(
FlowLayoutPanel
fpl
,
long
number
)
...
@@ -402,13 +509,16 @@ void SetCheck(FlowLayoutPanel fpl, long number)
...
@@ -402,13 +509,16 @@ void SetCheck(FlowLayoutPanel fpl, long number)
//string strType = "";
//string strType = "";
foreach
(
Control
c
in
fpl
.
Controls
)
foreach
(
Control
c
in
fpl
.
Controls
)
{
{
if
(
c
is
CheckBox
)
if
(
c
is
CheckBox
cbox
)
{
{
CheckBox
cbox
=
(
CheckBox
)
c
;
if
(
cbox
.
Tag
==
null
)
if
(
cbox
.
Tag
==
null
)
{
temp
=
0
;
temp
=
0
;
}
else
else
{
temp
=
(
long
)
cbox
.
Tag
;
temp
=
(
long
)
cbox
.
Tag
;
}
if
((
temp
&
number
)
==
temp
&&
temp
!=
0
)
if
((
temp
&
number
)
==
temp
&&
temp
!=
0
)
{
{
...
@@ -416,7 +526,9 @@ void SetCheck(FlowLayoutPanel fpl, long number)
...
@@ -416,7 +526,9 @@ void SetCheck(FlowLayoutPanel fpl, long number)
//strType += "/" + c.Text;
//strType += "/" + c.Text;
}
}
else
else
{
cbox
.
Checked
=
false
;
cbox
.
Checked
=
false
;
}
}
}
}
}
//return strType;
//return strType;
...
@@ -425,8 +537,7 @@ void SetEnabled(FlowLayoutPanel fpl, bool set)
...
@@ -425,8 +537,7 @@ void SetEnabled(FlowLayoutPanel fpl, bool set)
{
{
foreach
(
Control
c
in
fpl
.
Controls
)
foreach
(
Control
c
in
fpl
.
Controls
)
{
{
CheckBox
cbox
=
c
as
CheckBox
;
if
(
c
is
CheckBox
cbox
)
if
(
cbox
!=
null
)
{
{
cbox
.
Enabled
=
set
;
cbox
.
Enabled
=
set
;
}
}
...
@@ -443,9 +554,9 @@ void SetSelect(ComboBox cb, long k)
...
@@ -443,9 +554,9 @@ void SetSelect(ComboBox cb, long k)
List
<
long
>
keys
=
(
List
<
long
>)
cb
.
Tag
;
List
<
long
>
keys
=
(
List
<
long
>)
cb
.
Tag
;
int
index
=
keys
.
IndexOf
(
k
);
int
index
=
keys
.
IndexOf
(
k
);
if
(
index
>=
0
&&
index
<
cb
.
Items
.
Count
)
if
(
index
>=
0
&&
index
<
cb
.
Items
.
Count
)
{
cb
.
SelectedIndex
=
index
;
cb
.
SelectedIndex
=
index
;
else
}
cb
.
SelectedIndex
=
0
;
}
}
//得到所选值
//得到所选值
long
GetSelect
(
ComboBox
cb
)
long
GetSelect
(
ComboBox
cb
)
...
@@ -457,9 +568,13 @@ long GetSelect(ComboBox cb)
...
@@ -457,9 +568,13 @@ long GetSelect(ComboBox cb)
List
<
long
>
keys
=
(
List
<
long
>)
cb
.
Tag
;
List
<
long
>
keys
=
(
List
<
long
>)
cb
.
Tag
;
int
index
=
cb
.
SelectedIndex
;
int
index
=
cb
.
SelectedIndex
;
if
(
index
>=
keys
.
Count
)
if
(
index
>=
keys
.
Count
)
{
return
0
;
return
0
;
}
else
else
{
return
keys
[
index
];
return
keys
[
index
];
}
}
}
//得到checkbox的总值
//得到checkbox的总值
long
GetCheck
(
FlowLayoutPanel
fpl
)
long
GetCheck
(
FlowLayoutPanel
fpl
)
...
@@ -468,15 +583,21 @@ long GetCheck(FlowLayoutPanel fpl)
...
@@ -468,15 +583,21 @@ long GetCheck(FlowLayoutPanel fpl)
long
temp
;
long
temp
;
foreach
(
Control
c
in
fpl
.
Controls
)
foreach
(
Control
c
in
fpl
.
Controls
)
{
{
if
(
c
is
CheckBox
)
if
(
c
is
CheckBox
cbox
)
{
{
CheckBox
cbox
=
(
CheckBox
)
c
;
if
(
cbox
.
Tag
==
null
)
if
(
cbox
.
Tag
==
null
)
{
temp
=
0
;
temp
=
0
;
}
else
else
{
temp
=
(
long
)
cbox
.
Tag
;
temp
=
(
long
)
cbox
.
Tag
;
}
if
(
cbox
.
Checked
)
if
(
cbox
.
Checked
)
{
number
+=
temp
;
number
+=
temp
;
}
}
}
}
}
return
number
;
return
number
;
...
@@ -487,38 +608,56 @@ void AddListView(int p)
...
@@ -487,38 +608,56 @@ void AddListView(int p)
int
i
,
j
,
istart
,
iend
;
int
i
,
j
,
istart
,
iend
;
if
(
p
<=
0
)
if
(
p
<=
0
)
{
p
=
1
;
p
=
1
;
else
if
(
p
>=
pageNum
)
}
p
=
pageNum
;
else
if
(
p
>=
this
.
pageNum
)
istart
=
(
p
-
1
)
*
MaxRow
;
{
iend
=
p
*
MaxRow
;
p
=
this
.
pageNum
;
if
(
iend
>
cardcount
)
}
iend
=
cardcount
;
page
=
p
;
istart
=
(
p
-
1
)
*
this
.
maxRow
;
lv_cardlist
.
BeginUpdate
();
iend
=
p
*
this
.
maxRow
;
lv_cardlist
.
Items
.
Clear
();
if
(
iend
>
this
.
cardcount
)
{
iend
=
this
.
cardcount
;
}
this
.
page
=
p
;
this
.
lv_cardlist
.
BeginUpdate
();
this
.
lv_cardlist
.
Items
.
Clear
();
if
((
iend
-
istart
)
>
0
)
if
((
iend
-
istart
)
>
0
)
{
{
ListViewItem
[]
items
=
new
ListViewItem
[
iend
-
istart
];
ListViewItem
[]
items
=
new
ListViewItem
[
iend
-
istart
];
Card
mcard
;
Card
mcard
;
for
(
i
=
istart
,
j
=
0
;
i
<
iend
;
i
++,
j
++)
for
(
i
=
istart
,
j
=
0
;
i
<
iend
;
i
++,
j
++)
{
{
mcard
=
cardlist
[
i
];
mcard
=
this
.
cardlist
[
i
];
items
[
j
]
=
new
ListViewItem
();
items
[
j
]
=
new
ListViewItem
items
[
j
].
Tag
=
i
;
{
items
[
j
].
Text
=
mcard
.
id
.
ToString
();
Tag
=
i
,
if
(
mcard
.
id
==
oldCard
.
id
)
Text
=
mcard
.
id
.
ToString
()
};
if
(
mcard
.
id
==
this
.
oldCard
.
id
)
{
items
[
j
].
Checked
=
true
;
items
[
j
].
Checked
=
true
;
}
if
(
i
%
2
==
0
)
if
(
i
%
2
==
0
)
{
items
[
j
].
BackColor
=
Color
.
GhostWhite
;
items
[
j
].
BackColor
=
Color
.
GhostWhite
;
}
else
else
{
items
[
j
].
BackColor
=
Color
.
White
;
items
[
j
].
BackColor
=
Color
.
White
;
}
items
[
j
].
SubItems
.
Add
(
mcard
.
name
);
items
[
j
].
SubItems
.
Add
(
mcard
.
name
);
}
}
lv_cardlist
.
Items
.
AddRange
(
items
);
this
.
lv_cardlist
.
Items
.
AddRange
(
items
);
}
}
lv_cardlist
.
EndUpdate
();
this
.
lv_cardlist
.
EndUpdate
();
t
b_page
.
Text
=
page
.
ToString
();
t
his
.
tb_page
.
Text
=
this
.
page
.
ToString
();
}
}
#
endregion
#
endregion
...
@@ -526,119 +665,138 @@ void AddListView(int p)
...
@@ -526,119 +665,138 @@ void AddListView(int p)
#
region
设置卡片
#
region
设置卡片
public
YgoPath
GetPath
()
public
YgoPath
GetPath
()
{
{
return
ygopath
;
return
this
.
ygopath
;
}
}
public
Card
GetOldCard
()
public
Card
GetOldCard
()
{
{
return
oldCard
;
return
this
.
oldCard
;
}
}
private
void
setLinkMarks
(
long
mark
,
bool
setCheck
=
false
)
private
void
setLinkMarks
(
long
mark
,
bool
setCheck
=
false
)
{
{
if
(
setCheck
)
if
(
setCheck
)
{
{
SetCheck
(
pl_markers
,
mark
);
this
.
SetCheck
(
this
.
pl_markers
,
mark
);
}
}
tb_link
.
Text
=
Convert
.
ToString
(
mark
,
2
).
PadLeft
(
9
,
'0'
);
t
his
.
t
b_link
.
Text
=
Convert
.
ToString
(
mark
,
2
).
PadLeft
(
9
,
'0'
);
}
}
public
void
SetCard
(
Card
c
)
public
void
SetCard
(
Card
c
)
{
{
oldCard
=
c
;
this
.
oldCard
=
c
;
tb_cardname
.
Text
=
c
.
name
;
t
his
.
t
b_cardname
.
Text
=
c
.
name
;
tb_cardtext
.
Text
=
c
.
desc
;
t
his
.
t
b_cardtext
.
Text
=
c
.
desc
;
strs
=
new
string
[
c
.
Str
.
Length
];
this
.
strs
=
new
string
[
c
.
Str
.
Length
];
Array
.
Copy
(
c
.
Str
,
strs
,
Card
.
STR_MAX
);
Array
.
Copy
(
c
.
Str
,
this
.
strs
,
Card
.
STR_MAX
);
lb_scripttext
.
Items
.
Clear
();
this
.
lb_scripttext
.
Items
.
Clear
();
lb_scripttext
.
Items
.
AddRange
(
c
.
Str
);
this
.
lb_scripttext
.
Items
.
AddRange
(
c
.
Str
);
tb_edittext
.
Text
=
""
;
t
his
.
t
b_edittext
.
Text
=
""
;
//data
//data
SetSelect
(
cb_cardrule
,
c
.
ot
);
this
.
SetSelect
(
this
.
cb_cardrule
,
c
.
ot
);
SetSelect
(
cb_cardattribute
,
c
.
attribute
);
this
.
SetSelect
(
this
.
cb_cardattribute
,
c
.
attribute
);
SetSelect
(
cb_cardlevel
,
(
c
.
level
&
0xff
));
this
.
SetSelect
(
this
.
cb_cardlevel
,
(
c
.
level
&
0xff
));
SetSelect
(
cb_cardrace
,
c
.
race
);
this
.
SetSelect
(
this
.
cb_cardrace
,
c
.
race
);
//setcode
//setcode
long
[]
setcodes
=
c
.
GetSetCode
();
long
[]
setcodes
=
c
.
GetSetCode
();
tb_setcode1
.
Text
=
setcodes
[
0
].
ToString
(
"x"
);
t
his
.
t
b_setcode1
.
Text
=
setcodes
[
0
].
ToString
(
"x"
);
tb_setcode2
.
Text
=
setcodes
[
1
].
ToString
(
"x"
);
t
his
.
t
b_setcode2
.
Text
=
setcodes
[
1
].
ToString
(
"x"
);
tb_setcode3
.
Text
=
setcodes
[
2
].
ToString
(
"x"
);
t
his
.
t
b_setcode3
.
Text
=
setcodes
[
2
].
ToString
(
"x"
);
tb_setcode4
.
Text
=
setcodes
[
3
].
ToString
(
"x"
);
t
his
.
t
b_setcode4
.
Text
=
setcodes
[
3
].
ToString
(
"x"
);
//type,category
//type,category
SetCheck
(
pl_cardtype
,
c
.
type
);
this
.
SetCheck
(
this
.
pl_cardtype
,
c
.
type
);
if
(
c
.
IsType
(
Core
.
Info
.
CardType
.
TYPE_LINK
)){
if
(
c
.
IsType
(
Core
.
Info
.
CardType
.
TYPE_LINK
)){
setLinkMarks
(
c
.
def
,
true
);
this
.
setLinkMarks
(
c
.
def
,
true
);
}
}
else
{
else
{
tb_link
.
Text
=
""
;
t
his
.
t
b_link
.
Text
=
""
;
SetCheck
(
pl_markers
,
0
);
this
.
SetCheck
(
this
.
pl_markers
,
0
);
}
}
SetCheck
(
pl_category
,
c
.
category
);
this
.
SetCheck
(
this
.
pl_category
,
c
.
category
);
//Pendulum
//Pendulum
tb_pleft
.
Text
=
((
c
.
level
>>
24
)
&
0xff
).
ToString
();
t
his
.
t
b_pleft
.
Text
=
((
c
.
level
>>
24
)
&
0xff
).
ToString
();
tb_pright
.
Text
=
((
c
.
level
>>
16
)
&
0xff
).
ToString
();
t
his
.
t
b_pright
.
Text
=
((
c
.
level
>>
16
)
&
0xff
).
ToString
();
//atk,def
//atk,def
tb_atk
.
Text
=
(
c
.
atk
<
0
)
?
"?"
:
c
.
atk
.
ToString
();
t
his
.
t
b_atk
.
Text
=
(
c
.
atk
<
0
)
?
"?"
:
c
.
atk
.
ToString
();
if
(
c
.
IsType
(
Core
.
Info
.
CardType
.
TYPE_LINK
))
if
(
c
.
IsType
(
Core
.
Info
.
CardType
.
TYPE_LINK
))
tb_def
.
Text
=
"0"
;
{
this
.
tb_def
.
Text
=
"0"
;
}
else
else
tb_def
.
Text
=
(
c
.
def
<
0
)
?
"?"
:
c
.
def
.
ToString
();
{
tb_cardcode
.
Text
=
c
.
id
.
ToString
();
this
.
tb_def
.
Text
=
(
c
.
def
<
0
)
?
"?"
:
c
.
def
.
ToString
();
tb_cardalias
.
Text
=
c
.
alias
.
ToString
();
}
SetImage
(
c
.
id
.
ToString
());
this
.
tb_cardcode
.
Text
=
c
.
id
.
ToString
();
this
.
tb_cardalias
.
Text
=
c
.
alias
.
ToString
();
this
.
SetImage
(
c
.
id
.
ToString
());
}
}
#
endregion
#
endregion
#
region
获取卡片
#
region
获取卡片
public
Card
GetCard
()
public
Card
GetCard
()
{
{
int
temp
;
Card
c
=
new
Card
(
0
)
Card
c
=
new
Card
(
0
);
{
c
.
name
=
tb_cardname
.
Text
;
name
=
this
.
tb_cardname
.
Text
,
c
.
desc
=
tb_cardtext
.
Text
;
desc
=
this
.
tb_cardtext
.
Text
};
Array
.
Copy
(
strs
,
c
.
Str
,
Card
.
STR_MAX
);
Array
.
Copy
(
this
.
strs
,
c
.
Str
,
Card
.
STR_MAX
);
c
.
ot
=
(
int
)
GetSelect
(
cb_cardrule
);
c
.
ot
=
(
int
)
this
.
GetSelect
(
this
.
cb_cardrule
);
c
.
attribute
=
(
int
)
GetSelect
(
cb_cardattribute
);
c
.
attribute
=
(
int
)
this
.
GetSelect
(
this
.
cb_cardattribute
);
c
.
level
=
(
int
)
GetSelect
(
cb_cardlevel
);
c
.
level
=
(
int
)
this
.
GetSelect
(
this
.
cb_cardlevel
);
c
.
race
=
(
int
)
GetSelect
(
cb_cardrace
);
c
.
race
=
(
int
)
this
.
GetSelect
(
this
.
cb_cardrace
);
//系列
//系列
c
.
SetSetCode
(
c
.
SetSetCode
(
tb_setcode1
.
Text
,
t
his
.
t
b_setcode1
.
Text
,
tb_setcode2
.
Text
,
t
his
.
t
b_setcode2
.
Text
,
tb_setcode3
.
Text
,
t
his
.
t
b_setcode3
.
Text
,
tb_setcode4
.
Text
);
t
his
.
t
b_setcode4
.
Text
);
c
.
type
=
GetCheck
(
pl_cardtype
);
c
.
type
=
this
.
GetCheck
(
this
.
pl_cardtype
);
c
.
category
=
GetCheck
(
pl_category
);
c
.
category
=
this
.
GetCheck
(
this
.
pl_category
);
int
.
TryParse
(
t
b_pleft
.
Text
,
ou
t
temp
);
int
.
TryParse
(
t
his
.
tb_pleft
.
Text
,
out
in
t
temp
);
c
.
level
+=
(
temp
<<
24
);
c
.
level
+=
(
temp
<<
24
);
int
.
TryParse
(
tb_pright
.
Text
,
out
temp
);
int
.
TryParse
(
t
his
.
t
b_pright
.
Text
,
out
temp
);
c
.
level
+=
(
temp
<<
16
);
c
.
level
+=
(
temp
<<
16
);
if
(
tb_atk
.
Text
==
"?"
||
tb_atk
.
Text
==
"?"
)
if
(
this
.
tb_atk
.
Text
==
"?"
||
this
.
tb_atk
.
Text
==
"?"
)
{
c
.
atk
=
-
2
;
c
.
atk
=
-
2
;
else
if
(
tb_atk
.
Text
==
"."
)
}
else
if
(
this
.
tb_atk
.
Text
==
"."
)
{
c
.
atk
=
-
1
;
c
.
atk
=
-
1
;
}
else
else
int
.
TryParse
(
tb_atk
.
Text
,
out
c
.
atk
);
{
int
.
TryParse
(
this
.
tb_atk
.
Text
,
out
c
.
atk
);
}
if
(
c
.
IsType
(
Core
.
Info
.
CardType
.
TYPE_LINK
))
if
(
c
.
IsType
(
Core
.
Info
.
CardType
.
TYPE_LINK
))
{
{
c
.
def
=
(
int
)
GetCheck
(
pl_markers
);
c
.
def
=
(
int
)
this
.
GetCheck
(
this
.
pl_markers
);
}
}
else
else
{
{
if
(
tb_def
.
Text
==
"?"
||
tb_def
.
Text
==
"?"
)
if
(
this
.
tb_def
.
Text
==
"?"
||
this
.
tb_def
.
Text
==
"?"
)
{
c
.
def
=
-
2
;
c
.
def
=
-
2
;
else
if
(
tb_def
.
Text
==
"."
)
}
else
if
(
this
.
tb_def
.
Text
==
"."
)
{
c
.
def
=
-
1
;
c
.
def
=
-
1
;
}
else
else
int
.
TryParse
(
tb_def
.
Text
,
out
c
.
def
);
{
int
.
TryParse
(
this
.
tb_def
.
Text
,
out
c
.
def
);
}
}
}
long
.
TryParse
(
tb_cardcode
.
Text
,
out
c
.
id
);
long
.
TryParse
(
t
his
.
t
b_cardcode
.
Text
,
out
c
.
id
);
long
.
TryParse
(
tb_cardalias
.
Text
,
out
c
.
alias
);
long
.
TryParse
(
t
his
.
t
b_cardalias
.
Text
,
out
c
.
alias
);
return
c
;
return
c
;
}
}
...
@@ -648,14 +806,14 @@ public Card GetCard()
...
@@ -648,14 +806,14 @@ public Card GetCard()
//列表选择
//列表选择
void
Lv_cardlistSelectedIndexChanged
(
object
sender
,
EventArgs
e
)
void
Lv_cardlistSelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
{
if
(
lv_cardlist
.
SelectedItems
.
Count
>
0
)
if
(
this
.
lv_cardlist
.
SelectedItems
.
Count
>
0
)
{
{
int
sel
=
lv_cardlist
.
SelectedItems
[
0
].
Index
;
int
sel
=
this
.
lv_cardlist
.
SelectedItems
[
0
].
Index
;
int
index
=
(
page
-
1
)
*
M
axRow
+
sel
;
int
index
=
(
this
.
page
-
1
)
*
this
.
m
axRow
+
sel
;
if
(
index
<
cardlist
.
Count
)
if
(
index
<
this
.
cardlist
.
Count
)
{
{
Card
c
=
cardlist
[
index
];
Card
c
=
this
.
cardlist
[
index
];
SetCard
(
c
);
this
.
SetCard
(
c
);
}
}
}
}
}
}
...
@@ -665,41 +823,48 @@ void Lv_cardlistKeyDown(object sender, KeyEventArgs e)
...
@@ -665,41 +823,48 @@ void Lv_cardlistKeyDown(object sender, KeyEventArgs e)
switch
(
e
.
KeyCode
)
switch
(
e
.
KeyCode
)
{
{
case
Keys
.
Delete
:
case
Keys
.
Delete
:
cmdManager
.
ExcuteCommand
(
cardedit
.
delCard
,
menuitem_operacardsfile
.
Checked
);
this
.
cmdManager
.
ExcuteCommand
(
this
.
cardedit
.
delCard
,
this
.
menuitem_operacardsfile
.
Checked
);
break
;
break
;
case
Keys
.
Right
:
case
Keys
.
Right
:
Btn_PageDownClick
(
null
,
null
);
this
.
Btn_PageDownClick
(
null
,
null
);
break
;
break
;
case
Keys
.
Left
:
case
Keys
.
Left
:
Btn_PageUpClick
(
null
,
null
);
this
.
Btn_PageUpClick
(
null
,
null
);
break
;
break
;
}
}
}
}
//上一页
//上一页
void
Btn_PageUpClick
(
object
sender
,
EventArgs
e
)
void
Btn_PageUpClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
page
--;
}
AddListView
(
page
);
this
.
page
--;
this
.
AddListView
(
this
.
page
);
}
}
//下一页
//下一页
void
Btn_PageDownClick
(
object
sender
,
EventArgs
e
)
void
Btn_PageDownClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
page
++;
}
AddListView
(
page
);
this
.
page
++;
this
.
AddListView
(
this
.
page
);
}
}
//跳转到指定页数
//跳转到指定页数
void
Tb_pageKeyPress
(
object
sender
,
KeyPressEventArgs
e
)
void
Tb_pageKeyPress
(
object
sender
,
KeyPressEventArgs
e
)
{
{
if
(
e
.
KeyChar
==
(
char
)
Keys
.
Enter
)
if
(
e
.
KeyChar
==
(
char
)
Keys
.
Enter
)
{
{
int
p
;
int
.
TryParse
(
this
.
tb_page
.
Text
,
out
int
p
);
int
.
TryParse
(
tb_page
.
Text
,
out
p
);
if
(
p
>
0
)
if
(
p
>
0
)
AddListView
(
p
);
{
this
.
AddListView
(
p
);
}
}
}
}
}
#
endregion
#
endregion
...
@@ -708,30 +873,31 @@ void Tb_pageKeyPress(object sender, KeyPressEventArgs e)
...
@@ -708,30 +873,31 @@ void Tb_pageKeyPress(object sender, KeyPressEventArgs e)
//检查是否打开数据库
//检查是否打开数据库
public
bool
CheckOpen
()
public
bool
CheckOpen
()
{
{
if
(
File
.
Exists
(
nowCdbFile
))
if
(
File
.
Exists
(
this
.
nowCdbFile
))
{
return
true
;
return
true
;
}
else
else
{
{
MyMsg
.
Warning
(
LMSG
.
NotSelectDataBase
);
return
false
;
return
false
;
}
}
}
}
//打开数据库
//打开数据库
public
bool
Open
(
string
file
)
public
bool
Open
(
string
file
)
{
{
SetCDB
(
file
);
this
.
SetCDB
(
file
);
if
(!
File
.
Exists
(
file
))
if
(!
File
.
Exists
(
file
))
{
{
MyMsg
.
Error
(
LMSG
.
FileIsNotExists
);
MyMsg
.
Error
(
LMSG
.
FileIsNotExists
);
return
false
;
return
false
;
}
}
//清空
//清空
tmpCodes
.
Clear
();
t
his
.
t
mpCodes
.
Clear
();
cardlist
.
Clear
();
this
.
cardlist
.
Clear
();
//检查表是否存在
//检查表是否存在
DataBase
.
CheckTable
(
file
);
DataBase
.
CheckTable
(
file
);
srcCard
=
new
Card
();
this
.
srcCard
=
new
Card
();
SetCards
(
DataBase
.
Read
(
file
,
true
,
""
),
false
);
this
.
SetCards
(
DataBase
.
Read
(
file
,
true
,
""
),
false
);
return
true
;
return
true
;
}
}
...
@@ -740,7 +906,10 @@ public bool CardFilter(Card c, Card sc)
...
@@ -740,7 +906,10 @@ public bool CardFilter(Card c, Card sc)
{
{
bool
res
=
true
;
bool
res
=
true
;
if
(
sc
.
setcode
!=
0
)
if
(
sc
.
setcode
!=
0
)
{
res
&=
c
.
IsSetCode
(
sc
.
setcode
&
0xffff
);
res
&=
c
.
IsSetCode
(
sc
.
setcode
&
0xffff
);
}
return
res
;
return
res
;
}
}
//设置卡片列表的结果
//设置卡片列表的结果
...
@@ -748,70 +917,83 @@ public void SetCards(Card[] cards, bool isfresh)
...
@@ -748,70 +917,83 @@ public void SetCards(Card[] cards, bool isfresh)
{
{
if
(
cards
!=
null
)
if
(
cards
!=
null
)
{
{
cardlist
.
Clear
();
this
.
cardlist
.
Clear
();
foreach
(
Card
c
in
cards
)
foreach
(
Card
c
in
cards
)
{
{
if
(
CardFilter
(
c
,
srcCard
))
if
(
this
.
CardFilter
(
c
,
this
.
srcCard
))
cardlist
.
Add
(
c
);
{
this
.
cardlist
.
Add
(
c
);
}
}
this
.
cardcount
=
this
.
cardlist
.
Count
;
this
.
pageNum
=
this
.
cardcount
/
this
.
maxRow
;
if
(
this
.
cardcount
%
this
.
maxRow
>
0
)
{
this
.
pageNum
++;
}
}
cardcount
=
cardlist
.
Count
;
else
if
(
this
.
cardcount
==
0
)
pageNum
=
cardcount
/
MaxRow
;
{
if
(
cardcount
%
MaxRow
>
0
)
this
.
pageNum
=
1
;
pageNum
++;
}
else
if
(
cardcount
==
0
)
pageNum
=
1
;
this
.
tb_pagenum
.
Text
=
this
.
pageNum
.
ToString
();
tb_pagenum
.
Text
=
pageNum
.
ToString
();
if
(
isfresh
)
//是否跳到之前页数
if
(
isfresh
)
//是否跳到之前页数
AddListView
(
page
);
{
this
.
AddListView
(
this
.
page
);
}
else
else
AddListView
(
1
);
{
this
.
AddListView
(
1
);
}
}
}
else
else
{
//结果为空
{
//结果为空
cardcount
=
0
;
this
.
cardcount
=
0
;
page
=
1
;
this
.
page
=
1
;
pageNum
=
1
;
this
.
pageNum
=
1
;
t
b_page
.
Text
=
page
.
ToString
();
t
his
.
tb_page
.
Text
=
this
.
page
.
ToString
();
t
b_pagenum
.
Text
=
pageNum
.
ToString
();
t
his
.
tb_pagenum
.
Text
=
this
.
pageNum
.
ToString
();
cardlist
.
Clear
();
this
.
cardlist
.
Clear
();
lv_cardlist
.
Items
.
Clear
();
this
.
lv_cardlist
.
Items
.
Clear
();
//SetCard(new Card(0));
//SetCard(new Card(0));
}
}
}
}
//搜索卡片
//搜索卡片
public
void
Search
(
bool
isfresh
)
public
void
Search
(
bool
isfresh
)
{
{
Search
(
srcCard
,
isfresh
);
this
.
Search
(
this
.
srcCard
,
isfresh
);
}
}
void
Search
(
Card
c
,
bool
isfresh
)
void
Search
(
Card
c
,
bool
isfresh
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
}
//如果临时卡片不为空,则更新,这个在搜索的时候清空
//如果临时卡片不为空,则更新,这个在搜索的时候清空
if
(
tmpCodes
.
Count
>
0
)
if
(
t
his
.
t
mpCodes
.
Count
>
0
)
{
{
Card
[]
mcards
=
DataBase
.
Read
(
nowCdbFile
,
_
=
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
tmpCodes
.
ToArray
());
true
,
this
.
tmpCodes
.
ToArray
());
SetCards
(
getCompCards
(),
true
);
this
.
SetCards
(
this
.
getCompCards
(),
true
);
}
}
else
else
{
{
srcCard
=
c
;
this
.
srcCard
=
c
;
string
sql
=
DataBase
.
GetSelectSQL
(
c
);
string
sql
=
DataBase
.
GetSelectSQL
(
c
);
SetCards
(
DataBase
.
Read
(
nowCdbFile
,
true
,
sql
),
isfresh
);
this
.
SetCards
(
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
sql
),
isfresh
);
}
}
if
(
lv_cardlist
.
Items
.
Count
>
0
)
if
(
this
.
lv_cardlist
.
Items
.
Count
>
0
)
{
{
lv_cardlist
.
SelectedIndices
.
Clear
();
this
.
lv_cardlist
.
SelectedIndices
.
Clear
();
lv_cardlist
.
SelectedIndices
.
Add
(
0
);
this
.
lv_cardlist
.
SelectedIndices
.
Add
(
0
);
}
}
}
}
//更新临时卡片
//更新临时卡片
public
void
Reset
()
public
void
Reset
()
{
{
oldCard
=
new
Card
(
0
);
this
.
oldCard
=
new
Card
(
0
);
SetCard
(
oldCard
);
this
.
SetCard
(
this
.
oldCard
);
}
}
#
endregion
#
endregion
...
@@ -819,51 +1001,59 @@ public void Reset()
...
@@ -819,51 +1001,59 @@ public void Reset()
//搜索卡片
//搜索卡片
void
Btn_serachClick
(
object
sender
,
EventArgs
e
)
void
Btn_serachClick
(
object
sender
,
EventArgs
e
)
{
{
tmpCodes
.
Clear
();
//清空临时的结果
t
his
.
t
mpCodes
.
Clear
();
//清空临时的结果
Search
(
GetCard
(),
false
);
this
.
Search
(
this
.
GetCard
(),
false
);
}
}
//重置卡片
//重置卡片
void
Btn_resetClick
(
object
sender
,
EventArgs
e
)
void
Btn_resetClick
(
object
sender
,
EventArgs
e
)
{
{
Reset
();
this
.
Reset
();
}
}
//添加
//添加
void
Btn_addClick
(
object
sender
,
EventArgs
e
)
void
Btn_addClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
cardedit
!=
null
)
if
(
this
.
cardedit
!=
null
)
cmdManager
.
ExcuteCommand
(
cardedit
.
addCard
);
{
this
.
cmdManager
.
ExcuteCommand
(
this
.
cardedit
.
addCard
);
}
}
}
//修改
//修改
void
Btn_modClick
(
object
sender
,
EventArgs
e
)
void
Btn_modClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
cardedit
!=
null
)
if
(
this
.
cardedit
!=
null
)
cmdManager
.
ExcuteCommand
(
cardedit
.
modCard
,
menuitem_operacardsfile
.
Checked
);
{
this
.
cmdManager
.
ExcuteCommand
(
this
.
cardedit
.
modCard
,
this
.
menuitem_operacardsfile
.
Checked
);
}
}
}
//打开脚本
//打开脚本
void
Btn_luaClick
(
object
sender
,
EventArgs
e
)
void
Btn_luaClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
cardedit
!=
null
)
if
(
this
.
cardedit
!=
null
)
cardedit
.
OpenScript
(
menuitem_openfileinthis
.
Checked
,
addrequire
);
{
this
.
cardedit
.
OpenScript
(
this
.
menuitem_openfileinthis
.
Checked
,
this
.
Addrequire
);
}
}
}
//删除
//删除
void
Btn_delClick
(
object
sender
,
EventArgs
e
)
void
Btn_delClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
cardedit
!=
null
)
if
(
this
.
cardedit
!=
null
)
cmdManager
.
ExcuteCommand
(
cardedit
.
delCard
,
menuitem_operacardsfile
.
Checked
);
{
this
.
cmdManager
.
ExcuteCommand
(
this
.
cardedit
.
delCard
,
this
.
menuitem_operacardsfile
.
Checked
);
}
}
}
//撤销
//撤销
void
Btn_undoClick
(
object
sender
,
EventArgs
e
)
void
Btn_undoClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
cardedit
!=
null
)
if
(
this
.
cardedit
!=
null
)
{
{
cmdManager
.
Undo
();
this
.
cmdManager
.
Undo
();
Search
(
true
);
this
.
Search
(
true
);
}
}
}
}
//导入卡图
//导入卡图
void
Btn_imgClick
(
object
sender
,
EventArgs
e
)
void
Btn_imgClick
(
object
sender
,
EventArgs
e
)
{
{
ImportImageFromSelect
();
this
.
ImportImageFromSelect
();
}
}
#
endregion
#
endregion
...
@@ -874,11 +1064,11 @@ void Tb_cardcodeKeyPress(object sender, KeyPressEventArgs e)
...
@@ -874,11 +1064,11 @@ void Tb_cardcodeKeyPress(object sender, KeyPressEventArgs e)
if
(
e
.
KeyChar
==
(
char
)
Keys
.
Enter
)
if
(
e
.
KeyChar
==
(
char
)
Keys
.
Enter
)
{
{
Card
c
=
new
Card
(
0
);
Card
c
=
new
Card
(
0
);
long
.
TryParse
(
tb_cardcode
.
Text
,
out
c
.
id
);
long
.
TryParse
(
t
his
.
t
b_cardcode
.
Text
,
out
c
.
id
);
if
(
c
.
id
>
0
)
if
(
c
.
id
>
0
)
{
{
tmpCodes
.
Clear
();
//清空临时的结果
t
his
.
t
mpCodes
.
Clear
();
//清空临时的结果
Search
(
c
,
false
);
this
.
Search
(
c
,
false
);
}
}
}
}
}
}
...
@@ -887,26 +1077,28 @@ void Tb_cardnameKeyDown(object sender, KeyEventArgs e)
...
@@ -887,26 +1077,28 @@ void Tb_cardnameKeyDown(object sender, KeyEventArgs e)
{
{
if
(
e
.
KeyCode
==
Keys
.
Enter
)
if
(
e
.
KeyCode
==
Keys
.
Enter
)
{
{
Card
c
=
new
Card
(
0
);
Card
c
=
new
Card
(
0
)
c
.
name
=
tb_cardname
.
Text
;
{
name
=
this
.
tb_cardname
.
Text
};
if
(
c
.
name
.
Length
>
0
)
if
(
c
.
name
.
Length
>
0
)
{
{
tmpCodes
.
Clear
();
//清空临时的结果
t
his
.
t
mpCodes
.
Clear
();
//清空临时的结果
Search
(
c
,
false
);
this
.
Search
(
c
,
false
);
}
}
}
}
if
(
e
.
KeyCode
==
Keys
.
R
&&
e
.
Control
)
if
(
e
.
KeyCode
==
Keys
.
R
&&
e
.
Control
)
{
{
Btn_resetClick
(
null
,
null
);
this
.
Btn_resetClick
(
null
,
null
);
}
}
}
}
//卡片描述编辑
//卡片描述编辑
void
Setscripttext
(
string
str
)
void
Setscripttext
(
string
str
)
{
{
int
index
=
-
1
;
int
index
;
try
try
{
{
index
=
lb_scripttext
.
SelectedIndex
;
index
=
this
.
lb_scripttext
.
SelectedIndex
;
}
}
catch
catch
{
{
...
@@ -915,20 +1107,20 @@ void Setscripttext(string str)
...
@@ -915,20 +1107,20 @@ void Setscripttext(string str)
}
}
if
(
index
>=
0
)
if
(
index
>=
0
)
{
{
strs
[
index
]
=
str
;
this
.
strs
[
index
]
=
str
;
lb_scripttext
.
Items
.
Clear
();
this
.
lb_scripttext
.
Items
.
Clear
();
lb_scripttext
.
Items
.
AddRange
(
strs
);
this
.
lb_scripttext
.
Items
.
AddRange
(
this
.
strs
);
lb_scripttext
.
SelectedIndex
=
index
;
this
.
lb_scripttext
.
SelectedIndex
=
index
;
}
}
}
}
string
Getscripttext
()
string
Getscripttext
()
{
{
int
index
=
-
1
;
int
index
;
try
try
{
{
index
=
lb_scripttext
.
SelectedIndex
;
index
=
this
.
lb_scripttext
.
SelectedIndex
;
}
}
catch
catch
{
{
...
@@ -936,20 +1128,24 @@ string Getscripttext()
...
@@ -936,20 +1128,24 @@ string Getscripttext()
MyMsg
.
Error
(
LMSG
.
NotSelectScriptText
);
MyMsg
.
Error
(
LMSG
.
NotSelectScriptText
);
}
}
if
(
index
>=
0
)
if
(
index
>=
0
)
return
strs
[
index
];
{
return
this
.
strs
[
index
];
}
else
else
{
return
""
;
return
""
;
}
}
}
//脚本文本
//脚本文本
void
Lb_scripttextSelectedIndexChanged
(
object
sender
,
EventArgs
e
)
void
Lb_scripttextSelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
{
t
b_edittext
.
Text
=
Getscripttext
();
t
his
.
tb_edittext
.
Text
=
this
.
Getscripttext
();
}
}
//脚本文本
//脚本文本
void
Tb_edittextTextChanged
(
object
sender
,
EventArgs
e
)
void
Tb_edittextTextChanged
(
object
sender
,
EventArgs
e
)
{
{
Setscripttext
(
tb_edittext
.
Text
);
this
.
Setscripttext
(
this
.
tb_edittext
.
Text
);
}
}
#
endregion
#
endregion
...
@@ -964,35 +1160,40 @@ void Menuitem_aboutClick(object sender, EventArgs e)
...
@@ -964,35 +1160,40 @@ void Menuitem_aboutClick(object sender, EventArgs e)
void
Menuitem_checkupdateClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_checkupdateClick
(
object
sender
,
EventArgs
e
)
{
{
CheckUpdate
(
true
);
this
.
CheckUpdate
(
true
);
}
}
public
void
CheckUpdate
(
bool
showNew
)
public
void
CheckUpdate
(
bool
showNew
)
{
{
if
(!
isRun
())
if
(!
this
.
isRun
())
{
{
tasker
.
SetTask
(
MyTask
.
CheckUpdate
,
null
,
showNew
.
ToString
());
t
his
.
t
asker
.
SetTask
(
MyTask
.
CheckUpdate
,
null
,
showNew
.
ToString
());
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
checkUpdate
));
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
checkUpdate
));
}
}
}
}
bool
CancelTask
()
bool
CancelTask
()
{
{
bool
bl
=
false
;
bool
bl
=
false
;
if
(
t
asker
!=
null
&&
tasker
.
IsRuning
())
if
(
t
his
.
tasker
!=
null
&&
this
.
tasker
.
IsRuning
())
{
{
bl
=
MyMsg
.
Question
(
LMSG
.
IfCancelTask
);
bl
=
MyMsg
.
Question
(
LMSG
.
IfCancelTask
);
if
(
bl
)
if
(
bl
)
{
{
if
(
tasker
!=
null
)
if
(
this
.
tasker
!=
null
)
tasker
.
Cancel
();
{
if
(
bgWorker1
.
IsBusy
)
this
.
tasker
.
Cancel
();
bgWorker1
.
CancelAsync
();
}
if
(
this
.
bgWorker1
.
IsBusy
)
{
this
.
bgWorker1
.
CancelAsync
();
}
}
}
}
}
return
bl
;
return
bl
;
}
}
void
Menuitem_cancelTaskClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_cancelTaskClick
(
object
sender
,
EventArgs
e
)
{
{
CancelTask
();
this
.
CancelTask
();
}
}
void
Menuitem_githubClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_githubClick
(
object
sender
,
EventArgs
e
)
{
{
...
@@ -1010,7 +1211,7 @@ void Menuitem_openClick(object sender, EventArgs e)
...
@@ -1010,7 +1211,7 @@ void Menuitem_openClick(object sender, EventArgs e)
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
Open
(
dlg
.
FileName
);
this
.
Open
(
dlg
.
FileName
);
}
}
}
}
}
}
...
@@ -1026,7 +1227,9 @@ void Menuitem_newClick(object sender, EventArgs e)
...
@@ -1026,7 +1227,9 @@ void Menuitem_newClick(object sender, EventArgs e)
if
(
DataBase
.
Create
(
dlg
.
FileName
))
if
(
DataBase
.
Create
(
dlg
.
FileName
))
{
{
if
(
MyMsg
.
Question
(
LMSG
.
IfOpenDataBase
))
if
(
MyMsg
.
Question
(
LMSG
.
IfOpenDataBase
))
Open
(
dlg
.
FileName
);
{
this
.
Open
(
dlg
.
FileName
);
}
}
}
}
}
}
}
...
@@ -1034,18 +1237,21 @@ void Menuitem_newClick(object sender, EventArgs e)
...
@@ -1034,18 +1237,21 @@ void Menuitem_newClick(object sender, EventArgs e)
//读取ydk
//读取ydk
void
Menuitem_readydkClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_readydkClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
}
using
(
OpenFileDialog
dlg
=
new
OpenFileDialog
())
using
(
OpenFileDialog
dlg
=
new
OpenFileDialog
())
{
{
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectYdkPath
);
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectYdkPath
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ydkType
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ydkType
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
tmpCodes
.
Clear
();
t
his
.
t
mpCodes
.
Clear
();
string
[]
ids
=
YGOUtil
.
ReadYDK
(
dlg
.
FileName
);
string
[]
ids
=
YGOUtil
.
ReadYDK
(
dlg
.
FileName
);
tmpCodes
.
AddRange
(
ids
);
t
his
.
t
mpCodes
.
AddRange
(
ids
);
SetCards
(
DataBase
.
Read
(
nowCdbFile
,
true
,
this
.
SetCards
(
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
ids
),
false
);
ids
),
false
);
}
}
}
}
...
@@ -1053,17 +1259,20 @@ void Menuitem_readydkClick(object sender, EventArgs e)
...
@@ -1053,17 +1259,20 @@ void Menuitem_readydkClick(object sender, EventArgs e)
//从图片文件夹读取
//从图片文件夹读取
void
Menuitem_readimagesClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_readimagesClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
}
using
(
FolderBrowserDialog
fdlg
=
new
FolderBrowserDialog
())
using
(
FolderBrowserDialog
fdlg
=
new
FolderBrowserDialog
())
{
{
fdlg
.
Description
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectImagePath
);
fdlg
.
Description
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectImagePath
);
if
(
fdlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
fdlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
tmpCodes
.
Clear
();
t
his
.
t
mpCodes
.
Clear
();
string
[]
ids
=
YGOUtil
.
ReadImage
(
fdlg
.
SelectedPath
);
string
[]
ids
=
YGOUtil
.
ReadImage
(
fdlg
.
SelectedPath
);
tmpCodes
.
AddRange
(
ids
);
t
his
.
t
mpCodes
.
AddRange
(
ids
);
SetCards
(
DataBase
.
Read
(
nowCdbFile
,
true
,
this
.
SetCards
(
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
ids
),
false
);
ids
),
false
);
}
}
}
}
...
@@ -1079,7 +1288,7 @@ void Menuitem_quitClick(object sender, EventArgs e)
...
@@ -1079,7 +1288,7 @@ void Menuitem_quitClick(object sender, EventArgs e)
//是否在执行
//是否在执行
bool
isRun
()
bool
isRun
()
{
{
if
(
t
asker
!=
null
&&
tasker
.
IsRuning
())
if
(
t
his
.
tasker
!=
null
&&
this
.
tasker
.
IsRuning
())
{
{
MyMsg
.
Warning
(
LMSG
.
RunError
);
MyMsg
.
Warning
(
LMSG
.
RunError
);
return
true
;
return
true
;
...
@@ -1089,52 +1298,61 @@ bool isRun()
...
@@ -1089,52 +1298,61 @@ bool isRun()
//执行任务
//执行任务
void
Run
(
string
name
)
void
Run
(
string
name
)
{
{
if
(
isRun
())
if
(
this
.
isRun
())
{
return
;
return
;
taskname
=
name
;
}
title
=
title
+
" ("
+
taskname
+
")"
;
SetTitle
();
this
.
taskname
=
name
;
bgWorker1
.
RunWorkerAsync
();
this
.
title
=
this
.
title
+
" ("
+
this
.
taskname
+
")"
;
this
.
SetTitle
();
this
.
bgWorker1
.
RunWorkerAsync
();
}
}
//线程任务
//线程任务
void
BgWorker1DoWork
(
object
sender
,
System
.
ComponentModel
.
DoWorkEventArgs
e
)
void
BgWorker1DoWork
(
object
sender
,
System
.
ComponentModel
.
DoWorkEventArgs
e
)
{
{
tasker
.
Run
();
t
his
.
t
asker
.
Run
();
}
}
void
BgWorker1ProgressChanged
(
object
sender
,
System
.
ComponentModel
.
ProgressChangedEventArgs
e
)
void
BgWorker1ProgressChanged
(
object
sender
,
System
.
ComponentModel
.
ProgressChangedEventArgs
e
)
{
{
title
=
string
.
Format
(
"{0} ({1}-{2})"
,
t
his
.
t
itle
=
string
.
Format
(
"{0} ({1}-{2})"
,
RemoveTag
(
title
),
this
.
RemoveTag
(
this
.
title
),
taskname
,
this
.
taskname
,
// e.ProgressPercentage,
// e.ProgressPercentage,
e
.
UserState
);
e
.
UserState
);
SetTitle
();
this
.
SetTitle
();
}
}
//任务完成
//任务完成
void
BgWorker1RunWorkerCompleted
(
object
sender
,
System
.
ComponentModel
.
RunWorkerCompletedEventArgs
e
)
void
BgWorker1RunWorkerCompleted
(
object
sender
,
System
.
ComponentModel
.
RunWorkerCompletedEventArgs
e
)
{
{
//还原标题
//还原标题
int
t
=
title
.
LastIndexOf
(
" ("
);
int
t
=
t
his
.
t
itle
.
LastIndexOf
(
" ("
);
if
(
t
>
0
)
if
(
t
>
0
)
{
{
t
itle
=
title
.
Substring
(
0
,
t
);
t
his
.
title
=
this
.
title
.
Substring
(
0
,
t
);
SetTitle
();
this
.
SetTitle
();
}
}
if
(
e
.
Error
!=
null
)
if
(
e
.
Error
!=
null
)
{
//出错
{
//出错
if
(
tasker
!=
null
)
if
(
this
.
tasker
!=
null
)
tasker
.
Cancel
();
{
if
(
bgWorker1
.
IsBusy
)
this
.
tasker
.
Cancel
();
bgWorker1
.
CancelAsync
();
}
if
(
this
.
bgWorker1
.
IsBusy
)
{
this
.
bgWorker1
.
CancelAsync
();
}
MyMsg
.
Show
(
LanguageHelper
.
GetMsg
(
LMSG
.
TaskError
)
+
"\n"
+
e
.
Error
);
MyMsg
.
Show
(
LanguageHelper
.
GetMsg
(
LMSG
.
TaskError
)
+
"\n"
+
e
.
Error
);
}
}
else
if
(
tasker
.
IsCancel
()
||
e
.
Cancelled
)
else
if
(
t
his
.
t
asker
.
IsCancel
()
||
e
.
Cancelled
)
{
//取消任务
{
//取消任务
MyMsg
.
Show
(
LMSG
.
CancelTask
);
MyMsg
.
Show
(
LMSG
.
CancelTask
);
}
}
else
else
{
{
MyTask
mt
=
tasker
.
getLastTask
();
MyTask
mt
=
t
his
.
t
asker
.
getLastTask
();
switch
(
mt
)
switch
(
mt
)
{
{
case
MyTask
.
CheckUpdate
:
case
MyTask
.
CheckUpdate
:
...
@@ -1153,7 +1371,7 @@ void BgWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerC
...
@@ -1153,7 +1371,7 @@ void BgWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerC
break
;
break
;
case
MyTask
.
ReadMSE
:
case
MyTask
.
ReadMSE
:
//保存读取的卡片
//保存读取的卡片
SaveCards
(
tasker
.
CardList
);
this
.
SaveCards
(
this
.
tasker
.
CardList
);
MyMsg
.
Show
(
LMSG
.
ReadMSEisOK
);
MyMsg
.
Show
(
LMSG
.
ReadMSEisOK
);
break
;
break
;
}
}
...
@@ -1165,24 +1383,37 @@ void BgWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerC
...
@@ -1165,24 +1383,37 @@ void BgWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerC
//得到卡片列表,是否是选中的
//得到卡片列表,是否是选中的
public
Card
[]
GetCardList
(
bool
onlyselect
)
public
Card
[]
GetCardList
(
bool
onlyselect
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
null
;
return
null
;
}
List
<
Card
>
cards
=
new
List
<
Card
>();
List
<
Card
>
cards
=
new
List
<
Card
>();
if
(
onlyselect
)
if
(
onlyselect
)
{
{
foreach
(
ListViewItem
lvitem
in
lv_cardlist
.
SelectedItems
)
foreach
(
ListViewItem
lvitem
in
this
.
lv_cardlist
.
SelectedItems
)
{
{
int
index
;
int
index
;
if
(
lvitem
.
Tag
!=
null
)
if
(
lvitem
.
Tag
!=
null
)
{
index
=
(
int
)
lvitem
.
Tag
;
index
=
(
int
)
lvitem
.
Tag
;
}
else
else
index
=
lvitem
.
Index
+
(
page
-
1
)
*
MaxRow
;
{
if
(
index
>=
0
&&
index
<
cardlist
.
Count
)
index
=
lvitem
.
Index
+
(
this
.
page
-
1
)
*
this
.
maxRow
;
cards
.
Add
(
cardlist
[
index
]);
}
if
(
index
>=
0
&&
index
<
this
.
cardlist
.
Count
)
{
cards
.
Add
(
this
.
cardlist
[
index
]);
}
}
}
}
}
else
else
cards
.
AddRange
(
cardlist
.
ToArray
());
{
cards
.
AddRange
(
this
.
cardlist
.
ToArray
());
}
if
(
cards
.
Count
==
0
)
if
(
cards
.
Count
==
0
)
{
{
//MyMsg.Show(LMSG.NoSelectCard);
//MyMsg.Show(LMSG.NoSelectCard);
...
@@ -1191,28 +1422,36 @@ public Card[] GetCardList(bool onlyselect)
...
@@ -1191,28 +1422,36 @@ public Card[] GetCardList(bool onlyselect)
}
}
void
Menuitem_copytoClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_copytoClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
CopyTo
(
GetCardList
(
false
));
}
this
.
CopyTo
(
this
.
GetCardList
(
false
));
}
}
void
Menuitem_copyselecttoClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_copyselecttoClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
CopyTo
(
GetCardList
(
true
));
}
this
.
CopyTo
(
this
.
GetCardList
(
true
));
}
}
//保存卡片到当前数据库
//保存卡片到当前数据库
public
void
SaveCards
(
Card
[]
cards
)
public
void
SaveCards
(
Card
[]
cards
)
{
{
cmdManager
.
ExcuteCommand
(
cardedit
.
copyCard
,
cards
);
this
.
cmdManager
.
ExcuteCommand
(
this
.
cardedit
.
copyCard
,
cards
);
Search
(
srcCard
,
true
);
this
.
Search
(
this
.
srcCard
,
true
);
}
}
//卡片另存为
//卡片另存为
void
CopyTo
(
Card
[]
cards
)
void
CopyTo
(
Card
[]
cards
)
{
{
if
(
cards
==
null
||
cards
.
Length
==
0
)
if
(
cards
==
null
||
cards
.
Length
==
0
)
{
return
;
return
;
}
//select file
//select file
bool
replace
=
false
;
bool
replace
=
false
;
string
filename
=
null
;
string
filename
=
null
;
...
@@ -1239,35 +1478,49 @@ void CopyTo(Card[] cards)
...
@@ -1239,35 +1478,49 @@ void CopyTo(Card[] cards)
//裁剪图片
//裁剪图片
void
Menuitem_cutimagesClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_cutimagesClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
if
(
isRun
())
}
if
(
this
.
isRun
())
{
return
;
return
;
}
bool
isreplace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
bool
isreplace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
t
asker
.
SetTask
(
MyTask
.
CutImages
,
cardlist
.
ToArray
(),
t
his
.
tasker
.
SetTask
(
MyTask
.
CutImages
,
this
.
cardlist
.
ToArray
(),
ygopath
.
picpath
,
isreplace
.
ToString
());
this
.
ygopath
.
picpath
,
isreplace
.
ToString
());
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
CutImage
));
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
CutImage
));
}
}
void
Menuitem_saveasmse_selectClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_saveasmse_selectClick
(
object
sender
,
EventArgs
e
)
{
{
//选择
//选择
SaveAsMSE
(
true
);
this
.
SaveAsMSE
(
true
);
}
}
void
Menuitem_saveasmseClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_saveasmseClick
(
object
sender
,
EventArgs
e
)
{
{
//全部
//全部
SaveAsMSE
(
false
);
this
.
SaveAsMSE
(
false
);
}
}
void
SaveAsMSE
(
bool
onlyselect
)
void
SaveAsMSE
(
bool
onlyselect
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
if
(
isRun
())
}
if
(
this
.
isRun
())
{
return
;
return
;
Card
[]
cards
=
GetCardList
(
onlyselect
);
}
Card
[]
cards
=
this
.
GetCardList
(
onlyselect
);
if
(
cards
==
null
)
if
(
cards
==
null
)
{
return
;
return
;
}
//select save mse-set
//select save mse-set
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
{
{
...
@@ -1278,10 +1531,10 @@ void SaveAsMSE(bool onlyselect)
...
@@ -1278,10 +1531,10 @@ void SaveAsMSE(bool onlyselect)
bool
isUpdate
=
false
;
bool
isUpdate
=
false
;
#
if
DEBUG
#
if
DEBUG
isUpdate
=
MyMsg
.
Question
(
LMSG
.
OnlySet
);
isUpdate
=
MyMsg
.
Question
(
LMSG
.
OnlySet
);
#
endif
#endif
tasker
.
SetTask
(
MyTask
.
SaveAsMSE
,
cards
,
t
his
.
t
asker
.
SetTask
(
MyTask
.
SaveAsMSE
,
cards
,
dlg
.
FileName
,
isUpdate
.
ToString
());
dlg
.
FileName
,
isUpdate
.
ToString
());
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
SaveMse
));
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
SaveMse
));
}
}
}
}
}
}
...
@@ -1290,107 +1543,126 @@ void SaveAsMSE(bool onlyselect)
...
@@ -1290,107 +1543,126 @@ void SaveAsMSE(bool onlyselect)
#
region
导入卡图
#
region
导入卡图
void
ImportImageFromSelect
()
void
ImportImageFromSelect
()
{
{
string
tid
=
tb_cardcode
.
Text
;
string
tid
=
t
his
.
t
b_cardcode
.
Text
;
if
(
tid
==
"0"
||
tid
.
Length
==
0
)
if
(
tid
==
"0"
||
tid
.
Length
==
0
)
{
return
;
return
;
}
using
(
OpenFileDialog
dlg
=
new
OpenFileDialog
())
using
(
OpenFileDialog
dlg
=
new
OpenFileDialog
())
{
{
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectImage
)
+
"-"
+
tb_cardname
.
Text
;
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectImage
)
+
"-"
+
t
his
.
t
b_cardname
.
Text
;
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ImageType
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
ImageType
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
//dlg.FileName;
//dlg.FileName;
ImportImage
(
dlg
.
FileName
,
tid
);
this
.
ImportImage
(
dlg
.
FileName
,
tid
);
}
}
}
}
}
}
private
void
pl_image_DoubleClick
(
object
sender
,
EventArgs
e
)
private
void
pl_image_DoubleClick
(
object
sender
,
EventArgs
e
)
{
{
ImportImageFromSelect
();
this
.
ImportImageFromSelect
();
}
}
void
Pl_imageDragDrop
(
object
sender
,
DragEventArgs
e
)
void
Pl_imageDragDrop
(
object
sender
,
DragEventArgs
e
)
{
{
string
[]
files
=
e
.
Data
.
GetData
(
DataFormats
.
FileDrop
)
as
string
[];
string
[]
files
=
e
.
Data
.
GetData
(
DataFormats
.
FileDrop
)
as
string
[];
if
(
File
.
Exists
(
files
[
0
]))
if
(
File
.
Exists
(
files
[
0
]))
ImportImage
(
files
[
0
],
tb_cardcode
.
Text
);
{
this
.
ImportImage
(
files
[
0
],
this
.
tb_cardcode
.
Text
);
}
}
}
void
Pl_imageDragEnter
(
object
sender
,
DragEventArgs
e
)
void
Pl_imageDragEnter
(
object
sender
,
DragEventArgs
e
)
{
{
if
(
e
.
Data
.
GetDataPresent
(
DataFormats
.
FileDrop
))
if
(
e
.
Data
.
GetDataPresent
(
DataFormats
.
FileDrop
))
{
e
.
Effect
=
DragDropEffects
.
Link
;
//重要代码:表明是链接类型的数据,比如文件路径
e
.
Effect
=
DragDropEffects
.
Link
;
//重要代码:表明是链接类型的数据,比如文件路径
}
else
else
{
e
.
Effect
=
DragDropEffects
.
None
;
e
.
Effect
=
DragDropEffects
.
None
;
}
}
}
private
void
menuitem_importmseimg_Click
(
object
sender
,
EventArgs
e
)
private
void
menuitem_importmseimg_Click
(
object
sender
,
EventArgs
e
)
{
{
string
tid
=
tb_cardcode
.
Text
;
string
tid
=
t
his
.
t
b_cardcode
.
Text
;
menuitem_importmseimg
.
Checked
=
!
menuitem_importmseimg
.
Checked
;
this
.
menuitem_importmseimg
.
Checked
=
!
this
.
menuitem_importmseimg
.
Checked
;
SetImage
(
tid
);
this
.
SetImage
(
tid
);
}
}
void
ImportImage
(
string
file
,
string
tid
)
void
ImportImage
(
string
file
,
string
tid
)
{
{
string
f
;
string
f
;
if
(
pl_image
.
BackgroundImage
!=
null
if
(
this
.
pl_image
.
BackgroundImage
!=
null
&&
pl_image
.
BackgroundImage
!=
m_
cover
)
&&
this
.
pl_image
.
BackgroundImage
!=
this
.
cover
)
{
//释放图片资源
{
//释放图片资源
pl_image
.
BackgroundImage
.
Dispose
();
this
.
pl_image
.
BackgroundImage
.
Dispose
();
pl_image
.
BackgroundImage
=
m_
cover
;
this
.
pl_image
.
BackgroundImage
=
this
.
cover
;
}
}
if
(
menuitem_importmseimg
.
Checked
)
if
(
this
.
menuitem_importmseimg
.
Checked
)
{
{
if
(!
Directory
.
Exists
(
tasker
.
MSEImagePath
))
if
(!
Directory
.
Exists
(
this
.
tasker
.
MSEImagePath
))
Directory
.
CreateDirectory
(
tasker
.
MSEImagePath
);
{
f
=
MyPath
.
Combine
(
tasker
.
MSEImagePath
,
tid
+
".jpg"
);
Directory
.
CreateDirectory
(
this
.
tasker
.
MSEImagePath
);
}
f
=
MyPath
.
Combine
(
this
.
tasker
.
MSEImagePath
,
tid
+
".jpg"
);
File
.
Copy
(
file
,
f
,
true
);
File
.
Copy
(
file
,
f
,
true
);
}
}
else
else
{
{
// tasker.ToImg(file, ygopath.GetImage(tid),
// tasker.ToImg(file, ygopath.GetImage(tid),
// ygopath.GetImageThum(tid));
// ygopath.GetImageThum(tid));
t
asker
.
ToImg
(
file
,
ygopath
.
GetImage
(
tid
));
t
his
.
tasker
.
ToImg
(
file
,
this
.
ygopath
.
GetImage
(
tid
));
}
}
SetImage
(
tid
);
this
.
SetImage
(
tid
);
}
}
public
void
SetImage
(
string
id
)
public
void
SetImage
(
string
id
)
{
{
long
t
;
long
.
TryParse
(
id
,
out
long
t
);
long
.
TryParse
(
id
,
out
t
);
this
.
SetImage
(
t
);
SetImage
(
t
);
}
}
public
void
SetImage
(
long
id
)
public
void
SetImage
(
long
id
)
{
{
string
pic
=
ygopath
.
GetImage
(
id
);
string
pic
=
this
.
ygopath
.
GetImage
(
id
);
if
(
menuitem_importmseimg
.
Checked
)
//显示MSE图片
if
(
this
.
menuitem_importmseimg
.
Checked
)
//显示MSE图片
{
{
string
msepic
=
MseMaker
.
GetCardImagePath
(
t
asker
.
MSEImagePath
,
oldCard
);
string
msepic
=
MseMaker
.
GetCardImagePath
(
t
his
.
tasker
.
MSEImagePath
,
this
.
oldCard
);
if
(
File
.
Exists
(
msepic
))
if
(
File
.
Exists
(
msepic
))
{
{
pl_image
.
BackgroundImage
=
MyBitmap
.
readImage
(
msepic
);
this
.
pl_image
.
BackgroundImage
=
MyBitmap
.
readImage
(
msepic
);
}
}
}
}
else
if
(
File
.
Exists
(
pic
))
else
if
(
File
.
Exists
(
pic
))
{
{
pl_image
.
BackgroundImage
=
MyBitmap
.
readImage
(
pic
);
this
.
pl_image
.
BackgroundImage
=
MyBitmap
.
readImage
(
pic
);
}
}
else
else
pl_image
.
BackgroundImage
=
m_cover
;
{
this
.
pl_image
.
BackgroundImage
=
this
.
cover
;
}
}
}
void
Menuitem_convertimageClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_convertimageClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
if
(
isRun
())
}
if
(
this
.
isRun
())
{
return
;
return
;
}
using
(
FolderBrowserDialog
fdlg
=
new
FolderBrowserDialog
())
using
(
FolderBrowserDialog
fdlg
=
new
FolderBrowserDialog
())
{
{
fdlg
.
Description
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectImagePath
);
fdlg
.
Description
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectImagePath
);
if
(
fdlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
fdlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
bool
isreplace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
bool
isreplace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
tasker
.
SetTask
(
MyTask
.
ConvertImages
,
null
,
t
his
.
t
asker
.
SetTask
(
MyTask
.
ConvertImages
,
null
,
fdlg
.
SelectedPath
,
ygopath
.
gamepath
,
isreplace
.
ToString
());
fdlg
.
SelectedPath
,
this
.
ygopath
.
gamepath
,
isreplace
.
ToString
());
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ConvertImage
));
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ConvertImage
));
}
}
}
}
}
}
...
@@ -1399,23 +1671,29 @@ void Menuitem_convertimageClick(object sender, EventArgs e)
...
@@ -1399,23 +1671,29 @@ void Menuitem_convertimageClick(object sender, EventArgs e)
#
region
导出数据包
#
region
导出数据包
void
Menuitem_exportdataClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_exportdataClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
if
(
isRun
())
}
if
(
this
.
isRun
())
{
return
;
return
;
}
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
{
{
dlg
.
InitialDirectory
=
ygopath
.
gamepath
;
dlg
.
InitialDirectory
=
this
.
ygopath
.
gamepath
;
dlg
.
Filter
=
"Zip|(*.zip|All Files(*.*)|*.*"
;
dlg
.
Filter
=
"Zip|(*.zip|All Files(*.*)|*.*"
;
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
tasker
.
SetTask
(
MyTask
.
ExportData
,
t
his
.
t
asker
.
SetTask
(
MyTask
.
ExportData
,
GetCardList
(
false
),
this
.
GetCardList
(
false
),
ygopath
.
gamepath
,
this
.
ygopath
.
gamepath
,
dlg
.
FileName
,
dlg
.
FileName
,
GetOpenFile
(),
this
.
GetOpenFile
(),
a
ddrequire
);
this
.
A
ddrequire
);
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ExportData
));
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ExportData
));
}
}
}
}
...
@@ -1431,43 +1709,60 @@ bool CheckCard(Card[] cards, Card card, bool checkinfo)
...
@@ -1431,43 +1709,60 @@ bool CheckCard(Card[] cards, Card card, bool checkinfo)
foreach
(
Card
c
in
cards
)
foreach
(
Card
c
in
cards
)
{
{
if
(
c
.
id
!=
card
.
id
)
if
(
c
.
id
!=
card
.
id
)
{
continue
;
continue
;
}
//data数据不一样
//data数据不一样
if
(
checkinfo
)
if
(
checkinfo
)
{
return
card
.
EqualsData
(
c
);
return
card
.
EqualsData
(
c
);
}
else
else
{
return
true
;
return
true
;
}
}
}
return
false
;
return
false
;
}
}
//读取将要对比的数据
//读取将要对比的数据
Card
[]
getCompCards
()
Card
[]
getCompCards
()
{
{
if
(
tmpCodes
.
Count
==
0
)
if
(
this
.
tmpCodes
.
Count
==
0
)
{
return
null
;
return
null
;
if
(!
CheckOpen
())
}
if
(!
this
.
CheckOpen
())
{
return
null
;
return
null
;
return
DataBase
.
Read
(
nowCdbFile
,
true
,
tmpCodes
.
ToArray
());
}
return
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
this
.
tmpCodes
.
ToArray
());
}
}
public
void
CompareCards
(
string
cdbfile
,
bool
checktext
)
public
void
CompareCards
(
string
cdbfile
,
bool
checktext
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
tmpCodes
.
Clear
();
}
srcCard
=
new
Card
();
Card
[]
mcards
=
DataBase
.
Read
(
nowCdbFile
,
true
,
""
);
this
.
tmpCodes
.
Clear
();
this
.
srcCard
=
new
Card
();
Card
[]
mcards
=
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
""
);
Card
[]
cards
=
DataBase
.
Read
(
cdbfile
,
true
,
""
);
Card
[]
cards
=
DataBase
.
Read
(
cdbfile
,
true
,
""
);
foreach
(
Card
card
in
mcards
)
foreach
(
Card
card
in
mcards
)
{
{
if
(!
CheckCard
(
cards
,
card
,
checktext
))
//添加到id集合
if
(!
this
.
CheckCard
(
cards
,
card
,
checktext
))
//添加到id集合
tmpCodes
.
Add
(
card
.
id
.
ToString
());
{
this
.
tmpCodes
.
Add
(
card
.
id
.
ToString
());
}
}
}
if
(
tmpCodes
.
Count
==
0
)
if
(
t
his
.
t
mpCodes
.
Count
==
0
)
{
{
SetCards
(
null
,
false
);
this
.
SetCards
(
null
,
false
);
return
;
return
;
}
}
SetCards
(
getCompCards
(),
false
);
this
.
SetCards
(
this
.
getCompCards
(),
false
);
}
}
#
endregion
#
endregion
...
@@ -1475,36 +1770,48 @@ public void CompareCards(string cdbfile, bool checktext)
...
@@ -1475,36 +1770,48 @@ public void CompareCards(string cdbfile, bool checktext)
//把文件添加到菜单
//把文件添加到菜单
void
AddMenuItemFormMSE
()
void
AddMenuItemFormMSE
()
{
{
if
(!
Directory
.
Exists
(
datapath
))
if
(!
Directory
.
Exists
(
this
.
datapath
))
{
return
;
return
;
menuitem_mseconfig
.
DropDownItems
.
Clear
();
//清空
}
string
[]
files
=
Directory
.
GetFiles
(
datapath
);
this
.
menuitem_mseconfig
.
DropDownItems
.
Clear
();
//清空
string
[]
files
=
Directory
.
GetFiles
(
this
.
datapath
);
foreach
(
string
file
in
files
)
foreach
(
string
file
in
files
)
{
{
string
name
=
MyPath
.
getFullFileName
(
MSEConfig
.
TAG
,
file
);
string
name
=
MyPath
.
getFullFileName
(
MSEConfig
.
TAG
,
file
);
//是否是MSE配置文件
//是否是MSE配置文件
if
(
string
.
IsNullOrEmpty
(
name
))
if
(
string
.
IsNullOrEmpty
(
name
))
{
continue
;
continue
;
}
//菜单文字是语言
//菜单文字是语言
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
name
);
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
name
)
tsmi
.
ToolTipText
=
file
;
//提示文字为真实路径
{
tsmi
.
Click
+=
SetMseConfig_Click
;
ToolTipText
=
file
//提示文字为真实路径
if
(
msecfg
.
configName
.
Equals
(
name
,
StringComparison
.
OrdinalIgnoreCase
))
};
tsmi
.
Click
+=
this
.
SetMseConfig_Click
;
if
(
this
.
msecfg
.
configName
.
Equals
(
name
,
StringComparison
.
OrdinalIgnoreCase
))
{
tsmi
.
Checked
=
true
;
//如果是当前,则打勾
tsmi
.
Checked
=
true
;
//如果是当前,则打勾
menuitem_mseconfig
.
DropDownItems
.
Add
(
tsmi
);
}
this
.
menuitem_mseconfig
.
DropDownItems
.
Add
(
tsmi
);
}
}
}
}
void
SetMseConfig_Click
(
object
sender
,
EventArgs
e
)
void
SetMseConfig_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(
isRun
())
//正在执行任务
if
(
this
.
isRun
())
//正在执行任务
{
return
;
return
;
if
(
sender
is
ToolStripMenuItem
)
}
if
(
sender
is
ToolStripMenuItem
tsmi
)
{
{
ToolStripMenuItem
tsmi
=
(
ToolStripMenuItem
)
sender
;
//读取新的配置
//读取新的配置
msecfg
.
SetConfig
(
tsmi
.
ToolTipText
,
datapath
);
this
.
msecfg
.
SetConfig
(
tsmi
.
ToolTipText
,
this
.
datapath
);
//刷新菜单
//刷新菜单
AddMenuItemFormMSE
();
this
.
AddMenuItemFormMSE
();
//保存配置
//保存配置
MyConfig
.
Save
(
MyConfig
.
TAG_MSE
,
tsmi
.
Text
);
MyConfig
.
Save
(
MyConfig
.
TAG_MSE
,
tsmi
.
Text
);
}
}
...
@@ -1514,7 +1821,7 @@ void SetMseConfig_Click(object sender, EventArgs e)
...
@@ -1514,7 +1821,7 @@ void SetMseConfig_Click(object sender, EventArgs e)
#
region
查找
lua
函数
#
region
查找
lua
函数
private
void
menuitem_findluafunc_Click
(
object
sender
,
EventArgs
e
)
private
void
menuitem_findluafunc_Click
(
object
sender
,
EventArgs
e
)
{
{
string
funtxt
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_FUNCTION
);
string
funtxt
=
MyPath
.
Combine
(
this
.
datapath
,
MyConfig
.
FILE_FUNCTION
);
using
(
FolderBrowserDialog
fd
=
new
FolderBrowserDialog
())
using
(
FolderBrowserDialog
fd
=
new
FolderBrowserDialog
())
{
{
fd
.
Description
=
"Folder Name: ocgcore"
;
fd
.
Description
=
"Folder Name: ocgcore"
;
...
@@ -1533,38 +1840,43 @@ private void menuitem_findluafunc_Click(object sender, EventArgs e)
...
@@ -1533,38 +1840,43 @@ private void menuitem_findluafunc_Click(object sender, EventArgs e)
//系列名输入时
//系列名输入时
void
setCode_InputText
(
int
index
,
ComboBox
cb
,
TextBox
tb
)
void
setCode_InputText
(
int
index
,
ComboBox
cb
,
TextBox
tb
)
{
{
if
(
index
>=
0
&&
index
<
setcodeIsedit
.
Length
)
if
(
index
>=
0
&&
index
<
this
.
setcodeIsedit
.
Length
)
{
{
if
(
setcodeIsedit
[
index
])
//如果正在编辑
if
(
this
.
setcodeIsedit
[
index
])
//如果正在编辑
{
return
;
return
;
setcodeIsedit
[
index
]
=
true
;
}
int
temp
;
int
.
TryParse
(
tb
.
Text
,
NumberStyles
.
HexNumber
,
null
,
out
temp
);
this
.
setcodeIsedit
[
index
]
=
true
;
int
.
TryParse
(
tb
.
Text
,
NumberStyles
.
HexNumber
,
null
,
out
int
temp
);
//tb.Text = temp.ToString("x");
//tb.Text = temp.ToString("x");
if
(
temp
==
0
&&
(
tb
.
Text
!=
"0"
||
tb
.
Text
.
Length
==
0
))
if
(
temp
==
0
&&
(
tb
.
Text
!=
"0"
||
tb
.
Text
.
Length
==
0
))
{
temp
=
-
1
;
temp
=
-
1
;
SetSelect
(
cb
,
temp
);
}
setcodeIsedit
[
index
]
=
false
;
this
.
SetSelect
(
cb
,
temp
);
this
.
setcodeIsedit
[
index
]
=
false
;
}
}
}
}
private
void
tb_setcode1_TextChanged
(
object
sender
,
EventArgs
e
)
private
void
tb_setcode1_TextChanged
(
object
sender
,
EventArgs
e
)
{
{
setCode_InputText
(
1
,
cb_setname1
,
tb_setcode1
);
this
.
setCode_InputText
(
1
,
this
.
cb_setname1
,
this
.
tb_setcode1
);
}
}
private
void
tb_setcode2_TextChanged
(
object
sender
,
EventArgs
e
)
private
void
tb_setcode2_TextChanged
(
object
sender
,
EventArgs
e
)
{
{
setCode_InputText
(
2
,
cb_setname2
,
tb_setcode2
);
this
.
setCode_InputText
(
2
,
this
.
cb_setname2
,
this
.
tb_setcode2
);
}
}
private
void
tb_setcode3_TextChanged
(
object
sender
,
EventArgs
e
)
private
void
tb_setcode3_TextChanged
(
object
sender
,
EventArgs
e
)
{
{
setCode_InputText
(
3
,
cb_setname3
,
tb_setcode3
);
this
.
setCode_InputText
(
3
,
this
.
cb_setname3
,
this
.
tb_setcode3
);
}
}
private
void
tb_setcode4_TextChanged
(
object
sender
,
EventArgs
e
)
private
void
tb_setcode4_TextChanged
(
object
sender
,
EventArgs
e
)
{
{
setCode_InputText
(
4
,
cb_setname4
,
tb_setcode4
);
this
.
setCode_InputText
(
4
,
this
.
cb_setname4
,
this
.
tb_setcode4
);
}
}
#
endregion
#
endregion
...
@@ -1572,44 +1884,52 @@ private void tb_setcode4_TextChanged(object sender, EventArgs e)
...
@@ -1572,44 +1884,52 @@ private void tb_setcode4_TextChanged(object sender, EventArgs e)
//系列选择框 选择时
//系列选择框 选择时
void
setCode_Selected
(
int
index
,
ComboBox
cb
,
TextBox
tb
)
void
setCode_Selected
(
int
index
,
ComboBox
cb
,
TextBox
tb
)
{
{
if
(
index
>=
0
&&
index
<
setcodeIsedit
.
Length
)
if
(
index
>=
0
&&
index
<
this
.
setcodeIsedit
.
Length
)
{
{
if
(
setcodeIsedit
[
index
])
//如果正在编辑
if
(
this
.
setcodeIsedit
[
index
])
//如果正在编辑
{
return
;
return
;
setcodeIsedit
[
index
]
=
true
;
}
long
tmp
=
GetSelect
(
cb
);
this
.
setcodeIsedit
[
index
]
=
true
;
long
tmp
=
this
.
GetSelect
(
cb
);
tb
.
Text
=
tmp
.
ToString
(
"x"
);
tb
.
Text
=
tmp
.
ToString
(
"x"
);
setcodeIsedit
[
index
]
=
false
;
this
.
setcodeIsedit
[
index
]
=
false
;
}
}
}
}
private
void
cb_setname1_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
private
void
cb_setname1_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
{
setCode_Selected
(
1
,
cb_setname1
,
tb_setcode1
);
this
.
setCode_Selected
(
1
,
this
.
cb_setname1
,
this
.
tb_setcode1
);
}
}
private
void
cb_setname2_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
private
void
cb_setname2_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
{
setCode_Selected
(
2
,
cb_setname2
,
tb_setcode2
);
this
.
setCode_Selected
(
2
,
this
.
cb_setname2
,
this
.
tb_setcode2
);
}
}
private
void
cb_setname3_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
private
void
cb_setname3_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
{
setCode_Selected
(
3
,
cb_setname3
,
tb_setcode3
);
this
.
setCode_Selected
(
3
,
this
.
cb_setname3
,
this
.
tb_setcode3
);
}
}
private
void
cb_setname4_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
private
void
cb_setname4_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
{
setCode_Selected
(
4
,
cb_setname4
,
tb_setcode4
);
this
.
setCode_Selected
(
4
,
this
.
cb_setname4
,
this
.
tb_setcode4
);
}
}
#
endregion
#
endregion
#
region
读取
MSE
存档
#
region
读取
MSE
存档
private
void
menuitem_readmse_Click
(
object
sender
,
EventArgs
e
)
private
void
menuitem_readmse_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
if
(
isRun
())
}
if
(
this
.
isRun
())
{
return
;
return
;
}
//select open mse-set
//select open mse-set
using
(
OpenFileDialog
dlg
=
new
OpenFileDialog
())
using
(
OpenFileDialog
dlg
=
new
OpenFileDialog
())
{
{
...
@@ -1617,11 +1937,10 @@ private void menuitem_readmse_Click(object sender, EventArgs e)
...
@@ -1617,11 +1937,10 @@ private void menuitem_readmse_Click(object sender, EventArgs e)
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
MseType
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
MseType
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
bool
isUpdate
=
false
;
//是否替换存在的图片
bool
isUpdate
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
isUpdate
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
this
.
tasker
.
SetTask
(
MyTask
.
ReadMSE
,
null
,
tasker
.
SetTask
(
MyTask
.
ReadMSE
,
null
,
dlg
.
FileName
,
isUpdate
.
ToString
());
dlg
.
FileName
,
isUpdate
.
ToString
());
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ReadMSE
));
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ReadMSE
));
}
}
}
}
}
}
...
@@ -1630,9 +1949,12 @@ private void menuitem_readmse_Click(object sender, EventArgs e)
...
@@ -1630,9 +1949,12 @@ private void menuitem_readmse_Click(object sender, EventArgs e)
#
region
压缩数据库
#
region
压缩数据库
private
void
menuitem_compdb_Click
(
object
sender
,
EventArgs
e
)
private
void
menuitem_compdb_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
DataBase
.
Compression
(
nowCdbFile
);
}
DataBase
.
Compression
(
this
.
nowCdbFile
);
MyMsg
.
Show
(
LMSG
.
CompDBOK
);
MyMsg
.
Show
(
LMSG
.
CompDBOK
);
}
}
#
endregion
#
endregion
...
@@ -1641,60 +1963,73 @@ private void menuitem_compdb_Click(object sender, EventArgs e)
...
@@ -1641,60 +1963,73 @@ private void menuitem_compdb_Click(object sender, EventArgs e)
//删除卡片的时候,是否要删除图片和脚本
//删除卡片的时候,是否要删除图片和脚本
private
void
menuitem_deletecardsfile_Click
(
object
sender
,
EventArgs
e
)
private
void
menuitem_deletecardsfile_Click
(
object
sender
,
EventArgs
e
)
{
{
menuitem_operacardsfile
.
Checked
=
!
menuitem_operacardsfile
.
Checked
;
this
.
menuitem_operacardsfile
.
Checked
=
!
this
.
menuitem_operacardsfile
.
Checked
;
MyConfig
.
Save
(
MyConfig
.
TAG_DELETE_WITH
,
menuitem_operacardsfile
.
Checked
.
ToString
().
ToLower
());
MyConfig
.
Save
(
MyConfig
.
TAG_DELETE_WITH
,
this
.
menuitem_operacardsfile
.
Checked
.
ToString
().
ToLower
());
}
}
//用CodeEditor打开lua
//用CodeEditor打开lua
private
void
menuitem_openfileinthis_Click
(
object
sender
,
EventArgs
e
)
private
void
menuitem_openfileinthis_Click
(
object
sender
,
EventArgs
e
)
{
{
menuitem_openfileinthis
.
Checked
=
!
menuitem_openfileinthis
.
Checked
;
this
.
menuitem_openfileinthis
.
Checked
=
!
this
.
menuitem_openfileinthis
.
Checked
;
MyConfig
.
Save
(
MyConfig
.
TAG_OPEN_IN_THIS
,
menuitem_openfileinthis
.
Checked
.
ToString
().
ToLower
());
MyConfig
.
Save
(
MyConfig
.
TAG_OPEN_IN_THIS
,
this
.
menuitem_openfileinthis
.
Checked
.
ToString
().
ToLower
());
}
}
//自动检查更新
//自动检查更新
private
void
menuitem_autocheckupdate_Click
(
object
sender
,
EventArgs
e
)
private
void
menuitem_autocheckupdate_Click
(
object
sender
,
EventArgs
e
)
{
{
menuitem_autocheckupdate
.
Checked
=
!
menuitem_autocheckupdate
.
Checked
;
this
.
menuitem_autocheckupdate
.
Checked
=
!
this
.
menuitem_autocheckupdate
.
Checked
;
MyConfig
.
Save
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
,
menuitem_autocheckupdate
.
Checked
.
ToString
().
ToLower
());
MyConfig
.
Save
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
,
this
.
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
);
this
.
Addrequire
=
Microsoft
.
VisualBasic
.
Interaction
.
InputBox
(
"Module script?\n\nPress \"Cancel\" to remove module script."
,
""
,
this
.
Addrequire
);
menuitem_addrequire
.
Checked
=
(
a
ddrequire
.
Length
>
0
);
this
.
menuitem_addrequire
.
Checked
=
(
this
.
A
ddrequire
.
Length
>
0
);
MyConfig
.
Save
(
MyConfig
.
TAG_ADD_REQUIRE
,
a
ddrequire
);
MyConfig
.
Save
(
MyConfig
.
TAG_ADD_REQUIRE
,
this
.
A
ddrequire
);
}
}
#
endregion
#
endregion
#
region
语言菜单
#
region
语言菜单
void
GetLanguageItem
()
void
GetLanguageItem
()
{
{
if
(!
Directory
.
Exists
(
datapath
))
if
(!
Directory
.
Exists
(
this
.
datapath
))
{
return
;
return
;
menuitem_language
.
DropDownItems
.
Clear
();
}
string
[]
files
=
Directory
.
GetFiles
(
datapath
);
this
.
menuitem_language
.
DropDownItems
.
Clear
();
string
[]
files
=
Directory
.
GetFiles
(
this
.
datapath
);
foreach
(
string
file
in
files
)
foreach
(
string
file
in
files
)
{
{
string
name
=
MyPath
.
getFullFileName
(
MyConfig
.
TAG_LANGUAGE
,
file
);
string
name
=
MyPath
.
getFullFileName
(
MyConfig
.
TAG_LANGUAGE
,
file
);
if
(
string
.
IsNullOrEmpty
(
name
))
if
(
string
.
IsNullOrEmpty
(
name
))
{
continue
;
continue
;
}
TextInfo
txinfo
=
new
CultureInfo
(
CultureInfo
.
InstalledUICulture
.
Name
).
TextInfo
;
TextInfo
txinfo
=
new
CultureInfo
(
CultureInfo
.
InstalledUICulture
.
Name
).
TextInfo
;
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
txinfo
.
ToTitleCase
(
name
));
ToolStripMenuItem
tsmi
=
new
ToolStripMenuItem
(
txinfo
.
ToTitleCase
(
name
))
tsmi
.
ToolTipText
=
file
;
{
tsmi
.
Click
+=
SetLanguage_Click
;
ToolTipText
=
file
};
tsmi
.
Click
+=
this
.
SetLanguage_Click
;
if
(
MyConfig
.
readString
(
MyConfig
.
TAG_LANGUAGE
).
Equals
(
name
,
StringComparison
.
OrdinalIgnoreCase
))
if
(
MyConfig
.
readString
(
MyConfig
.
TAG_LANGUAGE
).
Equals
(
name
,
StringComparison
.
OrdinalIgnoreCase
))
{
tsmi
.
Checked
=
true
;
tsmi
.
Checked
=
true
;
menuitem_language
.
DropDownItems
.
Add
(
tsmi
);
}
this
.
menuitem_language
.
DropDownItems
.
Add
(
tsmi
);
}
}
}
}
void
SetLanguage_Click
(
object
sender
,
EventArgs
e
)
void
SetLanguage_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(
isRun
())
if
(
this
.
isRun
())
{
return
;
return
;
if
(
sender
is
ToolStripMenuItem
)
}
if
(
sender
is
ToolStripMenuItem
tsmi
)
{
{
ToolStripMenuItem
tsmi
=
(
ToolStripMenuItem
)
sender
;
MyConfig
.
Save
(
MyConfig
.
TAG_LANGUAGE
,
tsmi
.
Text
);
MyConfig
.
Save
(
MyConfig
.
TAG_LANGUAGE
,
tsmi
.
Text
);
GetLanguageItem
();
this
.
GetLanguageItem
();
MyMsg
.
Show
(
LMSG
.
PlzRestart
);
MyMsg
.
Show
(
LMSG
.
PlzRestart
);
}
}
}
}
...
@@ -1703,17 +2038,20 @@ void SetLanguage_Click(object sender, EventArgs e)
...
@@ -1703,17 +2038,20 @@ void SetLanguage_Click(object sender, EventArgs e)
//把mse存档导出为图片
//把mse存档导出为图片
void
Menuitem_exportMSEimageClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_exportMSEimageClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
isRun
())
if
(
this
.
isRun
())
{
return
;
return
;
}
string
msepath
=
MyPath
.
GetRealPath
(
MyConfig
.
readString
(
MyConfig
.
TAG_MSE_PATH
));
string
msepath
=
MyPath
.
GetRealPath
(
MyConfig
.
readString
(
MyConfig
.
TAG_MSE_PATH
));
if
(!
File
.
Exists
(
msepath
)){
if
(!
File
.
Exists
(
msepath
)){
MyMsg
.
Error
(
LMSG
.
exportMseImagesErr
);
MyMsg
.
Error
(
LMSG
.
exportMseImagesErr
);
menuitem_exportMSEimage
.
Checked
=
false
;
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
return
;
return
;
}
else
{
}
else
{
if
(
MseMaker
.
MseIsRunning
()){
if
(
MseMaker
.
MseIsRunning
()){
MseMaker
.
MseStop
();
MseMaker
.
MseStop
();
menuitem_exportMSEimage
.
Checked
=
false
;
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
return
;
return
;
}
else
{
}
else
{
...
@@ -1728,27 +2066,27 @@ void Menuitem_exportMSEimageClick(object sender, EventArgs e)
...
@@ -1728,27 +2066,27 @@ 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
.
e
xportSet
(
msepath
,
mseset
,
exportpath
,
delegate
{
MseMaker
.
E
xportSet
(
msepath
,
mseset
,
exportpath
,
delegate
{
menuitem_exportMSEimage
.
Checked
=
false
;
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
});
});
menuitem_exportMSEimage
.
Checked
=
true
;
this
.
menuitem_exportMSEimage
.
Checked
=
true
;
}
else
{
}
else
{
menuitem_exportMSEimage
.
Checked
=
false
;
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
}
}
}
}
}
}
void
Menuitem_testPendulumTextClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_testPendulumTextClick
(
object
sender
,
EventArgs
e
)
{
{
Card
c
=
GetCard
();
Card
c
=
this
.
GetCard
();
if
(
c
!=
null
){
if
(
c
!=
null
){
tasker
.
testPendulumText
(
c
.
desc
);
t
his
.
t
asker
.
testPendulumText
(
c
.
desc
);
}
}
}
}
void
Menuitem_export_select_sqlClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_export_select_sqlClick
(
object
sender
,
EventArgs
e
)
{
{
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
()){
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
()){
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
){
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
){
DataBase
.
exportSql
(
dlg
.
FileName
,
GetCardList
(
true
));
DataBase
.
ExportSql
(
dlg
.
FileName
,
this
.
GetCardList
(
true
));
MyMsg
.
Show
(
"OK"
);
MyMsg
.
Show
(
"OK"
);
}
}
}
}
...
@@ -1757,25 +2095,31 @@ void Menuitem_export_all_sqlClick(object sender, EventArgs e)
...
@@ -1757,25 +2095,31 @@ void Menuitem_export_all_sqlClick(object sender, EventArgs e)
{
{
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
()){
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
()){
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
){
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
){
DataBase
.
exportSql
(
dlg
.
FileName
,
GetCardList
(
false
));
DataBase
.
ExportSql
(
dlg
.
FileName
,
this
.
GetCardList
(
false
));
MyMsg
.
Show
(
"OK"
);
MyMsg
.
Show
(
"OK"
);
}
}
}
}
}
}
void
Menuitem_autoreturnClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_autoreturnClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
{
return
;
return
;
}
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
{
{
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectDataBasePath
);
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectDataBasePath
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
Card
[]
cards
=
DataBase
.
Read
(
nowCdbFile
,
true
,
""
);
Card
[]
cards
=
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
""
);
int
count
=
cards
.
Length
;
int
count
=
cards
.
Length
;
if
(
cards
==
null
||
cards
.
Length
==
0
)
if
(
cards
==
null
||
cards
.
Length
==
0
)
{
return
;
return
;
}
if
(
DataBase
.
Create
(
dlg
.
FileName
))
if
(
DataBase
.
Create
(
dlg
.
FileName
))
{
{
//
//
...
@@ -1795,27 +2139,33 @@ void Menuitem_autoreturnClick(object sender, EventArgs e)
...
@@ -1795,27 +2139,33 @@ void Menuitem_autoreturnClick(object sender, EventArgs e)
void
Menuitem_replaceClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_replaceClick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
CheckOpen
())
if
(!
this
.
CheckOpen
())
return
;
{
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
return
;
}
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
{
{
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectDataBasePath
);
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectDataBasePath
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
{
Card
[]
cards
=
DataBase
.
Read
(
nowCdbFile
,
true
,
""
);
Card
[]
cards
=
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
""
);
int
count
=
cards
.
Length
;
int
count
=
cards
.
Length
;
if
(
cards
==
null
||
cards
.
Length
==
0
)
if
(
cards
==
null
||
cards
.
Length
==
0
)
return
;
{
if
(
DataBase
.
Create
(
dlg
.
FileName
))
return
;
}
if
(
DataBase
.
Create
(
dlg
.
FileName
))
{
{
//
//
int
len
=
MyConfig
.
readInteger
(
MyConfig
.
TAG_AUTO_LEN
,
30
);
_
=
MyConfig
.
readInteger
(
MyConfig
.
TAG_AUTO_LEN
,
30
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
{
if
(
cards
[
i
].
desc
!=
null
)
if
(
cards
[
i
].
desc
!=
null
)
{
{
cards
[
i
].
desc
=
tasker
.
MseHelper
.
ReplaceText
(
cards
[
i
].
desc
,
cards
[
i
].
name
);
cards
[
i
].
desc
=
t
his
.
t
asker
.
MseHelper
.
ReplaceText
(
cards
[
i
].
desc
,
cards
[
i
].
name
);
}
}
}
}
DataBase
.
CopyDB
(
dlg
.
FileName
,
false
,
cards
);
DataBase
.
CopyDB
(
dlg
.
FileName
,
false
,
cards
);
...
@@ -1829,7 +2179,7 @@ private void text2LinkMarks(string text)
...
@@ -1829,7 +2179,7 @@ private void text2LinkMarks(string text)
{
{
try
{
try
{
long
mark
=
Convert
.
ToInt64
(
text
,
2
);
long
mark
=
Convert
.
ToInt64
(
text
,
2
);
setLinkMarks
(
mark
,
true
);
this
.
setLinkMarks
(
mark
,
true
);
}
catch
{
}
catch
{
//
//
}
}
...
@@ -1837,30 +2187,50 @@ private void text2LinkMarks(string text)
...
@@ -1837,30 +2187,50 @@ private void text2LinkMarks(string text)
void
Tb_linkTextChanged
(
object
sender
,
EventArgs
e
)
void
Tb_linkTextChanged
(
object
sender
,
EventArgs
e
)
{
{
t
ext2LinkMarks
(
tb_link
.
Text
);
t
his
.
text2LinkMarks
(
this
.
tb_link
.
Text
);
}
}
private
void
DataEditForm_KeyDown
(
object
sender
,
KeyEventArgs
e
)
private
void
DataEditForm_KeyDown
(
object
sender
,
KeyEventArgs
e
)
{
{
if
(
e
.
Control
&&
e
.
KeyCode
==
Keys
.
F
)
if
(
e
.
Control
&&
e
.
KeyCode
==
Keys
.
F
)
{
{
tb_cardname
.
Focus
();
this
.
tb_cardname
.
Focus
();
tb_cardname
.
SelectAll
();
this
.
tb_cardname
.
SelectAll
();
}
}
}
}
void
Tb_linkKeyPress
(
object
sender
,
KeyPressEventArgs
e
)
private
void
tb_cardtext_KeyDown
(
object
sender
,
KeyEventArgs
e
)
{
if
(
e
.
Modifiers
==
Keys
.
Control
&&
e
.
KeyCode
==
Keys
.
R
)
{
this
.
Btn_resetClick
(
null
,
null
);
}
else
if
(
e
.
Modifiers
==
Keys
.
Control
&&
e
.
KeyCode
==
Keys
.
F
)
{
this
.
tb_cardname
.
Focus
();
}
}
private
void
DataEditForm_Load
(
object
sender
,
EventArgs
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);
e
.
Handled
=
true
;
e
.
Handled
=
true
;
}
else
{
}
else
{
t
ext2LinkMarks
(
tb_link
.
Text
);
t
his
.
text2LinkMarks
(
this
.
tb_link
.
Text
);
}
}
}
}
void
DataEditFormSizeChanged
(
object
sender
,
EventArgs
e
)
void
DataEditFormSizeChanged
(
object
sender
,
EventArgs
e
)
{
{
InitListRows
();
this
.
InitListRows
();
this
.
AddListView
(
this
.
page
);
this
.
tmpCodes
.
Clear
();
//清空临时的结果
this
.
Search
(
true
);
}
}
}
}
...
...
DataEditorX/Language/LanguageHelper.cs
View file @
bc0829bf
...
@@ -19,19 +19,23 @@ namespace DataEditorX.Language
...
@@ -19,19 +19,23 @@ namespace DataEditorX.Language
/// </summary>
/// </summary>
public
class
LanguageHelper
public
class
LanguageHelper
{
{
static
Dictionary
<
string
,
string
>
gWordsList
=
new
Dictionary
<
string
,
string
>();
static
readonly
Dictionary
<
string
,
string
>
gWordsList
=
new
Dictionary
<
string
,
string
>();
static
SortedList
<
LMSG
,
string
>
gMsgList
=
new
SortedList
<
LMSG
,
string
>();
static
readonly
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
>();
readonly
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
...
@@ -43,7 +47,9 @@ public static string GetMsg(LMSG lMsg)
...
@@ -43,7 +47,9 @@ public static string GetMsg(LMSG lMsg)
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
);
...
@@ -53,8 +59,7 @@ public static void SetFormLabel(Form fm)
...
@@ -53,8 +59,7 @@ public static void SetFormLabel(Form fm)
static
bool
GetLabel
(
string
key
,
out
string
title
)
static
bool
GetLabel
(
string
key
,
out
string
title
)
{
{
string
v
;
if
(
gWordsList
.
TryGetValue
(
key
,
out
string
v
))
if
(
gWordsList
.
TryGetValue
(
key
,
out
v
))
{
{
title
=
v
;
title
=
v
;
return
true
;
return
true
;
...
@@ -66,23 +71,26 @@ static bool GetLabel(string key, out string title)
...
@@ -66,23 +71,26 @@ static bool GetLabel(string key, out string title)
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
lv
)
{
{
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
ms
)
{
{
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
);
...
@@ -91,7 +99,9 @@ static void SetControlLabel(Control c, string pName, string formName)
...
@@ -91,7 +99,9 @@ static void SetControlLabel(Control c, string pName, string formName)
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
)
...
@@ -115,11 +125,13 @@ static void SetMenuItem(string pName, ToolStripItem tsi)
...
@@ -115,11 +125,13 @@ static void SetMenuItem(string pName, ToolStripItem tsi)
{
{
string
title
;
string
title
;
if
(
tsi
is
ToolStripMenuItem
)
if
(
tsi
is
ToolStripMenuItem
tsmi
)
{
{
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
)
...
@@ -128,11 +140,12 @@ static void SetMenuItem(string pName, ToolStripItem tsi)
...
@@ -128,11 +140,12 @@ static void SetMenuItem(string pName, ToolStripItem tsi)
}
}
}
}
}
}
else
if
(
tsi
is
ToolStripLabel
)
else
if
(
tsi
is
ToolStripLabel
tlbl
)
{
{
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
;
}
}
}
}
}
...
@@ -142,56 +155,64 @@ static void SetMenuItem(string pName, ToolStripItem tsi)
...
@@ -142,56 +155,64 @@ static void SetMenuItem(string pName, ToolStripItem tsi)
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
);
this
.
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
(!
this
.
mWordslist
.
ContainsKey
(
key
))
mWordslist
.
Add
(
key
,
title
);
{
this
.
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
lv
)
{
{
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
(),
this
.
AddLabel
(
pName
+
SEP_CONTROL
+
i
.
ToString
(),
lv
.
Columns
[
i
].
Text
);
lv
.
Columns
[
i
].
Text
);
}
}
}
}
else
if
(
c
is
ToolStrip
)
else
if
(
c
is
ToolStrip
ms
)
{
{
ToolStrip
ms
=
(
ToolStrip
)
c
;
foreach
(
ToolStripItem
tsi
in
ms
.
Items
)
foreach
(
ToolStripItem
tsi
in
ms
.
Items
)
{
{
GetMenuItem
(
formName
+
SEP_CONTROL
+
ms
.
Name
,
tsi
);
this
.
GetMenuItem
(
formName
+
SEP_CONTROL
+
ms
.
Name
,
tsi
);
}
}
}
}
else
else
{
{
AddLabel
(
pName
,
c
.
Text
);
this
.
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
);
this
.
GetControlLabel
(
sc
,
pName
,
formName
);
}
}
}
}
ContextMenuStrip
conms
=
c
.
ContextMenuStrip
;
ContextMenuStrip
conms
=
c
.
ContextMenuStrip
;
...
@@ -199,7 +220,7 @@ void AddLabel(string key, string title)
...
@@ -199,7 +220,7 @@ void AddLabel(string key, string title)
{
{
foreach
(
ToolStripItem
ts
in
conms
.
Items
)
foreach
(
ToolStripItem
ts
in
conms
.
Items
)
{
{
GetMenuItem
(
formName
+
SEP_CONTROL
+
conms
.
Text
,
ts
);
this
.
GetMenuItem
(
formName
+
SEP_CONTROL
+
conms
.
Text
,
ts
);
}
}
}
}
}
}
...
@@ -207,23 +228,24 @@ void AddLabel(string key, string title)
...
@@ -207,23 +228,24 @@ void AddLabel(string key, string title)
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
tsmi
)
{
{
ToolStripMenuItem
tsmi
=
(
ToolStripMenuItem
)
tsi
;
this
.
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
);
this
.
GetMenuItem
(
pName
,
subtsi
);
}
}
}
}
}
}
else
if
(
tsi
is
ToolStripLabel
)
else
if
(
tsi
is
ToolStripLabel
tlbl
)
{
{
ToolStripLabel
tlbl
=
(
ToolStripLabel
)
tsi
;
this
.
AddLabel
(
pName
+
SEP_CONTROL
+
tlbl
.
Name
,
tlbl
.
Text
);
AddLabel
(
pName
+
SEP_CONTROL
+
tlbl
.
Name
,
tlbl
.
Text
);
}
}
}
}
...
@@ -235,9 +257,9 @@ public bool SaveLanguage(string conf)
...
@@ -235,9 +257,9 @@ 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
this
.
mWordslist
.
Keys
)
{
{
sw
.
WriteLine
(
k
+
SEP_LINE
+
mWordslist
[
k
]);
sw
.
WriteLine
(
k
+
SEP_LINE
+
this
.
mWordslist
[
k
]);
}
}
sw
.
WriteLine
(
"#"
);
sw
.
WriteLine
(
"#"
);
foreach
(
LMSG
k
in
gMsgList
.
Keys
)
foreach
(
LMSG
k
in
gMsgList
.
Keys
)
...
@@ -248,7 +270,9 @@ public bool SaveLanguage(string conf)
...
@@ -248,7 +270,9 @@ public bool SaveLanguage(string conf)
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
();
...
@@ -261,33 +285,45 @@ public bool SaveLanguage(string conf)
...
@@ -261,33 +285,45 @@ public bool SaveLanguage(string conf)
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
;
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
u
int
u
temp
);
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
();
...
...
DataEditorX/Language/MyMsg.cs
View file @
bc0829bf
...
@@ -19,7 +19,7 @@ namespace DataEditorX.Language
...
@@ -19,7 +19,7 @@ namespace DataEditorX.Language
/// </summary>
/// </summary>
public
static
class
MyMsg
public
static
class
MyMsg
{
{
static
string
info
,
warning
,
error
,
question
;
static
readonly
string
info
,
warning
,
error
,
question
;
static
MyMsg
()
static
MyMsg
()
{
{
info
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleInfo
);
info
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleInfo
);
...
@@ -47,9 +47,13 @@ public static bool Question(string strQues)
...
@@ -47,9 +47,13 @@ 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
)
{
{
...
@@ -71,9 +75,13 @@ public static bool Question(LMSG msg)
...
@@ -71,9 +75,13 @@ 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.cs
View file @
bc0829bf
...
@@ -43,70 +43,73 @@ public partial class MainForm : Form, IMainForm
...
@@ -43,70 +43,73 @@ public partial class MainForm : Form, IMainForm
public
MainForm
()
public
MainForm
()
{
{
//初始化控件
//初始化控件
InitializeComponent
();
this
.
InitializeComponent
();
}
}
public
void
SetDataPath
(
string
datapath
)
public
void
SetDataPath
(
string
datapath
)
{
{
//判断是否合法
//判断是否合法
if
(
string
.
IsNullOrEmpty
(
datapath
))
if
(
string
.
IsNullOrEmpty
(
datapath
))
{
return
;
return
;
tCards
=
null
;
}
this
.
tCards
=
null
;
//数据目录
//数据目录
this
.
datapath
=
datapath
;
this
.
datapath
=
datapath
;
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_ASYNC
))
if
(
MyConfig
.
readBoolean
(
MyConfig
.
TAG_ASYNC
))
{
{
//后台加载数据
//后台加载数据
bgWorker1
.
RunWorkerAsync
();
this
.
bgWorker1
.
RunWorkerAsync
();
}
}
else
else
{
{
Init
();
this
.
Init
();
InitForm
();
this
.
InitForm
();
}
}
}
}
void
CheckUpdate
()
void
CheckUpdate
()
{
{
TaskHelper
.
CheckVersion
(
false
);
TaskHelper
.
CheckVersion
(
false
);
}
}
public
void
s
etOpenFile
(
string
file
)
public
void
S
etOpenFile
(
string
file
)
{
{
this
.
openfile
=
file
;
this
.
openfile
=
file
;
}
}
void
Init
()
void
Init
()
{
{
//文件路径
//文件路径
conflang
=
MyConfig
.
GetLanguageFile
(
datapath
);
this
.
conflang
=
MyConfig
.
GetLanguageFile
(
this
.
datapath
);
//游戏数据,MSE数据
//游戏数据,MSE数据
datacfg
=
new
DataConfig
(
MyConfig
.
GetCardInfoFile
(
datapath
));
this
.
datacfg
=
new
DataConfig
(
MyConfig
.
GetCardInfoFile
(
this
.
datapath
));
//初始化YGOUtil的数据
//初始化YGOUtil的数据
YGOUtil
.
SetConfig
(
datacfg
);
YGOUtil
.
SetConfig
(
this
.
datacfg
);
//代码提示
//代码提示
string
funtxt
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_FUNCTION
);
string
funtxt
=
MyPath
.
Combine
(
this
.
datapath
,
MyConfig
.
FILE_FUNCTION
);
string
conlua
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_CONSTANT
);
string
conlua
=
MyPath
.
Combine
(
this
.
datapath
,
MyConfig
.
FILE_CONSTANT
);
string
confstring
=
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_STRINGS
);
string
confstring
=
MyPath
.
Combine
(
this
.
datapath
,
MyConfig
.
FILE_STRINGS
);
codecfg
=
new
CodeConfig
();
this
.
codecfg
=
new
CodeConfig
();
//添加函数
//添加函数
codecfg
.
AddFunction
(
funtxt
);
this
.
codecfg
.
AddFunction
(
funtxt
);
//添加指示物
//添加指示物
codecfg
.
AddStrings
(
confstring
);
this
.
codecfg
.
AddStrings
(
confstring
);
//添加常量
//添加常量
codecfg
.
AddConstant
(
conlua
);
this
.
codecfg
.
AddConstant
(
conlua
);
codecfg
.
SetNames
(
datacfg
.
dicSetnames
);
this
.
codecfg
.
SetNames
(
this
.
datacfg
.
dicSetnames
);
//生成菜单
//生成菜单
codecfg
.
InitAutoMenus
();
this
.
codecfg
.
InitAutoMenus
();
history
=
new
History
(
this
);
this
.
history
=
new
History
(
this
);
//读取历史记录
//读取历史记录
history
.
ReadHistory
(
MyPath
.
Combine
(
datapath
,
MyConfig
.
FILE_HISTORY
));
this
.
history
.
ReadHistory
(
MyPath
.
Combine
(
this
.
datapath
,
MyConfig
.
FILE_HISTORY
));
//加载多语言
//加载多语言
LanguageHelper
.
LoadFormLabels
(
conflang
);
LanguageHelper
.
LoadFormLabels
(
this
.
conflang
);
}
}
void
InitForm
()
void
InitForm
()
{
{
LanguageHelper
.
SetFormLabel
(
this
);
LanguageHelper
.
SetFormLabel
(
this
);
//设置所有窗口的语言
//设置所有窗口的语言
DockContentCollection
contents
=
dockPanel1
.
Contents
;
DockContentCollection
contents
=
this
.
dockPanel1
.
Contents
;
foreach
(
DockContent
dc
in
contents
)
foreach
(
DockContent
dc
in
contents
)
{
{
if
(
dc
is
Form
)
if
(
dc
is
Form
)
...
@@ -115,13 +118,17 @@ void InitForm()
...
@@ -115,13 +118,17 @@ void InitForm()
}
}
}
}
//添加历史菜单
//添加历史菜单
history
.
MenuHistory
();
this
.
history
.
MenuHistory
();
//如果没有将要打开的文件,则打开一个空数据库标签
//如果没有将要打开的文件,则打开一个空数据库标签
if
(
string
.
IsNullOrEmpty
(
openfile
))
if
(
string
.
IsNullOrEmpty
(
this
.
openfile
))
OpenDataBase
(
null
);
{
this
.
OpenDataBase
(
null
);
}
else
else
Open
(
openfile
);
{
this
.
Open
(
this
.
openfile
);
}
}
}
#
endregion
#
endregion
...
@@ -129,39 +136,38 @@ void InitForm()
...
@@ -129,39 +136,38 @@ void InitForm()
//清除cdb历史
//清除cdb历史
public
void
CdbMenuClear
()
public
void
CdbMenuClear
()
{
{
menuitem_history
.
DropDownItems
.
Clear
();
this
.
menuitem_history
.
DropDownItems
.
Clear
();
}
}
//清除lua历史
//清除lua历史
public
void
LuaMenuClear
()
public
void
LuaMenuClear
()
{
{
menuitem_shistory
.
DropDownItems
.
Clear
();
this
.
menuitem_shistory
.
DropDownItems
.
Clear
();
}
}
//添加cdb历史
//添加cdb历史
public
void
AddCdbMenu
(
ToolStripItem
item
)
public
void
AddCdbMenu
(
ToolStripItem
item
)
{
{
menuitem_history
.
DropDownItems
.
Add
(
item
);
this
.
menuitem_history
.
DropDownItems
.
Add
(
item
);
}
}
//添加lua历史
//添加lua历史
public
void
AddLuaMenu
(
ToolStripItem
item
)
public
void
AddLuaMenu
(
ToolStripItem
item
)
{
{
menuitem_shistory
.
DropDownItems
.
Add
(
item
);
this
.
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
;
switch
(
m
.
Msg
)
switch
(
m
.
Msg
)
{
{
case
MyConfig
.
WM_OPEN
:
//处理消息
case
MyConfig
.
WM_OPEN
:
//处理消息
file
=
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
FILE_TEMP
);
string
file
=
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
FILE_TEMP
);
if
(
File
.
Exists
(
file
))
if
(
File
.
Exists
(
file
))
{
{
this
.
Activate
();
this
.
Activate
();
S
tring
openfile
=
File
.
ReadAllText
(
file
);
s
tring
openfile
=
File
.
ReadAllText
(
file
);
//获取需要打开的文件路径
//获取需要打开的文件路径
Open
(
openfile
);
this
.
Open
(
openfile
);
//File.Delete(file);
//File.Delete(file);
}
}
break
;
break
;
...
@@ -180,26 +186,30 @@ void OpenScript(string file)
...
@@ -180,26 +186,30 @@ void OpenScript(string file)
//设置界面语言
//设置界面语言
LanguageHelper
.
SetFormLabel
(
cf
);
LanguageHelper
.
SetFormLabel
(
cf
);
//设置cdb列表
//设置cdb列表
cf
.
SetCDBList
(
history
.
GetcdbHistory
());
cf
.
SetCDBList
(
this
.
history
.
GetcdbHistory
());
//初始化函数提示
//初始化函数提示
cf
.
InitTooltip
(
codecfg
);
cf
.
InitTooltip
(
this
.
codecfg
);
//打开文件
//打开文件
cf
.
Open
(
file
);
cf
.
Open
(
file
);
cf
.
Show
(
dockPanel1
,
DockState
.
Document
);
cf
.
Show
(
this
.
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
(
this
.
datapath
);
}
else
else
def
=
new
DataEditForm
(
datapath
,
file
);
{
def
=
new
DataEditForm
(
this
.
datapath
,
file
);
}
//设置语言
//设置语言
LanguageHelper
.
SetFormLabel
(
def
);
LanguageHelper
.
SetFormLabel
(
def
);
//初始化界面数据
//初始化界面数据
def
.
InitControl
(
datacfg
);
def
.
InitControl
(
this
.
datacfg
);
def
.
Show
(
dockPanel1
,
DockState
.
Document
);
def
.
Show
(
this
.
dockPanel1
,
DockState
.
Document
);
}
}
//打开文件
//打开文件
public
void
Open
(
string
file
)
public
void
Open
(
string
file
)
...
@@ -209,28 +219,40 @@ public void Open(string file)
...
@@ -209,28 +219,40 @@ public void Open(string file)
return
;
return
;
}
}
//添加历史
//添加历史
history
.
AddHistory
(
file
);
this
.
history
.
AddHistory
(
file
);
//检查是否已经打开
//检查是否已经打开
if
(
FindEditForm
(
file
,
true
))
if
(
this
.
FindEditForm
(
file
,
true
))
{
return
;
return
;
}
//检查可用的
//检查可用的
if
(
FindEditForm
(
file
,
false
))
if
(
this
.
FindEditForm
(
file
,
false
))
{
return
;
return
;
if
(
YGOUtil
.
isScript
(
file
))
}
OpenScript
(
file
);
else
if
(
YGOUtil
.
isDataBase
(
file
))
if
(
YGOUtil
.
IsScript
(
file
))
OpenDataBase
(
file
);
{
this
.
OpenScript
(
file
);
}
else
if
(
YGOUtil
.
IsDataBase
(
file
))
{
this
.
OpenDataBase
(
file
);
}
}
}
//检查是否打开
//检查是否打开
bool
FindEditForm
(
string
file
,
bool
isOpen
)
bool
FindEditForm
(
string
file
,
bool
isOpen
)
{
{
DockContentCollection
contents
=
dockPanel1
.
Contents
;
DockContentCollection
contents
=
this
.
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
()))
...
@@ -257,24 +279,26 @@ bool FindEditForm(string file, bool isOpen)
...
@@ -257,24 +279,26 @@ bool FindEditForm(string file, bool isOpen)
//关闭当前
//关闭当前
void
CloseToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
CloseToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
dockPanel1
.
ActiveContent
.
DockHandler
!=
null
)
if
(
this
.
dockPanel1
.
ActiveContent
.
DockHandler
!=
null
)
dockPanel1
.
ActiveContent
.
DockHandler
.
Close
();
{
this
.
dockPanel1
.
ActiveContent
.
DockHandler
.
Close
();
}
}
}
//打开脚本编辑
//打开脚本编辑
void
Menuitem_codeeditorClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_codeeditorClick
(
object
sender
,
EventArgs
e
)
{
{
OpenScript
(
null
);
this
.
OpenScript
(
null
);
}
}
//新建DataEditorX
//新建DataEditorX
void
DataEditorToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
DataEditorToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
OpenDataBase
(
null
);
this
.
OpenDataBase
(
null
);
}
}
//关闭其他或者所有
//关闭其他或者所有
void
CloseMdi
(
bool
isall
)
void
CloseMdi
(
bool
isall
)
{
{
DockContentCollection
contents
=
dockPanel1
.
Contents
;
DockContentCollection
contents
=
this
.
dockPanel1
.
Contents
;
int
num
=
contents
.
Count
-
1
;
int
num
=
contents
.
Count
-
1
;
try
try
{
{
...
@@ -283,9 +307,13 @@ void CloseMdi(bool isall)
...
@@ -283,9 +307,13 @@ void CloseMdi(bool isall)
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
(
this
.
dockPanel1
.
ActiveContent
!=
contents
[
num
])
{
contents
[
num
].
DockHandler
.
Close
();
contents
[
num
].
DockHandler
.
Close
();
}
}
}
num
--;
num
--;
}
}
...
@@ -295,12 +323,12 @@ void CloseMdi(bool isall)
...
@@ -295,12 +323,12 @@ void CloseMdi(bool isall)
//关闭其他
//关闭其他
void
CloseOtherToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
CloseOtherToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
CloseMdi
(
false
);
this
.
CloseMdi
(
false
);
}
}
//关闭所有
//关闭所有
void
CloseAllToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
void
CloseAllToolStripMenuItemClick
(
object
sender
,
EventArgs
e
)
{
{
CloseMdi
(
true
);
this
.
CloseMdi
(
true
);
}
}
#
endregion
#
endregion
...
@@ -308,7 +336,7 @@ void CloseAllToolStripMenuItemClick(object sender, EventArgs e)
...
@@ -308,7 +336,7 @@ void CloseAllToolStripMenuItemClick(object sender, EventArgs e)
//得到当前的数据编辑
//得到当前的数据编辑
DataEditForm
GetActive
()
DataEditForm
GetActive
()
{
{
DataEditForm
df
=
dockPanel1
.
ActiveContent
as
DataEditForm
;
DataEditForm
df
=
this
.
dockPanel1
.
ActiveContent
as
DataEditForm
;
return
df
;
return
df
;
}
}
//打开文件
//打开文件
...
@@ -317,14 +345,19 @@ void Menuitem_openClick(object sender, EventArgs e)
...
@@ -317,14 +345,19 @@ 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
(
this
.
GetActive
()
!=
null
||
this
.
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
);
this
.
Open
(
file
);
}
}
}
}
}
}
...
@@ -340,27 +373,36 @@ void Menuitem_newClick(object sender, EventArgs e)
...
@@ -340,27 +373,36 @@ 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
(
this
.
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
.
i
sDataBase
(
file
))
if
(
YGOUtil
.
I
sDataBase
(
file
))
{
{
if
(
DataBase
.
Create
(
file
))
//是否创建成功
if
(
DataBase
.
Create
(
file
))
//是否创建成功
{
{
if
(
MyMsg
.
Question
(
LMSG
.
IfOpenDataBase
))
//是否打开新建的数据库
if
(
MyMsg
.
Question
(
LMSG
.
IfOpenDataBase
))
//是否打开新建的数据库
Open
(
file
);
{
this
.
Open
(
file
);
}
}
}
}
}
else
else
{
{
Open
(
file
);
this
.
Open
(
file
);
}
}
}
}
}
}
...
@@ -368,11 +410,12 @@ void Menuitem_newClick(object sender, EventArgs e)
...
@@ -368,11 +410,12 @@ void Menuitem_newClick(object sender, EventArgs e)
//保存文件
//保存文件
void
Menuitem_saveClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_saveClick
(
object
sender
,
EventArgs
e
)
{
{
IEditForm
cf
=
dockPanel1
.
ActiveContent
as
IEditForm
;
if
(
this
.
dockPanel1
.
ActiveContent
is
IEditForm
cf
)
if
(
cf
!=
null
)
{
{
if
(
cf
.
Save
())
//是否保存成功
if
(
cf
.
Save
())
//是否保存成功
{
MyMsg
.
Show
(
LMSG
.
SaveFileOK
);
MyMsg
.
Show
(
LMSG
.
SaveFileOK
);
}
}
}
}
}
#
endregion
#
endregion
...
@@ -381,13 +424,13 @@ void Menuitem_saveClick(object sender, EventArgs e)
...
@@ -381,13 +424,13 @@ void Menuitem_saveClick(object sender, EventArgs e)
//复制选中
//复制选中
void
Menuitem_copyselecttoClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_copyselecttoClick
(
object
sender
,
EventArgs
e
)
{
{
DataEditForm
df
=
GetActive
();
//获取当前的数据库编辑
DataEditForm
df
=
this
.
GetActive
();
//获取当前的数据库编辑
if
(
df
!=
null
)
if
(
df
!=
null
)
{
{
tCards
=
df
.
GetCardList
(
true
);
//获取选中的卡片
t
his
.
t
Cards
=
df
.
GetCardList
(
true
);
//获取选中的卡片
if
(
tCards
!=
null
)
if
(
t
his
.
t
Cards
!=
null
)
{
{
SetCopyNumber
(
tCards
.
Length
);
//显示复制卡片的数量
this
.
SetCopyNumber
(
this
.
tCards
.
Length
);
//显示复制卡片的数量
MyMsg
.
Show
(
LMSG
.
CopyCards
);
MyMsg
.
Show
(
LMSG
.
CopyCards
);
}
}
}
}
...
@@ -395,13 +438,13 @@ void Menuitem_copyselecttoClick(object sender, EventArgs e)
...
@@ -395,13 +438,13 @@ void Menuitem_copyselecttoClick(object sender, EventArgs e)
//复制当前结果
//复制当前结果
void
Menuitem_copyallClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_copyallClick
(
object
sender
,
EventArgs
e
)
{
{
DataEditForm
df
=
GetActive
();
//获取当前的数据库编辑
DataEditForm
df
=
this
.
GetActive
();
//获取当前的数据库编辑
if
(
df
!=
null
)
if
(
df
!=
null
)
{
{
tCards
=
df
.
GetCardList
(
false
);
//获取结果的所有卡片
t
his
.
t
Cards
=
df
.
GetCardList
(
false
);
//获取结果的所有卡片
if
(
tCards
!=
null
)
if
(
t
his
.
t
Cards
!=
null
)
{
{
SetCopyNumber
(
tCards
.
Length
);
//显示复制卡片的数量
this
.
SetCopyNumber
(
this
.
tCards
.
Length
);
//显示复制卡片的数量
MyMsg
.
Show
(
LMSG
.
CopyCards
);
MyMsg
.
Show
(
LMSG
.
CopyCards
);
}
}
}
}
...
@@ -409,22 +452,31 @@ void Menuitem_copyallClick(object sender, EventArgs e)
...
@@ -409,22 +452,31 @@ void Menuitem_copyallClick(object sender, EventArgs e)
//显示复制卡片的数量
//显示复制卡片的数量
void
SetCopyNumber
(
int
c
)
void
SetCopyNumber
(
int
c
)
{
{
string
tmp
=
menuitem_pastecards
.
Text
;
string
tmp
=
this
.
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
;
this
.
menuitem_pastecards
.
Text
=
tmp
;
}
}
//粘贴卡片
//粘贴卡片
void
Menuitem_pastecardsClick
(
object
sender
,
EventArgs
e
)
void
Menuitem_pastecardsClick
(
object
sender
,
EventArgs
e
)
{
{
if
(
tCards
==
null
)
if
(
this
.
tCards
==
null
)
{
return
;
return
;
DataEditForm
df
=
GetActive
();
}
DataEditForm
df
=
this
.
GetActive
();
if
(
df
==
null
)
if
(
df
==
null
)
{
return
;
return
;
df
.
SaveCards
(
tCards
);
//保存卡片
}
df
.
SaveCards
(
this
.
tCards
);
//保存卡片
MyMsg
.
Show
(
LMSG
.
PasteCards
);
MyMsg
.
Show
(
LMSG
.
PasteCards
);
}
}
...
@@ -434,42 +486,47 @@ void Menuitem_pastecardsClick(object sender, EventArgs e)
...
@@ -434,42 +486,47 @@ void Menuitem_pastecardsClick(object sender, EventArgs e)
//设置数据库1
//设置数据库1
void
Menuitem_comp1Click
(
object
sender
,
EventArgs
e
)
void
Menuitem_comp1Click
(
object
sender
,
EventArgs
e
)
{
{
compare1
=
GetActive
();
this
.
compare1
=
this
.
GetActive
();
if
(
compare1
!=
null
&&
!
string
.
IsNullOrEmpty
(
compare1
.
GetOpenFile
()))
if
(
this
.
compare1
!=
null
&&
!
string
.
IsNullOrEmpty
(
this
.
compare1
.
GetOpenFile
()))
{
{
menuitem_comp2
.
Enabled
=
true
;
this
.
menuitem_comp2
.
Enabled
=
true
;
CompareDB
();
this
.
CompareDB
();
}
}
}
}
//设置数据库2
//设置数据库2
void
Menuitem_comp2Click
(
object
sender
,
EventArgs
e
)
void
Menuitem_comp2Click
(
object
sender
,
EventArgs
e
)
{
{
compare2
=
GetActive
();
this
.
compare2
=
this
.
GetActive
();
if
(
compare2
!=
null
&&
!
string
.
IsNullOrEmpty
(
compare2
.
GetOpenFile
()))
if
(
this
.
compare2
!=
null
&&
!
string
.
IsNullOrEmpty
(
this
.
compare2
.
GetOpenFile
()))
{
{
CompareDB
();
this
.
CompareDB
();
}
}
}
}
//对比数据库
//对比数据库
void
CompareDB
()
void
CompareDB
()
{
{
if
(
compare1
==
null
||
compare2
==
null
)
if
(
this
.
compare1
==
null
||
this
.
compare2
==
null
)
{
return
;
return
;
string
cdb1
=
compare1
.
GetOpenFile
();
}
string
cdb2
=
compare2
.
GetOpenFile
();
string
cdb1
=
this
.
compare1
.
GetOpenFile
();
string
cdb2
=
this
.
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
);
this
.
compare1
.
CompareCards
(
cdb2
,
checktext
);
compare2
.
CompareCards
(
cdb1
,
checktext
);
this
.
compare2
.
CompareCards
(
cdb1
,
checktext
);
MyMsg
.
Show
(
LMSG
.
CompareOK
);
MyMsg
.
Show
(
LMSG
.
CompareOK
);
menuitem_comp2
.
Enabled
=
false
;
this
.
menuitem_comp2
.
Enabled
=
false
;
compare1
=
null
;
this
.
compare1
=
null
;
compare2
=
null
;
this
.
compare2
=
null
;
}
}
#
endregion
#
endregion
...
@@ -477,14 +534,14 @@ void CompareDB()
...
@@ -477,14 +534,14 @@ void CompareDB()
#
region
后台加载数据
#
region
后台加载数据
private
void
bgWorker1_DoWork
(
object
sender
,
System
.
ComponentModel
.
DoWorkEventArgs
e
)
private
void
bgWorker1_DoWork
(
object
sender
,
System
.
ComponentModel
.
DoWorkEventArgs
e
)
{
{
Init
();
this
.
Init
();
}
}
private
void
bgWorker1_RunWorkerCompleted
(
object
sender
,
System
.
ComponentModel
.
RunWorkerCompletedEventArgs
e
)
private
void
bgWorker1_RunWorkerCompleted
(
object
sender
,
System
.
ComponentModel
.
RunWorkerCompletedEventArgs
e
)
{
{
//更新UI
//更新UI
InitForm
();
this
.
InitForm
();
}
}
#
endregion
#
endregion
...
@@ -492,10 +549,15 @@ private void MainForm_Load(object sender, EventArgs e)
...
@@ -492,10 +549,15 @@ 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
;
{
Thread
th
=
new
Thread
(
CheckUpdate
);
return
;
th
.
IsBackground
=
true
;
//如果exe结束,则线程终止
}
th
.
Start
();
Thread
th
=
new
Thread
(
this
.
CheckUpdate
)
{
IsBackground
=
true
//如果exe结束,则线程终止
};
th
.
Start
();
}
}
}
}
}
}
DataEditorX/Program.cs
View file @
bc0829bf
...
@@ -31,14 +31,16 @@ private static void Main(string[] args)
...
@@ -31,14 +31,16 @@ private static void Main(string[] args)
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
.
s
etOpenFile
(
arg
);
mainForm
.
S
etOpenFile
(
arg
);
//数据目录
//数据目录
mainForm
.
SetDataPath
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_DATA
));
mainForm
.
SetDataPath
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_DATA
));
...
...
DataEditorX/changed.txt
View file @
bc0829bf
★更新历史
★更新历史
2.4.3.7
增加了一些自动完成
2.4.3.6
2.4.3.6
UI位置调整
UI位置调整
2.4.3.5
2.4.3.5
...
...
DataEditorX/data/strings.conf
View file @
bc0829bf
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
!
system
94
是否现在使用这张卡的效果?
!
system
94
是否现在使用这张卡的效果?
!
system
95
是否使用[%
ls
]的效果?
!
system
95
是否使用[%
ls
]的效果?
!
system
96
是否使用[%
ls
]的效果代替破坏?
!
system
96
是否使用[%
ls
]的效果代替破坏?
!
system
97
是否把[%
ls
]在魔法与陷阱区域
放置
?
!
system
97
是否把[%
ls
]在魔法与陷阱区域
盖放
?
!
system
98
是否要解放对方怪兽?
!
system
98
是否要解放对方怪兽?
!
system
100
先攻
!
system
100
先攻
!
system
101
后攻
!
system
101
后攻
...
@@ -68,6 +68,15 @@
...
@@ -68,6 +68,15 @@
!
system
213
已选择种族:
!
system
213
已选择种族:
!
system
214
已选择属性:
!
system
214
已选择属性:
!
system
215
已选择数字:
!
system
215
已选择数字:
!
system
216
在连锁%
d
发动
!
system
217
被连锁%
d
的[%
ls
]选择为对象
!
system
218
是否使用[%
ls
]的效果代替支付基本分?
!
system
219
是否使用[%
ls
]的效果代替取除超量素材?
!
system
220
是否使用[%
ls
]的效果代替取除指示物?
!
system
221
是否在[%
ls
]发动[%
ls
]的诱发效果?
!
system
222
是否要发动诱发效果?
!
system
223
稍后将询问其他可以发动的效果。
!
system
224
已用正规方法特殊召唤
!
system
500
请选择要解放的卡
!
system
500
请选择要解放的卡
!
system
501
请选择要丢弃的手卡
!
system
501
请选择要丢弃的手卡
!
system
502
请选择要破坏的卡
!
system
502
请选择要破坏的卡
...
@@ -95,13 +104,14 @@
...
@@ -95,13 +104,14 @@
!
system
524
请选择里侧攻击表示的怪兽
!
system
524
请选择里侧攻击表示的怪兽
!
system
525
请选择里侧守备表示的怪兽
!
system
525
请选择里侧守备表示的怪兽
!
system
526
请选择给对方确认的卡
!
system
526
请选择给对方确认的卡
!
system
527
请选择要
放置
到场上的卡
!
system
527
请选择要
盖放
到场上的卡
!
system
528
请选择要改变表示形式的怪兽
!
system
528
请选择要改变表示形式的怪兽
!
system
529
请选择自己的卡
!
system
529
请选择自己的卡
!
system
530
请选择对方的卡
!
system
530
请选择对方的卡
!
system
531
请选择上级召唤用需要解放的怪兽
!
system
531
请选择上级召唤用需要解放的怪兽
!
system
532
请选择要取除超量素材的怪兽
!
system
532
请选择要取除超量素材的怪兽
!
system
533
请选择连接召唤的素材
!
system
533
请选择连接召唤的素材
!
system
534
请选择要保留在场上的卡
!
system
549
请选择攻击的对象
!
system
549
请选择攻击的对象
!
system
550
请选择要发动的效果
!
system
550
请选择要发动的效果
!
system
551
请选择效果的对象
!
system
551
请选择效果的对象
...
@@ -229,17 +239,23 @@
...
@@ -229,17 +239,23 @@
!
system
1150
发动
!
system
1150
发动
!
system
1151
召唤
!
system
1151
召唤
!
system
1152
特殊召唤
!
system
1152
特殊召唤
!
system
1153
放置
!
system
1153
盖放
!
system
1154
反转召唤
!
system
1154
反转召唤
!
system
1155
守备表示
!
system
1155
守备表示
!
system
1156
攻击表示
!
system
1156
攻击表示
!
system
1157
攻击
!
system
1157
攻击
!
system
1158
查看列表
!
system
1158
查看列表
!
system
1159
当魔法卡
放置
!
system
1159
当魔法卡
盖放
!
system
1160
在灵摆区域发动
!
system
1160
在灵摆区域发动
!
system
1161
效果处理
!
system
1161
效果处理
!
system
1162
效果重置
!
system
1162
效果重置
!
system
1163
灵摆召唤
!
system
1163
灵摆召唤
!
system
1164
同调召唤
!
system
1165
超量召唤
!
system
1166
连接召唤
!
system
1190
加入手卡
!
system
1191
送去墓地
!
system
1192
除外
#menu
#menu
!
system
1200
联机模式
!
system
1200
联机模式
!
system
1201
单人模式
!
system
1201
单人模式
...
@@ -305,7 +321,7 @@
...
@@ -305,7 +321,7 @@
!
system
1279
开启音效
!
system
1279
开启音效
!
system
1280
开启音乐
!
system
1280
开启音乐
!
system
1281
按场景切换音乐
!
system
1281
按场景切换音乐
!
system
1290
忽略对方发言
!
system
1290
禁用聊天功能
!
system
1291
忽略观战者发言
!
system
1291
忽略观战者发言
!
system
1292
忽略时点
!
system
1292
忽略时点
!
system
1293
显示时点
!
system
1293
显示时点
...
@@ -314,6 +330,7 @@
...
@@ -314,6 +330,7 @@
!
system
1296
完成选择
!
system
1296
完成选择
!
system
1297
切洗手卡
!
system
1297
切洗手卡
!
system
1298
辅助功能
!
system
1298
辅助功能
!
system
1299
加快动画效果
!
system
1300
禁限卡表:
!
system
1300
禁限卡表:
!
system
1301
卡组列表:
!
system
1301
卡组列表:
!
system
1302
保存
!
system
1302
保存
...
@@ -366,8 +383,6 @@
...
@@ -366,8 +383,6 @@
!
system
1351
投降
!
system
1351
投降
!
system
1352
主要信息:
!
system
1352
主要信息:
!
system
1353
播放起始于回合:
!
system
1353
播放起始于回合:
!
system
1354
不显示卡片系列
!
system
1355
不显示提示按钮
!
system
1356
是否要放弃对卡组的修改?
!
system
1356
是否要放弃对卡组的修改?
!
system
1357
不提示保留对卡组的修改
!
system
1357
不提示保留对卡组的修改
!
system
1358
键入关键字后自动进行搜索
!
system
1358
键入关键字后自动进行搜索
...
@@ -377,11 +392,15 @@
...
@@ -377,11 +392,15 @@
!
system
1363
是否删除这个录像?
!
system
1363
是否删除这个录像?
!
system
1364
重命名录像
!
system
1364
重命名录像
!
system
1365
重命名失败,可能存在同名文件
!
system
1365
重命名失败,可能存在同名文件
!
system
1366
自动保存录像
!
system
1367
录像已自动保存为%
ls
.
yrp
!
system
1370
星数↑
!
system
1370
星数↑
!
system
1371
攻击↑
!
system
1371
攻击↑
!
system
1372
守备↑
!
system
1372
守备↑
!
system
1373
名称↓
!
system
1373
名称↓
!
system
1374
连接标记
!
system
1374
连接标记
!
system
1378
使用多个关键词搜索卡片
!
system
1379
启用扩展卡包调试模式
!
system
1380
人机模式
!
system
1380
人机模式
!
system
1381
残局模式
!
system
1381
残局模式
!
system
1382
人机信息:
!
system
1382
人机信息:
...
@@ -412,6 +431,7 @@
...
@@ -412,6 +431,7 @@
!
system
1418
额外卡组数量应不超过
15
张,当前卡组数量为%
d
张。
!
system
1418
额外卡组数量应不超过
15
张,当前卡组数量为%
d
张。
!
system
1419
副卡组数量应不超过
15
张,当前卡组数量为%
d
张。
!
system
1419
副卡组数量应不超过
15
张,当前卡组数量为%
d
张。
!
system
1420
有额外卡组卡片存在于主卡组,可能是额外卡组数量超过
15
张。
!
system
1420
有额外卡组卡片存在于主卡组,可能是额外卡组数量超过
15
张。
!
system
1421
宣言的卡不符合条件,或无法被主机识别。
!
system
1500
决斗结束。
!
system
1500
决斗结束。
!
system
1501
录像结束。
!
system
1501
录像结束。
!
system
1502
连接已断开。
!
system
1502
连接已断开。
...
@@ -419,7 +439,7 @@
...
@@ -419,7 +439,7 @@
!
system
1511
对方宣言了:[%
ls
]
!
system
1511
对方宣言了:[%
ls
]
!
system
1512
对方选择了:[%
d
]
!
system
1512
对方选择了:[%
d
]
!
system
1600
卡片改变了表示形式
!
system
1600
卡片改变了表示形式
!
system
1601
放置
了卡片
!
system
1601
盖放
了卡片
!
system
1602
卡的控制权改变了
!
system
1602
卡的控制权改变了
!
system
1603
[%
ls
]召唤中
!
system
1603
[%
ls
]召唤中
!
system
1604
怪兽召唤成功
!
system
1604
怪兽召唤成功
...
@@ -464,6 +484,9 @@
...
@@ -464,6 +484,9 @@
!
victory
0
x1a
「魂之接力」效果胜利
!
victory
0
x1a
「魂之接力」效果胜利
!
victory
0
x1b
「鬼计惰天使」效果胜利
!
victory
0
x1b
「鬼计惰天使」效果胜利
!
victory
0
x1c
「幻煌龙的天涡」效果胜利
!
victory
0
x1c
「幻煌龙的天涡」效果胜利
!
victory
0
x1d
「方程式运动员胜利团队」效果胜利
!
victory
0
x1e
「飞行象」效果胜利
!
victory
0
x1f
「守护神 艾克佐迪亚」效果胜利
!
victory
0
x20
由于「%
ls
」的效果获得比赛胜利
!
victory
0
x20
由于「%
ls
」的效果获得比赛胜利
#counters
#counters
!
counter
0
x1
魔力指示物
!
counter
0
x1
魔力指示物
...
@@ -531,6 +554,14 @@
...
@@ -531,6 +554,14 @@
!
counter
0
x1045
鳞粉指示物
!
counter
0
x1045
鳞粉指示物
!
counter
0
x46
指示物(刚鬼死斗)
!
counter
0
x46
指示物(刚鬼死斗)
!
counter
0
x47
指示物(限制代码)
!
counter
0
x47
指示物(限制代码)
!
counter
0
x48
指示物(连接死亡炮塔)
!
counter
0
x1049
警逻指示物
!
counter
0
x4a
运动员指示物
!
counter
0
x4b
枪管指示物
!
counter
0
x4c
召唤指示物
!
counter
0
x104d
信号指示物
!
counter
0
x4e
指示物(魂之灵摆)
!
counter
0
x104f
蛊指示物
#setnames, using tab for comment
#setnames, using tab for comment
!
setname
0
x1
正义盟军
A
・
O
・
J
!
setname
0
x1
正义盟军
A
・
O
・
J
!
setname
0
x2
次世代 ジェネクス
!
setname
0
x2
次世代 ジェネクス
...
@@ -714,7 +745,7 @@
...
@@ -714,7 +745,7 @@
!
setname
0
x82
怒怒怒 ドドド
!
setname
0
x82
怒怒怒 ドドド
!
setname
0
x83
机关傀儡 ギミック・パペット
!
setname
0
x83
机关傀儡 ギミック・パペット
!
setname
0
x84
燃烧拳击手
BK
(バーニングナックラー)
!
setname
0
x84
燃烧拳击手
BK
(バーニングナックラー)
!
setname
0
x85
超级防
御
机器人
SD
ロボ
!
setname
0
x85
超级防
卫
机器人
SD
ロボ
!
setname
0
x86
光天使
!
setname
0
x86
光天使
!
setname
0
x87
阴影 アンブラル
!
setname
0
x87
阴影 アンブラル
!
setname
0
x88
武神
!
setname
0
x88
武神
...
@@ -725,7 +756,7 @@
...
@@ -725,7 +756,7 @@
#setname 0x8c 德鲁伊 ドルイド
#setname 0x8c 德鲁伊 ドルイド
!
setname
0
x8d
鬼计 ゴーストリック
!
setname
0
x8d
鬼计 ゴーストリック
!
setname
0
x8e
吸血鬼 ヴァンパイア
!
setname
0
x8e
吸血鬼 ヴァンパイア
!
setname
0
x8f
刷
啦啦
ズババ
!
setname
0
x8f
刷
拉拉
ズババ
!
setname
0
x90
森罗 森羅
!
setname
0
x90
森罗 森羅
!
setname
0
x91
王家长眠之谷 ネクロバレー
!
setname
0
x91
王家长眠之谷 ネクロバレー
!
setname
0
x92
纹章 メダリオン
!
setname
0
x92
纹章 メダリオン
...
@@ -792,6 +823,7 @@
...
@@ -792,6 +823,7 @@
!
setname
0
xbf
灵使 霊使い
!
setname
0
xbf
灵使 霊使い
!
setname
0
xc0
凭依装着 憑依装着
!
setname
0
xc0
凭依装着 憑依装着
!
setname
0
xc1
PSY
骨架
PSY
フレーム
!
setname
0
xc1
PSY
骨架
PSY
フレーム
!
setname
0
x10c1
PSY
骨架装备
PSY
フレームギア
!
setname
0
xc2
动力工具 パワー・ツール
!
setname
0
xc2
动力工具 パワー・ツール
!
setname
0
xc3
锋利小鬼 エッジインプ
!
setname
0
xc3
锋利小鬼 エッジインプ
!
setname
0
xc4
神数 セフィラ
!
setname
0
xc4
神数 セフィラ
...
@@ -814,9 +846,10 @@
...
@@ -814,9 +846,10 @@
!
setname
0
xd4
伯吉斯异兽 バージェストマ
!
setname
0
xd4
伯吉斯异兽 バージェストマ
!
setname
0
xd5
但丁 ダンテ
!
setname
0
xd5
但丁 ダンテ
!
setname
0
xd6
破坏剑 破壊剣
!
setname
0
xd6
破坏剑 破壊剣
!
setname
0
xd7
巴斯达·布雷达
バスター・ブレイダー
!
setname
0
xd7
破坏之剑士
バスター・ブレイダー
!
setname
0
xd8
雾动机龙 ダイナミスト
!
setname
0
xd8
雾动机龙 ダイナミスト
!
setname
0
xd9
不知火
!
setname
0
xd9
不知火
!
setname
0
x10d9
妖刀-不知火 妖刀-不知火
!
setname
0
xda
龙魔王 竜魔王
!
setname
0
xda
龙魔王 竜魔王
!
setname
0
xdb
幻影 ファントム
!
setname
0
xdb
幻影 ファントム
!
setname
0
x10db
幻影骑士团 幻影騎士団
!
setname
0
x10db
幻影骑士团 幻影騎士団
...
@@ -891,3 +924,23 @@
...
@@ -891,3 +924,23 @@
!
setname
0
x114
空牙团 空牙団
!
setname
0
x114
空牙团 空牙団
!
setname
0
x115
闪刀 閃刀
!
setname
0
x115
闪刀 閃刀
!
setname
0
x1115
闪刀姬 閃刀姫
!
setname
0
x1115
闪刀姬 閃刀姫
!
setname
0
x116
圣像骑士 パラディオン
!
setname
0
x117
魔神仪 魔神儀
!
setname
0
x118
电脑网 サイバネット
!
setname
0
x119
转生炎兽 サラマングレイト
!
setname
0
x11a
恐龙摔跤手 ダイナレスラー
!
setname
0
x11b
自奏圣乐 オルフェゴール
!
setname
0
x11c
雷龙 サンダー·ドラゴン
!
setname
0
x11d
禁忌的 禁じられた
!
setname
0
x11e
危险!
Danger
!
!
setname
0
x11f
奈芙提斯 ネフティス
!
setname
0
x120
调皮宝贝 プランキッズ
!
setname
0
x121
魔妖
!
setname
0
x122
女武神
Valkyrie
!
setname
0
x123
蔷薇龙 ローズ・ドラゴン
!
setname
0
x124
机械天使 機械天使
!
setname
0
x125
笑容 スマイル
!
setname
0
x126
时间怪盗
Time
Thief
!
setname
0
x127
无限起动 無限起動
!
setname
0
x128
魔女术 ウィッチクラフト
!
setname
0
x129
咒眼 呪眼
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