Add a way to pan from the preview.
[master-thesis.git] / Parasitemia / Parasitemia / GUI / GUI.fs
1 module Parasitemia.GUI.Main
2
3 open System
4 open System.IO
5 open System.Linq
6 open System.Windows
7 open System.Windows.Media
8 open System.Windows.Markup
9 open System.Windows.Shapes
10 open System.Windows.Controls
11 open System.Diagnostics
12 open Microsoft.Win32 // For the common dialogs.
13
14 open Emgu.CV.WPF
15
16 open Config
17 open Types
18
19 let run (defaultConfig: Config) =
20 let app = new Application()
21 let mainWindow = Views.MainWindow()
22 let ctrl (name: string): 'a =
23 mainWindow.Root.FindName(name) :?> 'a
24
25 let colorRBCHealthy = Brushes.YellowGreen
26 let colorRBCInfected = Brushes.Red
27
28 let state = State.State()
29 let mutable currentScale = 1.
30 let mutable displayHealthy = false
31
32 let menuExit: MenuItem = ctrl "menuExit"
33 let menuSaveFile: MenuItem = ctrl "menuSave"
34 let menuLoadFile: MenuItem = ctrl "menuOpen"
35 let menuNewFile: MenuItem = ctrl "menuNew"
36 let menuAddSourceImage: MenuItem = ctrl "menuAddSourceImage"
37 let menuStartAnalysis: MenuItem = ctrl "menuStartAnalysis"
38 let menuHightlightRBC: MenuItem = ctrl "menuHightlightRBC"
39
40 let txtPatient: TextBox = ctrl "txtPatient"
41 let txtGlobalParasitemia: TextBox = ctrl "txtGlobalParasitemia"
42
43 let stackPreviews: StackPanel = ctrl "stackPreviews"
44
45 let scrollViewCurrentImage: ScrollViewer = ctrl "scrollViewCurrentImage"
46 let borderCurrentImage: Border = ctrl "borderCurrentImage"
47 let canvasCurrentImage: Canvas = ctrl "canvasCurrentImage"
48 let txtImageInformation: TextBlock = ctrl "txtImageInformation"
49
50 let scrollRBC: ScrollViewer = ctrl "scrollRBC"
51 let stackRBC: StackPanel = ctrl "stackRBC"
52
53 // Initializations.
54 menuHightlightRBC.IsChecked <- displayHealthy
55
56 // Utils.
57 let extractRBCPreview (img: Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte>) (rbc: RBC) : Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> =
58 let rbcWidth = rbc.size.Width
59 let rbcHeight = rbc.size.Height
60 let x = rbc.center.X - rbcWidth / 2. |> Utils.roundInt
61 let y = rbc.center.Y - rbcHeight / 2. |> Utils.roundInt
62 let w = Utils.roundInt rbcWidth
63 let h = Utils.roundInt rbcHeight
64 //Utils.dprintfn "w: %A, h: %A, cx: %A, cy: %A, img.w: %A, img.h: %A" w h x y img.Width img.Height
65 img.GetSubRect(System.Drawing.Rectangle(System.Drawing.Point((if x < 0 then 0 else x), (if y < 0 then 0 else y)),
66 System.Drawing.Size((if x + w >= img.Width then img.Width - x else w),
67 (if y + h >= img.Height then img.Height - y else h))))
68
69 let setRBCFrameStyle (rbc: RBC) (frame: Views.RBCFrame) =
70 frame.Opacity <- if displayHealthy || rbc.setManually || rbc.infected then 1. else 0.
71 let color = if rbc.infected then colorRBCInfected else colorRBCHealthy
72 frame.manuallyAdded.Visibility <- if rbc.setManually then Visibility.Visible else Visibility.Hidden
73 frame.manuallyAdded.Fill <- color
74 frame.border.Stroke <- color
75
76 let RBCFrameFromExisting (rbc: RBC) (frame: Views.RBCFrame) : Views.RBCFrame =
77 frame.Visibility <- Visibility.Visible
78 frame.Height <- rbc.size.Height
79 frame.Width <- rbc.size.Width
80 frame.Tag <- rbc
81 setRBCFrameStyle rbc frame
82 frame.border.StrokeThickness <- 1.
83 frame.txtRBCNumber.Text <- rbc.num.ToString()
84 frame
85
86 let highlightRBCFrame (frame: Views.RBCFrame) (highlight: bool) =
87 let rbc = frame.Tag :?> RBC
88 if highlight
89 then
90 frame.border.StrokeThickness <- 3.
91 if not rbc.infected && not rbc.setManually && not displayHealthy then frame.Opacity <- 1.
92 else
93 frame.border.StrokeThickness <- 1.
94 if not rbc.infected && not rbc.setManually && not displayHealthy then frame.Opacity <- 0.
95
96 let zoomToRBC (rbc: RBC) =
97 scrollViewCurrentImage.ScrollToHorizontalOffset(rbc.center.X * currentScale - scrollViewCurrentImage.ViewportWidth / 2. + borderCurrentImage.BorderThickness.Left)
98 scrollViewCurrentImage.ScrollToVerticalOffset(rbc.center.Y * currentScale - scrollViewCurrentImage.ViewportHeight / 2. + borderCurrentImage.BorderThickness.Top)
99
100 let parasitemiaText (nbTotal: int, nbInfected: int) : string =
101 if nbTotal = 0
102 then
103 ""
104 else
105 let percent = 100. * (float nbInfected) / (float nbTotal)
106 sprintf "%.1f %% (%d / %d)" percent nbInfected nbTotal
107
108 let updateCurrentImageInformation () =
109 match state.CurrentImage with
110 | Some srcImg ->
111 let parasitemiaStr = parasitemiaText (state.ImageParasitemia srcImg)
112 txtImageInformation.Inlines.Clear()
113 txtImageInformation.Inlines.Add(Documents.Run("Parasitemia: ", FontWeight = FontWeights.Bold))
114 txtImageInformation.Inlines.Add(parasitemiaStr)
115 txtImageInformation.Inlines.Add(Documents.LineBreak())
116
117 txtImageInformation.Inlines.Add(Documents.Run("Average erytrocyte diameter: ", FontWeight = FontWeights.Bold))
118 txtImageInformation.Inlines.Add(Documents.Run(string (Utils.roundInt <| 2. * srcImg.rbcRadius)))
119 txtImageInformation.Inlines.Add(Documents.Run(" px"))
120 txtImageInformation.Inlines.Add(Documents.LineBreak())
121
122 txtImageInformation.Inlines.Add(Documents.Run("Last analysis: ", FontWeight = FontWeights.Bold))
123 txtImageInformation.Inlines.Add(Documents.Run(if srcImg.dateLastAnalysis.Ticks = 0L then "<Never>" else srcImg.dateLastAnalysis.ToLocalTime().ToString()))
124 | _ -> ()
125
126 let updateGlobalParasitemia () =
127 txtGlobalParasitemia.Text <- parasitemiaText state.GlobalParasitemia
128
129 let rec setAsInfected (rbc: RBC) (infected: bool) =
130 state.SetAsInfected rbc infected
131 canvasCurrentImage.Children
132 |> Seq.cast<Views.RBCFrame>
133 |> Seq.iter
134 (fun frame ->
135 if (frame.Tag :?> RBC) = rbc
136 then
137 setRBCFrameStyle rbc frame)
138 updateRBCFramesPreview ()
139 updateCurrentImageInformation ()
140 updateGlobalParasitemia ()
141
142 and RBCFrame (rbc: RBC) : Views.RBCFrame =
143 let f = RBCFrameFromExisting rbc (Views.RBCFrame())
144 f.menuRBCSetAsHealthy.Click.AddHandler(fun obj args -> setAsInfected (f.Tag :?> RBC) false)
145 f.menuRBCSetAsInfected.Click.AddHandler(fun obj args -> setAsInfected (f.Tag :?> RBC) true)
146 f.ContextMenuOpening.AddHandler(
147 fun obj args ->
148 if (f.Tag :?> RBC).infected
149 then
150 f.menuRBCSetAsHealthy.Visibility <- Visibility.Visible
151 f.menuRBCSetAsInfected.Visibility <- Visibility.Collapsed
152 else
153 f.menuRBCSetAsHealthy.Visibility <- Visibility.Collapsed
154 f.menuRBCSetAsInfected.Visibility <- Visibility.Visible)
155
156 f.ContextMenuClosing.AddHandler(fun obj args -> if not f.IsMouseOver then highlightRBCFrame f false )
157 f.MouseEnter.AddHandler(fun obj args -> highlightRBCFrame f true)
158 f.MouseLeave.AddHandler(fun obj args -> if not f.grid.ContextMenu.IsOpen then highlightRBCFrame f false)
159 f
160
161 and updateRBCFramesPreview () =
162 match state.CurrentImage with
163 | Some srcImg ->
164 let mutable currentPreview = 0
165 for rbc in srcImg.rbcs |> List.filter (fun rbc -> displayHealthy || rbc.infected) do
166 let previewInfected =
167 if currentPreview < stackRBC.Children.Count
168 then
169 RBCFrameFromExisting rbc (stackRBC.Children.[currentPreview] :?> Views.RBCFrame)
170 else
171 let f = RBCFrame rbc
172 f.MouseLeftButtonUp.AddHandler(fun obj args -> zoomToRBC (f.Tag :?> RBC))
173 stackRBC.Children.Add(f) |> ignore
174 f
175
176 currentPreview <- currentPreview + 1
177
178 previewInfected.Height <- stackRBC.ActualHeight
179 previewInfected.Width <- stackRBC.ActualHeight * rbc.size.Width / rbc.size.Height
180 previewInfected.border.Fill <- ImageBrush(BitmapSourceConvert.ToBitmapSource(extractRBCPreview srcImg.img rbc))
181
182 stackRBC.Children.RemoveRange(currentPreview, stackRBC.Children.Count - currentPreview)
183 | _ -> ()
184
185 let updateRBCFramesCurrent () =
186 match state.CurrentImage with
187 | Some srcImg ->
188 let mutable currentCanvas = 0
189 for rbc in srcImg.rbcs do
190 let frame =
191 if currentCanvas < canvasCurrentImage.Children.Count
192 then
193 RBCFrameFromExisting rbc (canvasCurrentImage.Children.[currentCanvas] :?> Views.RBCFrame)
194 else
195 let f = RBCFrame rbc
196 canvasCurrentImage.Children.Add(f) |> ignore
197 f
198
199 currentCanvas <- currentCanvas + 1
200
201 Canvas.SetLeft(frame, rbc.center.X - rbc.size.Width / 2.)
202 Canvas.SetTop(frame, rbc.center.Y - rbc.size.Height / 2.)
203
204 for i in currentCanvas .. canvasCurrentImage.Children.Count - 1 do
205 canvasCurrentImage.Children.[i].Visibility <- Visibility.Hidden
206 | _ -> ()
207
208 let saveCurrentDocument () =
209 if state.FilePath = ""
210 then
211 let dialog = SaveFileDialog(AddExtension = true, DefaultExt = PiaZ.extension, Filter = PiaZ.filter);
212 let res = dialog.ShowDialog()
213 if res.HasValue && res.Value
214 then
215 state.FilePath <- dialog.FileName
216 state.Save()
217 else
218 state.Save()
219
220 // Ask the use to save the current document if neccessary.
221 let askSaveCurrent () =
222 if state.AlteredSinceLastSave
223 then
224 match MessageBox.Show("Would you like to save the current document?", "Saving the current document", MessageBoxButton.YesNo, MessageBoxImage.Question) with
225 | MessageBoxResult.Yes -> saveCurrentDocument ()
226 | _ -> ()
227
228 let updateCurrentImage () =
229 match state.CurrentImage with
230 | Some srcImg ->
231 // Highlight the preview.
232 stackPreviews.Children
233 |> Seq.cast<Views.ImageSourcePreview>
234 |> Seq.iter (fun preview -> preview.border.BorderThickness <- Thickness(if preview.Tag = (srcImg :> Object) then 3. else 0.))
235
236 canvasCurrentImage.Height <- float srcImg.img.Height
237 canvasCurrentImage.Width <- float srcImg.img.Width
238 canvasCurrentImage.Background <- ImageBrush(BitmapSourceConvert.ToBitmapSource(srcImg.img))
239
240 updateRBCFramesCurrent ()
241 updateRBCFramesPreview ()
242 updateCurrentImageInformation ()
243 | None ->
244 stackRBC.Children.Clear()
245 canvasCurrentImage.Children.Clear()
246 canvasCurrentImage.Background <- Brushes.Black
247
248 let setCurrentImage (srcImg: SourceImage) =
249 if state.CurrentImage.IsNone || state.CurrentImage.Value <> srcImg
250 then
251 state.CurrentImage <- Some srcImg
252 updateCurrentImage ()
253
254 let updateViewportPreview () =
255 for preview in stackPreviews.Children |> Seq.cast<Views.ImageSourcePreview> do
256 let srcImg = preview.Tag :?> SourceImage
257 if Some srcImg = state.CurrentImage then
258 preview.viewport.Visibility <- Visibility.Visible
259
260 let canvasWidth = canvasCurrentImage.ActualWidth * currentScale
261 let canvasHeight = canvasCurrentImage.ActualHeight * currentScale
262 let previewWidth = (preview.ActualWidth - preview.BorderThickness.Left - preview.BorderThickness.Right)
263 let previewHeight = (preview.ActualHeight - preview.BorderThickness.Top - preview.BorderThickness.Bottom)
264
265 let marginLeft = previewWidth * (scrollViewCurrentImage.HorizontalOffset - borderCurrentImage.BorderThickness.Left) / canvasWidth - 2.
266 let marginRight = previewWidth * (canvasWidth - (scrollViewCurrentImage.HorizontalOffset - borderCurrentImage.BorderThickness.Right) - scrollViewCurrentImage.ViewportWidth) / canvasWidth - 2.
267 let marginTop = previewHeight * (scrollViewCurrentImage.VerticalOffset - borderCurrentImage.BorderThickness.Top) / canvasHeight - 2.
268 let marginBottom = previewHeight * (canvasHeight - (scrollViewCurrentImage.VerticalOffset - borderCurrentImage.BorderThickness.Bottom) - scrollViewCurrentImage.ViewportHeight) / canvasHeight - 2.
269
270 preview.viewport.Margin <-
271 Thickness(
272 marginLeft,
273 marginTop,
274 marginRight,
275 marginBottom)
276 else
277 preview.viewport.Visibility <- Visibility.Hidden
278
279 let addPreview (srcImg: SourceImage) =
280 let imgCtrl = Views.ImageSourcePreview(Margin = Thickness(3.))
281
282 imgCtrl.menuRemoveImage.Click.AddHandler(fun obj args ->
283 stackPreviews.Children.Remove(imgCtrl)
284 let srcImg = imgCtrl.Tag :?> SourceImage
285 let currentRemoved = Some srcImg = state.CurrentImage
286 state.RemoveSourceImage srcImg
287 if currentRemoved
288 then
289 updateCurrentImage()
290 stackPreviews.Children |> Seq.cast<Views.ImageSourcePreview> |> Seq.iter (fun imgPreview -> imgPreview.txtImageNumber.Text <- (imgPreview.Tag :?> SourceImage).num.ToString()))
291
292 imgCtrl.Tag <- srcImg
293 imgCtrl.txtImageNumber.Text <- srcImg.num.ToString()
294 let width = 200
295 let height = srcImg.img.Height * width / srcImg.img.Width
296 imgCtrl.imagePreview.Source <- BitmapSourceConvert.ToBitmapSource(srcImg.img.Resize(width, height, Emgu.CV.CvEnum.Inter.Cubic))
297 stackPreviews.Children.Add(imgCtrl) |> ignore
298
299 // Zoom to a mouse position into the control 'imgCtrl'.
300 let zoomTo (mousePos: Point) =
301 let canvasW = canvasCurrentImage.ActualWidth * currentScale
302 let canvasH = canvasCurrentImage.ActualHeight * currentScale
303 let centerX = (mousePos.X - imgCtrl.BorderThickness.Left) / (imgCtrl.ActualWidth - imgCtrl.BorderThickness.Left) * canvasW
304 let centerY = (mousePos.Y - imgCtrl.BorderThickness.Top) / (imgCtrl.ActualHeight - imgCtrl.BorderThickness.Top) * canvasH
305 scrollViewCurrentImage.ScrollToHorizontalOffset(centerX - scrollViewCurrentImage.ViewportWidth / 2. + borderCurrentImage.BorderThickness.Left)
306 scrollViewCurrentImage.ScrollToVerticalOffset(centerY - scrollViewCurrentImage.ViewportHeight / 2. + borderCurrentImage.BorderThickness.Top)
307
308 imgCtrl.MouseLeftButtonDown.AddHandler(fun obj args ->
309 setCurrentImage (state.SourceImages |> Seq.find (fun srcImg -> (srcImg :> Object) = imgCtrl.Tag))
310 imgCtrl.UpdateLayout()
311 zoomTo (args.GetPosition(imgCtrl))
312 imgCtrl.CaptureMouse() |> ignore)
313
314 imgCtrl.MouseMove.AddHandler(fun obj args ->
315 if imgCtrl.IsMouseCaptured
316 then
317 zoomTo (args.GetPosition(imgCtrl)))
318
319 imgCtrl.MouseLeftButtonUp.AddHandler(fun obj args ->
320 if imgCtrl.IsMouseCaptured
321 then
322 imgCtrl.ReleaseMouseCapture())
323
324
325 let updatePreviews () =
326 stackPreviews.Children.Clear ()
327 for srcImg in state.SourceImages do
328 addPreview srcImg
329 updateCurrentImage ()
330
331 let updateGUI () =
332 txtPatient.Text <- state.PatientID
333 updatePreviews ()
334 updateGlobalParasitemia ()
335
336 txtPatient.TextChanged.AddHandler(fun obj args -> state.PatientID <- txtPatient.Text)
337
338 menuExit.Click.AddHandler(fun obj args ->
339 askSaveCurrent ()
340 mainWindow.Root.Close())
341
342 menuSaveFile.Click.AddHandler(fun obj args -> saveCurrentDocument ())
343
344 menuLoadFile.Click.AddHandler(fun obj args ->
345 // TODO: if current state not saved and not empty, ask to save it.
346 let dialog = OpenFileDialog(Filter = PiaZ.filter)
347 let res = dialog.ShowDialog()
348 if res.HasValue && res.Value
349 then
350 askSaveCurrent ()
351 state.FilePath <- dialog.FileName
352 state.Load()
353 updateGUI ())
354
355 menuNewFile.Click.AddHandler(fun obj args ->
356 askSaveCurrent ()
357 state.Reset()
358 updateGUI())
359
360 menuAddSourceImage.Click.AddHandler(fun obj args ->
361 let dialog = OpenFileDialog(Filter = "Image Files|*.png;*.jpg;*.tif;*.tiff")
362 let res = dialog.ShowDialog()
363 if res.HasValue && res.Value
364 then
365 let srcImg = state.AddSourceImage(dialog.FileName)
366 addPreview srcImg
367 updateGlobalParasitemia ()
368 if state.SourceImages.Count() = 1
369 then
370 updateCurrentImage ())
371
372 menuStartAnalysis.Click.AddHandler(fun obj args ->
373 if Analysis.showWindow mainWindow.Root state defaultConfig
374 then
375 updateGlobalParasitemia ()
376 updateCurrentImage ())
377
378 menuHightlightRBC.Click.AddHandler(fun obj args ->
379 displayHealthy <- menuHightlightRBC.IsChecked
380 updateRBCFramesPreview ()
381 updateRBCFramesCurrent ())
382
383 // Zoom on the current image.
384 let adjustCurrentImageBorders (deltaX: float) (deltaY: float) =
385 borderCurrentImage.BorderThickness <-
386 Thickness(
387 (scrollViewCurrentImage.ViewportWidth + deltaX) / 2.,
388 (scrollViewCurrentImage.ViewportHeight + deltaY) / 2.,
389 (scrollViewCurrentImage.ViewportWidth + deltaX) / 2.,
390 (scrollViewCurrentImage.ViewportHeight + deltaY) / 2.)
391
392 canvasCurrentImage.SizeChanged.AddHandler(fun obj args ->
393 let deltaX = args.NewSize.Width - args.PreviousSize.Width
394 let deltaY = args.NewSize.Height - args.PreviousSize.Height
395 if deltaX > 0.5 || deltaY > 0.5
396 then
397 adjustCurrentImageBorders 0.0 0.0
398 // Center the view at the center of the image initialy.
399 scrollViewCurrentImage.UpdateLayout()
400 scrollViewCurrentImage.ScrollToHorizontalOffset(borderCurrentImage.ActualWidth / 2. - scrollViewCurrentImage.ViewportWidth / 2.)
401 scrollViewCurrentImage.ScrollToVerticalOffset(borderCurrentImage.ActualHeight / 2. - scrollViewCurrentImage.ViewportHeight / 2.))
402
403 scrollViewCurrentImage.SizeChanged.AddHandler(fun obj args ->
404 let deltaX = args.NewSize.Width - args.PreviousSize.Width
405 let deltaY = args.NewSize.Height - args.PreviousSize.Height
406 adjustCurrentImageBorders deltaX deltaY
407 scrollViewCurrentImage.ScrollToHorizontalOffset(scrollViewCurrentImage.HorizontalOffset + deltaX / 8.)
408 scrollViewCurrentImage.ScrollToVerticalOffset(scrollViewCurrentImage.VerticalOffset + deltaY / 8.))
409
410 let mutable maxScale = 4.
411 let mutable minScale = 0.25
412 let currentImageScaleTransform = ScaleTransform()
413 canvasCurrentImage.LayoutTransform <- currentImageScaleTransform
414 borderCurrentImage.PreviewMouseWheel.AddHandler(fun obj args ->
415 let scaleFactor = if args.Delta > 0 then 2.0 else 0.5
416 if scaleFactor > 1. && currentScale < maxScale || scaleFactor < 1. && currentScale > minScale
417 then
418 let previousScale = currentScale
419 currentScale <-
420 let newScale = currentScale * scaleFactor
421 if newScale > maxScale then maxScale elif newScale < minScale then minScale else newScale
422 let realScaleFactor = currentScale / previousScale
423
424 let centerX = scrollViewCurrentImage.HorizontalOffset + scrollViewCurrentImage.ViewportWidth / 2. - borderCurrentImage.BorderThickness.Left
425 let centerY = scrollViewCurrentImage.VerticalOffset + scrollViewCurrentImage.ViewportHeight / 2. - borderCurrentImage.BorderThickness.Top
426
427 currentImageScaleTransform.ScaleX <- currentScale
428 currentImageScaleTransform.ScaleY <- currentScale
429
430 scrollViewCurrentImage.ScrollToHorizontalOffset(centerX * realScaleFactor - scrollViewCurrentImage.ViewportWidth / 2. + borderCurrentImage.BorderThickness.Left)
431 scrollViewCurrentImage.ScrollToVerticalOffset(centerY * realScaleFactor - scrollViewCurrentImage.ViewportHeight / 2. + borderCurrentImage.BorderThickness.Top)
432
433 args.Handled <- true)
434
435 // Pan on the current image.
436 let mutable scrollStartPosition = Point(0., 0.)
437 let mutable scrollStartOffsetX = 0.
438 let mutable scrollStartOffsetY = 0.
439 borderCurrentImage.PreviewMouseLeftButtonDown.AddHandler(fun obj args ->
440 scrollStartPosition <- args.GetPosition(scrollViewCurrentImage)
441 scrollStartOffsetX <- scrollViewCurrentImage.HorizontalOffset
442 scrollStartOffsetY <- scrollViewCurrentImage.VerticalOffset
443 borderCurrentImage.Cursor <- Input.Cursors.ScrollAll
444 borderCurrentImage.CaptureMouse() |> ignore
445 args.Handled <- true)
446
447 borderCurrentImage.PreviewMouseMove.AddHandler(fun obj args ->
448 if borderCurrentImage.IsMouseCaptured
449 then
450 let position = args.GetPosition(scrollViewCurrentImage)
451 let deltaX = scrollStartPosition.X - position.X
452 let deltaY = scrollStartPosition.Y - position.Y
453 scrollViewCurrentImage.ScrollToHorizontalOffset(deltaX + scrollStartOffsetX)
454 scrollViewCurrentImage.ScrollToVerticalOffset(deltaY + scrollStartOffsetY)
455
456 args.Handled <- true)
457
458 borderCurrentImage.PreviewMouseLeftButtonUp.AddHandler(fun obj args ->
459 if borderCurrentImage.IsMouseCaptured
460 then
461 borderCurrentImage.Cursor <- Input.Cursors.Arrow
462 borderCurrentImage.ReleaseMouseCapture()
463 args.Handled <- true)
464
465 // Viewport preview.
466 scrollViewCurrentImage.ScrollChanged.AddHandler(fun obj args -> updateViewportPreview ())
467
468 mainWindow.Root.Show()
469 app.Run()