Code quality changes, and added the possibility to set the amount of colors for the Quantizer.

This commit is contained in:
RKrom 2014-05-11 11:23:56 +02:00
commit 77a92d98c3
92 changed files with 690 additions and 653 deletions

View file

@ -46,7 +46,7 @@ namespace Greenshot.IniFile {
Separator = ",";
}
public IniPropertyAttribute(string name) : this() {
this.Name = name;
Name = name;
}
public string Description {
get;

View file

@ -24,10 +24,11 @@ using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using log4net;
namespace Greenshot.IniFile {
public class IniConfig {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IniConfig));
private static ILog LOG = LogManager.GetLogger(typeof(IniConfig));
private const string INI_EXTENSION = ".ini";
private const string DEFAULTS_POSTFIX = "-defaults";
private const string FIXED_POSTFIX = "-fixed";
@ -358,7 +359,7 @@ namespace Greenshot.IniFile {
}
if (allowSave && section.IsDirty) {
LOG.DebugFormat("Section {0} is marked dirty, saving!", sectionName);
IniConfig.Save();
Save();
}
return section;
}

View file

@ -23,6 +23,7 @@ using System.Collections.Generic;
using System.Reflection;
using System.IO;
using GreenshotPlugin.Core;
using log4net;
namespace Greenshot.IniFile {
/// <summary>
@ -30,7 +31,7 @@ namespace Greenshot.IniFile {
/// </summary>
[Serializable]
public abstract class IniSection {
protected static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IniSection));
protected static ILog LOG = LogManager.GetLogger(typeof(IniSection));
[NonSerialized]
private IDictionary<string, IniValue> values = new Dictionary<string, IniValue>();
@ -39,7 +40,7 @@ namespace Greenshot.IniFile {
public IniSectionAttribute IniSectionAttribute {
get {
if (iniSectionAttribute == null) {
iniSectionAttribute = GetIniSectionAttribute(this.GetType());
iniSectionAttribute = GetIniSectionAttribute(GetType());
}
return iniSectionAttribute;
}
@ -117,7 +118,7 @@ namespace Greenshot.IniFile {
/// </summary>
/// <param name="properties"></param>
public void Fill(Dictionary<string, string> properties) {
Type iniSectionType = this.GetType();
Type iniSectionType = GetType();
// Iterate over the members and create IniValueContainers
foreach (FieldInfo fieldInfo in iniSectionType.GetFields()) {

View file

@ -24,13 +24,14 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Text;
using log4net;
namespace Greenshot.IniFile {
/// <summary>
/// A container to be able to pass the value from a IniSection around.
/// </summary>
public class IniValue {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IniValue));
private static ILog LOG = LogManager.GetLogger(typeof(IniValue));
private PropertyInfo propertyInfo;
private FieldInfo fieldInfo;
private IniSection containingIniSection;
@ -39,13 +40,13 @@ namespace Greenshot.IniFile {
public IniValue(IniSection containingIniSection, PropertyInfo propertyInfo, IniPropertyAttribute iniPropertyAttribute) {
this.containingIniSection = containingIniSection;
this.propertyInfo = propertyInfo;
this.attributes = iniPropertyAttribute;
attributes = iniPropertyAttribute;
}
public IniValue(IniSection containingIniSection, FieldInfo fieldInfo, IniPropertyAttribute iniPropertyAttribute) {
this.containingIniSection = containingIniSection;
this.fieldInfo = fieldInfo;
this.attributes = iniPropertyAttribute;
attributes = iniPropertyAttribute;
}
/// <summary>
@ -318,7 +319,7 @@ namespace Greenshot.IniFile {
try {
LOG.WarnFormat("Problem '{0}' while converting {1} to type {2} trying fallback...", ex1.Message, propertyValue, valueType.FullName);
newValue = ConvertStringToValueType(valueType, defaultValue, attributes.Separator);
this.ContainingIniSection.IsDirty = true;
ContainingIniSection.IsDirty = true;
LOG.InfoFormat("Used default value {0} for property {1}", defaultValue, propertyName);
} catch (Exception ex2) {
LOG.Warn("Problem converting fallback value " + defaultValue + " to type " + valueType.FullName, ex2);