Skip to content

Commit fd72837

Browse files
implement edit config and restart in FileSyncAppWin
1 parent 61fdb53 commit fd72837

3 files changed

Lines changed: 78 additions & 13 deletions

File tree

FileSyncAppWin/MainForm.Designer.cs

Lines changed: 45 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FileSyncAppWin/MainForm.cs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ namespace FileSyncAppWin
33
public partial class MainForm : Form
44
{
55
Thread consoleThread;
6+
string[] Args;
67

78
public MainForm(string[] args)
89
{
910
InitializeComponent();
11+
Args = args;
1012
this.FormClosing += (s, e) => { FileSyncApp.Program.keepRunning = false; consoleThread?.Join(10_000); };
11-
consoleThread = new Thread(() =>
12-
{
13-
FileSyncApp.Program.Main(args);
14-
});
13+
1514
FileSyncApp.Program.JobsReady += (s, e) =>
1615
{
1716
foreach (var job in FileSyncApp.Program.Jobs)
@@ -33,8 +32,7 @@ public MainForm(string[] args)
3332

3433

3534
};
36-
consoleThread.Start();
37-
35+
3836
this.Resize += ((s, e) =>
3937
{
4038
this.SuspendLayout();
@@ -57,11 +55,26 @@ public MainForm(string[] args)
5755
};
5856
notifyIcon1.BalloonTipClicked += (s, e) => { this.BeginInvoke(() => { WindowState = FormWindowState.Normal; ShowInTaskbar = true; }); };
5957
//notifyIcon1.BalloonTipShown += (s, e) => { ShowInTaskbar = false; };
60-
58+
StartConsoleThread();
6159
//this.WindowState = FormWindowState.Minimized;
6260
}
6361

62+
void StartConsoleThread()
63+
{
64+
consoleThread = new Thread(() =>
65+
{
66+
FileSyncApp.Program.Main(Args);
67+
});
68+
consoleThread.Start();
6469

70+
}
71+
void Restart()
72+
{
73+
FileSyncApp.Program.keepRunning = false;
74+
consoleThread?.Join(10_000);
75+
FileSyncApp.Program.keepRunning = true;
76+
StartConsoleThread();
77+
}
6578

6679

6780
private void NewLogOutput(string e)
@@ -70,5 +83,16 @@ private void NewLogOutput(string e)
7083
this.BeginInvoke(() => { textBox1.Text = string.Join(Environment.NewLine, (new string[] { $"{DateTime.Now.ToString("HH:mm:ss.fff")} {e}" }).Concat(textBox1.Text.Split(Environment.NewLine).Take(1000))); });
7184

7285
}
86+
87+
private void btn_Config_Click(object sender, EventArgs e)
88+
{
89+
FileSyncAppConfigEditor.JobsEditForm jobsEditForm = new FileSyncAppConfigEditor.JobsEditForm("config.json");
90+
jobsEditForm.ShowDialog();
91+
}
92+
93+
private void btn_Restart_Click(object sender, EventArgs e)
94+
{
95+
Restart();
96+
}
7397
}
7498
}

FileSyncAppWin/MainForm.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
4-
Microsoft ResX Schema
4+
Microsoft ResX Schema
55
66
Version 2.0
77
@@ -48,7 +48,7 @@
4848
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
51-
51+
5252
mimetype: application/x-microsoft.net.object.soap.base64
5353
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter

0 commit comments

Comments
 (0)