11using Microsoft . Deployment . Compression . Cab ;
2+ using Newtonsoft . Json . Linq ;
23using System ;
34using System . Collections . Generic ;
45using System . Data ;
@@ -25,9 +26,8 @@ public partial class ThemePacker : Form
2526 private Dictionary < string , Image > _pictures ;
2627 private string _path ;
2728 private int _currentPic ;
28- private bool _isFolderBased ;
2929
30- private CustomProgressBar pbProgression ;
30+ private CustomProgressBar _pbProgression ;
3131
3232 private EventHandler _btnNextClick ;
3333
@@ -36,14 +36,14 @@ public partial class ThemePacker : Form
3636 public ThemePacker ( )
3737 {
3838 InitializeComponent ( ) ;
39- pbProgression = new CustomProgressBar ( ) ; pbProgression . Location = new Point ( 69 , 496 ) ;
40- pbProgression . MarqueeAnimationSpeed = 0 ;
41- pbProgression . Name = "pbProgression" ;
42- pbProgression . Size = new Size ( 400 , 28 ) ;
43- pbProgression . Style = ProgressBarStyle . Continuous ;
44- pbProgression . TabIndex = 16 ;
45- pbProgression . DisplayStyle = ProgressBarDisplayText . CustomText ;
46- Controls . Add ( pbProgression ) ;
39+ _pbProgression = new CustomProgressBar ( ) ; _pbProgression . Location = new Point ( 69 , 496 ) ;
40+ _pbProgression . MarqueeAnimationSpeed = 0 ;
41+ _pbProgression . Name = "pbProgression" ;
42+ _pbProgression . Size = new Size ( 400 , 28 ) ;
43+ _pbProgression . Style = ProgressBarStyle . Continuous ;
44+ _pbProgression . TabIndex = 16 ;
45+ _pbProgression . DisplayStyle = ProgressBarDisplayText . CustomText ;
46+ Controls . Add ( _pbProgression ) ;
4747 }
4848
4949 private void ThemePacker_Load ( object sender , EventArgs e )
@@ -98,7 +98,6 @@ private void ChooseImageFolderToolStripMenuItem_Click(object sender, EventArgs e
9898 btnNext . Enabled = true ;
9999 btnPrevious . Enabled = true ;
100100 ListShuffle ( ) ;
101- _isFolderBased = true ;
102101 UpdatePic ( ) ;
103102 }
104103 }
@@ -113,8 +112,6 @@ private async void GenerateFormInspirobotToolStripMenuItem_Click(object sender,
113112
114113 _currentPic = 0 ;
115114
116- _isFolderBased = false ;
117-
118115 _btnNextClick = BtnNext_Click_API ;
119116 btnNext . Click += _btnNextClick ;
120117
@@ -167,9 +164,9 @@ private void BtnPrevious_Click(object sender, EventArgs e)
167164 private void UpdatePic ( )
168165 {
169166 pbWallpaper . Image = _pictures . ElementAt ( _currentPic ) . Value ;
170- pbProgression . Value = ( int ) Math . Ceiling ( ( ( _currentPic + 1 ) * 100 ) / ( decimal ) ( _pictures . Count ) ) ;
171- pbProgression . CustomText = $ "{ _currentPic + 1 } / { _pictures . Count } ";
172- pbProgression . Refresh ( ) ;
167+ _pbProgression . Value = ( int ) Math . Ceiling ( ( ( _currentPic + 1 ) * 100 ) / ( decimal ) ( _pictures . Count ) ) ;
168+ _pbProgression . CustomText = $ "{ _currentPic + 1 } / { _pictures . Count } ";
169+ _pbProgression . Refresh ( ) ;
173170 }
174171
175172 private void BtnNext_Click ( object sender , EventArgs e )
@@ -234,10 +231,19 @@ public void Generate()
234231
235232 CopyQuick ( ) ;
236233
234+ ThemeFileSerializer tfs = new ThemeFileSerializer ( "temp\\ super.theme" ) ;
235+ tfs . Deserialize ( ) ;
236+ JObject theme = tfs . JSON ;
237+ theme [ "Theme" ] [ "DisplayName" ] = fileName ;
238+ theme [ "Control Panel_Desktop" ] [ "TileWallpaper" ] = "0" ;
239+ theme [ "Control Panel_Desktop" ] [ "WallpaperStyle" ] = "2" ;
240+ theme [ "Slideshow" ] [ "Interval" ] = "60000" ;
241+
242+ tfs . JSON = theme ;
243+ tfs . JsonSerialize ( ) ;
237244
238245 //read and replace
239246 string text = File . ReadAllText ( "temp\\ super.theme" ) ;
240- text = text . Replace ( "DisplayName=Tinderspirobot" , "DisplayName=" + fileName ) ;
241247 File . WriteAllText ( "temp\\ super.theme" , text ) ;
242248
243249 CabInfo cab = new CabInfo ( saveFileDialog . FileName ) ;
@@ -246,6 +252,11 @@ public void Generate()
246252 Environment . Exit ( 7 ) ;
247253 }
248254
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 ;
258+ }
259+
249260 private void CopyQuick ( )
250261 {
251262 foreach ( string path in _likeds )
0 commit comments