public MainViewModel() { MainSyncContext = SynchronizationContext.Current; LogFile.LogApplicationVersion(); // Set global callback for cases where Dependency Injection is not possible. App.NavigateToGettingStarted = () => { GettingStartedCommand.Execute(null); }; App.NavigateToUnlockBoot = () => { BootUnlockCommand.Execute(null); }; if (Registry.CurrentUser.OpenSubKey("Software\\WPInternals") == null) { Registry.CurrentUser.OpenSubKey("Software", true).CreateSubKey("WPInternals"); } if ((Registration.IsPrerelease) && (Registry.CurrentUser.OpenSubKey("Software\\WPInternals").GetValue("NdaAccepted") == null)) { this.ContextViewModel = new DisclaimerAndNdaViewModel(Disclaimer_Accepted); } else if (Registry.CurrentUser.OpenSubKey("Software\\WPInternals").GetValue("DisclaimerAccepted") == null) { this.ContextViewModel = new DisclaimerViewModel(Disclaimer_Accepted); } else if ((Registration.IsPrerelease) && !Registration.IsRegistered()) { ContextViewModel = new RegistrationViewModel(Registration_Completed, Registration_Failed); } else { StartOperation(); } }
void Disclaimer_Accepted() { ContextViewModel = null; if ((Registration.IsPrerelease) && !Registration.IsRegistered()) { ContextViewModel = new RegistrationViewModel(Registration_Completed, Registration_Failed); } else { StartOperation(); } }
void PhoneNotifier_NewDeviceArrived(ArrivalEventArgs Args) { PhoneInterfaces?PreviousInterface = LastInterface; LastInterface = Args.NewInterface; if (App.InterruptBoot && (Args.NewInterface == PhoneInterfaces.Lumia_Bootloader)) { App.InterruptBoot = false; LogFile.Log("Found Lumia BootMgr and user forced to interrupt the boot process. Force to Flash-mode."); Task.Run(() => SwitchModeViewModel.SwitchTo(PhoneNotifier, PhoneInterfaces.Lumia_Flash)); } else { if (Args.NewInterface != PhoneInterfaces.Qualcomm_Download) { App.InterruptBoot = false; } if (ContextViewModel == null) { ContextViewModel = InfoViewModel; } else if (ContextViewModel.IsFlashModeOperation) { if ((!ContextViewModel.IsSwitchingInterface) && (Args.NewInterface == PhoneInterfaces.Lumia_Bootloader)) { // The current screen is marked as "Flash operation". // When the bootloader is detected at this stage, it means a phone is booting and // it is possible that the phone is in a non-booting stage (not possible to boot past UEFI). // We will try to boot straight to Flash-mode, so that it will be possible to flash a new ROM. LogFile.Log("Found Lumia BootMgr while mode is not being switched. Screen is marked as Flash Operation. Force to Flash-mode."); Task.Run(() => SwitchModeViewModel.SwitchTo(PhoneNotifier, PhoneInterfaces.Lumia_Flash)); } } else { if ((!ContextViewModel.IsSwitchingInterface) && (Args.NewInterface != PhoneInterfaces.Lumia_Bootloader)) { ContextViewModel = InfoViewModel; } } } }
internal void ActivateSubContext(ContextViewModel NewSubContext) { if (_SubContextViewModel != null) { _SubContextViewModel.IsActive = false; } if (NewSubContext != null) { if (IsActive) { NewSubContext.Activate(); } else { NewSubContext.IsActive = false; } } SubContextViewModel = NewSubContext; }
internal void SwitchToDifferentInterface(PhoneInterfaces TargetInterface) { ModeViewModel.OnModeSwitchRequested(TargetInterface); ContextViewModel = ModeViewModel; }
internal void SwitchToRestoreBoot() { ContextViewModel = BootRestoreViewModel; }
internal void SwitchToDumpFFU() { ContextViewModel = DumpRomViewModel; }
internal void SwitchToDownload() { ContextViewModel = DownloadsViewModel; }
internal void SwitchToBackup() { ContextViewModel = BackupViewModel; }
internal void SwitchToFlashRom() { ContextViewModel = LumiaFlashRomViewModel; }
internal void SwitchToUnlockRoot() { ContextViewModel = RootUnlockViewModel; }
internal void SwitchToUndoRoot() { ContextViewModel = RootRestoreViewModel; }
internal ContextViewModel(MainViewModel Main, ContextViewModel SubContext) : this(Main) { SubContextViewModel = SubContext; }
internal void SwitchToInfoViewModel() { ContextViewModel = InfoViewModel; }
public void StartOperation() { IsMenuEnabled = true; _GettingStartedViewModel = new GettingStartedViewModel( () => { ContextViewModel = new DisclaimerViewModel( () => ContextViewModel = _GettingStartedViewModel ); }, SwitchToUnlockBoot, SwitchToUnlockRoot, SwitchToBackup, SwitchToDumpFFU, SwitchToFlashRom, SwitchToDownload ); this.ContextViewModel = _GettingStartedViewModel; PhoneNotifier = new PhoneNotifierViewModel(); PhoneNotifier.NewDeviceArrived += PhoneNotifier_NewDeviceArrived; PhoneNotifier.DeviceRemoved += PhoneNotifier_DeviceRemoved; InfoViewModel = new LumiaInfoViewModel(PhoneNotifier, (TargetInterface) => { ModeViewModel.OnModeSwitchRequested(TargetInterface); ContextViewModel = ModeViewModel; }, () => { ContextViewModel = _GettingStartedViewModel; }); InfoViewModel.ActivateSubContext(null); ModeViewModel = new LumiaModeViewModel(PhoneNotifier, SwitchToInfoViewModel); ModeViewModel.ActivateSubContext(null); BootUnlockViewModel = new LumiaUnlockBootViewModel(PhoneNotifier, SwitchToFlashRom, SwitchToUndoRoot, SwitchToDownload, true, SwitchToInfoViewModel); BootUnlockViewModel.ActivateSubContext(null); BootRestoreViewModel = new LumiaUnlockBootViewModel(PhoneNotifier, SwitchToFlashRom, SwitchToUndoRoot, SwitchToDownload, false, SwitchToInfoViewModel); BootRestoreViewModel.ActivateSubContext(null); RootUnlockViewModel = new LumiaUnlockRootViewModel(PhoneNotifier, SwitchToUnlockBoot, SwitchToDumpFFU, SwitchToFlashRom, true, SwitchToInfoViewModel); RootUnlockViewModel.ActivateSubContext(null); RootRestoreViewModel = new LumiaUnlockRootViewModel(PhoneNotifier, SwitchToUnlockBoot, SwitchToDumpFFU, SwitchToFlashRom, false, SwitchToInfoViewModel); RootRestoreViewModel.ActivateSubContext(null); BackupViewModel = new BackupViewModel(PhoneNotifier, SwitchToUnlockBoot, SwitchToInfoViewModel); BackupViewModel.ActivateSubContext(null); RestoreViewModel = new RestoreViewModel(PhoneNotifier, SwitchToDifferentInterface, SwitchToUnlockBoot, SwitchToFlashRom, SwitchToInfoViewModel); RestoreViewModel.ActivateSubContext(null); LumiaFlashRomViewModel = new LumiaFlashRomViewModel(PhoneNotifier, SwitchToUnlockBoot, SwitchToUnlockRoot, SwitchToDumpFFU, SwitchToBackup, SwitchToInfoViewModel); LumiaFlashRomViewModel.ActivateSubContext(null); DumpRomViewModel = new DumpRomViewModel(SwitchToUnlockBoot, SwitchToUnlockRoot, SwitchToFlashRom); DumpRomViewModel.ActivateSubContext(null); DownloadsViewModel = new DownloadsViewModel(PhoneNotifier); App.DownloadManager = DownloadsViewModel; PhoneNotifier.Start(); }
void Registration_Failed() { ContextViewModel = new MessageViewModel("Registration failed", () => Environment.Exit(0)); ((MessageViewModel)ContextViewModel).SubMessage = "Check your filewall settings"; }
void Registration_Completed() { ContextViewModel = null; StartOperation(); }