public override void UpdateFields(int NewValue, UpdatingSettings UpSet) { if (UpSet.Equals(UpdatingSettings.Armor) && NewValue <= 2 && NewValue > 0) { //base.UpdateFields(NewValue, UpSet); Armor = NewValue; } else if (UpSet.Equals(UpdatingSettings.Distance) && NewValue <= 4 && NewValue > 0) { Distance = NewValue; //base.UpdateFields(NewValue, UpSet); } else if (UpSet.Equals(UpdatingSettings.HP) && NewValue <= 40 && NewValue > 0) { HP = NewValue; //base.UpdateFields(NewValue, UpSet); } else if (UpSet.Equals(UpdatingSettings.Price) && NewValue <= 500 && NewValue > 0) { Price = NewValue; // base.UpdateFields(NewValue, UpSet); } else { throw new Exception("Incorrect characteristics"); } }
public void RefreshUpdatingState() { object oLock = new object(); lock (oLock) { var config = UpdatingSettings.LoadSettings(); // Retry loading if failed for (int i = 0; i < 3 && config == null; i++) { System.Threading.Thread.Sleep(100); config = UpdatingSettings.LoadSettings(); } if (config == null) { return; } UpdatingSettingsConfig = config; if (PowerToysUpdatingState != config.State) { IsNewVersionDownloading = false; } else { bool dateChanged = UpdateCheckedDate == UpdatingSettingsConfig.LastCheckedDateLocalized; bool fileDownloaded = string.IsNullOrEmpty(UpdatingSettingsConfig.DownloadedInstallerFilename); IsNewVersionDownloading = !(dateChanged || fileDownloaded); } PowerToysUpdatingState = UpdatingSettingsConfig.State; PowerToysNewAvailableVersion = UpdatingSettingsConfig.NewVersion; PowerToysNewAvailableVersionLink = UpdatingSettingsConfig.ReleasePageLink; UpdateCheckedDate = UpdatingSettingsConfig.LastCheckedDateLocalized; _isNewVersionChecked = PowerToysUpdatingState == UpdatingSettings.UpdatingState.UpToDate && !IsNewVersionDownloading; NotifyPropertyChanged(nameof(IsNewVersionCheckedAndUpToDate)); NotifyPropertyChanged(nameof(IsDownloadAllowed)); } }
public virtual void UpdateFields(int NewValue, UpdatingSettings UpSet) { switch (UpSet) { case UpdatingSettings.Armor: Armor = NewValue; break; case UpdatingSettings.Distance: Distance = NewValue; break; case UpdatingSettings.HP: HP = NewValue; break; case UpdatingSettings.Price: Price = NewValue; break; } }
public override void UpdateFields(int NewValue, UpdatingSettings UpSet)//Переопределенный метод для установки характеристик Берсерков { if (UpSet.Equals(UpdatingSettings.Armor) && NewValue <= 2 && NewValue > 0) { Armor = NewValue; //Никаких родительских вызовов, - свой метод!! } else if (UpSet.Equals(UpdatingSettings.Distance) && NewValue <= 4 && NewValue > 0) { Distance = NewValue; } else if (UpSet.Equals(UpdatingSettings.HP) && NewValue <= 50 && NewValue > 0) { HP = NewValue; } else if (UpSet.Equals(UpdatingSettings.Price) && NewValue <= 500 && NewValue > 0) { Price = NewValue; } else { throw new Exception("Incorrect characteristics"); } }
public GeneralViewModel(ISettingsRepository <GeneralSettings> settingsRepository, string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func <string, int> updateTheme, Func <string, int> ipcMSGCallBackFunc, Func <string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func <string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "", Action dispatcherAction = null) { CheckForUpdatesEventHandler = new ButtonClickCommand(CheckForUpdatesClick); RestartElevatedButtonEventHandler = new ButtonClickCommand(RestartElevated); UpdateNowButtonEventHandler = new ButtonClickCommand(UpdateNowClick); // To obtain the general settings configuration of PowerToys if it exists, else to create a new file and return the default configurations. if (settingsRepository == null) { throw new ArgumentNullException(nameof(settingsRepository)); } GeneralSettingsConfig = settingsRepository.SettingsConfig; UpdatingSettingsConfig = UpdatingSettings.LoadSettings(); if (UpdatingSettingsConfig == null) { UpdatingSettingsConfig = new UpdatingSettings(); } // set the callback functions value to hangle outgoing IPC message. SendConfigMSG = ipcMSGCallBackFunc; SendCheckForUpdatesConfigMSG = ipcMSGCheckForUpdatesCallBackFunc; SendRestartAsAdminConfigMSG = ipcMSGRestartAsAdminMSGCallBackFunc; // set the callback function value to update the UI theme. UpdateUIThemeCallBack = updateTheme; UpdateUIThemeCallBack(GeneralSettingsConfig.Theme); // Update Settings file folder: _settingsConfigFileFolder = configFileSubfolder; // Using Invariant here as these are internal strings and fxcop // expects strings to be normalized to uppercase. While the theme names // are represented in lowercase everywhere else, we'll use uppercase // normalization for switch statements switch (GeneralSettingsConfig.Theme.ToUpperInvariant()) { case "DARK": _themeIndex = 0; break; case "LIGHT": _themeIndex = 1; break; case "SYSTEM": _themeIndex = 2; break; } _startup = GeneralSettingsConfig.Startup; _autoDownloadUpdates = GeneralSettingsConfig.AutoDownloadUpdates; _isElevated = isElevated; _runElevated = GeneralSettingsConfig.RunElevated; RunningAsUserDefaultText = runAsUserText; RunningAsAdminDefaultText = runAsAdminText; _isAdmin = isAdmin; _updatingState = UpdatingSettingsConfig.State; _newAvailableVersion = UpdatingSettingsConfig.NewVersion; _newAvailableVersionLink = UpdatingSettingsConfig.ReleasePageLink; _updateCheckedDate = UpdatingSettingsConfig.LastCheckedDateLocalized; if (dispatcherAction != null) { _fileWatcher = Helper.GetFileWatcher(string.Empty, UpdatingSettings.SettingsFile, dispatcherAction); } }