@@ -16,8 +16,6 @@ namespace ZipImageViewer
1616 public partial class ViewWindow : BorderlessWindow , INotifyPropertyChanged
1717 {
1818 public event PropertyChangedEventHandler PropertyChanged ;
19- private readonly MainWindow mainWin ;
20-
2119
2220 private ( string BasePath , string SubPath ) viewPath ;
2321 /// <summary>
@@ -118,32 +116,29 @@ public ObservablePair<DependencyProps, DependencyProps> TransParams {
118116 private Setting . Transition LastTransition = Setting . Transition . None ;
119117
120118
121- public ViewWindow ( string basePath , string subPath , MainWindow win = null )
119+ public ViewWindow ( string basePath , string subPath )
122120 {
123121 InitializeComponent ( ) ;
124122 Opacity = 0d ;
125- mainWin = win ;
126123
127124 ViewPath = ( basePath , subPath ) ;
128125 }
129126
130127 private void ViewWindow_Loaded ( object sender , RoutedEventArgs e ) {
131128 //restore last state
132- if ( mainWin != null ) {
133- if ( mainWin . lastViewWindowRect != default ) {
134- Top = mainWin . lastViewWindowRect . Top ;
135- Left = mainWin . lastViewWindowRect . Left ;
136- if ( mainWin . lastViewWindowRect . Size != default ) {
137- Width = mainWin . lastViewWindowRect . Width ;
138- Height = mainWin . lastViewWindowRect . Height ;
139- }
140- else {
141- WindowState = WindowState . Maximized ;
142- }
129+ if ( Setting . LastViewWindowRect != default ) {
130+ Top = Setting . LastViewWindowRect . Top ;
131+ Left = Setting . LastViewWindowRect . Left ;
132+ if ( Setting . LastViewWindowRect . Size != default ) {
133+ Width = Setting . LastViewWindowRect . Width ;
134+ Height = Setting . LastViewWindowRect . Height ;
135+ }
136+ else {
137+ WindowState = WindowState . Maximized ;
143138 }
144- if ( Setting . ImmersionMode )
145- SwitchFullScreen ( this , ref mainWin . lastViewWindowRect , true ) ;
146139 }
140+ if ( Setting . ImmersionMode )
141+ SwitchFullScreen ( this , ref Setting . LastViewWindowRect , true ) ;
147142
148143 //fade in window content
149144 this . AnimateDoubleCubicEase ( OpacityProperty , 1d , 100 , EasingMode . EaseOut ) ;
@@ -155,12 +150,10 @@ private void ViewWin_Closed(object sender, EventArgs e) {
155150
156151 private void ViewWin_Closing ( object sender , CancelEventArgs e ) {
157152 //save window state
158- if ( mainWin != null ) {
159- if ( WindowState == WindowState . Maximized || IsFullScreen ( this ) )
160- mainWin . lastViewWindowRect = new Rect ( Left , Top , 0d , 0d ) ;
161- else
162- mainWin . lastViewWindowRect = new Rect ( Left , Top , ActualWidth , ActualHeight ) ;
163- }
153+ if ( WindowState == WindowState . Maximized || IsFullScreen ( this ) )
154+ Setting . LastViewWindowRect = new Rect ( Left , Top , 0d , 0d ) ;
155+ else
156+ Setting . LastViewWindowRect = new Rect ( Left , Top , ActualWidth , ActualHeight ) ;
164157
165158 IM . Source = null ;
166159 IM = null ;
0 commit comments