Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Ftt_Common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Ftt_Common
Commits
65c771d2
Commit
65c771d2
authored
Oct 18, 2025
by
罗显健
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【编号:24022】1.表开发工具优化:增加搜索面板 2.工具主界面菜单增加可折叠功能。
本次更新90%+的代码由AI生成。
parent
fd287c75
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
866 additions
and
197 deletions
+866
-197
Common.cs
Tools/MyCommon/Common.cs
+17
-2
Utils.cs
Tools/MyUtils/Utils.cs
+93
-2
wSysSetting.cs
Tools/MyUtils/wSysSetting.cs
+11
-53
wUploadUpdate.cs
Tools/UI/sys/wUploadUpdate.cs
+21
-10
wDBTableDevelopTools.Designer.cs
Tools/UI/wDBTableDevelopTools.Designer.cs
+207
-86
wDBTableDevelopTools.cs
Tools/UI/wDBTableDevelopTools.cs
+432
-32
wSysModule.cs
Tools/UI/wSysModule.cs
+3
-4
wXmlGenerator.cs
Tools/UI/wXmlGenerator.cs
+5
-2
wMain.Designer.cs
Tools/wMain.Designer.cs
+22
-2
wMain.cs
Tools/wMain.cs
+54
-3
wMain.resx
Tools/wMain.resx
+1
-1
No files found.
Tools/MyCommon/Common.cs
View file @
65c771d2
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -34,7 +34,7 @@ namespace Tools.MyCommon
/// <summary>
/// 用户信息
/// </summary>
public
static
class
LoginInfo
public
static
class
LoginInfo
{
/// <summary>
/// 用户名
...
...
@@ -121,6 +121,21 @@ namespace Tools.MyCommon
/// 默认Excel/Word文件导出路径
/// </summary>
public
static
string
DocExportPath
=>
"DocExportPath"
;
/// <summary>
/// 表设计器右侧面板展开状态
/// </summary>
public
static
string
DBTableDevelop_RightPanelExpanded
=>
"DBTableDevelop_RightPanelExpanded"
;
/// <summary>
/// 表设计器搜索类型(表/列)
/// </summary>
public
static
string
DBTableDevelop_SearchType
=>
"DBTableDevelop_SearchType"
;
/// <summary>
/// 表设计器是否搜索描述
/// </summary>
public
static
string
DBTableDevelop_SearchDesc
=>
"DBTableDevelop_SearchDesc"
;
}
/// <summary>
/// 导出类型
...
...
Tools/MyUtils/Utils.cs
View file @
65c771d2
...
...
@@ -57,7 +57,7 @@ namespace Tools.MyUtils
/// <summary>
/// 打包工具、更新包生成目录
/// </summary>
public
static
string
PackagePath
=>
$@"
{
Application
.
StartupPath
}
\Package"
;
public
static
string
PackagePath
=>
$@"
{
Application
.
StartupPath
}
\Package"
;
#
endregion
#
region
常用日期
...
...
@@ -188,6 +188,83 @@ namespace Tools.MyUtils
}
#
endregion
#
region
读写系统配置文件
(
XML
)
/// <summary>
/// 读取系统配置表(AppSetting)
/// </summary>
/// <returns>配置数据表</returns>
public
static
DataTable
ReadSysConfig
()
{
var
dtSetting
=
new
DataTable
(
"AppSetting"
);
if
(
File
.
Exists
(
SysConfigFilePath
))
{
dtSetting
.
ReadXml
(
SysConfigFilePath
);
}
return
dtSetting
;
}
/// <summary>
/// 保存系统配置表(AppSetting)
/// </summary>
/// <param name="dtSetting">配置数据表</param>
public
static
void
SaveSysConfig
(
DataTable
dtSetting
)
{
if
(
dtSetting
!=
null
)
{
dtSetting
.
WriteXml
(
SysConfigFilePath
,
XmlWriteMode
.
WriteSchema
);
}
}
/// <summary>
/// 从配置表中获取指定配置值
/// </summary>
/// <param name="dt">配置数据表</param>
/// <param name="name">配置名称</param>
/// <returns>配置值</returns>
public
static
string
GetConfigValue
(
DataTable
dt
,
string
name
)
{
if
(
dt
==
null
)
return
string
.
Empty
;
var
rows
=
dt
.
Select
(
$"Name='
{
name
}
'"
);
return
rows
.
Length
>
0
?
rows
[
0
][
"Value"
].
ToString
()
:
string
.
Empty
;
}
/// <summary>
/// 在配置表中设置指定配置值(存在则更新,不存在则新增)
/// </summary>
/// <param name="dt">配置数据表</param>
/// <param name="name">配置名称</param>
/// <param name="value">配置值</param>
public
static
void
SetConfigValue
(
DataTable
dt
,
string
name
,
string
value
)
{
if
(
dt
==
null
)
return
;
var
rows
=
dt
.
Select
(
$"Name='
{
name
}
'"
);
if
(
rows
.
Length
>
0
)
{
rows
[
0
][
"Value"
]
=
value
;
rows
[
0
].
EndEdit
();
}
else
{
var
newRow
=
dt
.
NewRow
();
newRow
[
"Name"
]
=
name
;
newRow
[
"Value"
]
=
value
;
dt
.
Rows
.
Add
(
newRow
);
}
}
/// <summary>
/// 读取系统配置并转换为字典
/// </summary>
/// <returns>配置字典</returns>
public
static
Dictionary
<
string
,
string
>
ReadSysConfigAsDictionary
()
{
var
dtSetting
=
ReadSysConfig
();
return
dtSetting
.
Rows
.
Cast
<
DataRow
>()
.
ToDictionary
(
x
=>
x
[
"Name"
].
ToString
(),
x
=>
x
[
"Value"
].
ToString
());
}
#
endregion
#
region
读写
json
配置文件
...
...
@@ -244,6 +321,7 @@ namespace Tools.MyUtils
}
#
endregion
#
region
选择文件
/
路径
/// <summary>
...
...
@@ -289,6 +367,18 @@ namespace Tools.MyUtils
return
result
;
}
/// <summary>
/// 创建目录
/// </summary>
/// <param name="path"></param>
public
static
void
CreatePathIfNotExists
(
string
path
)
{
if
(!
Directory
.
Exists
(
path
))
{
Directory
.
CreateDirectory
(
path
);
}
}
#
endregion
#
region
检查文件大小
...
...
@@ -332,7 +422,8 @@ namespace Tools.MyUtils
//EntryName用以指定压缩层级
string
EntryName
=
path
.
Substring
(
$@"
{
rootPath
}
\"
.
Length
);
//这里取根目录的相对路径
//创建新入口
ZipEntry
entry
=
new
ZipEntry
(
EntryName
)
{
ZipEntry
entry
=
new
ZipEntry
(
EntryName
)
{
DateTime
=
DateTime
.
Now
};
zip
.
PutNextEntry
(
entry
);
...
...
Tools/MyUtils/wSysSetting.cs
View file @
65c771d2
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System
;
using
System.Data
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
//
using
Tools.MyCommon
;
using
Tools.MyData
;
using
Tools.MyUtils
;
namespace
Tools.MyUtils
{
...
...
@@ -40,15 +32,14 @@ namespace Tools.MyUtils
private
void
wSysSetting_Load
(
object
sender
,
EventArgs
e
)
{
//读取设置信息
dtSetting
=
new
DataTable
(
"AppSetting"
);
dtSetting
.
ReadXml
(
Utils
.
SysConfigFilePath
);
dtSetting
=
Utils
.
ReadSysConfig
();
//填充界面
var
linkString
=
this
.
Get
Value
(
dtSetting
,
ConfigType
.
DefaultLink
);
var
linkString
=
Utils
.
GetConfig
Value
(
dtSetting
,
ConfigType
.
DefaultLink
);
this
.
LinkModel
=
Utils
.
GetDbItemModel
(
linkString
);
this
.
tbDefaultLink
.
Text
=
this
.
LinkModel
.
ToString
();
this
.
tbModelExportPath
.
Text
=
this
.
Get
Value
(
dtSetting
,
ConfigType
.
ModelExportPath
);
this
.
tbSqlExportPath
.
Text
=
this
.
Get
Value
(
dtSetting
,
ConfigType
.
SqlExportPath
);
this
.
tbDocExportPath
.
Text
=
this
.
Get
Value
(
dtSetting
,
ConfigType
.
DocExportPath
);
this
.
tbModelExportPath
.
Text
=
Utils
.
GetConfig
Value
(
dtSetting
,
ConfigType
.
ModelExportPath
);
this
.
tbSqlExportPath
.
Text
=
Utils
.
GetConfig
Value
(
dtSetting
,
ConfigType
.
SqlExportPath
);
this
.
tbDocExportPath
.
Text
=
Utils
.
GetConfig
Value
(
dtSetting
,
ConfigType
.
DocExportPath
);
//绑定事件
this
.
btnSelectDbLink
.
Click
+=
BtnSelectDbLink_Click
;
this
.
btnSelectModelPath
.
Click
+=
BtnSelectModelPath_Click
;
...
...
@@ -106,46 +97,15 @@ namespace Tools.MyUtils
private
void
BtnSave_Click
(
object
sender
,
EventArgs
e
)
{
//将设置写入结构表
this
.
Set
Value
(
dtSetting
,
ConfigType
.
DefaultLink
,
this
.
LinkModel
.
LinkString
);
this
.
Set
Value
(
dtSetting
,
ConfigType
.
ModelExportPath
,
this
.
tbModelExportPath
.
Text
);
this
.
Set
Value
(
dtSetting
,
ConfigType
.
SqlExportPath
,
this
.
tbSqlExportPath
.
Text
);
this
.
Set
Value
(
dtSetting
,
ConfigType
.
DocExportPath
,
this
.
tbDocExportPath
.
Text
);
Utils
.
SetConfig
Value
(
dtSetting
,
ConfigType
.
DefaultLink
,
this
.
LinkModel
.
LinkString
);
Utils
.
SetConfig
Value
(
dtSetting
,
ConfigType
.
ModelExportPath
,
this
.
tbModelExportPath
.
Text
);
Utils
.
SetConfig
Value
(
dtSetting
,
ConfigType
.
SqlExportPath
,
this
.
tbSqlExportPath
.
Text
);
Utils
.
SetConfig
Value
(
dtSetting
,
ConfigType
.
DocExportPath
,
this
.
tbDocExportPath
.
Text
);
//保存设置
dtSetting
.
WriteXml
(
Utils
.
SysConfigFilePath
,
XmlWriteMode
.
WriteSchema
);
Utils
.
SaveSysConfig
(
dtSetting
);
this
.
DialogResult
=
DialogResult
.
OK
;
}
/// <summary>
/// 获取指定配置值
/// </summary>
/// <param name="dt"></param>
/// <param name="name"></param>
/// <returns></returns>
private
string
GetValue
(
DataTable
dt
,
string
name
)
{
var
result
=
""
;
var
rows
=
dt
.
Select
(
$"Name='
{
name
}
'"
);
if
(
rows
.
Length
>
0
)
{
result
=
rows
[
0
][
"Value"
].
ToString
();
}
return
result
;
}
/// <summary>
/// 设置指定配置值
/// </summary>
/// <param name="dt"></param>
/// <param name="name"></param>
/// <param name="value"></param>
private
void
SetValue
(
DataTable
dt
,
string
name
,
string
value
)
{
var
rows
=
dt
.
Select
(
$"Name='
{
name
}
'"
);
if
(
rows
.
Length
>
0
)
{
rows
[
0
][
"Value"
]
=
value
;
rows
[
0
].
EndEdit
();
}
}
/// <summary>
/// 选择路径并赋值到文本框
/// </summary>
...
...
@@ -158,7 +118,5 @@ namespace Tools.MyUtils
tb
.
Text
=
frm
.
SelectedPath
;
}
}
}
}
Tools/UI/sys/wUploadUpdate.cs
View file @
65c771d2
...
...
@@ -99,16 +99,7 @@ namespace Tools.UI.sys
//打包所有文件
DirectoryInfo
dirInfo
=
new
DirectoryInfo
(
path
);
var
fileInfos
=
dirInfo
.
GetFiles
(
"*.*"
,
SearchOption
.
AllDirectories
).
ToList
();
fileInfos
=
fileInfos
.
Where
(
f
=>
!
f
.
FullName
.
Contains
(
"\\AutoUpdate\\"
)
//剔除自动更新文件
&&
!
f
.
FullName
.
Contains
(
Utils
.
LogPath
)
&&
!
f
.
FullName
.
Contains
(
Utils
.
TempPath
)
//日志、临时文件目录
&&
!
f
.
FullName
.
Contains
(
Utils
.
SavePath
)
// 系统预设的用户本地文件目录,需要排除
&&
!
f
.
FullName
.
Contains
(
Utils
.
PackagePath
)
//程序更新打包目录
&&
!
f
.
Name
.
Equals
(
"links.xml"
)
//剔除链接记录文件(本地常用数据库链接记录)
&&
!
f
.
Name
.
Equals
(
"sys_cfg.xml"
)
//剔除(表开发工具-系统配置)文件
&&
!
f
.
Extension
.
Equals
(
".json"
)
//剔除json配置信息
&&
!
f
.
Extension
.
Equals
(
""
)
//剔除无扩展名的文件(大部分是临时文件)
).
ToList
();
//剔除自动更新相关目录
fileInfos
=
fileInfos
.
Where
(
f
=>
!
IsFileIgnore
(
f
)).
ToList
();
//剔除自动更新相关目录
//构造压缩文件路径集合
List
<
string
>
FileNames
=
new
List
<
string
>();
FileNames
.
AddRange
(
fileInfos
.
Select
(
f
=>
f
.
FullName
));
...
...
@@ -138,6 +129,26 @@ namespace Tools.UI.sys
this
.
AsyncUI
(()
=>
this
.
_bar
.
Close
());
});
}
/// <summary>
/// 是否为需要剔除的文件
/// </summary>
/// <param name="f"></param>
/// <returns></returns>
private
bool
IsFileIgnore
(
FileInfo
f
)
{
return
f
.
FullName
.
Contains
(
"\\AutoUpdate\\"
)
//剔除自动更新文件
||
f
.
FullName
.
Contains
(
Utils
.
LogPath
)
//日志、
||
f
.
FullName
.
Contains
(
Utils
.
TempPath
)
//临时文件目录
||
f
.
FullName
.
Contains
(
Utils
.
SavePath
)
// 系统预设的用户本地文件目录,需要排除
||
f
.
FullName
.
Contains
(
Utils
.
PackagePath
)
//程序更新打包目录
||
f
.
Name
.
Equals
(
"links.xml"
)
//剔除链接记录文件(本地常用数据库链接记录)
||
f
.
Name
.
Equals
(
"sys_cfg.xml"
)
//剔除(表开发工具-系统配置)文件
||
f
.
Extension
.
Equals
(
".json"
)
//剔除json配置信息
||
f
.
FullName
.
Contains
(
"\\WebKit\\"
)
//剔除WebKit相关文件,太大了。
||
f
.
Extension
.
Equals
(
""
);
//剔除无扩展名的文件(大部分是临时文件)
}
private
void
btnSave_Click
(
object
sender
,
EventArgs
e
)
{
this
.
Save
();
...
...
Tools/UI/wDBTableDevelopTools.Designer.cs
View file @
65c771d2
namespace
Tools.UI
namespace
Tools.UI
{
partial
class
wDBTableDevelopTools
{
...
...
@@ -48,13 +48,6 @@
this
.
toolStripSeparator3
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
tsbHelp
=
new
System
.
Windows
.
Forms
.
ToolStripButton
();
this
.
dgvData
=
new
System
.
Windows
.
Forms
.
DataGridView
();
this
.
Column1
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
Column6
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
Column2
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
Column3
=
new
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
();
this
.
Column4
=
new
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
();
this
.
Column7
=
new
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
();
this
.
Column5
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
contextMenuStrip1
=
new
System
.
Windows
.
Forms
.
ContextMenuStrip
(
this
.
components
);
this
.
tsmiAddRow
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
tsmiDelRow
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
...
...
@@ -63,10 +56,28 @@
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbTableName
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbTableDescription
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
panel1
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
lstResult
=
new
System
.
Windows
.
Forms
.
ListBox
();
this
.
tbSearch
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
panel2
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
ckbSearchDesc
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
radBtnColumn
=
new
System
.
Windows
.
Forms
.
RadioButton
();
this
.
radBtnTable
=
new
System
.
Windows
.
Forms
.
RadioButton
();
this
.
btnToggle
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
radioButton2
=
new
System
.
Windows
.
Forms
.
RadioButton
();
this
.
FieldName
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
Description
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
ColumnType
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
IsNotNull
=
new
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
();
this
.
IsPrimaryKey
=
new
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
();
this
.
IsAutoIncrement
=
new
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
();
this
.
DefaultValue
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
toolStrip1
.
SuspendLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
dgvData
)).
BeginInit
();
this
.
contextMenuStrip1
.
SuspendLayout
();
this
.
tableLayoutPanel1
.
SuspendLayout
();
this
.
panel1
.
SuspendLayout
();
this
.
panel2
.
SuspendLayout
();
this
.
SuspendLayout
();
//
// toolStrip1
...
...
@@ -218,14 +229,14 @@
this
.
dgvData
.
BackgroundColor
=
System
.
Drawing
.
SystemColors
.
Window
;
this
.
dgvData
.
ColumnHeadersHeightSizeMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnHeadersHeightSizeMode
.
AutoSize
;
this
.
dgvData
.
Columns
.
AddRange
(
new
System
.
Windows
.
Forms
.
DataGridViewColumn
[]
{
this
.
Column1
,
this
.
Column6
,
this
.
Column
2
,
this
.
Column3
,
this
.
Column4
,
this
.
Column7
,
this
.
Column5
});
this
.
tableLayoutPanel1
.
SetColumnSpan
(
this
.
dgvData
,
8
);
this
.
FieldName
,
this
.
Description
,
this
.
Column
Type
,
this
.
IsNotNull
,
this
.
IsPrimaryKey
,
this
.
IsAutoIncrement
,
this
.
DefaultValue
});
this
.
tableLayoutPanel1
.
SetColumnSpan
(
this
.
dgvData
,
4
);
this
.
dgvData
.
ContextMenuStrip
=
this
.
contextMenuStrip1
;
this
.
dgvData
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
dgvData
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
31
);
...
...
@@ -233,59 +244,9 @@
this
.
dgvData
.
Name
=
"dgvData"
;
this
.
tableLayoutPanel1
.
SetRowSpan
(
this
.
dgvData
,
2
);
this
.
dgvData
.
RowTemplate
.
Height
=
23
;
this
.
dgvData
.
Size
=
new
System
.
Drawing
.
Size
(
927
,
516
);
this
.
dgvData
.
Size
=
new
System
.
Drawing
.
Size
(
650
,
516
);
this
.
dgvData
.
TabIndex
=
1
;
//
// Column1
//
this
.
Column1
.
DataPropertyName
=
"FieldName"
;
this
.
Column1
.
HeaderText
=
"字段"
;
this
.
Column1
.
Name
=
"Column1"
;
//
// Column6
//
this
.
Column6
.
DataPropertyName
=
"Description"
;
this
.
Column6
.
HeaderText
=
"说明"
;
this
.
Column6
.
Name
=
"Column6"
;
//
// Column2
//
this
.
Column2
.
DataPropertyName
=
"ColumnType"
;
this
.
Column2
.
HeaderText
=
"类型"
;
this
.
Column2
.
Name
=
"Column2"
;
this
.
Column2
.
Resizable
=
System
.
Windows
.
Forms
.
DataGridViewTriState
.
True
;
this
.
Column2
.
Width
=
150
;
//
// Column3
//
this
.
Column3
.
DataPropertyName
=
"IsNotNull"
;
this
.
Column3
.
HeaderText
=
"非空"
;
this
.
Column3
.
Name
=
"Column3"
;
this
.
Column3
.
Resizable
=
System
.
Windows
.
Forms
.
DataGridViewTriState
.
True
;
this
.
Column3
.
SortMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnSortMode
.
Automatic
;
//
// Column4
//
this
.
Column4
.
DataPropertyName
=
"IsPrimaryKey"
;
this
.
Column4
.
HeaderText
=
"主键"
;
this
.
Column4
.
Name
=
"Column4"
;
this
.
Column4
.
Resizable
=
System
.
Windows
.
Forms
.
DataGridViewTriState
.
True
;
this
.
Column4
.
SortMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnSortMode
.
Automatic
;
//
// Column7
//
this
.
Column7
.
DataPropertyName
=
"IsAutoIncrement"
;
this
.
Column7
.
HeaderText
=
"自增"
;
this
.
Column7
.
Name
=
"Column7"
;
this
.
Column7
.
Resizable
=
System
.
Windows
.
Forms
.
DataGridViewTriState
.
True
;
this
.
Column7
.
SortMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnSortMode
.
Automatic
;
//
// Column5
//
this
.
Column5
.
DataPropertyName
=
"DefaultValue"
;
this
.
Column5
.
HeaderText
=
"默认值"
;
this
.
Column5
.
Name
=
"Column5"
;
//
// contextMenuStrip1
//
this
.
contextMenuStrip1
.
Items
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
...
...
@@ -308,20 +269,20 @@
//
// tableLayoutPanel1
//
this
.
tableLayoutPanel1
.
ColumnCount
=
8
;
this
.
tableLayoutPanel1
.
ColumnCount
=
6
;
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Absolute
,
75F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
4
0F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
5
0F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Absolute
,
75F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
40F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
5F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
5F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
5F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
5F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
50F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Absolute
,
15F
));
this
.
tableLayoutPanel1
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Absolute
,
262F
));
this
.
tableLayoutPanel1
.
Controls
.
Add
(
this
.
dgvData
,
0
,
1
);
this
.
tableLayoutPanel1
.
Controls
.
Add
(
this
.
label1
,
0
,
0
);
this
.
tableLayoutPanel1
.
Controls
.
Add
(
this
.
label2
,
2
,
0
);
this
.
tableLayoutPanel1
.
Controls
.
Add
(
this
.
tbTableName
,
1
,
0
);
this
.
tableLayoutPanel1
.
Controls
.
Add
(
this
.
tbTableDescription
,
3
,
0
);
this
.
tableLayoutPanel1
.
Controls
.
Add
(
this
.
panel1
,
5
,
0
);
this
.
tableLayoutPanel1
.
Controls
.
Add
(
this
.
btnToggle
,
4
,
1
);
this
.
tableLayoutPanel1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
tableLayoutPanel1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
24
);
this
.
tableLayoutPanel1
.
Name
=
"tableLayoutPanel1"
;
...
...
@@ -345,7 +306,7 @@
// label2
//
this
.
label2
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
3
9
1
,
0
);
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
3
3
1
,
0
);
this
.
label2
.
Name
=
"label2"
;
this
.
label2
.
Size
=
new
System
.
Drawing
.
Size
(
69
,
27
);
this
.
label2
.
TabIndex
=
3
;
...
...
@@ -357,17 +318,165 @@
this
.
tbTableName
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
tbTableName
.
Location
=
new
System
.
Drawing
.
Point
(
78
,
3
);
this
.
tbTableName
.
Name
=
"tbTableName"
;
this
.
tbTableName
.
Size
=
new
System
.
Drawing
.
Size
(
30
7
,
23
);
this
.
tbTableName
.
Size
=
new
System
.
Drawing
.
Size
(
24
7
,
23
);
this
.
tbTableName
.
TabIndex
=
4
;
//
// tbTableDescription
//
this
.
tbTableDescription
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
tbTableDescription
.
Location
=
new
System
.
Drawing
.
Point
(
4
6
6
,
3
);
this
.
tbTableDescription
.
Location
=
new
System
.
Drawing
.
Point
(
4
0
6
,
3
);
this
.
tbTableDescription
.
Name
=
"tbTableDescription"
;
this
.
tbTableDescription
.
Size
=
new
System
.
Drawing
.
Size
(
30
7
,
23
);
this
.
tbTableDescription
.
Size
=
new
System
.
Drawing
.
Size
(
24
7
,
23
);
this
.
tbTableDescription
.
TabIndex
=
5
;
//
// panel1
//
this
.
panel1
.
Controls
.
Add
(
this
.
lstResult
);
this
.
panel1
.
Controls
.
Add
(
this
.
tbSearch
);
this
.
panel1
.
Controls
.
Add
(
this
.
panel2
);
this
.
panel1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
panel1
.
Location
=
new
System
.
Drawing
.
Point
(
674
,
3
);
this
.
panel1
.
Name
=
"panel1"
;
this
.
tableLayoutPanel1
.
SetRowSpan
(
this
.
panel1
,
3
);
this
.
panel1
.
Size
=
new
System
.
Drawing
.
Size
(
256
,
545
);
this
.
panel1
.
TabIndex
=
6
;
//
// lstResult
//
this
.
lstResult
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
lstResult
.
FormattingEnabled
=
true
;
this
.
lstResult
.
ItemHeight
=
17
;
this
.
lstResult
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
44
);
this
.
lstResult
.
Name
=
"lstResult"
;
this
.
lstResult
.
Size
=
new
System
.
Drawing
.
Size
(
256
,
501
);
this
.
lstResult
.
TabIndex
=
1
;
//
// tbSearch
//
this
.
tbSearch
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
tbSearch
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
21
);
this
.
tbSearch
.
Name
=
"tbSearch"
;
this
.
tbSearch
.
Size
=
new
System
.
Drawing
.
Size
(
256
,
23
);
this
.
tbSearch
.
TabIndex
=
0
;
this
.
tbSearch
.
KeyDown
+=
new
System
.
Windows
.
Forms
.
KeyEventHandler
(
this
.
tbSearch_KeyDown
);
//
// panel2
//
this
.
panel2
.
Controls
.
Add
(
this
.
ckbSearchDesc
);
this
.
panel2
.
Controls
.
Add
(
this
.
radBtnColumn
);
this
.
panel2
.
Controls
.
Add
(
this
.
radBtnTable
);
this
.
panel2
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
panel2
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
panel2
.
Name
=
"panel2"
;
this
.
panel2
.
Size
=
new
System
.
Drawing
.
Size
(
256
,
21
);
this
.
panel2
.
TabIndex
=
7
;
//
// ckbSearchDesc
//
this
.
ckbSearchDesc
.
AutoSize
=
true
;
this
.
ckbSearchDesc
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Right
;
this
.
ckbSearchDesc
.
Location
=
new
System
.
Drawing
.
Point
(
193
,
0
);
this
.
ckbSearchDesc
.
Name
=
"ckbSearchDesc"
;
this
.
ckbSearchDesc
.
Size
=
new
System
.
Drawing
.
Size
(
63
,
21
);
this
.
ckbSearchDesc
.
TabIndex
=
2
;
this
.
ckbSearchDesc
.
Text
=
"搜说明"
;
this
.
ckbSearchDesc
.
UseVisualStyleBackColor
=
true
;
//
// radBtnColumn
//
this
.
radBtnColumn
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
this
.
radBtnColumn
.
Location
=
new
System
.
Drawing
.
Point
(
80
,
0
);
this
.
radBtnColumn
.
Name
=
"radBtnColumn"
;
this
.
radBtnColumn
.
Size
=
new
System
.
Drawing
.
Size
(
80
,
21
);
this
.
radBtnColumn
.
TabIndex
=
1
;
this
.
radBtnColumn
.
Text
=
"列"
;
this
.
radBtnColumn
.
UseVisualStyleBackColor
=
true
;
//
// radBtnTable
//
this
.
radBtnTable
.
Checked
=
true
;
this
.
radBtnTable
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
this
.
radBtnTable
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
radBtnTable
.
Name
=
"radBtnTable"
;
this
.
radBtnTable
.
Size
=
new
System
.
Drawing
.
Size
(
80
,
21
);
this
.
radBtnTable
.
TabIndex
=
0
;
this
.
radBtnTable
.
TabStop
=
true
;
this
.
radBtnTable
.
Text
=
"表"
;
this
.
radBtnTable
.
UseVisualStyleBackColor
=
true
;
//
// btnToggle
//
this
.
btnToggle
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
btnToggle
.
Font
=
new
System
.
Drawing
.
Font
(
"Microsoft Sans Serif"
,
9F
,
System
.
Drawing
.
FontStyle
.
Bold
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnToggle
.
Location
=
new
System
.
Drawing
.
Point
(
656
,
27
);
this
.
btnToggle
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
btnToggle
.
Name
=
"btnToggle"
;
this
.
tableLayoutPanel1
.
SetRowSpan
(
this
.
btnToggle
,
2
);
this
.
btnToggle
.
Size
=
new
System
.
Drawing
.
Size
(
15
,
524
);
this
.
btnToggle
.
TabIndex
=
8
;
this
.
btnToggle
.
Text
=
">"
;
this
.
btnToggle
.
UseVisualStyleBackColor
=
true
;
//
// radioButton2
//
this
.
radioButton2
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
radioButton2
.
Name
=
"radioButton2"
;
this
.
radioButton2
.
Size
=
new
System
.
Drawing
.
Size
(
104
,
24
);
this
.
radioButton2
.
TabIndex
=
0
;
//
// FieldName
//
this
.
FieldName
.
DataPropertyName
=
"FieldName"
;
this
.
FieldName
.
HeaderText
=
"字段"
;
this
.
FieldName
.
Name
=
"FieldName"
;
//
// Description
//
this
.
Description
.
DataPropertyName
=
"Description"
;
this
.
Description
.
HeaderText
=
"说明"
;
this
.
Description
.
Name
=
"Description"
;
//
// ColumnType
//
this
.
ColumnType
.
DataPropertyName
=
"ColumnType"
;
this
.
ColumnType
.
HeaderText
=
"类型"
;
this
.
ColumnType
.
Name
=
"ColumnType"
;
this
.
ColumnType
.
Resizable
=
System
.
Windows
.
Forms
.
DataGridViewTriState
.
True
;
this
.
ColumnType
.
Width
=
150
;
//
// IsNotNull
//
this
.
IsNotNull
.
DataPropertyName
=
"IsNotNull"
;
this
.
IsNotNull
.
HeaderText
=
"非空"
;
this
.
IsNotNull
.
Name
=
"IsNotNull"
;
this
.
IsNotNull
.
Resizable
=
System
.
Windows
.
Forms
.
DataGridViewTriState
.
True
;
this
.
IsNotNull
.
SortMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnSortMode
.
Automatic
;
this
.
IsNotNull
.
Width
=
65
;
//
// IsPrimaryKey
//
this
.
IsPrimaryKey
.
DataPropertyName
=
"IsPrimaryKey"
;
this
.
IsPrimaryKey
.
HeaderText
=
"主键"
;
this
.
IsPrimaryKey
.
Name
=
"IsPrimaryKey"
;
this
.
IsPrimaryKey
.
Resizable
=
System
.
Windows
.
Forms
.
DataGridViewTriState
.
True
;
this
.
IsPrimaryKey
.
SortMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnSortMode
.
Automatic
;
this
.
IsPrimaryKey
.
Width
=
65
;
//
// IsAutoIncrement
//
this
.
IsAutoIncrement
.
DataPropertyName
=
"IsAutoIncrement"
;
this
.
IsAutoIncrement
.
HeaderText
=
"自增"
;
this
.
IsAutoIncrement
.
Name
=
"IsAutoIncrement"
;
this
.
IsAutoIncrement
.
Resizable
=
System
.
Windows
.
Forms
.
DataGridViewTriState
.
True
;
this
.
IsAutoIncrement
.
SortMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnSortMode
.
Automatic
;
this
.
IsAutoIncrement
.
Width
=
65
;
//
// DefaultValue
//
this
.
DefaultValue
.
DataPropertyName
=
"DefaultValue"
;
this
.
DefaultValue
.
HeaderText
=
"默认值"
;
this
.
DefaultValue
.
Name
=
"DefaultValue"
;
//
// wDBTableDevelopTools
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
7F
,
17F
);
...
...
@@ -375,7 +484,6 @@
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
933
,
575
);
this
.
Controls
.
Add
(
this
.
tableLayoutPanel1
);
this
.
Controls
.
Add
(
this
.
toolStrip1
);
this
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
3
,
4
,
3
,
4
);
this
.
Name
=
"wDBTableDevelopTools"
;
this
.
Text
=
"数据库表开发工具"
;
...
...
@@ -386,6 +494,10 @@
this
.
contextMenuStrip1
.
ResumeLayout
(
false
);
this
.
tableLayoutPanel1
.
ResumeLayout
(
false
);
this
.
tableLayoutPanel1
.
PerformLayout
();
this
.
panel1
.
ResumeLayout
(
false
);
this
.
panel1
.
PerformLayout
();
this
.
panel2
.
ResumeLayout
(
false
);
this
.
panel2
.
PerformLayout
();
this
.
ResumeLayout
(
false
);
this
.
PerformLayout
();
...
...
@@ -420,12 +532,21 @@
private
System
.
Windows
.
Forms
.
ToolStripButton
tsbLoadTable
;
private
System
.
Windows
.
Forms
.
ToolStripSeparator
toolStripSeparator5
;
private
System
.
Windows
.
Forms
.
ToolStripButton
tsbSysSetting
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Column1
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Column6
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Column2
;
private
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
Column3
;
private
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
Column4
;
private
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
Column7
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Column5
;
private
System
.
Windows
.
Forms
.
Panel
panel1
;
private
System
.
Windows
.
Forms
.
TextBox
tbSearch
;
private
System
.
Windows
.
Forms
.
ListBox
lstResult
;
private
System
.
Windows
.
Forms
.
RadioButton
radioButton2
;
private
System
.
Windows
.
Forms
.
Panel
panel2
;
private
System
.
Windows
.
Forms
.
RadioButton
radBtnColumn
;
private
System
.
Windows
.
Forms
.
RadioButton
radBtnTable
;
private
System
.
Windows
.
Forms
.
Button
btnToggle
;
private
System
.
Windows
.
Forms
.
CheckBox
ckbSearchDesc
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
FieldName
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Description
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
ColumnType
;
private
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
IsNotNull
;
private
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
IsPrimaryKey
;
private
System
.
Windows
.
Forms
.
DataGridViewCheckBoxColumn
IsAutoIncrement
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
DefaultValue
;
}
}
\ No newline at end of file
Tools/UI/wDBTableDevelopTools.cs
View file @
65c771d2
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
//
using
Tools.MyCommon
;
...
...
@@ -23,6 +20,11 @@ namespace Tools.UI
/// </summary>
Dictionary
<
string
,
string
>
dicConfig
=
null
;
/// <summary>
/// 右侧面板展开时的宽度
/// </summary>
private
const
int
RIGHT_PANEL_WIDTH
=
262
;
/// <summary>
/// 基础信息表
/// </summary>
...
...
@@ -39,6 +41,10 @@ namespace Tools.UI
/// 表的描述
/// </summary>
string
TableDescription
=>
this
.
tbTableDescription
.
Text
.
Trim
();
/// <summary>
/// 右侧面板是否展开
/// </summary>
bool
isRightPanelExpanded
=
true
;
public
wDBTableDevelopTools
()
{
...
...
@@ -53,7 +59,7 @@ namespace Tools.UI
private
void
InitSystem
()
{
if
(!
File
.
Exists
(
Utils
.
SysConfigFilePath
))
if
(!
File
.
Exists
(
Utils
.
SysConfigFilePath
))
{
#
region
结构初始化
...
...
@@ -68,6 +74,9 @@ namespace Tools.UI
{
ConfigType
.
ModelExportPath
,
Utils
.
TempPath
},
{
ConfigType
.
SqlExportPath
,
Utils
.
TempPath
},
{
ConfigType
.
DocExportPath
,
Utils
.
TempPath
},
{
ConfigType
.
DBTableDevelop_RightPanelExpanded
,
"True"
},
{
ConfigType
.
DBTableDevelop_SearchType
,
"Table"
},
{
ConfigType
.
DBTableDevelop_SearchDesc
,
"False"
},
},
};
dtSetting
.
PrimaryKey
=
new
DataColumn
[]
{
dtSetting
.
Columns
[
0
]
};
...
...
@@ -139,6 +148,17 @@ namespace Tools.UI
this
.
tsmiDelRow
.
Click
+=
TsmiDelRow_Click
;
//文本框-事件
this
.
tbTableName
.
KeyDown
+=
TbTableName_KeyDown
;
//搜索结果列表-事件
this
.
lstResult
.
DoubleClick
+=
LstResult_DoubleClick
;
//单选按钮-事件
this
.
radBtnTable
.
CheckedChanged
+=
RadBtn_CheckedChanged
;
this
.
radBtnColumn
.
CheckedChanged
+=
RadBtn_CheckedChanged
;
//折叠按钮-事件
this
.
btnToggle
.
Click
+=
BtnToggle_Click
;
//窗体关闭事件
this
.
FormClosing
+=
WDBTableDevelopTools_FormClosing
;
//恢复右侧面板状态
this
.
RestoreRightPanelState
();
}
private
void
BindBaseInfo
()
...
...
@@ -172,7 +192,7 @@ namespace Tools.UI
}
private
void
DgvData_CellValueChanged
(
object
sender
,
DataGridViewCellEventArgs
e
)
{
}
private
void
DgvData_EditingControlShowing
(
object
sender
,
DataGridViewEditingControlShowingEventArgs
e
)
{
...
...
@@ -191,7 +211,7 @@ namespace Tools.UI
"VARCHAR(50)"
,
"VARCHAR(MAX)"
,
"NVARCHAR(50)"
,
"NVARCHAR(MAX)"
,
"UNIQUEIDENTIFIER"
};
};
}
}
}
...
...
@@ -259,7 +279,7 @@ namespace Tools.UI
Utils
.
Tip
(
ex
.
Message
);
return
;
}
}
private
void
TsmiExportExcel_Click
(
object
sender
,
EventArgs
e
)
{
...
...
@@ -399,6 +419,101 @@ namespace Tools.UI
#
endregion
#
region
右侧搜索版面
-
事件
/// <summary>
/// 单选按钮-事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
RadBtn_CheckedChanged
(
object
sender
,
EventArgs
e
)
{
//清空搜索框
this
.
tbSearch
.
Text
=
string
.
Empty
;
//清空结果列表
this
.
lstResult
.
Items
.
Clear
();
}
/// <summary>
/// 搜索结果列表事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
LstResult_DoubleClick
(
object
sender
,
EventArgs
e
)
{
if
(
this
.
lstResult
.
SelectedItem
!=
null
)
{
var
selectedText
=
this
.
lstResult
.
SelectedItem
.
ToString
();
//设置等待光标
this
.
Cursor
=
Cursors
.
WaitCursor
;
try
{
//如果是列搜索结果,格式为 "TableName.ColumnName"
if
(
this
.
radBtnColumn
.
Checked
&&
selectedText
.
Contains
(
"."
))
{
//提取表名和列名
var
parts
=
selectedText
.
Split
(
'.'
);
var
tableName
=
parts
[
0
];
var
columnName
=
parts
[
1
];
//加载表数据
this
.
tbTableName
.
Text
=
tableName
;
this
.
InitTableColumnInfo
(
tableName
);
//定位到指定列
this
.
LocateToColumn
(
columnName
);
}
else
if
(
this
.
radBtnTable
.
Checked
)
{
//表搜索结果,直接使用
this
.
tbTableName
.
Text
=
selectedText
;
this
.
InitTableColumnInfo
(
selectedText
);
}
}
finally
{
//恢复默认光标
this
.
Cursor
=
Cursors
.
Default
;
}
}
}
/// <summary>
/// 折叠按钮-事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
BtnToggle_Click
(
object
sender
,
EventArgs
e
)
{
//切换状态
this
.
SetRightPanelState
(!
isRightPanelExpanded
);
}
private
void
tbSearch_KeyDown
(
object
sender
,
KeyEventArgs
e
)
{
if
(
e
.
KeyCode
==
Keys
.
Enter
)
{
this
.
ExecuteDBSearch
();
}
}
#
endregion
#
region
窗体关闭事件
private
void
WDBTableDevelopTools_FormClosing
(
object
sender
,
FormClosingEventArgs
e
)
{
//保存右侧面板状态
this
.
SaveRightPanelState
();
}
#
endregion
#
region
私有方法
/// <summary>
/// 明细检查
/// </summary>
...
...
@@ -451,14 +566,15 @@ namespace Tools.UI
private
void
SetConfig
()
{
//读取配置信息
var
dtSetting
=
new
DataTable
(
"AppSetting"
);
dtSetting
.
ReadXml
(
Utils
.
SysConfigFilePath
);
//保存到全局字典对象
this
.
dicConfig
=
dtSetting
.
Rows
.
Cast
<
DataRow
>().
ToDictionary
(
x
=>
x
[
"Name"
].
ToString
(),
x
=>
x
[
"Value"
].
ToString
());
this
.
dicConfig
=
Utils
.
ReadSysConfigAsDictionary
();
if
(!
dicConfig
.
ContainsKey
(
ConfigType
.
DefaultLink
))
return
;
//初始化数据库链接
var
link
=
dicConfig
[
"DefaultLink"
];
this
.
tstbDbLink
.
Text
=
Utils
.
GetDbItemModel
(
link
).
ToString
();
this
.
InitDBHelper
(
link
);
//初始化数据访问对象
var
link
=
dicConfig
[
ConfigType
.
DefaultLink
];
if
(!
string
.
IsNullOrEmpty
(
link
))
{
this
.
tstbDbLink
.
Text
=
Utils
.
GetDbItemModel
(
link
).
ToString
();
this
.
InitDBHelper
(
link
);
//初始化数据访问对象
}
}
/// <summary>
/// 创建明细新行
...
...
@@ -469,7 +585,7 @@ namespace Tools.UI
var
str
=
this
.
_ds
.
Tables
[
infoTable
].
Compute
(
"MAX(FieldName)"
,
"FieldName like 'NewField%'"
).
ToString
();
var
max
=
string
.
IsNullOrEmpty
(
str
)
?
0
:
int
.
Parse
(
str
.
Replace
(
"NewField"
,
""
));
var
drNew
=
this
.
_ds
.
Tables
[
infoTable
].
NewRow
();
drNew
[
"FieldName"
]
=
$"NewField
{
Utils
.
GenSerialNo
(
max
+
1
)}
"
;
drNew
[
"FieldName"
]
=
$"NewField
{
Utils
.
GenSerialNo
(
max
+
1
)}
"
;
drNew
[
"ColumnType"
]
=
"VARCHAR(50)"
;
drNew
.
EndEdit
();
...
...
@@ -492,7 +608,7 @@ namespace Tools.UI
}
return
path
;
}
/// <summary>
/// 初始化SQL依赖
/// </summary>
...
...
@@ -522,21 +638,10 @@ namespace Tools.UI
/// </summary>
private
void
InitDefaultPath
()
{
this
.
CreatePath
(
Utils
.
ConfigPath
);
this
.
CreatePath
(
Utils
.
LogPath
);
this
.
CreatePath
(
Utils
.
SavePath
);
this
.
CreatePath
(
Utils
.
TempPath
);
}
/// <summary>
/// 创建目录
/// </summary>
/// <param name="path"></param>
private
void
CreatePath
(
string
path
)
{
if
(!
Directory
.
Exists
(
path
))
{
Directory
.
CreateDirectory
(
path
);
}
Utils
.
CreatePathIfNotExists
(
Utils
.
ConfigPath
);
Utils
.
CreatePathIfNotExists
(
Utils
.
LogPath
);
Utils
.
CreatePathIfNotExists
(
Utils
.
SavePath
);
Utils
.
CreatePathIfNotExists
(
Utils
.
TempPath
);
}
/// <summary>
...
...
@@ -625,10 +730,305 @@ namespace Tools.UI
}
#
endregion
#
region
右侧面板状态管理
/// <summary>
/// 设置右侧面板状态
/// </summary>
/// <param name="isExpanded">是否展开</param>
private
void
SetRightPanelState
(
bool
isExpanded
)
{
//设置面板宽度和按钮文字
this
.
tableLayoutPanel1
.
ColumnStyles
[
5
].
SizeType
=
SizeType
.
Absolute
;
this
.
tableLayoutPanel1
.
ColumnStyles
[
5
].
Width
=
isExpanded
?
RIGHT_PANEL_WIDTH
:
0
;
this
.
btnToggle
.
Text
=
isExpanded
?
">"
:
"<"
;
this
.
isRightPanelExpanded
=
isExpanded
;
//强制刷新布局和按钮
this
.
tableLayoutPanel1
.
PerformLayout
();
this
.
btnToggle
.
Refresh
();
}
/// <summary>
/// 恢复右侧面板状态
/// </summary>
private
void
RestoreRightPanelState
()
{
if
(
dicConfig
==
null
)
return
;
//恢复面板展开/折叠状态
if
(
dicConfig
.
ContainsKey
(
ConfigType
.
DBTableDevelop_RightPanelExpanded
))
{
var
expanded
=
dicConfig
[
ConfigType
.
DBTableDevelop_RightPanelExpanded
];
if
(
bool
.
TryParse
(
expanded
,
out
bool
isExpanded
))
{
this
.
SetRightPanelState
(
isExpanded
);
}
}
//恢复搜索类型(表/列)
if
(
dicConfig
.
ContainsKey
(
ConfigType
.
DBTableDevelop_SearchType
))
{
var
searchType
=
dicConfig
[
ConfigType
.
DBTableDevelop_SearchType
];
if
(
searchType
==
"Table"
)
{
this
.
radBtnTable
.
Checked
=
true
;
}
else
if
(
searchType
==
"Column"
)
{
this
.
radBtnColumn
.
Checked
=
true
;
}
}
//恢复搜索描述选项
if
(
dicConfig
.
ContainsKey
(
ConfigType
.
DBTableDevelop_SearchDesc
))
{
var
searchDesc
=
dicConfig
[
ConfigType
.
DBTableDevelop_SearchDesc
];
if
(
bool
.
TryParse
(
searchDesc
,
out
bool
isSearchDesc
))
{
this
.
ckbSearchDesc
.
Checked
=
isSearchDesc
;
}
}
}
/// <summary>
/// 保存右侧面板状态
/// </summary>
private
void
SaveRightPanelState
()
{
try
{
var
dtSetting
=
Utils
.
ReadSysConfig
();
//保存面板展开/折叠状态
Utils
.
SetConfigValue
(
dtSetting
,
ConfigType
.
DBTableDevelop_RightPanelExpanded
,
isRightPanelExpanded
.
ToString
());
//保存搜索类型(表/列)
var
searchType
=
this
.
radBtnTable
.
Checked
?
"Table"
:
"Column"
;
Utils
.
SetConfigValue
(
dtSetting
,
ConfigType
.
DBTableDevelop_SearchType
,
searchType
);
//保存搜索描述选项
Utils
.
SetConfigValue
(
dtSetting
,
ConfigType
.
DBTableDevelop_SearchDesc
,
this
.
ckbSearchDesc
.
Checked
.
ToString
());
Utils
.
SaveSysConfig
(
dtSetting
);
}
catch
(
Exception
ex
)
{
//静默处理,不影响窗体关闭
System
.
Diagnostics
.
Debug
.
WriteLine
(
$"保存右侧面板状态失败:
{
ex
.
Message
}
"
);
}
}
#
endregion
#
region
列定位功能
/// <summary>
/// 定位到指定列
/// </summary>
/// <param name="columnName">列名</param>
private
void
LocateToColumn
(
string
columnName
)
{
if
(
this
.
dgvData
.
Rows
.
Count
==
0
)
return
;
try
{
//在数据表中查找指定的列
foreach
(
DataGridViewRow
row
in
this
.
dgvData
.
Rows
)
{
//使用与DataPropertyName一致的列名访问单元格,提高可读性
if
(
row
.
Cells
[
"FieldName"
].
Value
!=
null
&&
row
.
Cells
[
"FieldName"
].
Value
.
ToString
().
Equals
(
columnName
,
StringComparison
.
OrdinalIgnoreCase
))
{
//取消所有行的选中状态
this
.
dgvData
.
ClearSelection
();
//选中找到的行
row
.
Selected
=
true
;
#
region
待开发:支持查询后修改指定列类型列名等
//设置当前单元格
this
.
dgvData
.
CurrentCell
=
row
.
Cells
[
0
];
//滚动到可见区域
this
.
dgvData
.
FirstDisplayedScrollingRowIndex
=
row
.
Index
;
break
;
}
}
}
catch
(
Exception
ex
)
{
//定位失败不影响主流程,仅记录日志
System
.
Diagnostics
.
Debug
.
WriteLine
(
$"定位到列失败:
{
ex
.
Message
}
"
);
}
}
#
endregion
#
region
右侧数据库搜索
/// <summary>
/// 执行数据库搜索操作
/// </summary>
private
void
ExecuteDBSearch
()
{
//验证搜索前提条件
if
(!
this
.
ValidateSearchConditions
(
out
string
searchText
))
{
return
;
}
try
{
//生成搜索SQL和提示信息
var
(
sql
,
notFoundMessage
)
=
this
.
BuildSearchSql
(
searchText
);
//执行查询并显示结果
var
dt
=
this
.
_db
.
GetDataTable
(
sql
,
"search_result"
,
false
);
this
.
DisplaySearchResults
(
dt
,
notFoundMessage
);
}
catch
(
Exception
ex
)
{
Utils
.
Tip
(
$"搜索出错:\r\n
{
ex
.
Message
}
"
);
}
}
/// <summary>
/// 验证搜索条件
/// </summary>
/// <param name="searchText">输出搜索文本</param>
/// <returns>是否验证通过</returns>
private
bool
ValidateSearchConditions
(
out
string
searchText
)
{
searchText
=
string
.
Empty
;
//检查数据库连接
if
(
this
.
_db
==
null
||
!
this
.
_db
.
ConnectionTest
())
{
Utils
.
Tip
(
"数据库链接无效,请选择有效链接!"
);
return
false
;
}
//获取并验证搜索关键字
searchText
=
this
.
tbSearch
.
Text
.
Trim
();
if
(
string
.
IsNullOrEmpty
(
searchText
))
{
Utils
.
Tip
(
"请输入搜索关键字!"
);
return
false
;
}
return
true
;
}
/// <summary>
/// 构建搜索SQL
/// </summary>
/// <param name="searchText">搜索关键字</param>
/// <returns>SQL语句和未找到时的提示信息</returns>
private
(
string
sql
,
string
notFoundMessage
)
BuildSearchSql
(
string
searchText
)
{
bool
searchDesc
=
this
.
ckbSearchDesc
.
Checked
;
if
(
this
.
radBtnTable
.
Checked
)
{
return
this
.
BuildTableSearchSql
(
searchText
,
searchDesc
);
}
else
if
(
this
.
radBtnColumn
.
Checked
)
{
return
this
.
BuildColumnSearchSql
(
searchText
,
searchDesc
);
}
return
(
string
.
Empty
,
string
.
Empty
);
}
/// <summary>
/// 构建表搜索SQL
/// </summary>
/// <param name="searchText">搜索关键字</param>
/// <param name="searchDesc">是否搜索描述</param>
/// <returns>SQL语句和未找到时的提示信息</returns>
private
(
string
sql
,
string
notFoundMessage
)
BuildTableSearchSql
(
string
searchText
,
bool
searchDesc
)
{
if
(
searchDesc
)
{
var
sql
=
$@"
SELECT
a.name
FROM sysobjects a
LEFT JOIN sys.extended_properties b ON a.id = b.major_id AND b.minor_id = 0
WHERE a.xtype = 'U'
AND CONVERT(VARCHAR(500), b.value) LIKE '%
{
searchText
}
%'
ORDER BY a.name"
;
return
(
sql
,
$"未找到描述包含'
{
searchText
}
'的表!"
);
}
else
{
var
sql
=
$"SELECT name FROM sys.tables WHERE name LIKE '%
{
searchText
}
%' ORDER BY name"
;
return
(
sql
,
$"未找到包含'
{
searchText
}
'的表!"
);
}
}
/// <summary>
/// 构建列搜索SQL
/// </summary>
/// <param name="searchText">搜索关键字</param>
/// <param name="searchDesc">是否搜索描述</param>
/// <returns>SQL语句和未找到时的提示信息</returns>
private
(
string
sql
,
string
notFoundMessage
)
BuildColumnSearchSql
(
string
searchText
,
bool
searchDesc
)
{
if
(
searchDesc
)
{
var
sql
=
$@"
SELECT DISTINCT
OBJECT_NAME(a.id) + '.' + CONVERT(VARCHAR(100), a.name) AS name
FROM dbo.syscolumns a
INNER JOIN dbo.sysobjects b ON b.id = a.id AND b.xtype = 'U' AND b.name <> 'dtproperties'
LEFT JOIN sys.extended_properties d ON d.major_id = b.id AND d.minor_id = a.colid
WHERE CONVERT(VARCHAR(500), ISNULL(d.[value],'')) LIKE '%
{
searchText
}
%'
AND CONVERT(VARCHAR(500), ISNULL(d.[value],'')) <> ''
ORDER BY name"
;
return
(
sql
,
$"未找到描述包含'
{
searchText
}
'的列!"
);
}
else
{
var
sql
=
$@"
SELECT DISTINCT
OBJECT_NAME(c.object_id) + '.' + c.name AS name
FROM sys.columns c
INNER JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%
{
searchText
}
%'
ORDER BY name"
;
return
(
sql
,
$"未找到包含'
{
searchText
}
'的列!"
);
}
}
/// <summary>
/// 显示搜索结果
/// </summary>
/// <param name="dt">查询结果数据表</param>
/// <param name="notFoundMessage">未找到时的提示信息</param>
private
void
DisplaySearchResults
(
DataTable
dt
,
string
notFoundMessage
)
{
//清空结果列表
this
.
lstResult
.
Items
.
Clear
();
if
(
dt
.
Rows
.
Count
>
0
)
{
//填充搜索结果
foreach
(
DataRow
row
in
dt
.
Rows
)
{
this
.
lstResult
.
Items
.
Add
(
row
[
"name"
].
ToString
());
}
}
else
{
Utils
.
Tip
(
notFoundMessage
);
}
}
#
endregion
}
}
Tools/UI/wSysModule.cs
View file @
65c771d2
...
...
@@ -162,11 +162,10 @@ namespace Tools.UI
private
void
InitDefaultDbLink
()
{
//读取配置信息
var
dtSetting
=
new
DataTable
(
"AppSetting"
);
dtSetting
.
ReadXml
(
Utils
.
SysConfigFilePath
);
var
dicConfig
=
dtSetting
.
Rows
.
Cast
<
DataRow
>().
ToDictionary
(
x
=>
x
[
"Name"
].
ToString
(),
x
=>
x
[
"Value"
].
ToString
());
var
dicConfig
=
Utils
.
ReadSysConfigAsDictionary
();
if
(!
dicConfig
.
ContainsKey
(
ConfigType
.
DefaultLink
))
return
;
//初始化数据库链接
var
link
=
dicConfig
[
"DefaultLink"
];
var
link
=
dicConfig
[
ConfigType
.
DefaultLink
];
if
(!
string
.
IsNullOrEmpty
(
link
))
{
this
.
tstbLinkString
.
Text
=
Utils
.
GetDbItemModel
(
link
).
ToString
();
...
...
Tools/UI/wXmlGenerator.cs
View file @
65c771d2
...
...
@@ -148,7 +148,8 @@ namespace Tools.UI
//初始化列属性
ds
.
Tables
[
0
].
Columns
.
Cast
<
DataColumn
>().
ToList
()
.
ForEach
(
col
=>
{
.
ForEach
(
col
=>
{
bool
isKey
=
ds
.
Tables
[
0
].
PrimaryKey
.
Contains
(
col
);
var
dr
=
result
.
Tables
[
0
].
NewRow
();
dr
[
"Name"
]
=
col
.
ColumnName
;
...
...
@@ -289,7 +290,8 @@ ORDER BY b.column_id;";
var
sqlsNode
=
xmlDoc
.
CreateElement
(
"Sqls"
);
string
strKey
=
_ds
.
Tables
[
0
].
Columns
[
0
].
ToString
();
//首列一般主键列
string
keyWhere
=
$"
{
strKey
}
=@
{
strKey
}
"
;
var
columnList
=
this
.
_ds
.
Tables
[
0
].
Columns
.
Cast
<
DataColumn
>().
Select
(
c
=>
c
.
ColumnName
).
ToList
();
var
columnList
=
this
.
_ds
.
Tables
[
0
].
Columns
.
Cast
<
DataColumn
>().
Where
(
c
=>
!
_ds
.
Tables
[
0
].
PrimaryKey
.
Contains
(
c
)).
Select
(
c
=>
c
.
ColumnName
).
ToList
();
#
region
SelectObject
//SQL配置基本设置
...
...
@@ -311,6 +313,7 @@ ORDER BY b.column_id;";
//生成参数
foreach
(
DataColumn
dc
in
_ds
.
Tables
[
0
].
Columns
)
{
if
(
_ds
.
Tables
[
0
].
PrimaryKey
.
Contains
(
dc
))
continue
;
//新增的时候不需要主键列
this
.
AddParamNode
(
xmlDoc
,
sqlNode
,
dc
.
ColumnName
);
}
...
...
Tools/wMain.Designer.cs
View file @
65c771d2
namespace
Tools
namespace
Tools
{
partial
class
wMain
{
...
...
@@ -34,6 +34,7 @@
this
.
splitContainer1
=
new
System
.
Windows
.
Forms
.
SplitContainer
();
this
.
listView1
=
new
System
.
Windows
.
Forms
.
ListView
();
this
.
imageList1
=
new
System
.
Windows
.
Forms
.
ImageList
(
this
.
components
);
this
.
btnToggleMenu
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
menuStrip1
=
new
System
.
Windows
.
Forms
.
MenuStrip
();
this
.
toolStripMenuItem1
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
tsmiSysUpload
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
...
...
@@ -107,6 +108,7 @@
// splitContainer1.Panel1
//
this
.
splitContainer1
.
Panel1
.
Controls
.
Add
(
this
.
listView1
);
this
.
splitContainer1
.
Panel1
.
Controls
.
Add
(
this
.
btnToggleMenu
);
this
.
splitContainer1
.
Panel1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
//
// splitContainer1.Panel2
...
...
@@ -123,7 +125,7 @@
this
.
listView1
.
LargeImageList
=
this
.
imageList1
;
this
.
listView1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
listView1
.
Name
=
"listView1"
;
this
.
listView1
.
Size
=
new
System
.
Drawing
.
Size
(
200
,
3
6
9
);
this
.
listView1
.
Size
=
new
System
.
Drawing
.
Size
(
200
,
3
4
9
);
this
.
listView1
.
SmallImageList
=
this
.
imageList1
;
this
.
listView1
.
StateImageList
=
this
.
imageList1
;
this
.
listView1
.
TabIndex
=
0
;
...
...
@@ -139,6 +141,23 @@
this
.
imageList1
.
Images
.
SetKeyName
(
3
,
"51_工作群组.png"
);
this
.
imageList1
.
Images
.
SetKeyName
(
4
,
"60_空间.png"
);
//
// btnToggleMenu
//
this
.
btnToggleMenu
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
41
)))),
((
int
)(((
byte
)(
101
)))),
((
int
)(((
byte
)(
204
)))));
this
.
btnToggleMenu
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
btnToggleMenu
.
FlatAppearance
.
BorderSize
=
0
;
this
.
btnToggleMenu
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnToggleMenu
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Bold
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnToggleMenu
.
ForeColor
=
System
.
Drawing
.
Color
.
White
;
this
.
btnToggleMenu
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
349
);
this
.
btnToggleMenu
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
btnToggleMenu
.
Name
=
"btnToggleMenu"
;
this
.
btnToggleMenu
.
Size
=
new
System
.
Drawing
.
Size
(
200
,
20
);
this
.
btnToggleMenu
.
TabIndex
=
1
;
this
.
btnToggleMenu
.
Text
=
"<"
;
this
.
btnToggleMenu
.
UseVisualStyleBackColor
=
false
;
this
.
btnToggleMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
btnToggleMenu_Click
);
//
// menuStrip1
//
this
.
menuStrip1
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
234
)))),
((
int
)(((
byte
)(
245
)))),
((
int
)(((
byte
)(
255
)))));
...
...
@@ -612,5 +631,6 @@
private
System
.
Windows
.
Forms
.
Label
lbBrief
;
private
System
.
Windows
.
Forms
.
Label
label9
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
tsmiShowFetetoWork
;
private
System
.
Windows
.
Forms
.
Button
btnToggleMenu
;
}
}
\ No newline at end of file
Tools/wMain.cs
View file @
65c771d2
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
//
...
...
@@ -32,6 +30,14 @@ namespace Tools
/// 数据库访问对象
/// </summary>
DBHelper
_db
=
null
;
/// <summary>
/// 左侧菜单原始宽度
/// </summary>
private
int
OriginalMenuWidth
=
200
;
/// <summary>
/// 左侧菜单是否已折叠
/// </summary>
private
bool
IsMenuCollapsed
=
false
;
public
wMain
()
{
...
...
@@ -59,6 +65,8 @@ namespace Tools
}
private
void
WMain_Shown
(
object
sender
,
EventArgs
e
)
{
//保存原始宽度
this
.
OriginalMenuWidth
=
this
.
splitContainer1
.
SplitterDistance
;
//窗体拖拽事件
this
.
Header
.
MouseDown
+=
Header_MouseDown
;
this
.
Header
.
MouseUp
+=
Header_MouseUp
;
...
...
@@ -425,6 +433,18 @@ namespace Tools
UserLog
.
Write
(
$"关闭模块:
{
page
.
Text
}
"
);
//日志记录
this
.
OpenedList
.
Remove
(
page
.
Text
);
//移除列表
this
.
tabControl1
.
TabPages
.
Remove
(
page
);
//移除页面
//先关闭并释放窗体
if
(
page
.
Controls
.
Count
>
0
)
{
var
frm
=
page
.
Controls
[
0
]
as
Form
;
if
(
frm
!=
null
)
{
frm
.
Close
();
//触发FormClosing事件
frm
.
Dispose
();
//释放窗体资源
}
}
page
.
Dispose
();
//释放页面
}
}
...
...
@@ -451,13 +471,44 @@ namespace Tools
#
endregion
#
region
扩展:折叠
/
展开左侧菜单
/// <summary>
/// 折叠/展开按钮点击事件
/// </summary>
private
void
btnToggleMenu_Click
(
object
sender
,
EventArgs
e
)
{
this
.
ToggleMenu
();
}
/// <summary>
/// 切换菜单折叠/展开状态
/// </summary>
private
void
ToggleMenu
()
{
// 切换状态
this
.
IsMenuCollapsed
=
!
this
.
IsMenuCollapsed
;
// 使用三元运算符简化状态切换
this
.
splitContainer1
.
SplitterDistance
=
this
.
IsMenuCollapsed
?
20
:
this
.
OriginalMenuWidth
;
this
.
btnToggleMenu
.
Text
=
this
.
IsMenuCollapsed
?
">"
:
"<"
;
// 强制刷新按钮显示
this
.
btnToggleMenu
.
PerformLayout
();
this
.
btnToggleMenu
.
Refresh
();
}
#
endregion
#
region
扩展:使用内存展示
//定时器:默认开启,间隔1秒
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
{
var
p
=
Process
.
GetCurrentProcess
();
var
MB
=
(
p
.
WorkingSet64
/
1024
/
1024
);
// 使用PrivateMemorySize64获取进程独占的内存,与任务管理器显示一致
// WorkingSet64 包含共享内存,通常比实际占用大
var
MB
=
(
p
.
PrivateMemorySize64
/
1024
/
1024
);
this
.
AsyncUI
(()
=>
{
this
.
lbSysMemery
.
Text
=
$"
{
MB
}
M"
;
});
...
...
Tools/wMain.resx
View file @
65c771d2
...
...
@@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD0
EgAAAk1TRnQBSQFMAgEBBQEAA
RABAQEQ
AQEBIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
EgAAAk1TRnQBSQFMAgEBBQEAA
SgBAQEo
AQEBIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABgAMAAUADAAEBAQABCAYAASAYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
...
...
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