private bool SelectCompnentMouseDownTC(TabButtonContainerItem ribbonTabButtonContainerItem, Point point)
 {
     if (ribbonTabButtonContainerItem == null || !ribbonTabButtonContainerItem.Visible)
     {
         return(false);
     }
     //
     foreach (BaseItem one in ribbonTabButtonContainerItem.BaseItems)
     {
         TabButtonItem tabButtonItem = one as TabButtonItem;
         if (tabButtonItem == null)
         {
             continue;
         }
         if (tabButtonItem.DesignMouseClickRectangleContainsEx(point))
         {
             ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
             if (pSelectionService != null)
             {
                 this.m_Item1 = tabButtonItem;
                 TabPage ribbonPage = tabButtonItem.pTabPageItem as TabPage;
                 if (ribbonPage != null)
                 {
                     pSelectionService.SetSelectedComponents(new Component[] { ribbonPage as Component }, SelectionTypes.Primary);
                     this.m_TabControl.Refresh();
                 }
                 this.m_TabControl.TabPageSelectedIndex = ribbonTabButtonContainerItem.BaseItems.IndexOf(tabButtonItem);
                 //
                 return(true);
             }
         }
     }
     //
     if (ribbonTabButtonContainerItem.PreButtonVisible &&
         ribbonTabButtonContainerItem.PreButtonRectangle.Contains(point))
     {
         if (ribbonTabButtonContainerItem.PreButtonIncreaseIndex)
         {
             ribbonTabButtonContainerItem.TopViewItemIndex++;
         }
         else
         {
             ribbonTabButtonContainerItem.TopViewItemIndex--;
         }
     }
     if (ribbonTabButtonContainerItem.NextButtonVisible &&
         ribbonTabButtonContainerItem.NextButtonRectangle.Contains(point))
     {
         if (ribbonTabButtonContainerItem.PreButtonIncreaseIndex)
         {
             ribbonTabButtonContainerItem.TopViewItemIndex--;
         }
         else
         {
             ribbonTabButtonContainerItem.TopViewItemIndex++;
         }
     }
     //
     return(false);
 }
 private bool SelectCompnentMouseUpTC(TabButtonContainerItem ribbonTabButtonContainerItem, Point point)
 {
     if (ribbonTabButtonContainerItem == null || !ribbonTabButtonContainerItem.Visible)
     {
         return(false);
     }
     //
     foreach (BaseItem one in ribbonTabButtonContainerItem.BaseItems)
     {
         TabButtonItem tabButtonItem = one as TabButtonItem;
         if (tabButtonItem == null)
         {
             continue;
         }
         if (tabButtonItem.DesignMouseClickRectangleContainsEx(point))
         {
             ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
             if (pSelectionService != null)
             {
                 this.m_Item2 = tabButtonItem;
                 if (ribbonTabButtonContainerItem.BaseItems.ExchangeItem(this.m_Item1, this.m_Item2))
                 {
                     TabButtonItem tabButton = this.m_Item1 as TabButtonItem;
                     if (tabButton != null)
                     {
                         TabPage ribbonPage = tabButton.pTabPageItem as TabPage;
                         if (ribbonPage != null)
                         {
                             pSelectionService.SetSelectedComponents(new Component[] { ribbonPage as Component }, SelectionTypes.Primary);
                             this.m_TabControl.Refresh();
                         }
                     }
                     return(true);
                 }
                 else
                 {
                     TabPage ribbonPage = tabButtonItem.pTabPageItem as TabPage;
                     if (ribbonPage != null)
                     {
                         pSelectionService.SetSelectedComponents(new Component[] { ribbonPage as Component }, SelectionTypes.Primary);
                         this.m_TabControl.Refresh();
                     }
                     return(true);
                 }
             }
         }
     }
     //
     return(false);
 }
        private bool SelectCompnentMouseUp_DG(IUICollectionItem pUICollectionItem, Point point)
        {
            if (pUICollectionItem == null)
            {
                return(false);
            }
            if (!((IBaseItem)pUICollectionItem).Visible)
            {
                return(false);
            }
            //
            bool bIsCanvasItem             = pUICollectionItem is ICanvasItem;
            bool bIsTabButtonContainerItem = pUICollectionItem is ITabButtonContainerItem;

            //
            foreach (BaseItem one in pUICollectionItem.BaseItems)
            {
                if (this.SelectCompnentMouseUp_DG(one as IUICollectionItem, point))
                {
                    return(true);
                }
                //
                if (!bIsCanvasItem)
                {
                    if (one.DesignMouseClickRectangleContainsEx(point))
                    {
                        ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                        if (pSelectionService != null)
                        {
                            if (bIsTabButtonContainerItem && one is TabButtonItem)
                            {
                                TabButtonItem tabButtonItem = (TabButtonItem)one;
                                this.m_Item2 = tabButtonItem;
                                ITabButtonContainerItem pTabButtonContainerItem = (ITabButtonContainerItem)pUICollectionItem;
                                if (pTabButtonContainerItem.BaseItems.ExchangeItemT(this.m_Item1, this.m_Item2))
                                {
                                    RibbonPageTabButtonItem tabButton = this.m_Item1 as RibbonPageTabButtonItem;
                                    if (tabButton != null)
                                    {
                                        BaseItem tabPageItem = tabButtonItem.pTabPageItem as BaseItem;
                                        if (tabPageItem != null)
                                        {
                                            if (this.SetSelectedComponents(pSelectionService, tabPageItem))
                                            {
                                                this.m_Control.Refresh();
                                            }
                                        }
                                    }
                                    return(true);
                                }
                                else
                                {
                                    RibbonPageItem ribbonPage = tabButtonItem.pTabPageItem as RibbonPageItem;
                                    if (ribbonPage != null)
                                    {
                                        if (this.SetSelectedComponents(pSelectionService, ribbonPage))
                                        {
                                            this.m_Control.Refresh();
                                        }
                                    }
                                    return(true);
                                }
                            }
                            else
                            {
                                this.m_Item2 = one;
                                if (pUICollectionItem.BaseItems.ExchangeItem(this.m_Item1, this.m_Item2))
                                {
                                    if (this.SetSelectedComponents(pSelectionService, this.m_Item1))
                                    {
                                        this.m_Control.Refresh();
                                    }
                                    return(true);
                                }
                                else
                                {
                                    this.m_Control.Refresh();
                                    if (this.SetSelectedComponents(pSelectionService, one))
                                    {
                                        this.m_Control.Refresh();
                                    }
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            //
            if (bIsCanvasItem)
            {
                if (this.m_Item1 != null)
                {
                    if (this.m_MouseDownPoint != Point.Empty)
                    {
                        ISetBaseItemHelper pSetBaseItemHelper = this.m_Item1 as ISetBaseItemHelper;
                        if (pSetBaseItemHelper != null)
                        {
                            int iX = point.X - this.m_MouseDownPoint.X;
                            int iY = point.Y - this.m_MouseDownPoint.Y;
                            pSetBaseItemHelper.SetLocation(this.m_Item1.Location.X + iX, this.m_Item1.Location.Y + iY);
                            this.Translation_DG(this.m_Item1 as CanvasItem, iX, iY);
                            this.m_MouseDownPoint = Point.Empty;
                            this.m_Control.Refresh();
                        }
                    }
                    //
                    ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                    if (pSelectionService != null)
                    {
                        this.SetSelectedComponents(pSelectionService, this.m_Item1);
                    }
                    //
                    this.m_Item1 = null;
                    //
                    return(true);
                }
            }
            //
            return(false);
        }
        private bool SelectCompnentMouseDown_DG(IUICollectionItem pUICollectionItem, Point point)
        {
            if (pUICollectionItem == null)
            {
                return(false);
            }
            if (!((IBaseItem)pUICollectionItem).Visible)
            {
                return(false);
            }
            //
            bool bIsTabButtonContainerItem = pUICollectionItem is ITabButtonContainerItem;

            //
            foreach (BaseItem one in pUICollectionItem.BaseItems)
            {
                if (bIsTabButtonContainerItem && one is TabButtonItem)
                {
                    TabButtonItem tabButtonItem = (TabButtonItem)one;
                    if (tabButtonItem.DesignMouseClickRectangleContainsEx(point))
                    {
                        ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                        if (pSelectionService != null)
                        {
                            this.m_Item1 = tabButtonItem;
                            BaseItem tabPageItem = tabButtonItem.pTabPageItem as BaseItem;
                            if (tabPageItem != null)
                            {
                                if (this.SetSelectedComponents(pSelectionService, tabPageItem))
                                {
                                    this.m_Control.Refresh();
                                }
                            }
                            ITabButtonContainerItem pTabButtonContainerItem = (ITabButtonContainerItem)pUICollectionItem;
                            pTabButtonContainerItem.TabButtonItemSelectedIndex = pTabButtonContainerItem.BaseItems.IndexOf(tabButtonItem);
                            //
                            return(true);
                        }
                    }
                }
                else
                {
                    if (this.SelectCompnentMouseDown_DG(one as IUICollectionItem, point))
                    {
                        return(true);
                    }
                    //
                    if (one.DesignMouseClickRectangleContainsEx(point))
                    {
                        ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                        if (pSelectionService != null)
                        {
                            this.m_Item1          = one;
                            this.m_MouseDownPoint = point;
                            if (this.SetSelectedComponents(pSelectionService, one))
                            {
                                this.m_Control.Refresh();
                            }
                            return(true);
                        }
                    }
                }
            }
            //
            if (pUICollectionItem is IBaseItemStackExItem)
            {
                IBaseItemStackExItem pBaseItemStackExItem = (IBaseItemStackExItem)pUICollectionItem;
                if (pBaseItemStackExItem.PreButtonVisible &&
                    pBaseItemStackExItem.PreButtonRectangle.Contains(point))
                {
                    if (pBaseItemStackExItem.PreButtonIncreaseIndex)
                    {
                        pBaseItemStackExItem.TopViewItemIndex++;
                    }
                    else
                    {
                        pBaseItemStackExItem.TopViewItemIndex--;
                    }
                }
                if (pBaseItemStackExItem.NextButtonVisible &&
                    pBaseItemStackExItem.NextButtonRectangle.Contains(point))
                {
                    if (pBaseItemStackExItem.PreButtonIncreaseIndex)
                    {
                        pBaseItemStackExItem.TopViewItemIndex--;
                    }
                    else
                    {
                        pBaseItemStackExItem.TopViewItemIndex++;
                    }
                }
            }
            else if (pUICollectionItem is IGalleryItem)
            {
                IGalleryItem pGalleryItem = (IGalleryItem)pUICollectionItem;
                if (pGalleryItem.ScrollUpButtonRectangle.Contains(point))
                {
                    pGalleryItem.TopViewItemIndex++;
                }
                if (pGalleryItem.ScrollDownButtonRectangle.Contains(point))
                {
                    pGalleryItem.TopViewItemIndex--;
                }
            }
            //
            return(false);
        }