private string FixCasing(string text, string lastLine, List<string> namesEtc) { string original = text; if (radioButtonNormal.Checked) { if (checkBoxOnlyAllUpper.Checked && text != text.ToUpper()) return text; if (text.Length > 1) { // first all to lower text = text.ToLower().Trim(); text = text.FixExtraSpaces(); var st = new StripableText(text); st.FixCasing(namesEtc, false, true, true, lastLine); // fix all casing but names (that's a seperate option) text = st.MergedString; } } else if (radioButtonUppercase.Checked) { var st = new StripableText(text); text = st.Pre + st.StrippedText.ToUpper() + st.Post; text = HtmlUtil.FixUpperTags(text); // tags inside text } else if (radioButtonLowercase.Checked) { text = text.ToLower(); } if (original != text) _noOfLinesChanged++; return text; }
private void GeneratePreview() { Cursor = Cursors.WaitCursor; listViewFixes.BeginUpdate(); listViewFixes.Items.Clear(); foreach (Paragraph p in _subtitle.Paragraphs) { string text = p.Text; foreach (ListViewItem item in listViewNames.Items) { string name = item.SubItems[1].Text; string textNoTags = HtmlUtil.RemoveHtmlTags(text); if (textNoTags != textNoTags.ToUpper()) { if (item.Checked && text != null && text.Contains(name, StringComparison.OrdinalIgnoreCase) && name.Length > 1 && name != name.ToLower()) { var st = new StripableText(text); st.FixCasing(new List<string> { name }, true, false, false, string.Empty); text = st.MergedString; } } } if (text != p.Text) AddToPreviewListView(p, text); } listViewFixes.EndUpdate(); groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.ChangeCasingNames.LinesFoundX, listViewFixes.Items.Count); Cursor = Cursors.Default; }