public DesignSurface CreateDesignSurface()
        {
            DesignSurface        surface = this.CreateDesignSurfaceCore(this);
            DesignerEventService service = this.GetService(typeof(IDesignerEventService)) as DesignerEventService;

            if (service != null)
            {
                service.OnCreateDesigner(surface);
            }
            return(surface);
        }
        private void OnSelectionChanged(object sender, EventArgs args)
        {
            if (SelectionChanged != null)
            {
                SelectionChanged(this, EventArgs.Empty);
            }

            DesignerEventService eventService = GetService(typeof(IDesignerEventService)) as DesignerEventService;

            if (eventService != null)
            {
                eventService.RaiseSelectionChanged();
            }
        }
        public DesignSurface CreateDesignSurface(IServiceProvider parentProvider)
        {
            if (parentProvider == null)
            {
                throw new ArgumentNullException("parentProvider");
            }
            IServiceProvider     provider = new MergedServiceProvider(parentProvider, this);
            DesignSurface        surface  = this.CreateDesignSurfaceCore(provider);
            DesignerEventService service  = this.GetService(typeof(IDesignerEventService)) as DesignerEventService;

            if (service != null)
            {
                service.OnCreateDesigner(surface);
            }
            return(surface);
        }
        private void OnDesignSurfaceCreated(DesignSurface surface)
        {
            if (DesignSurfaceCreated != null)
            {
                DesignSurfaceCreated(this, new DesignSurfaceEventArgs(surface));
            }

            // monitor disposing
            surface.Disposed += new EventHandler(OnDesignSurfaceDisposed);

            DesignerEventService eventService = GetService(typeof(IDesignerEventService)) as DesignerEventService;

            if (eventService != null)
            {
                eventService.RaiseDesignerCreated(surface.GetService(typeof(IDesignerHost)) as IDesignerHost);
            }
        }
        private void OnDesignSurfaceDisposed(object sender, EventArgs args)
        {
            DesignSurface surface = (DesignSurface)sender;

            surface.Disposed -= new EventHandler(OnDesignSurfaceDisposed);

            if (DesignSurfaceDisposed != null)
            {
                DesignSurfaceDisposed(this, new DesignSurfaceEventArgs(surface));
            }

            DesignerEventService eventService = GetService(typeof(IDesignerEventService)) as DesignerEventService;

            if (eventService != null)
            {
                eventService.RaiseDesignerDisposed(surface.GetService(typeof(IDesignerHost)) as IDesignerHost);
            }
        }
Example #6
0
        /// <summary>
        ///  Public method to create a design surface.  This method
        ///  takes an additional service provider.  This service
        ///  provider will be combined with the service provider
        ///  already contained within DesignSurfaceManager.  Service
        ///  requests will go to this provider first, and then bubble
        ///  up to the service provider owned by DesignSurfaceManager.
        ///  This allows for services to be tailored for each design surface.
        /// </summary>
        public DesignSurface CreateDesignSurface(IServiceProvider parentProvider)
        {
            ArgumentNullException.ThrowIfNull(parentProvider);

            IServiceProvider mergedProvider = new MergedServiceProvider(parentProvider, this);

            DesignSurface surface = CreateDesignSurfaceCore(mergedProvider);

            // If we are providing IDesignerEventService, then we are responsible for
            // notifying it of new designers coming into place.  If we aren't
            // the ones providing the event service, then whoever is providing
            // it will be responsible for updating it when new designers are created.
            DesignerEventService eventService = GetService(typeof(IDesignerEventService)) as DesignerEventService;

            if (eventService is not null)
            {
                eventService.OnCreateDesigner(surface);
            }

            return(surface);
        }