public CodeView(string decompiledFullTypeName) { DecompiledFullTypeName = decompiledFullTypeName; this.adapter = new DecompiledTextEditorAdapter(new SharpDevelopTextEditor { IsReadOnly = true }) { DecompiledFullTypeName = decompiledFullTypeName }; this.Children.Add(adapter.TextEditor); adapter.TextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#"); // add margin this.iconMargin = new IconBarMargin(iconBarManager = new IconBarManager()); this.adapter.TextEditor.TextArea.LeftMargins.Insert(0, iconMargin); this.adapter.TextEditor.TextArea.TextView.VisualLinesChanged += delegate { iconMargin.InvalidateVisual(); }; // add marker service this.textMarkerService = new TextMarkerService(this); this.adapter.TextEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); this.adapter.TextEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); this.adapter.TextEditor.TextArea.TextView.Services.AddService(typeof(ITextMarkerService), textMarkerService); this.adapter.TextEditor.TextArea.TextView.Services.AddService(typeof(IBookmarkMargin), iconBarManager); // add events this.adapter.TextEditor.MouseHover += TextEditorMouseHover; this.adapter.TextEditor.MouseHoverStopped += TextEditorMouseHoverStopped; this.adapter.TextEditor.MouseLeave += TextEditorMouseLeave; }
public CodeView(string decompiledFileName) { this.adapter = new DecompiledTextEditorAdapter(new SharpDevelopTextEditor { IsReadOnly = true }) { DecompiledFileName = decompiledFileName }; this.Children.Add(adapter.TextEditor); adapter.TextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#"); // add margin this.iconMargin = new IconBarMargin(iconBarManager = new IconBarManager()); this.adapter.TextEditor.TextArea.LeftMargins.Insert(0, iconMargin); this.adapter.TextEditor.TextArea.TextView.VisualLinesChanged += delegate { iconMargin.InvalidateVisual(); }; // add marker service this.textMarkerService = new TextMarkerService(adapter.TextEditor.Document); this.adapter.TextEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); this.adapter.TextEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); this.adapter.TextEditor.TextArea.TextView.Services.AddService(typeof(ITextMarkerService), textMarkerService); this.adapter.TextEditor.TextArea.TextView.Services.AddService(typeof(IBookmarkMargin), iconBarManager); // DON'T add the editor in textview ervices - will mess the setting of breakpoints // add events this.adapter.TextEditor.MouseHover += TextEditorMouseHover; this.adapter.TextEditor.MouseHoverStopped += TextEditorMouseHoverStopped; this.adapter.TextEditor.MouseLeave += TextEditorMouseLeave; this.adapter.TextEditor.TextArea.DefaultInputHandler.NestedInputHandlers.Add(new SearchInputHandler(this.adapter.TextEditor.TextArea)); }
public TextMarker(TextMarkerService service, int startOffset, int length) { if (service == null) throw new ArgumentNullException("service"); this.service = service; this.StartOffset = startOffset; this.Length = length; this.markerType = TextMarkerType.None; }
public EnhancedScrollBar(TextEditor editor, TextMarkerService textMarkerService, IChangeWatcher changeWatcher) { if (editor == null) throw new ArgumentNullException("editor"); this.editor = editor; this.textMarkerService = textMarkerService; this.changeWatcher = changeWatcher; editor.Loaded += editor_Loaded; if (editor.IsLoaded) { editor_Loaded(null, null); } }
public CodeEditor() { CodeEditorOptions.Instance.PropertyChanged += CodeEditorOptions_Instance_PropertyChanged; CustomizedHighlightingColor.ActiveColorsChanged += CustomizedHighlightingColor_ActiveColorsChanged; ParserService.ParseInformationUpdated += ParserServiceParseInformationUpdated; this.FlowDirection = FlowDirection.LeftToRight; // code editing is always left-to-right this.CommandBindings.Add(new CommandBinding(SharpDevelopRoutedCommands.SplitView, OnSplitView)); textMarkerService = new TextMarkerService(this); iconBarManager = new IconBarManager(); if (CodeEditorOptions.Instance.EnableChangeMarkerMargin) { changeWatcher = new DefaultChangeWatcher(); } primaryTextEditor = CreateTextEditor(); primaryTextEditorAdapter = (CodeEditorAdapter)primaryTextEditor.TextArea.GetService(typeof(ITextEditor)); Debug.Assert(primaryTextEditorAdapter != null); activeTextEditor = primaryTextEditor; this.Document = primaryTextEditor.Document; primaryTextEditor.SetBinding(TextEditor.DocumentProperty, new Binding("Document") { Source = this }); this.ColumnDefinitions.Add(new ColumnDefinition()); this.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = minRowHeight }); SetRow(primaryTextEditor, 1); this.Children.Add(primaryTextEditor); }
void TextEditorMouseHover(object sender, MouseEventArgs e) { Debug.Assert(sender == this); ToolTipRequestEventArgs args = new ToolTipRequestEventArgs(this.Adapter); var pos = GetPositionFromPoint(e.GetPosition(this)); args.InDocument = pos.HasValue; if (pos.HasValue) { args.LogicalPosition = AvalonEditDocumentAdapter.ToLocation(pos.Value); } TextMarkerService textMarkerService = this.Adapter.GetService(typeof(ITextMarkerService)) as TextMarkerService; if (args.InDocument && textMarkerService != null) { var markersAtOffset = textMarkerService.GetMarkersAtOffset(args.Editor.Document.PositionToOffset(args.LogicalPosition.Line, args.LogicalPosition.Column)); ITextMarker markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null); if (markerWithToolTip != null) { args.SetToolTip(markerWithToolTip.ToolTip); } } if (!args.Handled) { // if request wasn't handled by a marker, pass it to the ToolTipRequestService ToolTipRequestService.RequestToolTip(args); } if (args.ContentToShow != null) { var contentToShowITooltip = args.ContentToShow as ITooltip; if (contentToShowITooltip != null && contentToShowITooltip.ShowAsPopup) { if (!(args.ContentToShow is UIElement)) { throw new NotSupportedException("Content to show in Popup must be UIElement: " + args.ContentToShow); } if (popup == null) { popup = CreatePopup(); } // if popup was only first level, hovering somewhere else closes it if (TryCloseExistingPopup(false)) { // when popup content decides to close, close the popup contentToShowITooltip.Closed += (closedSender, closedArgs) => { popup.IsOpen = false; }; popup.Child = (UIElement)args.ContentToShow; //ICSharpCode.SharpDevelop.Debugging.DebuggerService.CurrentDebugger.IsProcessRunningChanged SetPopupPosition(popup, e); popup.IsOpen = true; } e.Handled = true; } else { if (toolTip == null) { toolTip = new ToolTip(); toolTip.Closed += ToolTipClosed; } toolTip.PlacementTarget = this; // required for property inheritance if (args.ContentToShow is string) { toolTip.Content = new TextBlock { Text = args.ContentToShow as string, TextWrapping = TextWrapping.Wrap }; } else { toolTip.Content = args.ContentToShow; } toolTip.IsOpen = true; e.Handled = true; } } else { // close popup if mouse hovered over empty area if (popup != null) { e.Handled = true; } TryCloseExistingPopup(false); } }
public CodeEditor() { CodeEditorOptions.Instance.PropertyChanged += CodeEditorOptions_Instance_PropertyChanged; CustomizedHighlightingColor.ActiveColorsChanged += CustomizedHighlightingColor_ActiveColorsChanged; ParserService.ParseInformationUpdated += ParserServiceParseInformationUpdated; this.FlowDirection = FlowDirection.LeftToRight; // code editing is always left-to-right this.CommandBindings.Add(new CommandBinding(SharpDevelopRoutedCommands.SplitView, OnSplitView)); textMarkerService = new TextMarkerService(this); iconBarManager = new IconBarManager(); changeWatcher = new DefaultChangeWatcher(); primaryTextEditor = CreateTextEditor(); primaryTextEditorAdapter = (CodeEditorAdapter)primaryTextEditor.TextArea.GetService(typeof(ITextEditor)); Debug.Assert(primaryTextEditorAdapter != null); activeTextEditor = primaryTextEditor; this.Document = primaryTextEditor.Document; primaryTextEditor.SetBinding(TextEditor.DocumentProperty, new Binding("Document") { Source = this }); this.ColumnDefinitions.Add(new ColumnDefinition()); this.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = minRowHeight }); SetRow(primaryTextEditor, 1); this.Children.Add(primaryTextEditor); }
public CodeEditor() { CodeEditorOptions.Instance.PropertyChanged += CodeEditorOptions_Instance_PropertyChanged; CustomizedHighlightingColor.ActiveColorsChanged += CustomizedHighlightingColor_ActiveColorsChanged; SD.ParserService.ParseInformationUpdated += ParserServiceParseInformationUpdated; this.FlowDirection = FlowDirection.LeftToRight; // code editing is always left-to-right this.document = new TextDocument(); var documentServiceContainer = document.GetRequiredService<IServiceContainer>(); textMarkerService = new TextMarkerService(document); documentServiceContainer.AddService(typeof(ITextMarkerService), textMarkerService); iconBarManager = new IconBarManager(); documentServiceContainer.AddService(typeof(IBookmarkMargin), iconBarManager); if (CodeEditorOptions.Instance.EnableChangeMarkerMargin) { changeWatcher = new DefaultChangeWatcher(); } primaryTextEditor = CreateTextEditor(); primaryTextEditorAdapter = (CodeEditorAdapter)primaryTextEditor.TextArea.GetService(typeof(ITextEditor)); Debug.Assert(primaryTextEditorAdapter != null); this.ColumnDefinitions.Add(new ColumnDefinition()); this.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = minRowHeight }); SetRow(primaryTextEditor, 1); this.Children.Add(primaryTextEditor); }
void CreateTextEditor() { if (textEditorHost != null) { return; } textEditor = AvalonEditTextEditorAdapter.CreateAvalonEditInstance(); textEditor.IsReadOnly = true; textEditor.MouseDoubleClick += TextEditorDoubleClick; var adapter = new AvalonEditTextEditorAdapter(textEditor); var textMarkerService = new TextMarkerService(adapter.TextEditor.Document); adapter.TextEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); adapter.TextEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); adapter.TextEditor.TextArea.TextView.Services.AddService(typeof(ITextMarkerService), textMarkerService); textEditorHost = new ElementHost(); textEditorHost.Dock = DockStyle.Fill; textEditorHost.Child = textEditor; }
public TrackAdorner(EnhancedScrollBar enhanchedScrollBar, Grid trackGrid) : base(trackGrid) { this.editor = enhanchedScrollBar.editor; this.textMarkerService = enhanchedScrollBar.textMarkerService; this.Cursor = Cursors.Hand; this.ToolTip = string.Empty; textMarkerService.RedrawRequested += RedrawRequested; editor.TextArea.TextView.VisualLinesChanged += VisualLinesChanged; }
public MainWindow() { _settings = Settings.Default; ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue)); InitializeComponent(); this.Top = _settings.WindowTop; this.Left = _settings.WindowLeft; this.Height = _settings.WindowHeight; this.Width = _settings.WindowLWidth; this.WindowState = (WindowState)_settings.WindowState; _mainRow.Height = new GridLength(_settings.TabControlHeight); _configComboBox.ItemsSource = new[] {"Debug", "Release"}; var config = _settings.Config; _configComboBox.SelectedItem = config == "Release" ? "Release" : "Debug"; _tabControl.SelectedIndex = _settings.ActiveTabIndex; _findGrid.Visibility = System.Windows.Visibility.Collapsed; _foldingStrategy = new NitraFoldingStrategy(); _textBox1Tooltip = new ToolTip { PlacementTarget = _text }; _parseTimer = new Timer { AutoReset = false, Enabled = false, Interval = 300 }; _parseTimer.Elapsed += _parseTimer_Elapsed; _text.TextArea.Caret.PositionChanged += Caret_PositionChanged; _highlightingStyles = new Dictionary<string, HighlightingColor> { { "Keyword", new HighlightingColor { Foreground = new SimpleHighlightingBrush(Colors.Blue) } }, { "Comment", new HighlightingColor { Foreground = new SimpleHighlightingBrush(Colors.Green) } }, { "Number", new HighlightingColor { Foreground = new SimpleHighlightingBrush(Colors.Magenta) } }, { "Operator", new HighlightingColor { Foreground = new SimpleHighlightingBrush(Colors.Navy) } }, { "String", new HighlightingColor { Foreground = new SimpleHighlightingBrush(Colors.Maroon) } }, }; _foldingManager = FoldingManager.Install(_text.TextArea); _textMarkerService = new TextMarkerService(_text.Document); _text.TextArea.TextView.BackgroundRenderers.Add(_textMarkerService); _text.TextArea.TextView.LineTransformers.Add(_textMarkerService); _text.Options.ConvertTabsToSpaces = true; _text.Options.EnableRectangularSelection = true; _text.Options.IndentationSize = 2; _testsTreeView.SelectedValuePath = "FullPath"; LoadTests(); }
private void InitializeTextEditor() { #region AssemblyLoader assemblyLoader = new AssemblyLoader(); assemblyLoader.AssembliesLoading += (sender, args) => OnAssembliesLoading(args.Value); assemblyLoader.InternalAssembliesLoaded += (sender, args) => OnInternalAssembliesLoaded(args.Value); assemblyLoader.AssembliesLoaded += (sender, args) => OnAssembliesLoaded(args.Value); assemblyLoader.AssembliesUnloading += (sender, args) => OnAssembliesUnloading(args.Value); assemblyLoader.InternalAssembliesUnloaded += (sender, args) => OnInternalAssembliesUnloaded(args.Value); assemblyLoader.AssembliesUnloaded += (sender, args) => OnAssembliesUnloaded(args.Value); #endregion #region TextMarkerService textMarkerService = new TextMarkerService(TextEditor.Document); TextEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); TextEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); TextEditor.TextArea.TextView.Services.AddService(typeof(ITextMarkerService), textMarkerService); #endregion #region ReadOnlySectionProvider TextEditor.TextArea.ReadOnlySectionProvider = new MethodDefinitionReadOnlySectionProvider(this); #endregion #region SearchPanel SearchPanel.Install(TextEditor); #endregion #region CompletionCommand CompletionCommand = new Input.RoutedCommand(); CompletionCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.Space, Input.ModifierKeys.Control)); #endregion #region MoveLinesUpCommand var moveLinesUpCommand = new Input.RoutedCommand(); moveLinesUpCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.Up, Input.ModifierKeys.Alt)); var moveLinesUpCommandBinding = new Input.CommandBinding(moveLinesUpCommand, (sender, args) => ExecuteMoveLinesCommand(MovementDirection.Up)); TextEditor.CommandBindings.Add(moveLinesUpCommandBinding); #endregion #region MoveLinesDownCommand var moveLinesDownCommand = new Input.RoutedCommand(); moveLinesDownCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.Down, Input.ModifierKeys.Alt)); var moveLinesDownCommandBinding = new Input.CommandBinding(moveLinesDownCommand, (sender, args) => ExecuteMoveLinesCommand(MovementDirection.Down)); TextEditor.CommandBindings.Add(moveLinesDownCommandBinding); #endregion #region GoToLineCommand var goToLineCommand = new Input.RoutedCommand(); goToLineCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.G, Input.ModifierKeys.Control)); var goToLineCommandBinding = new Input.CommandBinding(goToLineCommand, (sender, args) => ExecuteGoToLineCommand()); TextEditor.CommandBindings.Add(goToLineCommandBinding); #endregion TextEditorSyntaxHighlighting = DefaultTextEditorSyntaxHighlighting; TextEditorShowLineNumbers = DefaultTextEditorShowLineNumbers; TextEditorShowSpaces = DefaultTextEditorShowSpaces; TextEditorShowTabs = DefaultTextEditorShowTabs; TextEditorConvertTabsToSpaces = DefaultTextEditorConvertTabsToSpaces; TextEditorHighlightCurrentLine = DefaultTextEditorHighlightCurrentLine; TextEditorIndentationSize = DefaultTextEditorIndentationSize; Doc.FileName = DefaultDocumentFileName; TextEditor.FontFamily = new Media.FontFamily(DefaultTextEditorFontFamily); TextEditor.FontSize = DefaultTextEditorFontSize; TextEditor.Options.EnableVirtualSpace = true; TextEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(TextEditor.Options); TextEditor.TextChanged += (sender, args) => { foreach (var marker in textMarkerService.TextMarkers) { if (marker == prefixMarker || marker == suffixMarker) continue; if (marker.Length != (int)marker.Tag) marker.Delete(); else { int caretOffset = TextEditor.CaretOffset; var line = Doc.GetLineByOffset(marker.StartOffset); int lineEndOffset = line.EndOffset; if (caretOffset == lineEndOffset) // special case for markers beyond line length marker.Delete(); } } OnTextEditorTextChanged(); }; }
public TrackAdorner(EnhancedScrollBar enhanchedScrollBar) { this.editor = enhanchedScrollBar.editor; this.textMarkerService = enhanchedScrollBar.textMarkerService; this.Cursor = Cursors.Hand; this.ToolTip = string.Empty; textMarkerService.RedrawRequested += textMarkerService_RedrawRequested; }
public TrackBackground(EnhancedScrollBar enhanchedScrollBar) { this.editor = enhanchedScrollBar.editor; this.textMarkerService = enhanchedScrollBar.textMarkerService; this.changeWatcher = enhanchedScrollBar.changeWatcher; textMarkerService.RedrawRequested += textMarkerService_RedrawRequested; }
public MainWindow() { _settings = Settings.Default; _highlightingStyles = new Dictionary<string, HighlightingColor>(StringComparer.OrdinalIgnoreCase); ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue)); InitializeComponent(); _mainRow.Height = new GridLength(_settings.TabControlHeight); _configComboBox.ItemsSource = new[] {"Debug", "Release"}; var config = _settings.Config; _configComboBox.SelectedItem = config == "Release" ? "Release" : "Debug"; _tabControl.SelectedIndex = _settings.ActiveTabIndex; _foldingStrategy = new NitraFoldingStrategy(); _textBox1Tooltip = new ToolTip { PlacementTarget = _text }; _parseTimer = new Timer { AutoReset = false, Enabled = false, Interval = 300 }; _parseTimer.Elapsed += _parseTimer_Elapsed; _text.TextArea.Caret.PositionChanged += Caret_PositionChanged; _foldingManager = FoldingManager.Install(_text.TextArea); _textMarkerService = new TextMarkerService(_text.Document); _text.TextArea.TextView.BackgroundRenderers.Add(_textMarkerService); _text.TextArea.TextView.LineTransformers.Add(_textMarkerService); _text.Options.ConvertTabsToSpaces = true; _text.Options.EnableRectangularSelection = true; _text.Options.IndentationSize = 2; _testsTreeView.SelectedValuePath = "FullPath"; _propertyGrid = new PependentPropertyGrid(); _windowsFormsHost.Child = _propertyGrid; if (string.IsNullOrWhiteSpace(_settings.CurrentSolution)) _solution = null; else LoadTests(); }
private void SetupMarkerService() { textMarkerService = new TextMarkerService(this.textEditor.Document); textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); var textView = textEditor.TextArea.TextView; textView.LineTransformers.Add(textMarkerService); textView.Services.AddService(typeof(ITextMarkerService), textMarkerService); }