/// <summary> /// Called when the <see cref="ResetToDefaultsCommand" /> is executed. /// </summary> /// <param name="parameter">The command parameter.</param> private void OnResetToDefaultsCommandExecuted(object parameter) { var activeSettingsName = ActiveSettingsName; var result = MessageBox.Show(@"Are you sure you want all " + activeSettingsName + " to be reset to their defaults?" + Environment.NewLine + Environment.NewLine + @"This action cannot be undone.", @"CodeMaid: Confirmation for Reset " + activeSettingsName, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { try { File.Delete(ActiveSettingsPath); RefreshPackageSettings(); ActiveSettings.Reload(); ReloadPagesFromSettings(); MessageBox.Show(string.Format("CodeMaid has successfully reset " + activeSettingsName + "."), "CodeMaid: Reset " + activeSettingsName + " Successful", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine("Unable to reset " + ActiveSettingsName, ex); MessageBox.Show("CodeMaid was unable to reset " + activeSettingsName + ". See output window for more details.", "CodeMaid: Reset " + activeSettingsName + " Unsuccessful", MessageBoxButton.OK, MessageBoxImage.Error); } } }
/// <summary> /// Called when the <see cref="ResetToDefaultsCommand" /> is executed. /// </summary> /// <param name="parameter">The command parameter.</param> private void OnResetToDefaultsCommandExecuted(object parameter) { var activeSettingsName = ActiveSettingsName; var result = MessageBox.Show(Resources.AreYouSureYouWantAll + activeSettingsName + Resources.OptionsViewModel_OnResetToDefaultsCommandExecuted_ToBeResetToTheirDefaults + Environment.NewLine + Environment.NewLine + Resources.ThisActionCannotBeUndone, Resources.CodeMaidConfirmationForReset + activeSettingsName, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { try { File.Delete(ActiveSettingsPath); RefreshPackageSettings(); ActiveSettings.Reload(); ReloadPagesFromSettings(); MessageBox.Show(string.Format(Resources.CodeMaidHasSuccessfullyReset + activeSettingsName + "."), Resources.CodeMaidReset + activeSettingsName + Resources.Successful, MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine(Resources.UnableToReset + ActiveSettingsName, ex); MessageBox.Show(Resources.CodeMaidWasUnableToReset + activeSettingsName + Resources.SeeOutputWindowForMoreDetails, Resources.CodeMaidReset + activeSettingsName + Resources.Unsuccessful, MessageBoxButton.OK, MessageBoxImage.Error); } } }
public void GoToPreviousSettings() { if (ActiveSetting > Enum.GetValues(typeof(ActiveSettings)).Cast <ActiveSettings>().Min()) { ActiveSetting -= 1; } }
/// <summary> /// Called to define a Setting for the Algorithm that can be used at runtime. /// </summary> /// <param name="setting"></param> public void DefineSetting(AlgorithmSetting setting) { //Active if (setting.TypeOfSetting == SettingType.ActiveAndDead || setting.TypeOfSetting == SettingType.ActiveOnly) { var instanceCopy = setting.Clone(); instanceCopy.InstanceType = SettingInstanceType.Active; ActiveSettings.Add(instanceCopy); } //Dead if (setting.TypeOfSetting == SettingType.ActiveAndDead || setting.TypeOfSetting == SettingType.DeadOnly) { var instanceCopy = setting.Clone(); instanceCopy.InstanceType = SettingInstanceType.Dead; DeadSettings.Add(instanceCopy); } //Global if (setting.TypeOfSetting == SettingType.Global) { var instanceCopy = setting.Clone(); instanceCopy.InstanceType = SettingInstanceType.Global; GlobalSettings.Add(instanceCopy); } }
public void GoToNextSetting() { if (ActiveSetting < Enum.GetValues(typeof(ActiveSettings)).Cast <ActiveSettings>().Max()) { ActiveSetting += 1; } }
/// <summary> /// Used from the Settings UI Only - Sets the instance value of the setting. /// </summary> /// <param name="settingName">Name of Setting to Set a value for.</param> /// <param name="type">Type of Setting to Set (Active/Dead/Global)</param> /// <param name="value">The New Instance Value of the Setting</param> internal void SetSetting(string settingName, SettingInstanceType type, int value) { AlgorithmSetting setting; //Select the Proper Collection. switch (type) { case SettingInstanceType.Active: setting = ActiveSettings.First(v => v.Name == settingName); break; case SettingInstanceType.Dead: setting = DeadSettings.First(v => v.Name == settingName); break; case SettingInstanceType.Global: setting = GlobalSettings.First(v => v.Name == settingName); break; default: throw new ArgumentException("Invalid SettingInstanceType Enum", "type"); } //Set the Value in the Proper Collection setting.Value = value; }
/// <summary> /// Returns the Value For the Setting, when the type is Active/Dead (If not found, it will automatically Search in Global) /// </summary> /// <param name="settingName">The Name of the setting to return.</param> /// <param name="OpponentIsDead">Specify which setting to return, (Active or Dead)</param> /// <returns>Returns the Instance Value of the Proper Setting (Active/Dead or Global)</returns> internal int GetSetting(string settingName, bool OpponentIsDead) { AlgorithmSetting foundSetting = null; if (GlobalSettings.Any(v => v.Name == settingName)) { //Setting was not found in Active/Dead - try in Global... foundSetting = GlobalSettings.FirstOrDefault(v => v.Name == settingName); } else { //Get the Value from the Proper Collection. if (OpponentIsDead) { foundSetting = DeadSettings.FirstOrDefault(v => v.Name == settingName); } else { foundSetting = ActiveSettings.FirstOrDefault(v => v.Name == settingName); } } if (foundSetting == null) { Log.Error($"[Custom Algorithm Settings]{settingName} Setting Does not exist! - Developer! - Check Algorithm Configuration!"); return(-1); } return(foundSetting.Value); }
/// <summary> /// Returns a List of Settings in their minimal form for Serializing to JSON. /// </summary> /// <returns></returns> internal List <Setting> GetValuesToSave() { var values = new List <Setting>(); GlobalSettings.ForEach(s => values.Add(s.GetSettingsToSerialize())); ActiveSettings.ForEach(s => values.Add(s.GetSettingsToSerialize())); DeadSettings.ForEach(s => values.Add(s.GetSettingsToSerialize())); return(values); }
/// <summary> /// Constructor /// </summary> public MainForm() { InitializeComponent(); var outerBorderColor = Color.FromArgb(0x80, 0x80, 0x80, 0x80); var innerBorderColor = Color.FromArgb(0x80, 0xB0, 0xC4, 0xDE); Brush innerBrush = new SolidBrush(innerBorderColor); Brush outerBrush = new SolidBrush(outerBorderColor); _innerPen = new Pen(innerBrush); _outerPen = new Pen(outerBrush); _activeSettings = new ActiveSettings(); }
/// <summary> /// Saves the current settings. /// </summary> private void Save() { foreach (var optionsPageViewModel in Pages.Flatten()) { optionsPageViewModel.SaveSettings(); } ActiveSettings.Save(); RefreshPackageSettings(); HasChanges = false; }
static void Main() { // If the program is running, close it: string daemonString = Path.GetDirectoryName(Application.ExecutablePath) + @"\VolumeOSD.exe"; System.Diagnostics.Process.Start(daemonString, "-Q"); Initialize(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool silent = Environment.GetCommandLineArgs().Length > 2 && Environment.GetCommandLineArgs()[2].ToUpper().Equals("-S"); bool activate = Environment.GetCommandLineArgs().Length > 2 && Environment.GetCommandLineArgs()[2].ToUpper().Equals("-A"); string file = Environment.GetCommandLineArgs()[1]; FolderZipper.ZipUtil.UnZipFiles(file, System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KenMazaika\\VolumeOSD\\themes\\", null, false); if (activate) { VolumeOSD.ActiveSettings settings = new ActiveSettings(); char[] del = new char[2]; del[0] = '\\'; del[1] = '.'; string[] splitFilename = file.Split(del); settings.Name = splitFilename[splitFilename.Length - 2]; settings.X = 0; settings.Y = 0; settings.Opacity = 0.0; ActiveSettings.Serialize(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KenMazaika\\VolumeOSD\\Settings.xml", settings); } else if (!silent) { MessageBox.Show("Theme Installed"); } // Launch the previewer if this was a normal double click action if (!activate && !silent) { System.Diagnostics.Process.Start(daemonString, "-P"); } }
/// <summary> /// Called when the <see cref="ImportCommand" /> is executed. /// </summary> /// <param name="parameter">The command parameter.</param> private void OnImportCommandExecuted(object parameter) { if (CheckToSavePendingChangesShouldCancelOperation()) { return; } var activeSettingsName = ActiveSettingsName; var dialog = new Microsoft.Win32.OpenFileDialog { Title = Resources.CodeMaidImport + activeSettingsName, DefaultExt = ".config", Filter = Resources.ConfigFilesConfigConfigAllFiles, CheckFileExists = true }; if (dialog.ShowDialog() == true) { try { File.Copy(dialog.FileName, ActiveSettingsPath, true); File.SetAttributes(ActiveSettingsPath, File.GetAttributes(ActiveSettingsPath) & ~FileAttributes.ReadOnly); RefreshPackageSettings(); ActiveSettings.Reload(); ReloadPagesFromSettings(); MessageBox.Show(string.Format(Resources.CodeMaidHasSuccessfullyImported1From0, dialog.FileName, activeSettingsName), Resources.CodeMaidImport + activeSettingsName + Resources.Successful, MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine(Resources._UnableToImport + activeSettingsName, ex); MessageBox.Show(Resources.CodeMaidWasUnableToImport + activeSettingsName + Resources.SeeOutputWindowForMoreDetails, Resources.CodeMaidImport + activeSettingsName + Resources.Unsuccessful, MessageBoxButton.OK, MessageBoxImage.Error); } } }
/// <summary> /// Called when the <see cref="ImportCommand" /> is executed. /// </summary> /// <param name="parameter">The command parameter.</param> private void OnImportCommandExecuted(object parameter) { if (CheckToSavePendingChangesShouldCancelOperation()) { return; } var activeSettingsName = ActiveSettingsName; var dialog = new Microsoft.Win32.OpenFileDialog { Title = "CodeMaid: Import " + activeSettingsName, DefaultExt = ".config", Filter = "Config files (*.config)|*.config|All Files (*.*)|*.*", CheckFileExists = true }; if (dialog.ShowDialog() == true) { try { File.Copy(dialog.FileName, ActiveSettingsPath, true); RefreshPackageSettings(); ActiveSettings.Reload(); ReloadPagesFromSettings(); MessageBox.Show(string.Format("CodeMaid has successfully imported " + activeSettingsName + " from '{0}'.", dialog.FileName), "CodeMaid: Import " + activeSettingsName + " Successful", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine("Unable to import " + activeSettingsName, ex); MessageBox.Show("CodeMaid was unable to import " + activeSettingsName + ". See output window for more details.", "CodeMaid: Import " + activeSettingsName + " Unsuccessful", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void Start() { try { foreach (ActiveProperties activeProperty in activeProperties) { var activeObjects = GameObject.FindGameObjectsWithTag(activeProperty.objectTag); foreach (var activeObject in activeObjects) { //The developer can simply tag items, and those tags will be affected in the DistanceByTag() function //However, if desired specific game objects can have an attached ActiveSettings script with it's own specific values //Also be aware that if you are going to use ActiveSettings in this manner then that class will need to inherit from MonoBehaviour //var activeSetting = activeObject.GetComponent<ActiveSettings>(); //if (activeSetting == null) //{ var activeSetting = new ActiveSettings(activeObject.transform, activeProperty.minDistance); //} //Example of how the Object Type is used. //if (activeProperty.objectTag == "HBCBuilding") //{ // activeSetting.objectType = ActiveSettings.ObjectType.Building; //} activeItems.Add(activeSetting); } } InvokeRepeating("ActivateObjects", timerStart, timerInterval); } catch (System.Exception ex) { Debug.LogError("ActiveMgmt Start Ex: " + ex.Message); } }
public void AddItem(ActiveSettings activeSetting) { activeItems.Add(activeSetting); }