mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 09:33:46 -07:00
FEATURE-945: Added environment variables to the external command (also removed unused imports and made some variables readonly)
This commit is contained in:
parent
4f326c9c0e
commit
d25021631e
90 changed files with 390 additions and 373 deletions
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Greenshot.Controls {
|
namespace Greenshot.Controls {
|
||||||
|
|
|
@ -26,16 +26,12 @@ using Greenshot.Configuration;
|
||||||
using Greenshot.Helpers;
|
using Greenshot.Helpers;
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.IniFile;
|
|
||||||
using log4net;
|
|
||||||
|
|
||||||
namespace Greenshot.Destinations {
|
namespace Greenshot.Destinations {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of EmailDestination.
|
/// Description of EmailDestination.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EmailDestination : AbstractDestination {
|
public class EmailDestination : AbstractDestination {
|
||||||
private static ILog LOG = LogManager.GetLogger(typeof(EmailDestination));
|
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
|
||||||
private static readonly Image mailIcon = GreenshotResources.getImage("Email.Image");
|
private static readonly Image mailIcon = GreenshotResources.getImage("Email.Image");
|
||||||
private static bool isActiveFlag;
|
private static bool isActiveFlag;
|
||||||
private static string mapiClient;
|
private static string mapiClient;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
using Greenshot.Drawing.Fields;
|
using Greenshot.Drawing.Fields;
|
||||||
|
|
|
@ -21,15 +21,12 @@
|
||||||
|
|
||||||
using Greenshot.Drawing.Fields;
|
using Greenshot.Drawing.Fields;
|
||||||
using Greenshot.Helpers;
|
using Greenshot.Helpers;
|
||||||
using Greenshot.Plugin;
|
|
||||||
using Greenshot.Plugin.Drawing;
|
using Greenshot.Plugin.Drawing;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Text;
|
using System.Drawing.Text;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Windows.Forms;
|
|
||||||
using log4net;
|
|
||||||
|
|
||||||
namespace Greenshot.Drawing {
|
namespace Greenshot.Drawing {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -22,7 +22,6 @@ using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Greenshot.Core;
|
using Greenshot.Core;
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
|
|
||||||
namespace Greenshot.Forms {
|
namespace Greenshot.Forms {
|
||||||
public partial class DropShadowSettingsForm : BaseForm {
|
public partial class DropShadowSettingsForm : BaseForm {
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
|
|
||||||
namespace Greenshot.Forms {
|
namespace Greenshot.Forms {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -22,7 +22,6 @@ using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Greenshot.Core;
|
using Greenshot.Core;
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
|
|
||||||
namespace Greenshot.Forms {
|
namespace Greenshot.Forms {
|
||||||
public partial class TornEdgeSettingsForm : BaseForm {
|
public partial class TornEdgeSettingsForm : BaseForm {
|
||||||
|
|
|
@ -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-1935: Delay when pasting and ShapeShifter from FlameFusion is running|
|
||||||
* BUG-1941: Error when creating speech bubble|
|
* BUG-1941: Error when creating speech bubble|
|
||||||
* BUG-1945: Failure starting Greenshot at system startup|
|
* 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...
|
Testing is not finished, use at your own risk...
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -95,14 +95,14 @@ namespace Confluence {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
|
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 AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.confluence.rpc.AuthenticationFailedException";
|
||||||
private const string V2_FAILED = "AXIS";
|
private const string V2_FAILED = "AXIS";
|
||||||
private static ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
||||||
private string credentials = null;
|
private string credentials = null;
|
||||||
private DateTime loggedInTime = DateTime.Now;
|
private DateTime loggedInTime = DateTime.Now;
|
||||||
private bool loggedIn = false;
|
private bool loggedIn = false;
|
||||||
private ConfluenceSoapServiceService confluence;
|
private ConfluenceSoapServiceService confluence;
|
||||||
private int timeout;
|
private readonly int timeout;
|
||||||
private string url;
|
private string url;
|
||||||
private Cache<string, RemotePage> pageCache = new Cache<string, RemotePage>(60 * config.Timeout);
|
private readonly Cache<string, RemotePage> pageCache = new Cache<string, RemotePage>(60 * config.Timeout);
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -143,9 +143,9 @@ namespace Confluence {
|
||||||
/// <returns>true if login was done sucessfully</returns>
|
/// <returns>true if login was done sucessfully</returns>
|
||||||
private bool doLogin(string user, string password) {
|
private bool doLogin(string user, string password) {
|
||||||
try {
|
try {
|
||||||
this.credentials = confluence.login(user, password);
|
credentials = confluence.login(user, password);
|
||||||
this.loggedInTime = DateTime.Now;
|
loggedInTime = DateTime.Now;
|
||||||
this.loggedIn = true;
|
loggedIn = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Check if confluence-v2 caused an error, use v1 instead
|
// Check if confluence-v2 caused an error, use v1 instead
|
||||||
if (e.Message.Contains(V2_FAILED) && url.Contains("v2")) {
|
if (e.Message.Contains(V2_FAILED) && url.Contains("v2")) {
|
||||||
|
@ -157,8 +157,8 @@ namespace Confluence {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Not an authentication issue
|
// Not an authentication issue
|
||||||
this.loggedIn = false;
|
loggedIn = false;
|
||||||
this.credentials = null;
|
credentials = null;
|
||||||
e.Data.Add("user", user);
|
e.Data.Add("user", user);
|
||||||
e.Data.Add("url", url);
|
e.Data.Add("url", url);
|
||||||
throw;
|
throw;
|
||||||
|
|
|
@ -36,11 +36,11 @@ namespace GreenshotConfluencePlugin {
|
||||||
/// Description of ConfluenceDestination.
|
/// Description of ConfluenceDestination.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ConfluenceDestination : AbstractDestination {
|
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<ConfluenceConfiguration>();
|
private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
||||||
private static readonly CoreConfiguration coreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
private static readonly CoreConfiguration coreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private static Image confluenceIcon = null;
|
private static readonly Image confluenceIcon = null;
|
||||||
private Confluence.Page page;
|
private readonly Page page;
|
||||||
public static bool IsInitialized {
|
public static bool IsInitialized {
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
|
@ -63,7 +63,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
public ConfluenceDestination() {
|
public ConfluenceDestination() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfluenceDestination(Confluence.Page page) {
|
public ConfluenceDestination(Page page) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,17 +105,17 @@ namespace GreenshotConfluencePlugin {
|
||||||
if (ConfluencePlugin.ConfluenceConnectorNoLogin == null || !ConfluencePlugin.ConfluenceConnectorNoLogin.isLoggedIn) {
|
if (ConfluencePlugin.ConfluenceConnectorNoLogin == null || !ConfluencePlugin.ConfluenceConnectorNoLogin.isLoggedIn) {
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
List<Confluence.Page> currentPages = ConfluenceUtils.GetCurrentPages();
|
List<Page> currentPages = ConfluenceUtils.GetCurrentPages();
|
||||||
if (currentPages == null || currentPages.Count == 0) {
|
if (currentPages == null || currentPages.Count == 0) {
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
foreach(Confluence.Page currentPage in currentPages) {
|
foreach(Page currentPage in currentPages) {
|
||||||
yield return new ConfluenceDestination(currentPage);
|
yield return new ConfluenceDestination(currentPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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
|
// force password check to take place before the pages load
|
||||||
if (!ConfluencePlugin.ConfluenceConnector.isLoggedIn) {
|
if (!ConfluencePlugin.ConfluenceConnector.isLoggedIn) {
|
||||||
return exportInformation;
|
return exportInformation;
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Automation;
|
using System.Windows.Automation;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumDisplayer(Type type) {
|
public EnumDisplayer(Type type) {
|
||||||
this.Type = type;
|
Type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type Type {
|
public Type Type {
|
||||||
|
@ -49,15 +49,15 @@ namespace GreenshotConfluencePlugin {
|
||||||
if (!value.IsEnum) {
|
if (!value.IsEnum) {
|
||||||
throw new ArgumentException("parameter is not an Enumerated type", "value");
|
throw new ArgumentException("parameter is not an Enumerated type", "value");
|
||||||
}
|
}
|
||||||
this.type = value;
|
type = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyCollection<string> DisplayNames {
|
public ReadOnlyCollection<string> DisplayNames {
|
||||||
get {
|
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);
|
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||||
foreach (var field in fields) {
|
foreach (var field in fields) {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace GreenshotConfluencePlugin {
|
namespace GreenshotConfluencePlugin {
|
||||||
|
@ -26,7 +26,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
/// Interaction logic for ConfluenceConfigurationForm.xaml
|
/// Interaction logic for ConfluenceConfigurationForm.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ConfluenceConfigurationForm : Window {
|
public partial class ConfluenceConfigurationForm : Window {
|
||||||
private ConfluenceConfiguration config;
|
private readonly ConfluenceConfiguration config;
|
||||||
public ConfluenceConfiguration Config {
|
public ConfluenceConfiguration Config {
|
||||||
get {
|
get {
|
||||||
return config;
|
return config;
|
||||||
|
@ -34,7 +34,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfluenceConfigurationForm(ConfluenceConfiguration config) {
|
public ConfluenceConfigurationForm(ConfluenceConfiguration config) {
|
||||||
this.DataContext = config;
|
DataContext = config;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using Confluence;
|
using Confluence;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@ namespace GreenshotConfluencePlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ConfluencePagePicker : System.Windows.Controls.Page {
|
public partial class ConfluencePagePicker : System.Windows.Controls.Page {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluencePagePicker));
|
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<Page> pagesToPick) {
|
public ConfluencePagePicker(ConfluenceUpload confluenceUpload, List<Page> pagesToPick) {
|
||||||
this.confluenceUpload = confluenceUpload;
|
this.confluenceUpload = confluenceUpload;
|
||||||
this.DataContext = pagesToPick;
|
DataContext = pagesToPick;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,20 +18,17 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
using Confluence;
|
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
|
||||||
namespace GreenshotConfluencePlugin {
|
namespace GreenshotConfluencePlugin {
|
||||||
public partial class ConfluenceSearch : System.Windows.Controls.Page {
|
public partial class ConfluenceSearch : System.Windows.Controls.Page {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceSearch));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceSearch));
|
||||||
private static ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
||||||
private ConfluenceUpload confluenceUpload;
|
private readonly ConfluenceUpload confluenceUpload;
|
||||||
|
|
||||||
public List<Confluence.Space> Spaces {
|
public List<Confluence.Space> Spaces {
|
||||||
get {
|
get {
|
||||||
|
@ -39,7 +36,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ObservableCollection<Confluence.Page> pages = new ObservableCollection<Confluence.Page>();
|
private readonly ObservableCollection<Confluence.Page> pages = new ObservableCollection<Confluence.Page>();
|
||||||
public ObservableCollection<Confluence.Page> Pages {
|
public ObservableCollection<Confluence.Page> Pages {
|
||||||
get {
|
get {
|
||||||
return pages;
|
return pages;
|
||||||
|
@ -48,14 +45,14 @@ namespace GreenshotConfluencePlugin {
|
||||||
|
|
||||||
public ConfluenceSearch(ConfluenceUpload confluenceUpload) {
|
public ConfluenceSearch(ConfluenceUpload confluenceUpload) {
|
||||||
this.confluenceUpload = confluenceUpload;
|
this.confluenceUpload = confluenceUpload;
|
||||||
this.DataContext = this;
|
DataContext = this;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
if (config.SearchSpaceKey == null) {
|
if (config.SearchSpaceKey == null) {
|
||||||
this.SpaceComboBox.SelectedItem = Spaces[0];
|
SpaceComboBox.SelectedItem = Spaces[0];
|
||||||
} else {
|
} else {
|
||||||
foreach(Confluence.Space space in Spaces) {
|
foreach(Confluence.Space space in Spaces) {
|
||||||
if (space.Key.Equals(config.SearchSpaceKey)) {
|
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();
|
SelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ using System.Windows.Input;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
|
||||||
using Confluence;
|
using Confluence;
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
|
|
||||||
namespace GreenshotConfluencePlugin {
|
namespace GreenshotConfluencePlugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -35,12 +34,12 @@ namespace GreenshotConfluencePlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ConfluenceTreePicker : System.Windows.Controls.Page {
|
public partial class ConfluenceTreePicker : System.Windows.Controls.Page {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceTreePicker));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceTreePicker));
|
||||||
private ConfluenceConnector confluenceConnector;
|
private readonly ConfluenceConnector confluenceConnector;
|
||||||
private ConfluenceUpload confluenceUpload;
|
private readonly ConfluenceUpload confluenceUpload;
|
||||||
private bool isInitDone = false;
|
private bool isInitDone = false;
|
||||||
|
|
||||||
public ConfluenceTreePicker(ConfluenceUpload confluenceUpload) {
|
public ConfluenceTreePicker(ConfluenceUpload confluenceUpload) {
|
||||||
this.confluenceConnector = ConfluencePlugin.ConfluenceConnector;
|
confluenceConnector = ConfluencePlugin.ConfluenceConnector;
|
||||||
this.confluenceUpload = confluenceUpload;
|
this.confluenceUpload = confluenceUpload;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,12 +100,12 @@ namespace GreenshotConfluencePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfluenceUpload(string filename) {
|
public ConfluenceUpload(string filename) {
|
||||||
this.Filename = filename;
|
Filename = filename;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.DataContext = this;
|
this.DataContext = this;
|
||||||
updateSpaces();
|
updateSpaces();
|
||||||
if (PickerPage == null) {
|
if (PickerPage == null) {
|
||||||
PickerTab.Visibility = System.Windows.Visibility.Collapsed;
|
PickerTab.Visibility = Visibility.Collapsed;
|
||||||
SearchTab.IsSelected = true;
|
SearchTab.IsSelected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
using System;
|
namespace TranslationByMarkupExtension {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
|
|
||||||
namespace TranslationByMarkupExtension {
|
|
||||||
public interface ITranslationProvider {
|
public interface ITranslationProvider {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Translates the specified key.
|
/// Translates the specified key.
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
using System;
|
using GreenshotPlugin.Core;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
|
|
||||||
using GreenshotConfluencePlugin;
|
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
|
|
||||||
namespace TranslationByMarkupExtension {
|
namespace TranslationByMarkupExtension {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace TranslationByMarkupExtension {
|
||||||
public class TranslationData : IWeakEventListener, INotifyPropertyChanged {
|
public class TranslationData : IWeakEventListener, INotifyPropertyChanged {
|
||||||
#region Private Members
|
#region Private Members
|
||||||
|
|
||||||
private string _key;
|
private readonly string _key;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace TranslationByMarkupExtension {
|
namespace TranslationByMarkupExtension {
|
||||||
public class TranslationManager {
|
public class TranslationManager {
|
||||||
|
|
|
@ -26,9 +26,9 @@ using GreenshotPlugin.Core;
|
||||||
namespace GreenshotDropboxPlugin {
|
namespace GreenshotDropboxPlugin {
|
||||||
class DropboxDestination : AbstractDestination {
|
class DropboxDestination : AbstractDestination {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxDestination));
|
||||||
private static DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
|
private static readonly DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
|
||||||
|
|
||||||
private DropboxPlugin plugin = null;
|
private readonly DropboxPlugin plugin = null;
|
||||||
public DropboxDestination(DropboxPlugin plugin) {
|
public DropboxDestination(DropboxPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ namespace GreenshotDropboxPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manually, ISurface surface, ICaptureDetails captureDetails) {
|
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;
|
string uploadURL = null;
|
||||||
bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
|
bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
|
||||||
if (uploaded) {
|
if (uploaded) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace GreenshotDropboxPlugin {
|
||||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||||
/// <param name="pluginAttribute">My own attributes</param>
|
/// <param name="pluginAttribute">My own attributes</param>
|
||||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||||
this.host = (IGreenshotHost)pluginHost;
|
host = (IGreenshotHost)pluginHost;
|
||||||
Attributes = myAttributes;
|
Attributes = myAttributes;
|
||||||
|
|
||||||
// Register configuration (don't need the configuration itself)
|
// Register configuration (don't need the configuration itself)
|
||||||
|
@ -83,7 +83,7 @@ namespace GreenshotDropboxPlugin {
|
||||||
itemPlugInConfig = new ToolStripMenuItem();
|
itemPlugInConfig = new ToolStripMenuItem();
|
||||||
itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
|
itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
|
||||||
itemPlugInConfig.Tag = host;
|
itemPlugInConfig.Tag = host;
|
||||||
itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick);
|
itemPlugInConfig.Click += new EventHandler(ConfigMenuClick);
|
||||||
itemPlugInConfig.Image = (Image)resources.GetObject("Dropbox");
|
itemPlugInConfig.Image = (Image)resources.GetObject("Dropbox");
|
||||||
|
|
||||||
PluginUtils.AddToContextMenu(host, itemPlugInConfig);
|
PluginUtils.AddToContextMenu(host, itemPlugInConfig);
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace GreenshotDropboxPlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DropboxUtils {
|
public class DropboxUtils {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxUtils));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxUtils));
|
||||||
private static DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
|
private static readonly DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
|
||||||
|
|
||||||
private DropboxUtils() {
|
private DropboxUtils() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using GreenshotPlugin.Controls;
|
using GreenshotPlugin.Controls;
|
||||||
|
|
||||||
namespace GreenshotDropboxPlugin.Forms {
|
namespace GreenshotDropboxPlugin.Forms {
|
||||||
|
|
|
@ -19,10 +19,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using GreenshotDropboxPlugin.Forms;
|
using GreenshotDropboxPlugin.Forms;
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
|
||||||
namespace GreenshotDropboxPlugin {
|
namespace GreenshotDropboxPlugin {
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -61,12 +61,12 @@ namespace ExternalCommand {
|
||||||
public Dictionary<string, bool> runInbackground;
|
public Dictionary<string, bool> runInbackground;
|
||||||
|
|
||||||
private const string MSPAINT = "MS Paint";
|
private const string MSPAINT = "MS Paint";
|
||||||
private static string paintPath;
|
private static readonly string paintPath;
|
||||||
private static bool hasPaint = false;
|
private static readonly bool hasPaint = false;
|
||||||
|
|
||||||
private const string PAINTDOTNET = "Paint.NET";
|
private const string PAINTDOTNET = "Paint.NET";
|
||||||
private static string paintDotNetPath;
|
private static readonly string paintDotNetPath;
|
||||||
private static bool hasPaintDotNet = false;
|
private static readonly bool hasPaintDotNet = false;
|
||||||
static ExternalCommandConfiguration() {
|
static ExternalCommandConfiguration() {
|
||||||
try {
|
try {
|
||||||
paintPath = PluginUtils.GetExePath("pbrush.exe");
|
paintPath = PluginUtils.GetExePath("pbrush.exe");
|
||||||
|
|
|
@ -34,24 +34,24 @@ namespace ExternalCommand {
|
||||||
/// Description of OCRDestination.
|
/// Description of OCRDestination.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ExternalCommandDestination : AbstractDestination {
|
public class ExternalCommandDestination : AbstractDestination {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandDestination));
|
private static readonly 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 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 ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
||||||
private string presetCommand;
|
private readonly string _presetCommand;
|
||||||
|
|
||||||
public ExternalCommandDestination(string commando) {
|
public ExternalCommandDestination(string commando) {
|
||||||
this.presetCommand = commando;
|
_presetCommand = commando;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Designation {
|
public override string Designation {
|
||||||
get {
|
get {
|
||||||
return "External " + presetCommand.Replace(',','_');
|
return "External " + _presetCommand.Replace(',','_');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Description {
|
public override string Description {
|
||||||
get {
|
get {
|
||||||
return presetCommand;
|
return _presetCommand;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,20 +61,20 @@ namespace ExternalCommand {
|
||||||
|
|
||||||
public override Image DisplayIcon {
|
public override Image DisplayIcon {
|
||||||
get {
|
get {
|
||||||
return IconCache.IconForCommand(presetCommand);
|
return IconCache.IconForCommand(_presetCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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();
|
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings();
|
||||||
|
|
||||||
|
|
||||||
if (presetCommand != null) {
|
if (_presetCommand != null) {
|
||||||
if (!config.runInbackground.ContainsKey(presetCommand)) {
|
if (!config.runInbackground.ContainsKey(_presetCommand)) {
|
||||||
config.runInbackground.Add(presetCommand, true);
|
config.runInbackground.Add(_presetCommand, true);
|
||||||
}
|
}
|
||||||
bool runInBackground = config.runInbackground[presetCommand];
|
bool runInBackground = config.runInbackground[_presetCommand];
|
||||||
string fullPath = captureDetails.Filename;
|
string fullPath = captureDetails.Filename;
|
||||||
if (fullPath == null) {
|
if (fullPath == null) {
|
||||||
fullPath = ImageOutput.SaveNamedTmpFile(surface, captureDetails, outputSettings);
|
fullPath = ImageOutput.SaveNamedTmpFile(surface, captureDetails, outputSettings);
|
||||||
|
@ -83,17 +83,20 @@ namespace ExternalCommand {
|
||||||
string output;
|
string output;
|
||||||
string error;
|
string error;
|
||||||
if (runInBackground) {
|
if (runInBackground) {
|
||||||
Thread commandThread = new Thread(delegate() {
|
Thread commandThread = new Thread(delegate()
|
||||||
CallExternalCommand(exportInformation, presetCommand, fullPath, out output, out error);
|
{
|
||||||
|
CallExternalCommand(exportInformation, fullPath, out output, out error);
|
||||||
ProcessExport(exportInformation, surface);
|
ProcessExport(exportInformation, surface);
|
||||||
});
|
})
|
||||||
commandThread.Name = "Running " + presetCommand;
|
{
|
||||||
commandThread.IsBackground = true;
|
Name = "Running " + _presetCommand,
|
||||||
|
IsBackground = true
|
||||||
|
};
|
||||||
commandThread.SetApartmentState(ApartmentState.STA);
|
commandThread.SetApartmentState(ApartmentState.STA);
|
||||||
commandThread.Start();
|
commandThread.Start();
|
||||||
exportInformation.ExportMade = true;
|
exportInformation.ExportMade = true;
|
||||||
} else {
|
} else {
|
||||||
CallExternalCommand(exportInformation, presetCommand, fullPath, out output, out error);
|
CallExternalCommand(exportInformation, fullPath, out output, out error);
|
||||||
ProcessExport(exportInformation, surface);
|
ProcessExport(exportInformation, surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,15 +108,14 @@ namespace ExternalCommand {
|
||||||
/// Call the external command, parse for URI, place to clipboard and set the export information
|
/// Call the external command, parse for URI, place to clipboard and set the export information
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="exportInformation"></param>
|
/// <param name="exportInformation"></param>
|
||||||
/// <param name="commando"></param>
|
|
||||||
/// <param name="fullPath"></param>
|
/// <param name="fullPath"></param>
|
||||||
/// <param name="output"></param>
|
/// <param name="output"></param>
|
||||||
/// <param name="error"></param>
|
/// <param name="error"></param>
|
||||||
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;
|
output = null;
|
||||||
error = null;
|
error = null;
|
||||||
try {
|
try {
|
||||||
if (CallExternalCommand(presetCommand, fullPath, out output, out error) == 0) {
|
if (CallExternalCommand(_presetCommand, fullPath, out output, out error) == 0) {
|
||||||
exportInformation.ExportMade = true;
|
exportInformation.ExportMade = true;
|
||||||
if (!string.IsNullOrEmpty(output)) {
|
if (!string.IsNullOrEmpty(output)) {
|
||||||
MatchCollection uriMatches = URI_REGEXP.Matches(output);
|
MatchCollection uriMatches = URI_REGEXP.Matches(output);
|
||||||
|
@ -121,7 +123,7 @@ namespace ExternalCommand {
|
||||||
if (config.OutputToClipboard) {
|
if (config.OutputToClipboard) {
|
||||||
ClipboardHelper.SetClipboardData(output);
|
ClipboardHelper.SetClipboardData(output);
|
||||||
}
|
}
|
||||||
if (uriMatches != null && uriMatches.Count > 0) {
|
if (uriMatches.Count > 0) {
|
||||||
exportInformation.Uri = uriMatches[0].Groups[1].Value;
|
exportInformation.Uri = uriMatches[0].Groups[1].Value;
|
||||||
LOG.InfoFormat("Got URI : {0} ", exportInformation.Uri);
|
LOG.InfoFormat("Got URI : {0} ", exportInformation.Uri);
|
||||||
if (config.UriToClipboard) {
|
if (config.UriToClipboard) {
|
||||||
|
@ -156,13 +158,13 @@ namespace ExternalCommand {
|
||||||
try {
|
try {
|
||||||
return CallExternalCommand(commando, fullPath, "runas", out output, out error);
|
return CallExternalCommand(commando, fullPath, "runas", out output, out error);
|
||||||
} catch {
|
} catch {
|
||||||
w32ex.Data.Add("commandline", config.commandlines[presetCommand]);
|
w32ex.Data.Add("commandline", config.commandlines[_presetCommand]);
|
||||||
w32ex.Data.Add("arguments", config.arguments[presetCommand]);
|
w32ex.Data.Add("arguments", config.arguments[_presetCommand]);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.Data.Add("commandline", config.commandlines[presetCommand]);
|
ex.Data.Add("commandline", config.commandlines[_presetCommand]);
|
||||||
ex.Data.Add("arguments", config.arguments[presetCommand]);
|
ex.Data.Add("arguments", config.arguments[_presetCommand]);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,8 +184,16 @@ namespace ExternalCommand {
|
||||||
output = null;
|
output = null;
|
||||||
error = null;
|
error = null;
|
||||||
if (!string.IsNullOrEmpty(commandline)) {
|
if (!string.IsNullOrEmpty(commandline)) {
|
||||||
using (Process process = new Process()) {
|
using (Process process = new Process())
|
||||||
process.StartInfo.FileName = commandline;
|
{
|
||||||
|
// 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.Arguments = FormatArguments(arguments, fullPath);
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
if (config.RedirectStandardOutput) {
|
if (config.RedirectStandardOutput) {
|
||||||
|
@ -200,13 +210,13 @@ namespace ExternalCommand {
|
||||||
process.WaitForExit();
|
process.WaitForExit();
|
||||||
if (config.RedirectStandardOutput) {
|
if (config.RedirectStandardOutput) {
|
||||||
output = process.StandardOutput.ReadToEnd();
|
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);
|
LOG.InfoFormat("Output:\n{0}", output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.RedirectStandardError) {
|
if (config.RedirectStandardError) {
|
||||||
error = process.StandardError.ReadToEnd();
|
error = process.StandardError.ReadToEnd();
|
||||||
if (error != null && error.Trim().Length > 0) {
|
if (error.Trim().Length > 0) {
|
||||||
LOG.WarnFormat("Error:\n{0}", error);
|
LOG.WarnFormat("Error:\n{0}", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +229,7 @@ namespace ExternalCommand {
|
||||||
|
|
||||||
public static string FormatArguments(string arguments, string fullpath)
|
public static string FormatArguments(string arguments, string fullpath)
|
||||||
{
|
{
|
||||||
return String.Format(arguments, fullpath);
|
return string.Format(arguments, fullpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,11 +34,11 @@ namespace ExternalCommand {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ExternalCommandPlugin : IGreenshotPlugin {
|
public class ExternalCommandPlugin : IGreenshotPlugin {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandPlugin));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandPlugin));
|
||||||
private static CoreConfiguration coreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
private static readonly CoreConfiguration coreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
||||||
private IGreenshotHost host;
|
private IGreenshotHost _host;
|
||||||
private PluginAttribute myAttributes;
|
private PluginAttribute _myAttributes;
|
||||||
private ToolStripMenuItem itemPlugInRoot;
|
private ToolStripMenuItem _itemPlugInRoot;
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -47,16 +47,13 @@ namespace ExternalCommand {
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing) {
|
protected virtual void Dispose(bool disposing) {
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
if (itemPlugInRoot != null) {
|
if (_itemPlugInRoot != null) {
|
||||||
itemPlugInRoot.Dispose();
|
_itemPlugInRoot.Dispose();
|
||||||
itemPlugInRoot = null;
|
_itemPlugInRoot = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalCommandPlugin() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<IDestination> Destinations() {
|
public IEnumerable<IDestination> Destinations() {
|
||||||
foreach(string command in config.commands) {
|
foreach(string command in config.commands) {
|
||||||
yield return new ExternalCommandDestination(command);
|
yield return new ExternalCommandDestination(command);
|
||||||
|
@ -87,7 +84,10 @@ namespace ExternalCommand {
|
||||||
LOG.WarnFormat("Found missing commandline for {0}", command);
|
LOG.WarnFormat("Found missing commandline for {0}", command);
|
||||||
return false;
|
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);
|
LOG.WarnFormat("Found 'invalid' commandline {0} for command {1}", config.commandlines[command], command);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -118,17 +118,17 @@ namespace ExternalCommand {
|
||||||
config.commands.Remove(command);
|
config.commands.Remove(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.host = pluginHost;
|
_host = pluginHost;
|
||||||
this.myAttributes = myAttributes;
|
_myAttributes = myAttributes;
|
||||||
|
|
||||||
|
|
||||||
itemPlugInRoot = new ToolStripMenuItem();
|
_itemPlugInRoot = new ToolStripMenuItem();
|
||||||
itemPlugInRoot.Tag = host;
|
_itemPlugInRoot.Tag = _host;
|
||||||
OnIconSizeChanged(this, new PropertyChangedEventArgs("IconSize"));
|
OnIconSizeChanged(this, new PropertyChangedEventArgs("IconSize"));
|
||||||
OnLanguageChanged(this, null);
|
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;
|
Language.LanguageChanged += OnLanguageChanged;
|
||||||
coreConfig.PropertyChanged += OnIconSizeChanged;
|
coreConfig.PropertyChanged += OnIconSizeChanged;
|
||||||
return true;
|
return true;
|
||||||
|
@ -144,7 +144,7 @@ namespace ExternalCommand {
|
||||||
try {
|
try {
|
||||||
string exePath = PluginUtils.GetExePath("cmd.exe");
|
string exePath = PluginUtils.GetExePath("cmd.exe");
|
||||||
if (exePath != null && File.Exists(exePath)) {
|
if (exePath != null && File.Exists(exePath)) {
|
||||||
itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0);
|
_itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.Warn("Couldn't get the cmd.exe image", ex);
|
LOG.Warn("Couldn't get the cmd.exe image", ex);
|
||||||
|
@ -153,13 +153,13 @@ namespace ExternalCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLanguageChanged(object sender, EventArgs e) {
|
private void OnLanguageChanged(object sender, EventArgs e) {
|
||||||
if (itemPlugInRoot != null) {
|
if (_itemPlugInRoot != null) {
|
||||||
itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure");
|
_itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Shutdown() {
|
public virtual void Shutdown() {
|
||||||
LOG.Debug("Shutdown of " + myAttributes.Name);
|
LOG.Debug("Shutdown of " + _myAttributes.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConfigMenuClick(object sender, EventArgs eventArgs) {
|
private void ConfigMenuClick(object sender, EventArgs eventArgs) {
|
||||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
@ -7,8 +27,8 @@ using GreenshotPlugin.Core;
|
||||||
|
|
||||||
namespace ExternalCommand {
|
namespace ExternalCommand {
|
||||||
public static class IconCache {
|
public static class IconCache {
|
||||||
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IconCache));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IconCache));
|
||||||
|
|
||||||
public static Image IconForCommand(string commandName) {
|
public static Image IconForCommand(string commandName) {
|
||||||
Image icon = null;
|
Image icon = null;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace ExternalCommand {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SettingsForm : ExternalCommandForm {
|
public partial class SettingsForm : ExternalCommandForm {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm));
|
||||||
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
||||||
|
|
||||||
public SettingsForm() {
|
public SettingsForm() {
|
||||||
//
|
//
|
||||||
|
|
|
@ -24,44 +24,45 @@ using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using GreenshotPlugin.Core;
|
||||||
|
|
||||||
namespace ExternalCommand {
|
namespace ExternalCommand {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of SettingsFormDetail.
|
/// Description of SettingsFormDetail.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SettingsFormDetail : ExternalCommandForm {
|
public partial class SettingsFormDetail : ExternalCommandForm {
|
||||||
private string commando;
|
|
||||||
private int commandIndex;
|
|
||||||
|
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsFormDetail));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsFormDetail));
|
||||||
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
||||||
|
|
||||||
|
private readonly string _commando;
|
||||||
|
private readonly int _commandIndex;
|
||||||
|
|
||||||
public SettingsFormDetail(string commando) {
|
public SettingsFormDetail(string commando) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
AcceptButton = buttonOk;
|
AcceptButton = buttonOk;
|
||||||
CancelButton = buttonCancel;
|
CancelButton = buttonCancel;
|
||||||
this.commando = commando;
|
_commando = commando;
|
||||||
|
|
||||||
if(commando != null) {
|
if(commando != null) {
|
||||||
textBox_name.Text = commando;
|
textBox_name.Text = commando;
|
||||||
textBox_commandline.Text = config.commandlines[commando];
|
textBox_commandline.Text = config.commandlines[commando];
|
||||||
textBox_arguments.Text = config.arguments[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 {
|
} else {
|
||||||
textBox_arguments.Text = "\"{0}\"";
|
textBox_arguments.Text = "\"{0}\"";
|
||||||
}
|
}
|
||||||
OKButtonState();
|
OkButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonOkClick(object sender, EventArgs e) {
|
void ButtonOkClick(object sender, EventArgs e) {
|
||||||
string commandName = textBox_name.Text;
|
string commandName = textBox_name.Text;
|
||||||
string commandLine = textBox_commandline.Text;
|
string commandLine = textBox_commandline.Text;
|
||||||
string arguments = textBox_arguments.Text;
|
string arguments = textBox_arguments.Text;
|
||||||
if(commando != null) {
|
if(_commando != null) {
|
||||||
config.commands[commandIndex] = commandName;
|
config.commands[_commandIndex] = commandName;
|
||||||
config.commandlines.Remove(commando);
|
config.commandlines.Remove(_commando);
|
||||||
config.commandlines.Add(commandName, commandLine);
|
config.commandlines.Add(commandName, commandLine);
|
||||||
config.arguments.Remove(commando);
|
config.arguments.Remove(_commando);
|
||||||
config.arguments.Add(commandName, arguments);
|
config.arguments.Add(commandName, arguments);
|
||||||
} else {
|
} else {
|
||||||
config.commands.Add(commandName);
|
config.commands.Add(commandName);
|
||||||
|
@ -71,15 +72,23 @@ namespace ExternalCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button3Click(object sender, EventArgs e) {
|
void Button3Click(object sender, EventArgs e) {
|
||||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
OpenFileDialog openFileDialog = new OpenFileDialog
|
||||||
openFileDialog.Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*";
|
{
|
||||||
openFileDialog.FilterIndex = 1;
|
Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*",
|
||||||
openFileDialog.CheckFileExists = true;
|
FilterIndex = 1,
|
||||||
openFileDialog.Multiselect = false;
|
CheckFileExists = true,
|
||||||
|
Multiselect = false
|
||||||
|
};
|
||||||
string initialPath = null;
|
string initialPath = null;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
initialPath = Path.GetDirectoryName(textBox_commandline.Text);
|
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)) {
|
if(initialPath != null && Directory.Exists(initialPath)) {
|
||||||
openFileDialog.InitialDirectory = initialPath;
|
openFileDialog.InitialDirectory = initialPath;
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,7 +101,7 @@ namespace ExternalCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OKButtonState() {
|
private void OkButtonState() {
|
||||||
// Assume OK
|
// Assume OK
|
||||||
buttonOk.Enabled = true;
|
buttonOk.Enabled = true;
|
||||||
textBox_name.BackColor = Color.White;
|
textBox_name.BackColor = Color.White;
|
||||||
|
@ -103,7 +112,7 @@ namespace ExternalCommand {
|
||||||
buttonOk.Enabled = false;
|
buttonOk.Enabled = false;
|
||||||
}
|
}
|
||||||
// Check if commandname is unique
|
// 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;
|
buttonOk.Enabled = false;
|
||||||
textBox_name.BackColor = Color.Red;
|
textBox_name.BackColor = Color.Red;
|
||||||
}
|
}
|
||||||
|
@ -111,15 +120,27 @@ namespace ExternalCommand {
|
||||||
if(string.IsNullOrEmpty(textBox_commandline.Text)) {
|
if(string.IsNullOrEmpty(textBox_commandline.Text)) {
|
||||||
buttonOk.Enabled = false;
|
buttonOk.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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?
|
// Is the command available?
|
||||||
if(!string.IsNullOrEmpty(textBox_commandline.Text) && !File.Exists(textBox_commandline.Text)) {
|
if (!File.Exists(cmdPath))
|
||||||
|
{
|
||||||
buttonOk.Enabled = false;
|
buttonOk.Enabled = false;
|
||||||
textBox_commandline.BackColor = Color.Red;
|
textBox_commandline.BackColor = Color.Red;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Are the arguments in a valid format?
|
// Are the arguments in a valid format?
|
||||||
try
|
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
|
catch
|
||||||
{
|
{
|
||||||
|
@ -129,16 +150,16 @@ namespace ExternalCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void textBox_name_TextChanged(object sender, EventArgs e) {
|
private void textBox_name_TextChanged(object sender, EventArgs e) {
|
||||||
OKButtonState();
|
OkButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void textBox_commandline_TextChanged(object sender, EventArgs e) {
|
private void textBox_commandline_TextChanged(object sender, EventArgs e) {
|
||||||
OKButtonState();
|
OkButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void textBox_arguments_TextChanged(object sender, EventArgs e)
|
private void textBox_arguments_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OKButtonState();
|
OkButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ using log4net;
|
||||||
namespace GreenshotFlickrPlugin {
|
namespace GreenshotFlickrPlugin {
|
||||||
public class FlickrDestination : AbstractDestination {
|
public class FlickrDestination : AbstractDestination {
|
||||||
private static ILog LOG = LogManager.GetLogger(typeof(FlickrDestination));
|
private static ILog LOG = LogManager.GetLogger(typeof(FlickrDestination));
|
||||||
private FlickrPlugin plugin;
|
private readonly FlickrPlugin plugin;
|
||||||
public FlickrDestination(FlickrPlugin plugin) {
|
public FlickrDestination(FlickrPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace GreenshotFlickrPlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FlickrUtils {
|
public class FlickrUtils {
|
||||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(FlickrUtils));
|
private static readonly ILog LOG = LogManager.GetLogger(typeof(FlickrUtils));
|
||||||
private static FlickrConfiguration config = IniConfig.GetIniSection<FlickrConfiguration>();
|
private static readonly FlickrConfiguration config = IniConfig.GetIniSection<FlickrConfiguration>();
|
||||||
private const string FLICKR_API_BASE_URL = "https://api.flickr.com/services/";
|
private const string FLICKR_API_BASE_URL = "https://api.flickr.com/services/";
|
||||||
private const string FLICKR_UPLOAD_URL = FLICKR_API_BASE_URL + "upload/";
|
private const string FLICKR_UPLOAD_URL = FLICKR_API_BASE_URL + "upload/";
|
||||||
// OAUTH
|
// OAUTH
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
|
||||||
using GreenshotPlugin.Controls;
|
using GreenshotPlugin.Controls;
|
||||||
|
|
||||||
namespace GreenshotFlickrPlugin.Forms {
|
namespace GreenshotFlickrPlugin.Forms {
|
||||||
|
|
|
@ -18,12 +18,8 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
using GreenshotFlickrPlugin.Forms;
|
using GreenshotFlickrPlugin.Forms;
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
|
|
||||||
namespace GreenshotFlickrPlugin {
|
namespace GreenshotFlickrPlugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
|
||||||
using GreenshotPlugin.Controls;
|
using GreenshotPlugin.Controls;
|
||||||
|
|
||||||
namespace GreenshotImgurPlugin {
|
namespace GreenshotImgurPlugin {
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace GreenshotImgurPlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ImgurHistory : ImgurForm {
|
public partial class ImgurHistory : ImgurForm {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurHistory));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurHistory));
|
||||||
private GreenshotColumnSorter columnSorter;
|
private readonly GreenshotColumnSorter columnSorter;
|
||||||
private static ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
|
private static readonly ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
|
||||||
private static ImgurHistory instance;
|
private static ImgurHistory instance;
|
||||||
|
|
||||||
public static void ShowHistory() {
|
public static void ShowHistory() {
|
||||||
|
@ -48,7 +48,7 @@ namespace GreenshotImgurPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImgurHistory() {
|
private ImgurHistory() {
|
||||||
this.ManualLanguageApply = true;
|
ManualLanguageApply = true;
|
||||||
//
|
//
|
||||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||||
//
|
//
|
||||||
|
@ -57,7 +57,7 @@ namespace GreenshotImgurPlugin {
|
||||||
CancelButton = finishedButton;
|
CancelButton = finishedButton;
|
||||||
// Init sorting
|
// Init sorting
|
||||||
columnSorter = new GreenshotColumnSorter();
|
columnSorter = new GreenshotColumnSorter();
|
||||||
this.listview_imgur_uploads.ListViewItemSorter = columnSorter;
|
listview_imgur_uploads.ListViewItemSorter = columnSorter;
|
||||||
columnSorter.SortColumn = 3;
|
columnSorter.SortColumn = 3;
|
||||||
columnSorter.Order = SortOrder.Descending;
|
columnSorter.Order = SortOrder.Descending;
|
||||||
redraw();
|
redraw();
|
||||||
|
@ -66,7 +66,7 @@ namespace GreenshotImgurPlugin {
|
||||||
}
|
}
|
||||||
ApplyLanguage();
|
ApplyLanguage();
|
||||||
if (config.Credits > 0) {
|
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)
|
private void FinishedButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenButtonClick(object sender, EventArgs e) {
|
private void OpenButtonClick(object sender, EventArgs e) {
|
||||||
|
@ -197,7 +197,7 @@ namespace GreenshotImgurPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the sort with these new sort options.
|
// Perform the sort with these new sort options.
|
||||||
this.listview_imgur_uploads.Sort();
|
listview_imgur_uploads.Sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
using GreenshotPlugin.Controls;
|
|
||||||
|
|
||||||
namespace GreenshotImgurPlugin {
|
namespace GreenshotImgurPlugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace GreenshotImgurPlugin {
|
||||||
public class ImgurDestination : AbstractDestination {
|
public class ImgurDestination : AbstractDestination {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurDestination));
|
||||||
private static ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
|
private static ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
|
||||||
private ImgurPlugin plugin = null;
|
private readonly ImgurPlugin plugin = null;
|
||||||
|
|
||||||
public ImgurDestination(ImgurPlugin plugin) {
|
public ImgurDestination(ImgurPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
@ -57,7 +57,7 @@ namespace GreenshotImgurPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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;
|
string uploadURL = null;
|
||||||
exportInformation.ExportMade = plugin.Upload(captureDetails, surface, out uploadURL);
|
exportInformation.ExportMade = plugin.Upload(captureDetails, surface, out uploadURL);
|
||||||
exportInformation.Uri = uploadURL;
|
exportInformation.Uri = uploadURL;
|
||||||
|
|
|
@ -80,7 +80,7 @@ namespace GreenshotImgurPlugin {
|
||||||
/// <param name="pluginAttribute">My own attributes</param>
|
/// <param name="pluginAttribute">My own attributes</param>
|
||||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||||
this.host = (IGreenshotHost)pluginHost;
|
host = (IGreenshotHost)pluginHost;
|
||||||
Attributes = myAttributes;
|
Attributes = myAttributes;
|
||||||
|
|
||||||
// Get configuration
|
// Get configuration
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -29,21 +29,21 @@ using Jira;
|
||||||
|
|
||||||
namespace GreenshotJiraPlugin {
|
namespace GreenshotJiraPlugin {
|
||||||
public partial class JiraForm : Form {
|
public partial class JiraForm : Form {
|
||||||
private JiraConnector jiraConnector;
|
private readonly JiraConnector jiraConnector;
|
||||||
private JiraIssue selectedIssue;
|
private JiraIssue selectedIssue;
|
||||||
private GreenshotColumnSorter columnSorter;
|
private readonly GreenshotColumnSorter columnSorter;
|
||||||
private JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
private readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||||
|
|
||||||
public JiraForm(JiraConnector jiraConnector) {
|
public JiraForm(JiraConnector jiraConnector) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
|
Icon = GreenshotResources.getGreenshotIcon();
|
||||||
AcceptButton = uploadButton;
|
AcceptButton = uploadButton;
|
||||||
CancelButton = cancelButton;
|
CancelButton = cancelButton;
|
||||||
|
|
||||||
initializeComponentText();
|
initializeComponentText();
|
||||||
|
|
||||||
this.columnSorter = new GreenshotColumnSorter();
|
columnSorter = new GreenshotColumnSorter();
|
||||||
this.jiraListView.ListViewItemSorter = columnSorter;
|
jiraListView.ListViewItemSorter = columnSorter;
|
||||||
|
|
||||||
this.jiraConnector = jiraConnector;
|
this.jiraConnector = jiraConnector;
|
||||||
|
|
||||||
|
@ -60,9 +60,9 @@ namespace GreenshotJiraPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeComponentText() {
|
private void initializeComponentText() {
|
||||||
this.label_jirafilter.Text = Language.GetString("jira", LangKey.label_jirafilter);
|
label_jirafilter.Text = Language.GetString("jira", LangKey.label_jirafilter);
|
||||||
this.label_comment.Text = Language.GetString("jira", LangKey.label_comment);
|
label_comment.Text = Language.GetString("jira", LangKey.label_comment);
|
||||||
this.label_filename.Text = Language.GetString("jira", LangKey.label_filename);
|
label_filename.Text = Language.GetString("jira", LangKey.label_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateForm() {
|
private void updateForm() {
|
||||||
|
@ -188,7 +188,7 @@ namespace GreenshotJiraPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the sort with these new sort options.
|
// Perform the sort with these new sort options.
|
||||||
this.jiraListView.Sort();
|
jiraListView.Sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JiraKeyTextChanged(object sender, EventArgs e) {
|
void JiraKeyTextChanged(object sender, EventArgs e) {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using GreenshotPlugin.Controls;
|
using GreenshotPlugin.Controls;
|
||||||
|
|
||||||
namespace GreenshotJiraPlugin {
|
namespace GreenshotJiraPlugin {
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
|
|
||||||
namespace GreenshotJiraPlugin {
|
namespace GreenshotJiraPlugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace Jira {
|
||||||
#region transport classes
|
#region transport classes
|
||||||
public class JiraFilter {
|
public class JiraFilter {
|
||||||
public JiraFilter(string name, string id) {
|
public JiraFilter(string name, string id) {
|
||||||
this.Name = name;
|
Name = name;
|
||||||
this.Id = id;
|
Id = id;
|
||||||
}
|
}
|
||||||
public string Name {
|
public string Name {
|
||||||
get;
|
get;
|
||||||
|
@ -48,15 +48,15 @@ namespace Jira {
|
||||||
|
|
||||||
public class JiraIssue {
|
public class JiraIssue {
|
||||||
public JiraIssue(string key, DateTime? created, string reporter, string assignee, string project, string summary, string description, string environment, string [] attachmentNames) {
|
public JiraIssue(string key, DateTime? created, string reporter, string assignee, string project, string summary, string description, string environment, string [] attachmentNames) {
|
||||||
this.Key = key;
|
Key = key;
|
||||||
this.Created = created;
|
Created = created;
|
||||||
this.Reporter = reporter;
|
Reporter = reporter;
|
||||||
this.Assignee = assignee;
|
Assignee = assignee;
|
||||||
this.Project = project;
|
Project = project;
|
||||||
this.Summary = summary;
|
Summary = summary;
|
||||||
this.Description = description;
|
Description = description;
|
||||||
this.Environment = environment;
|
Environment = environment;
|
||||||
this.AttachmentNames = attachmentNames;
|
AttachmentNames = attachmentNames;
|
||||||
}
|
}
|
||||||
public string Key {
|
public string Key {
|
||||||
get;
|
get;
|
||||||
|
@ -100,17 +100,17 @@ namespace Jira {
|
||||||
public class JiraConnector : IDisposable {
|
public class JiraConnector : IDisposable {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraConnector));
|
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 const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.jira.rpc.exception.RemoteAuthenticationException";
|
||||||
private static JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
private static readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||||
public const string DEFAULT_POSTFIX = "/rpc/soap/jirasoapservice-v2?wsdl";
|
public const string DEFAULT_POSTFIX = "/rpc/soap/jirasoapservice-v2?wsdl";
|
||||||
private string credentials;
|
private string credentials;
|
||||||
private DateTime loggedInTime = DateTime.Now;
|
private DateTime loggedInTime = DateTime.Now;
|
||||||
private bool loggedIn;
|
private bool loggedIn;
|
||||||
private JiraSoapServiceService jira;
|
private JiraSoapServiceService jira;
|
||||||
private int timeout;
|
private readonly int timeout;
|
||||||
private string url;
|
private string url;
|
||||||
private Cache<string, JiraIssue> jiraCache = new Cache<string, JiraIssue>(60 * config.Timeout);
|
private readonly Cache<string, JiraIssue> jiraCache = new Cache<string, JiraIssue>(60 * config.Timeout);
|
||||||
private Cache<string, RemoteUser> userCache = new Cache<string, RemoteUser>(60 * config.Timeout);
|
private readonly Cache<string, RemoteUser> userCache = new Cache<string, RemoteUser>(60 * config.Timeout);
|
||||||
private bool suppressBackgroundForm = false;
|
private readonly bool suppressBackgroundForm = false;
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -134,8 +134,8 @@ namespace Jira {
|
||||||
}
|
}
|
||||||
|
|
||||||
public JiraConnector(bool suppressBackgroundForm) {
|
public JiraConnector(bool suppressBackgroundForm) {
|
||||||
this.url = config.Url;
|
url = config.Url;
|
||||||
this.timeout = config.Timeout;
|
timeout = config.Timeout;
|
||||||
this.suppressBackgroundForm = suppressBackgroundForm;
|
this.suppressBackgroundForm = suppressBackgroundForm;
|
||||||
createService();
|
createService();
|
||||||
}
|
}
|
||||||
|
@ -171,13 +171,13 @@ namespace Jira {
|
||||||
ThreadStart jiraLogin = delegate {
|
ThreadStart jiraLogin = delegate {
|
||||||
LOG.DebugFormat("Loggin in");
|
LOG.DebugFormat("Loggin in");
|
||||||
try {
|
try {
|
||||||
this.credentials = jira.login(user, password);
|
credentials = jira.login(user, password);
|
||||||
} catch (Exception) {
|
} catch (Exception) {
|
||||||
if (!url.EndsWith("wsdl")) {
|
if (!url.EndsWith("wsdl")) {
|
||||||
url = url + "/rpc/soap/jirasoapservice-v2?wsdl";
|
url = url + "/rpc/soap/jirasoapservice-v2?wsdl";
|
||||||
// recreate the service with the new url
|
// recreate the service with the new url
|
||||||
createService();
|
createService();
|
||||||
this.credentials = jira.login(user, password);
|
credentials = jira.login(user, password);
|
||||||
// Worked, store the url in the configuration
|
// Worked, store the url in the configuration
|
||||||
config.Url = url;
|
config.Url = url;
|
||||||
IniConfig.Save();
|
IniConfig.Save();
|
||||||
|
@ -187,8 +187,8 @@ namespace Jira {
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.DebugFormat("Logged in");
|
LOG.DebugFormat("Logged in");
|
||||||
this.loggedInTime = DateTime.Now;
|
loggedInTime = DateTime.Now;
|
||||||
this.loggedIn = true;
|
loggedIn = true;
|
||||||
|
|
||||||
};
|
};
|
||||||
// Here we do it
|
// Here we do it
|
||||||
|
@ -204,8 +204,8 @@ namespace Jira {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Not an authentication issue
|
// Not an authentication issue
|
||||||
this.loggedIn = false;
|
loggedIn = false;
|
||||||
this.credentials = null;
|
credentials = null;
|
||||||
e.Data.Add("user", user);
|
e.Data.Add("user", user);
|
||||||
e.Data.Add("url", url);
|
e.Data.Add("url", url);
|
||||||
throw;
|
throw;
|
||||||
|
|
|
@ -35,10 +35,10 @@ namespace GreenshotJiraPlugin {
|
||||||
/// Description of JiraDestination.
|
/// Description of JiraDestination.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class JiraDestination : AbstractDestination {
|
public class JiraDestination : AbstractDestination {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraDestination));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraDestination));
|
||||||
private static JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
private static readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||||
private JiraPlugin jiraPlugin = null;
|
private readonly JiraPlugin jiraPlugin = null;
|
||||||
private JiraIssue jira = null;
|
private readonly JiraIssue jira = null;
|
||||||
|
|
||||||
public JiraDestination(JiraPlugin jiraPlugin) {
|
public JiraDestination(JiraPlugin jiraPlugin) {
|
||||||
this.jiraPlugin = jiraPlugin;
|
this.jiraPlugin = jiraPlugin;
|
||||||
|
@ -100,7 +100,7 @@ namespace GreenshotJiraPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surfaceToUpload, ICaptureDetails captureDetails) {
|
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));
|
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
||||||
if (jira != null) {
|
if (jira != null) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace GreenshotJiraPlugin {
|
||||||
/// <param name="pluginAttribute">My own attributes</param>
|
/// <param name="pluginAttribute">My own attributes</param>
|
||||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||||
this.host = (IGreenshotHost)pluginHost;
|
host = (IGreenshotHost)pluginHost;
|
||||||
jiraPluginAttributes = myAttributes;
|
jiraPluginAttributes = myAttributes;
|
||||||
|
|
||||||
// Register configuration (don't need the configuration itself)
|
// Register configuration (don't need the configuration itself)
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace GreenshotJiraPlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class JiraUtils {
|
public class JiraUtils {
|
||||||
private static readonly Regex JIRA_KEY_REGEX = new Regex(@"/browse/([A-Z0-9]+\-[0-9]+)");
|
private static readonly Regex JIRA_KEY_REGEX = new Regex(@"/browse/([A-Z0-9]+\-[0-9]+)");
|
||||||
private static JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
private static readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||||
|
|
||||||
public static List<JiraIssue> GetCurrentJiras() {
|
public static List<JiraIssue> GetCurrentJiras() {
|
||||||
// Make sure we suppress the login
|
// Make sure we suppress the login
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -43,12 +43,12 @@ namespace Greenshot.Interop {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Type of the COM object, set on constructor after getting the COM reference
|
/// Type of the COM object, set on constructor after getting the COM reference
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Type _COMType;
|
private readonly Type _COMType;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The type of which method calls are intercepted and executed on the COM object.
|
/// The type of which method calls are intercepted and executed on the COM object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Type _InterceptType;
|
private readonly Type _InterceptType;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
[DllImport("ole32.dll")]
|
[DllImport("ole32.dll")]
|
||||||
|
@ -214,9 +214,9 @@ namespace Greenshot.Interop {
|
||||||
/// </param>
|
/// </param>
|
||||||
private COMWrapper(object comObject, Type type)
|
private COMWrapper(object comObject, Type type)
|
||||||
: base(type) {
|
: base(type) {
|
||||||
this._COMObject = comObject;
|
_COMObject = comObject;
|
||||||
this._COMType = comObject.GetType();
|
_COMType = comObject.GetType();
|
||||||
this._InterceptType = type;
|
_InterceptType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -228,14 +228,14 @@ namespace Greenshot.Interop {
|
||||||
/// sure that the COM object is still cleaned up.
|
/// sure that the COM object is still cleaned up.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
~COMWrapper() {
|
~COMWrapper() {
|
||||||
this.Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cleans up the COM object.
|
/// Cleans up the COM object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
this.Dispose(true);
|
Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,17 +247,17 @@ namespace Greenshot.Interop {
|
||||||
/// <see cref="IDisposable"/> interface.
|
/// <see cref="IDisposable"/> interface.
|
||||||
/// </param>
|
/// </param>
|
||||||
private void Dispose(bool disposing) {
|
private void Dispose(bool disposing) {
|
||||||
if (disposing && null != this._COMObject) {
|
if (disposing && null != _COMObject) {
|
||||||
if (Marshal.IsComObject(this._COMObject)) {
|
if (Marshal.IsComObject(_COMObject)) {
|
||||||
try {
|
try {
|
||||||
while (Marshal.ReleaseComObject(this._COMObject) > 0);
|
while (Marshal.ReleaseComObject(_COMObject) > 0);
|
||||||
} catch (Exception) {
|
} catch (Exception) {
|
||||||
//LOG.WarnFormat("Problem releasing {0}", _COMType);
|
//LOG.WarnFormat("Problem releasing {0}", _COMType);
|
||||||
//LOG.Warn("Error: ", ex);
|
//LOG.Warn("Error: ", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._COMObject = null;
|
_COMObject = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ namespace Greenshot.Interop {
|
||||||
/// The full name of the intercepted type.
|
/// The full name of the intercepted type.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return this._InterceptType.FullName;
|
return _InterceptType.FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -282,7 +282,7 @@ namespace Greenshot.Interop {
|
||||||
/// The hash code of the wrapped object.
|
/// The hash code of the wrapped object.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public override int GetHashCode() {
|
public override int GetHashCode() {
|
||||||
return this._COMObject.GetHashCode();
|
return _COMObject.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -298,7 +298,7 @@ namespace Greenshot.Interop {
|
||||||
if (null != value && RemotingServices.IsTransparentProxy(value)) {
|
if (null != value && RemotingServices.IsTransparentProxy(value)) {
|
||||||
COMWrapper wrapper = RemotingServices.GetRealProxy(value) as COMWrapper;
|
COMWrapper wrapper = RemotingServices.GetRealProxy(value) as COMWrapper;
|
||||||
if (null != wrapper) {
|
if (null != wrapper) {
|
||||||
return this._COMObject == wrapper._COMObject;
|
return _COMObject == wrapper._COMObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,15 +469,15 @@ namespace Greenshot.Interop {
|
||||||
ParameterInfo parameter;
|
ParameterInfo parameter;
|
||||||
|
|
||||||
if ("Dispose" == methodName && 0 == argCount && typeof(void) == returnType) {
|
if ("Dispose" == methodName && 0 == argCount && typeof(void) == returnType) {
|
||||||
this.Dispose();
|
Dispose();
|
||||||
} else if ("ToString" == methodName && 0 == argCount && typeof(string) == returnType) {
|
} else if ("ToString" == methodName && 0 == argCount && typeof(string) == returnType) {
|
||||||
returnValue = this.ToString();
|
returnValue = ToString();
|
||||||
} else if ("GetType" == methodName && 0 == argCount && typeof(System.Type) == returnType) {
|
} else if ("GetType" == methodName && 0 == argCount && typeof(Type) == returnType) {
|
||||||
returnValue = this._InterceptType;
|
returnValue = _InterceptType;
|
||||||
} else if ("GetHashCode" == methodName && 0 == argCount && typeof(int) == returnType) {
|
} else if ("GetHashCode" == methodName && 0 == argCount && typeof(int) == returnType) {
|
||||||
returnValue = this.GetHashCode();
|
returnValue = GetHashCode();
|
||||||
} else if ("Equals" == methodName && 1 == argCount && typeof(bool) == returnType) {
|
} 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_"))) {
|
} else if (1 == argCount && typeof(void) == returnType && (methodName.StartsWith("add_") || methodName.StartsWith("remove_"))) {
|
||||||
bool removeHandler = methodName.StartsWith("remove_");
|
bool removeHandler = methodName.StartsWith("remove_");
|
||||||
methodName = methodName.Substring(removeHandler ? 7 : 4);
|
methodName = methodName.Substring(removeHandler ? 7 : 4);
|
||||||
|
@ -487,8 +487,8 @@ namespace Greenshot.Interop {
|
||||||
return new ReturnMessage(new ArgumentNullException("handler"), callMessage);
|
return new ReturnMessage(new ArgumentNullException("handler"), callMessage);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
invokeObject = this._COMObject;
|
invokeObject = _COMObject;
|
||||||
invokeType = this._COMType;
|
invokeType = _COMType;
|
||||||
|
|
||||||
if (methodName.StartsWith("get_")) {
|
if (methodName.StartsWith("get_")) {
|
||||||
// Property Get
|
// Property Get
|
||||||
|
@ -565,7 +565,7 @@ namespace Greenshot.Interop {
|
||||||
if (returnType.IsInterface) {
|
if (returnType.IsInterface) {
|
||||||
// Wrap the returned value in an intercepting COM wrapper
|
// Wrap the returned value in an intercepting COM wrapper
|
||||||
if (Marshal.IsComObject(returnValue)) {
|
if (Marshal.IsComObject(returnValue)) {
|
||||||
returnValue = COMWrapper.Wrap(returnValue, returnType);
|
returnValue = Wrap(returnValue, returnType);
|
||||||
}
|
}
|
||||||
} else if (returnType.IsEnum) {
|
} else if (returnType.IsEnum) {
|
||||||
// Convert to proper Enum type
|
// Convert to proper Enum type
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Greenshot.Interop {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
[AttributeUsage(AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
||||||
public sealed class ComProgIdAttribute : Attribute {
|
public sealed class ComProgIdAttribute : Attribute {
|
||||||
private string _value;
|
private readonly string _value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extracts the attribute from the specified type.
|
/// Extracts the attribute from the specified type.
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace GreenshotOCR {
|
||||||
private static OCRConfiguration config = IniConfig.GetIniSection<OCRConfiguration>();
|
private static OCRConfiguration config = IniConfig.GetIniSection<OCRConfiguration>();
|
||||||
private const int MIN_WIDTH = 130;
|
private const int MIN_WIDTH = 130;
|
||||||
private const int MIN_HEIGHT = 130;
|
private const int MIN_HEIGHT = 130;
|
||||||
private OcrPlugin plugin;
|
private readonly OcrPlugin plugin;
|
||||||
|
|
||||||
public override string Designation {
|
public override string Designation {
|
||||||
get {
|
get {
|
||||||
|
@ -62,7 +62,7 @@ namespace GreenshotOCR {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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;
|
exportInformation.ExportMade = plugin.DoOCR(surface) != null;
|
||||||
return exportInformation;
|
return exportInformation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
@ -61,7 +60,7 @@ namespace GreenshotOCR {
|
||||||
/// OCR Plugin Greenshot
|
/// OCR Plugin Greenshot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OcrPlugin : IGreenshotPlugin {
|
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 const string CONFIG_FILENAME = "ocr-config.properties";
|
||||||
private string OCR_COMMAND;
|
private string OCR_COMMAND;
|
||||||
private static IGreenshotHost host;
|
private static IGreenshotHost host;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -19,15 +19,13 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
|
|
||||||
namespace GreenshotOCR {
|
namespace GreenshotOCR {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of SettingsForm.
|
/// Description of SettingsForm.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SettingsForm : OCRForm {
|
public partial class SettingsForm : OCRForm {
|
||||||
private OCRConfiguration config;
|
private readonly OCRConfiguration config;
|
||||||
|
|
||||||
public SettingsForm(string [] languages, OCRConfiguration config) {
|
public SettingsForm(string [] languages, OCRConfiguration config) {
|
||||||
//
|
//
|
||||||
|
|
|
@ -18,16 +18,13 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using Greenshot.Interop.Office;
|
using Greenshot.Interop.Office;
|
||||||
using Greenshot.IniFile;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace GreenshotOfficePlugin {
|
namespace GreenshotOfficePlugin {
|
||||||
|
@ -38,8 +35,8 @@ namespace GreenshotOfficePlugin {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelDestination));
|
||||||
private const int ICON_APPLICATION = 0;
|
private const int ICON_APPLICATION = 0;
|
||||||
private const int ICON_WORKBOOK = 1;
|
private const int ICON_WORKBOOK = 1;
|
||||||
private static string exePath = null;
|
private static readonly string exePath = null;
|
||||||
private string workbookName = null;
|
private readonly string workbookName = null;
|
||||||
|
|
||||||
static ExcelDestination() {
|
static ExcelDestination() {
|
||||||
exePath = PluginUtils.GetExePath("EXCEL.EXE");
|
exePath = PluginUtils.GetExePath("EXCEL.EXE");
|
||||||
|
@ -107,7 +104,7 @@ namespace GreenshotOfficePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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;
|
bool createdFile = false;
|
||||||
string imageFile = captureDetails.Filename;
|
string imageFile = captureDetails.Filename;
|
||||||
if (imageFile == null || surface.Modified || !Regex.IsMatch(imageFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
|
if (imageFile == null || surface.Modified || !Regex.IsMatch(imageFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
|
||||||
|
|
|
@ -29,11 +29,11 @@ using System.IO;
|
||||||
|
|
||||||
namespace GreenshotOfficePlugin {
|
namespace GreenshotOfficePlugin {
|
||||||
public class OneNoteDestination : AbstractDestination {
|
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;
|
private const int ICON_APPLICATION = 0;
|
||||||
public const string DESIGNATION = "OneNote";
|
public const string DESIGNATION = "OneNote";
|
||||||
private static string exePath = null;
|
private static readonly string exePath = null;
|
||||||
private OneNotePage page = null;
|
private readonly OneNotePage page = null;
|
||||||
|
|
||||||
static OneNoteDestination() {
|
static OneNoteDestination() {
|
||||||
exePath = PluginUtils.GetExePath("ONENOTE.EXE");
|
exePath = PluginUtils.GetExePath("ONENOTE.EXE");
|
||||||
|
@ -99,7 +99,7 @@ namespace GreenshotOfficePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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) {
|
if (page == null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -34,18 +34,18 @@ namespace GreenshotOfficePlugin {
|
||||||
/// Description of OutlookDestination.
|
/// Description of OutlookDestination.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OutlookDestination : AbstractDestination {
|
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_APPLICATION = 0;
|
||||||
private const int ICON_MEETING = 2;
|
private const int ICON_MEETING = 2;
|
||||||
|
|
||||||
private static Image mailIcon = GreenshotPlugin.Core.GreenshotResources.getImage("Email.Image");
|
private static readonly Image mailIcon = GreenshotResources.getImage("Email.Image");
|
||||||
private static OfficeConfiguration conf = IniConfig.GetIniSection<OfficeConfiguration>();
|
private static readonly OfficeConfiguration conf = IniConfig.GetIniSection<OfficeConfiguration>();
|
||||||
private static string exePath = null;
|
private static readonly string exePath = null;
|
||||||
private static bool isActiveFlag = false;
|
private static readonly bool isActiveFlag = false;
|
||||||
private static string mapiClient = "Microsoft Outlook";
|
private static readonly string mapiClient = "Microsoft Outlook";
|
||||||
public const string DESIGNATION = "Outlook";
|
public const string DESIGNATION = "Outlook";
|
||||||
private string outlookInspectorCaption;
|
private readonly string outlookInspectorCaption;
|
||||||
private OlObjectClass outlookInspectorType;
|
private readonly OlObjectClass outlookInspectorType;
|
||||||
|
|
||||||
static OutlookDestination() {
|
static OutlookDestination() {
|
||||||
if (EmailConfigHelper.HasOutlook()) {
|
if (EmailConfigHelper.HasOutlook()) {
|
||||||
|
@ -142,7 +142,7 @@ namespace GreenshotOfficePlugin {
|
||||||
/// <param name="captureDetails"></param>
|
/// <param name="captureDetails"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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
|
// Outlook logic
|
||||||
string tmpFile = captureDetails.Filename;
|
string tmpFile = captureDetails.Filename;
|
||||||
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
|
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
|
||||||
|
|
|
@ -18,16 +18,13 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using Greenshot.Interop.Office;
|
using Greenshot.Interop.Office;
|
||||||
using Greenshot.IniFile;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace GreenshotOfficePlugin {
|
namespace GreenshotOfficePlugin {
|
||||||
|
@ -39,8 +36,8 @@ namespace GreenshotOfficePlugin {
|
||||||
private const int ICON_APPLICATION = 0;
|
private const int ICON_APPLICATION = 0;
|
||||||
private const int ICON_PRESENTATION = 1;
|
private const int ICON_PRESENTATION = 1;
|
||||||
|
|
||||||
private static string exePath = null;
|
private static readonly string exePath = null;
|
||||||
private string presentationName = null;
|
private readonly string presentationName = null;
|
||||||
|
|
||||||
static PowerpointDestination() {
|
static PowerpointDestination() {
|
||||||
exePath = PluginUtils.GetExePath("POWERPNT.EXE");
|
exePath = PluginUtils.GetExePath("POWERPNT.EXE");
|
||||||
|
@ -109,7 +106,7 @@ namespace GreenshotOfficePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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;
|
string tmpFile = captureDetails.Filename;
|
||||||
Size imageSize = Size.Empty;
|
Size imageSize = Size.Empty;
|
||||||
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
|
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
|
||||||
|
|
|
@ -33,11 +33,11 @@ namespace GreenshotOfficePlugin {
|
||||||
/// Description of EmailDestination.
|
/// Description of EmailDestination.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WordDestination : AbstractDestination {
|
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_APPLICATION = 0;
|
||||||
private const int ICON_DOCUMENT = 1;
|
private const int ICON_DOCUMENT = 1;
|
||||||
private static string exePath = null;
|
private static readonly string exePath = null;
|
||||||
private string documentCaption = null;
|
private readonly string documentCaption = null;
|
||||||
|
|
||||||
static WordDestination() {
|
static WordDestination() {
|
||||||
exePath = PluginUtils.GetExePath("WINWORD.EXE");
|
exePath = PluginUtils.GetExePath("WINWORD.EXE");
|
||||||
|
@ -51,7 +51,7 @@ namespace GreenshotOfficePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public WordDestination(string wordCaption) {
|
public WordDestination(string wordCaption) {
|
||||||
this.documentCaption = wordCaption;
|
documentCaption = wordCaption;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Designation {
|
public override string Designation {
|
||||||
|
@ -104,7 +104,7 @@ namespace GreenshotOfficePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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;
|
string tmpFile = captureDetails.Filename;
|
||||||
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
|
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
|
||||||
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
|
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
|
||||||
|
|
|
@ -20,10 +20,7 @@
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
using Greenshot.Interop;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using GreenshotOfficePlugin;
|
using GreenshotOfficePlugin;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using System;
|
using System;
|
||||||
|
|
|
@ -24,13 +24,7 @@ using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
using Greenshot.Interop;
|
|
||||||
using Greenshot.Interop.IE;
|
using Greenshot.Interop.IE;
|
||||||
using System.Threading;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
using GreenshotOfficePlugin;
|
using GreenshotOfficePlugin;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,6 @@
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using Greenshot.Interop;
|
|
||||||
using GreenshotOfficePlugin;
|
using GreenshotOfficePlugin;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
|
||||||
|
@ -30,7 +27,7 @@ namespace Greenshot.Interop.Office {
|
||||||
public class WordExporter {
|
public class WordExporter {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordExporter));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordExporter));
|
||||||
private static Version wordVersion = null;
|
private static Version wordVersion = null;
|
||||||
private static OfficeConfiguration config = IniConfig.GetIniSection<OfficeConfiguration>();
|
private static readonly OfficeConfiguration config = IniConfig.GetIniSection<OfficeConfiguration>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the used version is higher than Office 2003
|
/// Check if the used version is higher than Office 2003
|
||||||
|
|
|
@ -601,11 +601,11 @@ namespace Greenshot.Interop.Office {
|
||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
public uint propTag;
|
public uint propTag;
|
||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public uint alignPad;
|
public readonly uint alignPad;
|
||||||
[FieldOffset(8)]
|
[FieldOffset(8)]
|
||||||
public IntPtr Value;
|
public IntPtr Value;
|
||||||
[FieldOffset(8)]
|
[FieldOffset(8)]
|
||||||
public long filler;
|
public readonly long filler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -770,7 +770,7 @@ namespace Greenshot.Interop.Office {
|
||||||
Marshal.FreeHGlobal(propValue.Value);
|
Marshal.FreeHGlobal(propValue.Value);
|
||||||
IMAPIProp mapiProp = (IMAPIProp)Marshal.GetTypedObjectForIUnknown(IUnknown, typeof(IMAPIProp));
|
IMAPIProp mapiProp = (IMAPIProp)Marshal.GetTypedObjectForIUnknown(IUnknown, typeof(IMAPIProp));
|
||||||
return mapiProp.SaveChanges(4) == 0;
|
return mapiProp.SaveChanges(4) == 0;
|
||||||
} catch (System.Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.Error(ex);
|
LOG.Error(ex);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
using GreenshotPlugin.Controls;
|
|
||||||
|
|
||||||
namespace GreenshotPhotobucketPlugin {
|
namespace GreenshotPhotobucketPlugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace GreenshotPhotobucketPlugin {
|
||||||
public class PhotobucketDestination : AbstractDestination {
|
public class PhotobucketDestination : AbstractDestination {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PhotobucketDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PhotobucketDestination));
|
||||||
private static PhotobucketConfiguration config = IniConfig.GetIniSection<PhotobucketConfiguration>();
|
private static PhotobucketConfiguration config = IniConfig.GetIniSection<PhotobucketConfiguration>();
|
||||||
private PhotobucketPlugin plugin = null;
|
private readonly PhotobucketPlugin plugin = null;
|
||||||
private string albumPath = null;
|
private readonly string albumPath = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a Photobucket destination, which also has the path to the album in it
|
/// Create a Photobucket destination, which also has the path to the album in it
|
||||||
|
@ -97,7 +97,7 @@ namespace GreenshotPhotobucketPlugin {
|
||||||
/// <param name="captureDetails"></param>
|
/// <param name="captureDetails"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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;
|
string uploadURL = null;
|
||||||
bool uploaded = plugin.Upload(captureDetails, surface, albumPath, out uploadURL);
|
bool uploaded = plugin.Upload(captureDetails, surface, albumPath, out uploadURL);
|
||||||
if (uploaded) {
|
if (uploaded) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace GreenshotPhotobucketPlugin {
|
||||||
/// <param name="pluginAttribute">My own attributes</param>
|
/// <param name="pluginAttribute">My own attributes</param>
|
||||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||||
this.host = (IGreenshotHost)pluginHost;
|
host = (IGreenshotHost)pluginHost;
|
||||||
Attributes = myAttributes;
|
Attributes = myAttributes;
|
||||||
|
|
||||||
// Get configuration
|
// Get configuration
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|
|
@ -17,13 +17,6 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
using Greenshot.Plugin;
|
|
||||||
using GreenshotPlugin.Controls;
|
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
|
|
||||||
namespace GreenshotPicasaPlugin {
|
namespace GreenshotPicasaPlugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace GreenshotPicasaPlugin {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PicasaDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PicasaDestination));
|
||||||
private static PicasaConfiguration config = IniConfig.GetIniSection<PicasaConfiguration>();
|
private static PicasaConfiguration config = IniConfig.GetIniSection<PicasaConfiguration>();
|
||||||
|
|
||||||
private PicasaPlugin plugin = null;
|
private readonly PicasaPlugin plugin = null;
|
||||||
public PicasaDestination(PicasaPlugin plugin) {
|
public PicasaDestination(PicasaPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ namespace GreenshotPicasaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
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;
|
string uploadURL = null;
|
||||||
bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
|
bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
|
||||||
if (uploaded) {
|
if (uploaded) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace GreenshotPicasaPlugin {
|
||||||
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
||||||
/// <param name="pluginAttribute">My own attributes</param>
|
/// <param name="pluginAttribute">My own attributes</param>
|
||||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||||
this.host = (IGreenshotHost)pluginHost;
|
host = (IGreenshotHost)pluginHost;
|
||||||
Attributes = myAttributes;
|
Attributes = myAttributes;
|
||||||
|
|
||||||
// Get configuration
|
// Get configuration
|
||||||
|
@ -84,7 +84,7 @@ namespace GreenshotPicasaPlugin {
|
||||||
itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
|
itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
|
||||||
itemPlugInRoot.Tag = host;
|
itemPlugInRoot.Tag = host;
|
||||||
itemPlugInRoot.Image = (Image)resources.GetObject("Picasa");
|
itemPlugInRoot.Image = (Image)resources.GetObject("Picasa");
|
||||||
itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick);
|
itemPlugInRoot.Click += new EventHandler(ConfigMenuClick);
|
||||||
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
|
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
|
||||||
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
|
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
|
||||||
return true;
|
return true;
|
||||||
|
@ -127,7 +127,7 @@ namespace GreenshotPicasaPlugin {
|
||||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality);
|
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality);
|
||||||
try {
|
try {
|
||||||
string url = null;
|
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() {
|
delegate() {
|
||||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||||
string contentType = "image/" + config.UploadFormat.ToString();
|
string contentType = "image/" + config.UploadFormat.ToString();
|
||||||
|
|
|
@ -22,7 +22,6 @@ using Greenshot.IniFile;
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
namespace GreenshotPicasaPlugin {
|
namespace GreenshotPicasaPlugin {
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -441,7 +441,7 @@ namespace GreenshotPlugin.Controls {
|
||||||
if (hotkey.LastIndexOf('+') > 0) {
|
if (hotkey.LastIndexOf('+') > 0) {
|
||||||
hotkey = hotkey.Remove(0,hotkey.LastIndexOf('+')+1).Trim();
|
hotkey = hotkey.Remove(0,hotkey.LastIndexOf('+')+1).Trim();
|
||||||
}
|
}
|
||||||
key = (Keys)Keys.Parse(typeof(Keys), hotkey);
|
key = (Keys)Enum.Parse(typeof(Keys), hotkey);
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,9 +74,12 @@ namespace GreenshotPlugin.Core {
|
||||||
get {
|
get {
|
||||||
List<TV> elements = new List<TV>();
|
List<TV> elements = new List<TV>();
|
||||||
|
|
||||||
|
lock (lockObject)
|
||||||
|
{
|
||||||
foreach (TV element in internalCache.Values) {
|
foreach (TV element in internalCache.Values) {
|
||||||
elements.Add(element);
|
elements.Add(element);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
foreach (TV element in elements) {
|
foreach (TV element in elements) {
|
||||||
yield return element;
|
yield return element;
|
||||||
}
|
}
|
||||||
|
@ -105,9 +108,13 @@ namespace GreenshotPlugin.Core {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
/// <returns>true if the cache contains the key</returns>
|
/// <returns>true if the cache contains the key</returns>
|
||||||
public bool Contains(TK key) {
|
public bool Contains(TK key)
|
||||||
|
{
|
||||||
|
lock (lockObject)
|
||||||
|
{
|
||||||
return internalCache.ContainsKey(key);
|
return internalCache.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a value to the cache
|
/// Add a value to the cache
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace GreenshotPlugin.Core {
|
||||||
private long lastCheck;
|
private long lastCheck;
|
||||||
private readonly long waitTime;
|
private readonly long waitTime;
|
||||||
public EventDelay(long ticks) {
|
public EventDelay(long ticks) {
|
||||||
this.waitTime = ticks;
|
waitTime = ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Check() {
|
public bool Check() {
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace GreenshotPlugin.Core {
|
||||||
// The parameter format is a single alpha followed by the value belonging to the parameter, e.g. :
|
// 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"}
|
// ${capturetime:d"yyyy-MM-dd HH_mm_ss"}
|
||||||
private static readonly Regex VAR_REGEXP = new Regex(@"\${(?<variable>[^:}]+)[:]?(?<parameters>[^}]*)}", RegexOptions.Compiled);
|
private static readonly Regex VAR_REGEXP = new Regex(@"\${(?<variable>[^:}]+)[:]?(?<parameters>[^}]*)}", RegexOptions.Compiled);
|
||||||
|
private static readonly Regex CMD_VAR_REGEXP = new Regex(@"%(?<variable>[^%]+)%", RegexOptions.Compiled);
|
||||||
|
|
||||||
private static readonly Regex SPLIT_REGEXP = new Regex(";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", RegexOptions.Compiled);
|
private static readonly Regex SPLIT_REGEXP = new Regex(";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", RegexOptions.Compiled);
|
||||||
private const int MAX_TITLE_LENGTH = 80;
|
private const int MAX_TITLE_LENGTH = 80;
|
||||||
|
@ -74,7 +75,7 @@ namespace GreenshotPlugin.Core {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove invalid characters from the path
|
/// Remove invalid characters from the path
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fullpath">string with the full path to a file</param>
|
/// <param name="path">string with the full path to a file</param>
|
||||||
/// <returns>string with the full path to a file, without invalid characters</returns>
|
/// <returns>string with the full path to a file, without invalid characters</returns>
|
||||||
public static string MakePathSafe(string path) {
|
public static string MakePathSafe(string path) {
|
||||||
// Make the path save!
|
// Make the path save!
|
||||||
|
@ -389,6 +390,51 @@ namespace GreenshotPlugin.Core {
|
||||||
return replaceValue;
|
return replaceValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Simply" fill the pattern with environment variables
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pattern">String with pattern %var%</param>
|
||||||
|
/// <param name="filenameSafeMode">true to make sure everything is filenamesafe</param>
|
||||||
|
/// <returns>Filled string</returns>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "Simply" fill the pattern with environment variables
|
/// "Simply" fill the pattern with environment variables
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace GreenshotPlugin.Core {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SpecialFolderPatternConverter : PatternConverter {
|
public class SpecialFolderPatternConverter : PatternConverter {
|
||||||
override protected void Convert(TextWriter writer, object state) {
|
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));
|
writer.Write(Environment.GetFolderPath(specialFolder));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1032,7 +1032,7 @@ Greenshot received information from CloudServiceName. You can close this browser
|
||||||
// Get response object.
|
// Get response object.
|
||||||
using (HttpListenerResponse response = context.Response) {
|
using (HttpListenerResponse response = context.Response) {
|
||||||
// Write a "close" 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.
|
// Write to response stream.
|
||||||
response.ContentLength64 = buffer.Length;
|
response.ContentLength64 = buffer.Length;
|
||||||
using (var stream = response.OutputStream) {
|
using (var stream = response.OutputStream) {
|
||||||
|
|
|
@ -110,6 +110,8 @@ namespace GreenshotPlugin.Core {
|
||||||
public static Image GetCachedExeIcon(string path, int index) {
|
public static Image GetCachedExeIcon(string path, int index) {
|
||||||
string cacheKey = string.Format("{0}:{1}", path, index);
|
string cacheKey = string.Format("{0}:{1}", path, index);
|
||||||
Image returnValue;
|
Image returnValue;
|
||||||
|
lock (exeIconCache)
|
||||||
|
{
|
||||||
if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
|
if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
|
||||||
lock (exeIconCache) {
|
lock (exeIconCache) {
|
||||||
if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
|
if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
|
||||||
|
@ -120,6 +122,7 @@ namespace GreenshotPlugin.Core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,10 @@ namespace GreenshotPlugin.Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceforgeFile(string file, string pubdate, string link, string directLink) {
|
public SourceforgeFile(string file, string pubdate, string link, string directLink) {
|
||||||
this._file = file;
|
_file = file;
|
||||||
DateTime.TryParse(pubdate, out _pubdate);
|
DateTime.TryParse(pubdate, out _pubdate);
|
||||||
this._link = link;
|
_link = link;
|
||||||
this._directLink = directLink;
|
_directLink = directLink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue