2010-04-16 3 views
1

최근에 비디오를 표시하기 위해 IVideoWindow 인터페이스를 사용하여 IVMRWindowlessControl에서 내 사용자 지정 Winforms 컨트롤로 전환했습니다.IVMRWindowlessControl을 사용하여 Winforms 컨트롤에서 비디오를 표시하고 전체 화면 전환 허용

이유는 컨트롤 내의 비디오에 확대/축소 기능을 허용했기 때문입니다.
그러나 전환 할 때 IVideoWindow의 FullScreen 모드를 사용할 수없고 현재 SetVideoWindow() 메서드를 사용하여이 모드를 복제하려고합니다.

컨트롤과 비디오의 해상도가 같아서 화면의 상단/왼쪽에 컨트롤을 배치 할 수없고 최상위 창이 될 때가 있습니다. .

IVideoWindow :: put_FullScreenMode 이후로 이것을 달성하는 방법에 대한 아이디어는 모두 당신을 위해 무엇을 했습니까?

답변

1

비디오 컨트롤을 새로운 형식으로 호스팅하여 전체 화면 문제를 해결 한 후 현재 화면의 크기로 조정 한 다음 양식의 'Esc'키를 눌러 일반 크기 비디오로 되돌립니다.

회원

private Rectangle fullScreenRectangle; 
    private bool fullScreen; 
    private Form fullScreenForm; 
    private Control fullScreenParent; 

전환 전체 화면 코드

/// <summary> 
    /// Toggle Full Screen Mode 
    /// </summary> 
    public bool FullScreen 
    { 
     get 
     { 
      return this.fullScreen; 
     } 
     set 
     { 
      this.fullScreen = value; 

      if (this.fullScreen) 
      { 
       // If switch to full screen, save the current size of the control 
       this.fullScreenRectangle = new Rectangle(this.Location, this.Size); 

       // Get the current screen resolution and set that to be the control's size 
       Rectangle screenRect = Screen.GetBounds(this); 

       // Create a new form on which to host the control whilst we go to full screen mode. 
       this.fullScreenForm = new Form(); 
       this.fullScreenForm.Location = PointToScreen(new Point(0, 0)); 
       this.fullScreenForm.Size = new Size(screenRect.Width, screenRect.Height); 
       this.fullScreenForm.BackColor = Color.Black; 
       this.fullScreenForm.ShowInTaskbar = false; 
       this.fullScreenForm.ShowIcon = false; 
       this.fullScreenForm.FormBorderStyle = FormBorderStyle.None; 
       this.fullScreenForm.KeyPreview = true; 
       this.fullScreenForm.PreviewKeyDown += new PreviewKeyDownEventHandler(fullScreenForm_PreviewKeyDown); 
       this.fullScreenParent = this.Parent; 
       this.fullScreenForm.Controls.Add(this); 
       this.fullScreenForm.Show(); 

       this.windowlessControl.SetVideoPosition(null, screenRect); 
      } 
      else 
      { 
       // Revert to the original control size 
       this.Location = PointToScreen(new Point(this.fullScreenRectangle.Left, this.fullScreenRectangle.Top)); 
       this.Size = new Size(this.fullScreenRectangle.Width, this.fullScreenRectangle.Height); 

       this.windowlessControl.SetVideoPosition(null, this.fullScreenRectangle); 

       if (this.fullScreenForm != null) 
       { 
        this.fullScreenForm.Controls.Remove(this); 

        if (this.fullScreenParent != null) 
         this.Parent = this.fullScreenParent; 

        this.fullScreenForm.PreviewKeyDown -= new PreviewKeyDownEventHandler(fullScreenForm_PreviewKeyDown); 
        this.fullScreenForm.Close(); 
       } 
      } 
     } 
    } 

    void fullScreenForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) 
    { 
     if (e.KeyCode == Keys.Escape) 
     { 
      var viewer = this.Controls[0] as ViewerControl; 

      if (viewer != null) 
       viewer.FullScreen = false; 
     } 
    } 
- : 여기에 코드의 추출물이다
관련 문제