Small stability fixes

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1811 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-21 14:12:03 +00:00
parent 9017331dc5
commit 9b7c7a9b7e
4 changed files with 86 additions and 55 deletions

View file

@ -57,6 +57,7 @@ namespace Greenshot.Forms
this.checkboxDateTime = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.button_cancel = new GreenshotPlugin.Controls.GreenshotButton();
this.checkboxPrintInverted = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkbox_grayscale = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.SuspendLayout();
//
// checkbox_dontaskagain
@ -65,7 +66,7 @@ namespace Greenshot.Forms
this.checkbox_dontaskagain.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.LanguageKey = "printoptions_dontaskagain";
this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 152);
this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 158);
this.checkbox_dontaskagain.Name = "checkbox_dontaskagain";
this.checkbox_dontaskagain.Size = new System.Drawing.Size(240, 17);
this.checkbox_dontaskagain.TabIndex = 19;
@ -135,8 +136,9 @@ namespace Greenshot.Forms
//
// button_ok
//
this.button_ok.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button_ok.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button_ok.Location = new System.Drawing.Point(187, 179);
this.button_ok.Location = new System.Drawing.Point(187, 207);
this.button_ok.Name = "button_ok";
this.button_ok.Size = new System.Drawing.Size(75, 23);
this.button_ok.TabIndex = 25;
@ -162,7 +164,7 @@ namespace Greenshot.Forms
// button_cancel
//
this.button_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_cancel.Location = new System.Drawing.Point(268, 179);
this.button_cancel.Location = new System.Drawing.Point(268, 207);
this.button_cancel.Name = "button_cancel";
this.button_cancel.Size = new System.Drawing.Size(75, 23);
this.button_cancel.TabIndex = 27;
@ -175,20 +177,34 @@ namespace Greenshot.Forms
this.checkboxPrintInverted.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.LanguageKey = "printoptions_inverted";
this.checkboxPrintInverted.Location = new System.Drawing.Point(12, 132);
this.checkboxPrintInverted.Location = new System.Drawing.Point(12, 135);
this.checkboxPrintInverted.Name = "checkboxPrintInverted";
this.checkboxPrintInverted.PropertyName = "OutputPrintInverted";
this.checkboxPrintInverted.Size = new System.Drawing.Size(141, 17);
this.checkboxPrintInverted.TabIndex = 28;
this.checkboxPrintInverted.Text = "Print with inverted colors";
this.checkboxPrintInverted.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.UseVisualStyleBackColor = true;
//
// checkbox_grayscale
//
this.checkbox_grayscale.AutoSize = true;
this.checkbox_grayscale.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_grayscale.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_grayscale.LanguageKey = "printoption_printgrayscale";
this.checkbox_grayscale.Location = new System.Drawing.Point(12, 181);
this.checkbox_grayscale.Name = "checkbox_grayscale";
this.checkbox_grayscale.PropertyName = "OutputPrintGrayscale";
this.checkbox_grayscale.Size = new System.Drawing.Size(56, 17);
this.checkbox_grayscale.TabIndex = 29;
this.checkbox_grayscale.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_grayscale.UseVisualStyleBackColor = true;
//
// PrintOptionsDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(355, 212);
this.ClientSize = new System.Drawing.Size(355, 242);
this.Controls.Add(this.checkbox_grayscale);
this.Controls.Add(this.checkboxPrintInverted);
this.Controls.Add(this.button_cancel);
this.Controls.Add(this.checkboxDateTime);
@ -203,11 +219,11 @@ namespace Greenshot.Forms
this.MinimizeBox = false;
this.Name = "PrintOptionsDialog";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Greenshot print options";
this.Text = "string ###printoptions_title### not found";
this.ResumeLayout(false);
this.PerformLayout();
}
private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_grayscale;
private GreenshotPlugin.Controls.GreenshotCheckBox checkboxPrintInverted;
private GreenshotPlugin.Controls.GreenshotButton button_cancel;
private GreenshotPlugin.Controls.GreenshotCheckBox checkboxDateTime;

View file

