Esempio n. 1
0
        internal bool DropTab(TearableTabItem tabItemSource)
        {
            bool retVal = false;

            try
            {
                TearableTabControl tabControlTarget = this;

                if (tabControlTarget != null)
                {
                    TearableTabControl tabControlSource = tabItemSource.Parent as TearableTabControl;
                    if (tabControlTarget != tabControlSource && !tabControlTarget.IsChildOf(tabItemSource))
                    {
                        if (null != tabControlSource && tabControlSource.Items.Contains(tabItemSource))
                        {
                            tabControlSource.Items.Remove(tabItemSource);
                            // Should this be disposed if no items remain???
                        }
                        tabControlTarget.Items.Insert(tabControlTarget.Items.Count, tabItemSource);
                        tabItemSource.IsSelected = true;
                        retVal = true;
                    }
                    else
                    {
                        Log.LogWriter.Instance.WriteToLog(Log.LogMsgType.Error, "Cannot add tab to internal tab control");
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(retVal);
        }
        public bool DropTab(TearableTabItem tabItem)
        {
            bool retValue = false;

            if (null != ttcMain)
            {
                retValue = ttcMain.DropTab(tabItem);
            }
            else if (null != itccCenter)
            {
                retValue = itccCenter.DropTab(tabItem);
            }
            return(retValue);
        }
Esempio n. 3
0
        private void TabItem_Drop(object sender, DragEventArgs e)
        {
            try
            {
                TearableTabItem tabItemTarget = e.Source as TearableTabItem;
                TearableTabItem tabItemSource = e.Data.GetData(typeof(TearableTabItem)) as TearableTabItem;

                if (null != SharedData)
                {
                    SharedData.AllowTabDrag = false;
                }

                if (tabItemTarget != null && tabItemSource != null)
                {
                    tiHoverTimer?.Stop();
                    tiHoverTimer = null;
                    if (!tabItemTarget.Equals(tabItemSource))
                    {
                        TearableTabControl tabControlSource = tabItemSource.Parent as TearableTabControl;
                        String             source           = tabControlSource.Name;
                        TearableTabControl tabControlTarget = tabItemTarget.Parent as TearableTabControl;
                        String             target           = tabControlTarget.Name;
                        if (tabControlSource.Equals(tabControlTarget))
                        {
                            int sourceIndex = tabControlTarget.Items.IndexOf(tabItemSource);
                            int targetIndex = tabControlTarget.Items.IndexOf(tabItemTarget);

                            tabControlTarget.Items.Remove(tabItemSource);
                            tabControlTarget.Items.Insert(targetIndex, tabItemSource);

                            //tabControlTarget.Items.Remove(tabItemTarget);
                            //tabControlTarget.Items.Insert(sourceIndex, tabItemTarget);
                        }
                        else
                        {
                            int targetIndex = Math.Min(tabControlTarget.Items.Count, tabControlTarget.Items.IndexOf(tabItemTarget));
                            int one         = tabControlTarget.Items.IndexOf(tabItemTarget);

                            tabControlSource.Items.Remove(tabItemSource);
                            tabControlTarget.Items.Insert(targetIndex, tabItemSource);
                        }
                        tabItemSource.IsSelected = true;
                    }
                    e.Handled = true;
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 4
0
        private void TabItem_DragEnter(object sender, DragEventArgs e)
        {
            TearableTabItem tabItem = sender as TearableTabItem;

            //if (true || MouseUtil.IsOver(this, "Border") && null != SharedData)
            //{
            //  TearableTabItem tabItemSource = e.Data.GetData(typeof(TearableTabItem)) as TearableTabItem;
            //  TearableTabControl tabControlTarget = this.Parent as TearableTabControl;
            //  TearableTabControl tabControlSource = tabItemSource.Parent as TearableTabControl;
            //  if (null != tabItemSource && null != tabControlTarget)
            //  {
            //    if (null != tabControlSource)
            //    {
            //      tabControlSource.Items.Remove(tabItemSource);
            //    }
            //    int index = tabControlTarget.Items.IndexOf(this);
            //    if (0 != index) { }
            //    tabControlTarget.Items.Insert(0, tabItemSource);
            //    //tabControlTarget.Items.Insert(tabControlTarget.Items.IndexOf(tabItem), tabItemSource);
            //  }
            //}

            if (null != SharedData && SharedData.AllowTabDrag && tabItem != null)
            {
                e.Handled = true;
                if (!tabItem.IsSelected)
                {
                    if (tiHoverTimer == null)
                    {
                        tiHoverTimer          = new DispatcherTimer();
                        tiHoverTimer.Interval = new TimeSpan(0, 0, 0, 0, 200);
                        tiHoverTimer.Tick    += (s, e1) =>
                        {
                            tabItem.IsSelected = true;
                            tiHoverTimer.Stop();
                            tiHoverTimer = null;
                        };
                    }
                    tiHoverTimer.Start();
                }
            }
        }
Esempio n. 5
0
        private void TabItem_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            TearableTabItem tabItem = e.Source as TearableTabItem;

            if (tabItem != null)
            {
                if (Mouse.LeftButton == MouseButtonState.Pressed)
                {
                    if (typeof(Button) != Mouse.DirectlyOver.GetType())
                    {
                        if (null != SharedData)
                        {
                            SharedData.AdornerStartPoint = e.GetPosition(this);
                        }

                        SharedData?.StartDrag((sender as FrameworkElement).Parent as TearableTabControl, tabItem);
                    }
                }

                e.Handled = true;
            }
        }
 public bool AddControl(DropLocation location, TearableTabControl ttControl, TearableTabItem newTabItem, ref Grid droppedItemParent)
 {
     return(true);
 }
        public bool AddSplitControl(DropLocation location, DropLocation sourceLocation, TearableTabItem ttItem)
        {
            if (ttcMain.Items.Contains(ttItem) && 1 == ttcMain.Items.Count)
            {
                return(false);
            }
            switch (location)
            {
            case DropLocation.Top:
            case DropLocation.Bottom:
                itccCenter = new TearableTabSplitHorizontal(this);
                break;

            case DropLocation.Left:
            case DropLocation.Right:
                itccCenter = new TearableTabSplitVertical(this);
                break;

            case DropLocation.Center:
            default:
                throw new NotSupportedException("Center not supported");
            }
            tabs[location] = itccCenter;

            gridContentSplitControl.Children.Remove(ttcMain);
            ttddMain.Visibility = Visibility.Collapsed;
            ttddMain.DetachDetectorElement();
            Grid tmpGrid = null;

            itccCenter.AddControl(location, ttcMain, ttItem, ref tmpGrid);
            gridContentSplitControl.Children.Insert(0, itccCenter as UIElement);
            ttcMain = null;
            return(true);
        }