Refactored the Office Destinations, including the Interop & configuration, to the new Office plug-in. Also refactored some code to be more consistent.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2131 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-10-10 14:18:05 +00:00
commit 4d399a60ac
34 changed files with 739 additions and 365 deletions

View file

@ -163,8 +163,8 @@ namespace Greenshot.Helpers {
// This fixes a problem when a balloon is still visible and a capture needs to be taken
// forcefully removes the balloon!
if (!conf.HideTrayicon) {
MainForm.instance.notifyIcon.Visible = false;
MainForm.instance.notifyIcon.Visible = true;
MainForm.Instance.NotifyIcon.Visible = false;
MainForm.Instance.NotifyIcon.Visible = true;
}
LOG.Debug(String.Format("Capturing with mode {0} and using Cursor {1}", captureMode, captureMouseCursor));
capture.CaptureDetails.CaptureMode = captureMode;
@ -191,7 +191,7 @@ namespace Greenshot.Helpers {
// Workaround for proble with DPI retrieval, the FromHwnd activates the window...
WindowDetails previouslyActiveWindow = WindowDetails.GetActiveWindow();
// Workaround for changed DPI settings in Windows 7
using (Graphics graphics = Graphics.FromHwnd(MainForm.instance.Handle)) {
using (Graphics graphics = Graphics.FromHwnd(MainForm.Instance.Handle)) {
capture.CaptureDetails.DpiX = graphics.DpiX;
capture.CaptureDetails.DpiY = graphics.DpiY;
}
@ -524,10 +524,10 @@ namespace Greenshot.Helpers {
}
switch (eventArgs.MessageType) {
case SurfaceMessageTyp.Error:
MainForm.instance.notifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Error);
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Error);
break;
case SurfaceMessageTyp.Info:
MainForm.instance.notifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Info);
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Info);
break;
case SurfaceMessageTyp.FileSaved:
case SurfaceMessageTyp.UploadedUri:
@ -535,8 +535,8 @@ namespace Greenshot.Helpers {
EventHandler balloonTipClosedHandler = null;
balloonTipClosedHandler = delegate(object sender, EventArgs e) {
LOG.DebugFormat("Deregistering the BalloonTipClosed");
MainForm.instance.notifyIcon.BalloonTipClicked -= balloonTipClickedHandler;
MainForm.instance.notifyIcon.BalloonTipClosed -= balloonTipClosedHandler;
MainForm.Instance.NotifyIcon.BalloonTipClicked -= balloonTipClickedHandler;
MainForm.Instance.NotifyIcon.BalloonTipClosed -= balloonTipClosedHandler;
};
balloonTipClickedHandler = delegate(object sender, EventArgs e) {
@ -555,12 +555,12 @@ namespace Greenshot.Helpers {
}
}
LOG.DebugFormat("Deregistering the BalloonTipClicked");
MainForm.instance.notifyIcon.BalloonTipClicked -= balloonTipClickedHandler;
MainForm.instance.notifyIcon.BalloonTipClosed -= balloonTipClosedHandler;
MainForm.Instance.NotifyIcon.BalloonTipClicked -= balloonTipClickedHandler;
MainForm.Instance.NotifyIcon.BalloonTipClosed -= balloonTipClosedHandler;
};
MainForm.instance.notifyIcon.BalloonTipClicked += balloonTipClickedHandler;
MainForm.instance.notifyIcon.BalloonTipClosed += balloonTipClosedHandler;
MainForm.instance.notifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Info);
MainForm.Instance.NotifyIcon.BalloonTipClicked += balloonTipClickedHandler;
MainForm.Instance.NotifyIcon.BalloonTipClosed += balloonTipClosedHandler;
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Info);
break;
}
};

View file

