public void ClientToScreen(VideoGrabberFormPositionType type)
        {
            ResetPanels();

            Rectangle r = Screen.PrimaryScreen.Bounds;
            int       x = 0;
            int       y = 0;

            switch (type)
            {
            // 預設
            case VideoGrabberFormPositionType.Default:                                      x = r.Width - videoGrabberFormSize.Width;                       y = Screen.PrimaryScreen.WorkingArea.Height - videoGrabberFormSize.Height; break;

            // 邊角
            case VideoGrabberFormPositionType.CornerUpperLeft:                      x = 0;                                                                                          y = 0;                                                                                          break;

            case VideoGrabberFormPositionType.CornerUpperRight:                     x = r.Width - videoGrabberFormSize.Width;                       y = 0;                                                                                          break;

            case VideoGrabberFormPositionType.CornerLowerLeft:                      x = 0;                                                                                          y = r.Height - videoGrabberFormSize.Height;                     break;

            case VideoGrabberFormPositionType.CornerLowerRight:                     x = r.Width - videoGrabberFormSize.Width;                       y = r.Height - videoGrabberFormSize.Height;                     break;

            case VideoGrabberFormPositionType.CornerMiddleLeft1:            x = 0;                                                                                          y = r.Height / 2 - videoGrabberFormSize.Height;         break;

            case VideoGrabberFormPositionType.CornerMiddleLeft2:            x = 0;                                                                                          y = r.Height / 2;                                                                       break;

            case VideoGrabberFormPositionType.CornerMiddleRight1:           x = r.Width - videoGrabberFormSize.Width;                       y = r.Height / 2 - videoGrabberFormSize.Height;         break;

            case VideoGrabberFormPositionType.CornerMiddleRight2:           x = r.Width - videoGrabberFormSize.Width;                       y = r.Height / 2;                                                                       break;

            // 垂直左
            case VideoGrabberFormPositionType.CornerMiddleLeftUpper:        x = r.Width / 2 - videoGrabberFormSize.Width;           y = 0;                                                                                          break;

            case VideoGrabberFormPositionType.CornerMiddleLeftMiddle1:      x = r.Width / 2 - videoGrabberFormSize.Width;           y = r.Height / 2 - videoGrabberFormSize.Height;         break;

            case VideoGrabberFormPositionType.CornerMiddleLeftMiddle2:      x = r.Width / 2 - videoGrabberFormSize.Width;           y = r.Height / 2;                                                                       break;

            case VideoGrabberFormPositionType.CornerMiddleLeftLower:        x = r.Width / 2 - videoGrabberFormSize.Width;           y = r.Height - videoGrabberFormSize.Height;                     break;

            // 垂直右
            case VideoGrabberFormPositionType.CornerMiddleRightMiddle1:     x = r.Width / 2;                                                                        y = 0;                                                                                          break;

            case VideoGrabberFormPositionType.CornerMiddleRightMiddle2:     x = r.Width / 2;                                                                        y = r.Height / 2 - videoGrabberFormSize.Height;         break;

            case VideoGrabberFormPositionType.CornerMiddleRightUpper:       x = r.Width / 2;                                                                        y = r.Height / 2;                                                                       break;

            case VideoGrabberFormPositionType.CornerMiddleRightLower:       x = r.Width / 2;                                                                        y = r.Height - videoGrabberFormSize.Height;                     break;

            // 中心線
            case VideoGrabberFormPositionType.CenterHLeft:                          x = 0;                                                                                          y = r.Height / 2 - videoGrabberFormSize.Height / 2;     break;

            case VideoGrabberFormPositionType.CenterHLeftMiddle:            x = r.Width / 2 - videoGrabberFormSize.Width;           y = r.Height / 2 - videoGrabberFormSize.Height / 2;     break;

            case VideoGrabberFormPositionType.CenterH:                                      x = r.Width / 2 - videoGrabberFormSize.Width / 2;       y = r.Height / 2 - videoGrabberFormSize.Height / 2;     break;

            case VideoGrabberFormPositionType.CenterHRightMiddle:           x = r.Width / 2;                                                                        y = r.Height / 2 - videoGrabberFormSize.Height / 2;     break;

            case VideoGrabberFormPositionType.CenterHRight:                         x = r.Width - videoGrabberFormSize.Width;                       y = r.Height / 2 - videoGrabberFormSize.Height / 2;     break;

            // 垂直線
            case VideoGrabberFormPositionType.CenterVUpper:                         x = r.Width / 2 - videoGrabberFormSize.Width / 2;       y = 0;                                                                                          break;

            case VideoGrabberFormPositionType.CenterVMiddleUpper:           x = r.Width / 2 - videoGrabberFormSize.Width / 2;       y = r.Height / 2 - videoGrabberFormSize.Height;         break;

            case VideoGrabberFormPositionType.CenterV:                                      x = r.Width / 2 - videoGrabberFormSize.Width / 2;       y = r.Height / 2 - videoGrabberFormSize.Height / 2;     break;

            case VideoGrabberFormPositionType.CenterVMiddleLower:           x = r.Width / 2 - videoGrabberFormSize.Width / 2;       y = r.Height / 2;                                                                       break;

            case VideoGrabberFormPositionType.CenterVLower:                         x = r.Width / 2 - videoGrabberFormSize.Width / 2;       y = r.Height - videoGrabberFormSize.Height;                     break;
            }
            selectedLocation.X = x;
            selectedLocation.Y = y;

            Hide();
            OnPositionChanged();
        }
예제 #2
0
 public void SetPosition(VideoGrabberFormPositionType type)
 {
     positionForm.VideoGrabberFormSize = this.Size;
     positionForm.ClientToScreen(type);
 }