| 1 | // Copyright (C) Microsoft Corporation. All rights reserved. |
| 2 | |
| 3 | using WslSettings.Contracts.Services; |
| 4 | |
| 5 | namespace WslSettings.Services; |
| 6 | |
| 7 | public class WindowService : IWindowService |
| 8 | { |
| 9 | public WindowService() |
| 10 | { |
| 11 | } |
| 12 | |
| 13 | public WindowEx CreateOrGetWindow(IWindowService.WindowId windowId) |
| 14 | { |
| 15 | WindowEx window; |
| 16 | switch (windowId) |
| 17 | { |
| 18 | case IWindowService.WindowId.MainWindow: |
| 19 | if (App.MainWindow == null) |
| 20 | { |
| 21 | App.MainWindow = new MainWindow(); |
| 22 | } |
| 23 | |
| 24 | if (App.MainWindow!.Content == null) |
| 25 | { |
| 26 | App.MainWindow.Content = App.GetService<Views.Settings.ShellPage>(); |
| 27 | } |
| 28 | |
| 29 | window = App.MainWindow; |
| 30 | break; |
| 31 | case IWindowService.WindowId.OOBEWindow: |
| 32 | if (App.OOBEWindow == null) |
| 33 | { |
| 34 | App.OOBEWindow = new OOBEWindow(); |
| 35 | } |
| 36 | |
| 37 | if (App.OOBEWindow.Content == null) |
| 38 | { |
| 39 | App.OOBEWindow.Content = App.GetService<Views.OOBE.ShellPage>(); |
| 40 | } |
| 41 | |
| 42 | window = App.OOBEWindow; |
| 43 | break; |
| 44 | default: |
| 45 | throw new ArgumentException("Invalid ActivationWindowId"); |
| 46 | } |
| 47 | |
| 48 | return window; |
| 49 | } |
| 50 | } |