Exemple #1
0
 public override void Initialize(System.ComponentModel.IComponent component)
 {
     base.Initialize(component);
     canParentProvider = new CanParentProvider(this);
     dragDropHandler   = new DragDropHandler((Control)component, this.BehaviorService, (IDesignerHost)this.GetService(typeof(IDesignerHost)));
 }
Exemple #2
0
        /// <include file="doc\FormDocumentDesigner.uex" path='docs/doc[@for="FormDocumentDesigner.Initialize"]/*'>

        /// <devdoc>

        ///     Initializes the designer with the given component.  The designer can

        ///     get the component's site and request services from it in this call.

        /// </devdoc>

        public override void Initialize(IComponent component)
        {
            // We have to shadow the WindowState before we call base.Initialize

            PropertyDescriptor windowStateProp = TypeDescriptor.GetProperties(component.GetType())["WindowState"];

            if (windowStateProp != null && windowStateProp.PropertyType == typeof(FormWindowState))
            {
                WindowState = (FormWindowState)windowStateProp.GetValue(component);
            }



            initializing = true;

            base.Initialize(component);

            initializing = false;



            AutoResizeHandles = true;



            Debug.Assert(component is Form, "FormDocumentDesigner expects its component to be a form.");



            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (host != null)
            {
                host.LoadComplete += new EventHandler(OnLoadComplete);

                host.Activated += new EventHandler(OnDesignerActivate);

                host.Deactivated += new EventHandler(OnDesignerDeactivate);
            }



            Form form = (Form)Control;

            form.WindowState = FormWindowState.Normal;

            ShadowProperties["AcceptButton"] = form.AcceptButton;

            ShadowProperties["CancelButton"] = form.CancelButton;



            // Monitor component/remove add events for our tray

            //

            IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            if (cs != null)
            {
                cs.ComponentAdded += new ComponentEventHandler(this.OnComponentAdded);

                cs.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
            }

            canParentProvider = new CanParentProvider(this);
            dragDropHandler   = new DragDropHandler((Control)component, this.BehaviorService, (IDesignerHost)this.GetService(typeof(IDesignerHost)));
        }