Beispiel #1
0
        // Needs optimization
        private void MoveWindowControls(WindowControlPosition position)
        {
            switch (position)
            {
            case WindowControlPosition.Right:
                windowControlsContainer.Location = new Point(titleBar.Width - 77, windowControlsContainer.Location.Y);
                windowControlsContainer.Anchor   = AnchorStyles.Right | AnchorStyles.Top;
                settingsButton.Location          = new Point(20, 0);
                settingsButton.Anchor            = AnchorStyles.Left | AnchorStyles.Top;
                // detect if currently close and minimize buttons are switched
                if (closeButton.Location.X < minimizeButton.Location.X)
                {
                    int closeButtonLocationX    = closeButton.Location.X;
                    int minimizeButtonLocationX = minimizeButton.Location.X;
                    closeButton.Location    = new Point(minimizeButtonLocationX, closeButton.Location.Y);
                    minimizeButton.Location = new Point(closeButtonLocationX, closeButton.Location.Y);
                }
                break;

            case WindowControlPosition.Left:
                windowControlsContainer.Location = new Point(12, windowControlsContainer.Location.Y);
                windowControlsContainer.Anchor   = AnchorStyles.Left | AnchorStyles.Top;
                settingsButton.Location          = new Point(titleBar.Width - 49, 0);
                settingsButton.Anchor            = AnchorStyles.Right | AnchorStyles.Top;
                if (closeButton.Location.X > minimizeButton.Location.X)
                {
                    int closeButtonLocationX    = closeButton.Location.X;
                    int minimizeButtonLocationX = minimizeButton.Location.X;
                    closeButton.Location    = new Point(minimizeButtonLocationX, closeButton.Location.Y);
                    minimizeButton.Location = new Point(closeButtonLocationX, closeButton.Location.Y);
                }
                break;
            }
        }
 // Needs optimization
 private void MoveWindowControls(WindowControlPosition position)
 {
     switch (position)
     {
         case WindowControlPosition.Right:
             windowControlsContainer.Location = new Point(titleBar.Width - 77, windowControlsContainer.Location.Y);
             windowControlsContainer.Anchor = AnchorStyles.Right | AnchorStyles.Top;
             settingsButton.Location = new Point(20, 0);
             settingsButton.Anchor = AnchorStyles.Left | AnchorStyles.Top;
             // detect if currently close and minimize buttons are switched
             if (closeButton.Location.X < minimizeButton.Location.X)
             {
                 int closeButtonLocationX = closeButton.Location.X;
                 int minimizeButtonLocationX = minimizeButton.Location.X;
                 closeButton.Location = new Point(minimizeButtonLocationX, closeButton.Location.Y);
                 minimizeButton.Location = new Point(closeButtonLocationX, closeButton.Location.Y);
             }
             break;
         case WindowControlPosition.Left:
             windowControlsContainer.Location = new Point(12, windowControlsContainer.Location.Y);
             windowControlsContainer.Anchor = AnchorStyles.Left | AnchorStyles.Top;
             settingsButton.Location = new Point(titleBar.Width - 49, 0);
             settingsButton.Anchor = AnchorStyles.Right | AnchorStyles.Top;
             if (closeButton.Location.X > minimizeButton.Location.X)
             {
                 int closeButtonLocationX = closeButton.Location.X;
                 int minimizeButtonLocationX = minimizeButton.Location.X;
                 closeButton.Location = new Point(minimizeButtonLocationX, closeButton.Location.Y);
                 minimizeButton.Location = new Point(closeButtonLocationX, closeButton.Location.Y);
             }
             break;
     }
 }