Files
firefox-addin-manager/MVVM/ViewModels/MainViewModel.ps1
T
2026-06-10 21:57:56 +02:00

49 lines
1.7 KiB
PowerShell

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)"
}
}