代码清理

This commit is contained in:
ChsBuffer
2020-08-09 03:54:57 +08:00
parent 0b09ce62f1
commit 764009ebff
5 changed files with 13 additions and 61 deletions

View File

@@ -214,35 +214,6 @@ namespace Netch.Controllers
return true;
}
// private new void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
// {
// if (!Write(e.Data)) return;
// if (State == State.Starting)
// {
// if (Instance.HasExited)
// State = State.Stopped;
// else if (e.Data.Contains("Started"))
// State = State.Started;
// else if (e.Data.Contains("Failed") || e.Data.Contains("Unable")) State = State.Stopped;
// }
// else if (State == State.Started)
// {
// if (e.Data.StartsWith("[APP][Bandwidth]"))
// {
// var splited = e.Data.Replace("[APP][Bandwidth]", "").Trim().Split(',');
// if (splited.Length == 2)
// {
// var uploadSplited = splited[0].Split(':');
// var downloadSplited = splited[1].Split(':');
//
// if (uploadSplited.Length == 2 && downloadSplited.Length == 2)
// if (long.TryParse(uploadSplited[1], out var upload) && long.TryParse(downloadSplited[1], out var download))
// Task.Run(() => OnBandwidthUpdated(upload, download));
// }
// }
// }
// }
public override void Stop()
{
Task.Run(() =>
@@ -253,17 +224,5 @@ namespace Netch.Controllers
});
StopInstance();
}
/// <summary>
/// 流量变动事件
/// </summary>
public event BandwidthUpdateHandler OnBandwidthUpdated;
/// <summary>
/// 流量变动处理器
/// </summary>
/// <param name="upload">上传</param>
/// <param name="download">下载</param>
public delegate void BandwidthUpdateHandler(long upload, long download);
}
}

View File

@@ -237,8 +237,7 @@ namespace Netch.Forms
Visible = true;
ShowInTaskbar = true; // 显示在系统任务栏
WindowState = FormWindowState.Normal; // 还原窗体
NotifyIcon.Visible = true; // 托盘图标隐藏
WindowState = FormWindowState.Normal; // 还原窗体
return;
}
@@ -455,8 +454,7 @@ namespace Netch.Forms
{
Visible = true;
ShowInTaskbar = true; //显示在系统任务栏
WindowState = FormWindowState.Normal; //还原窗体
NotifyIcon.Visible = true; //托盘图标隐藏
WindowState = FormWindowState.Normal; //还原窗体
}
Activate();

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
using System.Windows.Forms;
namespace Netch
{
@@ -12,8 +13,8 @@ namespace Netch
/// 换行
/// </summary>
public const string EOF = "\r\n";
public static readonly string NetchDir = AppDomain.CurrentDomain.BaseDirectory.TrimEnd();
public static readonly string NetchDir = Application.StartupPath;
/// <summary>
/// 主窗体的静态实例

View File

@@ -21,7 +21,7 @@ namespace Netch
using (var mutex = new Mutex(false, "Global\\Netch"))
{
// 设置当前目录
Directory.SetCurrentDirectory(Application.StartupPath);
Directory.SetCurrentDirectory(Global.NetchDir);
// 清理上一次的日志文件,防止淤积占用磁盘空间
if (Directory.Exists("logging"))
@@ -40,7 +40,7 @@ namespace Netch
}
// 预创建目录
var directories = new[] { "mode", "data", "i18n", "logging" };
var directories = new[] {"mode", "data", "i18n", "logging"};
foreach (var item in directories)
{
// 检查是否已经存在
@@ -57,11 +57,11 @@ namespace Netch
// 加载语言
i18N.Load(Global.Settings.Language);
// 记录当前系统语言
Logging.Info($"当前语言:{Global.Settings.Language}");
Logging.Info($"版本: {UpdateChecker.Owner}/{UpdateChecker.Repo}@{UpdateChecker.Version}");
Logging.Info($"主程序创建日期: {File.GetCreationTime(Global.NetchDir + "\\Netch.exe"):yyyy-M-d HH:mm}");
Logging.Info($"主程序 SHA256: {Utils.Utils.SHA256CheckSum(Application.ExecutablePath)}");
Task.Run(() =>
{
Logging.Info($"版本: {UpdateChecker.Owner}/{UpdateChecker.Repo}@{UpdateChecker.Version}");
Logging.Info($"主程序 SHA256: {Utils.Utils.SHA256CheckSum(Application.ExecutablePath)}");
});
// 检查是否已经运行
if (!mutex.WaitOne(0, false))
@@ -88,12 +88,6 @@ namespace Netch
{
Logging.Error(e.Exception.ToString());
Utils.Utils.Open(Logging.LogFile);
/*if (!e.Exception.ToString().Contains("ComboBox"))
{
MessageBox.Show(e.Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}*/
//Application.Exit();
}
}
}

View File

@@ -4,7 +4,7 @@ using Netch.Models;
namespace Netch.Utils
{
public static partial class Logging
public static class Logging
{
public const string LogFile = "logging\\application.log";