private bool SelectFirstRunWord() { Paragraph firstParagraph = Paragraphs.FirstBlock as Paragraph; if (firstParagraph == null) { return(false); } ARun firstWord = firstParagraph.Inlines.FirstInline as ARun; if (IsPlayingOnlyText) { while (firstWord != null && firstWord.IsImage) { firstWord = firstWord.LogicalNext(); } } if (firstWord == null) { return(false); } firstWord.Select(); return(true); }
private bool SelectPreviousRunWord() { if (CurrentRunWord == null) { return(false); } ARun prevRun = CurrentARun.LogicalPrevious(); if (IsPlayingOnlyText) { while (prevRun != null && prevRun.IsImage) { prevRun = prevRun.LogicalPrevious(); } } if (prevRun == null) { return(false); } prevRun.Select(); return(true); }
private bool SelectNextRunWord() { if (CurrentRunWord == null) { return(false); } ARun nextRun = CurrentARun.LogicalNext(); if (IsPlayingOnlyText) { while (nextRun != null && nextRun.IsImage) { nextRun = nextRun.LogicalNext(); } } if (nextRun == null) { return(false); } nextRun.Select(); return(true); }
private void Run_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ARun run = sender as ARun; run.Cursor = Cursors.Wait; switch (CurrentState) { case State.Stop: if (e.ClickCount == 1) { run.Select(); run.PlayCachedSound(); } else if (e.ClickCount == 2) { StopSound(); run.Select(); if (run is RunWord) { CurrentState = State.Edit; } } break; case State.Play: if (e.ClickCount == 1) { CurrentState = State.Stop; StopSound(); run.Select(); run.PlayCachedSound(); } else if (e.ClickCount == 2) { StopSound(); run.Select(); if (run is RunWord) { CurrentState = State.Edit; } } break; case State.Segment: if (e.ClickCount == 1) { if (run is RunImage) { run.Select(); break; } RunWord curRun = run as RunWord; RichTextBox rtb = curRun.IsImage ? ImageCaptionRTB : BookContentRTB; TextPointer curPointer = rtb.GetPositionFromPoint(e.GetPosition(run), false); if (curPointer == null) { return; } TextPointerContext contextPrev = curPointer.GetPointerContext(GoBackward); TextPointerContext contextNext = curPointer.GetPointerContext(GoForward); // MERGE if (contextNext == TextPointerContext.ElementEnd) { curRun.MergeWithNext(); } else if (contextPrev == TextPointerContext.ElementStart) { curRun.MergeWithPrev(); } // SPLIT else if (contextPrev == contextNext && contextNext == TextPointerContext.Text) { RunWord newRun = curRun.SplitAt(curPointer); InitiateRun(newRun); newRun.UpdateBackground(); //newRun.UpdateSegmentedBackground(); } } break; case State.Edit: if (e.ClickCount == 1) { CurrentState = State.Stop; run.Select(); run.PlayCachedSound(); } else if (e.ClickCount == 2) { run.Select(); if (run is RunWord) { CurrentState = State.Edit; } } break; case State.Caption: break; } run.Cursor = Cursors.Hand; }