private void Window_Loaded(object sender, RoutedEventArgs e) { foreach (TextMediaBindableRun curRun in UrakawaHtmlFlowDocument.GetChildren <TextMediaBindableRun>(mFlowViewer.Document, true)) { addMouseButtonEventHandler(curRun); } }
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]; } }
private void Application_Startup(object sender, StartupEventArgs e) { string errMsg; if (!ParseCommandLineArguments(e.Args, out errMsg)) { MessageBox.Show( String.Format("{0}\nUsage: FlowDocumentXmlEditor [-xuk:<xuk_uri>]", errMsg)); this.Shutdown(-1); return; } mProject = new Project(); //MainWindow mw1 = new MainWindow(); mw2 = new MainWindow(mProject, mProjectUri); if (mProjectUri != null) { OpenXukAction action = new OpenXukAction(mProject, mProjectUri); bool wasCancelled; ProgressWindow.ExecuteProgressAction(action, out wasCancelled); if (wasCancelled) { Shutdown(-1); return; } } if (mProject.NumberOfPresentations > 0) { Presentation pres = mProject.GetPresentation(0); TextChannel textCh = null; foreach (Channel ch in pres.ChannelsManager.ListOfChannels) { if (ch is TextChannel) { textCh = (TextChannel)ch; break; } } //UrakawaHtmlFlowDocument doc1 = new UrakawaHtmlFlowDocument(pres.getRootNode(), textCh); //mw1.EditedDocument = doc1; GenericExtractionVisitor.USE_TEXT_BOX_UIELEMENT = false; UrakawaHtmlFlowDocument doc2 = new UrakawaHtmlFlowDocument(pres.RootNode, textCh); mw2.EditedDocument = doc2; } //mw1.Show(); mw2.Show(); }
private void FlowDocument_MouseDown(object sender, MouseButtonEventArgs e) { return; Point mousePosition = Mouse.GetPosition(mFlowViewer); TextPointer ptr = UrakawaHtmlFlowDocument.GetPositionFromPoint(mFlowViewer, 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]; } }