Esempio n. 1
0
        protected override void OnDragDrop(DragEventArgs e)
        {
            base.OnDragDrop(e);

            Point p = PointToClient(new Point(e.X, e.Y));

            if (e.Data.GetDataPresent(typeof(SideTabItem)))
            {
                SideTabItem draggedItem = (SideTabItem)e.Data.GetData(typeof(SideTabItem));

                // drag tabitem into other sideTab
                SideTab tab = GetTabAt(p.X, p.Y);
                if (tab != null)
                {
                    if (tab == Tabs.DragOverTab && tab.CanDragDrop)
                    {
                        Tabs.DragOverTab.SideTabStatus = SideTabStatus.Normal;
                        draggedItem.SideTabItemStatus  = SideTabItemStatus.Normal;
                        switch (e.Effect)
                        {
                        case DragDropEffects.Move:
                            if (Tabs.DragOverTab != activeTab)
                            {
                                activeTab.Items.Remove(draggedItem);
                                Tabs.DragOverTab.Items.Add(draggedItem);
                            }
                            break;

                        case DragDropEffects.Copy:
                            SideTabItem newItem = draggedItem.Clone();
                            Tabs.DragOverTab.Items.Add(newItem);
                            break;
                        }
                        Tabs.DragOverTab = null;
                        Refresh();
                    }
                }
            }
            else if (e.Data.GetDataPresent(typeof(string)))
            {
                if (Tabs.DragOverTab != null)
                {
                    string str = (string)e.Data.GetData(typeof(string));
                    Tabs.DragOverTab.Items.Add("Text:" + str.Trim(), str);
                }
                Tabs.DragOverTab = null;
                Refresh();
            }
            else
            {
                Tabs.DragOverTab = null;
                Refresh();
            }
        }
Esempio n. 2
0
            protected override void OnDragDrop(DragEventArgs e)
            {
                base.OnDragDrop(e);

                Point p = PointToClient(new Point(e.X, e.Y));

                if (e.Data.GetDataPresent(typeof(SideTabItem)))
                {
                    SideTabItem draggedItem = (SideTabItem)e.Data.GetData(typeof(SideTabItem));
                    switch (e.Effect)
                    {
                    case DragDropEffects.Move:
                        SideTabItem item = sideBar.activeTab.GetItemAt(p.X, p.Y);

                        if (item != sideBar.activeTab.ChoosedItem)
                        {
                            int idx = sideBar.activeTab.Items.DraggedIndex;
                            if (idx != -1)
                            {
                                sideBar.activeTab.Items.Remove(draggedItem);
                                sideBar.activeTab.Items.Insert(idx, draggedItem);
                            }
                        }
                        break;

                    case DragDropEffects.Copy:
                        SideTabItem newItem = draggedItem.Clone();
                        newItem.SideTabItemStatus = SideTabItemStatus.Normal;
                        sideBar.activeTab.Items.Add(newItem);
                        break;
                    }
                    sideBar.ClearDraggings(sideBar.activeTab);
                    sideBar.Tabs.DragOverTab = null;
                    sideBar.Refresh();
                }
                else if (e.Data.GetDataPresent(typeof(string)))
                {
                    if (sideBar.Tabs.DragOverTab != null)
                    {
                        string str = (string)e.Data.GetData(typeof(string));
                        sideBar.Tabs.DragOverTab.Items.Add("Text:" + str.Trim(), str);
                    }
                    sideBar.Tabs.DragOverTab = null;
                    Refresh();
                }
                else
                {
                    sideBar.Tabs.DragOverTab = null;
                    sideBar.Refresh();
                }
            }