cbfa535d20
* Add log tab * Merge control mesg & duty log * Fix ping (calc loss) * Add current connection in ping tab. Able to copy by double clicking item * Log font has moved to config * Add debug enable on config + save * Display ping failed reason (debug enable) * Handled copy exception * New content list in duty tab * Show loss rate option in ping tab * Rename Chinese packet info file (No data) * Bigger UI font
139 lines
2.6 KiB
C#
139 lines
2.6 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace DutyContent.Tab
|
|
{
|
|
public partial class LogForm : Form, Interface.ISuppLocale, Interface.ISuppActPlugin
|
|
{
|
|
private static LogForm _self;
|
|
public static LogForm Self => _self;
|
|
|
|
public LogForm()
|
|
{
|
|
_self = this;
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void PluginDeinitialize()
|
|
{
|
|
|
|
}
|
|
|
|
public void PluginInitialize()
|
|
{
|
|
chkLogScroll.Checked = true;
|
|
}
|
|
|
|
public void RefreshLocale()
|
|
{
|
|
|
|
}
|
|
|
|
public void UpdateUiLocale()
|
|
{
|
|
btnLogCopy.Text = Locale.Text(501);
|
|
btnLogClear.Text = Locale.Text(502);
|
|
chkLogScroll.Text = Locale.Text(503);
|
|
|
|
var logfont = new Font(DcConfig.Duty.LogFontFamily, DcConfig.Duty.LogFontSize, FontStyle.Regular);
|
|
txtLogText.Font = logfont;
|
|
}
|
|
|
|
private void BtnLogCopy_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (txtLogText.SelectionLength != 0)
|
|
txtLogText.Copy();
|
|
else
|
|
{
|
|
txtLogText.SelectAll();
|
|
|
|
txtLogText.Copy();
|
|
|
|
txtLogText.SelectionStart = txtLogText.TextLength;
|
|
txtLogText.SelectionLength = 0;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Ex(ex, 35);
|
|
}
|
|
}
|
|
|
|
private void BtnLogClear_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
txtLogText.Clear();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Ex(ex, 36);
|
|
}
|
|
}
|
|
|
|
private void InvokeLog(Color color, string mesg)
|
|
{
|
|
WorkerAct.Invoker(() =>
|
|
{
|
|
txtLogText.SelectionColor = color;
|
|
txtLogText.SelectionStart = txtLogText.TextLength;
|
|
txtLogText.SelectionLength = 0;
|
|
txtLogText.AppendText(mesg);
|
|
|
|
txtLogText.SelectionColor = txtLogText.ForeColor;
|
|
|
|
if (chkLogScroll.Checked)
|
|
ThirdParty.NativeMethods.ScrollToBottom(txtLogText);
|
|
});
|
|
}
|
|
|
|
//
|
|
public void WriteLog(Color color, string mesg, bool with_time = true)
|
|
{
|
|
if (txtLogText.IsDisposed || string.IsNullOrEmpty(mesg))
|
|
return;
|
|
|
|
string line;
|
|
|
|
if (!with_time)
|
|
line = mesg + Environment.NewLine;
|
|
else
|
|
{
|
|
var dt = DateTime.Now.ToString("HH:mm:ss");
|
|
line = $"[{dt}] {mesg}{Environment.NewLine}";
|
|
}
|
|
|
|
InvokeLog(color, line);
|
|
}
|
|
|
|
//
|
|
public void WriteLogSection(Color color, string section, string mesg, bool with_time = true)
|
|
{
|
|
if (txtLogText.IsDisposed || string.IsNullOrEmpty(mesg))
|
|
return;
|
|
|
|
string line;
|
|
|
|
if (!with_time)
|
|
line = $"[{section}] {mesg}{Environment.NewLine}";
|
|
else
|
|
{
|
|
var dt = DateTime.Now.ToString("HH:mm:ss");
|
|
line = $"[{dt}/{section}] {mesg}{Environment.NewLine}";
|
|
}
|
|
|
|
InvokeLog(color, line);
|
|
}
|
|
|
|
//
|
|
public Font LogFont
|
|
{
|
|
get { return txtLogText.Font; }
|
|
set { txtLogText.Font = value; }
|
|
}
|
|
}
|
|
}
|