void Select(IFitFunction func) { bool changed = false; if (_doc.FitEnsemble.Count == 0) // Fitting is fresh, we can add the function silently { FitElement newele = new FitElement(); newele.FitFunction = func; _doc.FitEnsemble.Add(newele); _doc.SetDefaultParametersForFitElement(0); changed = true; } else if (_doc.FitEnsemble.Count > 0 && _doc.FitEnsemble[_doc.FitEnsemble.Count - 1].FitFunction == null) { _doc.FitEnsemble[_doc.FitEnsemble.Count - 1].FitFunction = func; _doc.SetDefaultParametersForFitElement(_doc.FitEnsemble.Count - 1); changed = true; } else // Count>0, and there is already a fit function, we { // have to ask the user whether he wants to discard the old functions or keep them System.Enum selchoice = _lastSelectionChoice; if (Current.Gui.ShowDialog(ref selchoice, "As only or as additional?")) { _lastSelectionChoice = (SelectionChoice)selchoice; if (_lastSelectionChoice == SelectionChoice.SelectAsAdditional) { FitElement newele = new FitElement(); newele.FitFunction = func; _doc.FitEnsemble.Add(newele); _doc.SetDefaultParametersForFitElement(_doc.FitEnsemble.Count - 1); changed = true; } else // select as only { _doc.FitEnsemble[0].FitFunction = func; _doc.SetDefaultParametersForFitElement(0); for (int i = _doc.FitEnsemble.Count - 1; i >= 1; --i) { _doc.FitEnsemble.RemoveAt(i); } changed = true; } } } if (changed) { // _doc.FitEnsemble.InitializeParameterSetFromEnsembleParameters(_doc.CurrentParameters); this._fitEnsembleController.Refresh(); } }
public void ShowEarlierOrLater(double adjustMilliseconds, SelectionChoice selection) { if (subtitleListView1.SelectedItems.Count < 1) { return; } if (selection == SelectionChoice.AllLines) { for (int i = 0; i < _subtitle.Paragraphs.Count; i++) { ShowEarlierOrLaterParagraph(adjustMilliseconds, i); } } else if (selection == SelectionChoice.SelectionAndForward) { for (int i = subtitleListView1.SelectedItems[0].Index; i < _subtitle.Paragraphs.Count; i++) { ShowEarlierOrLaterParagraph(adjustMilliseconds, i); } } else if (selection == SelectionChoice.SelectionOnly) { for (int i = subtitleListView1.SelectedItems[0].Index; i < _subtitle.Paragraphs.Count; i++) { if (subtitleListView1.Items[i].Selected) { ShowEarlierOrLaterParagraph(adjustMilliseconds, i); } } } var idx = subtitleListView1.SelectedItems[0].Index; subtitleListView1.Fill(_subtitle); subtitleListView1.SelectIndexAndEnsureVisible(_subtitle.GetParagraphOrDefault(idx)); }
public void ShowEarlierOrLater(double adjustMilliseconds, SelectionChoice selection) { var tc = new TimeCode(adjustMilliseconds); MakeHistoryForUndo(_language.BeforeShowSelectedLinesEarlierLater + ": " + tc); if (adjustMilliseconds < 0) { if (selection == SelectionChoice.AllLines) ShowStatus(string.Format(_language.ShowAllLinesXSecondsLinesEarlier, adjustMilliseconds / -TimeCode.BaseUnit)); else if (selection == SelectionChoice.SelectionOnly) ShowStatus(string.Format(_language.ShowSelectedLinesXSecondsLinesEarlier, adjustMilliseconds / -TimeCode.BaseUnit)); else if (selection == SelectionChoice.SelectionAndForward) ShowStatus(string.Format(_language.ShowSelectionAndForwardXSecondsLinesEarlier, adjustMilliseconds / -TimeCode.BaseUnit)); } else { if (selection == SelectionChoice.AllLines) ShowStatus(string.Format(_language.ShowAllLinesXSecondsLinesLater, adjustMilliseconds / TimeCode.BaseUnit)); else if (selection == SelectionChoice.SelectionOnly) ShowStatus(string.Format(_language.ShowSelectedLinesXSecondsLinesLater, adjustMilliseconds / TimeCode.BaseUnit)); else if (selection == SelectionChoice.SelectionAndForward) ShowStatus(string.Format(_language.ShowSelectionAndForwardXSecondsLinesLater, adjustMilliseconds / TimeCode.BaseUnit)); } double frameRate = CurrentFrameRate; SubtitleListview1.BeginUpdate(); int startFrom = 0; if (selection == SelectionChoice.SelectionAndForward) { if (SubtitleListview1.SelectedItems.Count > 0) startFrom = SubtitleListview1.SelectedItems[0].Index; else startFrom = _subtitle.Paragraphs.Count; } for (int i = startFrom; i < _subtitle.Paragraphs.Count; i++) { switch (selection) { case SelectionChoice.SelectionOnly: if (SubtitleListview1.Items[i].Selected) ShowEarlierOrLaterParagraph(adjustMilliseconds, i); break; case SelectionChoice.AllLines: case SelectionChoice.SelectionAndForward: ShowEarlierOrLaterParagraph(adjustMilliseconds, i); break; } } SubtitleListview1.EndUpdate(); if (_subtitle.WasLoadedWithFrameNumbers) _subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(frameRate); RefreshSelectedParagraph(); UpdateSourceView(); UpdateListSyntaxColoring(); }
void Select(IFitFunction func) { bool changed = false; if (_doc.FitEnsemble.Count == 0) // Fitting is fresh, we can add the function silently { FitElement newele = new FitElement(); newele.FitFunction = func; _doc.FitEnsemble.Add(newele); _doc.SetDefaultParametersForFitElement(0); changed = true; } else if (_doc.FitEnsemble.Count > 0 && _doc.FitEnsemble[_doc.FitEnsemble.Count - 1].FitFunction == null) { _doc.FitEnsemble[_doc.FitEnsemble.Count - 1].FitFunction = func; _doc.SetDefaultParametersForFitElement(_doc.FitEnsemble.Count - 1); changed = true; } else // Count>0, and there is already a fit function, we { // have to ask the user whether he wants to discard the old functions or keep them System.Enum selchoice = _lastSelectionChoice; if (Current.Gui.ShowDialog(ref selchoice, "As only or as additional?")) { _lastSelectionChoice = (SelectionChoice)selchoice; if (_lastSelectionChoice == SelectionChoice.SelectAsAdditional) { FitElement newele = new FitElement(); newele.FitFunction = func; _doc.FitEnsemble.Add(newele); _doc.SetDefaultParametersForFitElement(_doc.FitEnsemble.Count - 1); changed = true; } else // select as only { _doc.FitEnsemble[0].FitFunction = func; _doc.SetDefaultParametersForFitElement(0); for (int i = _doc.FitEnsemble.Count - 1; i >= 1; --i) _doc.FitEnsemble.RemoveAt(i); changed = true; } } } if (changed) { // _doc.FitEnsemble.InitializeParameterSetFromEnsembleParameters(_doc.CurrentParameters); this._fitEnsembleController.Refresh(); } }