mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Added some fixes for the IDestination code, allowing a Destination to supply dynamics without base. Also made the savetmpfile able to store in a supplied path.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2037 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
c037b99d6e
commit
203a34ee6f
7 changed files with 52 additions and 24 deletions
|
@ -35,7 +35,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// <summary>
|
||||
/// Description of AbstractDestination.
|
||||
/// </summary>
|
||||
public abstract class AbstractDestination : IDestination {
|
||||
public abstract class AbstractDestination : IDestination {
|
||||
private const string PATH_KEY = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AbstractDestination));
|
||||
private static CoreConfiguration configuration = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
|
@ -124,26 +124,37 @@ namespace GreenshotPlugin.Core {
|
|||
basisMenuItem.DropDownOpening += delegate (object source, EventArgs eventArgs) {
|
||||
if (basisMenuItem.DropDownItems.Count == 0) {
|
||||
List<IDestination> subDestinations = new List<IDestination>();
|
||||
// Fixing Bug #3536968 by catching the COMException (every exception) and not displaying the "subDestinations"
|
||||
try {
|
||||
subDestinations.AddRange(DynamicDestinations());
|
||||
} catch(Exception ex) {
|
||||
LOG.ErrorFormat("Skipping {0}, due to the following error: {1}", Description, ex.Message);
|
||||
}
|
||||
// Fixing Bug #3536968 by catching the COMException (every exception) and not displaying the "subDestinations"
|
||||
try {
|
||||
subDestinations.AddRange(DynamicDestinations());
|
||||
} catch(Exception ex) {
|
||||
LOG.ErrorFormat("Skipping {0}, due to the following error: {1}", Description, ex.Message);
|
||||
}
|
||||
if (subDestinations.Count > 0) {
|
||||
subDestinations.Sort();
|
||||
ToolStripMenuItem destinationMenuItem = new ToolStripMenuItem(Description);
|
||||
destinationMenuItem.Tag = this;
|
||||
destinationMenuItem.Image = DisplayIcon;
|
||||
destinationMenuItem.Click += destinationClickHandler;
|
||||
basisMenuItem.DropDownItems.Add(destinationMenuItem);
|
||||
foreach(IDestination subDestination in subDestinations) {
|
||||
destinationMenuItem = new ToolStripMenuItem(subDestination.Description);
|
||||
destinationMenuItem.Tag = subDestination;
|
||||
destinationMenuItem.Image = subDestination.DisplayIcon;
|
||||
|
||||
ToolStripMenuItem destinationMenuItem = null;
|
||||
if (!useDynamicsOnly) {
|
||||
destinationMenuItem = new ToolStripMenuItem(Description);
|
||||
destinationMenuItem.Tag = this;
|
||||
destinationMenuItem.Image = DisplayIcon;
|
||||
destinationMenuItem.Click += destinationClickHandler;
|
||||
basisMenuItem.DropDownItems.Add(destinationMenuItem);
|
||||
}
|
||||
if (useDynamicsOnly && subDestinations.Count == 1) {
|
||||
basisMenuItem.Tag = subDestinations[0];
|
||||
basisMenuItem.Text = subDestinations[0].Description;
|
||||
basisMenuItem.Click -= destinationClickHandler;
|
||||
basisMenuItem.Click += destinationClickHandler;
|
||||
} else {
|
||||
foreach (IDestination subDestination in subDestinations) {
|
||||
destinationMenuItem = new ToolStripMenuItem(subDestination.Description);
|
||||
destinationMenuItem.Tag = subDestination;
|
||||
destinationMenuItem.Image = subDestination.DisplayIcon;
|
||||
destinationMenuItem.Click += destinationClickHandler;
|
||||
basisMenuItem.DropDownItems.Add(destinationMenuItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Setting base "click" only if there are no sub-destinations
|
||||
|
||||
|
@ -173,6 +184,12 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
public virtual bool useDynamicsOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool isLinkable {
|
||||
get {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue