@@ -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}
0 commit comments