/// <inheritdoc/> public override void Remove() { base.Remove(); _selection.Remove(); _selection = null; }
private void OnPaste(object target, ExecutedRoutedEventArgs args) { if (target != _textEditor.TextArea) { return; } TextArea textArea = _textEditor.TextArea; if (textArea != null && textArea.Document != null) { Debug.WriteLine(Clipboard.GetText(TextDataFormat.Html)); // convert text back to correct newlines for this document string newLine = TextUtilities.GetNewLineFromDocument(textArea.Document, textArea.Caret.Line); string text = TextUtilities.NormalizeNewLines(Clipboard.GetText(), newLine); string[] commands = text.Split(new String[] { newLine }, StringSplitOptions.None); string scriptText = ""; if (commands.Length > 1) { text = newLine; foreach (string command in commands) { text += "... " + command + newLine; scriptText += command.Replace("\t", " ") + newLine; } } if (!string.IsNullOrEmpty(text)) { bool fullLine = textArea.Options.CutCopyWholeLine && Clipboard.ContainsData(LineSelectedType); bool rectangular = Clipboard.ContainsData(RectangleSelection.RectangularSelectionDataType); if (fullLine) { DocumentLine currentLine = textArea.Document.GetLineByNumber(textArea.Caret.Line); if (textArea.ReadOnlySectionProvider.CanInsert(currentLine.Offset)) { textArea.Document.Insert(currentLine.Offset, text); } } else if (rectangular && textArea.Selection.IsEmpty) { if (!RectangleSelection.PerformRectangularPaste(textArea, textArea.Caret.Position, text, false)) { _textEditor.Write(text, false); } } else { _textEditor.Write(text, false); } } textArea.Caret.BringCaretToView(); args.Handled = true; if (commands.Length > 1) { _dispatcherWindow.Dispatcher.BeginInvoke(new Action(delegate() { ExecuteStatements(scriptText); })); } } }
public GenericFileBrowser() { InitializeComponent(); base.BaseLayoutContextFlyout = this.BaseLayoutContextFlyout; base.BaseLayoutItemContextFlyout = this.BaseLayoutItemContextFlyout; switch (AppSettings.DirectorySortOption) { case SortOption.Name: SortedColumn = nameColumn; break; case SortOption.DateModified: SortedColumn = dateColumn; break; case SortOption.FileType: SortedColumn = typeColumn; break; case SortOption.Size: SortedColumn = sizeColumn; break; } var selectionRectangle = RectangleSelection.Create(AllView, SelectionRectangle, AllView_SelectionChanged); selectionRectangle.SelectionStarted += SelectionRectangle_SelectionStarted; selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded; AllView.PointerCaptureLost += AllView_ItemPress; AppSettings.ThemeModeChanged += AppSettings_ThemeModeChanged; }
public ColumnViewBase() : base() { this.InitializeComponent(); CurrentColumn = this; var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged); tapDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer(); }
public GridViewBrowser() : base() { InitializeComponent(); this.DataContext = this; var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged); selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded; }
public GridViewBrowser() { InitializeComponent(); this.DataContext = this; base.BaseLayoutContextFlyout = BaseLayoutContextFlyout; base.BaseLayoutItemContextFlyout = BaseLayoutItemContextFlyout; var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged); selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded; }
public GenericFileBrowser2() : base() { InitializeComponent(); this.DataContext = this; var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged); selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded; renameDoubleClickTimer = DispatcherQueue.GetForCurrentThread().CreateTimer(); }
public ColumnViewBrowser() : base() { this.InitializeComponent(); ColumnViewBrowser1 = this; ColumnViewBase.ItemInvoked += ColumnViewBase_ItemInvoked; ColumnViewBase.UnFocusPreviousListView += ColumnViewBase_UnFocusPreviousListView; ColumnViewBase.DismissColumn += ColumnViewBase_DismissColumn; //this.DataContext = this; var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged); tapDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer(); }
/// <inheritdoc/> public override void ToStateOne() { base.ToStateOne(); _selection = new RectangleSelection( _editor.Project.CurrentContainer.HelperLayer, _rectangle, _editor.Project.Options.HelperStyle, _editor.Project.Options.PointShape); _selection.ToStateOne(); }
public GenericFileBrowser() : base() { InitializeComponent(); var selectionRectangle = RectangleSelection.Create(AllView, SelectionRectangle, AllView_SelectionChanged); selectionRectangle.SelectionStarted += SelectionRectangle_SelectionStarted; selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded; AllView.PointerCaptureLost += AllView_ItemPress; tapDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer(); }
public GridViewBrowser() { this.InitializeComponent(); base.BaseLayoutContextFlyout = this.BaseLayoutContextFlyout; base.BaseLayoutItemContextFlyout = this.BaseLayoutItemContextFlyout; var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged); selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded; App.AppSettings.LayoutModeChangeRequested += AppSettings_LayoutModeChangeRequested; SetItemTemplate(); // Set ItemTemplate }
public GenericFileBrowser() { InitializeComponent(); base.BaseLayoutContextFlyout = BaseLayoutContextFlyout; base.BaseLayoutItemContextFlyout = BaseLayoutItemContextFlyout; tapDebounceTimer = new DispatcherTimer(); var selectionRectangle = RectangleSelection.Create(AllView, SelectionRectangle, AllView_SelectionChanged); selectionRectangle.SelectionStarted += SelectionRectangle_SelectionStarted; selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded; AllView.PointerCaptureLost += AllView_ItemPress; }
public static string GetParent(TextArea sender) { // 获取光标位置前面的至多30个字符 var currentCursorPosition = sender.Caret.Position; var selection = new RectangleSelection(sender, new TextViewPosition(currentCursorPosition.Line, currentCursorPosition.Column - 30 >= 0 ? currentCursorPosition.Column - 30 : 0), currentCursorPosition); // 正则获取Parent var parentMatch = Regex.Match(selection.GetText(), @"(?<=([^\w{}]|^))[^.]*?(?:\[.*?\])?\.(?=\w*$)", RegexOptions.RightToLeft); if (parentMatch.Success) { return(parentMatch.Value); } else { return(""); } }
//private Workspace _workspace; public DataInitialization(int Width, int Height) { var unityContainerInit = new UnityContainer(); _action = unityContainerInit.Resolve <Actions>(); _selectClass = unityContainerInit.Resolve <Selection>(); _pointSelection = unityContainerInit.Resolve <PointSelection>(); _rectangleSelection = unityContainerInit.Resolve <RectangleSelection>(); _drawClass = unityContainerInit.Resolve <DrawOnCanvas>(new OrderedParametersOverride(new object[] { Width, Height, _action })); _editDate = unityContainerInit.Resolve <EditData>(new OrderedParametersOverride(new object[] { _drawClass, _action })); _rectangl = unityContainerInit.Resolve <RectangleFigure>(); _ellipse = unityContainerInit.Resolve <EllipseFigure>(); _line = unityContainerInit.Resolve <Line>(); _poliLine = unityContainerInit.Resolve <PolylineFigure>(); _polygon = unityContainerInit.Resolve <PolygonFigure>(); _rectangleSelect = unityContainerInit.Resolve <RectangleSelect>(); _listFigures.Add(_rectangl); _listFigures.Add(_ellipse); _listFigures.Add(_line); _listFigures.Add(_poliLine); _listFigures.Add(_polygon); _drawListFigures.Add(_rectangl); _drawListFigures.Add(_ellipse); _drawListFigures.Add(_line); _drawListFigures.Add(_poliLine); _drawListFigures.Add(_polygon); _drawListFigures.Add(_rectangleSelect); _selectionList.Add(_pointSelection); _selectionList.Add(_rectangleSelection); _modesList.Add(unityContainerInit.Resolve <DrawMode>(new OrderedParametersOverride(new object[] { _listFigures, _selectClass, _drawClass }))); _modesList.Add(unityContainerInit.Resolve <SelectRegionMode>(new OrderedParametersOverride(new object[] { _listFigures, _selectClass, _drawClass, _editDate, _selectionList }))); _modesList.Add(unityContainerInit.Resolve <SelectPointoMode>(new OrderedParametersOverride(new object[] { _listFigures, _selectClass, _drawClass, _editDate, _selectionList }))); _workspace = new Workspace(_selectClass, _drawClass, _editDate, _listFigures, _modesList, _drawListFigures); }
public static string GetToken(TextArea sender) { // 获取光标位置前面的至多30个字符 var po = sender.Caret.Position; var selection = new RectangleSelection( sender, new TextViewPosition(po.Line, po.Column - 30 >= 0 ? po.Column - 30 : 0), po); // 正则获取Parent var tokenMatch = Regex.Match(selection.GetText(), @"(?<=([^\w]|^))\w*$", RegexOptions.RightToLeft); if (tokenMatch.Success) { return(tokenMatch.Value); } else { return(""); } }
public ColumnViewBrowser() : base() { this.InitializeComponent(); //this.DataContext = this; var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged); }
private static void SurroundRectangleSelectionWithBlockComment(EdiTextEditor editor, BlockDefinition block, RectangleSelection sel) { if (sel == null) { return; } // Backup current view position of rectangular selection int selectionStart = editor.SelectionStart; int selectionLength = editor.SelectionLength; int caretOffset = editor.CaretOffset; TextViewPosition startPos = new TextViewPosition(sel.StartPosition); TextViewPosition endPos = new TextViewPosition(sel.EndPosition); TextReplaceBlockRegion[] region = new TextReplaceBlockRegion[sel.Segments.Count()]; bool bFoundNoMatch = true; for (int i = sel.Segments.Count() - 1; i >= 0; i--) { var item = sel.Segments.ElementAt(i); // Attempt to find the currently set comment before and after the current selection switch (block.TypeOfBlock) { case BlockDefinition.BlockAt.Start: region[i] = FindSelectedStartCommentRegion(block.StartBlock, editor.Document, editor.Document.GetText(item), item.StartOffset, item.Length); break; case BlockDefinition.BlockAt.End: region[i] = FindSelectedEndCommentRegion(block.EndBlock, editor.Document, editor.Document.GetText(item), item.StartOffset); break; case BlockDefinition.BlockAt.StartAndEnd: region[i] = FindSelectedCommentRegion(block.StartBlock, block.EndBlock, editor.Document, editor.Document.GetText(item), item.StartOffset, item.Length); break; default: throw new NotImplementedException(block.TypeOfBlock.ToString()); } if (region[i] == null) { bFoundNoMatch = false; } } if (bFoundNoMatch == true) { for (int i = sel.Segments.Count() - 1; i >= 0; i--) { var item = sel.Segments.ElementAt(i); // Remove the block surround (comment) if there is a match available switch (block.TypeOfBlock) { case BlockDefinition.BlockAt.Start: editor.Document.Remove(region[i].StartOffset, region[i].CommentStart.Length); break; case BlockDefinition.BlockAt.End: editor.Document.Remove(region[i].EndOffset, region[i].CommentEnd.Length); break; case BlockDefinition.BlockAt.StartAndEnd: editor.Document.Remove(region[i].EndOffset, region[i].CommentEnd.Length); editor.Document.Remove(region[i].StartOffset, region[i].CommentStart.Length); break; default: throw new NotImplementedException(block.TypeOfBlock.ToString()); } } } else { for (int i = sel.Segments.Count() - 1; i >= 0; i--) { var item = sel.Segments.ElementAt(i); switch (block.TypeOfBlock) { case BlockDefinition.BlockAt.Start: editor.Document.Insert(item.StartOffset, block.StartBlock); break; case BlockDefinition.BlockAt.End: editor.Document.Insert(item.EndOffset, block.EndBlock); break; case BlockDefinition.BlockAt.StartAndEnd: // Insert a new comment since we could not find one ... editor.Document.Insert(item.EndOffset, block.EndBlock); editor.Document.Insert(item.StartOffset, block.StartBlock); break; default: throw new NotImplementedException(block.TypeOfBlock.ToString()); } } // Move original selection to the rigth and apply rectangular selection editor.CaretOffset = caretOffset; editor.SelectionStart = selectionStart; editor.SelectionLength = selectionLength; //startPos.Column += block.StartBlock.Length; //endPos.Column += block.StartBlock.Length; // Reset selection to keep the text that was originally selected editor.TextArea.Selection = new RectangleSelection(editor.TextArea, startPos, endPos); } }
public ColumnViewBase() : base() { this.InitializeComponent(); CurrentColumn = this; var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged); }
/// <summary> /// Insert a start string and an end string /// before and after the currently selected text. /// </summary> /// <param name="editor"></param> /// <param name="block"></param> static public void SurroundSelectionWithBlockComment(EdiTextEditor editor, BlockDefinition block) { if (editor == null) { return; } RectangleSelection sel = null; // Rectangle selection is a different deal... if ((editor.TextArea.Selection is RectangleSelection) == true) { sel = editor.TextArea.Selection as RectangleSelection; if (sel == null) { return; } // Single line block selection can be treaded like normal selection if (sel.IsMultiline == true) { SurroundRectangleSelectionWithBlockComment(editor, block, sel); return; } } // BlockSurround the current cursor location if there is no current selection ////if (editor.SelectionLength == 0) //// return; // Attempt to find the currently set comment before and after the current selection TextReplaceBlockRegion region = null; switch (block.TypeOfBlock) { case BlockDefinition.BlockAt.Start: region = FindSelectedStartCommentRegion(block.StartBlock, editor.Document, editor.SelectedText, editor.SelectionStart, editor.SelectionLength); break; case BlockDefinition.BlockAt.End: region = FindSelectedEndCommentRegion(block.EndBlock, editor.Document, editor.SelectedText, editor.SelectionStart); break; case BlockDefinition.BlockAt.StartAndEnd: region = FindSelectedCommentRegion(block.StartBlock, block.EndBlock, editor.Document, editor.SelectedText, editor.SelectionStart, editor.SelectionLength); break; default: throw new NotImplementedException(block.TypeOfBlock.ToString()); } // Remove the block surround (comment) if there is a match available if (region != null) { switch (block.TypeOfBlock) { case BlockDefinition.BlockAt.Start: editor.Document.Remove(region.StartOffset, region.CommentStart.Length); break; case BlockDefinition.BlockAt.End: editor.Document.Remove(region.EndOffset, region.CommentEnd.Length); break; case BlockDefinition.BlockAt.StartAndEnd: editor.Document.Remove(region.EndOffset, region.CommentEnd.Length); editor.Document.Remove(region.StartOffset, region.CommentStart.Length); break; default: throw new NotImplementedException(block.TypeOfBlock.ToString()); } } else { int startOffset = editor.SelectionStart; int endOffset = editor.SelectionStart + editor.SelectionLength; int lenOffset = editor.SelectionLength; switch (block.TypeOfBlock) { case BlockDefinition.BlockAt.Start: editor.Document.Insert(startOffset, block.StartBlock); break; case BlockDefinition.BlockAt.End: editor.Document.Insert(endOffset, block.EndBlock); break; case BlockDefinition.BlockAt.StartAndEnd: // Insert a new comment since we could not find one ... editor.Document.Insert(endOffset, block.EndBlock); editor.Document.Insert(startOffset, block.StartBlock); break; default: throw new NotImplementedException(block.TypeOfBlock.ToString()); } // Reset selection to keep the text that was originally selected editor.Select(startOffset + block.StartBlock.Length, lenOffset); } }