public override void Initialize(IComponent component)
        {
            base.Initialize(component);
            base.AutoResizeHandles = true;
            ExtendedTabControl control = component as ExtendedTabControl;
            ISelectionService  service = (ISelectionService)this.GetService(typeof(ISelectionService));

            if (service != null)
            {
                service.SelectionChanged += new EventHandler(this.OnSelectionChanged);
            }
            IComponentChangeService service2 = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));

            if (service2 != null)
            {
                service2.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
            }
            if (control != null)
            {
                control.SelectedIndexChanged     += new EventHandler(this.OnTabSelectedIndexChanged);
                control.GotFocus                 += new EventHandler(this.OnGotFocus);
                control.RightToLeftLayoutChanged += new EventHandler(this.OnRightToLeftLayoutChanged);
                control.ControlAdded             += new ControlEventHandler(this.OnControlAdded);
            }
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         ISelectionService service = (ISelectionService)this.GetService(typeof(ISelectionService));
         if (service != null)
         {
             service.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
         }
         IComponentChangeService service2 = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
         if (service2 != null)
         {
             service2.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
         }
         ExtendedTabControl control = this.Control as ExtendedTabControl;
         if (control != null)
         {
             control.SelectedIndexChanged     -= new EventHandler(this.OnTabSelectedIndexChanged);
             control.GotFocus                 -= new EventHandler(this.OnGotFocus);
             control.RightToLeftLayoutChanged -= new EventHandler(this.OnRightToLeftLayoutChanged);
             control.ControlAdded             -= new ControlEventHandler(this.OnControlAdded);
         }
     }
     base.Dispose(disposing);
 }
        private void OnSelectionChanged(object sender, EventArgs e)
        {
            ISelectionService service = (ISelectionService)this.GetService(typeof(ISelectionService));

            this.tabControlSelected = false;
            if (service != null)
            {
                ICollection        selectedComponents = service.GetSelectedComponents();
                ExtendedTabControl component          = (ExtendedTabControl)base.Component;
                foreach (object obj2 in selectedComponents)
                {
                    if (obj2 == component)
                    {
                        this.tabControlSelected = true;
                    }
                    ExtendedTabPage tabPageOfComponent = GetTabPageOfComponent(obj2);
                    if ((tabPageOfComponent != null) && (tabPageOfComponent.Parent == component))
                    {
                        this.tabControlSelected = false;
                        component.SelectedTab   = tabPageOfComponent;
                        break;
                    }
                }
            }
        }
        protected override bool GetHitTest(Point point)
        {
            ExtendedTabControl control = (ExtendedTabControl)this.Control;

            if (this.tabControlSelected)
            {
                Point pt = this.Control.PointToClient(point);
                return(!control.DisplayRectangle.Contains(pt));
            }
            return(false);
        }
        protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize)
        {
            ExtendedTabControl control = (ExtendedTabControl)this.Control;

            if (control.SelectedTab == null)
            {
                throw new ArgumentException("Only ExtendedTabPages can be placed in ExtendedTabControls.");
            }
            IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (service != null)
            {
                ExtendedTabPageDesigner toInvoke = (ExtendedTabPageDesigner)service.GetDesigner(control.SelectedTab);
                ParentControlDesigner.InvokeCreateTool(toInvoke, tool);
            }
            return(null);
        }
        private void OnRemove(object sender, EventArgs eevent)
        {
            ExtendedTabControl component = (ExtendedTabControl)base.Component;

            if ((component != null) && (component.TabPages.Count != 0))
            {
                MemberDescriptor member      = TypeDescriptor.GetProperties(base.Component)["Controls"];
                ExtendedTabPage  selectedTab = component.SelectedTab;
                IDesignerHost    service     = (IDesignerHost)this.GetService(typeof(IDesignerHost));
                if (service != null)
                {
                    DesignerTransaction transaction = null;
                    try
                    {
                        try
                        {
                            transaction = service.CreateTransaction("TabControlRemoveTab");
                            base.RaiseComponentChanging(member);
                        }
                        catch (CheckoutException exception)
                        {
                            if (exception != CheckoutException.Canceled)
                            {
                                throw exception;
                            }
                            return;
                        }
                        service.DestroyComponent(selectedTab);
                        base.RaiseComponentChanged(member, null, null);
                    }
                    finally
                    {
                        if (transaction != null)
                        {
                            transaction.Commit();
                        }
                    }
                }
            }
        }
        private void OnTabSelectedIndexChanged(object sender, EventArgs e)
        {
            ISelectionService service = (ISelectionService)this.GetService(typeof(ISelectionService));

            if (service != null)
            {
                ICollection        selectedComponents = service.GetSelectedComponents();
                ExtendedTabControl component          = (ExtendedTabControl)base.Component;
                bool flag = false;
                foreach (object obj2 in selectedComponents)
                {
                    ExtendedTabPage tabPageOfComponent = GetTabPageOfComponent(obj2);
                    if (((tabPageOfComponent != null) && (tabPageOfComponent.Parent == component)) && (tabPageOfComponent == component.SelectedTab))
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    service.SetSelectedComponents(new object[] { base.Component });
                }
            }
        }
 protected override void OnDragOver(DragEventArgs de)
 {
     if (this.forwardOnDrag)
     {
         ExtendedTabControl control = (ExtendedTabControl)this.Control;
         Point pt = this.Control.PointToClient(new Point(de.X, de.Y));
         if (!control.DisplayRectangle.Contains(pt))
         {
             de.Effect = DragDropEffects.None;
         }
         else
         {
             ExtendedTabPageDesigner selectedTabPageDesigner = this.GetSelectedTabPageDesigner();
             if (selectedTabPageDesigner != null)
             {
                 selectedTabPageDesigner.OnDragOverInternal(de);
             }
         }
     }
     else
     {
         base.OnDragOver(de);
     }
 }
        public override void InitializeNewComponent(IDictionary defaultValues)
        {
            base.InitializeNewComponent(defaultValues);
            try
            {
                this.addingOnInitialize = true;
                this.OnAdd(this, EventArgs.Empty);
                this.OnAdd(this, EventArgs.Empty);
            }
            finally
            {
                this.addingOnInitialize = false;
            }
            MemberDescriptor member = TypeDescriptor.GetProperties(base.Component)["Controls"];

            base.RaiseComponentChanging(member);
            base.RaiseComponentChanged(member, null, null);
            ExtendedTabControl component = (ExtendedTabControl)base.Component;

            if (component != null)
            {
                component.SelectedIndex = 0;
            }
        }
