private void AddBookmark(string text, TextRenderData first, TextRenderData last, Color color) { BookmarkModel bookmark = _bookmarkRepository.AddBookmark( ViewModel.BookId, PageCanvas.Bookmarks, text, ColorHelper.ToInt32(color), first.TokenID, last.TokenID); var previousPageWord = PageCanvas.PreviousTexts.LastOrDefault() ?? new TextRenderData(); if (first.TokenID == previousPageWord.TokenID) { PageCanvas.Highlight(PageCanvas.GetPrevPagePanel(), previousPageWord.Rect, previousPageWord.Rect, bookmark, color); } var nextPageWord = PageCanvas.NextTexts.FirstOrDefault() ?? new TextRenderData(); if (last.TokenID == nextPageWord.TokenID) { PageCanvas.Highlight(PageCanvas.GetNextPagePanel(), nextPageWord.Rect, nextPageWord.Rect, bookmark, color); } PageCanvas.Highlight(PageCanvas.GetCurrentPagePanel(), first.Rect, last.Rect, bookmark, color); }
public void ClearSelection() { _actionButtonsTimer.Stop(); SelectionActions.Hide(); FirstSelectionText = LastSelectionText = null; SelectionPolygon.Visibility = Visibility.Collapsed; RightSelectionItem.Visibility = LeftSelectionItem.Visibility = Visibility.Collapsed; }
private void InitTextSelection(TextRenderData word, TextRenderData wordContinuation) { AppBar.Close(); PageCanvas.Manipulator.Pause(); PageCanvas.SetSelection(word, wordContinuation); ManipulationService.SetManipulationListener(PageCanvas, _textManipulationListener); TouchPanel.EnabledGestures = GestureType.FreeDrag; AppBar.Visibility = Visibility.Collapsed; PageCanvas.ShowActionButtons(); }
private void AddBookmark(string text, TextRenderData first, TextRenderData last) { ColorSelector.Show(); ClearTextSelection(); ManipulationService.SetManipulationListener(PageCanvas, _dummyManipulationListenner); _bookmarkText = text; _bookmarkFirstTextContext = first; _bookmarkLastTextContext = last; }
public void SetSelection(TextRenderData wa, TextRenderData wb) { SelectionActions.Hide(); Rect rect = wa.Rect; Rect lastSelectionRect = wb.Rect; Polygon currentPolygon = SelectionPolygon; if (currentPolygon == null) { return; } if (rect.Top > lastSelectionRect.Top || Math.Abs(rect.Top - lastSelectionRect.Top) < 0.0001 && rect.Left > lastSelectionRect.Left) { TextRenderData textContext = wa; wa = wb; wb = textContext; } if (FirstSelectionText == wa && LastSelectionText == wb) { return; } FirstSelectionText = wa; LastSelectionText = wb; Rect firstSelectionRect = wa.Rect; lastSelectionRect = wb.Rect; PointCollection selectionPolygon = GetSelectionPolygon(firstSelectionRect, lastSelectionRect, GetCurrentPagePanel().ActualWidth); currentPolygon.Points = selectionPolygon; currentPolygon.Fill = AppSettings.Default.ColorScheme.SelectionBrush; currentPolygon.Visibility = Visibility.Visible; BuildSelectionItem(LeftSelectionItem, firstSelectionRect.Left - 11, firstSelectionRect.Top, firstSelectionRect.Height); BuildSelectionItem(RightSelectionItem, lastSelectionRect.Right - 11, lastSelectionRect.Top, lastSelectionRect.Height); var tmp = (firstSelectionRect.Left + SelectionActions.Width + OffsetX) - GetCurrentPagePanel().ActualWidth; tmp = tmp < 0 ? 0 : tmp; var leftMargin = firstSelectionRect.Left - tmp; var topMargin = firstSelectionRect.Top - SelectionActions.Height - 12; topMargin = topMargin < 0 ? 0 : topMargin; SelectionActions.Margin = new Thickness(leftMargin, topMargin, 0, 0); }
private void OnTextManipulatonStated(object sender, ManipulationStartedEventArgs e) { Point manipulationPoint = GetManipulationPoint(e.ManipulationOrigin, e.ManipulationContainer); _firstWord = PageCanvas.FirstSelectionText; _lastWord = PageCanvas.LastSelectionText; double num1 = _firstWord.Rect.DistanceTo(manipulationPoint); double num2 = _lastWord.Rect.DistanceTo(manipulationPoint); if (num1 > num2) { TextRenderData textContext = _firstWord; _firstWord = _lastWord; _lastWord = textContext; num1 = num2; } _textManipulationStarted = num1 < 30.0; }
private static Polygon RenderHighlight(BookmarkModel bookmarkModel, Panel canvas, PageRenderData context) { int tokenID = bookmarkModel.TokenID; TextRenderData firstHighlightedText = context.Texts.FirstOrDefault(t => t.TokenID == tokenID) ?? (context.Texts).FirstOrDefault(); if (firstHighlightedText == null) { return(null); } int endTokenID = bookmarkModel.EndTokenID; TextRenderData lastHighlightedText = context.Texts.LastOrDefault(t => t.TokenID == endTokenID) ?? (context.Texts).LastOrDefault(); if (lastHighlightedText == null) { return(null); } Rect firtstRect = firstHighlightedText.Rect; Rect lastRect = lastHighlightedText.Rect; var pointCollection = SelectionHelper.GetSelectionPolygon( firtstRect, lastRect, canvas.ActualWidth, context.OffsetX, Convert.ToDouble(AppSettings.Default.FontSettings.FontInterval)); var polygon = new Polygon { Width = canvas.ActualWidth, Height = canvas.ActualHeight, Fill = new SolidColorBrush(ColorHelper.ToColor(bookmarkModel.Color)) { Opacity = 0.3 }, Points = pointCollection, Visibility = Visibility.Visible }; return(polygon); }
private void OnTextManipulatonDelta(object sender, ManipulationDeltaEventArgs e) { Vector2 vector2 = new Vector2(); while (TouchPanel.IsGestureAvailable) { vector2 = TouchPanel.ReadGesture().Position; } if (Orientation == PageOrientation.LandscapeLeft) { vector2 = new Vector2(vector2.Y, 480f - vector2.X); } else if (Orientation == PageOrientation.LandscapeRight) { vector2 = new Vector2((float)ActualWidth - vector2.Y, vector2.X); } if (!this._textManipulationStarted) { return; } var point = new Point(vector2.X - _offsetX, vector2.Y - _offsetY); TextRenderData a = PageCanvas.CurrentTexts.FirstOrDefault(l => l.Rect.Contains(point)); if (a == null) { return; } if (a.TokenID < _lastWord.TokenID) { a = PageCanvas.CurrentTexts.FirstOrDefault(l => l.TokenID == a.TokenID); } else { a = PageCanvas.CurrentTexts.LastOrDefault(l => l.TokenID == a.TokenID); } PageCanvas.SetSelection(a, _lastWord); Debug.WriteLine(_lastWord.Text); }
private void PageOnHold(object sender, PointManipulationEventArgs e) { var point = e.ManipulationOrigin; var word = PageCanvas.CurrentTexts.FirstOrDefault(l => l.Rect.Contains(point)); if (word == null) { return; } var words = PageCanvas.CurrentTexts.Where(w => w.TokenID == word.TokenID).ToList(); word = words.FirstOrDefault(); TextRenderData wordContinuation = words.LastOrDefault() ?? word; //TextRenderData word = PageCanvas.CurrentTexts.FirstOrDefault(l => l.Rect.Contains(point)); InitTextSelection(word, wordContinuation); }