Esempio n. 1
0
        public void DockFloaty(DockStyle how)
        {
            switch (how)
            {
            case DockStyle.Top:
            case DockStyle.Bottom:
                if (m_floaty.DockMode == DockStyle.None && m_floaty.Visible)
                {
                    m_lastFloatLocation = (m_floaty as Control).FindForm().Bounds;
                }
                m_floaty.Dock(how);
                this.SendToBack();
                break;

            case DockStyle.None:
                m_floaty.Float();
                if (m_lastFloatLocation.Height > 10)                         // mainly making sure not 0,0,0,0
                {
                    bool fVisible = false;
                    foreach (Screen screen in Screen.AllScreens)
                    {
                        // We'll accept it as 'visible' if the screen contains the center top and the top is at least
                        // 30 pixels above the bottom of the screen. The number is arbitrary, but should make at least
                        // part of the title bar available to drag it by, without restricting people who want a very
                        // small one at the bottom of the screen.
                        if (screen.WorkingArea.Contains(new Point(m_lastFloatLocation.Left + m_lastFloatLocation.Width / 2,
                                                                  m_lastFloatLocation.Top)) &&
                            m_lastFloatLocation.Top + 30 < screen.WorkingArea.Bottom)
                        {
                            fVisible = true;
                            break;
                        }
                    }
                    if (fVisible)
                    {
                        (m_floaty as Control).FindForm().Bounds = m_lastFloatLocation;
                    }
                }
                break;

            default:
                return;                         // ignored.
            }
        }
Esempio n. 2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Called when the user clicked the Top menu item. Should dock to the top.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event
 /// data.</param>
 /// ------------------------------------------------------------------------------------
 private void OnDockTopClicked(object sender, EventArgs e)
 {
     m_floaty.Dock(DockStyle.Top);
 }