Example #1
0
        private void OnTimerEvent(object sender, EventArgs arg)
        {
            if (subtitleLoadFlag)
            {
                //here is for algoritm for showing subtitle
                // do thing that be do in 100 milisecond

                if (axWindowsMediaPlayer1.status.Equals("Paused"))
                {  // part pause
                    if (detectList.hasSubtitle(axWindowsMediaPlayer1.Ctlcontrols.currentPosition))
                    {
                    }
                    else
                    {
                    }
                }
                else if (axWindowsMediaPlayer1.status.Equals("Stopped"))
                {  // part stop
                    if (detectList.hasSubtitle(axWindowsMediaPlayer1.Ctlcontrols.currentPosition))
                    {
                    }
                    else
                    {
                    }
                    if (detectList.IndexSubtitileOnEdit != -1)
                    {
                        detectList.IndexSubtitileOnEdit = -1;
                    }
                }
                else if (axWindowsMediaPlayer1.status.Remove(7, (axWindowsMediaPlayer1.status.Length - 7)).Equals("Playing"))
                {  // part play
                    double currentPosition = axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
                    if (detectList.hasSubtitle(currentPosition))
                    {
                        if (canChangeSubtitleWithMovie)
                        {
                            if (detectList.IndexSubtitileOnEdit != detectList.GetIndexSubtitle(currentPosition))
                            {
                                if (detectList.IndexSubtitileOnEdit >= 0)
                                {
                                    // replace changed subtitle
                                    detectList.SetStartTime(detectList.IndexSubtitileOnEdit, textBoxShowTime.Text);
                                    detectList.SetTextSubtitle(detectList.IndexSubtitileOnEdit, textBoxSubtitleText.Text);
                                    detectList.SetEndTime(detectList.IndexSubtitileOnEdit, textBoxHideTime.Text);
                                    dataGridView1.Rows[detectList.IndexSubtitileOnEdit].InheritedStyle.ForeColor = Color.Red;
                                    dataGridView1.Rows[detectList.IndexSubtitileOnEdit].Cells[1].Value           = textBoxShowTime.Text;
                                    dataGridView1.Rows[detectList.IndexSubtitileOnEdit].Cells[2].Value           = textBoxHideTime.Text;
                                    dataGridView1.Rows[detectList.IndexSubtitileOnEdit].Cells[3].Value           = textBoxDuration.Text;
                                    dataGridView1.Rows[detectList.IndexSubtitileOnEdit].Cells[4].Value           = textBoxSubtitleText.Text;
                                }

                                // show new subtitle
                                canBeChangeTextBoxFlag          = false;
                                detectList.IndexSubtitileOnEdit = detectList.GetIndexSubtitle(currentPosition);
                                textBoxShowTime.Text            = detectList.GetStartTime(currentPosition);
                                textBoxSubtitleText.Text        = detectList.GetTextSubtitle(currentPosition);
                                textBoxHideTime.Text            = detectList.GetEndTime(currentPosition);
                                textBoxDuration.Text            = detectList.GetDurationTime(currentPosition);
                                canBeChangeTextBoxFlag          = true;
                            }
                        }
                    }
                    else
                    {
                    }
                }
                //  MessageBox.Show(axWindowsMediaPlayer1.status.Remove(7,axWindowsMediaPlayer1.status.Length-7)+"-");
                //  DetectList detectList = new DetectList();
                //  if ( axWindowsMediaPlayer1.Ctlcontrols.currentPosition.ToString();
            }
        }