本文整理汇总了C#中ext_ConnectMode类的典型用法代码示例。如果您正苦于以下问题:C# ext_ConnectMode类的具体用法?C# ext_ConnectMode怎么用?C# ext_ConnectMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ext_ConnectMode类属于命名空间,在下文中一共展示了ext_ConnectMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnConnection
public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
{
try
{
_application = Core.Default.CreateObjectFromComProxy(null, Application);
/*
* _application is stored as COMObject the common base type for all reference types in NetOffice
* because this addin is loaded in different office application.
*
* with the CreateObjectFromComProxy method the _application instance is created as corresponding wrapper based on the com proxy type
*/
if (_application is Excel.Application)
_hostApplicationName = "Excel";
else if (_application is Word.Application)
_hostApplicationName = "Word";
else if (_application is Outlook.Application)
_hostApplicationName = "Outlook";
else if (_application is PowerPoint.Application)
_hostApplicationName = "PowerPoint";
else if (_application is Access.Application)
_hostApplicationName = "Access";
}
catch (Exception exception)
{
if(_hostApplicationName != null)
OfficeRegistry.LogErrorMessage(_hostApplicationName, _progId, "Error occured in OnConnection. ", exception);
}
}
示例2: OnConnection
/// <summary>Implements the constructor for the Add-in object. Place your initialization code within this method.</summary>
//public Connect()
//{
//}
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
/// <param term='application'>Root object of the host application.</param>
/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) {
applicationObject = (DTE2) application;
addInInstance = (AddIn) addInInst;
// Only execute the startup code if the connection mode is a startup mode
//if( connectMode == ext_ConnectMode.ext_cm_UISetup ) {
if (connectMode == ext_ConnectMode.ext_cm_AfterStartup) {
//Initializing Context
Context.ApplicationObject = applicationObject;
Context.AddInInstance = addInInstance;
//Initializing EventSinks
SolutionEventSink solutionEventSink = new SolutionEventSink();
addinEventSink = new AddinEventSink();
//Initializing Controller
controller = new UIController();
controller.Sinks.Add(solutionEventSink);
controller.Sinks.Add(addinEventSink);
controller.Init(solutionEventSink, addinEventSink);
addinEventSink.OnStartup(applicationObject);
if (Context.ApplicationObject.Solution.IsOpen){
solutionEventSink.OnOpenSolution();
}
}
}
示例3: OnConnection
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
var dte = application as DTE;
if (dte == null) return;
_dte = dte;
try
{
if (dte.Version != DteVersion)
{
Notify("OpenWrap Visual Studio integration is not correct version, re-creating now.");
dte.Solution.AddIns.OfType<AddIn>().First(x => x.ProgID == _progId).Remove();
if (dte.Version == "9.0")
dte.Solution.AddIns.Add(ComConstants.ADD_IN_PROGID_2008, ComConstants.ADD_IN_DESCRIPTION, ComConstants.ADD_IN_NAME, true);
else if (dte.Version == "10.0")
dte.Solution.AddIns.Add(ComConstants.ADD_IN_PROGID_2010, ComConstants.ADD_IN_DESCRIPTION, ComConstants.ADD_IN_NAME, true);
else if (dte.Version == "11.0")
dte.Solution.AddIns.Add(ComConstants.ADD_IN_PROGID_2012, ComConstants.ADD_IN_DESCRIPTION, ComConstants.ADD_IN_NAME, true);
return;
}
_rootPath = GetRootLocation(dte.Solution.FullName);
if (_rootPath == null) return;
Notify("OpenWrap Visual Studio Integration ({0}) starting.", FileVersionInfo.GetVersionInfo(GetType().Assembly.Location).FileVersion);
Notify("Root location: " + _rootPath);
LoadAppDomain();
}
catch (Exception e)
{
Notify("OpenWrap failed to initialize. Improbability Drive has been activated.\r\n", e.ToString());
}
}
示例4: OnConnection
public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
{
try
{
_vbe = Application as VBE;
_addin = AddInInst as AddIn;
switch (ConnectMode)
{
case ext_ConnectMode.ext_cm_AfterStartup:
InitializeAddIn();
break;
case ext_ConnectMode.ext_cm_Startup:
break;
case ext_ConnectMode.ext_cm_External:
break;
case ext_ConnectMode.ext_cm_CommandLine:
break;
default:
throw new ArgumentOutOfRangeException("ConnectMode");
}
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
示例5: OnConnection
/// <summary>Implements the OnConnection method of theIDTExtensibility2 interface. Receives notification that the Add-in isbeing loaded.</summary>
/// <param term='application'>Root object of the hostapplication.</param>
/// <param term='connectMode'>Describes how the Add-in isbeing loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
try
{
Logger.SetListener(new FileLogger());
Logger.Write("Connecting to Visual Studio");
_applicationObject = (DTE2) application;
StartupHandler.SetApplication(_applicationObject);
setupListener();
bindWorkspaceEvents();
SolutionStateHandler.BindEvents(_applicationObject);
SaverOfFilesThatVSKeepsStashigInMem.BindEvents(_applicationObject);
_addInInstance = (AddIn) addInInst;
Logger.Write("Adding menu item");
RegisterCommandHandlers();
if (connectMode == ext_ConnectMode.ext_cm_UISetup || theShitIsNotThere())
{
if (connectMode == ext_ConnectMode.ext_cm_UISetup)
Analytics.SendEvent("UI_SETUP");
else
Analytics.SendEvent("UI_SETUP_MANUAL");
AddMenuItems();
Logger.Write("Menu item added");
_initializedMenu = true;
}
AddContextMenue();
}
catch(Exception ex)
{
Logger.Write("OnConnect " + ex);
}
}
示例6: OnConnection
/// <summary>
/// Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.
/// </summary>
/// <param name='application'>
/// Root object of the host application.
/// </param>
/// <param name='connectMode'>
/// Describes how the Add-in is being loaded.
/// </param>
/// <param name='addIn'>
/// Object representing this Add-in.
/// </param>
/// /// <param name='custom'>
/// Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, ext_ConnectMode connectMode, object addIn, ref Array custom)
{
_application = (DTE2)application;
_addIn = (AddIn)addIn;
try
{
if (connectMode == ext_ConnectMode.ext_cm_Startup || connectMode == ext_ConnectMode.ext_cm_AfterStartup)
{
_listener = CreateTraceListener();
_env = new ControllerEnvironment(new WindowHandle(_application.MainWindow.HWnd), _listener);
_controller = CreateController();
_controller.OnConnectionStateChange += OnConnectionStateChange;
CreateCommands();
CreateToolWindow();
_listener.WriteLine("Addin initialized");
if (connectMode == ext_ConnectMode.ext_cm_AfterStartup)
{
OnStartupComplete(ref custom);
}
}
}
catch (Exception ex)
{
if (_listener != null)
{
_listener.WriteLine(ex);
}
}
}
示例7: OnConnection
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
/// <param term='application'>Root object of the host application.</param>
/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_application = (DTE2)application;
_addInInstance = (AddIn)addInInst;
// Core
var name = _addInInstance.Name;
var outputPane = _application.ToolWindows.OutputWindow.OutputWindowPanes.GetPane(name);
var feedback = new FeedbackManager(name, outputPane);
_core = new Core(feedback);
// Events
_events = (Events2)_application.Events;
_projectsEvents = _events.ProjectsEvents;
_projectItemsEvents = _events.ProjectItemsEvents;
_documentEvents = _events.DocumentEvents;
_buildEvents = _events.BuildEvents;
AttachEvents();
// If being connected when Solution is already loaded - try to load all projects
if (_application.Solution != null)
{
_core.Load(_application.Solution);
}
}
示例8:
/// <summary>
/// Implements the OnConnection method of the IDTExtensibility2 interface.
/// </summary>
/// <remarks>
/// <para>
/// Receives notification that the Add-in is being loaded.
/// </para>
/// </remarks>
/// <param term='application'>Root object of the host application.</param>
/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
void IDTExtensibility2.OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
dte = (DTE2)application;
addIn = (AddIn)addInInst;
ShellProxy.Instance.AddInConnected(this);
}
示例9: OnConnection
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
try
{
this._applicationObject = (DTE2)application;
this._addInInstance = (AddIn)addInInst;
if (connectMode == ext_ConnectMode.ext_cm_Startup && AddinSetupState.State == SetupState.FirstRun)
{
LogHelper.LogDebug("Add-in SetupState is FirstRun");
LogHelper.LogDebug("Removing add-in commands");
this.RemoveAddinCommands();
LogHelper.LogDebug("Creating add-in commands");
this.CreateAddinCommands();
LogHelper.LogDebug("Opening FirstRunStep1 form");
FirstRunStep1 firstRunStep = new FirstRunStep1();
firstRunStep.ShowDialog();
LogHelper.LogDebug("Setting add-in SetupState to complete");
AddinSetupState.State = SetupState.SetupComplete;
}
if (connectMode == ext_ConnectMode.ext_cm_Startup || connectMode == ext_ConnectMode.ext_cm_AfterStartup)
{
LogHelper.LogDebug("Creating add-in menus");
this.CreateAddinMenus();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "CodeKeep");
}
}
示例10: OnConnection
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
/// <param term='application'>Root object of the host application.</param>
/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
if (connectMode == ext_ConnectMode.ext_cm_UISetup)
{
// Create the command object
object[] contextGUIDS = new object[] { };
Commands2 commands = (Commands2)_applicationObject.Commands;
try
{
Command cmd = commands.AddNamedCommand2(_addInInstance, "DocumentClass",
"Class Documentator", "Document your class module ", true, 59, ref contextGUIDS,
(int)vsCommandStatus.vsCommandStatusSupported +
(int)vsCommandStatus.vsCommandStatusEnabled,
(int)vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton);
// Create a command bar on the code window
CommandBar CmdBar = ((CommandBars)_applicationObject.CommandBars)["Code Window"];
// Add a command to the Code Window's shortcut menu.
CommandBarControl cmdBarCtl = (CommandBarControl)cmd.AddControl(CmdBar,
CmdBar.Controls.Count + 1);
cmdBarCtl.Caption = "Class Doc";
}
catch (System.ArgumentException)
{
}
}
}
示例11: OnConnection
/// <summary>
/// Implements the OnDisconnection method of the IDTExtensibility2 interface.
/// Occurs when he Add-in is loaded into Visual Studio.
/// </summary>
/// <param name="application">A reference to an instance of the IDE, DTE.</param>
/// <param name="connectMode">
/// An <see cref="ext_ConnectMode"/> enumeration value that indicates
/// the way the add-in was loaded into Visual Studio.
/// </param>
/// <param name="instance">An <see cref="AddIn"/> reference to the add-in's own instance.</param>
/// <param name="custom">An empty array that you can use to pass host-specific data for use in the add-in.</param>
public void OnConnection(object application, ext_ConnectMode connectMode, object instance, ref Array custom)
{
App = (DTE2) application;
Instance = (AddIn) instance;
Events = App.Events as Events2;
Logger = new OutputWindowLogger(App);
Logger.Log("Loading...");
Compose(); // Do not attempt to use [Import]s before this line!
if(Chirp == null)
{
Logger.Log("Unable to load.");
return;
}
BindEvents();
PrintLoadedEngines();
Logger.Log("Ready");
if(App.Solution.IsOpen)
{
SolutionOpened();
foreach (var project in App.Solution.Projects.Cast<Project>())
{
ProjectAdded(project);
}
}
}
示例12: OnConnection
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
/// <param term='application'>Root object of the host application.</param>
/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
if (connectMode == ext_ConnectMode.ext_cm_UISetup)
{
object[] contextGUIDS = new object[] { };
Commands2 commands = (Commands2)_applicationObject.Commands;
CommandBars cBars = (CommandBars)_applicationObject.CommandBars;
try
{
Command commandProjectSettings = commands.AddNamedCommand2(_addInInstance, "DavecProjectSchemaSettings", "Davec Project Settings", "Manages Database Project Settings", false, 1, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
Command commandAddSchemaUpdate = commands.AddNamedCommand2(_addInInstance, "DavecProjectUpdate", "Davec Update", "Updates Database Schema", false, 2, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
CommandBar vsBarProject = cBars["Project"];
CommandBar vsBarFolder = cBars["Folder"];
commandProjectSettings.AddControl(vsBarProject, 1);
commandAddSchemaUpdate.AddControl(vsBarFolder, 1);
}
catch (System.ArgumentException)
{
//ignore
}
var _solutionEvents = _applicationObject.Events.SolutionEvents;
_solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);
var _documentEvents = _applicationObject.Events.DocumentEvents;
_documentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(_documentEvents_DocumentSaved);
}
}
示例13: OnConnection
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
/// <param term='application'>Root object of the host application.</param>
/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
_dbgWatchConfig = new QuickWatchConfig();
try {
CommandBar commandBar = ((CommandBars)_applicationObject.CommandBars)["Code Window"];
// Create Quick watch menu
_controlQuickWatch = commandBar.Controls.Add(MsoControlType.msoControlButton, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, true);
_controlQuickWatch.Caption = "QuickWatchEx...";
_controlQuickWatch.Enabled = IsInDebugMode(_applicationObject);
_menuItemHandlerQuickWatch = (CommandBarEvents)_applicationObject.Events.CommandBarEvents[_controlQuickWatch];
_menuItemHandlerQuickWatch.Click += MenuItemHandlerQuickWatch_Click;
_debuggerEvents = _applicationObject.Events.DebuggerEvents;
_debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
_debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;
_debuggerEvents.OnEnterRunMode += DebuggerEvents_OnEnterRunMode;
} catch (Exception e) {
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例14: OnConnection
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
/// <param term='application'>Root object of the host application.</param>
/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
Globals.DTE = (DTE2)application;
Globals.Addin = (AddIn)addInInst;
solutionEvents = Globals.DTE.Events.SolutionEvents;
solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);
solutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(SolutionEvents_BeforeClosing);
commandManager = new CommandManager(Globals.DTE, Globals.Addin);
commandBarBuilder = new CommandBarBuilder(Globals.DTE, Globals.Addin);
switch (connectMode)
{
case ext_ConnectMode.ext_cm_UISetup:
// Initialize the UI of the add-in
break;
case ext_ConnectMode.ext_cm_Startup:
// The add-in was marked to load on startup
// Do nothing at this point because the IDE may not be fully initialized
// Visual Studio will call OnStartupComplete when fully initialized
break;
case ext_ConnectMode.ext_cm_AfterStartup:
// The add-in was loaded by hand after startup using the Add-In Manager
// Initialize it in the same way that when is loaded on startup
Initialize();
break;
}
}
示例15: OnConnection
public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
{
pb = new PBHelper();
application = (DTE2)Application;
addInInstance = (AddIn)AddInInst;
if (ConnectMode == ext_ConnectMode.ext_cm_UISetup)
{
object[] contextGUIDS = new object[] { };
Commands2 commands = (Commands2)application.Commands;
// get item bar
Microsoft.VisualStudio.CommandBars.CommandBar itemCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)application.CommandBars)["Item"];
try
{
// add me commands
Command command = commands.AddNamedCommand2(addInInstance, "Dw2Struct", "Generate Structure", "Generates a structure of the columns in the datawindow", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
Command command2 = commands.AddNamedCommand2(addInInstance, "Dw2Nv", "Generate NonVisualObject", "Generates an NonVisualObject of the columns in the datawindow", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
if ((command != null))
{
command.AddControl(itemCommandBar, itemCommandBar.Controls.Count);
}
if ((command2 != null))
{
command2.AddControl(itemCommandBar, itemCommandBar.Controls.Count);
}
}
catch (System.ArgumentException)
{
}
}
}