|
using System;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Drawing;
using Reflector;
namespace AutoDiagramer
{
#region AutoDiagrammerPackage CLASS
/// <summary>
/// This class provides one part to be able to be a Lutz Roeders Reflector
/// AddIn. The other file is called AutoDiagrammerWindow. This part provides
/// the Load/Unload and menu click code
/// </summary>
public class AutoDiagrammerPackage : IPackage
{
#region Instance Fields
private IWindowManager _windowManager;
private ICommandBarManager _commandBarManager;
private ICommandBarSeparator _separator;
private ICommandBarButton _toolsButton;
#endregion
#region Reflector Package Methods
/// <summary>
/// Standard IPackage load method. Creates <see cref="AutoDiagrammerWindow">AutoDiagrammerWindow</see>
/// and UI elements for addin
/// </summary>
/// <param name="serviceProvider">IServiceProvider serviceProvider for addin</param>
public void Load(IServiceProvider serviceProvider)
{
//create a new Window, giving it the serviceProvider
AutoDiagrammerWindow window = new AutoDiagrammerWindow(serviceProvider);
//hook the addin into Reflector UI
this._windowManager = (IWindowManager) serviceProvider.GetService(typeof(IWindowManager));
this._windowManager.Windows.Add("AutoDiagrammer", window, "Auto Diagrammer");
this._commandBarManager = (ICommandBarManager) serviceProvider.GetService(typeof(ICommandBarManager));
this._separator = this._commandBarManager.CommandBars["Tools"].Items.AddSeparator();
this._toolsButton = this._commandBarManager.CommandBars["Tools"].Items.AddButton("Auto Diagrammer", new EventHandler(this.Tools_Click));
}
/// <summary>
/// Unhook the addin from Reflector UI
/// </summary>
public void Unload()
{
//unhook the addin from Reflector UI
this._windowManager.Windows.Remove("AutoDiagrammer");
this._commandBarManager.CommandBars["Tools"].Items.Remove(this._toolsButton);
this._commandBarManager.CommandBars["Tools"].Items.Remove(this._separator);
}
/// <summary>
/// Reflector addin menu clicked, user wants to see addin, so show it
/// </summary>
/// <param name="sender">reflector addin menu</param>
/// <param name="e">event args</param>
private void Tools_Click(object sender, EventArgs e)
{
//user wants to see addin, so show it
this._windowManager.Windows["AutoDiagrammer"].Visible = true;
}
#endregion
}
#endregion
}
|
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.
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
Both of these at Sussex University UK.
Award(s)
I am lucky enough to have won a few awards for Zany Crazy code articles over the years
- Microsoft C# MVP 2016
- Codeproject MVP 2016
- Microsoft C# MVP 2015
- Codeproject MVP 2015
- Microsoft C# MVP 2014
- Codeproject MVP 2014
- Microsoft C# MVP 2013
- Codeproject MVP 2013
- Microsoft C# MVP 2012
- Codeproject MVP 2012
- Microsoft C# MVP 2011
- Codeproject MVP 2011
- Microsoft C# MVP 2010
- Codeproject MVP 2010
- Microsoft C# MVP 2009
- Codeproject MVP 2009
- Microsoft C# MVP 2008
- Codeproject MVP 2008
- And numerous codeproject awards which you can see over at my blog