@@ -24,6 +24,7 @@ public partial class ThemePacker : Form
2424
2525 private List < string > _likeds ;
2626 private Dictionary < string , Image > _pictures ;
27+ private Dictionary < string , bool > _shownImages ;
2728 private string _path ;
2829 private int _currentPic ;
2930
@@ -55,9 +56,11 @@ private void ThemePacker_Load(object sender, EventArgs e)
5556 btnLike . Enabled = false ;
5657 btnNext . Enabled = false ;
5758 btnPrevious . Enabled = false ;
59+ btnUnlike . Enabled = false ;
5860 _currentPic = 0 ;
5961 _likeds = new List < string > ( ) ;
6062 _pictures = new Dictionary < string , Image > ( ) ;
63+ _shownImages = new Dictionary < string , bool > ( ) ;
6164 _imageList = new ImageList ( ) ;
6265 _imageList . ImageSize = new Size ( 128 , 128 ) ;
6366 _imageList . ColorDepth = ColorDepth . Depth32Bit ;
@@ -97,7 +100,6 @@ private void ChooseImageFolderToolStripMenuItem_Click(object sender, EventArgs e
97100 btnLike . Enabled = true ;
98101 btnNext . Enabled = true ;
99102 btnPrevious . Enabled = true ;
100- ListShuffle ( ) ;
101103 UpdatePic ( ) ;
102104 }
103105 }
@@ -122,10 +124,39 @@ private async void GenerateFormInspirobotToolStripMenuItem_Click(object sender,
122124 UpdatePic ( ) ;
123125 }
124126
125- private void ListShuffle ( )
127+ private void ImportThemepackToolStripMenuItem_Click ( object sender , EventArgs e )
126128 {
127- Random rng = new Random ( ) ;
128- _pictures = _pictures . OrderBy ( x => rng . Next ( ) ) . ToDictionary ( item => item . Key , item => item . Value ) ;
129+ OpenFileDialog openFileDialog = new OpenFileDialog ( ) ;
130+ openFileDialog . Filter = "Themepack | *.themepack" ;
131+ openFileDialog . Title = "Ouvrir" ;
132+
133+ if ( openFileDialog . ShowDialog ( ) == DialogResult . OK && openFileDialog . FileName . EndsWith ( ".themepack" ) )
134+ {
135+
136+ string filename = $ "temp\\ { openFileDialog . FileName . Split ( '\\ ' ) . Last ( ) } ";
137+ File . Copy ( openFileDialog . FileName , filename ) ;
138+ File . Move ( filename , filename = filename . Replace ( ".themepack" , ".cab" ) ) ;
139+
140+ CabInfo cab = new CabInfo ( filename ) ;
141+ _path = filename . Split ( '.' ) [ 0 ] ;
142+ cab . Unpack ( _path ) ;
143+
144+ _btnNextClick = BtnNext_Click ;
145+ btnNext . Click += _btnNextClick ;
146+
147+ if ( SelectPic ( _path + "\\ DesktopBackground" ) )
148+ {
149+ btnLike . Enabled = true ;
150+ btnNext . Enabled = true ;
151+ btnPrevious . Enabled = true ;
152+ UpdatePic ( ) ;
153+ }
154+
155+ foreach ( var pics in _pictures )
156+ {
157+ BtnLike_Click ( null , null ) ;
158+ }
159+ }
129160 }
130161
131162 private bool SelectPic ( string path = null )
@@ -159,10 +190,6 @@ private void BtnPrevious_Click(object sender, EventArgs e)
159190 _currentPic -- ;
160191 UpdatePic ( ) ;
161192 }
162- else
163- {
164- MessageBox . Show ( "DIS IS ZE BEGINING (joy face)" ) ;
165- }
166193 }
167194
168195 private void UpdatePic ( )
@@ -180,15 +207,12 @@ private void BtnNext_Click(object sender, EventArgs e)
180207 _currentPic ++ ;
181208 UpdatePic ( ) ;
182209 }
183- else
184- {
185- MessageBox . Show ( "DIS IS ZE END (sad face)" ) ;
186- }
187210 }
188211
189212 private void BtnLike_Click ( object sender , EventArgs e )
190213 {
191214 btnGenerate . Enabled = true ;
215+ btnUnlike . Enabled = true ;
192216
193217 var currentImg = _pictures . ElementAt ( _currentPic ) ;
194218 if ( ! _likeds . Contains ( currentImg . Key ) )
@@ -294,6 +318,11 @@ private void BtnUnlike_Click(object sender, EventArgs e)
294318
295319 UpdatePic ( ) ;
296320 }
321+
322+ if ( picturesLsv . Items . Count == 0 )
323+ {
324+ btnUnlike . Enabled = false ;
325+ }
297326 }
298327
299328 private async void BtnNext_Click_API ( object sender , EventArgs e )
@@ -352,50 +381,23 @@ private async Task GetImageFromInspirobot()
352381 }
353382 }
354383
355- private void ThemePacker_FormClosed ( object sender , FormClosedEventArgs e )
356- {
357- ClearPictures ( ) ;
358- if ( Directory . Exists ( "temp" ) )
359- {
360- Directory . Delete ( "temp" , true ) ;
361- }
362- }
363-
364- private void ImportThemepackToolStripMenuItem_Click ( object sender , EventArgs e )
384+ private void AsImageFolderToolStripMenuItem_Click ( object sender , EventArgs e )
365385 {
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- {
372-
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 ) ;
380386
381- if ( SelectPic ( _path + "\\ DesktopBackground" ) )
382- {
383- btnLike . Enabled = true ;
384- btnNext . Enabled = true ;
385- btnPrevious . Enabled = true ;
386- UpdatePic ( ) ;
387- }
388- }
389387 }
390388
391- private void AsImageFolderToolStripMenuItem_Click ( object sender , EventArgs e )
389+ ~ ThemePacker ( )
392390 {
393-
391+ ClearPictures ( ) ;
394392 }
395393
396- ~ ThemePacker ( )
394+ private void ThemePacker_FormClosing ( object sender , FormClosingEventArgs e )
397395 {
398396 ClearPictures ( ) ;
397+ if ( Directory . Exists ( "temp" ) )
398+ {
399+ Directory . Delete ( "temp" , true ) ;
400+ }
399401 }
400402 }
401403}
0 commit comments