Beispiel #1
0
        private void ParentContainerInvalid()
        {
            // MessageBox.Show("ParentContainerInvalid call");
            if (null != _parentContainer && _ds == _parentContainer.DeviceSpecific)
            {
                _parentContainer.DeviceSpecific = null;

                // container's enabled deviceSpecific control is deleted.
                // another disabled deviceSpecific child may need to be enabled.
                foreach (System.Web.UI.Control control in _parentContainer.Controls)
                {
                    if (control is DeviceSpecific && control != _ds)
                    {
                        // found a valid candidate
                        DeviceSpecific newDS = (DeviceSpecific)control;
                        if (newDS.Site != null)
                        {
                            IDesignerHost host = (IDesignerHost)newDS.Site.GetService(typeof(IDesignerHost));
                            Debug.Assert(host != null, "host is null in DeviceSpecificDesigner");
                            IDesigner designer = host.GetDesigner((IComponent)newDS);

                            // this designer could be null if the page is disposing the controls (Page.Dispose).
                            if (designer != null)
                            {
                                _parentContainer.DeviceSpecific = newDS;
                                DeviceSpecificDesigner dsd = (DeviceSpecificDesigner)designer;
                                dsd.TreatAsDuplicate(false);
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public override void OnSetParent()
        {
            // MessageBox.Show("OnSetParent call for _ds.Site.Name=" + _ds.Site.Name + ", _ds.ID=" + _ds.ID);
            base.OnSetParent();

            Debug.Assert(_ds.Parent != null, "_ds.Parent is null");

            if (null != _parentContainer)
            {
                ParentContainerInvalid();
            }

            System.Web.UI.Control parentContainer = _ds.Parent;

            if (parentContainer is System.Web.UI.MobileControls.Panel)
            {
                _parentContainer = (System.Web.UI.MobileControls.Panel)parentContainer;
                _ds.SetOwner(_parentContainer);

                if (null != _parentContainer.DeviceSpecific &&
                    0 != String.Compare(_ds.ID, _parentContainer.DeviceSpecific.ID, StringComparison.OrdinalIgnoreCase))
                {
                    // the parent container already has a deviceSpecific child.
                    // this instance is a duplicate and needs to update its rendering.
                    // MessageBox.Show("OnSetParent - this instance is a duplicate");
                    TreatAsDuplicate(true);

                    // the current valid DeviceSpecific is intentionaly refreshed because
                    // if this deviceSpecific instance is recreated via a Undo operation
                    // the current valid DeviceSpecific appears as a duplicate if not refreshed.
                    IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
                    Debug.Assert(host != null, "Did not get a valid IDesignerHost reference");
                    IDesigner designer = host.GetDesigner((IComponent)_parentContainer.DeviceSpecific);
                    Debug.Assert(designer != null, "designer is null in DeviceSpecificDesigner");
                    DeviceSpecificDesigner dsd = (DeviceSpecificDesigner)designer;
                    dsd.UpdateRendering();
                }
                else
                {
                    // MessageBox.Show("OnSetParent - this instance becomes the valid ds");
                    _parentContainer.DeviceSpecific = _ds;
                    if (_isDuplicate)
                    {
                        TreatAsDuplicate(false);
                    }
                }
            }
            else
            {
                _parentContainer = null;
            }

            // Invalidate the type descriptor so that the PropertyOverrides
            // property browsable status gets updated
            TypeDescriptor.Refresh(Component);
        }