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

            if (service != null)
            {
                service.OnCreateDesigner(surface);
            }
            return(surface);
        }
        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);
        }
Пример #3
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);
        }