public void curRun_MouseEnter(object sender, MouseEventArgs e) { TextMediaBindableRun senderRun = (TextMediaBindableRun)sender; senderRun.Background = Brushes.Red; senderRun.TextDecorations.Add(mOverTextDecoration); /* * DeactivateLastBorder(); * * InlineUIContainer newBorderWrap = new InlineUIContainer(tb); * * Border b = new Border(); * b.BorderThickness = 2; * //b.BorderBrush = * * inlines.InsertAfter(run, newInlineBoxed); * inlines.Remove(run); * * run.MouseDown -= new MouseButtonEventHandler(curRun_MouseDown); * run.MouseEnter -= new MouseEventHandler(curRun_MouseEnter); * run.MouseLeave -= new MouseEventHandler(curRun_MouseLeave); * * run.InvalidateBinding(); * * mLastBorder = newBorderWrap; * senderRun; */ }
public void curRun_MouseLeave(object sender, MouseEventArgs e) { TextMediaBindableRun senderRun = (TextMediaBindableRun)sender; senderRun.Background = Brushes.White; senderRun.TextDecorations.Remove(mOverTextDecoration); }
public void curRun_MouseDown(object sender, MouseButtonEventArgs e) { if (!(e.LeftButton == MouseButtonState.Pressed && e.ClickCount == 2)) { return; } Point mousePosition = Mouse.GetPosition(mFlowViewer); TextMediaBindableRun senderRun = (TextMediaBindableRun)sender; InlineCollection inlines = null; if (senderRun.Parent is Span) { Span o = senderRun.Parent as Span; inlines = o.Inlines; } else if (senderRun.Parent is Paragraph) { Paragraph o = senderRun.Parent as Paragraph; inlines = o.Inlines; } else if (senderRun.Parent is TextBlock) { TextBlock o = senderRun.Parent as TextBlock; inlines = o.Inlines; } else { Debug.Print("Should never happen"); } if (inlines != null) { DoMouseDownStuff(senderRun, inlines); } TextPointer ptr = UrakawaHtmlFlowDocument.GetPositionFromPoint(senderRun, mousePosition); if (ptr != null) { string textAfterCursor = ptr.GetTextInRun(LogicalDirection.Forward); string textBeforeCursor = ptr.GetTextInRun(LogicalDirection.Backward); string[] textsAfterCursor = textAfterCursor.Split('.', ' '); string[] textsBeforeCursor = textBeforeCursor.Split('.', ' '); string currentWord = textsBeforeCursor[textsBeforeCursor.Length - 1] + textsAfterCursor[0]; } }
void thisKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter || e.Key == Key.Escape) { TextMediaBindableRun run = CloseSelf(e.Key == Key.Enter); App.mw2.addMouseButtonEventHandler(run); App.mw2.ResetLastInlineBoxed(); } }
public void addMouseButtonEventHandler(TextMediaBindableRun run) { if (run != null) { run.MouseDown += new MouseButtonEventHandler(curRun_MouseDown); run.MouseEnter += new MouseEventHandler(curRun_MouseEnter); run.MouseLeave += new MouseEventHandler(curRun_MouseLeave); } }
private void DeactivateLastInlineBoxed() { if (mLastInlineBoxed != null) { TextMediaBindableRun newRun = mLastInlineBoxed.CloseSelf(false); addMouseButtonEventHandler(newRun); mLastInlineBoxed = null; } }
private void DoMouseDownStuff(TextMediaBindableRun run, InlineCollection inlines) { DeactivateLastInlineBoxed(); TextMediaTextBox tb = new TextMediaTextBox(run.TextMedia); InlineUIContainer newInlineBoxed = new InlineUIContainer(tb); inlines.InsertAfter(run, newInlineBoxed); inlines.Remove(run); run.MouseDown -= new MouseButtonEventHandler(curRun_MouseDown); run.MouseEnter -= new MouseEventHandler(curRun_MouseEnter); run.MouseLeave -= new MouseEventHandler(curRun_MouseLeave); run.InvalidateBinding(); mLastInlineBoxed = tb; }
private TextMediaBindableRun DoCloseSelf(bool saveContent, InlineUIContainer container, InlineCollection inlines) { if (saveContent) { BindingExpression be = GetBindingExpression(TextBox.TextProperty); be.UpdateSource(); //mLastInlineBoxed.OriginalText.setText(mLastInlineBoxed.Text); if (Text != OriginalText.Text) { //newRun.Text = mLastInlineBoxed.Text; } } TextMediaBindableRun newRun = new TextMediaBindableRun(OriginalText); InvalidateBinding(); inlines.InsertAfter(container, newRun); inlines.Remove(container); return(newRun); }