@@ -64,7 +64,7 @@ private void ThemePacker_Load(object sender, EventArgs e)
6464 picturesLsv . LargeImageList = _imageList ;
6565 picturesLsv . View = View . LargeIcon ;
6666
67- CreateDirectory ( "temp" ) ; //crée un dossier temporaire
67+ CreateDirectory ( "temp\\ themepack " ) ; //crée un dossier temporaire
6868 }
6969
7070 private void ClearPictures ( )
@@ -128,10 +128,15 @@ private void ListShuffle()
128128 _pictures = _pictures . OrderBy ( x => rng . Next ( ) ) . ToDictionary ( item => item . Key , item => item . Value ) ;
129129 }
130130
131- private bool SelectPic ( )
131+ private bool SelectPic ( string path = null )
132132 {
133- List < string > imagesList = Directory . GetFiles ( _path , "*.jpg" , SearchOption . TopDirectoryOnly ) . ToList ( ) ;
134- imagesList . AddRange ( Directory . GetFiles ( _path , "*.png" , SearchOption . TopDirectoryOnly ) ) ;
133+ if ( path == null )
134+ {
135+ path = _path ;
136+ }
137+
138+ List < string > imagesList = Directory . GetFiles ( path , "*.jpg" , SearchOption . TopDirectoryOnly ) . ToList ( ) ;
139+ imagesList . AddRange ( Directory . GetFiles ( path , "*.png" , SearchOption . TopDirectoryOnly ) ) ;
135140 if ( imagesList . Count < 1 )
136141 {
137142 MessageBox . Show ( "Votre dossier ne contient pas d'image ou pas le bon type d'image. (png et jpg only)" ) ;
@@ -158,7 +163,6 @@ private void BtnPrevious_Click(object sender, EventArgs e)
158163 {
159164 MessageBox . Show ( "DIS IS ZE BEGINING (joy face)" ) ;
160165 }
161- //Hide();
162166 }
163167
164168 private void UpdatePic ( )
@@ -240,32 +244,23 @@ public void Generate()
240244 theme [ "Slideshow" ] [ "Interval" ] = "60000" ;
241245
242246 tfs . JSON = theme ;
243- tfs . JsonSerialize ( ) ;
244-
245- //read and replace
246- string text = File . ReadAllText ( "temp\\ super.theme" ) ;
247- File . WriteAllText ( "temp\\ super.theme" , text ) ;
247+ tfs . JsonSerialize ( $ "temp\\ themepack\\ { fileName } .theme") ;
248248
249249 CabInfo cab = new CabInfo ( saveFileDialog . FileName ) ;
250- cab . Pack ( "temp" , true , Microsoft . Deployment . Compression . CompressionLevel . Normal , null ) ;
251-
252- Environment . Exit ( 7 ) ;
253- }
250+ cab . Pack ( "temp\\ themepack" , true , Microsoft . Deployment . Compression . CompressionLevel . Normal , null ) ;
254251
255- private void SetThemeFileSerializerProperty ( dynamic theme , string category , string property , string value )
256- {
257- ( ( theme as IDictionary < string , object > ) [ category ] as IDictionary < string , object > ) [ property ] = value ;
252+ this . Close ( ) ;
258253 }
259254
260255 private void CopyQuick ( )
261256 {
262257 foreach ( string path in _likeds )
263258 {
264- File . Copy ( path , "temp\\ DesktopBackground\\ " + new FileInfo ( path ) . Name ) ;
259+ File . Copy ( path , "temp\\ themepack \\ DesktopBackground\\ " + new FileInfo ( path ) . Name ) ;
265260 }
266261
267262 File . Copy ( "Resources\\ super.theme" , "temp\\ super.theme" , true ) ;
268- File . Copy ( "Resources\\ icon.png" , "temp\\ icon.png" , true ) ;
263+ File . Copy ( "Resources\\ icon.png" , "temp\\ themepack \\ icon.png" , true ) ;
269264 }
270265
271266 private void CreateDirectory ( string path )
@@ -327,6 +322,8 @@ private async void BtnNext_Click_API(object sender, EventArgs e)
327322
328323 private async Task GetImageFromInspirobot ( )
329324 {
325+ Directory . CreateDirectory ( @"temp\images" ) ;
326+
330327 using ( var client = new HttpClient ( ) )
331328 {
332329 client . BaseAddress = new Uri ( "http://inspirobot.me/" ) ;
@@ -342,7 +339,7 @@ private async Task GetImageFromInspirobot()
342339 {
343340 string [ ] urlBits = url . Split ( "/" . ToArray ( ) , StringSplitOptions . RemoveEmptyEntries ) ;
344341 string fileName = urlBits [ urlBits . Length - 1 ] ;
345- string imagePath = $ "temp\\ { fileName } ";
342+ string imagePath = $ "temp\\ images \\ { fileName } ";
346343
347344 Debug . WriteLine ( $ "Starting { fileName } download") ;
348345 webClient . DownloadFile ( new Uri ( url ) , imagePath ) ;
@@ -366,7 +363,29 @@ private void ThemePacker_FormClosed(object sender, FormClosedEventArgs e)
366363
367364 private void ImportThemepackToolStripMenuItem_Click ( object sender , EventArgs e )
368365 {
366+ OpenFileDialog openFileDialog = new OpenFileDialog ( ) ;
367+ openFileDialog . Filter = "Themepack | *.themepack" ;
368+ openFileDialog . Title = "Ouvrir" ;
369+
370+ if ( openFileDialog . ShowDialog ( ) == DialogResult . OK && openFileDialog . FileName . EndsWith ( ".themepack" ) )
371+ {
369372
373+ string filename = $ "temp\\ { openFileDialog . FileName . Split ( '\\ ' ) . Last ( ) } ";
374+ File . Copy ( openFileDialog . FileName , filename ) ;
375+ File . Move ( filename , filename = filename . Replace ( ".themepack" , ".cab" ) ) ;
376+
377+ CabInfo cab = new CabInfo ( filename ) ;
378+ _path = filename . Split ( '.' ) [ 0 ] ;
379+ cab . Unpack ( _path ) ;
380+
381+ if ( SelectPic ( _path + "\\ DesktopBackground" ) )
382+ {
383+ btnLike . Enabled = true ;
384+ btnNext . Enabled = true ;
385+ btnPrevious . Enabled = true ;
386+ UpdatePic ( ) ;
387+ }
388+ }
370389 }
371390
372391 private void AsImageFolderToolStripMenuItem_Click ( object sender , EventArgs e )
0 commit comments