public override void ShowDropWindow()
 {
     if (!bDropWindowOpened)
     {
         bDropWindowOpened = true;
         DropWindow dw = new DropWindow();
         dw.Result     += new StringsEventHandler(dw_Result);
         dw.FormClosed += new FormClosedEventHandler(dw_FormClosed);
         dw.Show();
         Rectangle taskbar = NativeMethods.GetTaskbarRectangle();
         if (Engine.ConfigUI.LastDropBoxPosition == Point.Empty)
         {
             dw.Location = new Point(SystemInformation.PrimaryMonitorSize.Width - dw.Width - 100,
                                     SystemInformation.PrimaryMonitorSize.Height - taskbar.Height - dw.Height - 10);
         }
         else
         {
             dw.Location = Engine.ConfigUI.LastDropBoxPosition;
         }
     }
 }
Exemplo n.º 2
0
        public static void UpdateLocation(DropWindow wnd, double left, double top, double width, double height)
        {
            double hrectoffset = 0, vrectoffset = 0;

            if (wnd.Host is LayoutDocumentGroupControl)
            {
                var dcrt  = wnd.Host as LayoutDocumentGroupControl;
                int index = dcrt.IndexOf();
                wnd.Width  = width;
                wnd.Height = height;
                if (wnd.DropPanel.InnerRect.Width < wnd.MinWidth)
                {
                    hrectoffset = (wnd.MinWidth - wnd.DropPanel.InnerRect.Width) / 2;
                    if (index == 0)
                    {
                        wnd.Width += hrectoffset;
                        left      -= hrectoffset;
                    }
                    if (index == dcrt.ParentChildrenCount - 1)
                    {
                        wnd.Width += hrectoffset;
                    }
                }
                if (wnd.DropPanel.InnerRect.Height < wnd.MinHeight)
                {
                    vrectoffset = (wnd.MinHeight - wnd.DropPanel.InnerRect.Height) / 2;
                    if (index == 0)
                    {
                        wnd.Height += vrectoffset;
                        top        -= vrectoffset;
                    }
                    if (index == dcrt.ParentChildrenCount - 1)
                    {
                        wnd.Height += vrectoffset;
                    }
                }


                if (left < 0)
                {
                    wnd.HorizontalOffset = 0;
                    hrectoffset         += left;
                }
                else if (left + wnd.Width > SystemParameters.VirtualScreenWidth)
                {
                    wnd.HorizontalOffset = SystemParameters.VirtualScreenWidth - wnd.Width;
                    hrectoffset         += left + wnd.Width - SystemParameters.VirtualScreenWidth;
                }
                else
                {
                    wnd.HorizontalOffset = left;
                }

                if (top < 0)
                {
                    wnd.VerticalOffset = 0;
                    vrectoffset       += top;
                }
                else if (top + wnd.Height > SystemParameters.VirtualScreenHeight)
                {
                    wnd.VerticalOffset = SystemParameters.VirtualScreenHeight - wnd.Height;
                    vrectoffset       += top + wnd.Height - SystemParameters.VirtualScreenHeight;
                }
                else
                {
                    wnd.VerticalOffset = top;
                }

                wnd.DropPanel.OuterRect = new Rect(hrectoffset, vrectoffset, width, height);
            }
            else
            {
                wnd.Width  = width;
                wnd.Height = height;
                if (wnd.MinWidth > width)
                {
                    hrectoffset = (wnd.MinWidth - width) / 2;
                    left       -= hrectoffset;
                    width       = wnd.MinWidth;
                }
                if (wnd.MinHeight > height)
                {
                    vrectoffset = (wnd.MinHeight - height) / 2;
                    top        -= vrectoffset;
                    height      = wnd.MinHeight;
                }


                if (left < 0)
                {
                    wnd.HorizontalOffset = 0;
                    hrectoffset         += left;
                }
                else if (left + width > SystemParameters.VirtualScreenWidth)
                {
                    wnd.HorizontalOffset = SystemParameters.VirtualScreenWidth - width;
                    hrectoffset         += left + width - SystemParameters.VirtualScreenWidth;
                }
                else
                {
                    wnd.HorizontalOffset = left;
                }

                if (top < 0)
                {
                    wnd.VerticalOffset = 0;
                    vrectoffset       += top;
                }
                else if (top + height > SystemParameters.VirtualScreenHeight)
                {
                    wnd.VerticalOffset = SystemParameters.VirtualScreenHeight - height;
                    vrectoffset       += top + height - SystemParameters.VirtualScreenHeight;
                }
                else
                {
                    wnd.VerticalOffset = top;
                }
                wnd.DropPanel.InnerRect = new Rect(hrectoffset, vrectoffset, wnd.Width, wnd.Height);
                wnd.DropPanel.OuterRect = new Rect(0, 0, wnd.Width, wnd.Height);
            }
        }