Exemplo n.º 1
0
        private IEventBindingService GetEventPropertyService(object obj, ITypeDescriptorContext context)
        {
            IEventBindingService iEventBindingService = null;

            if (!sunkEvent)
            {
                sunkEvent = true;
                IDesignerEventService iDesignerEventService = sp.GetService(typeof(IDesignerEventService)) as IDesignerEventService;
                if (iDesignerEventService != null)
                {
                    iDesignerEventService.ActiveDesignerChanged += new ActiveDesignerEventHandler(OnActiveDesignerChanged);
                }
            }

            if (iEventBindingService == null && host != null)
            {
                iEventBindingService = host.GetService(typeof(IEventBindingService)) as IEventBindingService;
            }

            if (iEventBindingService == null && obj is IComponent)
            {
                if (obj != null)
                {
                    iEventBindingService = (obj as IComponent).Site.GetService(typeof(IEventBindingService)) as IEventBindingService;
                }
            }
            if (iEventBindingService == null && context != null)
            {
                iEventBindingService = context.GetService(typeof(IEventBindingService)) as IEventBindingService;
            }

            return(iEventBindingService);
        }
        void IDisposable.Dispose()
        {
            WorkflowView view = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;

            if (view != null)
            {
                if (this.refreshTypesHandler != null)
                {
                    view.Idle -= this.refreshTypesHandler;
                }
                if (this.refreshDesignerActionsHandler != null)
                {
                    view.Idle -= this.refreshDesignerActionsHandler;
                }
                if (this.refreshTasksHandler != null)
                {
                    view.Idle -= this.refreshTasksHandler;
                }
            }
            this.refreshTypesHandler           = null;
            this.refreshDesignerActionsHandler = null;
            this.refreshTasksHandler           = null;
            IExtendedUIService service = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;

            if (service != null)
            {
                service.RemoveDesignerActions();
            }
            IPropertyValueUIService service2 = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService;

            if (service2 != null)
            {
                service2.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.OnPropertyGridAdornments));
            }
            IComponentChangeService service3 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (service3 != null)
            {
                service3.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
            }
            ISelectionService service4 = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;

            if (service4 != null)
            {
                service4.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
            }
            ITypeProvider provider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;

            if (provider != null)
            {
                provider.TypesChanged -= new EventHandler(this.OnTypeSystemTypesChanged);
            }
            IDesignerEventService service5 = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService;

            if (service5 != null)
            {
                service5.ActiveDesignerChanged -= new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
            }
            this.serviceProvider.LoadComplete -= new EventHandler(this.OnDesignerReloaded);
        }
Exemplo n.º 3
0
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);

            IComponentChangeService changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
            IDesignerEventService   desigerEvt    = GetService(typeof(IDesignerEventService)) as IDesignerEventService;

            changeService.ComponentRemoved += new ComponentEventHandler(changeService_ComponentRemoved);

            orbAdorner = new Adorner();
            tabAdorner = new Adorner();

            BehaviorService.Adorners.AddRange(new Adorner[] { orbAdorner, tabAdorner });
            if (Ribbon.QuickAcessToolbar.Visible)
            {
                quickAccessAdorner = new Adorner();
                BehaviorService.Adorners.Add(quickAccessAdorner);
                quickAccessAdorner.Glyphs.Add(new RibbonQuickAccessToolbarGlyph(BehaviorService, this, Ribbon));
            }
            else
            {
                quickAccessAdorner = null;
            }
            //orbAdorner.Glyphs.Add(new RibbonOrbAdornerGlyph(BehaviorService, this, Ribbon));
            tabAdorner.Glyphs.Add(new RibbonTabGlyph(BehaviorService, this, Ribbon));
        }
        public WorkflowDesignerEventsCoordinator(IDesignerLoaderHost serviceProvider)
        {
            this.serviceProvider = serviceProvider;
            this.serviceProvider.LoadComplete += new EventHandler(this.OnDesignerReloaded);
            IDesignerEventService service = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService;

            if (service != null)
            {
                service.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
            }
            ITypeProvider provider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;

            if (provider != null)
            {
                provider.TypesChanged += new EventHandler(this.OnTypeSystemTypesChanged);
            }
            ISelectionService service2 = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;

            if (service2 != null)
            {
                service2.SelectionChanged += new EventHandler(this.OnSelectionChanged);
            }
            IComponentChangeService service3 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (service3 != null)
            {
                service3.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
            }
            IPropertyValueUIService service4 = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService;

            if (service4 != null)
            {
                service4.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.OnPropertyGridAdornments));
            }
        }
        private IEventBindingService GetEventPropertyService(object obj, ITypeDescriptorContext context)
        {
            IEventBindingService service = null;

            if (!this.sunkEvent)
            {
                IDesignerEventService service2 = (IDesignerEventService)this.sp.GetService(typeof(IDesignerEventService));
                if (service2 != null)
                {
                    service2.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
                }
                this.sunkEvent = true;
            }
            if ((service == null) && (this.currentHost != null))
            {
                service = (IEventBindingService)this.currentHost.GetService(typeof(IEventBindingService));
            }
            if ((service == null) && (obj is IComponent))
            {
                ISite site = ((IComponent)obj).Site;
                if (site != null)
                {
                    service = (IEventBindingService)site.GetService(typeof(IEventBindingService));
                }
            }
            if ((service == null) && (context != null))
            {
                service = (IEventBindingService)context.GetService(typeof(IEventBindingService));
            }
            return(service);
        }
    //- realy on SurfaceManager.ActiveDesignSurface
    //- which effectively points to ACTIVE DesignSurface
    public void ReloadComboBox() {
        _bSuppressEvents = true;
        try {
            //- IDesignerEventService provides a global eventing mechanism for designer events. With this mechanism,
            //- an application is informed when a designer becomes active. The service provides a collection of
            //- designers and a single place where global objects, such as the Properties window, can monitor selection
            //- change events.
            IDesignerEventService des = (IDesignerEventService) SurfaceManager.GetService( typeof( IDesignerEventService ) );
            if( null == des )
                return;
            IDesignerHost host = des.ActiveDesigner;


            object selectedObj = pgrdPropertyGrid.SelectedObject;
            if( null == selectedObj )
                return; //- don't reload at all


            //- get the name of the control selected from the comboBox
            //- and if we are not able to get it then it's better to exit
            string sName = string.Empty;
            if( selectedObj is Form ) {
                sName = ((Form) selectedObj).Name;
            }
            else if( selectedObj is Control ) {
                sName = ((Control) selectedObj).Site.Name;
            }
            if( string.IsNullOrEmpty( sName ) )
                return;



            //- prepare the data for reloading the combobox (begin)
            List<object> ctrlsToAdd = new List<object>();
            string pgrdComboBox_Text = string.Empty;
            try {
                ComponentCollection ctrlsExisting = host.Container.Components;
                Debug.Assert( 0 != ctrlsExisting.Count );


                foreach( Component comp in ctrlsExisting ) {
                    string sItemText = TranslateComponentToName( comp );
                    ctrlsToAdd.Add( sItemText );
                    if( sName == comp.Site.Name )
                        pgrdComboBox_Text = sItemText;
                }//end_foreach
            }
            catch( Exception ) {
                return; //- (rollback)
            }
            //- update the combobox (commit)
            pgrdComboBox.Items.Clear();
            pgrdComboBox.Items.AddRange( ctrlsToAdd.ToArray() );
            pgrdComboBox.Text = pgrdComboBox_Text;
        }
        finally {
            _bSuppressEvents = false;
        }
    }
Exemplo n.º 7
0
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);

            IComponentChangeService changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
            IDesignerEventService   desigerEvt    = GetService(typeof(IDesignerEventService)) as IDesignerEventService;

            changeService.ComponentRemoved += new ComponentEventHandler(changeService_ComponentRemoved);
        }
        private void OnTypeSystemTypesChanged(object sender, EventArgs e)
        {
            this.typeSystemTypesChanged = true;
            IDesignerEventService service = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService;

            if ((service != null) && (service.ActiveDesigner == this.serviceProvider.GetService(typeof(IDesignerHost))))
            {
                this.RefreshTypes();
            }
        }
Exemplo n.º 9
0
        //- rely on SurfaceManager.ActiveDesignSurface
        //- which effectively points to ACTIVE DesignSurface
        private void OrientPropertyGridTowardsObject()
        {
            //- IDesignerEventService provides a global eventing mechanism for designer events. With this mechanism,
            //- an application is informed when a designer becomes active. The service provides a collection of
            //- designers and a single place where global objects, such as the Properties window, can monitor selection
            //- change events.
            IDesignerEventService des = (IDesignerEventService)SurfaceManager.GetService(typeof(IDesignerEventService));

            if (null == des)
            {
                return;
            }
            IDesignerHost host = des.ActiveDesigner;

            //- get the ISelectionService from the active Designsurface
            //- and if we are not able to get it then it'sType better to exit
            ISelectionService iSel = host.GetService(typeof(ISelectionService)) as ISelectionService;

            if (iSel == null)
            {
                return;
            }

            //- get the name of the control selected from the comboBox
            //- and if we are not able to get it then it's better to exit
            string sName = pgrdComboBox.SelectedItem.ToString();

            if (string.IsNullOrEmpty(sName))
            {
                return;
            }

            //- save the collection of objects currently selected

            //- loop through the controls inside the current Designsurface
            //- if we find the one selected into the comboBox then
            //- use the ISelectionService to select it
            //- (and this will select it into the PropertyGridHost)
            ComponentCollection ctrlsExisting = host.Container.Components;

            Debug.Assert(0 != ctrlsExisting.Count);
            foreach (Component comp in ctrlsExisting)
            {
                string sItemText = TranslateComponentToName(comp);
                if (sName == sItemText)
                {
                    Component[] arr = { comp };
                    //- ISelectionService in action...
                    iSel.SetSelectedComponents(arr);
                    //this.SelectedObject = arr[0];
                    break;
                }
            }
        }
Exemplo n.º 10
0
 internal void OnDesignerInfoChanged(DesignerToolboxInfo state)
 {
     if (this._designerEventService == null)
     {
         this._designerEventService = state.DesignerHost.GetService(typeof(IDesignerEventService)) as IDesignerEventService;
     }
     if ((this._designerEventService != null) && (this._designerEventService.ActiveDesigner == state.DesignerHost))
     {
         this.FilterChanged();
     }
 }
Exemplo n.º 11
0
        private void OnTypeSystemTypesChanged(object sender, EventArgs e)
        {
            this.typeSystemTypesChanged = true;

            //If the current designer is not active designer then we need to wait for it to be active before we update the types
            IDesignerEventService designerEventService = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService;

            if (designerEventService != null && designerEventService.ActiveDesigner == this.serviceProvider.GetService(typeof(IDesignerHost)))
            {
                RefreshTypes();
            }
        }
Exemplo n.º 12
0
        private void OnRefreshTasks(object sender, EventArgs e)
        {
            WorkflowView workflowView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;

            if (this.refreshTasksHandler != null)
            {
                if (workflowView != null)
                {
                    workflowView.Idle -= this.refreshTasksHandler;
                }
                this.refreshTasksHandler = null;
            }

            ISelectionService  selectionService  = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;
            IExtendedUIService extendedUIService = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;

            if (selectionService != null && extendedUIService != null)
            {
                extendedUIService.RemoveDesignerActions();

                //Only if the current designer is active designer we add the designer actions to the task list
                IDesignerEventService designerEventService = (IDesignerEventService)this.serviceProvider.GetService(typeof(IDesignerEventService));
                if (designerEventService != null && designerEventService.ActiveDesigner == this.serviceProvider.GetService(typeof(IDesignerHost)))
                {
                    foreach (object obj in selectionService.GetSelectedComponents())
                    {
                        ActivityDesigner activityDesigner = null;
                        if (obj is HitTestInfo)
                        {
                            activityDesigner = ((HitTestInfo)obj).AssociatedDesigner;
                        }
                        else if (obj is Activity)
                        {
                            activityDesigner = ActivityDesigner.GetDesigner(obj as Activity);
                        }

                        if (activityDesigner != null)
                        {
                            extendedUIService.AddDesignerActions(new List <DesignerAction>(activityDesigner.DesignerActions).ToArray());
                        }
                    }
                }
            }

            if (workflowView != null)
            {
                workflowView.Invalidate();
            }
        }
        /// <devdoc>
        ///     Visual Studio tells us that a project is going to be closed before it
        ///     begins closing document windows.  We must release type loaders at
        ///     project close, but this means that any unflushed designers won't
        ///     be able to get to their type loaders.  So flush all of them here.
        /// </devdoc>
        private void FlushAllOpenDesigners()
        {
            IDesignerEventService ds = (IDesignerEventService)GetService(typeof(IDesignerEventService));

            if (ds != null)
            {
                foreach (IDesignerHost host in ds.Designers)
                {
                    IVSMDDesigner designer = host as IVSMDDesigner;
                    if (designer != null)
                    {
                        designer.Flush();
                    }
                }
            }
        }
        private void OnRefreshTasks(object sender, EventArgs e)
        {
            WorkflowView view = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;

            if (this.refreshTasksHandler != null)
            {
                if (view != null)
                {
                    view.Idle -= this.refreshTasksHandler;
                }
                this.refreshTasksHandler = null;
            }
            ISelectionService  service  = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;
            IExtendedUIService service2 = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;

            if ((service != null) && (service2 != null))
            {
                service2.RemoveDesignerActions();
                IDesignerEventService service3 = (IDesignerEventService)this.serviceProvider.GetService(typeof(IDesignerEventService));
                if ((service3 != null) && (service3.ActiveDesigner == this.serviceProvider.GetService(typeof(IDesignerHost))))
                {
                    foreach (object obj2 in service.GetSelectedComponents())
                    {
                        ActivityDesigner associatedDesigner = null;
                        if (obj2 is HitTestInfo)
                        {
                            associatedDesigner = ((HitTestInfo)obj2).AssociatedDesigner;
                        }
                        else if (obj2 is Activity)
                        {
                            associatedDesigner = ActivityDesigner.GetDesigner(obj2 as Activity);
                        }
                        if (associatedDesigner != null)
                        {
                            service2.AddDesignerActions(new List <DesignerAction>(associatedDesigner.DesignerActions).ToArray());
                        }
                    }
                }
            }
            if (view != null)
            {
                view.Invalidate();
            }
        }
Exemplo n.º 15
0
        public WorkflowDesignerEventsCoordinator(IDesignerLoaderHost serviceProvider)
        {
            this.serviceProvider = serviceProvider;

            this.serviceProvider.LoadComplete += new EventHandler(OnDesignerReloaded);

            //Listen to the events so that we are sure that we appropriately refresh the designer actions and tasks when the types
            //change
            IDesignerEventService designerEventService = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService;

            if (designerEventService != null)
            {
                designerEventService.ActiveDesignerChanged += new ActiveDesignerEventHandler(OnActiveDesignerChanged);
            }

            ITypeProvider typeProvider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;

            if (typeProvider != null)
            {
                typeProvider.TypesChanged += new EventHandler(OnTypeSystemTypesChanged);
            }

            ISelectionService selectionService = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;

            if (selectionService != null)
            {
                selectionService.SelectionChanged += new EventHandler(OnSelectionChanged);
            }

            IComponentChangeService componentChangedService = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (componentChangedService != null)
            {
                componentChangedService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
            }

            IPropertyValueUIService propertyValueService = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService;

            if (propertyValueService != null)
            {
                propertyValueService.AddPropertyValueUIHandler(new PropertyValueUIHandler(OnPropertyGridAdornments));
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Remove SolutionListenerForProjectUpdates from collection of SolutionListeners as we do not support references
            SolutionListenerForProjectReferenceUpdate referenceUpdateListener = SolutionListeners.OfType <SolutionListenerForProjectReferenceUpdate>().SingleOrDefault();

            if (referenceUpdateListener != null)
            {
                referenceUpdateListener.Dispose();
                SolutionListeners.Remove(referenceUpdateListener);
            }

            // Find SolutionListenerForProjectEvents and subscribe to OnBeforeProjectClosed
            SolutionListenerForProjectEvents projectEventListener = SolutionListeners.OfType <SolutionListenerForProjectEvents>().SingleOrDefault();

            if (projectEventListener != null)
            {
                projectEventListener.BeforeProjectFileClosed += new EventHandler <BeforeProjectFileClosedEventArgs>(OnBeforeProjectFileClosed);
            }

            // Hook designer event services
            IDesignerEventService eventService = (IDesignerEventService)GetService(typeof(IDesignerEventService));

            eventService.DesignerCreated += new DesignerEventHandler(OnDesignerCreated);

            // Hook ToolboxInitialized event
            this.ToolboxInitialized += new EventHandler(OnToolboxInitialized);
            this.ToolboxUpgraded    += new EventHandler(OnToolboxUpgraded);

            // Add menu handlers
            this.AddMenuHandlers();

            // Create settings service
            AddonStudioSettings settings = new AddonStudioSettings(this);

            // Add service
            this.AddService(typeof(IInterfaceStudioSettings), settings);

            // Register the WoW project factory
            base.RegisterProjectFactory(new MultiverseInterfaceProjectFactory(this));
        }
Exemplo n.º 17
0
        private void StopMonitoring(object sender, EventArgs e)
        {
            IDesignerEventService des = (IDesignerEventService)this.Control.Site.GetService(typeof(IDesignerEventService));

            if (des == null)
            {
                return;
            }

            // Remove event handlers for event notification methods.
            des.DesignerCreated       -= new DesignerEventHandler(this.DesignerCreated);
            des.DesignerDisposed      -= new DesignerEventHandler(this.DesignerDisposed);
            des.ActiveDesignerChanged -= new ActiveDesignerEventHandler(this.DesignerChanged);
            des.SelectionChanged      -= new EventHandler(this.SelectionChanged);

            dm.monitoring_events = false;
            // Rebuild menu with "Start monitoring" command.
            dvc = new DesignerVerbCollection(new DesignerVerb[] {
                new DesignerVerb("Start monitoring", new EventHandler(this.StartMonitoring))
            });
            dm.Refresh();
        }
Exemplo n.º 18
0
        private IEventBindingService GetEventPropertyService(object obj, ITypeDescriptorContext context)
        {
            IEventBindingService eventPropertySvc = null;

            if (!sunkEvent)
            {
                IDesignerEventService des = (IDesignerEventService)sp.GetService(typeof(IDesignerEventService));

                Debug.Assert(des != null, "Unable to get DesignerEventService for EventsTab");

                if (des != null)
                {
                    des.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
                }
                sunkEvent = true;
            }

            if (eventPropertySvc == null && currentHost != null)
            {
                eventPropertySvc = (IEventBindingService)currentHost.GetService(typeof(IEventBindingService));
            }

            if (eventPropertySvc == null && obj is IComponent)
            {
                ISite site = ((IComponent)obj).Site;

                if (site != null)
                {
                    eventPropertySvc = (IEventBindingService)site.GetService(typeof(IEventBindingService));
                }
            }

            if (eventPropertySvc == null && context != null)
            {
                eventPropertySvc = (IEventBindingService)context.GetService(typeof(IEventBindingService));
            }
            return(eventPropertySvc);
        }
 //<Snippet1>
 public void LinkDesignerEvent(IDesignerEventService eventService)
 {
     // Registers an event handler for the DesignerCreated and DesignerDisposed events.
     eventService.DesignerCreated  += new DesignerEventHandler(this.OnDesignerEvent);
     eventService.DesignerDisposed += new DesignerEventHandler(this.OnDesignerEvent);
 }
Exemplo n.º 20
0
 private void EnsureDesignerEventService() {
     if (GetFlag(GotDesignerEventService)) {
         return;
     }
     designerEventService = (IDesignerEventService)GetService(typeof(IDesignerEventService));
     if (designerEventService != null) {
         SetFlag(GotDesignerEventService, true);
         designerEventService.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
         OnActiveDesignerChanged(null, new ActiveDesignerEventArgs(null, designerEventService.ActiveDesigner));
     }
 }
Exemplo n.º 21
0
        /// <include file='doc\PropertyGrid.uex' path='docs/doc[@for="PropertyGrid.Dispose"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected override void Dispose(bool disposing) {

            if (disposing) {
                // Unhook IDesignerEventService.ActiveDesignerChanged event
                //
                if (GetFlag(GotDesignerEventService)) {                
                    Debug.Assert(designerEventService != null, "GetFlag(GotDesignerEventService) inconsistent with designerEventService == null");
                    if (designerEventService != null) {
                        designerEventService.ActiveDesignerChanged -= new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
                    }                
                    designerEventService = null;
                    SetFlag(GotDesignerEventService, false);
                }
                this.ActiveDesigner = null;

                if (viewTabs != null) {
                    for (int i = 0; i < viewTabs.Length; i++) {
                        viewTabs[i].Dispose();
                    }
                    viewTabs = null;
                }

                if (imageList != null) {
                    for (int i = 0; i < imageList.Length; i++) {
                        if(imageList[i] != null) {
                            imageList[i].Dispose();
                        }
                    }
                    imageList = null;
                }

                if (bmpAlpha != null) {
                    bmpAlpha.Dispose();
                    bmpAlpha = null;
                }
                
                if (bmpCategory != null) {
                    bmpCategory.Dispose();
                    bmpCategory = null;
                }
                
                if (bmpPropPage != null) {
                    bmpPropPage.Dispose();
                    bmpPropPage = null;
                }
           
                if (lineBrush != null) {
                    lineBrush.Dispose();
                    lineBrush = null;
                }

                if (peMain != null) {
                    peMain.Dispose();
                    peMain = null;
                }

                if (currentObjects != null) {
                    currentObjects = null;
                    SinkPropertyNotifyEvents();
                }

                ClearCachedProps();
                currentPropEntries = null;            
            }

            base.Dispose(disposing);
        }
 internal void BeginLoad(DesignerLoader loader)
 {
     if ((this._loader != null) && (this._loader != loader))
     {
         Exception exception = new InvalidOperationException(System.Design.SR.GetString("DesignerHostLoaderSpecified")) {
             HelpLink = "DesignerHostLoaderSpecified"
         };
         throw exception;
     }
     IDesignerEventService service = null;
     bool flag = this._loader != null;
     this._loader = loader;
     if (!flag)
     {
         if (loader is IExtenderProvider)
         {
             IExtenderProviderService service2 = this.GetService(typeof(IExtenderProviderService)) as IExtenderProviderService;
             if (service2 != null)
             {
                 service2.AddExtenderProvider((IExtenderProvider) loader);
             }
         }
         service = this.GetService(typeof(IDesignerEventService)) as IDesignerEventService;
         if (service != null)
         {
             service.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
             this._designerEventService = service;
         }
     }
     this._state[StateLoading] = true;
     this._surface.OnLoading();
     try
     {
         this._loader.BeginLoad(this);
     }
     catch (Exception innerException)
     {
         if (innerException is TargetInvocationException)
         {
             innerException = innerException.InnerException;
         }
         string message = innerException.Message;
         if ((message == null) || (message.Length == 0))
         {
             innerException = new Exception(System.Design.SR.GetString("DesignSurfaceFatalError", new object[] { innerException.ToString() }), innerException);
         }
         ((IDesignerLoaderHost) this).EndLoad(null, false, new object[] { innerException });
     }
     if (this._designerEventService == null)
     {
         this.OnActiveDesignerChanged(null, new ActiveDesignerEventArgs(null, this));
     }
 }
 private void EnsureDesignerEventService()
 {
     if (!this.GetFlag(2))
     {
         this.designerEventService = (IDesignerEventService) this.GetService(typeof(IDesignerEventService));
         if (this.designerEventService != null)
         {
             this.SetFlag(2, true);
             this.designerEventService.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
             this.OnActiveDesignerChanged(null, new ActiveDesignerEventArgs(null, this.designerEventService.ActiveDesigner));
         }
     }
 }
 internal DesignerCreationListener(IDesignerEventService designerEvents, Options options)
 {
     designerEvents.DesignerCreated += (s, e) => e.Designer.LoadComplete += OnDesignerLoaded;
     _options = options;
 }