@ -33,14 +33,15 @@ namespace GreenshotPlugin.Controls {
ITypeResolutionService typeResService = GetService(typeof(ITypeResolutionService)) as ITypeResolutionService;
Assembly currentAssembly = this.GetType().Assembly;
string assemblyPath = typeResService.GetPathOfAssembly(currentAssembly.GetName());
if (!Language.AddLanguageFilePath(Path.Combine(Path.GetDirectoryName(assemblyPath), @"..\..\Greenshot\Languages\"))) {
Language.AddLanguageFilePath(Path.Combine(Path.GetDirectoryName(assemblyPath), @"..\..\..\Greenshot\Languages\"));
string assemblyDirectory = Path.GetDirectoryName(assemblyPath);
if (!Language.AddLanguageFilePath(Path.Combine(assemblyDirectory, @"..\..\Greenshot\Languages\"))) {
Language.AddLanguageFilePath(Path.Combine(assemblyDirectory, @"..\..\..\Greenshot\Languages\"));
}
if (!Language.AddLanguageFilePath(Path.Combine(Path.GetDirectoryName(assemblyPath), @"..\..\Languages\"))) {
Language.AddLanguageFilePath(Path.Combine(Path.GetDirectoryName(assemblyPath), @"..\..\..\Languages\"));
if (!Language.AddLanguageFilePath(Path.Combine(assemblyDirectory, @"..\..\Languages\"))) {
Language.AddLanguageFilePath(Path.Combine(assemblyDirectory, @"..\..\..\Languages\"));
}
} catch (Exception ex) {
MessageBox.Show(ex.ToString());
MessageBox.Show(ex.ToString(), "Greenshot designer exception!");
}
}
}

View file

@ -6,6 +6,7 @@ using System.IO;
namespace GreenshotPlugin.Core {
public static class EncryptionHelper {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger("EncryptionHelper");
private const string RGBIV = "dlgjowejgogkklwj";
private const string KEY = "lsjvkwhvwujkagfauguwcsjgu2wueuff";
@ -15,8 +16,9 @@ namespace GreenshotPlugin.Core {
/// <param name="ClearText">the string to call upon</param>
/// <returns>an encryped string in base64 form</returns>
public static string Encrypt(this string ClearText) {
byte[] clearTextBytes = Encoding.ASCII.GetBytes(ClearText);
string returnValue = null;
try {
byte[] clearTextBytes = Encoding.ASCII.GetBytes(ClearText);
SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
using (MemoryStream ms = new MemoryStream()) {
@ -29,6 +31,9 @@ namespace GreenshotPlugin.Core {
cs.Close();
returnValue = Convert.ToBase64String(ms.ToArray());
}
} catch (Exception ex) {
LOG.ErrorFormat("Error encrypting, error: ", ex.Message);
}
return returnValue;
}
@ -38,8 +43,9 @@ namespace GreenshotPlugin.Core {
/// <param name="EncryptedText">a base64 encoded rijndael encrypted string</param>
/// <returns>Decrypeted text</returns>
public static string Decrypt(this string EncryptedText) {
byte[] encryptedTextBytes = Convert.FromBase64String(EncryptedText);
string returnValue = null;
try {
byte[] encryptedTextBytes = Convert.FromBase64String(EncryptedText);
using (MemoryStream ms = new MemoryStream()) {
SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
@ -55,6 +61,9 @@ namespace GreenshotPlugin.Core {
cs.Close();
returnValue = Encoding.ASCII.GetString(ms.ToArray());
}
} catch (Exception ex) {
LOG.ErrorFormat("Error decrypting {0}, error: ", EncryptedText, ex.Message);
}
return returnValue;
}

View file

@ -54,14 +54,16 @@ namespace GreenshotPlugin.Core {
/// Static initializer for the language code
/// </summary>
static Language() {
if (!LogHelper.isInitialized) {
LOG.Warn("Log4net hasn't been initialized yet! (Design mode?)");
LogHelper.InitializeLog4NET();
}
if (!IniConfig.IsInited) {
LOG.Warn("IniConfig hasn't been initialized yet! (Design mode?)");
IniConfig.Init("greenshot", "greenshot");
}
if (!LogHelper.isInitialized) {
LOG.Warn("Log4net hasn't been initialized yet! (Design mode?)");
LogHelper.InitializeLog4NET();
}
try {
string applicationDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string applicationFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
@ -73,6 +75,9 @@ namespace GreenshotPlugin.Core {
// Startup path
AddPath(Path.Combine(applicationFolder, @"Languages"));
} catch (Exception pathException) {
LOG.Error(pathException);
}
try {
using (RegistryKey languageGroupsKey = Registry.LocalMachine.OpenSubKey(LANGUAGE_GROUPS_KEY, false)) {