Skip to content

Commit cb82617

Browse files
committed
修改优化文件夹结构
1 parent f2af444 commit cb82617

28 files changed

+57
-42
lines changed
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
using System.IO;
77
using System.Diagnostics;
88
using System.Windows.Forms;
9+
using TimeControl.Tools;
910

10-
namespace TimeControl
11+
namespace TimeControl.AppControl
1112
{
1213
public class App
1314
{
14-
public AppInformation appInformation=new();
15-
internal int tempTime=0;
15+
public AppInformation appInformation = new();
16+
internal int tempTime = 0;
1617
/// <summary>
1718
/// 返回进程的简要概述
1819
/// </summary>
@@ -21,7 +22,7 @@ public override string ToString()
2122
{
2223
return appInformation.name + " 已使用:" + TimeConvert.DescribeTime(appInformation.time);
2324
}
24-
public App(string name,int time, int restInterval)
25+
public App(string name, int time, int restInterval)
2526
{
2627
appInformation.time = time;
2728
appInformation.name = name;
@@ -43,7 +44,7 @@ public virtual void Run()
4344
internal void CheckRest()
4445
{
4546
tempTime++;
46-
if (tempTime >= appInformation.restInterval &&appInformation.restInterval !=0)
47+
if (tempTime >= appInformation.restInterval && appInformation.restInterval != 0)
4748
{
4849
tempTime = 0;
4950
MessageBox.Show(appInformation.name + "休息时间已到,暂停休息一下吧。", "提示", MessageBoxButtons.OK,
@@ -59,8 +60,8 @@ public void Reset()
5960
}
6061
public bool IsRunning()
6162
{
62-
Process[] processes=Process.GetProcessesByName(appInformation.name);
63-
if (processes.Length>0)
63+
Process[] processes = Process.GetProcessesByName(appInformation.name);
64+
if (processes.Length > 0)
6465
return true;
6566
return false;
6667
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
using System.Threading.Tasks;
77
using System.Windows.Forms;
88
using System.IO;
9+
using TimeControl.Tools;
910

10-
namespace TimeControl
11+
namespace TimeControl.AppControl
1112
{
1213
public class AppController
1314
{
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
using System.Text;
66
using System.Threading.Tasks;
77

8-
namespace TimeControl
8+
namespace TimeControl.AppControl
99
{
1010
public class AppInformation
1111
{
1212
public string name;
13-
public int time=0;
14-
public int restInterval=0;
15-
public int timeLimit=0;
13+
public int time = 0;
14+
public int restInterval = 0;
15+
public int timeLimit = 0;
1616
}
1717
}
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,33 @@
66
using System.Diagnostics;
77
using System.Windows.Forms;
88
using System.IO;
9+
using TimeControl.Tools;
10+
using TimeControl.Windows;
911

10-
namespace TimeControl
12+
namespace TimeControl.AppControl
1113
{
1214
public class LimitedApp : App
1315
{
14-
15-
public LimitedApp(string name,int time,int timeLimit,int restInterval) :
16-
base(name,time,restInterval)
16+
17+
public LimitedApp(string name, int time, int timeLimit, int restInterval) :
18+
base(name, time, restInterval)
1719
{
1820
appInformation.timeLimit = timeLimit;
1921
}
20-
public LimitedApp(AppInformation appInformation):base(appInformation)
22+
public LimitedApp(AppInformation appInformation) : base(appInformation)
2123
{ }
2224
/// <summary>
2325
/// 运行一次(一秒),并根据情况显示警告或关闭进程,然后保存到文件
2426
/// </summary>
2527
public override void Run()
2628
{
2729
appInformation.time++;
28-
if (appInformation.time ==appInformation.timeLimit - 30)
30+
if (appInformation.time == appInformation.timeLimit - 30)
2931
{
3032
LimitWarningWindow warningWindow = new(this);
3133
warningWindow.Show();
3234
}
33-
if (appInformation.time >=appInformation.timeLimit)
35+
if (appInformation.time >= appInformation.timeLimit)
3436
{
3537
Ban();
3638
}
@@ -42,7 +44,7 @@ public override void Run()
4244
/// <returns>时间受限进程的简要概述</returns>
4345
public override string ToString()
4446
{
45-
return base.ToString() + " 进程时间限制为:" +TimeConvert.DescribeTime(appInformation.timeLimit);
47+
return base.ToString() + " 进程时间限制为:" + TimeConvert.DescribeTime(appInformation.timeLimit);
4648
}
4749
/// <summary>
4850
/// 禁用掉该程序

TimeControl/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using System.Windows.Forms;
66
using System.Diagnostics;
77
using System.IO;
8+
using TimeControl.Tools;
9+
using TimeControl.Windows;
810

911
namespace TimeControl
1012
{
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
using System.Text;
77
using System.Threading.Tasks;
88

9-
namespace TimeControl
9+
namespace TimeControl.Tools
1010
{
1111
public static class Command
1212
{
1313
public static void RunCommand(string command)
1414
{
1515
ProcessStartInfo info = new();
1616
info.FileName = "cmd.exe";
17-
info.CreateNoWindow=true;
17+
info.CreateNoWindow = true;
1818
info.RedirectStandardInput = true;
1919
Process process = Process.Start(info);
2020
process.StandardInput.WriteLine(command);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Threading.Tasks;
66
using System.Runtime.InteropServices;
77

8-
namespace TimeControl
8+
namespace TimeControl.Tools
99
{
1010
static class Dllimport
1111
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Threading.Tasks;
66
using System.Security.Cryptography;
77

8-
namespace TimeControl
8+
namespace TimeControl.Tools
99
{
1010
internal static class Password
1111
{
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
using System.Threading.Tasks;
66
using System.Xml.Serialization;
77
using System.IO;
8+
using TimeControl.AppControl;
89

9-
namespace TimeControl
10+
namespace TimeControl.Tools
1011
{
1112
public static class TimeControlFile
1213
{
@@ -22,12 +23,12 @@ public static void SaveToXML(List<App> apps)
2223
{
2324
DirectoryInfo directoryInfo = new DirectoryInfo(TimeFileDirectory);
2425
FileInfo[] files = directoryInfo.GetFiles();
25-
if(files.Length>=10)
26+
if (files.Length >= 10)
2627
{
2728
foreach (FileInfo file in files)
2829
File.Delete(file.FullName);
2930
}
30-
using (StreamWriter sw = new StreamWriter(TimeFileDirectory +
31+
using (StreamWriter sw = new StreamWriter(TimeFileDirectory +
3132
$"\\{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}.xml"))
3233
{
3334
XmlSerializer xmlSerializer = new(typeof(List<AppInformation>));
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66

7-
namespace TimeControl
7+
namespace TimeControl.Tools
88
{
99
static class TimeConvert
1010
{
@@ -16,11 +16,11 @@ public static string DescribeTime(int seconds) =>
1616
/// <summary>
1717
/// 舍去剩余的秒数,返回整时间分钟数
1818
/// </summary>
19-
public static int ToIntMinutes(int seconds)=>Convert.ToInt32(seconds / 60);
19+
public static int ToIntMinutes(int seconds) => Convert.ToInt32(seconds / 60);
2020
/// <summary>
2121
/// 获取除去整数分后剩余的秒数
2222
/// </summary>
23-
public static int GetExtraSeconds(int seconds)=> Convert.ToInt32(seconds %60);
23+
public static int GetExtraSeconds(int seconds) => Convert.ToInt32(seconds % 60);
2424
/// <summary>
2525
/// 分钟转秒
2626
/// </summary>

0 commit comments

Comments
 (0)