Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Samples » Downloads
 
Add your own
alternative version

Building Applications with the SharpDevelop Core

, 3 Jan 2006
Use XML definitions for your applications to make them extensible.
icsharpcodecoredemo.zip
RichTextEditor
RichTextEditor.addin
Startup
AddIns
Base.addin
data
options
resources
StringResources.de.resources
ImageResources.resources
Startup.exe.manifest
StringResources.resources
AddInManager
AddInManager.addin
Src
StringResources.de.resources
StringResources.resources
WizardBackground.png
Base
doc
ICSharpCode.Core
Configuration
Resources
ICSharpCode.Core.doc
ICSharpCode.Core.snk
Src
AddInTree
AddIn
DefaultConditionEvaluators
DefaultDoozers
Icon
MenuItem
Gui
ToolBarItem
Gui
Services
FileUtility
LoggingService
MenuService
MessageService
PropertyService
ResourceService
StringParser
ToolBarService
Util
RequiredLibraries
ICSharpCode.SharpZipLib.dll
log4net.dll
// <file>
//     <copyright see="prj:///doc/copyright.txt"/>
//     <license see="prj:///doc/license.txt"/>
//     <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
//     <version>$Revision: 32 $</version>
// </file>

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Core;

namespace ICSharpCode.AddInManager
{
	public class ShowCommand : AbstractMenuCommand
	{
		#if STANDALONE
		static bool resourcesRegistered;
		#endif
		
		public override void Run()
		{
			#if STANDALONE
			if (!resourcesRegistered) {
				resourcesRegistered = true;
				ResourceService.RegisterStrings("ICSharpCode.AddInManager.StringResources", typeof(ShowCommand).Assembly);
			}
			#endif
			ManagerForm.ShowForm();
		}
	}
	
	public class AddInManagerAddInStateConditionEvaluator : IConditionEvaluator
	{
		public bool IsValid(object caller, Condition condition)
		{
			string states = condition.Properties["states"];
			string action = ((AddInControl)caller).AddIn.Action.ToString();
			foreach (string state in states.Split(',')) {
				if (state == action)
					return true;
			}
			return false;
		}
	}
	
	public class DisableCommand : AbstractMenuCommand
	{
		public override void Run()
		{
			ManagerForm.Instance.TryRunAction(((AddInControl)Owner).AddIn, AddInAction.Disable);
		}
	}
	
	public class EnableCommand : AbstractMenuCommand
	{
		public override void Run()
		{
			ManagerForm.Instance.TryRunAction(((AddInControl)Owner).AddIn, AddInAction.Enable);
		}
	}
	
	public class AbortInstallCommand : AbstractMenuCommand
	{
		public override void Run()
		{
			ManagerForm.Instance.TryRunAction(((AddInControl)Owner).AddIn, AddInAction.Uninstall);
		}
	}
	
	public class AbortUpdateCommand : AbstractMenuCommand
	{
		public override void Run()
		{
			ManagerForm.Instance.TryRunAction(((AddInControl)Owner).AddIn, AddInAction.InstalledTwice);
		}
	}
	
	public class UninstallCommand : AbstractMenuCommand
	{
		public override void Run()
		{
			ManagerForm.Instance.TryUninstall(((AddInControl)Owner).AddIn);
		}
	}
	
	public class OpenHomepageCommand : AbstractMenuCommand
	{
		public override bool IsEnabled {
			get {
				return ((AddInControl)Owner).AddIn.Properties["url"].Length > 0;
			}
		}
		
		public override void Run()
		{
			#if STANDALONE
			try {
				System.Diagnostics.Process.Start(((AddInControl)Owner).AddIn.Properties["url"]);
			} catch {}
			#else
			FileService.OpenFile(((AddInControl)Owner).AddIn.Properties["url"]);
			#endif
			ManagerForm.Instance.Close();
		}
	}
	
	public class AboutCommand : AbstractMenuCommand
	{
		public override void Run()
		{
			using (AboutForm form = new AboutForm(((AddInControl)Owner).AddIn)) {
				form.ShowDialog(ManagerForm.Instance);
			}
		}
	}
	
	public class OptionsCommand : AbstractMenuCommand
	{
		public override bool IsEnabled {
			get {
				#if !STANDALONE
				AddIn addIn = ((AddInControl)Owner).AddIn;
				if (addIn.Enabled) {
					foreach (KeyValuePair<string, ExtensionPath> pair in addIn.Paths) {
						if (pair.Key.StartsWith("/SharpDevelop/Dialogs/OptionsDialog")) {
							return true;
						}
					}
				}
				#endif
				return false;
			}
		}
		
		public override void Run()
		{
			#if !STANDALONE
			AddIn addIn = ((AddInControl)Owner).AddIn;
			AddInTreeNode dummyNode = new AddInTreeNode();
			foreach (KeyValuePair<string, ExtensionPath> pair in addIn.Paths) {
				if (pair.Key.StartsWith("/SharpDevelop/Dialogs/OptionsDialog")) {
					dummyNode.Codons.AddRange(pair.Value.Codons);
				}
			}
			ICSharpCode.SharpDevelop.Commands.OptionsCommand.ShowTabbedOptions(addIn.Name + " " + ResourceService.GetString("AddInManager.Options"),
			                                                                   dummyNode);
			#endif
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

Share

About the Author

Daniel Grunwald

Germany Germany
I am the lead developer on the SharpDevelop open source project.
Follow on   Twitter   Google+   LinkedIn

| Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 3 Jan 2006
Article Copyright 2006 by Daniel Grunwald
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid