55using System . Threading ;
66using System . Threading . Tasks ;
77using System . Windows . Forms ;
8+ using HtmlAgilityPack ;
89using Windows . ApplicationModel ;
910using Windows . Management . Deployment ;
1011using xtrance . Properties ;
@@ -45,6 +46,7 @@ public Form1()
4546 textBoxDirectory . Text = Properties . Settings . Default . FilesPath ;
4647 textBoxDirectory . TextChanged += TextBox_TextChanged ;
4748
49+ buttonOK . Enabled = true ; buttonCancel . Enabled = false ;
4850
4951
5052 new Thread ( ( ) =>
@@ -85,7 +87,7 @@ public Form1()
8587 { IsBackground = true } . Start ( ) ;
8688 }
8789
88- private string RootPath => textBoxDirectory . Text + @"\" ;
90+ private string RootPath => @"\\?\" + textBoxDirectory . Text + @"\" ;
8991
9092 private void TextBox_TextChanged ( object sender , EventArgs e )
9193 {
@@ -111,6 +113,7 @@ private void buttonOK_Click(object sender, EventArgs e)
111113 string user = textBoxUser . Text ;
112114 string pass = textBoxPassword . Text ;
113115 int serverId = Int32 . Parse ( textBoxServer . Text ) ;
116+ buttonOK . Enabled = false ; buttonCancel . Enabled = true ;
114117
115118 _task = Task . Run ( async ( ) =>
116119 {
@@ -171,7 +174,11 @@ private void buttonOK_Click(object sender, EventArgs e)
171174 {
172175 Log ( ex . ToString ( ) ) ;
173176 }
174- } , _cancellationToken . Token ) . ContinueWith ( _ => Log ( "done" ) ) ;
177+ } , _cancellationToken . Token ) . ContinueWith ( _ => {
178+ Log ( "done" ) ;
179+ buttonOK . Invoke ( ( Action ) ( ( ) => buttonOK . Enabled = true ) ) ;
180+ buttonCancel . Invoke ( ( Action ) ( ( ) => buttonCancel . Enabled = false ) ) ;
181+ } ) ;
175182 }
176183
177184 private void SaveBook ( Book book )
@@ -195,6 +202,7 @@ private void SaveMetaBook(MetaBook metaBook)
195202 {
196203 Log ( "Saving metabook : " + metaBook . ToString ( ) ) ;
197204 string path = Sanitize ( metaBook . Author ) + @"\" + Sanitize ( metaBook . Name ) ;
205+
198206 Directory . CreateDirectory ( RootPath + path ) ;
199207 if ( metaBook . Data != null )
200208 {
@@ -216,7 +224,12 @@ private void labelFrom_Click(object sender, EventArgs e)
216224
217225 private string Sanitize ( string input )
218226 {
219- return String . Join ( "_" , input . Split ( Path . GetInvalidFileNameChars ( ) ) ) . TrimEnd ( '.' ) . Trim ( ) ;
227+ string s = String . Join ( "_" , input . Split ( Path . GetInvalidFileNameChars ( ) ) ) . TrimEnd ( '.' ) . Trim ( ) ;
228+ if ( s . Length > 250 )
229+ {
230+ s = s . Substring ( 0 , 250 ) ;
231+ }
232+ return s ;
220233 }
221234
222235 private void buttonUpdate_Click ( object sender , EventArgs e )
0 commit comments