private bool SelectCompnentMouseUp_DG(CanvasItem canvasItem, Point point)
 {
     if (canvasItem == null)
     {
         return(false);
     }
     //
     foreach (BaseItem one in canvasItem.BaseItems)
     {
         if (this.SelectCompnentMouseUp(one as RibbonGalleryItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseUp(one as ButtonGroupItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseUp_DG(one as BaseItemStackExItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseUp_DG(one as BaseItemStackItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseUp_DG(one as CanvasItem, point))
         {
             return(true);
         }
         ////
         //if (one.DesignMouseClickRectangleContainsEx(point))
         //{
         //    ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
         //    if (pSelectionService != null)
         //    {
         //        this.m_Item2 = one;
         //        if (canvasItem.BaseItems.ExchangeItem(this.m_Item1, this.m_Item2))
         //        {
         //            pSelectionService.SetSelectedComponents(new Component[] { this.m_Item1 as Component }, SelectionTypes.Primary);
         //            this.m_BaseBar.Refresh();
         //            return true;
         //        }
         //        else
         //        {
         //            pSelectionService.SetSelectedComponents(new Component[] { one as Component }, SelectionTypes.Primary);
         //            this.m_BaseBar.Refresh();
         //            return true;
         //        }
         //    }
         //}
     }
     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_DescriptionMenuPopupPanel.Refresh();
             }
         }
         //
         ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
         if (pSelectionService != null)
         {
             pSelectionService.SetSelectedComponents(new Component[] { m_Item1 as Component }, SelectionTypes.Primary);
         }
         //
         this.m_Item1 = null;
         //
         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);
        }