Exemplo n.º 1
0
        private void SetTrackerPos(DesktopEdge pos)
        {
            if (tracker != null)
            {
                Funktionen.SnapWindow(tracker, pos, 5);
            }

            trackerpos = pos;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Verschiebt ein Fenster an der angegebenen Desktopposition
        /// </summary>
        public static void SnapWindow(Form Frm, DesktopEdge Edge, int Spacing)
        {
            int posx = 0;
            int posy = 0;

            switch (Edge)
            {
            case DesktopEdge.TopLeft:
                posx = Spacing;
                posy = Spacing;
                break;

            case DesktopEdge.TopCenter:
                posx = SystemInformation.WorkingArea.Width / 2 - Frm.Width / 2;
                posy = Spacing;
                break;

            case DesktopEdge.TopRight:
                posx = SystemInformation.WorkingArea.Width - Frm.Width - Spacing;
                posy = Spacing;
                break;

            case DesktopEdge.CenterLeft:
                posx = Spacing;
                posy = SystemInformation.WorkingArea.Height / 2 - Frm.Height / 2;
                break;

            case DesktopEdge.Center:
                posx = SystemInformation.WorkingArea.Width / 2 - Frm.Width / 2;
                posy = SystemInformation.WorkingArea.Height / 2 - Frm.Height / 2;
                break;

            case DesktopEdge.CenterRight:
                posx = SystemInformation.WorkingArea.Width - Frm.Width - Spacing;
                posy = SystemInformation.WorkingArea.Height / 2 - Frm.Height / 2;
                break;

            case DesktopEdge.BottomLeft:
                posx = Spacing;
                posy = SystemInformation.WorkingArea.Height - Frm.Height - Spacing;
                break;

            case DesktopEdge.BottomCenter:
                posx = SystemInformation.WorkingArea.Width / 2 - Frm.Width / 2;
                posy = SystemInformation.WorkingArea.Height - Frm.Height - Spacing;
                break;

            case DesktopEdge.BottomRight:
                posx = SystemInformation.WorkingArea.Width - Frm.Width - Spacing;
                posy = SystemInformation.WorkingArea.Height - Frm.Height - Spacing;
                break;
            }

            Frm.Location = new System.Drawing.Point(posx, posy);
        }