@ -74,8 +74,8 @@ namespace Greenshot.Helpers {
/// <returns>List<IDestination></returns>
private static List<IDestination> GetPluginDestinations() {
List<IDestination> destinations = new List<IDestination>();
foreach (PluginAttribute pluginAttribute in PluginHelper.instance.Plugins.Keys) {
IGreenshotPlugin plugin = PluginHelper.instance.Plugins[pluginAttribute];
foreach (PluginAttribute pluginAttribute in PluginHelper.Instance.Plugins.Keys) {
IGreenshotPlugin plugin = PluginHelper.Instance.Plugins[pluginAttribute];
try {
var dests = plugin.Destinations();
if (dests != null) {

View file

@ -28,7 +28,6 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using Greenshot.Interop.Office;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using Greenshot.IniFile;

View file

@ -39,14 +39,26 @@ namespace Greenshot.Helpers {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PluginHelper));
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
public static string pluginPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),Application.ProductName);
public static string applicationPath = Path.GetDirectoryName(Application.ExecutablePath);
public static string pafPath = Path.Combine(Application.StartupPath, @"App\Greenshot");
public static readonly PluginHelper instance = new PluginHelper();
private static string pluginPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),Application.ProductName);
private static string applicationPath = Path.GetDirectoryName(Application.ExecutablePath);
private static string pafPath = Path.Combine(Application.StartupPath, @"App\Greenshot");
private static IDictionary<PluginAttribute, IGreenshotPlugin> plugins = new SortedDictionary<PluginAttribute, IGreenshotPlugin>();
private static readonly PluginHelper instance = new PluginHelper();
public static PluginHelper Instance {
get {
return instance;
}
}
private PluginHelper() {
PluginUtils.Host = this;
}
public NotifyIcon NotifyIcon {
get {
return MainForm.Instance.NotifyIcon;
}
}
public bool HasPlugins() {
@ -145,7 +157,7 @@ namespace Greenshot.Helpers {
/// </summary>
/// <param name="imageToImport">Image to handle</param>
public void ImportCapture(ICapture captureToImport) {
MainForm.instance.BeginInvoke((MethodInvoker)delegate {
MainForm.Instance.BeginInvoke((MethodInvoker)delegate {
CaptureHelper.ImportCapture(captureToImport);
});
}

View file

@ -73,8 +73,8 @@ namespace Greenshot.Helpers {
private static List<IProcessor> GetPluginsProcessors() {
List<IProcessor> processors = new List<IProcessor>();
foreach (PluginAttribute pluginAttribute in PluginHelper.instance.Plugins.Keys) {
IGreenshotPlugin plugin = PluginHelper.instance.Plugins[pluginAttribute];
foreach (PluginAttribute pluginAttribute in PluginHelper.Instance.Plugins.Keys) {
IGreenshotPlugin plugin = PluginHelper.Instance.Plugins[pluginAttribute];
try {
var procs = plugin.Processors();
if (procs != null) {

View file

@ -78,9 +78,9 @@ namespace Greenshot.Experimental {
try {
UpdateHelper.ProcessRSSInfo(currentVersion);
if (latestGreenshot != null) {
MainForm.instance.notifyIcon.BalloonTipClicked += HandleBalloonTipClick;
MainForm.instance.notifyIcon.BalloonTipClosed += CleanupBalloonTipClick;
MainForm.instance.notifyIcon.ShowBalloonTip(10000, "Greenshot", Language.GetFormattedString(LangKey.update_found, latestGreenshot.Version), ToolTipIcon.Info);
MainForm.Instance.NotifyIcon.BalloonTipClicked += HandleBalloonTipClick;
MainForm.Instance.NotifyIcon.BalloonTipClosed += CleanupBalloonTipClick;
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", Language.GetFormattedString(LangKey.update_found, latestGreenshot.Version), ToolTipIcon.Info);
}
conf.LastUpdateCheck = DateTime.Now;
IniConfig.Save();
@ -91,8 +91,8 @@ namespace Greenshot.Experimental {
}
private static void CleanupBalloonTipClick(object sender, EventArgs e) {
MainForm.instance.notifyIcon.BalloonTipClicked -= HandleBalloonTipClick;
MainForm.instance.notifyIcon.BalloonTipClosed -= CleanupBalloonTipClick;
MainForm.Instance.NotifyIcon.BalloonTipClicked -= HandleBalloonTipClick;
MainForm.Instance.NotifyIcon.BalloonTipClosed -= CleanupBalloonTipClick;
}
private static void HandleBalloonTipClick(object sender, EventArgs e) {
@ -106,8 +106,8 @@ namespace Greenshot.Experimental {
} catch (Exception) {
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, latestGreenshot.Link), Language.GetString(LangKey.error));
} finally {
MainForm.instance.notifyIcon.BalloonTipClicked -= HandleBalloonTipClick;
MainForm.instance.notifyIcon.BalloonTipClosed -= CleanupBalloonTipClick;
MainForm.Instance.NotifyIcon.BalloonTipClicked -= HandleBalloonTipClick;
MainForm.Instance.NotifyIcon.BalloonTipClosed -= CleanupBalloonTipClick;
}
}