コード例 #1
0
        /// <summary>
        /// Shows the dialog to subtitle track.
        /// </summary>
        /// <param name="subTitles">A VclControl class instance's SubTitles.All collection.</param>
        /// <param name="trackDescription">A VclControl class instance's SubTitles.Current member.</param>
        /// <returns>A Vlc.DotNet.Core.TrackDescription class instance or null, if no subtitle was selected.</returns>
        public static TrackDescription Execute(IEnumerable <TrackDescription> subTitles, TrackDescription trackDescription)
        {
            if (subTitles == null || subTitles.Count() == 0) // Nothing to select from so return null
            {
                return(null);
            }

            FormSelectSubtitle selectSubtitleForm = new FormSelectSubtitle(); // Create the form

            int subID = -1;                                                   // Id if a VclControl class instance's SubTitles.Current member was null.

            if (trackDescription != null)                                     // Get the current subtitles ID..
            {
                subID = trackDescription.ID;
            }

            foreach (TrackDescription desc in subTitles) // List the subtitle tracks..
            {
                selectSubtitleForm.lbSubtitles.Items.Add(desc);
            }

            for (int i = 0; i < selectSubtitleForm.lbSubtitles.Items.Count; i++) // if a subtitle with and ID is found on the list, select it..
            {
                if (((TrackDescription)selectSubtitleForm.lbSubtitles.Items[i]).ID == subID)
                {
                    selectSubtitleForm.lbSubtitles.SelectedIndex = i;
                    break; // no reason to iterate them all..
                }
            }

            if (selectSubtitleForm.ShowDialog() == DialogResult.OK) // If user selects OK, then return the selected TrackDescription class instance..
            {
                return(selectSubtitleForm.lbSubtitles.SelectedItem as TrackDescription);
            }
            else // Otherwise, return null
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: FormPlayer.cs プロジェクト: VPKSoft/vamp
        // Handle all the button clicks (Panel).
        private void CommonClickHandler(object sender, EventArgs e)
        {
            if (sender.GetType() != typeof(Panel)) // only accept panels..
            {
                return;
            }

            Panel btn = (sender as Panel);

            if (btn.Equals(btnWindForward))       // if the wind forward was clicked..
            {
                wind   = !wind;                   // toggle the state..
                rewind = false;                   // disable rewind to avoid "mental" state..
            }
            else if (btn.Equals(btnWindBackward)) // if the wind forward was clicked..
            {
                rewind = !rewind;                 // toggle the state..
                wind   = false;                   // disable wind to avoid "mental" state..
            }
            else if (btn.Equals(btnPause))
            {
                TogglePause();
            }
            else if (btn.Equals(btnPlay))
            {
                if (wind || rewind)
                {
                    wind   = false;
                    rewind = false;
                    if (!vlcControl.IsPlaying)
                    {
                        vlcControl.Play();
                    }
                }
                else if (!vlcControl.IsPlaying) // If pausing is possible..
                {
                    TogglePause();              // .. do the pause thing.
                }
            }
            else if (btn.Equals(btnStop)) // Stop button was clicked..
            {
                if (startPlay)
                {
                    Database.UpdateFile(file.FullName, vlcControl.Time, vlcControl.Length, IsWacthed, Volume);
                }
                closeForm = true;              // signal the timer to close the form..
            }
            else if (btn.Equals(btnSeekStart)) // If to-the-beginning button was clicked
            {
                tmMain.Enabled = false;        // disable the timer from doing it's job..
                // No winding/rewinding
                wind            = false;
                rewind          = false;
                vlcControl.Time = 0;         // Back to start
                tmMain.Enabled  = true;      // .. enable the timer to do it's job.
            }
            else if (btn.Equals(btnSeekEnd)) // If to-the-ending button was clicked
            {
                tmMain.Enabled = false;      // disable the timer from doing it's job..
                // No winding/rewinding
                wind            = false;
                rewind          = false;
                vlcControl.Time = vlcControl.Length - 1;          // To the end
                tmMain.Enabled  = true;                           // .. enable the timer to do it's job.
            }
            else if (btn.Equals(btnVolume))                       // the volume button was clicked..
            {
                int volume = Convert.ToInt32(btn.Tag.ToString()); // get the saved volume, if zero set to hundred (muted by the volume slider)
                volume = volume == 0 ? 100 : volume;

                sliderPosition.Scroll -= sliderPosition_Scroll; // detach the event handler, so the slider does not launch the scroll event..
                if (muted)
                {
                    muted = false;                                     // not muted..
                    btn.BackgroundImage = Properties.Resources.volume; // set the image to not muted..
                    sliderVolume.Value  = volume;                      // set the volume..
                    btn.Tag             = volume;                      // save the volume to the Tag property
                }
                else
                {
                    muted               = true;                            // set to muted..
                    btn.Tag             = sliderVolume.Value;              // save the volume to the Tag property
                    sliderVolume.Value  = 0;                               // set the volume slider to 0 = muted
                    btn.BackgroundImage = Properties.Resources.volume_off; // set the image to muted..
                }
                // set the tool-tip value
                lbToolTip.Text         = DBLangEngine.GetMessage("msgVolumePercentage", "Volume: {0}%|As in a tool-tip to describe volume and its percentage value", (sliderVolume.Value * 300) / sliderVolume.Maximum);
                sliderPosition.Scroll += sliderPosition_Scroll;   // re-attach the event handler back..
            }
            else if (btn.Equals(btnSelectSubtitle))               // Select subtitle was clicked..
            {
                m_GlobalHook.MouseMove -= M_GlobalHook_MouseMove; // don't listen the global events when a dialog is visible..
                m_GlobalHook.MouseDown -= M_GlobalHook_MouseDown; // don't listen the global events when a dialog is visible..

                // as the user which subtitle track one might want..
                TrackDescription desc = FormSelectSubtitle.Execute(vlcControl.SubTitles.All, vlcControl.SubTitles.Current);
                if (desc != null) // if something was selected assign it to be the current subtitle track..
                {
                    vlcControl.SubTitles.Current = desc;
                }
                m_GlobalHook.MouseMove += M_GlobalHook_MouseMove; // start listening the global events again as the dialog closed..
                m_GlobalHook.MouseDown += M_GlobalHook_MouseDown; // start listening the global events again as the dialog closed..
            }
            SetButtonStates();                                    // sets the button states to enabled / disabled depending on the playback "conditions"..
        }