예제 #1
0
        /// <summary>
        /// Locate the selected substring in the current TASMovieInput[] object
        /// </summary>
        private void btnFindInput_Click(object sender, EventArgs e)
        {
            if (FrameData == null)
            {
                return;
            }

            int start    = (lvInput.SelectedIndices.Count > 0) ? lvInput.SelectedIndices[0] + 1 : 0;
            int end      = lvInput.Items.Count;
            int position = TASMovieInput.Search(ref FrameData, txtJumpToFrame.Text, start, end);

            if (position < 0)
            {
                if (start > 0)
                {
                    DialogResult answer = MessageBox.Show(MovieSplicer.UI.frmMain.frm,
                                                          "Input pattern not found between selected position and end of movie.\nContinue searching from the beginning?",
                                                          "Continue",
                                                          MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (answer == DialogResult.OK)
                    {
                        position = TASMovieInput.Search(ref FrameData, txtJumpToFrame.Text, 0, start);
                    }
                }
            }

            if (position >= 0 && position < FrameData.Length)
            {
                // clear the selection collection
                // NOTE::This is since we will be creating a new selected items collection
                // with only 1 item (the resulting frame), but we don't want to clear if no results are
                // found (since it'll just jump back to the top and repeat if we do)
                lvInput.SelectedIndices.Clear();

                lvInput.Items[position].Selected = true;
                lvInput.Items[position].Focused  = true;
                lvInput.Focus();
                lvInput.EnsureVisible(position);
            }
            else
            {
                MessageBox.Show(MovieSplicer.UI.frmMain.frm, "Input pattern not found", "Sorry",
                                MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
            }
        }
예제 #2
0
        public bool findNext(string find, bool downward)
        {
            if (Movie == null)
            {
                return(false);
            }

            int start = 0;
            int end   = lvInput.Items.Count;

            if (downward)
            {
                start = lvInput.SelectedIndices.Count > 0 ? lvInput.SelectedIndices[0] + 1 : 0;
            }
            else
            {
                start = (lvInput.SelectedIndices.Count > 0 ? lvInput.SelectedIndices[lvInput.SelectedIndices.Count - 1] : end) - 1;
                end   = -1;
            }

            int position = TASMovieInput.Search(ref FrameData.Input, find, start, end);

            if (position < 0)
            {
                if (lvInput.SelectedIndices.Count > 0)
                {
                    DialogResult answer = MessageBox.Show(MovieSplicer.UI.frmMain.frm,
                                                          "Input pattern not found between selected position and end of movie.\nContinue searching from the "
                                                          + (downward ? "beginning" : "end") + " of the movie?", "Continue",
                                                          MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (answer == DialogResult.OK)
                    {
                        end      = downward ? 0 : lvInput.Items.Count - 1;
                        position = TASMovieInput.Search(ref FrameData.Input, find, end, start);
                    }
                }
            }

            if (position >= 0 && position < FrameData.Input.Length)
            {
                // clear the selection collection
                // NOTE::This is since we will be creating a new selected items collection
                // with only 1 item (the resulting frame), but we don't want to clear if no results are
                // found (since it'll just jump back to the top and repeat if we do)
                lvInput.SelectedIndices.Clear();

                lvInput.Items[position].Selected = true;
                lvInput.Items[position].Focused  = true;
                lvInput.Focus();
                lvInput.EnsureVisible(position);

                return(true);
            }
            else
            {
                MessageBox.Show(this,
                                "Input pattern not found",
                                "Sorry",
                                MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);

                return(false);
            }
        }