Пример #1
0
        /// <summary>
        /// Undock given content</summary>
        /// <param name="content">Content to undock</param>
        public void Undock(IDockContent content)
        {
            ClosePopup();
            DockContent dockContent;

            if ((dockContent = (content as DockContent)) != null)
            {
                dockContent.IsVisible         = false;
                dockContent.IsFocusedChanged -= DockContent_IsFocusedChanged;
                m_children.Remove(dockContent);
                foreach (SideBarButton b in Items)
                {
                    if (b.Tag == dockContent)
                    {
                        if (m_lastItemOver == b)
                        {
                            m_timer.Stop();
                            m_lastItemOver = null;
                        }
                        Items.Remove(b);
                        break;
                    }
                }
            }
        }
Пример #2
0
 void TabItem_DragEnter(object sender, DragEventArgs e)
 {
     e.Effects      = DragDropEffects.Scroll & e.AllowedEffects;
     e.Handled      = true;
     m_lastItemOver = (SideBarButton)sender;
     m_timerTime    = DateTime.Now;
     m_timer.Start();
 }
Пример #3
0
        void Window_Closing(object sender, EventArgs e)
        {
            IDockContent content = (IDockContent)PART_Popup.Tag;

            ClosePopup();
            m_lastItemOver = null;
            Undock(content);
        }
Пример #4
0
        /// <summary>
        /// Add new content to side tab</summary>
        /// <param name="content">New dock content</param>
        private void AddContent(DockContent content)
        {
            m_children.Add(content);
            content.Settings.DockState = DockState.Collapsed;
            FrameworkElement fe      = CreateHeader(content);
            SideBarButton    tabItem = new SideBarButton(TabsPlacement)
            {
                Content = fe,
                Tag     = content,
            };

            tabItem.MouseEnter += TabItem_MouseEnter;
            tabItem.AllowDrop   = true;
            tabItem.DragEnter  += TabItem_DragEnter;
            tabItem.Click      += TabItem_Click;
            Items.Add(tabItem);
            content.IsVisible         = true;
            content.IsFocused         = false;
            content.IsFocusedChanged += DockContent_IsFocusedChanged;
        }
Пример #5
0
        /// <summary>
        /// Add new content to this side tab
        /// </summary>
        /// <param name="content"></param>
        private void AddContent(DockContent content)
        {
            m_children.Add(content);
            content.Settings.DockState = DockState.Collapsed;
            FrameworkElement fe      = CreateHeader(content);
            SideBarButton    tabItem = new SideBarButton(TabsPlacement)
            {
                Content = fe,
                Tag     = content,
            };

            tabItem.MouseEnter += new System.Windows.Input.MouseEventHandler(TabItem_MouseEnter);
            tabItem.AllowDrop   = true;
            tabItem.DragEnter  += new DragEventHandler(TabItem_DragEnter);
            tabItem.Click      += new RoutedEventHandler(TabItem_Click);
            Items.Add(tabItem);
            content.IsVisible         = true;
            content.IsFocused         = false;
            content.IsFocusedChanged += new EventHandler <BooleanArgs>(DockContent_IsFocusedChanged);
        }
Пример #6
0
 /// <summary>
 /// Undock given content</summary>
 /// <param name="content">Content to undock</param>
 public void Undock(IDockContent content)
 {
     ClosePopup();
     DockContent dockContent;
     if ((dockContent = (content as DockContent)) != null)
     {
         dockContent.IsVisible = false;
         dockContent.IsFocusedChanged -= DockContent_IsFocusedChanged;
         m_children.Remove(dockContent);
         foreach (SideBarButton b in Items)
         {
             if (b.Tag == dockContent)
             {
                 if (m_lastItemOver == b)
                 {
                     m_timer.Stop();
                     m_lastItemOver = null;
                 }
                 Items.Remove(b);
                 break;
             }
         }
     }
 }
Пример #7
0
 /// <summary>
 /// Add new content to side tab</summary>
 /// <param name="content">New dock content</param>
 private void AddContent(DockContent content)
 {
     m_children.Add(content);
     content.Settings.DockState = DockState.Collapsed;
     FrameworkElement fe = CreateHeader(content);
     SideBarButton tabItem = new SideBarButton(TabsPlacement)
     {
         Content = fe,
         Tag = content,
     };
     tabItem.MouseEnter += TabItem_MouseEnter;
     tabItem.AllowDrop = true;
     tabItem.DragEnter += TabItem_DragEnter;
     tabItem.Click += TabItem_Click;
     Items.Add(tabItem);
     content.IsVisible = true;
     content.IsFocused = false;
     content.IsFocusedChanged += DockContent_IsFocusedChanged;
 }
Пример #8
0
 void TabItem_DragEnter(object sender, DragEventArgs e)
 {
     e.Effects = DragDropEffects.Scroll & e.AllowedEffects;
     e.Handled = true;
     m_lastItemOver = (SideBarButton)sender;
     m_timerTime = DateTime.Now;
     m_timer.Start();
 }
Пример #9
0
 void TabItem_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
 {
     m_lastItemOver = (SideBarButton)sender;
     m_timerTime = DateTime.Now;
     m_timer.Start();
 }
Пример #10
0
        void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (Dispatcher.Thread != Thread.CurrentThread)
            {
                Dispatcher.BeginInvoke(new EventHandler<ElapsedEventArgs>(Timer_Elapsed), new object[] { sender, e });
                return;
            }
            try
            {
                Point curMousePos = m_lastItemOver != null ? Win32Calls.GetPosition(m_lastItemOver) : new Point(-1, -1);
                if (m_lastItemOver != null && new Rect(0, 0, m_lastItemOver.ActualWidth, m_lastItemOver.ActualHeight).Contains(curMousePos))
                {
                    TimeSpan ts = DateTime.Now - m_timerTime;
                    if (ts.TotalMilliseconds > 500 || Mouse.LeftButton == MouseButtonState.Pressed)
                    {
                        ShowPopup();
                        m_lastItemOver.IsChecked = true;
                        m_lastItemOver = null;
                        m_timerTime = DateTime.Now;
                    }
                    m_timer.Start();
                }
                else
                {
                    var app = Application.Current;
                    if (app == null)
                        return;

                    var window = app.MainWindow;
                    if (window == null || !window.IsActive)
                        return;

                    if (PART_Popup.IsOpen && !PART_Popup.Resizing)
                    {
                        Win32Calls.Win32Point pt32 = new Win32Calls.Win32Point();
                        Win32Calls.GetCursorPos(ref pt32);
                        Point mousePos = new Point(pt32.X, pt32.Y);
                        Point pos = PointToScreen(new Point(0, 0));
                        Matrix m = PresentationSource.FromVisual(Window.GetWindow(this)).CompositionTarget.TransformToDevice;
                        if (m != Matrix.Identity)
                        {
                            m.Invert();
                            mousePos = m.Transform(mousePos);
                            pos = m.Transform(pos);
                        }
                        switch (TabsPlacement)
                        {
                            case System.Windows.Controls.Dock.Top:
                                pos.Y += ActualHeight;
                                break;
                            case System.Windows.Controls.Dock.Bottom:
                                pos.Y -= PART_Popup.Height;
                                break;
                            case System.Windows.Controls.Dock.Left:
                                pos.X += ActualWidth;
                                break;
                            case System.Windows.Controls.Dock.Right:
                                pos.X -= PART_Popup.Width;
                                break;
                        }
                        bool b2 = new Rect(pos.X, pos.Y, PART_Popup.Width, PART_Popup.Height).Contains(mousePos);
                        Point posThis = Win32Calls.GetPosition(this);
                        bool b3 = new Rect(0, 0, ActualWidth, ActualHeight).Contains(posThis);
                        if (!b2 && !b3)
                        {
                            TimeSpan ts = DateTime.Now - m_timerTime;
                            if(ts.TotalMilliseconds > 1000)
                            {
                                // if mouse is outside for more than some time, then collapse this popup
                                ClosePopup();
                            }
                            else
                            {
                                m_timer.Start();
                            }
                        }
                        else
                        {
                            m_timerTime = DateTime.Now;
                            m_timer.Start();
                        }
                    }
                }
            }
            catch (InvalidOperationException)
            {
                // Can be thrown when closing the application and popup is still open...
            }
        }
Пример #11
0
 void Window_Closing(object sender, EventArgs e)
 {
     IDockContent content = (IDockContent)PART_Popup.Tag;
     ClosePopup();
     m_lastItemOver = null;
     Undock(content);
 }
Пример #12
0
 void TabItem_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
 {
     m_lastItemOver = (SideBarButton)sender;
     m_timerTime    = DateTime.Now;
     m_timer.Start();
 }
Пример #13
0
        void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (Dispatcher.Thread != Thread.CurrentThread)
            {
                Dispatcher.BeginInvoke(new EventHandler <ElapsedEventArgs>(Timer_Elapsed), new object[] { sender, e });
                return;
            }
            try
            {
                Point curMousePos = m_lastItemOver != null?Win32Calls.GetPosition(m_lastItemOver) : new Point(-1, -1);

                if (m_lastItemOver != null && new Rect(0, 0, m_lastItemOver.ActualWidth, m_lastItemOver.ActualHeight).Contains(curMousePos))
                {
                    TimeSpan ts = DateTime.Now - m_timerTime;
                    if (ts.TotalMilliseconds > 500 || Mouse.LeftButton == MouseButtonState.Pressed)
                    {
                        ShowPopup();
                        m_lastItemOver.IsChecked = true;
                        m_lastItemOver           = null;
                        m_timerTime = DateTime.Now;
                    }
                    m_timer.Start();
                }
                else
                {
                    var app = Application.Current;
                    if (app == null)
                    {
                        return;
                    }

                    var window = app.MainWindow;
                    if (window == null || !window.IsActive)
                    {
                        return;
                    }

                    if (PART_Popup.IsOpen && !PART_Popup.Resizing)
                    {
                        var pt32 = new Windows.POINT();
                        Win32Calls.GetCursorPos(ref pt32);
                        Point  mousePos = new Point(pt32.x, pt32.y);
                        Point  pos      = PointToScreen(new Point(0, 0));
                        Matrix m        = PresentationSource.FromVisual(Window.GetWindow(this)).CompositionTarget.TransformToDevice;
                        if (m != Matrix.Identity)
                        {
                            m.Invert();
                            mousePos = m.Transform(mousePos);
                            pos      = m.Transform(pos);
                        }
                        switch (TabsPlacement)
                        {
                        case System.Windows.Controls.Dock.Top:
                            pos.Y += ActualHeight;
                            break;

                        case System.Windows.Controls.Dock.Bottom:
                            pos.Y -= PART_Popup.Height;
                            break;

                        case System.Windows.Controls.Dock.Left:
                            pos.X += ActualWidth;
                            break;

                        case System.Windows.Controls.Dock.Right:
                            pos.X -= PART_Popup.Width;
                            break;
                        }
                        bool  b2      = new Rect(pos.X, pos.Y, PART_Popup.Width, PART_Popup.Height).Contains(mousePos);
                        Point posThis = Win32Calls.GetPosition(this);
                        bool  b3      = new Rect(0, 0, ActualWidth, ActualHeight).Contains(posThis);
                        if (!b2 && !b3)
                        {
                            TimeSpan ts = DateTime.Now - m_timerTime;
                            if (ts.TotalMilliseconds > 1000)
                            {
                                // if mouse is outside for more than some time, then collapse this popup
                                ClosePopup();
                            }
                            else
                            {
                                m_timer.Start();
                            }
                        }
                        else
                        {
                            m_timerTime = DateTime.Now;
                            m_timer.Start();
                        }
                    }
                }
            }
            catch (InvalidOperationException)
            {
                // Can be thrown when closing the application and popup is still open...
            }
        }
Пример #14
0
 /// <summary>
 /// Add new content to this side tab
 /// </summary>
 /// <param name="content"></param>
 private void AddContent(DockContent content)
 {
     m_children.Add(content);
     content.Settings.DockState = DockState.Collapsed;
     FrameworkElement fe = CreateHeader(content);
     SideBarButton tabItem = new SideBarButton(TabsPlacement)
     {
         Content = fe,
         Tag = content,
     };
     tabItem.MouseEnter += new System.Windows.Input.MouseEventHandler(TabItem_MouseEnter);
     tabItem.AllowDrop = true;
     tabItem.DragEnter += new DragEventHandler(TabItem_DragEnter);
     tabItem.Click += new RoutedEventHandler(TabItem_Click);
     Items.Add(tabItem);
     content.IsVisible = true;
     content.IsFocused = false;
     content.IsFocusedChanged += new EventHandler<BooleanArgs>(DockContent_IsFocusedChanged);
 }