예제 #1
0
        protected bool IsItemContainerSupported(ToolboxItemContainer container, IDesignerHost host)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            ICollection creatorCollection = this.GetCreatorCollection(host);

            this._lastState = host.GetService(typeof(DesignerToolboxInfo)) as DesignerToolboxInfo;
            if (this._lastState == null)
            {
                this._lastState = new DesignerToolboxInfo(this, host);
                host.AddService(typeof(DesignerToolboxInfo), this._lastState);
            }
            switch (GetFilterSupport(container.GetFilter(creatorCollection), this._lastState.Filter))
            {
            case FilterSupport.NotSupported:
                return(false);

            case FilterSupport.Supported:
                return(true);

            case FilterSupport.Custom:
                if (this._lastState.ToolboxUser == null)
                {
                    break;
                }
                return(this._lastState.ToolboxUser.GetToolSupported(container.GetToolboxItem(creatorCollection)));
            }
            return(false);
        }