diff --git a/Greenshot/Forms/PrintOptionsDialog.Designer.cs b/Greenshot/Forms/PrintOptionsDialog.Designer.cs index df9087ae1..7936d3c57 100644 --- a/Greenshot/Forms/PrintOptionsDialog.Designer.cs +++ b/Greenshot/Forms/PrintOptionsDialog.Designer.cs @@ -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; diff --git a/GreenshotPlugin/Controls/GreenshotForm.cs b/GreenshotPlugin/Controls/GreenshotForm.cs index 24e3cf34b..931efd686 100644 --- a/GreenshotPlugin/Controls/GreenshotForm.cs +++ b/GreenshotPlugin/Controls/GreenshotForm.cs @@ -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!"); } } } diff --git a/GreenshotPlugin/Core/EncryptionHelper.cs b/GreenshotPlugin/Core/EncryptionHelper.cs index 0bc6c72e4..c714b4bc3 100644 --- a/GreenshotPlugin/Core/EncryptionHelper.cs +++ b/GreenshotPlugin/Core/EncryptionHelper.cs @@ -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,19 +16,23 @@ namespace GreenshotPlugin.Core { /// the string to call upon /// an encryped string in base64 form public static string Encrypt(this string ClearText) { - byte[] clearTextBytes = Encoding.ASCII.GetBytes(ClearText); string returnValue = null; - SymmetricAlgorithm rijn = SymmetricAlgorithm.Create(); - - using (MemoryStream ms = new MemoryStream()) { - byte[] rgbIV = Encoding.ASCII.GetBytes(RGBIV); - byte[] key = Encoding.ASCII.GetBytes(KEY); - CryptoStream cs = new CryptoStream(ms, rijn.CreateEncryptor(key, rgbIV), CryptoStreamMode.Write); - - cs.Write(clearTextBytes, 0, clearTextBytes.Length); - - cs.Close(); - returnValue = Convert.ToBase64String(ms.ToArray()); + try { + byte[] clearTextBytes = Encoding.ASCII.GetBytes(ClearText); + SymmetricAlgorithm rijn = SymmetricAlgorithm.Create(); + + using (MemoryStream ms = new MemoryStream()) { + byte[] rgbIV = Encoding.ASCII.GetBytes(RGBIV); + byte[] key = Encoding.ASCII.GetBytes(KEY); + CryptoStream cs = new CryptoStream(ms, rijn.CreateEncryptor(key, rgbIV), CryptoStreamMode.Write); + + cs.Write(clearTextBytes, 0, clearTextBytes.Length); + + cs.Close(); + returnValue = Convert.ToBase64String(ms.ToArray()); + } + } catch (Exception ex) { + LOG.ErrorFormat("Error encrypting, error: ", ex.Message); } return returnValue; } @@ -38,22 +43,26 @@ namespace GreenshotPlugin.Core { /// a base64 encoded rijndael encrypted string /// Decrypeted text public static string Decrypt(this string EncryptedText) { - byte[] encryptedTextBytes = Convert.FromBase64String(EncryptedText); string returnValue = null; - using (MemoryStream ms = new MemoryStream()) { - SymmetricAlgorithm rijn = SymmetricAlgorithm.Create(); - - - byte[] rgbIV = Encoding.ASCII.GetBytes(RGBIV); - byte[] key = Encoding.ASCII.GetBytes(KEY); - - CryptoStream cs = new CryptoStream(ms, rijn.CreateDecryptor(key, rgbIV), - CryptoStreamMode.Write); - - cs.Write(encryptedTextBytes, 0, encryptedTextBytes.Length); - - cs.Close(); - returnValue = Encoding.ASCII.GetString(ms.ToArray()); + try { + byte[] encryptedTextBytes = Convert.FromBase64String(EncryptedText); + using (MemoryStream ms = new MemoryStream()) { + SymmetricAlgorithm rijn = SymmetricAlgorithm.Create(); + + + byte[] rgbIV = Encoding.ASCII.GetBytes(RGBIV); + byte[] key = Encoding.ASCII.GetBytes(KEY); + + CryptoStream cs = new CryptoStream(ms, rijn.CreateDecryptor(key, rgbIV), + CryptoStreamMode.Write); + + cs.Write(encryptedTextBytes, 0, encryptedTextBytes.Length); + + cs.Close(); + returnValue = Encoding.ASCII.GetString(ms.ToArray()); + } + } catch (Exception ex) { + LOG.ErrorFormat("Error decrypting {0}, error: ", EncryptedText, ex.Message); } return returnValue; diff --git a/GreenshotPlugin/Core/Language.cs b/GreenshotPlugin/Core/Language.cs index 308556021..c8d6eaf71 100644 --- a/GreenshotPlugin/Core/Language.cs +++ b/GreenshotPlugin/Core/Language.cs @@ -54,25 +54,30 @@ namespace GreenshotPlugin.Core { /// Static initializer for the language code /// 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"); } - string applicationDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - string applicationFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - - // PAF Path - AddPath(Path.Combine(applicationFolder, @"App\Greenshot\Languages")); - - // Application data path - AddPath(Path.Combine(applicationDataFolder, @"Greenshot\Languages\")); - - // Startup path - AddPath(Path.Combine(applicationFolder, @"Languages")); + 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); + + // PAF Path + AddPath(Path.Combine(applicationFolder, @"App\Greenshot\Languages")); + + // Application data path + AddPath(Path.Combine(applicationDataFolder, @"Greenshot\Languages\")); + + // Startup path + AddPath(Path.Combine(applicationFolder, @"Languages")); + } catch (Exception pathException) { + LOG.Error(pathException); + } try { using (RegistryKey languageGroupsKey = Registry.LocalMachine.OpenSubKey(LANGUAGE_GROUPS_KEY, false)) {