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
28b65b6f
Commit
28b65b6f
authored
Jan 11, 2022
by
段廷瑞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、日志查看优化:增加路径历史记录
parent
c0165201
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
116 deletions
+45
-116
TextBoxEx.Designer.cs
Tools/MyCommon/controls/TextBoxEx.Designer.cs
+0
-36
TextBoxEx.cs
Tools/MyCommon/controls/TextBoxEx.cs
+0
-38
Tools.csproj
Tools/Tools.csproj
+0
-6
wLogViewer.Designer.cs
Tools/UI/wLogViewer.Designer.cs
+27
-28
wLogViewer.cs
Tools/UI/wLogViewer.cs
+18
-8
No files found.
Tools/MyCommon/controls/TextBoxEx.Designer.cs
deleted
100644 → 0
View file @
c0165201
namespace
Tools.MyCommon.controls
{
partial
class
TextBoxEx
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private
System
.
ComponentModel
.
IContainer
components
=
null
;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected
override
void
Dispose
(
bool
disposing
)
{
if
(
disposing
&&
(
components
!=
null
))
{
components
.
Dispose
();
}
base
.
Dispose
(
disposing
);
}
#
region
组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private
void
InitializeComponent
()
{
components
=
new
System
.
ComponentModel
.
Container
();
}
#
endregion
}
}
Tools/MyCommon/controls/TextBoxEx.cs
deleted
100644 → 0
View file @
c0165201
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
namespace
Tools.MyCommon.controls
{
/*
* FLAG:重写一个文本框,具备文本着色功能
*/
public
partial
class
TextBoxEx
:
TextBox
{
public
TextBoxEx
()
{
InitializeComponent
();
//绘制样式
this
.
SetStyle
(
ControlStyles
.
UserPaint
//控件将自行绘制,而不是通过操作系统来绘制,重写OnPaint()方法
|
ControlStyles
.
OptimizedDoubleBuffer
//该控件首先在缓冲区中绘制,而不是直接绘制到屏幕上,这样可以减少闪烁
|
ControlStyles
.
AllPaintingInWmPaint
//控件将忽略 WM_ERASEBKGND 窗口消息以减少闪烁
|
ControlStyles
.
ResizeRedraw
//在调整控件大小时重绘控件
|
ControlStyles
.
SupportsTransparentBackColor
//控件接受 alpha 组件小于 255 的 BackColor 以模拟透明
,
true
);
}
protected
override
void
OnPaint
(
PaintEventArgs
e
)
{
base
.
OnPaint
(
e
);
}
}
}
Tools/Tools.csproj
View file @
28b65b6f
...
...
@@ -78,12 +78,6 @@
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"MyCommon\controls\TextBoxEx.cs"
>
<SubType>
Component
</SubType>
</Compile>
<Compile
Include=
"MyCommon\controls\TextBoxEx.Designer.cs"
>
<DependentUpon>
TextBoxEx.cs
</DependentUpon>
</Compile>
<Compile
Include=
"MyCommon\Log.cs"
/>
<Compile
Include=
"MyCommon\UserLog.cs"
/>
<Compile
Include=
"MyCommon\controls\MyTreeView.cs"
>
...
...
Tools/UI/wLogViewer.Designer.cs
View file @
28b65b6f
...
...
@@ -29,16 +29,16 @@
private
void
InitializeComponent
()
{
this
.
toolStrip1
=
new
System
.
Windows
.
Forms
.
ToolStrip
();
this
.
toolStripLabel2
=
new
System
.
Windows
.
Forms
.
ToolStripLabel
();
this
.
tscbEncoding
=
new
System
.
Windows
.
Forms
.
ToolStripComboBox
();
this
.
toolStripSeparator1
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
toolStripLabel1
=
new
System
.
Windows
.
Forms
.
ToolStripLabel
();
this
.
tstbLogPath
=
new
System
.
Windows
.
Forms
.
ToolStripTextBox
();
this
.
tsbSelectPath
=
new
System
.
Windows
.
Forms
.
ToolStripButton
();
this
.
listBox1
=
new
System
.
Windows
.
Forms
.
ListBox
();
this
.
textBox1
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
splitContainer1
=
new
System
.
Windows
.
Forms
.
SplitContainer
();
this
.
progressBar1
=
new
System
.
Windows
.
Forms
.
ProgressBar
();
this
.
toolStripLabel2
=
new
System
.
Windows
.
Forms
.
ToolStripLabel
();
this
.
tscbEncoding
=
new
System
.
Windows
.
Forms
.
ToolStripComboBox
();
this
.
toolStripSeparator1
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
tscbLogPath
=
new
System
.
Windows
.
Forms
.
ToolStripComboBox
();
this
.
toolStrip1
.
SuspendLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
splitContainer1
)).
BeginInit
();
this
.
splitContainer1
.
Panel1
.
SuspendLayout
();
...
...
@@ -53,7 +53,7 @@
this
.
tscbEncoding
,
this
.
toolStripSeparator1
,
this
.
toolStripLabel1
,
this
.
ts
t
bLogPath
,
this
.
ts
c
bLogPath
,
this
.
tsbSelectPath
});
this
.
toolStrip1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
toolStrip1
.
Name
=
"toolStrip1"
;
...
...
@@ -61,19 +61,29 @@
this
.
toolStrip1
.
TabIndex
=
0
;
this
.
toolStrip1
.
Text
=
"toolStrip1"
;
//
// toolStripLabel2
//
this
.
toolStripLabel2
.
Name
=
"toolStripLabel2"
;
this
.
toolStripLabel2
.
Size
=
new
System
.
Drawing
.
Size
(
44
,
22
);
this
.
toolStripLabel2
.
Text
=
"编码:"
;
//
// tscbEncoding
//
this
.
tscbEncoding
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
tscbEncoding
.
Name
=
"tscbEncoding"
;
this
.
tscbEncoding
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
25
);
//
// toolStripSeparator1
//
this
.
toolStripSeparator1
.
Name
=
"toolStripSeparator1"
;
this
.
toolStripSeparator1
.
Size
=
new
System
.
Drawing
.
Size
(
6
,
25
);
//
// toolStripLabel1
//
this
.
toolStripLabel1
.
Name
=
"toolStripLabel1"
;
this
.
toolStripLabel1
.
Size
=
new
System
.
Drawing
.
Size
(
68
,
22
);
this
.
toolStripLabel1
.
Text
=
"日志路径:"
;
//
// tstbLogPath
//
this
.
tstbLogPath
.
Font
=
new
System
.
Drawing
.
Font
(
"Microsoft YaHei UI"
,
9F
);
this
.
tstbLogPath
.
Name
=
"tstbLogPath"
;
this
.
tstbLogPath
.
ReadOnly
=
true
;
this
.
tstbLogPath
.
Size
=
new
System
.
Drawing
.
Size
(
300
,
25
);
//
// tsbSelectPath
//
this
.
tsbSelectPath
.
Image
=
global
::
Tools
.
Properties
.
Resources
.
文件夹
;
...
...
@@ -129,22 +139,11 @@
this
.
progressBar1
.
Size
=
new
System
.
Drawing
.
Size
(
535
,
2
);
this
.
progressBar1
.
TabIndex
=
3
;
//
// toolStripLabel2
//
this
.
toolStripLabel2
.
Name
=
"toolStripLabel2"
;
this
.
toolStripLabel2
.
Size
=
new
System
.
Drawing
.
Size
(
44
,
22
);
this
.
toolStripLabel2
.
Text
=
"编码:"
;
//
// tscbEncoding
//
this
.
tscbEncoding
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
tscbEncoding
.
Name
=
"tscbEncoding"
;
this
.
tscbEncoding
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
25
);
//
// toolStripSeparator1
// tscbLogPath
//
this
.
toolStripSeparator1
.
Name
=
"toolStripSeparator1"
;
this
.
toolStripSeparator1
.
Size
=
new
System
.
Drawing
.
Size
(
6
,
25
);
this
.
tscbLogPath
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
tscbLogPath
.
Name
=
"tscbLogPath"
;
this
.
tscbLogPath
.
Size
=
new
System
.
Drawing
.
Size
(
300
,
25
);
//
// wLogViewer
//
...
...
@@ -173,7 +172,6 @@
private
System
.
Windows
.
Forms
.
ToolStrip
toolStrip1
;
private
System
.
Windows
.
Forms
.
ToolStripLabel
toolStripLabel1
;
private
System
.
Windows
.
Forms
.
ToolStripTextBox
tstbLogPath
;
private
System
.
Windows
.
Forms
.
ToolStripButton
tsbSelectPath
;
private
System
.
Windows
.
Forms
.
ListBox
listBox1
;
private
System
.
Windows
.
Forms
.
TextBox
textBox1
;
...
...
@@ -182,5 +180,6 @@
private
System
.
Windows
.
Forms
.
ToolStripLabel
toolStripLabel2
;
private
System
.
Windows
.
Forms
.
ToolStripComboBox
tscbEncoding
;
private
System
.
Windows
.
Forms
.
ToolStripSeparator
toolStripSeparator1
;
private
System
.
Windows
.
Forms
.
ToolStripComboBox
tscbLogPath
;
}
}
\ No newline at end of file
Tools/UI/wLogViewer.cs
View file @
28b65b6f
...
...
@@ -17,8 +17,9 @@ namespace Tools.UI
{
public
partial
class
wLogViewer
:
wBasic
{
List
<
string
>
pathList
=
new
List
<
string
>();
string
LogPath
{
get
=>
this
.
ts
tbLogPath
.
Text
;
set
=>
this
.
tst
bLogPath
.
Text
=
value
;
}
string
LogPath
{
get
=>
this
.
ts
cbLogPath
.
Text
;
set
=>
this
.
tsc
bLogPath
.
Text
=
value
;
}
public
wLogViewer
()
{
...
...
@@ -28,24 +29,26 @@ namespace Tools.UI
//窗体:加载
private
void
wLogViewer_Load
(
object
sender
,
EventArgs
e
)
{
//初始化编码选择下拉框
var
list
=
new
List
<
string
>
{
Encoding
.
Default
.
HeaderName
.
ToUpper
(),
Encoding
.
UTF8
.
HeaderName
.
ToUpper
(),
};
this
.
tscbEncoding
.
Items
.
AddRange
(
list
.
Distinct
().
ToArray
());
this
.
tscbEncoding
.
SelectedIndex
=
0
;
//初始化文件路径下拉框
pathList
=
Utils
.
GetJsonConfig
<
List
<
string
>>();
this
.
tscbLogPath
.
Items
.
AddRange
(
pathList
.
Distinct
().
ToArray
());
}
//窗体:显示完成
private
void
wLogViewer_Shown
(
object
sender
,
EventArgs
e
)
{
this
.
tsbSelectPath
.
Click
+=
TsbSelectPath_Click
;
this
.
ts
tbLogPath
.
TextChanged
+=
TstbLogPath_Text
Changed
;
this
.
ts
cbLogPath
.
SelectedIndexChanged
+=
TscbLogPath_SelectedIndex
Changed
;
this
.
tscbEncoding
.
SelectedIndexChanged
+=
TscbEncoding_SelectedIndexChanged
;
this
.
listBox1
.
SelectedIndexChanged
+=
ListBox1_SelectedIndexChanged
;
}
/// <summary>
/// 选择路径
/// </summary>
...
...
@@ -54,17 +57,22 @@ namespace Tools.UI
var
folder
=
Utils
.
SelectFolder
();
if
(!
string
.
IsNullOrEmpty
(
folder
))
{
//路径下拉记录
if
(!
this
.
tscbLogPath
.
Items
.
Contains
(
folder
))
this
.
tscbLogPath
.
Items
.
Add
(
folder
);
//刷新下拉框文本
this
.
LogPath
=
folder
;
//保存路径记录
Utils
.
SaveJsonConfig
(
this
.
tscbLogPath
.
Items
.
Cast
<
string
>().
ToList
());
}
}
/// <summary>
/// 路径文本改变时,刷新列表框
/// </summary>
private
void
Ts
tbLogPath_Text
Changed
(
object
sender
,
EventArgs
e
)
private
void
Ts
cbLogPath_SelectedIndex
Changed
(
object
sender
,
EventArgs
e
)
{
this
.
InitListBox
();
}
/// <summary>
/// 编码切换:重新解析日志文件
/// </summary>
...
...
@@ -120,6 +128,8 @@ namespace Tools.UI
encode
=
Encoding
.
GetEncoding
(
this
.
tscbEncoding
.
Text
);
//清空信息
this
.
textBox1
.
Text
=
string
.
Empty
;
//生成文件路径
var
logFileName
=
$@"
{
this
.
LogPath
}
\
{
fileName
}
"
;
//如果上一个任务还未结束,则取消
if
(
_task
!=
null
&&
!
_task
.
IsCompleted
)
{
...
...
@@ -134,7 +144,7 @@ namespace Tools.UI
//读取日志内容
var
initLength
=
1024
;
var
buffer
=
new
byte
[
initLength
];
var
fs
=
new
FileStream
(
$@"
{
this
.
LogPath
}
\
{
fileName
}
"
,
FileMode
.
Open
,
FileAccess
.
Read
);
var
fs
=
new
FileStream
(
logFileName
,
FileMode
.
Open
,
FileAccess
.
Read
);
//初始化进度条
this
.
AsyncUI
(()
=>
{
this
.
progressBar1
.
Maximum
=
Math
.
Max
(
1
,
(
int
)(
fs
.
Length
/
initLength
));
...
...
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