diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index e72a2ec44..fb385de5d 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -951,7 +951,7 @@ namespace Greenshot { } // Only add if the value is not fixed - if (!conf.Values["CaptureMousepointer"].Attributes.FixedValue) { + if (!conf.Values["CaptureMousepointer"].IsFixed) { // For the capture mousecursor option ToolStripMenuSelectListItem captureMouseItem = new ToolStripMenuSelectListItem(); captureMouseItem.Text = Language.GetString("settings_capture_mousepointer"); @@ -964,7 +964,7 @@ namespace Greenshot { this.contextmenu_quicksettings.DropDownItems.Add(captureMouseItem); } ToolStripMenuSelectList selectList = null; - if (!conf.Values["Destinations"].Attributes.FixedValue) { + if (!conf.Values["Destinations"].IsFixed) { // screenshot destination selectList = new ToolStripMenuSelectList("destinations", true); selectList.Text = Language.GetString(LangKey.settings_destination); @@ -976,7 +976,7 @@ namespace Greenshot { this.contextmenu_quicksettings.DropDownItems.Add(selectList); } - if (!conf.Values["WindowCaptureMode"].Attributes.FixedValue) { + if (!conf.Values["WindowCaptureMode"].IsFixed) { // Capture Modes selectList = new ToolStripMenuSelectList("capturemodes", false); selectList.Text = Language.GetString(LangKey.settings_window_capture_mode); @@ -996,7 +996,7 @@ namespace Greenshot { foreach(string propertyName in conf.Values.Keys) { if (propertyName.StartsWith("OutputPrint")) { iniValue = conf.Values[propertyName]; - if (iniValue.Attributes.LanguageKey != null && !iniValue.Attributes.FixedValue) { + if (iniValue.Attributes.LanguageKey != null && !iniValue.IsFixed) { selectList.AddItem(Language.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value); } } @@ -1011,11 +1011,11 @@ namespace Greenshot { selectList.Text = Language.GetString(LangKey.settings_visualization); iniValue = conf.Values["PlayCameraSound"]; - if (!iniValue.Attributes.FixedValue) { + if (!iniValue.IsFixed) { selectList.AddItem(Language.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value); } iniValue = conf.Values["ShowTrayNotification"]; - if (!iniValue.Attributes.FixedValue) { + if (!iniValue.IsFixed) { selectList.AddItem(Language.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value); } if (selectList.DropDownItems.Count > 0) { diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs index 87ac1a8b5..59ee7c7b4 100644 --- a/Greenshot/Forms/SettingsForm.cs +++ b/Greenshot/Forms/SettingsForm.cs @@ -281,7 +281,7 @@ namespace Greenshot { private void DisplayDestinations() { bool destinationsEnabled = true; if (coreConfiguration.Values.ContainsKey("Destinations")) { - destinationsEnabled = !coreConfiguration.Values["Destinations"].Attributes.FixedValue; + destinationsEnabled = !coreConfiguration.Values["Destinations"].IsFixed; } checkbox_picker.Checked = false; @@ -335,23 +335,24 @@ namespace Greenshot { combobox_language.SelectedValue = Language.CurrentLanguage; } // Disable editing when the value is fixed - combobox_language.Enabled = !coreConfiguration.Values["Language"].Attributes.FixedValue; + combobox_language.Enabled = !coreConfiguration.Values["Language"].IsFixed; textbox_storagelocation.Text = FilenameHelper.FillVariables(coreConfiguration.OutputFilePath, false); // Disable editing when the value is fixed - textbox_storagelocation.Enabled = !coreConfiguration.Values["OutputFilePath"].Attributes.FixedValue; + textbox_storagelocation.Enabled = !coreConfiguration.Values["OutputFilePath"].IsFixed; SetWindowCaptureMode(coreConfiguration.WindowCaptureMode); // Disable editing when the value is fixed - combobox_window_capture_mode.Enabled = !coreConfiguration.Values["WindowCaptureMode"].Attributes.FixedValue; + combobox_window_capture_mode.Enabled = !coreConfiguration.Values["WindowCaptureMode"].IsFixed; trackBarJpegQuality.Value = coreConfiguration.OutputFileJpegQuality; + trackBarJpegQuality.Enabled = !coreConfiguration.Values["OutputFileJpegQuality"].IsFixed; textBoxJpegQuality.Text = coreConfiguration.OutputFileJpegQuality+"%"; DisplayDestinations(); numericUpDownWaitTime.Value = coreConfiguration.CaptureDelay >=0?coreConfiguration.CaptureDelay:0; - + numericUpDownWaitTime.Enabled = !coreConfiguration.Values["CaptureDelay"].IsFixed; // Autostart checkbox logic. if (StartupHelper.hasRunAll()) { // Remove runUser if we already have a run under all @@ -365,6 +366,7 @@ namespace Greenshot { } numericUpDown_daysbetweencheck.Value = coreConfiguration.UpdateCheckInterval; + numericUpDown_daysbetweencheck.Enabled = !coreConfiguration.Values["UpdateCheckInterval"].IsFixed; CheckDestinationSettings(); } @@ -520,7 +522,7 @@ namespace Greenshot { bool pickerSelected = checkbox_picker.Checked; bool destinationsEnabled = true; if (coreConfiguration.Values.ContainsKey("Destinations")) { - destinationsEnabled = !coreConfiguration.Values["Destinations"].Attributes.FixedValue; + destinationsEnabled = !coreConfiguration.Values["Destinations"].IsFixed; } listview_destinations.Enabled = destinationsEnabled; diff --git a/GreenshotPlugin/Controls/GreenshotForm.cs b/GreenshotPlugin/Controls/GreenshotForm.cs index ffe443e49..fa6b4c528 100644 --- a/GreenshotPlugin/Controls/GreenshotForm.cs +++ b/GreenshotPlugin/Controls/GreenshotForm.cs @@ -399,7 +399,7 @@ namespace GreenshotPlugin.Controls { CheckBox checkBox = controlObject as CheckBox; if (checkBox != null) { checkBox.Checked = (bool)iniValue.Value; - checkBox.Enabled = !iniValue.Attributes.FixedValue; + checkBox.Enabled = !iniValue.IsFixed; continue; } @@ -410,12 +410,12 @@ namespace GreenshotPlugin.Controls { string hotkeyValue = (string)iniValue.Value; if (!string.IsNullOrEmpty(hotkeyValue)) { hotkeyControl.SetHotkey(hotkeyValue); - hotkeyControl.Enabled = !iniValue.Attributes.FixedValue; + hotkeyControl.Enabled = !iniValue.IsFixed; } continue; } textBox.Text = iniValue.ToString(); - textBox.Enabled = !iniValue.Attributes.FixedValue; + textBox.Enabled = !iniValue.IsFixed; continue; } @@ -423,7 +423,7 @@ namespace GreenshotPlugin.Controls { if (comboxBox != null) { comboxBox.Populate(iniValue.ValueType); comboxBox.SetValue((Enum)iniValue.Value); - comboxBox.Enabled = !iniValue.Attributes.FixedValue; + comboxBox.Enabled = !iniValue.IsFixed; continue; } } diff --git a/GreenshotPlugin/IniFile/IniConfig.cs b/GreenshotPlugin/IniFile/IniConfig.cs index a4ed1da22..208fd6f7f 100644 --- a/GreenshotPlugin/IniFile/IniConfig.cs +++ b/GreenshotPlugin/IniFile/IniConfig.cs @@ -241,7 +241,7 @@ namespace Greenshot.IniFile { if (fixedProperties.TryGetValue(section.IniSectionAttribute.Name, out fixedPropertiesForSection)) { foreach (string fixedPropertyKey in fixedPropertiesForSection.Keys) { if (section.Values.ContainsKey(fixedPropertyKey)) { - section.Values[fixedPropertyKey].Attributes.FixedValue = true; + section.Values[fixedPropertyKey].IsFixed = true; } } } diff --git a/GreenshotPlugin/IniFile/IniValue.cs b/GreenshotPlugin/IniFile/IniValue.cs index 205ab16a7..bf8c996fa 100644 --- a/GreenshotPlugin/IniFile/IniValue.cs +++ b/GreenshotPlugin/IniFile/IniValue.cs @@ -47,12 +47,29 @@ namespace Greenshot.IniFile { this.attributes = iniPropertyAttribute; } + /// + /// Return true when the value is fixed + /// + public bool IsFixed { + get { + if (attributes != null) { + return attributes.FixedValue; + } + return false; + } + set { + if (attributes != null) { + attributes.FixedValue = value; + } + } + } + public MemberInfo MemberInfo { get { if (propertyInfo == null) { return fieldInfo; } else { - return propertyInfo; + return propertyInfo; } } } @@ -104,7 +121,7 @@ namespace Greenshot.IniFile { if (propertyInfo == null) { valueType = fieldInfo.FieldType; } else { - valueType = propertyInfo.PropertyType; + valueType = propertyInfo.PropertyType; } if (valueType.IsGenericType && valueType.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) { // We are dealing with a generic type that is nullable