mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 21:43:24 -07:00
More performance improvements
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1919 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
e4a87aa4e4
commit
59665da813
2 changed files with 48 additions and 32 deletions
|
@ -87,6 +87,8 @@ namespace Greenshot {
|
||||||
// init surface
|
// init surface
|
||||||
this.surface = iSurface as Surface;
|
this.surface = iSurface as Surface;
|
||||||
editorList.Add(this);
|
editorList.Add(this);
|
||||||
|
|
||||||
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||||
//
|
//
|
||||||
|
@ -172,6 +174,7 @@ namespace Greenshot {
|
||||||
// Create the file menu, normally this is done when opening but if we don't do it now the short-cut keys are missing.
|
// Create the file menu, normally this is done when opening but if we don't do it now the short-cut keys are missing.
|
||||||
// See Bugs #3526974 & #3527020
|
// See Bugs #3526974 & #3527020
|
||||||
FileMenuDropDownOpening(null, null);
|
FileMenuDropDownOpening(null, null);
|
||||||
|
this.ResumeLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddDestinationButton(IDestination toolstripDestination) {
|
void AddDestinationButton(IDestination toolstripDestination) {
|
||||||
|
|
|
@ -12,11 +12,13 @@ using System.IO;
|
||||||
namespace GreenshotPlugin.Controls {
|
namespace GreenshotPlugin.Controls {
|
||||||
public abstract class GreenshotForm : Form, IGreenshotLanguageBindable {
|
public abstract class GreenshotForm : Form, IGreenshotLanguageBindable {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(GreenshotForm));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(GreenshotForm));
|
||||||
|
private static IDictionary<Type, FieldInfo[]> reflectionCache = new Dictionary<Type, FieldInfo[]>();
|
||||||
private IComponentChangeService m_changeService;
|
private IComponentChangeService m_changeService;
|
||||||
private bool isDesignModeLanguageSet = false;
|
private bool isDesignModeLanguageSet = false;
|
||||||
private bool applyLanguageManually = false;
|
private bool applyLanguageManually = false;
|
||||||
private IDictionary<string, Control> designTimeControls;
|
private IDictionary<string, Control> designTimeControls;
|
||||||
private IDictionary<string, ToolStripItem> designTimeToolStripItems;
|
private IDictionary<string, ToolStripItem> designTimeToolStripItems;
|
||||||
|
|
||||||
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
|
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
|
||||||
public string LanguageKey {
|
public string LanguageKey {
|
||||||
get;
|
get;
|
||||||
|
@ -274,16 +276,15 @@ namespace GreenshotPlugin.Controls {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void ApplyLanguage() {
|
protected void ApplyLanguage() {
|
||||||
string langString = null;
|
string langString = null;
|
||||||
|
this.SuspendLayout();
|
||||||
|
try {
|
||||||
// Set title of the form
|
// Set title of the form
|
||||||
if (!string.IsNullOrEmpty(LanguageKey) && Language.TryGetString(LanguageKey, out langString)) {
|
if (!string.IsNullOrEmpty(LanguageKey) && Language.TryGetString(LanguageKey, out langString)) {
|
||||||
this.Text = langString;
|
this.Text = langString;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the text values for all GreenshotControls
|
// Reset the text values for all GreenshotControls
|
||||||
foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
|
foreach (FieldInfo field in GetCachedFields(this.GetType())) {
|
||||||
if (!field.FieldType.IsSubclassOf(typeof(Control)) && !field.FieldType.IsSubclassOf(typeof(ToolStripItem))) {
|
|
||||||
LOG.DebugFormat("No Control or ToolStripItem: {0}", field.Name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Object controlObject = field.GetValue(this);
|
Object controlObject = field.GetValue(this);
|
||||||
if (controlObject == null) {
|
if (controlObject == null) {
|
||||||
LOG.DebugFormat("No value: {0}", field.Name);
|
LOG.DebugFormat("No value: {0}", field.Name);
|
||||||
|
@ -310,6 +311,9 @@ namespace GreenshotPlugin.Controls {
|
||||||
ApplyLanguage(designToolStripItem);
|
ApplyLanguage(designToolStripItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.ResumeLayout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -338,11 +342,20 @@ namespace GreenshotPlugin.Controls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static FieldInfo[] GetCachedFields(Type typeToGetFieldsFor) {
|
||||||
|
FieldInfo[] fields = null;
|
||||||
|
if (!reflectionCache.TryGetValue(typeToGetFieldsFor, out fields)) {
|
||||||
|
fields = typeToGetFieldsFor.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
reflectionCache.Add(typeToGetFieldsFor, fields);
|
||||||
|
}
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fill all GreenshotControls with the values from the configuration
|
/// Fill all GreenshotControls with the values from the configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void FillFields() {
|
protected void FillFields() {
|
||||||
foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
|
foreach (FieldInfo field in GetCachedFields(this.GetType())) {
|
||||||
if (!field.FieldType.IsSubclassOf(typeof(Control))) {
|
if (!field.FieldType.IsSubclassOf(typeof(Control))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +397,7 @@ namespace GreenshotPlugin.Controls {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void StoreFields() {
|
protected void StoreFields() {
|
||||||
bool iniDirty = false;
|
bool iniDirty = false;
|
||||||
foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
|
foreach (FieldInfo field in GetCachedFields(this.GetType())) {
|
||||||
if (!field.FieldType.IsSubclassOf(typeof(Control))) {
|
if (!field.FieldType.IsSubclassOf(typeof(Control))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue