Exemplo n.º 1
0
        private void AdjustDisplayTime(bool onlySelectedLines)
        {
            if (IsSubtitleLoaded)
            {
                ReloadFromSourceView();
                var adjustDisplayTime = new AdjustDisplayDuration();
                _formPositionsAndSizes.SetPositionAndSize(adjustDisplayTime);

                ListView.SelectedIndexCollection selectedIndexes = null;
                if (onlySelectedLines)
                {
                    adjustDisplayTime.Text += " - " + _language.SelectedLines;
                    selectedIndexes = SubtitleListview1.SelectedIndices;
                }

                if (adjustDisplayTime.ShowDialog(this) == DialogResult.OK)
                {
                    MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment);
                    if (adjustDisplayTime.AdjustUsingPercent)
                    {
                        double percent = double.Parse(adjustDisplayTime.AdjustValue);
                        _subtitle.AdjustDisplayTimeUsingPercent(percent, selectedIndexes);
                    }
                    else if (adjustDisplayTime.AdjustUsingSeconds)
                    {
                        double seconds = double.Parse(adjustDisplayTime.AdjustValue);
                        _subtitle.AdjustDisplayTimeUsingSeconds(seconds, selectedIndexes);
                    }
                    else
                    { // recalculate durations!!!
                        double maxCharSeconds = (double)(adjustDisplayTime.MaxCharactersPerSecond);
                        _subtitle.RecalculateDisplayTimes(maxCharSeconds, selectedIndexes);
                    }
                    ShowStatus(string.Format(_language.DisplayTimesAdjustedX, adjustDisplayTime.AdjustValue));
                    SaveSubtitleListviewIndexes();
                    if (IsFramesRelevant && CurrentFrameRate > 0)
                    {
                        _subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
                        if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
                            ShowSource();
                    }
                    ShowSource();
                    SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
                    RestoreSubtitleListviewIndexes();
                }
                _formPositionsAndSizes.SavePositionAndSize(adjustDisplayTime);
            }
            else
            {
                MessageBox.Show(_language.NoSubtitleLoaded, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 2
0
        private void AdjustDisplayTime(bool onlySelectedLines)
        {
            if (!IsSubtitleLoaded)
            {
                DisplaySubtitleNotLoadedMessage();
                return;
            }

            ReloadFromSourceView();
            using (var adjustDisplayTime = new AdjustDisplayDuration())
            {
                List<int> selectedIndices = null;
                if (onlySelectedLines)
                {
                    adjustDisplayTime.Text += " - " + _language.SelectedLines;
                    selectedIndices = new List<int>();
                    foreach (int item in SubtitleListview1.SelectedIndices)
                    {
                        selectedIndices.Add(item);
                    }
                }

                if (adjustDisplayTime.ShowDialog(this) == DialogResult.OK)
                {
                    MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment);
                    if (adjustDisplayTime.AdjustUsingPercent)
                    {
                        double percent = double.Parse(adjustDisplayTime.AdjustValue);
                        _subtitle.AdjustDisplayTimeUsingPercent(percent, selectedIndices);
                    }
                    else if (adjustDisplayTime.AdjustUsingSeconds)
                    {
                        double seconds = double.Parse(adjustDisplayTime.AdjustValue);
                        _subtitle.AdjustDisplayTimeUsingSeconds(seconds, selectedIndices);
                    }
                    else
                    { // recalculate durations!!!
                        double maxCharSeconds = (double)(adjustDisplayTime.MaxCharactersPerSecond);
                        _subtitle.RecalculateDisplayTimes(maxCharSeconds, selectedIndices);
                    }
                    ShowStatus(string.Format(_language.DisplayTimesAdjustedX, adjustDisplayTime.AdjustValue));
                    SaveSubtitleListviewIndices();
                    if (IsFramesRelevant && CurrentFrameRate > 0)
                    {
                        _subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
                        if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
                            ShowSource();
                    }
                    ShowSource();
                    SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
                    RestoreSubtitleListviewIndices();
                }
            }
        }
Exemplo n.º 3
0
        private void AdjustDisplayTime(bool onlySelectedLines)
        {
            if (!this.IsSubtitleLoaded)
            {
                this.DisplaySubtitleNotLoadedMessage();
                return;
            }

            this.ReloadFromSourceView();
            using (var adjustDisplayTime = new AdjustDisplayDuration())
            {
                ListView.SelectedIndexCollection selectedIndices = null;
                if (onlySelectedLines)
                {
                    adjustDisplayTime.Text += " - " + this._language.SelectedLines;
                    selectedIndices = this.SubtitleListview1.SelectedIndices;
                }

                if (adjustDisplayTime.ShowDialog(this) == DialogResult.OK)
                {
                    this.MakeHistoryForUndo(this._language.BeforeDisplayTimeAdjustment);
                    if (adjustDisplayTime.AdjustUsingPercent)
                    {
                        double percent = double.Parse(adjustDisplayTime.AdjustValue);
                        this._subtitle.AdjustDisplayTimeUsingPercent(percent, selectedIndices);
                    }
                    else if (adjustDisplayTime.AdjustUsingSeconds)
                    {
                        double seconds = double.Parse(adjustDisplayTime.AdjustValue);
                        this._subtitle.AdjustDisplayTimeUsingSeconds(seconds, selectedIndices);
                    }
                    else
                    { // recalculate durations!!!
                        double maxCharSeconds = (double)adjustDisplayTime.MaxCharactersPerSecond;
                        this._subtitle.RecalculateDisplayTimes(maxCharSeconds, selectedIndices);
                    }

                    this.ShowStatus(string.Format(this._language.DisplayTimesAdjustedX, adjustDisplayTime.AdjustValue));
                    this.SaveSubtitleListviewIndices();
                    if (this.IsFramesRelevant && this.CurrentFrameRate > 0)
                    {
                        this._subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(this.CurrentFrameRate);
                        if (this.tabControlSubtitle.SelectedIndex == TabControlSourceView)
                        {
                            this.ShowSource();
                        }
                    }

                    this.ShowSource();
                    this.SubtitleListview1.Fill(this._subtitle, this._subtitleAlternate);
                    this.RestoreSubtitleListviewIndices();
                }
            }
        }