예제 #1
0
 private void TabBackground_MouseLeave(object sender, MouseEventArgs e)
 {
     if (ParentTabControl != null)
     {
         ParentTabControl.TabBackground_MouseLeave(this, e);
     }
 }
        internal void StartTabDrag(Point p, ChromeTabItem tab = null, bool isTabGrab = false)
        {
            this._lastMouseDown = DateTime.UtcNow;
            if (tab == null)
            {
                HitTestResult result = VisualTreeHelper.HitTest(this, this.downPoint);
                if (result == null)
                {
                    return;
                }
                DependencyObject source = result.VisualHit;
                while (source != null && !this.Children.Contains(source as UIElement))
                {
                    source = VisualTreeHelper.GetParent(source);
                }
                if (source == null)
                {
                    //The mouse is not over a tab item, so just return.
                    return;
                }
                this.draggedTab = source as ChromeTabItem;
            }
            else if (tab != null)
            {
                this.draggedTab = tab;
            }
            else
            {
                return;
            }

            if (this.draggedTab != null)
            {
                if (this.Children.Count == 1 &&
                    ParentTabControl.DragWindowWithOneTab &&
                    Mouse.LeftButton == MouseButtonState.Pressed &&
                    !isTabGrab)
                {
                    this.draggingWindow = true;
                    Window.GetWindow(this).DragMove();
                }
                else
                {
                    this.downTabBoundsPoint = MouseUtilities.CorrectGetPosition(this.draggedTab);
                    Canvas.SetZIndex(this.draggedTab, 1000);
                    ParentTabControl.ChangeSelectedItem(this.draggedTab);
                    if (isTabGrab)
                    {
                        for (int i = 0; i < this.Children.Count; i++)
                        {
                            ProcessMouseMove(new Point(p.X + 0.1, p.Y));
                        }
                    }
                    else
                    {
                        ProcessMouseMove(new Point(p.X + 0.1, p.Y));
                    }
                }
            }
        }
예제 #3
0
 private void CloseButton_Click(object sender, RoutedEventArgs e)
 {
     if (ParentTabControl != null)
     {
         ParentTabControl.CloseButton_Click(this, e);
     }
 }
예제 #4
0
        protected override Size MeasureOverride(Size availableSize)
        {
            this.currentTabWidth = CalculateTabWidth(availableSize);
            ParentTabControl.SetCanAddTab(this.currentTabWidth > this.MinTabWidth);

            if (_hideAddButton)
            {
                this.addButton.Visibility = System.Windows.Visibility.Hidden;
            }
            else if (ParentTabControl.IsAddButtonVisible)
            {
                this.addButton.Visibility = this.currentTabWidth > this.MinTabWidth ? Visibility.Visible : Visibility.Collapsed;
            }
            else
            {
                this.addButton.Visibility = System.Windows.Visibility.Collapsed;
            }

            double height     = double.IsPositiveInfinity(availableSize.Height) ? this.defaultMeasureHeight : availableSize.Height;
            Size   resultSize = new Size(0, availableSize.Height);

            foreach (UIElement child in this.Children)
            {
                ChromeTabItem item    = ItemsControl.ContainerFromElement(this.ParentTabControl, child) as ChromeTabItem;
                Size          tabSize = new Size(GetWidthForTabItem(item), height - item.Margin.Bottom);
                child.Measure(tabSize);
                resultSize.Width += child.DesiredSize.Width - overlap;
            }
            if (ParentTabControl.IsAddButtonVisible)
            {
                this.addButton.Measure(this.addButtonSize);
                resultSize.Width += this.addButtonSize.Width;
            }
            return(resultSize);
        }
예제 #5
0
 private void TabBackground_PreviewDragOver(object sender, DragEventArgs e)
 {
     if (ParentTabControl != null)
     {
         ParentTabControl.TabBackground_PreviewDragOver(this, e);
     }
 }
예제 #6
0
 private void TabBackground_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (ParentTabControl != null)
     {
         ParentTabControl.TabBackground_PreviewMouseLeftButtonDown(this, e);
     }
 }
예제 #7
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     base.OnKeyDown(e);
     if (e.Key == Key.Enter || e.Key == Key.Space || e.Key == Key.Return)
     {
         ParentTabControl.ChangeSelectedItem(this);
     }
 }
예제 #8
0
 private void PersistentTimer_Tick(object sender, EventArgs e)
 {
     StoptPersistTimer();
     if (ParentTabControl != null)
     {
         ParentTabControl.RemoveFromItemHolder(this);
     }
 }
예제 #9
0
        protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseLeftButtonUp(e);
            this.draggingWindow = false;
            if (this.addButtonRect.Contains(e.GetPosition(this)) && this.addButton.Background == Brushes.DarkGray)
            {
                this.addButton.Background = null;
                this.InvalidateVisual();
                if (this.addButton.Visibility == Visibility.Visible)
                {
                    //ParentTabControl.AddTab(new Label(), true); // HACK: Do something with default templates, here.
                    //AddTabClick();
                    ParentTabControl.RerouteAddTabClick();
                }
                return;
            }
            if (this.IsMouseCaptured)
            {
                Mouse.Capture(null);

                double offset = 0;
                if (this.slideIndex < this.originalIndex + 1)
                {
                    offset = this.slideIntervals[this.slideIndex + 1] - 2 * this.currentTabWidth / 3 + this.overlap;
                }
                else if (this.slideIndex > this.originalIndex + 1)
                {
                    offset = this.slideIntervals[this.slideIndex - 1] + 2 * this.currentTabWidth / 3 - this.overlap;
                }
                Console.WriteLine(offset);
                Action completed = () =>
                {
                    if (this.draggedTab != null)
                    {
                        ParentTabControl.ChangeSelectedItem(this.draggedTab);
                        this.draggedTab.Margin = new Thickness(offset, 0, -offset, 0);
                        this.draggedTab        = null;
                        this.captureGuard      = 0;
                        ParentTabControl.MoveTab(this.originalIndex, this.slideIndex - 1);
                    }
                };
                Reanimate(this.draggedTab, offset, .1, completed);
            }
            else
            {
                if (this.draggedTab != null)
                {
                    ParentTabControl.ChangeSelectedItem(this.draggedTab);
                    this.draggedTab.Margin = new Thickness(0);
                }
                this.draggedTab   = null;
                this.captureGuard = 0;
            }
        }
예제 #10
0
 protected override void OnInitialized(EventArgs e)
 {
     base.OnInitialized(e);
     this.SetTabItemsOnTabs();
     if (Children.Count > 0)
     {
         if (Children[0] is ChromeTabItem)
         {
             ParentTabControl.ChangeSelectedItem(Children[0] as ChromeTabItem);
         }
     }
 }
예제 #11
0
 protected override void OnInitialized(EventArgs e)
 {
     base.OnInitialized(e);
     this.SetTabItemsOnTabs();
     if (Children.Count > 0)
     {
         if (Children[0] is ChromeTabItem)
         {
             ParentTabControl.ChangeSelectedItem(Children[0] as ChromeTabItem);
         }
     }
     if (ParentTabControl != null && ParentTabControl.AddButtonTemplate != null)
     {
         SetAddButtonControlTemplate(ParentTabControl.AddButtonTemplate);
     }
 }
예제 #12
0
        internal void StartTabDrag(Point p, ChromeTabItem tab = null, bool isTabGrab = false)
        {
            this._lastMouseDown = DateTime.UtcNow;
            if (tab == null)
            {
                tab = GetTabFromMousePosition(this.downPoint);
            }

            if (tab != null)
            {
                this.draggedTab = tab;
            }
            else
            {
                //The mouse is not over a tab item, so just return.
                return;
            }

            if (this.draggedTab != null)
            {
                if (this.Children.Count == 1 &&
                    ParentTabControl.DragWindowWithOneTab &&
                    Mouse.LeftButton == MouseButtonState.Pressed &&
                    !isTabGrab)
                {
                    this.draggingWindow = true;
                    Window.GetWindow(this).DragMove();
                }
                else
                {
                    this.downTabBoundsPoint = MouseUtilities.CorrectGetPosition(this.draggedTab);
                    Canvas.SetZIndex(this.draggedTab, 1000);
                    ParentTabControl.ChangeSelectedItem(this.draggedTab);
                    if (isTabGrab)
                    {
                        for (int i = 0; i < this.Children.Count; i++)
                        {
                            ProcessMouseMove(new Point(p.X + 0.1, p.Y));
                        }
                    }
                }
            }
        }
예제 #13
0
            public void buildGui()
            {
                AstEngine.HostPanel.clear();
                "Calculating Mappings fro Methods called".info();
                MethodsCalledMappings    = AstEngine.AstData.calculateMappingsFor_MethodsCalled();
                MethodIsCalledByMappings = AstEngine.AstData.calculateMappingsFor_MethodIsCalledBy(MethodsCalledMappings);

                AllMethods = this.MethodsCalledMappings.Keys.toList();
                AllMethods.add_OnlyNewItems(this.MethodIsCalledByMappings.Keys.toList());
                "MethodsCalledMappings has {0} root methods".info(MethodsCalledMappings.Keys.size());
                "MethodIsCalledByMappings has {0} root methods".info(MethodIsCalledByMappings.Keys.size());
                "AllMethods has {0} root methods".info(AllMethods.size());

                ParentTabControl         = AstEngine.HostPanel.add_TabControl();
                TreeViewModeTab          = ParentTabControl.add_Tab("TreeView Mode");
                GraphModeTab             = ParentTabControl.add_Tab("Graph Mode");
                InteractiveBrowseModeTab = ParentTabControl.add_Tab("Interactive Browse Mode");
                build_TreeViewMode(TreeViewModeTab);
                build_GraphMode(GraphModeTab);
            }
예제 #14
0
        protected override Size MeasureOverride(Size availableSize)
        {
            double activeWidth = double.IsPositiveInfinity(availableSize.Width) ? 500 : availableSize.Width - this.leftMargin - this.rightMargin;

            this.currentTabWidth = Math.Min(Math.Max((activeWidth + (this.Children.Count - 1) * overlap) / this.Children.Count, this.minTabWidth), this.maxTabWidth);
            ParentTabControl.SetCanAddTab(this.currentTabWidth > this.minTabWidth);
            this.addButton.Visibility = this.currentTabWidth > this.minTabWidth ? Visibility.Visible : Visibility.Collapsed;
            double height     = double.IsPositiveInfinity(availableSize.Height) ? this.defaultMeasureHeight : availableSize.Height;
            Size   resultSize = new Size(0, availableSize.Height);

            foreach (UIElement child in this.Children)
            {
                ChromeTabItem item    = ItemsControl.ContainerFromElement(this.ParentTabControl, child) as ChromeTabItem;
                Size          tabSize = new Size(this.currentTabWidth, height - item.Margin.Bottom);
                child.Measure(tabSize);
                resultSize.Width += child.DesiredSize.Width - overlap;
            }
            this.addButton.Measure(this.addButtonSize);
            resultSize.Width += this.addButtonSize.Width;
            return(resultSize);
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            this.rightMargin = ParentTabControl.IsAddButtonVisible ? 25 : 0;
            double activeWidth = finalSize.Width - this.leftMargin - this.rightMargin;

            this.currentTabWidth = Math.Min(Math.Max((activeWidth + (this.Children.Count - 1) * overlap) / this.Children.Count, this.minTabWidth), this.maxTabWidth);
            ParentTabControl.SetCanAddTab(this.currentTabWidth > this.minTabWidth);

            if (_hideAddButton)
            {
                this.addButton.Visibility = System.Windows.Visibility.Hidden;
            }
            else if (ParentTabControl.IsAddButtonVisible)
            {
                this.addButton.Visibility = this.currentTabWidth > this.minTabWidth ? Visibility.Visible : Visibility.Collapsed;
            }
            else
            {
                this.addButton.Visibility = System.Windows.Visibility.Collapsed;
            }

            this.finalSize = finalSize;
            double offset = leftMargin;

            foreach (UIElement element in this.Children)
            {
                double        thickness = 0.0;
                ChromeTabItem item      = ItemsControl.ContainerFromElement(this.ParentTabControl, element) as ChromeTabItem;
                thickness = item.Margin.Bottom;
                element.Arrange(new Rect(offset, 0, this.currentTabWidth, finalSize.Height - thickness));
                offset += this.currentTabWidth - overlap;
            }
            if (ParentTabControl.IsAddButtonVisible)
            {
                this.addButtonRect = new Rect(new Point(offset + overlap, (finalSize.Height - this.addButtonSize.Height) / 2), this.addButtonSize);
                this.addButton.Arrange(this.addButtonRect);
            }
            return(finalSize);
        }
예제 #16
0
        private void OnTabRelease(Point p, bool closeTabOnRelease, double animationDuration = stickyReanimateDuration)
        {
            lock (_lockObject)
            {
                this.draggingWindow = false;
                if (ParentTabControl.IsAddButtonVisible)
                {
                    if (this.addButtonRect.Contains(p) && this.addButton.Background == Brushes.DarkGray)
                    {
                        this.addButton.Background = null;
                        this.InvalidateVisual();
                        if (this.addButton.Visibility == Visibility.Visible)
                        {
                            ParentTabControl.AddTab();
                        }
                        return;
                    }
                }
                if (this.IsMouseCaptured)
                {
                    this.ReleaseMouseCapture();
                    double offset = 0;
                    if (this.slideIntervals != null)
                    {
                        if (this.slideIndex < this.originalIndex + 1)
                        {
                            offset = this.slideIntervals[this.slideIndex + 1] - GetWidthForTabItem(this.draggedTab) * (1 - tabWidthSlidePercent) + this.overlap;
                        }
                        else if (this.slideIndex > this.originalIndex + 1)
                        {
                            offset = this.slideIntervals[this.slideIndex - 1] + GetWidthForTabItem(this.draggedTab) * (1 - tabWidthSlidePercent) - this.overlap;
                        }
                    }
                    int    localSlideIndex = this.slideIndex;
                    Action completed       = () =>
                    {
                        if (this.draggedTab != null)
                        {
                            ParentTabControl.ChangeSelectedItem(this.draggedTab);
                            object vm = this.draggedTab.Content;
                            this.draggedTab.Margin = new Thickness(offset, 0, -offset, 0);
                            this.draggedTab        = null;
                            this.captureGuard      = 0;
                            ParentTabControl.MoveTab(this.originalIndex, localSlideIndex - 1);
                            this.slideIntervals       = null;
                            this.addButton.Visibility = System.Windows.Visibility.Visible;
                            _hideAddButton            = false;
                            this.InvalidateVisual();
                            if (closeTabOnRelease && ParentTabControl.CloseTabCommand != null)
                            {
                                Debug.WriteLine("sendt close tab command");
                                ParentTabControl.CloseTabCommand.Execute(vm);
                            }
                            if (this.Children.Count > 1)
                            {
                                //this fixes a bug where sometimes tabs got stuck in the wrong position.
                                RealignAllTabs();
                            }
                        }
                    };

                    Reanimate(this.draggedTab, offset, animationDuration, completed);
                }
                else
                {
                    if (this.draggedTab != null)
                    {
                        ParentTabControl.ChangeSelectedItem(this.draggedTab);
                        this.draggedTab.Margin = new Thickness(0);
                    }
                    this.draggedTab     = null;
                    this.captureGuard   = 0;
                    this.slideIntervals = null;
                }
            }
        }
예제 #17
0
 private void Close()
 {
     ParentTabControl.RemoveTab(this);
 }