@@ -91,6 +91,19 @@ public UIFactory(ImageSource applicationIcon) : this()
91
91
/// </summary>
92
92
public System . Windows . Media . Brush UpdateWindowGridBackgroundBrush { get ; set ; }
93
93
94
+ /// <summary>
95
+ /// A delegate for handling windows that are created by a <see cref="UIFactory"/>
96
+ /// </summary>
97
+ /// <param name="window"><see cref="Window"/> that has been created and initialized (with view model, if applicable)</param>
98
+ /// <param name="factory"><see cref="UIFactory"/> that created the given <see cref="Window"/></param>
99
+ public delegate void WindowHandler ( Window window , UIFactory factory ) ;
100
+
101
+ /// <summary>
102
+ /// Set this property to manually do any other setup on a <see cref="Window"/> after it has been created by the <see cref="UIFactory"/>.
103
+ /// Can be used to tweak view models, change styles on the <see cref="Window"/>, etc.
104
+ /// </summary>
105
+ public WindowHandler ProcessWindowAfterInit { get ; set ; }
106
+
94
107
/// <inheritdoc/>
95
108
public virtual IUpdateAvailable CreateUpdateAvailableWindow ( SparkleUpdater sparkle , List < AppCastItem > updates , bool isUpdateAlreadyDownloaded = false )
96
109
{
@@ -120,6 +133,7 @@ public virtual IUpdateAvailable CreateUpdateAvailableWindow(SparkleUpdater spark
120
133
viewModel . ReleaseNotesGrabber = ReleaseNotesGrabberOverride ;
121
134
}
122
135
viewModel . Initialize ( sparkle , updates , isUpdateAlreadyDownloaded , ReleaseNotesHTMLTemplate , AdditionalReleaseNotesHeaderHTML , ReleaseNotesDateTimeFormat ) ;
136
+ ProcessWindowAfterInit ? . Invoke ( window , this ) ;
123
137
return window ;
124
138
}
125
139
@@ -131,16 +145,20 @@ public virtual IDownloadProgress CreateProgressWindow(SparkleUpdater sparkle, Ap
131
145
ItemToDownload = item ,
132
146
SoftwareWillRelaunchAfterUpdateInstalled = sparkle . RelaunchAfterUpdate
133
147
} ;
134
- return new DownloadProgressWindow ( viewModel )
148
+ var window = new DownloadProgressWindow ( viewModel )
135
149
{
136
150
Icon = _applicationIcon
137
151
} ;
152
+ ProcessWindowAfterInit ? . Invoke ( window , this ) ;
153
+ return window ;
138
154
}
139
155
140
156
/// <inheritdoc/>
141
157
public virtual ICheckingForUpdates ShowCheckingForUpdates ( SparkleUpdater sparkle )
142
158
{
143
- return new CheckingForUpdatesWindow { Icon = _applicationIcon } ;
159
+ var window = new CheckingForUpdatesWindow ( ) { Icon = _applicationIcon } ;
160
+ ProcessWindowAfterInit ? . Invoke ( window , this ) ;
161
+ return window ;
144
162
}
145
163
146
164
/// <inheritdoc/>
@@ -192,6 +210,7 @@ public virtual void ShowToast(SparkleUpdater sparkle, List<AppCastItem> updates,
192
210
} ;
193
211
try
194
212
{
213
+ ProcessWindowAfterInit ? . Invoke ( toast , this ) ;
195
214
toast . Show ( Resources . DefaultUIFactory_ToastMessage , Resources . DefaultUIFactory_ToastCallToAction , 5 ) ;
196
215
System . Windows . Threading . Dispatcher . Run ( ) ;
197
216
}
@@ -218,6 +237,7 @@ private void ShowMessage(string title, string message)
218
237
Icon = _applicationIcon
219
238
} ;
220
239
messageWindow . WindowStartupLocation = WindowStartupLocation . CenterScreen ;
240
+ ProcessWindowAfterInit ? . Invoke ( messageWindow , this ) ;
221
241
messageWindow . ShowDialog ( ) ;
222
242
}
223
243
0 commit comments