Exemplo n.º 10
0
        private void OnAdd(object sender, EventArgs eevent)
        {
            ExtendedTabControl component = (ExtendedTabControl)base.Component;
            IDesignerHost      service   = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (service != null)
            {
                DesignerTransaction transaction = null;
                try
                {
                    try
                    {
                        transaction = service.CreateTransaction("TabControlAddTab");
                    }
                    catch (CheckoutException exception)
                    {
                        if (exception != CheckoutException.Canceled)
                        {
                            throw exception;
                        }
                        return;
                    }
                    MemberDescriptor member = TypeDescriptor.GetProperties(component)["Controls"];
                    ExtendedTabPage  page   = (ExtendedTabPage)service.CreateComponent(typeof(ExtendedTabPage));
                    if (!this.addingOnInitialize)
                    {
                        base.RaiseComponentChanging(member);
                    }
                    page.Padding = new Padding(3);
                    string             str         = null;
                    PropertyDescriptor descriptor2 = TypeDescriptor.GetProperties(page)["Name"];
                    if ((descriptor2 != null) && (descriptor2.PropertyType == typeof(string)))
                    {
                        str = (string)descriptor2.GetValue(page);
                    }
                    if (str != null)
                    {
                        PropertyDescriptor descriptor3 = TypeDescriptor.GetProperties(page)["Text"];
                        if (descriptor3 != null)
                        {
                            descriptor3.SetValue(page, str);
                        }
                    }
                    PropertyDescriptor descriptor4 = TypeDescriptor.GetProperties(page)["UseVisualStyleBackColor"];
                    if (((descriptor4 != null) && (descriptor4.PropertyType == typeof(bool))) && (!descriptor4.IsReadOnly && descriptor4.IsBrowsable))
                    {
                        descriptor4.SetValue(page, true);
                    }
                    component.Controls.Add(page);
                    component.SelectedIndex = component.TabCount - 1;
                    if (!this.addingOnInitialize)
                    {
                        base.RaiseComponentChanged(member, null, null);
                    }
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }