11using System . Windows ;
22using System . Windows . Input ;
3+ using System . Windows . Media ;
4+ using System . Windows . Media . Imaging ;
35
46using Microsoft . Win32 ;
57
@@ -16,6 +18,34 @@ namespace Bloxstrap.UI.ViewModels.Settings
1618{
1719 public class ModsViewModel : NotifyPropertyChangedViewModel
1820 {
21+ private ImageSource ? _backgroundPreview ;
22+ private ImageSource ? _loadingScreenPreview ;
23+
24+ public ImageSource ? BackgroundPreview
25+ {
26+ get => _backgroundPreview ;
27+ set
28+ {
29+ _backgroundPreview = value ;
30+ OnPropertyChanged ( nameof ( BackgroundPreview ) ) ;
31+ OnPropertyChanged ( nameof ( BackgroundPreviewVisibility ) ) ;
32+ }
33+ }
34+
35+ public ImageSource ? LoadingScreenPreview
36+ {
37+ get => _loadingScreenPreview ;
38+ set
39+ {
40+ _loadingScreenPreview = value ;
41+ OnPropertyChanged ( nameof ( LoadingScreenPreview ) ) ;
42+ OnPropertyChanged ( nameof ( LoadingScreenPreviewVisibility ) ) ;
43+ }
44+ }
45+
46+ public Visibility BackgroundPreviewVisibility => BackgroundPreview != null ? Visibility . Visible : Visibility . Collapsed ;
47+ public Visibility LoadingScreenPreviewVisibility => LoadingScreenPreview != null ? Visibility . Visible : Visibility . Collapsed ;
48+
1949 private void OpenModsFolder ( ) => Process . Start ( "explorer.exe" , Paths . Modifications ) ;
2050
2151 private readonly Dictionary < string , byte [ ] > FontHeaders = new ( )
@@ -70,6 +100,7 @@ private void ManageCustomBackground()
70100 if ( ! String . IsNullOrEmpty ( BackgroundTask . NewState ) )
71101 {
72102 BackgroundTask . NewState = "" ;
103+ BackgroundPreview = null ;
73104 }
74105 else
75106 {
@@ -85,6 +116,17 @@ private void ManageCustomBackground()
85116 {
86117 using var img = System . Drawing . Image . FromFile ( dialog . FileName ) ;
87118 BackgroundTask . NewState = dialog . FileName ;
119+
120+ // Load preview image
121+ var bitmap = new BitmapImage ( ) ;
122+ bitmap . BeginInit ( ) ;
123+ bitmap . UriSource = new Uri ( dialog . FileName ) ;
124+ bitmap . CacheOption = BitmapCacheOption . OnLoad ;
125+ bitmap . DecodePixelWidth = 400 ; // Resize untuk preview
126+ bitmap . EndInit ( ) ;
127+ bitmap . Freeze ( ) ;
128+
129+ BackgroundPreview = bitmap ;
88130 }
89131 catch
90132 {
@@ -102,6 +144,7 @@ private void ManageCustomLoadingScreen()
102144 if ( ! String . IsNullOrEmpty ( LoadingScreenTask . NewState ) )
103145 {
104146 LoadingScreenTask . NewState = "" ;
147+ LoadingScreenPreview = null ;
105148 }
106149 else
107150 {
@@ -117,6 +160,17 @@ private void ManageCustomLoadingScreen()
117160 {
118161 using var img = System . Drawing . Image . FromFile ( dialog . FileName ) ;
119162 LoadingScreenTask . NewState = dialog . FileName ;
163+
164+ // Load preview image
165+ var bitmap = new BitmapImage ( ) ;
166+ bitmap . BeginInit ( ) ;
167+ bitmap . UriSource = new Uri ( dialog . FileName ) ;
168+ bitmap . CacheOption = BitmapCacheOption . OnLoad ;
169+ bitmap . DecodePixelWidth = 400 ; // Resize untuk preview
170+ bitmap . EndInit ( ) ;
171+ bitmap . Freeze ( ) ;
172+
173+ LoadingScreenPreview = bitmap ;
120174 }
121175 catch
122176 {
0 commit comments