예제 #1
0
        private void Provider_SelectionChanged(object sender, NodesChangedEventArgs args)
        {
            INavigationContextProvider provider = (INavigationContextProvider)sender;
            INodeInformation           node     = (args.ChangedNodes.Count > 0 ? args.ChangedNodes[0] : null);

            if (_tableMenu == null &&
                _tableRegex.IsMatch(node.Context))
            {
                _tableMenu = (HierarchyObject)node.GetService(typeof(IMenuHandler));

                MenuItem item = new MenuItem();
                _tableMenu.AddChild(string.Empty, item);
            }
        }
예제 #2
0
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _addInInstance = (AddIn)addInInst;

            // search ServiceCache.ServiceProvider.GetService ->
            // http://sqlblog.com/blogs/jonathan_kehayias/archive/2009/08/22/sql-2008-r2-breaks-ssms-addins.aspx

            ObjectExplorerService objectExplorer = (ObjectExplorerService)ServiceCache.ServiceProvider.GetService(typeof(IObjectExplorerService));

            // for some reason calling GetSelectedNodes forces to add ContextService to ObjectExplorerService.Container.Components
            int count = objectExplorer.Container.Components.Count;
            int nodeCount; INodeInformation[] nodes;

            objectExplorer.GetSelectedNodes(out nodeCount, out nodes);
            count = nodeCount; count = nodes.Length;
            count = objectExplorer.Container.Components.Count;

            ContextService             contextService = (ContextService)objectExplorer.Container.Components[1];
            INavigationContextProvider provider = contextService.ObjectExplorerContext;

            provider.CurrentContextChanged += new NodesChangedEventHandler(Provider_SelectionChanged);
        }