diff --git a/Greenshot/AssemblyInfo.cs b/Greenshot/AssemblyInfo.cs
index 71277cb02..6694dedb4 100644
--- a/Greenshot/AssemblyInfo.cs
+++ b/Greenshot/AssemblyInfo.cs
@@ -21,7 +21,6 @@
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs b/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs
index d8c8ef68c..161f566bd 100644
--- a/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs
+++ b/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs
@@ -22,7 +22,6 @@
using Greenshot.IniFile;
using GreenshotPlugin.Core;
using System.Drawing;
-using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Greenshot.Controls {
diff --git a/Greenshot/Destinations/EmailDestination.cs b/Greenshot/Destinations/EmailDestination.cs
index 16dcf0866..c8ff8ad24 100644
--- a/Greenshot/Destinations/EmailDestination.cs
+++ b/Greenshot/Destinations/EmailDestination.cs
@@ -26,16 +26,12 @@ using Greenshot.Configuration;
using Greenshot.Helpers;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
-using Greenshot.IniFile;
-using log4net;
namespace Greenshot.Destinations {
///
/// Description of EmailDestination.
///
public class EmailDestination : AbstractDestination {
- private static ILog LOG = LogManager.GetLogger(typeof(EmailDestination));
- private static CoreConfiguration conf = IniConfig.GetIniSection();
private static readonly Image mailIcon = GreenshotResources.getImage("Email.Image");
private static bool isActiveFlag;
private static string mapiClient;
diff --git a/Greenshot/Drawing/HighlightContainer.cs b/Greenshot/Drawing/HighlightContainer.cs
index aec48208f..701592539 100644
--- a/Greenshot/Drawing/HighlightContainer.cs
+++ b/Greenshot/Drawing/HighlightContainer.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
using System;
-using System.Drawing;
using System.Runtime.Serialization;
using Greenshot.Drawing.Fields;
diff --git a/Greenshot/Drawing/SpeechbubbleContainer.cs b/Greenshot/Drawing/SpeechbubbleContainer.cs
index eef5e8ef6..4bbc91c29 100644
--- a/Greenshot/Drawing/SpeechbubbleContainer.cs
+++ b/Greenshot/Drawing/SpeechbubbleContainer.cs
@@ -21,15 +21,12 @@
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
-using Greenshot.Plugin;
using Greenshot.Plugin.Drawing;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Runtime.Serialization;
-using System.Windows.Forms;
-using log4net;
namespace Greenshot.Drawing {
///
diff --git a/Greenshot/Forms/DropShadowSettingsForm.cs b/Greenshot/Forms/DropShadowSettingsForm.cs
index 358b98970..06e170117 100644
--- a/Greenshot/Forms/DropShadowSettingsForm.cs
+++ b/Greenshot/Forms/DropShadowSettingsForm.cs
@@ -22,7 +22,6 @@ using System;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Core;
-using GreenshotPlugin.Core;
namespace Greenshot.Forms {
public partial class DropShadowSettingsForm : BaseForm {
diff --git a/Greenshot/Forms/PrintOptionsDialog.cs b/Greenshot/Forms/PrintOptionsDialog.cs
index 1175bf1dc..fb728a590 100644
--- a/Greenshot/Forms/PrintOptionsDialog.cs
+++ b/Greenshot/Forms/PrintOptionsDialog.cs
@@ -21,7 +21,6 @@
using System;
using System.Windows.Forms;
using Greenshot.IniFile;
-using GreenshotPlugin.Core;
namespace Greenshot.Forms {
///
diff --git a/Greenshot/Forms/TornEdgeSettingsForm.cs b/Greenshot/Forms/TornEdgeSettingsForm.cs
index 707ea5c32..1bf429ea6 100644
--- a/Greenshot/Forms/TornEdgeSettingsForm.cs
+++ b/Greenshot/Forms/TornEdgeSettingsForm.cs
@@ -22,7 +22,6 @@ using System;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Core;
-using GreenshotPlugin.Core;
namespace Greenshot.Forms {
public partial class TornEdgeSettingsForm : BaseForm {
diff --git a/Greenshot/releases/additional_files/readme.txt.template b/Greenshot/releases/additional_files/readme.txt.template
index 4fd81e5dc..3668769d5 100644
--- a/Greenshot/releases/additional_files/readme.txt.template
+++ b/Greenshot/releases/additional_files/readme.txt.template
@@ -34,7 +34,8 @@ This version has changes, compared to 1.2.8.12, for the following reported ticke
* BUG-1935: Delay when pasting and ShapeShifter from FlameFusion is running|
* BUG-1941: Error when creating speech bubble|
* BUG-1945: Failure starting Greenshot at system startup|
-* BUG-1949: Can't delete Imgur upload|
+* BUG-1949: Can't delete Imgur upload
+* FEATURE-945: Added environment variables to the external command
Testing is not finished, use at your own risk...
diff --git a/GreenshotBoxPlugin/Properties/AssemblyInfo.cs b/GreenshotBoxPlugin/Properties/AssemblyInfo.cs
index 4dbee7804..d8104cf29 100644
--- a/GreenshotBoxPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotBoxPlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/GreenshotConfluencePlugin/Confluence.cs b/GreenshotConfluencePlugin/Confluence.cs
index 05651949d..b875052ba 100644
--- a/GreenshotConfluencePlugin/Confluence.cs
+++ b/GreenshotConfluencePlugin/Confluence.cs
@@ -95,14 +95,14 @@ namespace Confluence {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.confluence.rpc.AuthenticationFailedException";
private const string V2_FAILED = "AXIS";
- private static ConfluenceConfiguration config = IniConfig.GetIniSection();
+ private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection();
private string credentials = null;
private DateTime loggedInTime = DateTime.Now;
private bool loggedIn = false;
private ConfluenceSoapServiceService confluence;
- private int timeout;
+ private readonly int timeout;
private string url;
- private Cache pageCache = new Cache(60 * config.Timeout);
+ private readonly Cache pageCache = new Cache(60 * config.Timeout);
public void Dispose() {
Dispose(true);
@@ -143,9 +143,9 @@ namespace Confluence {
/// true if login was done sucessfully
private bool doLogin(string user, string password) {
try {
- this.credentials = confluence.login(user, password);
- this.loggedInTime = DateTime.Now;
- this.loggedIn = true;
+ credentials = confluence.login(user, password);
+ loggedInTime = DateTime.Now;
+ loggedIn = true;
} catch (Exception e) {
// Check if confluence-v2 caused an error, use v1 instead
if (e.Message.Contains(V2_FAILED) && url.Contains("v2")) {
@@ -157,8 +157,8 @@ namespace Confluence {
return false;
}
// Not an authentication issue
- this.loggedIn = false;
- this.credentials = null;
+ loggedIn = false;
+ credentials = null;
e.Data.Add("user", user);
e.Data.Add("url", url);
throw;
diff --git a/GreenshotConfluencePlugin/ConfluenceDestination.cs b/GreenshotConfluencePlugin/ConfluenceDestination.cs
index 10e212d5e..8161908ac 100644
--- a/GreenshotConfluencePlugin/ConfluenceDestination.cs
+++ b/GreenshotConfluencePlugin/ConfluenceDestination.cs
@@ -36,11 +36,11 @@ namespace GreenshotConfluencePlugin {
/// Description of ConfluenceDestination.
///
public class ConfluenceDestination : AbstractDestination {
- private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceDestination));
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceDestination));
private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection();
private static readonly CoreConfiguration coreConfig = IniConfig.GetIniSection();
- private static Image confluenceIcon = null;
- private Confluence.Page page;
+ private static readonly Image confluenceIcon = null;
+ private readonly Page page;
public static bool IsInitialized {
get;
private set;
@@ -63,7 +63,7 @@ namespace GreenshotConfluencePlugin {
public ConfluenceDestination() {
}
- public ConfluenceDestination(Confluence.Page page) {
+ public ConfluenceDestination(Page page) {
this.page = page;
}
@@ -105,17 +105,17 @@ namespace GreenshotConfluencePlugin {
if (ConfluencePlugin.ConfluenceConnectorNoLogin == null || !ConfluencePlugin.ConfluenceConnectorNoLogin.isLoggedIn) {
yield break;
}
- List currentPages = ConfluenceUtils.GetCurrentPages();
+ List currentPages = ConfluenceUtils.GetCurrentPages();
if (currentPages == null || currentPages.Count == 0) {
yield break;
}
- foreach(Confluence.Page currentPage in currentPages) {
+ foreach(Page currentPage in currentPages) {
yield return new ConfluenceDestination(currentPage);
}
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
// force password check to take place before the pages load
if (!ConfluencePlugin.ConfluenceConnector.isLoggedIn) {
return exportInformation;
diff --git a/GreenshotConfluencePlugin/ConfluenceUtils.cs b/GreenshotConfluencePlugin/ConfluenceUtils.cs
index 3ffafbfd6..72f62c3e4 100644
--- a/GreenshotConfluencePlugin/ConfluenceUtils.cs
+++ b/GreenshotConfluencePlugin/ConfluenceUtils.cs
@@ -20,7 +20,6 @@
*/
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Windows.Automation;
diff --git a/GreenshotConfluencePlugin/EnumDisplayer.cs b/GreenshotConfluencePlugin/EnumDisplayer.cs
index 102bf6732..e601c2a30 100644
--- a/GreenshotConfluencePlugin/EnumDisplayer.cs
+++ b/GreenshotConfluencePlugin/EnumDisplayer.cs
@@ -40,7 +40,7 @@ namespace GreenshotConfluencePlugin {
}
public EnumDisplayer(Type type) {
- this.Type = type;
+ Type = type;
}
public Type Type {
@@ -49,15 +49,15 @@ namespace GreenshotConfluencePlugin {
if (!value.IsEnum) {
throw new ArgumentException("parameter is not an Enumerated type", "value");
}
- this.type = value;
+ type = value;
}
}
public ReadOnlyCollection DisplayNames {
get {
- this.reverseValues = (IDictionary) Activator.CreateInstance(typeof(Dictionary<,>).GetGenericTypeDefinition().MakeGenericType(typeof(string),type));
+ reverseValues = (IDictionary) Activator.CreateInstance(typeof(Dictionary<,>).GetGenericTypeDefinition().MakeGenericType(typeof(string),type));
- this.displayValues = (IDictionary)Activator.CreateInstance(typeof(Dictionary<,>).GetGenericTypeDefinition().MakeGenericType(type, typeof(string)));
+ displayValues = (IDictionary)Activator.CreateInstance(typeof(Dictionary<,>).GetGenericTypeDefinition().MakeGenericType(type, typeof(string)));
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static);
foreach (var field in fields) {
diff --git a/GreenshotConfluencePlugin/Forms/ConfluenceConfigurationForm.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluenceConfigurationForm.xaml.cs
index 63b72292d..507f1ee8f 100644
--- a/GreenshotConfluencePlugin/Forms/ConfluenceConfigurationForm.xaml.cs
+++ b/GreenshotConfluencePlugin/Forms/ConfluenceConfigurationForm.xaml.cs
@@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
+
using System.Windows;
namespace GreenshotConfluencePlugin {
@@ -26,7 +26,7 @@ namespace GreenshotConfluencePlugin {
/// Interaction logic for ConfluenceConfigurationForm.xaml
///
public partial class ConfluenceConfigurationForm : Window {
- private ConfluenceConfiguration config;
+ private readonly ConfluenceConfiguration config;
public ConfluenceConfiguration Config {
get {
return config;
@@ -34,7 +34,7 @@ namespace GreenshotConfluencePlugin {
}
public ConfluenceConfigurationForm(ConfluenceConfiguration config) {
- this.DataContext = config;
+ DataContext = config;
this.config = config;
InitializeComponent();
}
diff --git a/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs
index a8ddec0dd..381eb4139 100644
--- a/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs
+++ b/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs
@@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
+
using Confluence;
using System.Collections.Generic;
@@ -28,11 +28,11 @@ namespace GreenshotConfluencePlugin {
///
public partial class ConfluencePagePicker : System.Windows.Controls.Page {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluencePagePicker));
- private ConfluenceUpload confluenceUpload = null;
+ private readonly ConfluenceUpload confluenceUpload = null;
public ConfluencePagePicker(ConfluenceUpload confluenceUpload, List pagesToPick) {
this.confluenceUpload = confluenceUpload;
- this.DataContext = pagesToPick;
+ DataContext = pagesToPick;
InitializeComponent();
}
diff --git a/GreenshotConfluencePlugin/Forms/ConfluenceSearch.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluenceSearch.xaml.cs
index 3c816a2f9..042a68427 100644
--- a/GreenshotConfluencePlugin/Forms/ConfluenceSearch.xaml.cs
+++ b/GreenshotConfluencePlugin/Forms/ConfluenceSearch.xaml.cs
@@ -18,20 +18,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
+
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
-
-using Confluence;
-using GreenshotPlugin.Core;
using Greenshot.IniFile;
namespace GreenshotConfluencePlugin {
public partial class ConfluenceSearch : System.Windows.Controls.Page {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceSearch));
- private static ConfluenceConfiguration config = IniConfig.GetIniSection();
- private ConfluenceUpload confluenceUpload;
+ private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection();
+ private readonly ConfluenceUpload confluenceUpload;
public List Spaces {
get {
@@ -39,7 +36,7 @@ namespace GreenshotConfluencePlugin {
}
}
- private ObservableCollection pages = new ObservableCollection();
+ private readonly ObservableCollection pages = new ObservableCollection();
public ObservableCollection Pages {
get {
return pages;
@@ -48,14 +45,14 @@ namespace GreenshotConfluencePlugin {
public ConfluenceSearch(ConfluenceUpload confluenceUpload) {
this.confluenceUpload = confluenceUpload;
- this.DataContext = this;
+ DataContext = this;
InitializeComponent();
if (config.SearchSpaceKey == null) {
- this.SpaceComboBox.SelectedItem = Spaces[0];
+ SpaceComboBox.SelectedItem = Spaces[0];
} else {
foreach(Confluence.Space space in Spaces) {
if (space.Key.Equals(config.SearchSpaceKey)) {
- this.SpaceComboBox.SelectedItem = space;
+ SpaceComboBox.SelectedItem = space;
}
}
}
@@ -94,7 +91,7 @@ namespace GreenshotConfluencePlugin {
}
}
- void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) {
+ void Page_Loaded(object sender, RoutedEventArgs e) {
SelectionChanged();
}
diff --git a/GreenshotConfluencePlugin/Forms/ConfluenceTreePicker.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluenceTreePicker.xaml.cs
index b639a5f98..716262030 100644
--- a/GreenshotConfluencePlugin/Forms/ConfluenceTreePicker.xaml.cs
+++ b/GreenshotConfluencePlugin/Forms/ConfluenceTreePicker.xaml.cs
@@ -27,7 +27,6 @@ using System.Windows.Input;
using System.Windows.Threading;
using Confluence;
-using GreenshotPlugin.Core;
namespace GreenshotConfluencePlugin {
///
@@ -35,12 +34,12 @@ namespace GreenshotConfluencePlugin {
///
public partial class ConfluenceTreePicker : System.Windows.Controls.Page {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceTreePicker));
- private ConfluenceConnector confluenceConnector;
- private ConfluenceUpload confluenceUpload;
+ private readonly ConfluenceConnector confluenceConnector;
+ private readonly ConfluenceUpload confluenceUpload;
private bool isInitDone = false;
public ConfluenceTreePicker(ConfluenceUpload confluenceUpload) {
- this.confluenceConnector = ConfluencePlugin.ConfluenceConnector;
+ confluenceConnector = ConfluencePlugin.ConfluenceConnector;
this.confluenceUpload = confluenceUpload;
InitializeComponent();
}
diff --git a/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs
index 3c3d9442e..fe1b81a8a 100644
--- a/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs
+++ b/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs
@@ -100,12 +100,12 @@ namespace GreenshotConfluencePlugin {
}
public ConfluenceUpload(string filename) {
- this.Filename = filename;
+ Filename = filename;
InitializeComponent();
this.DataContext = this;
updateSpaces();
if (PickerPage == null) {
- PickerTab.Visibility = System.Windows.Visibility.Collapsed;
+ PickerTab.Visibility = Visibility.Collapsed;
SearchTab.IsSelected = true;
}
}
diff --git a/GreenshotConfluencePlugin/Support/ITranslationProvider.cs b/GreenshotConfluencePlugin/Support/ITranslationProvider.cs
index 6bd4bf402..a19c27fd8 100644
--- a/GreenshotConfluencePlugin/Support/ITranslationProvider.cs
+++ b/GreenshotConfluencePlugin/Support/ITranslationProvider.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-
-namespace TranslationByMarkupExtension {
+namespace TranslationByMarkupExtension {
public interface ITranslationProvider {
///
/// Translates the specified key.
diff --git a/GreenshotConfluencePlugin/Support/LanguageXMLTranslationProvider.cs b/GreenshotConfluencePlugin/Support/LanguageXMLTranslationProvider.cs
index 75d952e76..f3ebcaca0 100644
--- a/GreenshotConfluencePlugin/Support/LanguageXMLTranslationProvider.cs
+++ b/GreenshotConfluencePlugin/Support/LanguageXMLTranslationProvider.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-
-using GreenshotConfluencePlugin;
-using GreenshotPlugin.Core;
+using GreenshotPlugin.Core;
namespace TranslationByMarkupExtension {
///
diff --git a/GreenshotConfluencePlugin/Support/TranslationData.cs b/GreenshotConfluencePlugin/Support/TranslationData.cs
index b47fe4a65..e9be13aff 100644
--- a/GreenshotConfluencePlugin/Support/TranslationData.cs
+++ b/GreenshotConfluencePlugin/Support/TranslationData.cs
@@ -6,7 +6,7 @@ namespace TranslationByMarkupExtension {
public class TranslationData : IWeakEventListener, INotifyPropertyChanged {
#region Private Members
- private string _key;
+ private readonly string _key;
#endregion
diff --git a/GreenshotConfluencePlugin/Support/TranslationManager.cs b/GreenshotConfluencePlugin/Support/TranslationManager.cs
index fa801d3d2..7e9516271 100644
--- a/GreenshotConfluencePlugin/Support/TranslationManager.cs
+++ b/GreenshotConfluencePlugin/Support/TranslationManager.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Threading;
namespace TranslationByMarkupExtension {
public class TranslationManager {
diff --git a/GreenshotDropboxPlugin/DropboxDestination.cs b/GreenshotDropboxPlugin/DropboxDestination.cs
index c4f79732f..d9ef2cd33 100644
--- a/GreenshotDropboxPlugin/DropboxDestination.cs
+++ b/GreenshotDropboxPlugin/DropboxDestination.cs
@@ -26,9 +26,9 @@ using GreenshotPlugin.Core;
namespace GreenshotDropboxPlugin {
class DropboxDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxDestination));
- private static DropboxPluginConfiguration config = IniConfig.GetIniSection();
+ private static readonly DropboxPluginConfiguration config = IniConfig.GetIniSection();
- private DropboxPlugin plugin = null;
+ private readonly DropboxPlugin plugin = null;
public DropboxDestination(DropboxPlugin plugin) {
this.plugin = plugin;
}
@@ -53,7 +53,7 @@ namespace GreenshotDropboxPlugin {
}
public override ExportInformation ExportCapture(bool manually, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
string uploadURL = null;
bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
if (uploaded) {
diff --git a/GreenshotDropboxPlugin/DropboxPlugin.cs b/GreenshotDropboxPlugin/DropboxPlugin.cs
index 772545395..7fd82cd60 100644
--- a/GreenshotDropboxPlugin/DropboxPlugin.cs
+++ b/GreenshotDropboxPlugin/DropboxPlugin.cs
@@ -73,7 +73,7 @@ namespace GreenshotDropboxPlugin {
/// Use the IGreenshotPluginHost interface to register events
/// My own attributes
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- this.host = (IGreenshotHost)pluginHost;
+ host = (IGreenshotHost)pluginHost;
Attributes = myAttributes;
// Register configuration (don't need the configuration itself)
@@ -83,7 +83,7 @@ namespace GreenshotDropboxPlugin {
itemPlugInConfig = new ToolStripMenuItem();
itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
itemPlugInConfig.Tag = host;
- itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick);
+ itemPlugInConfig.Click += new EventHandler(ConfigMenuClick);
itemPlugInConfig.Image = (Image)resources.GetObject("Dropbox");
PluginUtils.AddToContextMenu(host, itemPlugInConfig);
diff --git a/GreenshotDropboxPlugin/DropboxUtils.cs b/GreenshotDropboxPlugin/DropboxUtils.cs
index 126a41cd3..f7775d106 100644
--- a/GreenshotDropboxPlugin/DropboxUtils.cs
+++ b/GreenshotDropboxPlugin/DropboxUtils.cs
@@ -31,7 +31,7 @@ namespace GreenshotDropboxPlugin {
///
public class DropboxUtils {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxUtils));
- private static DropboxPluginConfiguration config = IniConfig.GetIniSection();
+ private static readonly DropboxPluginConfiguration config = IniConfig.GetIniSection();
private DropboxUtils() {
}
diff --git a/GreenshotDropboxPlugin/Forms/DropboxForm.cs b/GreenshotDropboxPlugin/Forms/DropboxForm.cs
index b2c87ec61..8cadb1fc3 100644
--- a/GreenshotDropboxPlugin/Forms/DropboxForm.cs
+++ b/GreenshotDropboxPlugin/Forms/DropboxForm.cs
@@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
+
using GreenshotPlugin.Controls;
namespace GreenshotDropboxPlugin.Forms {
diff --git a/GreenshotDropboxPlugin/Forms/SettingsForm.cs b/GreenshotDropboxPlugin/Forms/SettingsForm.cs
index 280ded7f1..9529986cf 100644
--- a/GreenshotDropboxPlugin/Forms/SettingsForm.cs
+++ b/GreenshotDropboxPlugin/Forms/SettingsForm.cs
@@ -19,10 +19,7 @@
* along with this program. If not, see .
*/
-using System;
-using System.Windows.Forms;
using GreenshotDropboxPlugin.Forms;
-using GreenshotPlugin.Core;
using Greenshot.IniFile;
namespace GreenshotDropboxPlugin {
diff --git a/GreenshotDropboxPlugin/Properties/AssemblyInfo.cs b/GreenshotDropboxPlugin/Properties/AssemblyInfo.cs
index 67d20ede5..4d498f26f 100644
--- a/GreenshotDropboxPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotDropboxPlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs b/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs
index f83bc9370..daea99116 100644
--- a/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs
+++ b/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs
@@ -61,12 +61,12 @@ namespace ExternalCommand {
public Dictionary runInbackground;
private const string MSPAINT = "MS Paint";
- private static string paintPath;
- private static bool hasPaint = false;
+ private static readonly string paintPath;
+ private static readonly bool hasPaint = false;
private const string PAINTDOTNET = "Paint.NET";
- private static string paintDotNetPath;
- private static bool hasPaintDotNet = false;
+ private static readonly string paintDotNetPath;
+ private static readonly bool hasPaintDotNet = false;
static ExternalCommandConfiguration() {
try {
paintPath = PluginUtils.GetExePath("pbrush.exe");
diff --git a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs
index ee13f6eee..bec3be704 100644
--- a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs
+++ b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs
@@ -34,24 +34,24 @@ namespace ExternalCommand {
/// Description of OCRDestination.
///
public class ExternalCommandDestination : AbstractDestination {
- private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandDestination));
- private static Regex URI_REGEXP = new Regex(@"((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)");
- private static ExternalCommandConfiguration config = IniConfig.GetIniSection();
- private string presetCommand;
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandDestination));
+ private static readonly Regex URI_REGEXP = new Regex(@"((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)");
+ private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection();
+ private readonly string _presetCommand;
public ExternalCommandDestination(string commando) {
- this.presetCommand = commando;
+ _presetCommand = commando;
}
public override string Designation {
get {
- return "External " + presetCommand.Replace(',','_');
+ return "External " + _presetCommand.Replace(',','_');
}
}
public override string Description {
get {
- return presetCommand;
+ return _presetCommand;
}
}
@@ -61,20 +61,20 @@ namespace ExternalCommand {
public override Image DisplayIcon {
get {
- return IconCache.IconForCommand(presetCommand);
+ return IconCache.IconForCommand(_presetCommand);
}
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings();
- if (presetCommand != null) {
- if (!config.runInbackground.ContainsKey(presetCommand)) {
- config.runInbackground.Add(presetCommand, true);
+ if (_presetCommand != null) {
+ if (!config.runInbackground.ContainsKey(_presetCommand)) {
+ config.runInbackground.Add(_presetCommand, true);
}
- bool runInBackground = config.runInbackground[presetCommand];
+ bool runInBackground = config.runInbackground[_presetCommand];
string fullPath = captureDetails.Filename;
if (fullPath == null) {
fullPath = ImageOutput.SaveNamedTmpFile(surface, captureDetails, outputSettings);
@@ -83,17 +83,20 @@ namespace ExternalCommand {
string output;
string error;
if (runInBackground) {
- Thread commandThread = new Thread(delegate() {
- CallExternalCommand(exportInformation, presetCommand, fullPath, out output, out error);
+ Thread commandThread = new Thread(delegate()
+ {
+ CallExternalCommand(exportInformation, fullPath, out output, out error);
ProcessExport(exportInformation, surface);
- });
- commandThread.Name = "Running " + presetCommand;
- commandThread.IsBackground = true;
+ })
+ {
+ Name = "Running " + _presetCommand,
+ IsBackground = true
+ };
commandThread.SetApartmentState(ApartmentState.STA);
commandThread.Start();
exportInformation.ExportMade = true;
} else {
- CallExternalCommand(exportInformation, presetCommand, fullPath, out output, out error);
+ CallExternalCommand(exportInformation, fullPath, out output, out error);
ProcessExport(exportInformation, surface);
}
}
@@ -105,15 +108,14 @@ namespace ExternalCommand {
/// Call the external command, parse for URI, place to clipboard and set the export information
///
///
- ///
///
///
///
- private void CallExternalCommand(ExportInformation exportInformation, string commando, string fullPath, out string output, out string error) {
+ private void CallExternalCommand(ExportInformation exportInformation, string fullPath, out string output, out string error) {
output = null;
error = null;
try {
- if (CallExternalCommand(presetCommand, fullPath, out output, out error) == 0) {
+ if (CallExternalCommand(_presetCommand, fullPath, out output, out error) == 0) {
exportInformation.ExportMade = true;
if (!string.IsNullOrEmpty(output)) {
MatchCollection uriMatches = URI_REGEXP.Matches(output);
@@ -121,7 +123,7 @@ namespace ExternalCommand {
if (config.OutputToClipboard) {
ClipboardHelper.SetClipboardData(output);
}
- if (uriMatches != null && uriMatches.Count > 0) {
+ if (uriMatches.Count > 0) {
exportInformation.Uri = uriMatches[0].Groups[1].Value;
LOG.InfoFormat("Got URI : {0} ", exportInformation.Uri);
if (config.UriToClipboard) {
@@ -156,13 +158,13 @@ namespace ExternalCommand {
try {
return CallExternalCommand(commando, fullPath, "runas", out output, out error);
} catch {
- w32ex.Data.Add("commandline", config.commandlines[presetCommand]);
- w32ex.Data.Add("arguments", config.arguments[presetCommand]);
+ w32ex.Data.Add("commandline", config.commandlines[_presetCommand]);
+ w32ex.Data.Add("arguments", config.arguments[_presetCommand]);
throw;
}
} catch (Exception ex) {
- ex.Data.Add("commandline", config.commandlines[presetCommand]);
- ex.Data.Add("arguments", config.arguments[presetCommand]);
+ ex.Data.Add("commandline", config.commandlines[_presetCommand]);
+ ex.Data.Add("arguments", config.arguments[_presetCommand]);
throw;
}
}
@@ -182,8 +184,16 @@ namespace ExternalCommand {
output = null;
error = null;
if (!string.IsNullOrEmpty(commandline)) {
- using (Process process = new Process()) {
- process.StartInfo.FileName = commandline;
+ using (Process process = new Process())
+ {
+ // Fix variables
+ commandline = FilenameHelper.FillVariables(commandline, true);
+ commandline = FilenameHelper.FillCmdVariables(commandline, true);
+
+ arguments = FilenameHelper.FillVariables(arguments, false);
+ arguments = FilenameHelper.FillCmdVariables(arguments, false);
+
+ process.StartInfo.FileName = FilenameHelper.FillCmdVariables(commandline, true);
process.StartInfo.Arguments = FormatArguments(arguments, fullPath);
process.StartInfo.UseShellExecute = false;
if (config.RedirectStandardOutput) {
@@ -200,13 +210,13 @@ namespace ExternalCommand {
process.WaitForExit();
if (config.RedirectStandardOutput) {
output = process.StandardOutput.ReadToEnd();
- if (config.ShowStandardOutputInLog && output != null && output.Trim().Length > 0) {
+ if (config.ShowStandardOutputInLog && output.Trim().Length > 0) {
LOG.InfoFormat("Output:\n{0}", output);
}
}
if (config.RedirectStandardError) {
error = process.StandardError.ReadToEnd();
- if (error != null && error.Trim().Length > 0) {
+ if (error.Trim().Length > 0) {
LOG.WarnFormat("Error:\n{0}", error);
}
}
@@ -219,7 +229,7 @@ namespace ExternalCommand {
public static string FormatArguments(string arguments, string fullpath)
{
- return String.Format(arguments, fullpath);
+ return string.Format(arguments, fullpath);
}
}
}
diff --git a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs
index 9531b0066..7848128a7 100644
--- a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs
+++ b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs
@@ -34,11 +34,11 @@ namespace ExternalCommand {
///
public class ExternalCommandPlugin : IGreenshotPlugin {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandPlugin));
- private static CoreConfiguration coreConfig = IniConfig.GetIniSection();
- private static ExternalCommandConfiguration config = IniConfig.GetIniSection();
- private IGreenshotHost host;
- private PluginAttribute myAttributes;
- private ToolStripMenuItem itemPlugInRoot;
+ private static readonly CoreConfiguration coreConfig = IniConfig.GetIniSection();
+ private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection();
+ private IGreenshotHost _host;
+ private PluginAttribute _myAttributes;
+ private ToolStripMenuItem _itemPlugInRoot;
public void Dispose() {
Dispose(true);
@@ -47,16 +47,13 @@ namespace ExternalCommand {
protected virtual void Dispose(bool disposing) {
if (disposing) {
- if (itemPlugInRoot != null) {
- itemPlugInRoot.Dispose();
- itemPlugInRoot = null;
+ if (_itemPlugInRoot != null) {
+ _itemPlugInRoot.Dispose();
+ _itemPlugInRoot = null;
}
}
}
- public ExternalCommandPlugin() {
- }
-
public IEnumerable Destinations() {
foreach(string command in config.commands) {
yield return new ExternalCommandDestination(command);
@@ -87,7 +84,10 @@ namespace ExternalCommand {
LOG.WarnFormat("Found missing commandline for {0}", command);
return false;
}
- if (!File.Exists(config.commandlines[command])) {
+ string commandline = FilenameHelper.FillVariables(config.commandlines[command], true);
+ commandline = FilenameHelper.FillCmdVariables(commandline, true);
+
+ if (!File.Exists(commandline)) {
LOG.WarnFormat("Found 'invalid' commandline {0} for command {1}", config.commandlines[command], command);
return false;
}
@@ -118,17 +118,17 @@ namespace ExternalCommand {
config.commands.Remove(command);
}
- this.host = pluginHost;
- this.myAttributes = myAttributes;
+ _host = pluginHost;
+ _myAttributes = myAttributes;
- itemPlugInRoot = new ToolStripMenuItem();
- itemPlugInRoot.Tag = host;
+ _itemPlugInRoot = new ToolStripMenuItem();
+ _itemPlugInRoot.Tag = _host;
OnIconSizeChanged(this, new PropertyChangedEventArgs("IconSize"));
OnLanguageChanged(this, null);
- itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick);
+ _itemPlugInRoot.Click += new EventHandler(ConfigMenuClick);
- PluginUtils.AddToContextMenu(host, itemPlugInRoot);
+ PluginUtils.AddToContextMenu(_host, _itemPlugInRoot);
Language.LanguageChanged += OnLanguageChanged;
coreConfig.PropertyChanged += OnIconSizeChanged;
return true;
@@ -144,7 +144,7 @@ namespace ExternalCommand {
try {
string exePath = PluginUtils.GetExePath("cmd.exe");
if (exePath != null && File.Exists(exePath)) {
- itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0);
+ _itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0);
}
} catch (Exception ex) {
LOG.Warn("Couldn't get the cmd.exe image", ex);
@@ -153,13 +153,13 @@ namespace ExternalCommand {
}
private void OnLanguageChanged(object sender, EventArgs e) {
- if (itemPlugInRoot != null) {
- itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure");
+ if (_itemPlugInRoot != null) {
+ _itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure");
}
}
public virtual void Shutdown() {
- LOG.Debug("Shutdown of " + myAttributes.Name);
+ LOG.Debug("Shutdown of " + _myAttributes.Name);
}
private void ConfigMenuClick(object sender, EventArgs eventArgs) {
diff --git a/GreenshotExternalCommandPlugin/IconCache.cs b/GreenshotExternalCommandPlugin/IconCache.cs
index c3e3f16bd..d7eac4410 100644
--- a/GreenshotExternalCommandPlugin/IconCache.cs
+++ b/GreenshotExternalCommandPlugin/IconCache.cs
@@ -1,5 +1,25 @@
-using System;
-using System.Collections.Generic;
+/*
+ * Greenshot - a free and open source screenshot tool
+ * Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
+ *
+ * For more information see: http://getgreenshot.org/
+ * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+using System;
using System.Drawing;
using System.IO;
using Greenshot.IniFile;
@@ -7,8 +27,8 @@ using GreenshotPlugin.Core;
namespace ExternalCommand {
public static class IconCache {
- private static ExternalCommandConfiguration config = IniConfig.GetIniSection();
- private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IconCache));
+ private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection();
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IconCache));
public static Image IconForCommand(string commandName) {
Image icon = null;
diff --git a/GreenshotExternalCommandPlugin/Properties/AssemblyInfo.cs b/GreenshotExternalCommandPlugin/Properties/AssemblyInfo.cs
index 812fd723c..26af92de2 100644
--- a/GreenshotExternalCommandPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotExternalCommandPlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/GreenshotExternalCommandPlugin/SettingsForm.cs b/GreenshotExternalCommandPlugin/SettingsForm.cs
index 247e38b59..a872b6882 100644
--- a/GreenshotExternalCommandPlugin/SettingsForm.cs
+++ b/GreenshotExternalCommandPlugin/SettingsForm.cs
@@ -30,7 +30,7 @@ namespace ExternalCommand {
///
public partial class SettingsForm : ExternalCommandForm {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm));
- private static ExternalCommandConfiguration config = IniConfig.GetIniSection();
+ private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection();
public SettingsForm() {
//
diff --git a/GreenshotExternalCommandPlugin/SettingsFormDetail.cs b/GreenshotExternalCommandPlugin/SettingsFormDetail.cs
index ae9d4b030..4890ee2a1 100644
--- a/GreenshotExternalCommandPlugin/SettingsFormDetail.cs
+++ b/GreenshotExternalCommandPlugin/SettingsFormDetail.cs
@@ -24,44 +24,45 @@ using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
+using GreenshotPlugin.Core;
namespace ExternalCommand {
///
/// Description of SettingsFormDetail.
///
public partial class SettingsFormDetail : ExternalCommandForm {
- private string commando;
- private int commandIndex;
-
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsFormDetail));
- private static ExternalCommandConfiguration config = IniConfig.GetIniSection();
+ private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection();
+
+ private readonly string _commando;
+ private readonly int _commandIndex;
public SettingsFormDetail(string commando) {
InitializeComponent();
AcceptButton = buttonOk;
CancelButton = buttonCancel;
- this.commando = commando;
+ _commando = commando;
if(commando != null) {
textBox_name.Text = commando;
textBox_commandline.Text = config.commandlines[commando];
textBox_arguments.Text = config.arguments[commando];
- commandIndex = config.commands.FindIndex(delegate(string s) { return s == commando; });
+ _commandIndex = config.commands.FindIndex(delegate(string s) { return s == commando; });
} else {
textBox_arguments.Text = "\"{0}\"";
}
- OKButtonState();
+ OkButtonState();
}
void ButtonOkClick(object sender, EventArgs e) {
string commandName = textBox_name.Text;
string commandLine = textBox_commandline.Text;
string arguments = textBox_arguments.Text;
- if(commando != null) {
- config.commands[commandIndex] = commandName;
- config.commandlines.Remove(commando);
+ if(_commando != null) {
+ config.commands[_commandIndex] = commandName;
+ config.commandlines.Remove(_commando);
config.commandlines.Add(commandName, commandLine);
- config.arguments.Remove(commando);
+ config.arguments.Remove(_commando);
config.arguments.Add(commandName, arguments);
} else {
config.commands.Add(commandName);
@@ -71,15 +72,23 @@ namespace ExternalCommand {
}
void Button3Click(object sender, EventArgs e) {
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*";
- openFileDialog.FilterIndex = 1;
- openFileDialog.CheckFileExists = true;
- openFileDialog.Multiselect = false;
+ OpenFileDialog openFileDialog = new OpenFileDialog
+ {
+ Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*",
+ FilterIndex = 1,
+ CheckFileExists = true,
+ Multiselect = false
+ };
string initialPath = null;
- try {
+ try
+ {
initialPath = Path.GetDirectoryName(textBox_commandline.Text);
- } catch { }
+ }
+ catch (Exception ex)
+ {
+ LOG.WarnFormat("Can't get the initial path via {0}", textBox_commandline.Text);
+ LOG.Warn("Exception: ", ex);
+ }
if(initialPath != null && Directory.Exists(initialPath)) {
openFileDialog.InitialDirectory = initialPath;
} else {
@@ -92,7 +101,7 @@ namespace ExternalCommand {
}
}
- private void OKButtonState() {
+ private void OkButtonState() {
// Assume OK
buttonOk.Enabled = true;
textBox_name.BackColor = Color.White;
@@ -103,7 +112,7 @@ namespace ExternalCommand {
buttonOk.Enabled = false;
}
// Check if commandname is unique
- if(commando == null && !string.IsNullOrEmpty(textBox_name.Text) && config.commands.Contains(textBox_name.Text)) {
+ if(_commando == null && !string.IsNullOrEmpty(textBox_name.Text) && config.commands.Contains(textBox_name.Text)) {
buttonOk.Enabled = false;
textBox_name.BackColor = Color.Red;
}
@@ -111,15 +120,27 @@ namespace ExternalCommand {
if(string.IsNullOrEmpty(textBox_commandline.Text)) {
buttonOk.Enabled = false;
}
- // Is the command available?
- if(!string.IsNullOrEmpty(textBox_commandline.Text) && !File.Exists(textBox_commandline.Text)) {
- buttonOk.Enabled = false;
- textBox_commandline.BackColor = Color.Red;
+
+ if (!string.IsNullOrEmpty(textBox_commandline.Text))
+ {
+ // Added this to be more flexible, using the Greenshot var format
+ string cmdPath = FilenameHelper.FillVariables(textBox_commandline.Text, true);
+ // And also replace the "DOS" Variables
+ cmdPath = FilenameHelper.FillCmdVariables(cmdPath, true);
+ // Is the command available?
+ if (!File.Exists(cmdPath))
+ {
+ buttonOk.Enabled = false;
+ textBox_commandline.BackColor = Color.Red;
+ }
}
- // Are the arguments in a valid format?
- try
+ // Are the arguments in a valid format?
+ try
{
- ExternalCommandDestination.FormatArguments(textBox_arguments.Text, string.Empty);
+ string arguments = FilenameHelper.FillVariables(textBox_arguments.Text, false);
+ arguments = FilenameHelper.FillCmdVariables(arguments, false);
+
+ ExternalCommandDestination.FormatArguments(arguments, string.Empty);
}
catch
{
@@ -129,16 +150,16 @@ namespace ExternalCommand {
}
private void textBox_name_TextChanged(object sender, EventArgs e) {
- OKButtonState();
+ OkButtonState();
}
private void textBox_commandline_TextChanged(object sender, EventArgs e) {
- OKButtonState();
+ OkButtonState();
}
private void textBox_arguments_TextChanged(object sender, EventArgs e)
{
- OKButtonState();
+ OkButtonState();
}
}
diff --git a/GreenshotFlickrPlugin/FlickrDestination.cs b/GreenshotFlickrPlugin/FlickrDestination.cs
index 7155937aa..0630ae933 100644
--- a/GreenshotFlickrPlugin/FlickrDestination.cs
+++ b/GreenshotFlickrPlugin/FlickrDestination.cs
@@ -27,7 +27,7 @@ using log4net;
namespace GreenshotFlickrPlugin {
public class FlickrDestination : AbstractDestination {
private static ILog LOG = LogManager.GetLogger(typeof(FlickrDestination));
- private FlickrPlugin plugin;
+ private readonly FlickrPlugin plugin;
public FlickrDestination(FlickrPlugin plugin) {
this.plugin = plugin;
}
diff --git a/GreenshotFlickrPlugin/FlickrUtils.cs b/GreenshotFlickrPlugin/FlickrUtils.cs
index 8737f85e0..08cc9e139 100644
--- a/GreenshotFlickrPlugin/FlickrUtils.cs
+++ b/GreenshotFlickrPlugin/FlickrUtils.cs
@@ -34,7 +34,7 @@ namespace GreenshotFlickrPlugin {
///
public class FlickrUtils {
private static readonly ILog LOG = LogManager.GetLogger(typeof(FlickrUtils));
- private static FlickrConfiguration config = IniConfig.GetIniSection();
+ private static readonly FlickrConfiguration config = IniConfig.GetIniSection();
private const string FLICKR_API_BASE_URL = "https://api.flickr.com/services/";
private const string FLICKR_UPLOAD_URL = FLICKR_API_BASE_URL + "upload/";
// OAUTH
diff --git a/GreenshotFlickrPlugin/Forms/FlickrForm.cs b/GreenshotFlickrPlugin/Forms/FlickrForm.cs
index 59358436e..f302308b2 100644
--- a/GreenshotFlickrPlugin/Forms/FlickrForm.cs
+++ b/GreenshotFlickrPlugin/Forms/FlickrForm.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
-using System;
using GreenshotPlugin.Controls;
namespace GreenshotFlickrPlugin.Forms {
diff --git a/GreenshotFlickrPlugin/Forms/SettingsForm.cs b/GreenshotFlickrPlugin/Forms/SettingsForm.cs
index 0835e2ea5..5622670b8 100644
--- a/GreenshotFlickrPlugin/Forms/SettingsForm.cs
+++ b/GreenshotFlickrPlugin/Forms/SettingsForm.cs
@@ -18,12 +18,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
-using System.Drawing;
-using System.Windows.Forms;
using GreenshotFlickrPlugin.Forms;
-using GreenshotPlugin.Core;
namespace GreenshotFlickrPlugin {
///
diff --git a/GreenshotFlickrPlugin/Properties/AssemblyInfo.cs b/GreenshotFlickrPlugin/Properties/AssemblyInfo.cs
index 810171a92..445f5e3e7 100644
--- a/GreenshotFlickrPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotFlickrPlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/GreenshotImgurPlugin/Forms/ImgurForm.cs b/GreenshotImgurPlugin/Forms/ImgurForm.cs
index d476f9313..35cd2949c 100644
--- a/GreenshotImgurPlugin/Forms/ImgurForm.cs
+++ b/GreenshotImgurPlugin/Forms/ImgurForm.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
-using System;
using GreenshotPlugin.Controls;
namespace GreenshotImgurPlugin {
diff --git a/GreenshotImgurPlugin/Forms/ImgurHistory.cs b/GreenshotImgurPlugin/Forms/ImgurHistory.cs
index 064fcc21f..b7efa5cb1 100644
--- a/GreenshotImgurPlugin/Forms/ImgurHistory.cs
+++ b/GreenshotImgurPlugin/Forms/ImgurHistory.cs
@@ -33,8 +33,8 @@ namespace GreenshotImgurPlugin {
///
public partial class ImgurHistory : ImgurForm {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurHistory));
- private GreenshotColumnSorter columnSorter;
- private static ImgurConfiguration config = IniConfig.GetIniSection();
+ private readonly GreenshotColumnSorter columnSorter;
+ private static readonly ImgurConfiguration config = IniConfig.GetIniSection();
private static ImgurHistory instance;
public static void ShowHistory() {
@@ -48,7 +48,7 @@ namespace GreenshotImgurPlugin {
}
private ImgurHistory() {
- this.ManualLanguageApply = true;
+ ManualLanguageApply = true;
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
@@ -57,7 +57,7 @@ namespace GreenshotImgurPlugin {
CancelButton = finishedButton;
// Init sorting
columnSorter = new GreenshotColumnSorter();
- this.listview_imgur_uploads.ListViewItemSorter = columnSorter;
+ listview_imgur_uploads.ListViewItemSorter = columnSorter;
columnSorter.SortColumn = 3;
columnSorter.Order = SortOrder.Descending;
redraw();
@@ -66,7 +66,7 @@ namespace GreenshotImgurPlugin {
}
ApplyLanguage();
if (config.Credits > 0) {
- this.Text = this.Text + " (" + config.Credits + " credits)";
+ Text = Text + " (" + config.Credits + " credits)";
}
}
@@ -169,7 +169,7 @@ namespace GreenshotImgurPlugin {
private void FinishedButtonClick(object sender, EventArgs e)
{
- this.Hide();
+ Hide();
}
private void OpenButtonClick(object sender, EventArgs e) {
@@ -197,7 +197,7 @@ namespace GreenshotImgurPlugin {
}
// Perform the sort with these new sort options.
- this.listview_imgur_uploads.Sort();
+ listview_imgur_uploads.Sort();
}
diff --git a/GreenshotImgurPlugin/Forms/SettingsForm.cs b/GreenshotImgurPlugin/Forms/SettingsForm.cs
index 8a35fc06e..40b9d65d3 100644
--- a/GreenshotImgurPlugin/Forms/SettingsForm.cs
+++ b/GreenshotImgurPlugin/Forms/SettingsForm.cs
@@ -19,9 +19,6 @@
* along with this program. If not, see .
*/
using System;
-using System.Windows.Forms;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.Controls;
namespace GreenshotImgurPlugin {
///
diff --git a/GreenshotImgurPlugin/ImgurDestination.cs b/GreenshotImgurPlugin/ImgurDestination.cs
index 9002463f3..6f931376f 100644
--- a/GreenshotImgurPlugin/ImgurDestination.cs
+++ b/GreenshotImgurPlugin/ImgurDestination.cs
@@ -31,7 +31,7 @@ namespace GreenshotImgurPlugin {
public class ImgurDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurDestination));
private static ImgurConfiguration config = IniConfig.GetIniSection();
- private ImgurPlugin plugin = null;
+ private readonly ImgurPlugin plugin = null;
public ImgurDestination(ImgurPlugin plugin) {
this.plugin = plugin;
@@ -57,7 +57,7 @@ namespace GreenshotImgurPlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
string uploadURL = null;
exportInformation.ExportMade = plugin.Upload(captureDetails, surface, out uploadURL);
exportInformation.Uri = uploadURL;
diff --git a/GreenshotImgurPlugin/ImgurPlugin.cs b/GreenshotImgurPlugin/ImgurPlugin.cs
index c5c354eec..1a69aee2e 100644
--- a/GreenshotImgurPlugin/ImgurPlugin.cs
+++ b/GreenshotImgurPlugin/ImgurPlugin.cs
@@ -80,7 +80,7 @@ namespace GreenshotImgurPlugin {
/// My own attributes
/// true if plugin is initialized, false if not (doesn't show)
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- this.host = (IGreenshotHost)pluginHost;
+ host = (IGreenshotHost)pluginHost;
Attributes = myAttributes;
// Get configuration
diff --git a/GreenshotImgurPlugin/Properties/AssemblyInfo.cs b/GreenshotImgurPlugin/Properties/AssemblyInfo.cs
index 06afabdf8..ba9c51983 100644
--- a/GreenshotImgurPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotImgurPlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/GreenshotJiraPlugin/Forms/JiraForm.cs b/GreenshotJiraPlugin/Forms/JiraForm.cs
index 535a039bf..e0c81c827 100644
--- a/GreenshotJiraPlugin/Forms/JiraForm.cs
+++ b/GreenshotJiraPlugin/Forms/JiraForm.cs
@@ -29,21 +29,21 @@ using Jira;
namespace GreenshotJiraPlugin {
public partial class JiraForm : Form {
- private JiraConnector jiraConnector;
+ private readonly JiraConnector jiraConnector;
private JiraIssue selectedIssue;
- private GreenshotColumnSorter columnSorter;
- private JiraConfiguration config = IniConfig.GetIniSection();
+ private readonly GreenshotColumnSorter columnSorter;
+ private readonly JiraConfiguration config = IniConfig.GetIniSection();
public JiraForm(JiraConnector jiraConnector) {
InitializeComponent();
- this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
+ Icon = GreenshotResources.getGreenshotIcon();
AcceptButton = uploadButton;
CancelButton = cancelButton;
initializeComponentText();
- this.columnSorter = new GreenshotColumnSorter();
- this.jiraListView.ListViewItemSorter = columnSorter;
+ columnSorter = new GreenshotColumnSorter();
+ jiraListView.ListViewItemSorter = columnSorter;
this.jiraConnector = jiraConnector;
@@ -60,9 +60,9 @@ namespace GreenshotJiraPlugin {
}
private void initializeComponentText() {
- this.label_jirafilter.Text = Language.GetString("jira", LangKey.label_jirafilter);
- this.label_comment.Text = Language.GetString("jira", LangKey.label_comment);
- this.label_filename.Text = Language.GetString("jira", LangKey.label_filename);
+ label_jirafilter.Text = Language.GetString("jira", LangKey.label_jirafilter);
+ label_comment.Text = Language.GetString("jira", LangKey.label_comment);
+ label_filename.Text = Language.GetString("jira", LangKey.label_filename);
}
private void updateForm() {
@@ -188,7 +188,7 @@ namespace GreenshotJiraPlugin {
}
// Perform the sort with these new sort options.
- this.jiraListView.Sort();
+ jiraListView.Sort();
}
void JiraKeyTextChanged(object sender, EventArgs e) {
diff --git a/GreenshotJiraPlugin/Forms/JiraFormBase.cs b/GreenshotJiraPlugin/Forms/JiraFormBase.cs
index 6cba807a3..b67d2e947 100644
--- a/GreenshotJiraPlugin/Forms/JiraFormBase.cs
+++ b/GreenshotJiraPlugin/Forms/JiraFormBase.cs
@@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
+
using GreenshotPlugin.Controls;
namespace GreenshotJiraPlugin {
diff --git a/GreenshotJiraPlugin/Forms/SettingsForm.cs b/GreenshotJiraPlugin/Forms/SettingsForm.cs
index 1ecaecfbf..49954efea 100644
--- a/GreenshotJiraPlugin/Forms/SettingsForm.cs
+++ b/GreenshotJiraPlugin/Forms/SettingsForm.cs
@@ -18,9 +18,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
-using System.Windows.Forms;
-using GreenshotPlugin.Core;
namespace GreenshotJiraPlugin {
///
diff --git a/GreenshotJiraPlugin/Jira.cs b/GreenshotJiraPlugin/Jira.cs
index cdaaae97a..53fdfa37f 100644
--- a/GreenshotJiraPlugin/Jira.cs
+++ b/GreenshotJiraPlugin/Jira.cs
@@ -33,8 +33,8 @@ namespace Jira {
#region transport classes
public class JiraFilter {
public JiraFilter(string name, string id) {
- this.Name = name;
- this.Id = id;
+ Name = name;
+ Id = id;
}
public string Name {
get;
@@ -48,15 +48,15 @@ namespace Jira {
public class JiraIssue {
public JiraIssue(string key, DateTime? created, string reporter, string assignee, string project, string summary, string description, string environment, string [] attachmentNames) {
- this.Key = key;
- this.Created = created;
- this.Reporter = reporter;
- this.Assignee = assignee;
- this.Project = project;
- this.Summary = summary;
- this.Description = description;
- this.Environment = environment;
- this.AttachmentNames = attachmentNames;
+ Key = key;
+ Created = created;
+ Reporter = reporter;
+ Assignee = assignee;
+ Project = project;
+ Summary = summary;
+ Description = description;
+ Environment = environment;
+ AttachmentNames = attachmentNames;
}
public string Key {
get;
@@ -100,17 +100,17 @@ namespace Jira {
public class JiraConnector : IDisposable {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraConnector));
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.jira.rpc.exception.RemoteAuthenticationException";
- private static JiraConfiguration config = IniConfig.GetIniSection();
+ private static readonly JiraConfiguration config = IniConfig.GetIniSection();
public const string DEFAULT_POSTFIX = "/rpc/soap/jirasoapservice-v2?wsdl";
private string credentials;
private DateTime loggedInTime = DateTime.Now;
private bool loggedIn;
private JiraSoapServiceService jira;
- private int timeout;
+ private readonly int timeout;
private string url;
- private Cache jiraCache = new Cache(60 * config.Timeout);
- private Cache userCache = new Cache(60 * config.Timeout);
- private bool suppressBackgroundForm = false;
+ private readonly Cache jiraCache = new Cache(60 * config.Timeout);
+ private readonly Cache userCache = new Cache(60 * config.Timeout);
+ private readonly bool suppressBackgroundForm = false;
public void Dispose() {
Dispose(true);
@@ -134,8 +134,8 @@ namespace Jira {
}
public JiraConnector(bool suppressBackgroundForm) {
- this.url = config.Url;
- this.timeout = config.Timeout;
+ url = config.Url;
+ timeout = config.Timeout;
this.suppressBackgroundForm = suppressBackgroundForm;
createService();
}
@@ -171,13 +171,13 @@ namespace Jira {
ThreadStart jiraLogin = delegate {
LOG.DebugFormat("Loggin in");
try {
- this.credentials = jira.login(user, password);
+ credentials = jira.login(user, password);
} catch (Exception) {
if (!url.EndsWith("wsdl")) {
url = url + "/rpc/soap/jirasoapservice-v2?wsdl";
// recreate the service with the new url
createService();
- this.credentials = jira.login(user, password);
+ credentials = jira.login(user, password);
// Worked, store the url in the configuration
config.Url = url;
IniConfig.Save();
@@ -187,8 +187,8 @@ namespace Jira {
}
LOG.DebugFormat("Logged in");
- this.loggedInTime = DateTime.Now;
- this.loggedIn = true;
+ loggedInTime = DateTime.Now;
+ loggedIn = true;
};
// Here we do it
@@ -204,8 +204,8 @@ namespace Jira {
return false;
}
// Not an authentication issue
- this.loggedIn = false;
- this.credentials = null;
+ loggedIn = false;
+ credentials = null;
e.Data.Add("user", user);
e.Data.Add("url", url);
throw;
diff --git a/GreenshotJiraPlugin/JiraDestination.cs b/GreenshotJiraPlugin/JiraDestination.cs
index bd443b37e..71bdd9d9e 100644
--- a/GreenshotJiraPlugin/JiraDestination.cs
+++ b/GreenshotJiraPlugin/JiraDestination.cs
@@ -35,10 +35,10 @@ namespace GreenshotJiraPlugin {
/// Description of JiraDestination.
///
public class JiraDestination : AbstractDestination {
- private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraDestination));
- private static JiraConfiguration config = IniConfig.GetIniSection();
- private JiraPlugin jiraPlugin = null;
- private JiraIssue jira = null;
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraDestination));
+ private static readonly JiraConfiguration config = IniConfig.GetIniSection();
+ private readonly JiraPlugin jiraPlugin = null;
+ private readonly JiraIssue jira = null;
public JiraDestination(JiraPlugin jiraPlugin) {
this.jiraPlugin = jiraPlugin;
@@ -100,7 +100,7 @@ namespace GreenshotJiraPlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surfaceToUpload, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
if (jira != null) {
diff --git a/GreenshotJiraPlugin/JiraPlugin.cs b/GreenshotJiraPlugin/JiraPlugin.cs
index 18e6576b9..b57a7a795 100644
--- a/GreenshotJiraPlugin/JiraPlugin.cs
+++ b/GreenshotJiraPlugin/JiraPlugin.cs
@@ -101,7 +101,7 @@ namespace GreenshotJiraPlugin {
/// My own attributes
/// true if plugin is initialized, false if not (doesn't show)
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- this.host = (IGreenshotHost)pluginHost;
+ host = (IGreenshotHost)pluginHost;
jiraPluginAttributes = myAttributes;
// Register configuration (don't need the configuration itself)
diff --git a/GreenshotJiraPlugin/JiraUtils.cs b/GreenshotJiraPlugin/JiraUtils.cs
index cd78c4bde..51e518dfd 100644
--- a/GreenshotJiraPlugin/JiraUtils.cs
+++ b/GreenshotJiraPlugin/JiraUtils.cs
@@ -30,7 +30,7 @@ namespace GreenshotJiraPlugin {
///
public class JiraUtils {
private static readonly Regex JIRA_KEY_REGEX = new Regex(@"/browse/([A-Z0-9]+\-[0-9]+)");
- private static JiraConfiguration config = IniConfig.GetIniSection();
+ private static readonly JiraConfiguration config = IniConfig.GetIniSection();
public static List GetCurrentJiras() {
// Make sure we suppress the login
diff --git a/GreenshotJiraPlugin/Properties/AssemblyInfo.cs b/GreenshotJiraPlugin/Properties/AssemblyInfo.cs
index 080ba5f3d..c3e1b2a63 100644
--- a/GreenshotJiraPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotJiraPlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/GreenshotOCRCommand/COMWrapper.cs b/GreenshotOCRCommand/COMWrapper.cs
index af7ef4bb0..9c8f0da03 100644
--- a/GreenshotOCRCommand/COMWrapper.cs
+++ b/GreenshotOCRCommand/COMWrapper.cs
@@ -43,12 +43,12 @@ namespace Greenshot.Interop {
///
/// Type of the COM object, set on constructor after getting the COM reference
///
- private Type _COMType;
+ private readonly Type _COMType;
///
/// The type of which method calls are intercepted and executed on the COM object.
///
- private Type _InterceptType;
+ private readonly Type _InterceptType;
#endregion
[DllImport("ole32.dll")]
@@ -214,9 +214,9 @@ namespace Greenshot.Interop {
///
private COMWrapper(object comObject, Type type)
: base(type) {
- this._COMObject = comObject;
- this._COMType = comObject.GetType();
- this._InterceptType = type;
+ _COMObject = comObject;
+ _COMType = comObject.GetType();
+ _InterceptType = type;
}
#endregion
@@ -228,14 +228,14 @@ namespace Greenshot.Interop {
/// sure that the COM object is still cleaned up.
///
~COMWrapper() {
- this.Dispose(false);
+ Dispose(false);
}
///
/// Cleans up the COM object.
///
public void Dispose() {
- this.Dispose(true);
+ Dispose(true);
GC.SuppressFinalize(this);
}
@@ -247,17 +247,17 @@ namespace Greenshot.Interop {
/// interface.
///
private void Dispose(bool disposing) {
- if (disposing && null != this._COMObject) {
- if (Marshal.IsComObject(this._COMObject)) {
+ if (disposing && null != _COMObject) {
+ if (Marshal.IsComObject(_COMObject)) {
try {
- while (Marshal.ReleaseComObject(this._COMObject) > 0);
+ while (Marshal.ReleaseComObject(_COMObject) > 0);
} catch (Exception) {
//LOG.WarnFormat("Problem releasing {0}", _COMType);
//LOG.Warn("Error: ", ex);
}
}
- this._COMObject = null;
+ _COMObject = null;
}
}
@@ -272,7 +272,7 @@ namespace Greenshot.Interop {
/// The full name of the intercepted type.
///
public override string ToString() {
- return this._InterceptType.FullName;
+ return _InterceptType.FullName;
}
///
@@ -282,7 +282,7 @@ namespace Greenshot.Interop {
/// The hash code of the wrapped object.
///
public override int GetHashCode() {
- return this._COMObject.GetHashCode();
+ return _COMObject.GetHashCode();
}
///
@@ -298,7 +298,7 @@ namespace Greenshot.Interop {
if (null != value && RemotingServices.IsTransparentProxy(value)) {
COMWrapper wrapper = RemotingServices.GetRealProxy(value) as COMWrapper;
if (null != wrapper) {
- return this._COMObject == wrapper._COMObject;
+ return _COMObject == wrapper._COMObject;
}
}
@@ -469,15 +469,15 @@ namespace Greenshot.Interop {
ParameterInfo parameter;
if ("Dispose" == methodName && 0 == argCount && typeof(void) == returnType) {
- this.Dispose();
+ Dispose();
} else if ("ToString" == methodName && 0 == argCount && typeof(string) == returnType) {
- returnValue = this.ToString();
- } else if ("GetType" == methodName && 0 == argCount && typeof(System.Type) == returnType) {
- returnValue = this._InterceptType;
+ returnValue = ToString();
+ } else if ("GetType" == methodName && 0 == argCount && typeof(Type) == returnType) {
+ returnValue = _InterceptType;
} else if ("GetHashCode" == methodName && 0 == argCount && typeof(int) == returnType) {
- returnValue = this.GetHashCode();
+ returnValue = GetHashCode();
} else if ("Equals" == methodName && 1 == argCount && typeof(bool) == returnType) {
- returnValue = this.Equals(callMessage.Args[0]);
+ returnValue = Equals(callMessage.Args[0]);
} else if (1 == argCount && typeof(void) == returnType && (methodName.StartsWith("add_") || methodName.StartsWith("remove_"))) {
bool removeHandler = methodName.StartsWith("remove_");
methodName = methodName.Substring(removeHandler ? 7 : 4);
@@ -487,8 +487,8 @@ namespace Greenshot.Interop {
return new ReturnMessage(new ArgumentNullException("handler"), callMessage);
}
} else {
- invokeObject = this._COMObject;
- invokeType = this._COMType;
+ invokeObject = _COMObject;
+ invokeType = _COMType;
if (methodName.StartsWith("get_")) {
// Property Get
@@ -565,7 +565,7 @@ namespace Greenshot.Interop {
if (returnType.IsInterface) {
// Wrap the returned value in an intercepting COM wrapper
if (Marshal.IsComObject(returnValue)) {
- returnValue = COMWrapper.Wrap(returnValue, returnType);
+ returnValue = Wrap(returnValue, returnType);
}
} else if (returnType.IsEnum) {
// Convert to proper Enum type
diff --git a/GreenshotOCRCommand/ComProgIdAttribute.cs b/GreenshotOCRCommand/ComProgIdAttribute.cs
index 231786e12..b8ef6a98e 100644
--- a/GreenshotOCRCommand/ComProgIdAttribute.cs
+++ b/GreenshotOCRCommand/ComProgIdAttribute.cs
@@ -26,7 +26,7 @@ namespace Greenshot.Interop {
///
[AttributeUsage(AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
public sealed class ComProgIdAttribute : Attribute {
- private string _value;
+ private readonly string _value;
///
/// Extracts the attribute from the specified type.
diff --git a/GreenshotOCRCommand/Properties/AssemblyInfo.cs b/GreenshotOCRCommand/Properties/AssemblyInfo.cs
index 419eb53b6..2daec6629 100644
--- a/GreenshotOCRCommand/Properties/AssemblyInfo.cs
+++ b/GreenshotOCRCommand/Properties/AssemblyInfo.cs
@@ -21,7 +21,6 @@
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
diff --git a/GreenshotOCRPlugin/OCRDestination.cs b/GreenshotOCRPlugin/OCRDestination.cs
index ac50ad74a..cd745baab 100644
--- a/GreenshotOCRPlugin/OCRDestination.cs
+++ b/GreenshotOCRPlugin/OCRDestination.cs
@@ -33,7 +33,7 @@ namespace GreenshotOCR {
private static OCRConfiguration config = IniConfig.GetIniSection();
private const int MIN_WIDTH = 130;
private const int MIN_HEIGHT = 130;
- private OcrPlugin plugin;
+ private readonly OcrPlugin plugin;
public override string Designation {
get {
@@ -62,7 +62,7 @@ namespace GreenshotOCR {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
exportInformation.ExportMade = plugin.DoOCR(surface) != null;
return exportInformation;
}
diff --git a/GreenshotOCRPlugin/OCRPlugin.cs b/GreenshotOCRPlugin/OCRPlugin.cs
index 8b4440136..c0e3137c9 100644
--- a/GreenshotOCRPlugin/OCRPlugin.cs
+++ b/GreenshotOCRPlugin/OCRPlugin.cs
@@ -21,7 +21,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Greenshot.IniFile;
@@ -61,7 +60,7 @@ namespace GreenshotOCR {
/// OCR Plugin Greenshot
///
public class OcrPlugin : IGreenshotPlugin {
- private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OcrPlugin));
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OcrPlugin));
private const string CONFIG_FILENAME = "ocr-config.properties";
private string OCR_COMMAND;
private static IGreenshotHost host;
diff --git a/GreenshotOCRPlugin/Properties/AssemblyInfo.cs b/GreenshotOCRPlugin/Properties/AssemblyInfo.cs
index c524510e1..303fbc1ea 100644
--- a/GreenshotOCRPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotOCRPlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/GreenshotOCRPlugin/SettingsForm.cs b/GreenshotOCRPlugin/SettingsForm.cs
index 88b1d029a..8fcb4ea90 100644
--- a/GreenshotOCRPlugin/SettingsForm.cs
+++ b/GreenshotOCRPlugin/SettingsForm.cs
@@ -19,15 +19,13 @@
* along with this program. If not, see .
*/
using System;
-using System.Windows.Forms;
-using GreenshotPlugin.Core;
namespace GreenshotOCR {
///
/// Description of SettingsForm.
///
public partial class SettingsForm : OCRForm {
- private OCRConfiguration config;
+ private readonly OCRConfiguration config;
public SettingsForm(string [] languages, OCRConfiguration config) {
//
diff --git a/GreenshotOfficePlugin/Destinations/ExcelDestination.cs b/GreenshotOfficePlugin/Destinations/ExcelDestination.cs
index 1b9e6febb..31771ca62 100644
--- a/GreenshotOfficePlugin/Destinations/ExcelDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/ExcelDestination.cs
@@ -18,16 +18,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
+
using System.Collections.Generic;
using System.Drawing;
using System.IO;
-using System.Windows.Forms;
-
using GreenshotPlugin.Core;
using Greenshot.Plugin;
using Greenshot.Interop.Office;
-using Greenshot.IniFile;
using System.Text.RegularExpressions;
namespace GreenshotOfficePlugin {
@@ -38,8 +35,8 @@ namespace GreenshotOfficePlugin {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelDestination));
private const int ICON_APPLICATION = 0;
private const int ICON_WORKBOOK = 1;
- private static string exePath = null;
- private string workbookName = null;
+ private static readonly string exePath = null;
+ private readonly string workbookName = null;
static ExcelDestination() {
exePath = PluginUtils.GetExePath("EXCEL.EXE");
@@ -107,7 +104,7 @@ namespace GreenshotOfficePlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
bool createdFile = false;
string imageFile = captureDetails.Filename;
if (imageFile == null || surface.Modified || !Regex.IsMatch(imageFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
diff --git a/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs b/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs
index 9a72feee5..048b039ef 100644
--- a/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs
@@ -29,11 +29,11 @@ using System.IO;
namespace GreenshotOfficePlugin {
public class OneNoteDestination : AbstractDestination {
- private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
private const int ICON_APPLICATION = 0;
public const string DESIGNATION = "OneNote";
- private static string exePath = null;
- private OneNotePage page = null;
+ private static readonly string exePath = null;
+ private readonly OneNotePage page = null;
static OneNoteDestination() {
exePath = PluginUtils.GetExePath("ONENOTE.EXE");
@@ -99,7 +99,7 @@ namespace GreenshotOfficePlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
if (page == null) {
try {
diff --git a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
index 66db19b40..6410e82d5 100644
--- a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
@@ -34,18 +34,18 @@ namespace GreenshotOfficePlugin {
/// Description of OutlookDestination.
///
public class OutlookDestination : AbstractDestination {
- private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OutlookDestination));
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OutlookDestination));
private const int ICON_APPLICATION = 0;
private const int ICON_MEETING = 2;
- private static Image mailIcon = GreenshotPlugin.Core.GreenshotResources.getImage("Email.Image");
- private static OfficeConfiguration conf = IniConfig.GetIniSection();
- private static string exePath = null;
- private static bool isActiveFlag = false;
- private static string mapiClient = "Microsoft Outlook";
+ private static readonly Image mailIcon = GreenshotResources.getImage("Email.Image");
+ private static readonly OfficeConfiguration conf = IniConfig.GetIniSection();
+ private static readonly string exePath = null;
+ private static readonly bool isActiveFlag = false;
+ private static readonly string mapiClient = "Microsoft Outlook";
public const string DESIGNATION = "Outlook";
- private string outlookInspectorCaption;
- private OlObjectClass outlookInspectorType;
+ private readonly string outlookInspectorCaption;
+ private readonly OlObjectClass outlookInspectorType;
static OutlookDestination() {
if (EmailConfigHelper.HasOutlook()) {
@@ -142,7 +142,7 @@ namespace GreenshotOfficePlugin {
///
///
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
// Outlook logic
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
diff --git a/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs b/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs
index 30a5d3df5..b3b317cba 100644
--- a/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs
@@ -18,16 +18,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
+
using System.Collections.Generic;
using System.Drawing;
using System.IO;
-using System.Windows.Forms;
-
using GreenshotPlugin.Core;
using Greenshot.Plugin;
using Greenshot.Interop.Office;
-using Greenshot.IniFile;
using System.Text.RegularExpressions;
namespace GreenshotOfficePlugin {
@@ -39,8 +36,8 @@ namespace GreenshotOfficePlugin {
private const int ICON_APPLICATION = 0;
private const int ICON_PRESENTATION = 1;
- private static string exePath = null;
- private string presentationName = null;
+ private static readonly string exePath = null;
+ private readonly string presentationName = null;
static PowerpointDestination() {
exePath = PluginUtils.GetExePath("POWERPNT.EXE");
@@ -109,7 +106,7 @@ namespace GreenshotOfficePlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
string tmpFile = captureDetails.Filename;
Size imageSize = Size.Empty;
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
diff --git a/GreenshotOfficePlugin/Destinations/WordDestination.cs b/GreenshotOfficePlugin/Destinations/WordDestination.cs
index 202b2ee72..b92001cea 100644
--- a/GreenshotOfficePlugin/Destinations/WordDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/WordDestination.cs
@@ -33,11 +33,11 @@ namespace GreenshotOfficePlugin {
/// Description of EmailDestination.
///
public class WordDestination : AbstractDestination {
- private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
private const int ICON_APPLICATION = 0;
private const int ICON_DOCUMENT = 1;
- private static string exePath = null;
- private string documentCaption = null;
+ private static readonly string exePath = null;
+ private readonly string documentCaption = null;
static WordDestination() {
exePath = PluginUtils.GetExePath("WINWORD.EXE");
@@ -51,7 +51,7 @@ namespace GreenshotOfficePlugin {
}
public WordDestination(string wordCaption) {
- this.documentCaption = wordCaption;
+ documentCaption = wordCaption;
}
public override string Designation {
@@ -104,7 +104,7 @@ namespace GreenshotOfficePlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
diff --git a/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs b/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs
index 0a5bfd161..5da5de6da 100644
--- a/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs
@@ -20,10 +20,7 @@
*/
using System;
using System.Collections.Generic;
-using System.Text;
using System.Reflection;
-
-using Greenshot.Interop;
using System.Drawing;
using GreenshotOfficePlugin;
using Greenshot.IniFile;
diff --git a/GreenshotOfficePlugin/OfficeExport/OneNoteExporter.cs b/GreenshotOfficePlugin/OfficeExport/OneNoteExporter.cs
index f2e419411..d152c8ec5 100644
--- a/GreenshotOfficePlugin/OfficeExport/OneNoteExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/OneNoteExporter.cs
@@ -20,7 +20,6 @@
*/
using System.Runtime.InteropServices;
-using System.Windows.Forms;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using System;
diff --git a/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs b/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs
index 39e0ea13c..6ecab8c4c 100644
--- a/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs
@@ -24,13 +24,7 @@ using System.Text;
using System.IO;
using Microsoft.Win32;
-
-using Greenshot.Interop;
using Greenshot.Interop.IE;
-using System.Threading;
-using System.Runtime.InteropServices;
-using System.Windows.Forms;
-using GreenshotPlugin.Core;
using GreenshotOfficePlugin;
using Greenshot.IniFile;
diff --git a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs
index bd45749e2..22e26eb00 100644
--- a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs
@@ -20,9 +20,6 @@
*/
using System;
using System.Collections.Generic;
-using System.Text;
-
-using Greenshot.Interop;
using GreenshotOfficePlugin;
using Greenshot.IniFile;
@@ -30,7 +27,7 @@ namespace Greenshot.Interop.Office {
public class WordExporter {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordExporter));
private static Version wordVersion = null;
- private static OfficeConfiguration config = IniConfig.GetIniSection();
+ private static readonly OfficeConfiguration config = IniConfig.GetIniSection();
///
/// Check if the used version is higher than Office 2003
diff --git a/GreenshotOfficePlugin/OfficeInterop/OutlookUtils.cs b/GreenshotOfficePlugin/OfficeInterop/OutlookUtils.cs
index 3f1532cef..ad6c9f840 100644
--- a/GreenshotOfficePlugin/OfficeInterop/OutlookUtils.cs
+++ b/GreenshotOfficePlugin/OfficeInterop/OutlookUtils.cs
@@ -601,11 +601,11 @@ namespace Greenshot.Interop.Office {
[FieldOffset(0)]
public uint propTag;
[FieldOffset(4)]
- public uint alignPad;
+ public readonly uint alignPad;
[FieldOffset(8)]
public IntPtr Value;
[FieldOffset(8)]
- public long filler;
+ public readonly long filler;
}
///
@@ -770,7 +770,7 @@ namespace Greenshot.Interop.Office {
Marshal.FreeHGlobal(propValue.Value);
IMAPIProp mapiProp = (IMAPIProp)Marshal.GetTypedObjectForIUnknown(IUnknown, typeof(IMAPIProp));
return mapiProp.SaveChanges(4) == 0;
- } catch (System.Exception ex) {
+ } catch (Exception ex) {
LOG.Error(ex);
return false;
} finally {
diff --git a/GreenshotOfficePlugin/Properties/AssemblyInfo.cs b/GreenshotOfficePlugin/Properties/AssemblyInfo.cs
index 79ad89124..a2c7f647e 100644
--- a/GreenshotOfficePlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotOfficePlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/GreenshotPhotobucketPlugin/Forms/SettingsForm.cs b/GreenshotPhotobucketPlugin/Forms/SettingsForm.cs
index 560a29b39..dcb077820 100644
--- a/GreenshotPhotobucketPlugin/Forms/SettingsForm.cs
+++ b/GreenshotPhotobucketPlugin/Forms/SettingsForm.cs
@@ -18,10 +18,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
-using System.Windows.Forms;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.Controls;
namespace GreenshotPhotobucketPlugin {
///
diff --git a/GreenshotPhotobucketPlugin/PhotobucketDestination.cs b/GreenshotPhotobucketPlugin/PhotobucketDestination.cs
index 68f467c53..11642c24e 100644
--- a/GreenshotPhotobucketPlugin/PhotobucketDestination.cs
+++ b/GreenshotPhotobucketPlugin/PhotobucketDestination.cs
@@ -33,8 +33,8 @@ namespace GreenshotPhotobucketPlugin {
public class PhotobucketDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PhotobucketDestination));
private static PhotobucketConfiguration config = IniConfig.GetIniSection();
- private PhotobucketPlugin plugin = null;
- private string albumPath = null;
+ private readonly PhotobucketPlugin plugin = null;
+ private readonly string albumPath = null;
///
/// Create a Photobucket destination, which also has the path to the album in it
@@ -97,7 +97,7 @@ namespace GreenshotPhotobucketPlugin {
///
///
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
string uploadURL = null;
bool uploaded = plugin.Upload(captureDetails, surface, albumPath, out uploadURL);
if (uploaded) {
diff --git a/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs b/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs
index 63fd3f035..3f2a70da7 100644
--- a/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs
+++ b/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs
@@ -74,7 +74,7 @@ namespace GreenshotPhotobucketPlugin {
/// My own attributes
/// true if plugin is initialized, false if not (doesn't show)
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- this.host = (IGreenshotHost)pluginHost;
+ host = (IGreenshotHost)pluginHost;
Attributes = myAttributes;
// Get configuration
diff --git a/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs b/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs
index d732925da..acdab0857 100644
--- a/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
diff --git a/GreenshotPicasaPlugin/Forms/SettingsForm.cs b/GreenshotPicasaPlugin/Forms/SettingsForm.cs
index edb7597f0..1ee8f5594 100644
--- a/GreenshotPicasaPlugin/Forms/SettingsForm.cs
+++ b/GreenshotPicasaPlugin/Forms/SettingsForm.cs
@@ -17,13 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-
-using Greenshot.Plugin;
-using GreenshotPlugin.Controls;
-using GreenshotPlugin.Core;
namespace GreenshotPicasaPlugin {
///
diff --git a/GreenshotPicasaPlugin/PicasaDestination.cs b/GreenshotPicasaPlugin/PicasaDestination.cs
index 8e489ef09..2a245716a 100644
--- a/GreenshotPicasaPlugin/PicasaDestination.cs
+++ b/GreenshotPicasaPlugin/PicasaDestination.cs
@@ -28,7 +28,7 @@ namespace GreenshotPicasaPlugin {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PicasaDestination));
private static PicasaConfiguration config = IniConfig.GetIniSection();
- private PicasaPlugin plugin = null;
+ private readonly PicasaPlugin plugin = null;
public PicasaDestination(PicasaPlugin plugin) {
this.plugin = plugin;
}
@@ -53,7 +53,7 @@ namespace GreenshotPicasaPlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
+ ExportInformation exportInformation = new ExportInformation(Designation, Description);
string uploadURL = null;
bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
if (uploaded) {
diff --git a/GreenshotPicasaPlugin/PicasaPlugin.cs b/GreenshotPicasaPlugin/PicasaPlugin.cs
index 7de3b12c9..334cead8c 100644
--- a/GreenshotPicasaPlugin/PicasaPlugin.cs
+++ b/GreenshotPicasaPlugin/PicasaPlugin.cs
@@ -73,7 +73,7 @@ namespace GreenshotPicasaPlugin {
/// Use the ICaptureHost interface to register in the MainContextMenu
/// My own attributes
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- this.host = (IGreenshotHost)pluginHost;
+ host = (IGreenshotHost)pluginHost;
Attributes = myAttributes;
// Get configuration
@@ -84,7 +84,7 @@ namespace GreenshotPicasaPlugin {
itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
itemPlugInRoot.Tag = host;
itemPlugInRoot.Image = (Image)resources.GetObject("Picasa");
- itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick);
+ itemPlugInRoot.Click += new EventHandler(ConfigMenuClick);
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
return true;
@@ -127,7 +127,7 @@ namespace GreenshotPicasaPlugin {
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality);
try {
string url = null;
- new PleaseWaitForm().ShowAndWait(PicasaPlugin.Attributes.Name, Language.GetString("picasa", LangKey.communication_wait),
+ new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("picasa", LangKey.communication_wait),
delegate() {
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
string contentType = "image/" + config.UploadFormat.ToString();
diff --git a/GreenshotPicasaPlugin/PicasaUtils.cs b/GreenshotPicasaPlugin/PicasaUtils.cs
index 14c8307d1..4aef53b5c 100644
--- a/GreenshotPicasaPlugin/PicasaUtils.cs
+++ b/GreenshotPicasaPlugin/PicasaUtils.cs
@@ -22,7 +22,6 @@ using Greenshot.IniFile;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using System;
-using System.Net;
using System.Xml;
namespace GreenshotPicasaPlugin {
diff --git a/GreenshotPicasaPlugin/Properties/AssemblyInfo.cs b/GreenshotPicasaPlugin/Properties/AssemblyInfo.cs
index 4e50cceda..479b13c8e 100644
--- a/GreenshotPicasaPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotPicasaPlugin/Properties/AssemblyInfo.cs
@@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/GreenshotPlugin/Controls/HotkeyControl.cs b/GreenshotPlugin/Controls/HotkeyControl.cs
index 372e67633..1d5b9d5d0 100644
--- a/GreenshotPlugin/Controls/HotkeyControl.cs
+++ b/GreenshotPlugin/Controls/HotkeyControl.cs
@@ -441,7 +441,7 @@ namespace GreenshotPlugin.Controls {
if (hotkey.LastIndexOf('+') > 0) {
hotkey = hotkey.Remove(0,hotkey.LastIndexOf('+')+1).Trim();
}
- key = (Keys)Keys.Parse(typeof(Keys), hotkey);
+ key = (Keys)Enum.Parse(typeof(Keys), hotkey);
}
return key;
}
diff --git a/GreenshotPlugin/Core/Cache.cs b/GreenshotPlugin/Core/Cache.cs
index 06b98899f..faf2a75a7 100644
--- a/GreenshotPlugin/Core/Cache.cs
+++ b/GreenshotPlugin/Core/Cache.cs
@@ -74,8 +74,11 @@ namespace GreenshotPlugin.Core {
get {
List elements = new List();
- foreach (TV element in internalCache.Values) {
- elements.Add(element);
+ lock (lockObject)
+ {
+ foreach (TV element in internalCache.Values) {
+ elements.Add(element);
+ }
}
foreach (TV element in elements) {
yield return element;
@@ -105,8 +108,12 @@ namespace GreenshotPlugin.Core {
///
///
/// true if the cache contains the key
- public bool Contains(TK key) {
- return internalCache.ContainsKey(key);
+ public bool Contains(TK key)
+ {
+ lock (lockObject)
+ {
+ return internalCache.ContainsKey(key);
+ }
}
///
diff --git a/GreenshotPlugin/Core/EventDelay.cs b/GreenshotPlugin/Core/EventDelay.cs
index 1dbd3d7c7..c1c686107 100644
--- a/GreenshotPlugin/Core/EventDelay.cs
+++ b/GreenshotPlugin/Core/EventDelay.cs
@@ -26,7 +26,7 @@ namespace GreenshotPlugin.Core {
private long lastCheck;
private readonly long waitTime;
public EventDelay(long ticks) {
- this.waitTime = ticks;
+ waitTime = ticks;
}
public bool Check() {
diff --git a/GreenshotPlugin/Core/FilenameHelper.cs b/GreenshotPlugin/Core/FilenameHelper.cs
index 236f4f2d9..33a41a3a2 100644
--- a/GreenshotPlugin/Core/FilenameHelper.cs
+++ b/GreenshotPlugin/Core/FilenameHelper.cs
@@ -38,6 +38,7 @@ namespace GreenshotPlugin.Core {
// The parameter format is a single alpha followed by the value belonging to the parameter, e.g. :
// ${capturetime:d"yyyy-MM-dd HH_mm_ss"}
private static readonly Regex VAR_REGEXP = new Regex(@"\${(?[^:}]+)[:]?(?[^}]*)}", RegexOptions.Compiled);
+ private static readonly Regex CMD_VAR_REGEXP = new Regex(@"%(?[^%]+)%", RegexOptions.Compiled);
private static readonly Regex SPLIT_REGEXP = new Regex(";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", RegexOptions.Compiled);
private const int MAX_TITLE_LENGTH = 80;
@@ -74,7 +75,7 @@ namespace GreenshotPlugin.Core {
///
/// Remove invalid characters from the path
///
- /// string with the full path to a file
+ /// string with the full path to a file
/// string with the full path to a file, without invalid characters
public static string MakePathSafe(string path) {
// Make the path save!
@@ -389,6 +390,51 @@ namespace GreenshotPlugin.Core {
return replaceValue;
}
+ ///
+ /// "Simply" fill the pattern with environment variables
+ ///
+ /// String with pattern %var%
+ /// true to make sure everything is filenamesafe
+ /// Filled string
+ public static string FillCmdVariables(string pattern, bool filenameSafeMode)
+ {
+ IDictionary processVars = null;
+ IDictionary userVars = null;
+ IDictionary machineVars = null;
+ try
+ {
+ processVars = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Process);
+ }
+ catch (Exception e)
+ {
+ LOG.Error("Error retrieving EnvironmentVariableTarget.Process", e);
+ }
+
+ try
+ {
+ userVars = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User);
+ }
+ catch (Exception e)
+ {
+ LOG.Error("Error retrieving EnvironmentVariableTarget.User", e);
+ }
+
+ try
+ {
+ machineVars = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine);
+ }
+ catch (Exception e)
+ {
+ LOG.Error("Error retrieving EnvironmentVariableTarget.Machine", e);
+ }
+
+ return CMD_VAR_REGEXP.Replace(pattern,
+ delegate (Match m) {
+ return MatchVarEvaluator(m, null, processVars, userVars, machineVars, filenameSafeMode);
+ }
+ );
+ }
+
///
/// "Simply" fill the pattern with environment variables
///
@@ -419,7 +465,7 @@ namespace GreenshotPlugin.Core {
return VAR_REGEXP.Replace(pattern,
delegate(Match m) {
- return MatchVarEvaluator(m, null, processVars, userVars, machineVars, filenameSafeMode);
+ return MatchVarEvaluator(m, null, processVars, userVars, machineVars, filenameSafeMode);
}
);
}
diff --git a/GreenshotPlugin/Core/LogHelper.cs b/GreenshotPlugin/Core/LogHelper.cs
index 27b2b6211..bd6aae4c9 100644
--- a/GreenshotPlugin/Core/LogHelper.cs
+++ b/GreenshotPlugin/Core/LogHelper.cs
@@ -101,7 +101,7 @@ namespace GreenshotPlugin.Core {
///
public class SpecialFolderPatternConverter : PatternConverter {
override protected void Convert(TextWriter writer, object state) {
- Environment.SpecialFolder specialFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), base.Option, true);
+ Environment.SpecialFolder specialFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), Option, true);
writer.Write(Environment.GetFolderPath(specialFolder));
}
}
diff --git a/GreenshotPlugin/Core/OAuthHelper.cs b/GreenshotPlugin/Core/OAuthHelper.cs
index add088da2..23651a7ef 100644
--- a/GreenshotPlugin/Core/OAuthHelper.cs
+++ b/GreenshotPlugin/Core/OAuthHelper.cs
@@ -1032,7 +1032,7 @@ Greenshot received information from CloudServiceName. You can close this browser
// Get response object.
using (HttpListenerResponse response = context.Response) {
// Write a "close" response.
- byte[] buffer = System.Text.Encoding.UTF8.GetBytes(ClosePageResponse.Replace("CloudServiceName", _cloudServiceName));
+ byte[] buffer = Encoding.UTF8.GetBytes(ClosePageResponse.Replace("CloudServiceName", _cloudServiceName));
// Write to response stream.
response.ContentLength64 = buffer.Length;
using (var stream = response.OutputStream) {
diff --git a/GreenshotPlugin/Core/PluginUtils.cs b/GreenshotPlugin/Core/PluginUtils.cs
index a3d910e61..e50210a5c 100644
--- a/GreenshotPlugin/Core/PluginUtils.cs
+++ b/GreenshotPlugin/Core/PluginUtils.cs
@@ -110,12 +110,15 @@ namespace GreenshotPlugin.Core {
public static Image GetCachedExeIcon(string path, int index) {
string cacheKey = string.Format("{0}:{1}", path, index);
Image returnValue;
- if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
- lock (exeIconCache) {
- if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
- returnValue = GetExeIcon(path, index);
- if (returnValue != null) {
- exeIconCache.Add(cacheKey, returnValue);
+ lock (exeIconCache)
+ {
+ if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
+ lock (exeIconCache) {
+ if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
+ returnValue = GetExeIcon(path, index);
+ if (returnValue != null) {
+ exeIconCache.Add(cacheKey, returnValue);
+ }
}
}
}
diff --git a/GreenshotPlugin/Core/SourceForgeHelper.cs b/GreenshotPlugin/Core/SourceForgeHelper.cs
index 6ead257d0..c58b6fbb0 100644
--- a/GreenshotPlugin/Core/SourceForgeHelper.cs
+++ b/GreenshotPlugin/Core/SourceForgeHelper.cs
@@ -85,10 +85,10 @@ namespace GreenshotPlugin.Core {
}
public SourceforgeFile(string file, string pubdate, string link, string directLink) {
- this._file = file;
+ _file = file;
DateTime.TryParse(pubdate, out _pubdate);
- this._link = link;
- this._directLink = directLink;
+ _link = link;
+ _directLink = directLink;
}
}
///