Esempio n. 1
0
 public void Show(Control control, DropDownStripAlignType alignType)
 {
     if (control == null)
     {
         throw new ArgumentNullException("control");
     }
     SetOwnerItem(control);
     Show(control, control.ClientRectangle, alignType);
 }
Esempio n. 2
0
        public void Show(Control control, Rectangle area, DropDownStripAlignType alignType)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }
            SetOwnerItem(control);

            Point     location = control.PointToScreen(new Point(area.Left, area.Top + area.Height));
            Rectangle screen   = Screen.FromControl(control).WorkingArea;

            resizableTop = resizableRight = false;
            if (alignType == DropDownStripAlignType.Left)
            {
                //if (location.X + Size.Width > screen.Left + screen.Width)
                //{
                //    resizableRight = true;
                //    location.X = screen.Left + screen.Width - Size.Width;
                //}
            }
            else if (alignType == DropDownStripAlignType.Center)
            {
                //if (location.X + (area.Width + Size.Width) / 2 > screen.Right)
                //{
                //    resizableRight = true;
                //    location.X = screen.Right - Size.Width;
                //}
                //else
                //{
                //    resizableRight = true;
                //    location.X = location.X - (Size.Width - area.Width) / 2;
                //}
                resizableRight = true;
                location.X     = location.X - (Size.Width - area.Width) / 2;
            }
            else //right
            {
                resizableRight = true;
                location.X     = location.X - Size.Width + area.Width;
            }

            if (location.Y + Size.Height > (screen.Top + screen.Height))
            {
                resizableTop = true;
                location.Y  -= Size.Height + area.Height;
            }
            location = control.PointToClient(location);
            Show(control, location, ToolStripDropDownDirection.BelowRight);
        }