private static void CmdSetSpecialPronounce_Executed(object sender, ExecutedRoutedEventArgs e) { var viewer = e.Parameter as DMDocumentScrollViewer; if (viewer == null) { return; } var syncable = viewer.SelectedElements.First() as ISyncable; var dpoSync = syncable as DependencyObject; var sentence = syncable.GetParent <DMSentence>(); var editorDialog = new DialogSpeechTextEditor(sentence, new Action <string>( (speechText) => { var dpo = syncable as DependencyObject; if (dpo != null) { SyncExtension.SetSpeechText(dpo, speechText); } })); editorDialog.ShowDialog(); }
public void Selection_Changed(object sender, EventArgs e) { //this.Dely(200); this.SelectedElements.Cast <DependencyObject>().ToList().ForEach( (dpo) => { SyncExtension.SetIsCurrent(dpo, false); }); this.SelectedElements.Clear(); var selection = this.flowDocumentViewer.Selection; TextElement first = null; switch (this.SelectMode) { case SyncControl.SelectMode.Word: first = this.GetSelectedSyncable <SyncableWord>(selection.Start); break; case SyncControl.SelectMode.Phrase: first = this.GetSelectedSyncable <DMPhrase>(selection.Start); break; case SyncControl.SelectMode.Sentence: first = this.GetSelectedSyncable <DMSentence>(selection.Start); break; case SyncControl.SelectMode.Paragraph: first = this.GetSelectedSyncable <DMParagraph>(selection.Start); break; } ISyncable begin = null, end = null; if (first != null) { begin = first as ISyncable; var next = first; while (next != null && next.ElementStart.CompareTo(selection.End) == -1) { this.SelectedElements.Add(next); if (next is ISyncable) { end = next as ISyncable; this.BeginTime = begin.BeginTime; this.EndTime = end.EndTime; } if (next is Inline) { next = (next as Inline).NextInline; } else if (next is Block) { next = (next as Block).NextBlock; } else { break; } } this.flowDocumentViewer.Selection.Changed -= Selection_Changed; this.flowDocumentViewer.Selection.Select(first.ElementStart, this.SelectedElements.Last().ContentEnd); this.flowDocumentViewer.Selection.Changed += Selection_Changed; } if (this.SelectionChanged != null) { this.SelectionChanged(this, new EventArgs()); } this.SelectedElements.Cast <DependencyObject>().ToList().ForEach( (dpo) => { SyncExtension.SetIsCurrent(dpo, true); }); }