/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see .
*/
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows;
using System.Windows.Input;
using dnSpy.Contracts.Menus;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Formatting;
using Microsoft.VisualStudio.Utilities;
namespace dnSpy.Contracts.Text.Editor {
///
/// Creates s. You must
/// this interface with a . Optional attributes: ,
/// .
///
public interface IGlyphTextMarkerMouseProcessorProvider {
///
/// Creates a or returns null
///
/// Text view host
/// Margin
///
IGlyphTextMarkerMouseProcessor? GetAssociatedMouseProcessor(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin);
}
///
/// context
///
public interface IGlyphTextMarkerMouseProcessorContext {
///
/// Gets the glyph margin
///
IWpfTextViewMargin Margin { get; }
///
/// Gets the text view host
///
IWpfTextViewHost Host { get; }
///
/// Gets the text view
///
IWpfTextView TextView { get; }
///
/// Gets the line
///
IWpfTextViewLine Line { get; }
///
/// Sorted markers shown in the glyph margin. The first marker is the top most marker.
///
IGlyphTextMarker[] Markers { get; }
///
/// Gets the span provider
///
IGlyphTextMarkerSpanProvider SpanProvider { get; }
}
///
/// mouse processor (see also )
///
public interface IGlyphTextMarkerMouseProcessor {
///
/// Creates context menu objects
///
/// Context
/// Position of the mouse pointer relative to the glyph margin
///
IEnumerable GetContextMenuObjects(IGlyphTextMarkerMouseProcessorContext context, Point marginRelativePoint);
///
/// Mouse down handler
///
/// Context
/// Mouse event args
void OnMouseDown(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e);
///
/// Mouse up handler
///
/// Context
/// Mouse event args
void OnMouseUp(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e);
///
/// Mouse left button down handler
///
/// Context
/// Mouse event args
void OnMouseLeftButtonDown(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e);
///
/// Mouse left button up handler
///
/// Context
/// Mouse event args
void OnMouseLeftButtonUp(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e);
///
/// Mouse right button down handler
///
/// Context
/// Mouse event args
void OnMouseRightButtonDown(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e);
///
/// Mouse right button up handler
///
/// Context
/// Mouse event args
void OnMouseRightButtonUp(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e);
///
/// Mouse move handler
///
/// Context
/// Mouse event args
void OnMouseMove(IGlyphTextMarkerMouseProcessorContext context, MouseEventArgs e);
///
/// Mouse enter handler
///
/// Context
/// Mouse event args
void OnMouseEnter(IGlyphTextMarkerMouseProcessorContext context, MouseEventArgs e);
///
/// Mouse leave handler
///
/// Context
/// Mouse event args
void OnMouseLeave(IGlyphTextMarkerMouseProcessorContext context, MouseEventArgs e);
}
///
/// Abstract class implementing
///
public abstract class GlyphTextMarkerMouseProcessorBase : IGlyphTextMarkerMouseProcessor {
///
/// Constructor
///
protected GlyphTextMarkerMouseProcessorBase() { }
///
/// Creates context menu objects
///
/// Context
/// Position of the mouse pointer relative to the glyph margin
///
public virtual IEnumerable GetContextMenuObjects(IGlyphTextMarkerMouseProcessorContext context, Point marginRelativePoint) {
yield break;
}
///
/// Default mouse down handler
///
/// Context
/// Mouse event args
public virtual void OnMouseDown(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e) { }
///
/// Default mouse up handler
///
/// Context
/// Mouse event args
public virtual void OnMouseUp(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e) { }
///
/// Default mouse left button down handler
///
/// Context
/// Mouse event args
public virtual void OnMouseLeftButtonDown(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e) { }
///
/// Default mouse left button up handler
///
/// Context
/// Mouse event args
public virtual void OnMouseLeftButtonUp(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e) { }
///
/// Default mouse right button down handler
///
/// Context
/// Mouse event args
public virtual void OnMouseRightButtonDown(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e) { }
///
/// Default mouse right button up handler
///
/// Context
/// Mouse event args
public virtual void OnMouseRightButtonUp(IGlyphTextMarkerMouseProcessorContext context, MouseButtonEventArgs e) { }
///
/// Default mouse move handler
///
/// Context
/// Mouse event args
public virtual void OnMouseMove(IGlyphTextMarkerMouseProcessorContext context, MouseEventArgs e) { }
///
/// Default mouse enter handler
///
/// Context
/// Mouse event args
public virtual void OnMouseEnter(IGlyphTextMarkerMouseProcessorContext context, MouseEventArgs e) { }
///
/// Default mouse leave handler
///
/// Context
/// Mouse event args
public virtual void OnMouseLeave(IGlyphTextMarkerMouseProcessorContext context, MouseEventArgs e) { }
}
}