Exemplo n.º 25
0
    // </snippet6>

    // <snippet7>
    // This utility method connects the designer to various
    // services it will use.
    private void InitializeServices()
    {
        // Acquire a reference to DesignerActionService.
        this.actionService =
            GetService(typeof(DesignerActionService))
            as DesignerActionService;

        // Acquire a reference to DesignerActionUIService.
        this.actionUiService =
            GetService(typeof(DesignerActionUIService))
            as DesignerActionUIService;

        // Acquire a reference to IComponentChangeService.
        this.changeService =
            GetService(typeof(IComponentChangeService))
            as IComponentChangeService;

        // <snippet14>
        // Hook the IComponentChangeService events.
        if (this.changeService != null)
        {
            this.changeService.ComponentChanged +=
                new ComponentChangedEventHandler(
                    ChangeService_ComponentChanged);

            this.changeService.ComponentAdded +=
                new ComponentEventHandler(
                    ChangeService_ComponentAdded);

            this.changeService.ComponentRemoved +=
                new ComponentEventHandler(
                    changeService_ComponentRemoved);
        }
        // </snippet14>

        // Acquire a reference to ISelectionService.
        this.selectionService =
            GetService(typeof(ISelectionService))
            as ISelectionService;

        // Hook the SelectionChanged event.
        if (this.selectionService != null)
        {
            this.selectionService.SelectionChanged +=
                new EventHandler(selectionService_SelectionChanged);
        }

        // Acquire a reference to IDesignerEventService.
        this.eventService =
            GetService(typeof(IDesignerEventService))
            as IDesignerEventService;

        if (this.eventService != null)
        {
            this.eventService.ActiveDesignerChanged +=
                new ActiveDesignerEventHandler(
                    eventService_ActiveDesignerChanged);
        }

        // Acquire a reference to IDesignerHost.
        this.host =
            GetService(typeof(IDesignerHost))
            as IDesignerHost;

        // Acquire a reference to IDesignerOptionService.
        this.optionService =
            GetService(typeof(IDesignerOptionService))
            as IDesignerOptionService;

        // Acquire a reference to IEventBindingService.
        this.eventBindingService =
            GetService(typeof(IEventBindingService))
            as IEventBindingService;

        // Acquire a reference to IExtenderListService.
        this.listService =
            GetService(typeof(IExtenderListService))
            as IExtenderListService;

        // Acquire a reference to IReferenceService.
        this.referenceService =
            GetService(typeof(IReferenceService))
            as IReferenceService;

        // Acquire a reference to ITypeResolutionService.
        this.typeResService =
            GetService(typeof(ITypeResolutionService))
            as ITypeResolutionService;

        // Acquire a reference to IComponentDiscoveryService.
        this.componentDiscoveryService =
            GetService(typeof(IComponentDiscoveryService))
            as IComponentDiscoveryService;

        // Acquire a reference to IToolboxService.
        this.toolboxService =
            GetService(typeof(IToolboxService))
            as IToolboxService;

        // Acquire a reference to UndoEngine.
        this.undoEng =
            GetService(typeof(UndoEngine))
            as UndoEngine;

        if (this.undoEng != null)
        {
            MessageBox.Show("UndoEngine");
        }
    }
 //<Snippet1>
 public void LinkActiveDesignerEvent(IDesignerEventService eventService)
 {
     // Registers an event handler for the ActiveDesignerChanged event.
     eventService.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerEvent);
 }
 internal DesignerCreationListener(IDesignerEventService designerEvents, Options options)
 {
     designerEvents.DesignerCreated += (s, e) => e.Designer.LoadComplete += OnDesignerLoaded;
     _options = options;
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.GetFlag(2))
         {
             if (this.designerEventService != null)
             {
                 this.designerEventService.ActiveDesignerChanged -= new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
             }
             this.designerEventService = null;
             this.SetFlag(2, false);
         }
         this.ActiveDesigner = null;
         if (this.viewTabs != null)
         {
             for (int i = 0; i < this.viewTabs.Length; i++)
             {
                 this.viewTabs[i].Dispose();
             }
             this.viewTabs = null;
         }
         if (this.imageList != null)
         {
             for (int j = 0; j < this.imageList.Length; j++)
             {
                 if (this.imageList[j] != null)
                 {
                     this.imageList[j].Dispose();
                 }
             }
             this.imageList = null;
         }
         if (this.bmpAlpha != null)
         {
             this.bmpAlpha.Dispose();
             this.bmpAlpha = null;
         }
         if (this.bmpCategory != null)
         {
             this.bmpCategory.Dispose();
             this.bmpCategory = null;
         }
         if (this.bmpPropPage != null)
         {
             this.bmpPropPage.Dispose();
             this.bmpPropPage = null;
         }
         if (this.lineBrush != null)
         {
             this.lineBrush.Dispose();
             this.lineBrush = null;
         }
         if (this.peMain != null)
         {
             this.peMain.Dispose();
             this.peMain = null;
         }
         if (this.currentObjects != null)
         {
             this.currentObjects = null;
             this.SinkPropertyNotifyEvents();
         }
         this.ClearCachedProps();
         this.currentPropEntries = null;
     }
     base.Dispose(disposing);
 }