Пример #1
0
        void OnViewChanged(object sender, EventArgs args)
        {
            if (viewProvider != null)
            {
                this.dynamicProviders.Remove(viewProvider);
                viewProvider.ItemsChanged -= OnProviderItemsChanged;
            }

            //only treat active ViewContent as a Toolbox consumer if it implements IToolboxConsumer
            if (IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.ActiveView != null)
            {
                CurrentConsumer = IdeApp.Workbench.ActiveDocument.ActiveView.GetContent <IToolboxConsumer> ();
                viewProvider    = IdeApp.Workbench.ActiveDocument.ActiveView.GetContent <IToolboxDynamicProvider> ();
                customizer      = IdeApp.Workbench.ActiveDocument.ActiveView.GetContent <IToolboxCustomizer> ();
                if (viewProvider != null)
                {
                    this.dynamicProviders.Add(viewProvider);
                    viewProvider.ItemsChanged += OnProviderItemsChanged;
                    OnToolboxContentsChanged();
                }
            }
            else
            {
                CurrentConsumer = null;
                viewProvider    = null;
                customizer      = null;
            }
        }
Пример #2
0
        void OnContentChanged(object sender, EventArgs args)
        {
            foreach (var viewProvider in viewProviders)
            {
                this.dynamicProviders.Remove(viewProvider);
                viewProvider.ItemsChanged -= OnProviderItemsChanged;
            }
            viewProviders.Clear();

            //only treat active ViewContent as a Toolbox consumer if it implements IToolboxConsumer
            if (IdeApp.Workbench.ActiveDocument != null)
            {
                CurrentConsumer = IdeApp.Workbench.ActiveDocument.GetContent <IToolboxConsumer> (true);
                foreach (var viewProvider in IdeApp.Workbench.ActiveDocument.GetContents <IToolboxDynamicProvider> ())
                {
                    viewProviders.Add(viewProvider);
                    dynamicProviders.Add(viewProvider);
                    viewProvider.ItemsChanged += OnProviderItemsChanged;
                }
                customizer = IdeApp.Workbench.ActiveDocument.GetContent <IToolboxCustomizer> (true);
                if (viewProviders.Count > 0)
                {
                    OnToolboxContentsChanged();
                }
            }
            else
            {
                CurrentConsumer = null;
                customizer      = null;
            }
        }
		void OnViewChanged (object sender, EventArgs args)
		{
			if (viewProvider != null) {
				this.dynamicProviders.Remove (viewProvider);
				viewProvider.ItemsChanged -= OnProviderItemsChanged;
			}
			
			//only treat active ViewContent as a Toolbox consumer if it implements IToolboxConsumer
			if (IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.ActiveView != null) {
				CurrentConsumer = IdeApp.Workbench.ActiveDocument.ActiveView.GetContent<IToolboxConsumer> ();
				viewProvider    = IdeApp.Workbench.ActiveDocument.ActiveView.GetContent<IToolboxDynamicProvider> ();
				customizer = IdeApp.Workbench.ActiveDocument.ActiveView.GetContent<IToolboxCustomizer> ();
				if (viewProvider != null)  {
					this.dynamicProviders.Add (viewProvider);
					viewProvider.ItemsChanged += OnProviderItemsChanged;
					OnToolboxContentsChanged ();
				}
			} else {
				CurrentConsumer = null;
				viewProvider = null;
				customizer = null;
			}
		}