mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
This changes enables the settings (most of them) which are supplied in the greenshot-fixed.ini to be unchangeable in the settings.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1969 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
459c2e16f9
commit
48159a99b0
7 changed files with 122 additions and 55 deletions
|
@ -900,39 +900,47 @@ namespace Greenshot {
|
|||
private void InitializeQuickSettingsMenu() {
|
||||
this.contextmenu_quicksettings.DropDownItems.Clear();
|
||||
|
||||
if (conf.DisableQuickSettings) {
|
||||
return;
|
||||
}
|
||||
// For the capture mousecursor option
|
||||
ToolStripMenuSelectListItem captureMouseItem = new ToolStripMenuSelectListItem();
|
||||
captureMouseItem.Text = Language.GetString("settings_capture_mousepointer");
|
||||
captureMouseItem.Checked = conf.CaptureMousepointer;
|
||||
captureMouseItem.CheckOnClick = true;
|
||||
captureMouseItem.CheckStateChanged += delegate {
|
||||
conf.CaptureMousepointer = captureMouseItem.Checked;
|
||||
};
|
||||
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(captureMouseItem);
|
||||
|
||||
// screenshot destination
|
||||
ToolStripMenuSelectList selectList = new ToolStripMenuSelectList("destinations",true);
|
||||
selectList.Text = Language.GetString(LangKey.settings_destination);
|
||||
// Working with IDestination:
|
||||
foreach(IDestination destination in DestinationHelper.GetAllDestinations()) {
|
||||
selectList.AddItem(destination.Description, destination, conf.OutputDestinations.Contains(destination.Designation));
|
||||
if (conf.DisableQuickSettings) {
|
||||
return;
|
||||
}
|
||||
selectList.CheckedChanged += new EventHandler(this.QuickSettingDestinationChanged);
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
|
||||
// Capture Modes
|
||||
selectList = new ToolStripMenuSelectList("capturemodes", false);
|
||||
selectList.Text = Language.GetString(LangKey.settings_window_capture_mode);
|
||||
string enumTypeName = typeof(WindowCaptureMode).Name;
|
||||
foreach(WindowCaptureMode captureMode in Enum.GetValues(typeof(WindowCaptureMode))) {
|
||||
selectList.AddItem(Language.GetString(enumTypeName + "." + captureMode.ToString()), captureMode, conf.WindowCaptureMode == captureMode);
|
||||
// Only add if the value is not fixed
|
||||
if (!conf.Values["CaptureMousepointer"].Attributes.FixedValue) {
|
||||
// For the capture mousecursor option
|
||||
ToolStripMenuSelectListItem captureMouseItem = new ToolStripMenuSelectListItem();
|
||||
captureMouseItem.Text = Language.GetString("settings_capture_mousepointer");
|
||||
captureMouseItem.Checked = conf.CaptureMousepointer;
|
||||
captureMouseItem.CheckOnClick = true;
|
||||
captureMouseItem.CheckStateChanged += delegate {
|
||||
conf.CaptureMousepointer = captureMouseItem.Checked;
|
||||
};
|
||||
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(captureMouseItem);
|
||||
}
|
||||
ToolStripMenuSelectList selectList = null;
|
||||
if (!conf.Values["Destinations"].Attributes.FixedValue) {
|
||||
// screenshot destination
|
||||
selectList = new ToolStripMenuSelectList("destinations", true);
|
||||
selectList.Text = Language.GetString(LangKey.settings_destination);
|
||||
// Working with IDestination:
|
||||
foreach (IDestination destination in DestinationHelper.GetAllDestinations()) {
|
||||
selectList.AddItem(destination.Description, destination, conf.OutputDestinations.Contains(destination.Designation));
|
||||
}
|
||||
selectList.CheckedChanged += new EventHandler(this.QuickSettingDestinationChanged);
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
}
|
||||
|
||||
if (!conf.Values["WindowCaptureMode"].Attributes.FixedValue) {
|
||||
// Capture Modes
|
||||
selectList = new ToolStripMenuSelectList("capturemodes", false);
|
||||
selectList.Text = Language.GetString(LangKey.settings_window_capture_mode);
|
||||
string enumTypeName = typeof(WindowCaptureMode).Name;
|
||||
foreach (WindowCaptureMode captureMode in Enum.GetValues(typeof(WindowCaptureMode))) {
|
||||
selectList.AddItem(Language.GetString(enumTypeName + "." + captureMode.ToString()), captureMode, conf.WindowCaptureMode == captureMode);
|
||||
}
|
||||
selectList.CheckedChanged += new EventHandler(this.QuickSettingCaptureModeChanged);
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
}
|
||||
selectList.CheckedChanged += new EventHandler(this.QuickSettingCaptureModeChanged);
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
|
||||
// print options
|
||||
selectList = new ToolStripMenuSelectList("printoptions",true);
|
||||
|
@ -942,24 +950,32 @@ namespace Greenshot {
|
|||
foreach(string propertyName in conf.Values.Keys) {
|
||||
if (propertyName.StartsWith("OutputPrint")) {
|
||||
iniValue = conf.Values[propertyName];
|
||||
if (iniValue.Attributes.LanguageKey != null) {
|
||||
if (iniValue.Attributes.LanguageKey != null && !iniValue.Attributes.FixedValue) {
|
||||
selectList.AddItem(Language.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
selectList.CheckedChanged += new EventHandler(this.QuickSettingBoolItemChanged);
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
if (selectList.DropDownItems.Count > 0) {
|
||||
selectList.CheckedChanged += new EventHandler(this.QuickSettingBoolItemChanged);
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
}
|
||||
|
||||
// effects
|
||||
selectList = new ToolStripMenuSelectList("effects",true);
|
||||
selectList.Text = Language.GetString(LangKey.settings_visualization);
|
||||
|
||||
iniValue = conf.Values["PlayCameraSound"];
|
||||
selectList.AddItem(Language.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value);
|
||||
if (!iniValue.Attributes.FixedValue) {
|
||||
selectList.AddItem(Language.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value);
|
||||
}
|
||||
iniValue = conf.Values["ShowTrayNotification"];
|
||||
selectList.AddItem(Language.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value);
|
||||
selectList.CheckedChanged += new EventHandler(this.QuickSettingBoolItemChanged);
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
if (!iniValue.Attributes.FixedValue) {
|
||||
selectList.AddItem(Language.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value);
|
||||
}
|
||||
if (selectList.DropDownItems.Count > 0) {
|
||||
selectList.CheckedChanged += new EventHandler(this.QuickSettingBoolItemChanged);
|
||||
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
}
|
||||
}
|
||||
|
||||
void QuickSettingCaptureModeChanged(object sender, EventArgs e) {
|
||||
|
|
|
@ -255,6 +255,10 @@ namespace Greenshot {
|
|||
/// Build the view with all the destinations
|
||||
/// </summary>
|
||||
private void DisplayDestinations() {
|
||||
bool destinationsEnabled = true;
|
||||
if (coreConfiguration.Values.ContainsKey("Destinations")) {
|
||||
destinationsEnabled = !coreConfiguration.Values["Destinations"].Attributes.FixedValue;
|
||||
}
|
||||
checkbox_picker.Checked = false;
|
||||
|
||||
listview_destinations.Items.Clear();
|
||||
|
@ -289,6 +293,8 @@ namespace Greenshot {
|
|||
item.Checked = false;
|
||||
}
|
||||
}
|
||||
checkbox_picker.Enabled = destinationsEnabled;
|
||||
listview_destinations.Enabled = destinationsEnabled;
|
||||
}
|
||||
|
||||
private void DisplaySettings() {
|
||||
|
@ -304,9 +310,16 @@ namespace Greenshot {
|
|||
if (Language.CurrentLanguage != null) {
|
||||
combobox_language.SelectedValue = Language.CurrentLanguage;
|
||||
}
|
||||
// Disable editing when the value is fixed
|
||||
combobox_language.Enabled = !coreConfiguration.Values["Language"].Attributes.FixedValue;
|
||||
|
||||
textbox_storagelocation.Text = FilenameHelper.FillVariables(coreConfiguration.OutputFilePath, false);
|
||||
|
||||
// Disable editing when the value is fixed
|
||||
textbox_storagelocation.Enabled = !coreConfiguration.Values["OutputFilePath"].Attributes.FixedValue;
|
||||
|
||||
SetWindowCaptureMode(coreConfiguration.WindowCaptureMode);
|
||||
// Disable editing when the value is fixed
|
||||
combobox_window_capture_mode.Enabled = !coreConfiguration.Values["WindowCaptureMode"].Attributes.FixedValue;
|
||||
|
||||
trackBarJpegQuality.Value = coreConfiguration.OutputFileJpegQuality;
|
||||
textBoxJpegQuality.Text = coreConfiguration.OutputFileJpegQuality+"%";
|
||||
|
@ -477,7 +490,11 @@ namespace Greenshot {
|
|||
void CheckDestinationSettings() {
|
||||
bool clipboardDestinationChecked = false;
|
||||
bool pickerSelected = checkbox_picker.Checked;
|
||||
listview_destinations.Enabled = true;
|
||||
bool destinationsEnabled = true;
|
||||
if (coreConfiguration.Values.ContainsKey("Destinations")) {
|
||||
destinationsEnabled = !coreConfiguration.Values["Destinations"].Attributes.FixedValue;
|
||||
}
|
||||
listview_destinations.Enabled = destinationsEnabled;
|
||||
|
||||
foreach(int index in listview_destinations.CheckedIndices) {
|
||||
ListViewItem item = listview_destinations.Items[index];
|
||||
|
|
|
@ -389,20 +389,23 @@ namespace GreenshotPlugin.Controls {
|
|||
CheckBox checkBox = controlObject as CheckBox;
|
||||
if (checkBox != null) {
|
||||
checkBox.Checked = (bool)iniValue.Value;
|
||||
checkBox.Enabled = !iniValue.Attributes.FixedValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
TextBox textBox = controlObject as TextBox;
|
||||
if (textBox != null) {
|
||||
HotkeyControl hotkeyControl = controlObject as HotkeyControl;
|
||||
if (hotkeyControl != null) {
|
||||
string hotkeyValue = (string)iniValue.Value;
|
||||
if (!string.IsNullOrEmpty(hotkeyValue)) {
|
||||
hotkeyControl.SetHotkey(hotkeyValue);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
textBox.Text = iniValue.ToString();
|
||||
HotkeyControl hotkeyControl = controlObject as HotkeyControl;
|
||||
if (hotkeyControl != null) {
|
||||
string hotkeyValue = (string)iniValue.Value;
|
||||
if (!string.IsNullOrEmpty(hotkeyValue)) {
|
||||
hotkeyControl.SetHotkey(hotkeyValue);
|
||||
hotkeyControl.Enabled = !iniValue.Attributes.FixedValue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
textBox.Text = iniValue.ToString();
|
||||
textBox.Enabled = !iniValue.Attributes.FixedValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -410,9 +413,9 @@ namespace GreenshotPlugin.Controls {
|
|||
if (comboxBox != null) {
|
||||
comboxBox.Populate(iniValue.ValueType);
|
||||
comboxBox.SetValue((Enum)iniValue.Value);
|
||||
comboxBox.Enabled = !iniValue.Attributes.FixedValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace Greenshot.IniFile {
|
|||
public string Separator = ",";
|
||||
public string DefaultValue;
|
||||
public string LanguageKey;
|
||||
public bool FixedValue = false;
|
||||
public bool ExcludeIfNull=false;
|
||||
|
||||
public string Name {
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Greenshot.IniFile {
|
|||
|
||||
private static Dictionary<string, IniSection> sectionMap = new Dictionary<string, IniSection>();
|
||||
private static Dictionary<string, Dictionary<string, string>> sections = new Dictionary<string, Dictionary<string, string>>();
|
||||
private static Dictionary<string, Dictionary<string, string>> fixedProperties = null;
|
||||
public static event FileSystemEventHandler IniChanged;
|
||||
private static bool portableCheckMade = false;
|
||||
|
||||
|
@ -224,10 +225,25 @@ namespace Greenshot.IniFile {
|
|||
// Load the normal
|
||||
Read(CreateIniLocation(configName + INI_EXTENSION));
|
||||
// Load the fixed settings
|
||||
Read(CreateIniLocation(configName + FIXED_POSTFIX + INI_EXTENSION));
|
||||
fixedProperties = Read(CreateIniLocation(configName + FIXED_POSTFIX + INI_EXTENSION));
|
||||
|
||||
foreach (IniSection section in sectionMap.Values) {
|
||||
section.Fill(PropertiesForSection(section));
|
||||
FixProperties(section);
|
||||
}
|
||||
}
|
||||
|
||||
private static void FixProperties(IniSection section) {
|
||||
// Make properties unchangable
|
||||
if (fixedProperties != null) {
|
||||
Dictionary<string, string> fixedPropertiesForSection = null;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,10 +251,10 @@ namespace Greenshot.IniFile {
|
|||
/// Read the ini file into the Dictionary
|
||||
/// </summary>
|
||||
/// <param name="iniLocation">Path & Filename of ini file</param>
|
||||
private static void Read(string iniLocation) {
|
||||
private static Dictionary<string, Dictionary<string, string>> Read(string iniLocation) {
|
||||
if (!File.Exists(iniLocation)) {
|
||||
//LOG.Info("Can't find file: " + iniLocation);
|
||||
return;
|
||||
LOG.Info("Can't find file: " + iniLocation);
|
||||
return null;
|
||||
}
|
||||
LOG.DebugFormat("Loading ini-file: {0}", iniLocation);
|
||||
//LOG.Info("Reading ini-properties from file: " + iniLocation);
|
||||
|
@ -264,6 +280,7 @@ namespace Greenshot.IniFile {
|
|||
}
|
||||
}
|
||||
}
|
||||
return newSections;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -296,6 +313,7 @@ namespace Greenshot.IniFile {
|
|||
// Store for later save & retrieval
|
||||
sectionMap.Add(sectionName, section);
|
||||
section.Fill(PropertiesForSection(section));
|
||||
FixProperties(section);
|
||||
}
|
||||
if (section.IsDirty) {
|
||||
LOG.DebugFormat("Section {0} is marked dirty, saving!", sectionName);
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace Greenshot.IniFile {
|
|||
if (Attribute.IsDefined(fieldInfo, typeof(IniPropertyAttribute))) {
|
||||
if (!Values.ContainsKey(fieldInfo.Name)) {
|
||||
IniPropertyAttribute iniPropertyAttribute = (IniPropertyAttribute)fieldInfo.GetCustomAttributes(typeof(IniPropertyAttribute), false)[0];
|
||||
Values.Add(fieldInfo.Name, new IniValue(this, fieldInfo, iniPropertyAttribute));
|
||||
Values.Add(iniPropertyAttribute.Name, new IniValue(this, fieldInfo, iniPropertyAttribute));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ namespace Greenshot.IniFile {
|
|||
if (Attribute.IsDefined(propertyInfo, typeof(IniPropertyAttribute))) {
|
||||
if (!Values.ContainsKey(propertyInfo.Name)) {
|
||||
IniPropertyAttribute iniPropertyAttribute = (IniPropertyAttribute)propertyInfo.GetCustomAttributes(typeof(IniPropertyAttribute), false)[0];
|
||||
Values.Add(propertyInfo.Name, new IniValue(this, propertyInfo, iniPropertyAttribute));
|
||||
Values.Add(iniPropertyAttribute.Name, new IniValue(this, propertyInfo, iniPropertyAttribute));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,18 +57,27 @@ namespace Greenshot.IniFile {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the IniSection this value is contained in
|
||||
/// </summary>
|
||||
public IniSection ContainingIniSection {
|
||||
get {
|
||||
return containingIniSection;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the in the ini file defined attributes
|
||||
/// </summary>
|
||||
public IniPropertyAttribute Attributes {
|
||||
get {
|
||||
return attributes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the value for this IniValue
|
||||
/// </summary>
|
||||
public object Value {
|
||||
get {
|
||||
if (propertyInfo == null) {
|
||||
|
@ -86,6 +95,9 @@ namespace Greenshot.IniFile {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Type of the value
|
||||
/// </summary>
|
||||
public Type ValueType {
|
||||
get {
|
||||
Type valueType = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue