From 9f78a2d0828154921e3dbf70965697e5713e1b17 Mon Sep 17 00:00:00 2001 From: Marco Wende Date: Wed, 10 Jun 2026 21:57:56 +0200 Subject: [PATCH] Add MainViewModel.ps1 --- MVVM/ViewModels/MainViewModel.ps1 | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 MVVM/ViewModels/MainViewModel.ps1 diff --git a/MVVM/ViewModels/MainViewModel.ps1 b/MVVM/ViewModels/MainViewModel.ps1 new file mode 100644 index 0000000..6bb276c --- /dev/null +++ b/MVVM/ViewModels/MainViewModel.ps1 @@ -0,0 +1,48 @@ +class MainViewModel : FirefoxAddinManager.ObservableBase { + + [DeployViewModel] $Deploy + [DiagnosticViewModel] $Diagnostic + + hidden [string] $_firefoxPath = "" + hidden [string] $_statusBar = "" + hidden [bool] $_isAdmin = $false + hidden [bool] $_isIntune = $false + + [string] $FirefoxPath { + get { return $this._firefoxPath } + set { $this._firefoxPath = $value; $this.OnPropertyChanged("FirefoxPath") } + } + + [string] $StatusBar { + get { return $this._statusBar } + set { $this._statusBar = $value; $this.OnPropertyChanged("StatusBar") } + } + + [bool] $IsAdmin { + get { return $this._isAdmin } + set { $this._isAdmin = $value; $this.OnPropertyChanged("IsAdmin") } + } + + [bool] $IsIntune { + get { return $this._isIntune } + set { $this._isIntune = $value; $this.OnPropertyChanged("IsIntune") } + } + + [string] AdminLabel { + get { return if ($this.IsAdmin) { "Administrator-Modus aktiv" } else { "KEIN Admin - eingeschraenkte Funktionen" } } + } + + [string] IntuneLabel { + get { return if ($this.IsIntune) { "Intune: erkannt" } else { "Intune: nicht erkannt" } } + } + + MainViewModel() { + $this.Deploy = [DeployViewModel]::new() + $this.Diagnostic = [DiagnosticViewModel]::new() + $this.IsAdmin = [FirefoxService]::IsAdmin() + $this.IsIntune = [FirefoxService]::IsIntuneManaged() + $ffDir = [FirefoxService]::FindInstallDir() + $this.FirefoxPath = if ($ffDir) { $ffDir } else { "Firefox nicht gefunden" } + $this.StatusBar = "Firefox: $($this.FirefoxPath) | $($this.AdminLabel) | $($this.IntuneLabel)" + } +}