2010-04-16 22 views
1

J'ai récemment passé d'utiliser l'interface IVideoWindow à IVMRWindowlessControl dans mes Winforms personnalisés commande pour afficher la vidéo.Utiliser IVMRWindowlessControl pour afficher la vidéo dans un Winforms contrôle et permettre à bascule plein écran

La raison était de permettre aux capacités de zoom sur la vidéo dans le contrôle.
Cependant, dans la commutation, j'ai trouvé que le mode FullScreen de IVideoWindow n'est pas disponible et je suis en train d'essayer de reproduire ce en utilisant la méthode SetVideoWindow(). Je trouve que je taille la vidéo dans mon contrôle pour être à la même résolution que l'écran mais je ne peux pas obtenir le contrôle pour se positionner en haut/à gauche de l'écran et devenir la fenêtre la plus haute .

Toutes les idées sur la façon d'y parvenir depuis le IVideoWindow :: put_FullScreenMode juste fait pour vous?

Répondre

1

Résolu le problème FullScreen en hébergeant le contrôle vidéo sous une nouvelle forme que j'ai redimensionné à la taille de l'écran actuel, puis manipulé la touche 'Échap' dans le formulaire, pour revenir à la vidéo de taille normale. Voici un extrait du code: -

Membres

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

bascule Code FullScreen

/// <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; 
     } 
    }