/// <summary> /// Clears all the existing breakpoints /// </summary> /// <param name="sender">The <see cref="MenuFlyoutItem"/> that was clicked</param> /// <param name="e">The <see cref="RoutedEventArgs"/> for the current event</param> private void RemoveAllBreakpointsButton_Clicked(object sender, RoutedEventArgs e) { BreakpointsCleared?.Invoke(this, BreakpointIndicators.Count); BreakpointIndicators.Clear(); UpdateBreakpointsInfo(); IdeOverlaysCanvas.Invalidate(); CodeEditBox.InvalidateOverlays(); }
/// <summary> /// Sets up a breakpoint when the user taps on the breakpoints area /// </summary> /// <param name="sender">The <see cref="Canvas"/> instance in use</param> /// <param name="e">The <see cref="TappedRoutedEventArgs"/> instance for the event</param> private void BreakpointsCanvas_Tapped(object sender, TappedRoutedEventArgs e) { // Calculate the target vertical offset for the tap double yOffset = e.GetPosition((Border)sender).Y - 8 - // Tap Y offset and adjustment CodeEditBox.VerticalScrollBarMargin.Top + // Top internal padding CodeEditBox.ContentScroller !.VerticalOffset; // Vertical scroll offset // Get the range aligned to the left edge of the tapped line ITextRange range = CodeEditBox.Document.GetRangeFromPoint(new Point(0, yOffset), PointOptions.ClientCoordinates); range.GetRect(PointOptions.Transform, out Rect line, out _); // Get the line number int lineNumber = CodeEditBox.Text.AsSpan(0, range.StartPosition).Count(Characters.CarriageReturn) + 1; if (lineNumber == 1) { return; } // Store or remove the breakpoint if (BreakpointIndicators.ContainsKey(lineNumber)) { BreakpointIndicators.Remove(lineNumber); if (BreakpointIndicators.Count == 0) { BreakpointsBorder.ContextFlyout = null; } BreakpointRemoved?.Invoke(this, new BreakpointToggleEventArgs(lineNumber, BreakpointIndicators.Count)); } else { if (BreakpointIndicators.Count == 0) { BreakpointsBorder.ContextFlyout = BreakpointsMenuFlyout; } BreakpointIndicators.GetOrAddValueRef(lineNumber) = (float)line.Top; BreakpointAdded?.Invoke(this, new BreakpointToggleEventArgs(lineNumber, BreakpointIndicators.Count)); } UpdateBreakpointsInfo(); IdeOverlaysCanvas.Invalidate(); CodeEditBox.InvalidateOverlays(); }
private void View_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (lockEvent) { return; } CodeEditBox code = null;// MainForm.GetActiveCodeBox(); if (code == null) { return; } int line = (int)e.Node.Tag; code.GoTo(line + 15); code.GoTo(line); //code.EditBox.Select(code.EditBox.SelectionStart, e.Node.Text.Length); code.Focus(); }
/// <summary> /// Deletes the last character as if the delete key had been pressed /// </summary> public void DeleteCharacter() { CodeEditBox.DeleteSelectionOrCharacter(); }
/// <summary> /// Inserts a given source <see cref="string"/> into the current selection /// </summary> /// <param name="source">The source text to insert</param> public void InsertText(string source) { CodeEditBox.InsertText(source); }