本文整理汇总了C#中Microsoft.VisualStudio.Shell.Package类的典型用法代码示例。如果您正苦于以下问题:C# Package类的具体用法?C# Package怎么用?C# Package使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Package类属于Microsoft.VisualStudio.Shell命名空间,在下文中一共展示了Package类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Initialize
protected override void Initialize()
{
_dte = GetService(typeof(DTE)) as DTE2;
Package = this;
Telemetry.SetDeviceName(_dte.Edition);
Logger.Initialize(this, Constants.VSIX_NAME);
Events2 events = (Events2)_dte.Events;
_solutionEvents = events.SolutionEvents;
_solutionEvents.AfterClosing += () => { TableDataSource.Instance.CleanAllErrors(); };
_solutionEvents.ProjectRemoved += (project) => { TableDataSource.Instance.CleanAllErrors(); };
_buildEvents = events.BuildEvents;
_buildEvents.OnBuildBegin += OnBuildBegin;
CreateConfig.Initialize(this);
Recompile.Initialize(this);
CompileOnBuild.Initialize(this);
RemoveConfig.Initialize(this);
CompileAllFiles.Initialize(this);
CleanOutputFiles.Initialize(this);
base.Initialize();
}
开发者ID:PaulVrugt,项目名称:WebCompiler,代码行数:25,代码来源:WebCompilerPackage.cs
示例2: AddInheritDocCommand
private AddInheritDocCommand(Package package)
{
this.package = package;
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var menuCommandId = new CommandID(CommandSet, CommandId);
var menuItem = new OleMenuCommand(MenuItemCallback, menuCommandId);
commandService.AddCommand(menuItem);
menuItem.BeforeQueryStatus += (sender, e) =>
{
bool visible = false;
var dte = (DTE)Package.GetGlobalService(typeof(SDTE));
var classElem = SearchService.FindClass(dte);
if (classElem != null)
{
List<CodeElement> codeElements = SearchService.FindCodeElements(dte);
if (classElem.ImplementedInterfaces.Count > 0)
{
visible = true;
}
else
{
visible = codeElements.Any(elem => elem.IsInherited() || elem.OverridesSomething());
}
}
((OleMenuCommand)sender).Visible = visible;
};
}
}
开发者ID:mmahulea,项目名称:FactonExtensionPackage,代码行数:32,代码来源:AddInheritDocCommand.cs
示例3: LocatorWindowCommand
/// <summary>
/// Initializes a new instance of the <see cref="LocatorWindowCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
private LocatorWindowCommand(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.package = package;
OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.ShowToolWindow, menuCommandID);
commandService.AddCommand(menuItem);
}
// Get the instance number 0 of this tool window. This window is single instance so this instance
// is actually the only one.
// The last flag is set to true so that if the tool window does not exists it will be created.
_locatorWindow = package.FindToolWindow(typeof(LocatorWindow), 0, true) as LocatorWindow;
if ((null == _locatorWindow) || (null == _locatorWindow.Frame))
{
throw new NotSupportedException("Cannot create tool window");
}
_locator = new Locator();
_solution = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
_solution.AdviseSolutionEvents(_locator, out _cookie);
_locatorWindow.SetLocator(_locator);
_locator.StartWorkerThread();
}
开发者ID:SoulForMachine,项目名称:QtCreatorPack,代码行数:37,代码来源:LocatorWindowCommand.cs
示例4: BuildStartProject
/// <summary>
/// Initializes a new instance of the <see cref="BuildStartProject"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
private BuildStartProject(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.package = package;
// Add a menu item.
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
commandService.AddCommand(menuItem);
}
// Register as an advisory interface.
var solutionService = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
if (solutionService != null)
{
solutionService.AdviseSolutionEvents(this, out m_EventSinkCookie);
}
}
开发者ID:Wakusei,项目名称:BuildStartProject,代码行数:30,代码来源:BuildStartProject.cs
示例5: CommandWithArguments
private CommandWithArguments(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.package = package;
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var menuCommandID = new CommandID(CommandSet, CommandId);
// Step 1: Add the <CommandFlag>AllowParams</CommandFlag> in the .vsct file for the command
// Step 2: Use an OleMenuCommand, not a MenuCommand
var oleMenuCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID);
// Step 3: Initialize the ParametersDescription property to the "$" value.
// That magical value means that the command accepts any kind of values
oleMenuCommand.ParametersDescription = "$";
commandService.AddCommand(oleMenuCommand);
}
}
开发者ID:visualstudioextensibility,项目名称:VSX-Samples,代码行数:26,代码来源:CommandWithArguments.cs
示例6: EditorFactory
public EditorFactory(Package package, IComponentContext context)
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} constructor", this));
this.editorPackage = package;
this.context = context;
}
开发者ID:gleblebedev,项目名称:toe,代码行数:7,代码来源:EditorFactory.cs
示例7: IntegrationTestServiceCommands
private IntegrationTestServiceCommands(Package package)
{
if (package == null)
{
throw new ArgumentNullException(nameof(package));
}
_package = package;
var commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var startServiceMenuCmdId = new CommandID(GrpIdIntegrationTestServiceCommands, CmdIdStartIntegrationTestService);
_startServiceMenuCmd = new MenuCommand(StartServiceCallback, startServiceMenuCmdId) {
Enabled = true,
Supported = true,
Visible = true
};
commandService.AddCommand(_startServiceMenuCmd);
var stopServiceMenuCmdId = new CommandID(GrpIdIntegrationTestServiceCommands, CmdIdStopIntegrationTestService);
_stopServiceMenuCmd = new MenuCommand(StopServiceCallback, stopServiceMenuCmdId) {
Enabled = false,
Supported = true,
Visible = false
};
commandService.AddCommand(_stopServiceMenuCmd);
}
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:30,代码来源:IntegrationTestServiceCommands.cs
示例8: PoorMansTSqlFormatterCommand
/// <summary>
/// Initializes a new instance of the <see cref="PoorMansTSqlFormatterCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
private PoorMansTSqlFormatterCommand(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.package = package;
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
_applicationObject = Package.GetGlobalService(typeof(DTE)) as DTE;
_formattingManager = PoorMansTSqlFormatterPluginShared.Utils.GetFormattingManager(Properties.Settings.Default);
//Command cmd = _applicationObject.Commands.Item("Tools.FormatTSQLCode", -1);
//cmd.Bindings = "Text Editor::Ctrl+Shift+D";
var menuFormatCommandID = new CommandID(CommandSet, FormatCommandId);
var menuFormatItem = new MenuCommand(this.MenuFormatCallback, menuFormatCommandID);
commandService.AddCommand(menuFormatItem);
var menuOptionsCommandID = new CommandID(CommandSet, OptionsCommandId);
var menuOptionsItem = new MenuCommand(this.MenuOptionsCallback, menuOptionsCommandID);
commandService.AddCommand(menuOptionsItem);
_formatCommand = _applicationObject.Commands.Item("Tools.FormatTSQLCode", -1);
SetFormatHotkey();
}
}
开发者ID:GetACookie,项目名称:PoorMansTSqlFormatter,代码行数:35,代码来源:PoorMansTSqlFormatterCommand.cs
示例9: Factory
public Factory(Package package)
: base()
{
this.package = package;
var solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution));
ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out solutionCookie));
}
开发者ID:jijo-paulose,项目名称:bistro-framework,代码行数:7,代码来源:Factory.cs
示例10: AliaserCommand
/// <summary>
/// Initializes a new instance of the <see cref="AliaserCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
private AliaserCommand(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.package = package;
this.MainService = new AliaserService();
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
CommandID menuToAliasCommandID = new CommandID(MenuGroup, ALIASER_TO_ALIAS_COMMAND_ID);
CommandID menuToInstanceCommandID = new CommandID(MenuGroup, ALIASER_TO_INSTANCE_COMMAND_ID);
EventHandler transformAliasToInstace = this.TransformAliasToInstace;
EventHandler transformInstaceToAlias = this.TransformInstaceToAlias;
MenuCommand menuItemToInstace = new MenuCommand(transformAliasToInstace, menuToInstanceCommandID);
MenuCommand menuItemToAlias = new MenuCommand(transformInstaceToAlias, menuToAliasCommandID);
commandService.AddCommand(menuItemToInstace);
commandService.AddCommand(menuItemToAlias);
}
}
开发者ID:jiriKuba,项目名称:Aliaser,代码行数:31,代码来源:AliaserCommand.cs
示例11: ProjectFactory
protected ProjectFactory(Package package)
{
Package = package;
Site = package;
// Please be aware that this methods needs that ServiceProvider is valid, thus the ordering of calls in the ctor matters.
buildEngine = Utilities.InitializeMsBuildEngine(buildEngine, Site);
}
开发者ID:mimura1133,项目名称:vstex,代码行数:8,代码来源:ProjectFactory.cs
示例12: SolutionEventsListener
private SolutionEventsListener(Package package)
{
if (package == null)
throw new ArgumentNullException(nameof(package));
this.package = package;
}
开发者ID:xoriath,项目名称:atmelstudio-fstack-usage,代码行数:8,代码来源:SolutionEventsListener.cs
示例13: VisualStudioConnection
public VisualStudioConnection(Package package)
{
_package = package;
_dte = (DTE2)Package.GetGlobalService(typeof(DTE));
_solutionEvents = ((Events2)_dte.Events).SolutionEvents;
_buildEvents = ((Events2)_dte.Events).BuildEvents;
_subject = new Subject<EventType>();
}
开发者ID:Refresh06,项目名称:visualmutator,代码行数:8,代码来源:VisualStudioConnection.cs
示例14: BooLangProjectFactory
public BooLangProjectFactory(Package package)
: base(package)
{
string booBinPath = (string)Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0Exp\Configuration\Packages\{55663be2-a969-4279-82c5-a6f27936f4f7}").GetValue("BooBinPath");
this.package = (ProjectPackage)package;
this.BuildEngine.GlobalProperties["BoocToolPath"] = new BuildProperty("BoocToolPath", booBinPath);
this.BuildEngine.GlobalProperties["BooBinPath"] = new BuildProperty("BooBinPath",booBinPath);
}
开发者ID:w4x,项目名称:boolangstudio,代码行数:8,代码来源:BooLangProjectFactory.cs
示例15: ProjectFactory
protected ProjectFactory(Microsoft.VisualStudio.Shell.Package package)
{
this.package = package;
this.site = package;
// Please be aware that this methods needs that ServiceProvider is valid, thus the ordering of calls in the ctor matters.
this.buildEngine = Utilities.InitializeMsBuildEngine(this.buildEngine, this.site);
}
开发者ID:Jeremiahf,项目名称:wix3,代码行数:8,代码来源:projectfactory.cs
示例16: DexterFileAnalysisCommand
public DexterFileAnalysisCommand(Package package, int commandId, Guid commandSet, ConfigurationProvider configurationProvider)
: base(package, commandId, commandSet, configurationProvider)
{
WindowEvents events = ((Events2)Dte.Events).WindowEvents;
events.WindowActivated += OnDocumentWindowActivated;
events.WindowClosing += OnDocumentWindowClosed;
}
开发者ID:KarolAntczak,项目名称:Dexter,代码行数:8,代码来源:DexterFileAnalysisCommand.cs
示例17: ClojureProjectNode
/// <summary>
/// Initializes a new instance of the <see cref = "ClojureProjectNode" /> class.
/// </summary>
/// <param name = "package">Value of the project package for initialize internal package field.</param>
public ClojureProjectNode(Package package)
{
this.package = package;
InitializeImageList();
CanProjectDeleteItems = true;
}
开发者ID:vasily-kirichenko,项目名称:vsClojure,代码行数:12,代码来源:ClojureProjectNode.cs
示例18: AttachToAnythingController
public AttachToAnythingController(Package package, DTE dte, AttachTargetOptionPage options, ProcessWaitSource waitSource, IDiagnosticLogger logger)
{
_package = package;
_dte = dte;
_options = options;
_waitSource = waitSource;
_logger = logger;
}
开发者ID:ashmind,项目名称:AttachToAnything,代码行数:8,代码来源:AttachToAnythingController.cs
示例19: DexterAnalysisCommand
/// <summary>
/// Initializes a new instance of the <see cref="DexterAnalysisCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
/// <param name="commandId">Command ID.</param>
/// <param name="commandSet">Command menu group (command set GUID).</param>
public DexterAnalysisCommand(Package package, int commandId, Guid commandSet, ConfigurationProvider configurationProvider)
: base(package,commandId,commandSet)
{
AutoEnabled = true;
dexterInfoValidator = new DexterInfoValidator();
projectInfoValidator = new ProjectInfoValidator();
ConfigurationProvider = configurationProvider;
Refresh();
}
开发者ID:KarolAntczak,项目名称:Dexter,代码行数:16,代码来源:DexterAnalysisCommand.cs
示例20: MenuCommandController
public MenuCommandController(Package package)
{
_package = package;
_statusController = new StatusController
{
StatusBar = Package.GetGlobalService(typeof(SVsStatusbar)) as IVsStatusbar,
OutputWindow = _package.GetOutputPane(VSConstants.GUID_OutWindowGeneralPane, "Lonestar"),
};
}
开发者ID:BenHall,项目名称:lonestar,代码行数:9,代码来源:MenuCommandController.cs
注:本文中的Microsoft.VisualStudio.Shell.Package类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论