private void DoMergeWords() { var cnt = SelectedTextParts.Count; if (cnt == 0) { Messenger.Default.Send("No selection"); return; } TextPart mergedWords = null; var toDelete = new List <TextPart>(); TextPart firstPart = null; var foundCount = 0; var orderedParts = SelectedTextParts.Distinct().OrderBy(a => a.StartMills).ToList(); foreach (var word in orderedParts) { //if (foundCount == cnt) //{ // break; // found all //} if (SelectedTextParts.Contains(word)) { if (mergedWords == null) { mergedWords = new TextPart { StartMills = word.StartMills, Text = "" }; firstPart = word; } else { toDelete.Add(word); } mergedWords.Text = mergedWords.Text.Trim() + " " + word.Text.Trim(); //mergedWords.TextWidth += word.TextWidth; foundCount++; } } //mergedWords.Text = mergedWords.Text.Trim(); firstPart.Text = mergedWords.Text; var lastPart = orderedParts[orderedParts.Count - 1]; firstPart.TextWidth = (lastPart.StartMills + lastPart.TextWidth) - firstPart.StartMills; for (var ix = 0; ix < toDelete.Count; ix++) { TextParts.Remove(toDelete[ix]); } RaisePropertyChanged("FullText"); }
private void DoSelectedDelete() { if (SelectedTextParts == null || SelectedTextParts.Count == 0) { return; } var copied = SelectedTextParts.ToList(); var answ = System.Windows.MessageBox.Show($"Are you sure you want to delete {copied.Count} selected text bits?", "Confirm delete...", MessageBoxButton.YesNo); if (answ == MessageBoxResult.Yes) { for (var x = 0; x < copied.Count; x++) { TextParts.Remove(copied[x]); } } RaisePropertyChanged("FullText"); }