@@ -101,6 +101,19 @@ public UIFactory(WindowIcon applicationIcon, string releaseNotesSeparatorTemplat
101
101
/// </summary>
102
102
public ReleaseNotesGrabber ReleaseNotesGrabberOverride { get ; set ; } = null ;
103
103
104
+ /// <summary>
105
+ /// A delegate for handling windows that are created by a <see cref="UIFactory"/>
106
+ /// </summary>
107
+ /// <param name="window"><see cref="Window"/> that has been created and initialized (with view model, if applicable)</param>
108
+ /// <param name="factory"><see cref="UIFactory"/> that created the given <see cref="Window"/></param>
109
+ public delegate void WindowHandler ( Window window , UIFactory factory ) ;
110
+
111
+ /// <summary>
112
+ /// Set this property to manually do any other setup on a <see cref="Window"/> after it has been created by the <see cref="UIFactory"/>.
113
+ /// Can be used to tweak view models, change styles on the <see cref="Window"/>, etc.
114
+ /// </summary>
115
+ public WindowHandler ProcessWindowAfterInit { get ; set ; }
116
+
104
117
/// <inheritdoc/>
105
118
public virtual IUpdateAvailable CreateUpdateAvailableWindow ( SparkleUpdater sparkle , List < AppCastItem > updates , bool isUpdateAlreadyDownloaded = false )
106
119
{
@@ -130,6 +143,7 @@ public virtual IUpdateAvailable CreateUpdateAvailableWindow(SparkleUpdater spark
130
143
viewModel . ReleaseNotesGrabber = ReleaseNotesGrabberOverride ;
131
144
}
132
145
viewModel . Initialize ( sparkle , updates , isUpdateAlreadyDownloaded , ReleaseNotesHTMLTemplate , AdditionalReleaseNotesHeaderHTML , ReleaseNotesDateTimeFormat ) ;
146
+ ProcessWindowAfterInit ? . Invoke ( window , this ) ;
133
147
return window ;
134
148
}
135
149
@@ -141,19 +155,23 @@ public virtual IDownloadProgress CreateProgressWindow(SparkleUpdater sparkle, Ap
141
155
ItemToDownload = item ,
142
156
SoftwareWillRelaunchAfterUpdateInstalled = sparkle . RelaunchAfterUpdate
143
157
} ;
144
- return new DownloadProgressWindow ( viewModel , _iconBitmap )
158
+ var window = new DownloadProgressWindow ( viewModel , _iconBitmap )
145
159
{
146
160
Icon = _applicationIcon
147
161
} ;
162
+ ProcessWindowAfterInit ? . Invoke ( window , this ) ;
163
+ return window ;
148
164
}
149
165
150
166
/// <inheritdoc/>
151
167
public virtual ICheckingForUpdates ShowCheckingForUpdates ( SparkleUpdater sparkle )
152
168
{
153
- return new CheckingForUpdatesWindow ( _iconBitmap )
169
+ var window = new CheckingForUpdatesWindow ( _iconBitmap )
154
170
{
155
171
Icon = _applicationIcon
156
172
} ;
173
+ ProcessWindowAfterInit ? . Invoke ( window , this ) ;
174
+ return window ;
157
175
}
158
176
159
177
/// <inheritdoc/>
@@ -211,6 +229,7 @@ private void ShowMessage(string title, string message)
211
229
Icon = _applicationIcon
212
230
} ;
213
231
messageWindow . WindowStartupLocation = WindowStartupLocation . CenterScreen ;
232
+ ProcessWindowAfterInit ? . Invoke ( window , this ) ;
214
233
messageWindow . Show ( ) ; // TODO: This was ShowDialog; will this break anything?
215
234
}
216
235
0 commit comments