mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Moving back to trunk!
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1602 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
ad265b2c54
commit
8d458998a1
332 changed files with 17647 additions and 9466 deletions
|
@ -19,17 +19,37 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
|
||||
namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Description of PluginUtils.
|
||||
/// </summary>
|
||||
public class PluginUtils {
|
||||
private PluginUtils() {
|
||||
}
|
||||
public static class PluginUtils {
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to add a MenuItem to the File MenuItem of an ImageEditor
|
||||
/// </summary>
|
||||
/// <param name="image">Image to display in the menu</param>
|
||||
/// <param name="text">Text to display in the menu</param>
|
||||
/// <param name="tag">The TAG value</param>
|
||||
/// <param name="shortcutKeys">Keys which can be used as shortcut</param>
|
||||
/// <param name="handler">The onclick handler</param>
|
||||
public static void AddToFileMenu(IImageEditor imageEditor, Image image, string text, object tag, Keys? shortcutKeys, System.EventHandler handler) {
|
||||
System.Windows.Forms.ToolStripMenuItem item = new System.Windows.Forms.ToolStripMenuItem();
|
||||
item.Image = image;
|
||||
item.Text = text;
|
||||
item.Tag = tag;
|
||||
if (shortcutKeys.HasValue) {
|
||||
item.ShortcutKeys = shortcutKeys.Value;
|
||||
}
|
||||
item.Click += handler;
|
||||
AddToFileMenu(imageEditor, item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to add a MenuItem to the File MenuItem of an ImageEditor
|
||||
/// </summary>
|
||||
|
@ -69,5 +89,28 @@ namespace GreenshotPlugin.Core {
|
|||
toolStripMenuItem.DropDownItems.Add(item);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Helper method to add a MenuItem to the Greenshot context menu
|
||||
/// </summary>
|
||||
/// <param name="imageEditor"></param>
|
||||
/// <param name="item"></param>
|
||||
public static void AddToContextMenu(IGreenshotHost host, ToolStripMenuItem item) {
|
||||
// Here we can hang ourselves to the main context menu!
|
||||
ContextMenuStrip contextMenu = host.MainMenu;
|
||||
bool addedItem = false;
|
||||
|
||||
// Try to find a separator, so we insert ourselves after it
|
||||
for(int i=0; i < contextMenu.Items.Count; i++) {
|
||||
if (contextMenu.Items[i].GetType() == typeof(ToolStripSeparator)) {
|
||||
contextMenu.Items.Insert(i+1, item);
|
||||
addedItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If we didn't insert the item, we just add it...
|
||||
if (!addedItem) {
|
||||
contextMenu.Items.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue