Ejemplo n.º 1
0
        /// <summary>Constructor that initializes the various resources that we use in rendering.</summary>
        /// <param name="parentWindow">Parent window that this renderer belongs to.</param>
        public ChromeTabRenderer(TitleBarTabMainForm parentWindow)
            : base(parentWindow)
        {
            // Initialize the various images to use during rendering
            _activeLeftSideImage    = ResourceUtil.GetImage(Resources.ChromeLeftImage);
            _activeRightSideImage   = ResourceUtil.GetImage(Resources.ChromeRightImage);
            _activeCenterImage      = ResourceUtil.GetImage(Resources.ChromeCenterImage);
            _inactiveLeftSideImage  = ResourceUtil.GetImage(Resources.ChromeInactiveLeftImage);
            _inactiveRightSideImage = ResourceUtil.GetImage(Resources.ChromeInactiveRightImage);
            _inactiveCenterImage    = ResourceUtil.GetImage(Resources.ChromeInactiveCenterImage);
            _closeButtonImage       = ResourceUtil.GetImage(Resources.ChromeCloseImage);
            _closeButtonHoverImage  = ResourceUtil.GetImage(Resources.ChromeCloseHoverImage);
            _background             = ResourceUtil.GetImage(Resources.ChromeBackgroundImage);
            _addButtonImage         = new Bitmap(ResourceUtil.GetImage(Resources.ChromeAddImage));
            _addButtonHoverImage    = new Bitmap(ResourceUtil.GetImage(Resources.ChromeAddHoverImage));

            // Set the various positioning properties
            CloseButtonMarginTop  = 6;
            CloseButtonMarginLeft = 2;
            AddButtonMarginTop    = 5;
            AddButtonMarginLeft   = -3;
            CaptionMarginTop      = 5;
            IconMarginTop         = 6;
            IconMarginRight       = 5;
            AddButtonMarginRight  = 5;

            ShowAddButton = false;
        }
Ejemplo n.º 2
0
        protected void HandleApplicationMouseLUp(Point mousePos)
        {
            // If we released the mouse button while we were dragging a torn tab, put that tab into a new window
            if (m_tornTab != null)
            {
                TitleBarTabItem tabToRelease = null;

                lock (m_tornTabLock)
                {
                    if (m_tornTab != null)
                    {
                        tabToRelease = m_tornTab;
                        m_tornTab    = null;
                    }
                }

                if (tabToRelease != null)
                {
                    TitleBarTabMainForm newWindow = (TitleBarTabMainForm)Activator.CreateInstance(m_parentForm.GetType());

                    // Set the initial window position and state properly
                    if (newWindow.WindowState == FormWindowState.Maximized)
                    {
                        Screen screen = Screen.AllScreens.First(s => s.WorkingArea.Contains(Cursor.Position));

                        newWindow.StartPosition = FormStartPosition.Manual;
                        newWindow.WindowState   = FormWindowState.Normal;
                        newWindow.Left          = screen.WorkingArea.Left;
                        newWindow.Top           = screen.WorkingArea.Top;
                        newWindow.Width         = screen.WorkingArea.Width;
                        newWindow.Height        = screen.WorkingArea.Height;
                    }

                    else
                    {
                        newWindow.Left = Cursor.Position.X;
                        newWindow.Top  = Cursor.Position.Y;
                    }

                    tabToRelease.Parent = newWindow;
                    m_parentForm.ApplicationContext.OpenWindow(newWindow);

                    newWindow.Show();
                    newWindow.Tabs.Add(tabToRelease);
                    newWindow.SelectedTabIndex = 0;
                    newWindow.ResizeTabContents();

                    m_tornTabForm.Close();
                    m_tornTabForm = null;

                    if (m_parentForm.Tabs.Count == 0)
                    {
                        m_parentForm.Close();
                    }
                }
            }

            OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, Cursor.Position.X, Cursor.Position.Y, 0));
        }
Ejemplo n.º 3
0
        /// <summary>Retrieves or creates the overlay for <paramref name="parentForm" />.</summary>
        /// <param name="parentForm">Parent form that we are to create the overlay for.</param>
        /// <returns>Newly-created or previously existing overlay for <paramref name="parentForm" />.</returns>
        public static TitleBarTabsOverlay GetInstance(TitleBarTabMainForm parentForm)
        {
            if (!_parents.ContainsKey(parentForm))
            {
                _parents.Add(parentForm, new TitleBarTabsOverlay(parentForm));
            }

            return(_parents[parentForm]);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds <paramref name="window" /> to <see cref="_openWindows" /> and attaches event handlers to its <see cref="Form.FormClosed" /> event to keep track
        /// of it.
        /// </summary>
        /// <param name="window">Window that we're opening.</param>
        public void OpenWindow(TitleBarTabMainForm window)
        {
            if (!_openWindows.Contains(window))
            {
                window.ApplicationContext = this;

                _openWindows.Add(window);
                window.FormClosed += window_FormClosed;
            }
        }
Ejemplo n.º 5
0
        /// <summary>Constructor; takes the initial window to display and, if it's not closing, opens it and shows it.</summary>
        /// <param name="initialFormInstance">Initial window to display.</param>
        public void Start(TitleBarTabMainForm initialFormInstance)
        {
            if (initialFormInstance.IsClosing)
            {
                ExitThread();
            }

            else
            {
                OpenWindow(initialFormInstance);
                initialFormInstance.Show();
            }
        }
Ejemplo n.º 6
0
        /// <summary>Creates the overlay window and attaches it to <paramref name="parentForm" />.</summary>
        /// <param name="parentForm">Parent form that the overlay should be rendered on top of.</param>
        protected TitleBarTabsOverlay(TitleBarTabMainForm parentForm)
        {
            m_parentForm = parentForm;

            // We don't want this window visible in the taskbar
            ShowInTaskbar   = false;
            FormBorderStyle = FormBorderStyle.Sizable;
            MinimizeBox     = false;
            MaximizeBox     = false;
            m_aeroEnabled   = m_parentForm.IsCompositionEnabled;

            Show(m_parentForm);
            AttachHandlers();
        }
Ejemplo n.º 7
0
        /// <summary>Default constructor that initializes the <see cref="_parentWindow" /> and <see cref="ShowAddButton" /> properties.</summary>
        /// <param name="parentWindow">The parent window that this renderer instance belongs to.</param>
        protected BaseTabRenderer(TitleBarTabMainForm parentWindow)
        {
            _parentWindow             = parentWindow;
            ShowAddButton             = true;
            TabRepositionDragDistance = 10;
            TabTearDragDistance       = 10;

            parentWindow.Tabs.CollectionModified += Tabs_CollectionModified;

            if (parentWindow._overlay != null)
            {
                parentWindow._overlay.MouseMove += Overlay_MouseMove;
                parentWindow._overlay.MouseUp   += Overlay_MouseUp;
                parentWindow._overlay.MouseDown += Overlay_MouseDown;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Event handler that is called when <see cref="m_parentForm" /> is in the process of closing.  This uninstalls <see cref="m_hookproc" /> from the low-
        /// level hooks list and stops the consumer thread that processes those events.
        /// </summary>
        /// <param name="sender">Object from which this event originated, <see cref="m_parentForm" /> in this case.</param>
        /// <param name="e">Arguments associated with this event.</param>
        private void _parentForm_Closing(object sender, CancelEventArgs e)
        {
            TitleBarTabMainForm form = (TitleBarTabMainForm)sender;

            if (form == null)
            {
                return;
            }

            if (_parents.ContainsKey(form))
            {
                _parents.Remove(form);
            }

            Application.RemoveMessageFilter(this);
        }
Ejemplo n.º 9
0
 /// <summary>Default constructor that initializes the various properties.</summary>
 /// <param name="parent">Parent window that contains this tab.</param>
 public TitleBarTabItem(TitleBarTabMainForm parent)
 {
     ShowCloseButton = true;
     Parent          = parent;
 }