本文整理汇总了C#中Mono.TextEditor.MarginMouseEventArgs.TriggersContextMenu方法的典型用法代码示例。如果您正苦于以下问题:C# MarginMouseEventArgs.TriggersContextMenu方法的具体用法?C# MarginMouseEventArgs.TriggersContextMenu怎么用?C# MarginMouseEventArgs.TriggersContextMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.MarginMouseEventArgs
的用法示例。
在下文中一共展示了MarginMouseEventArgs.TriggersContextMenu方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnIconButtonPress
void OnIconButtonPress (object s, MarginMouseEventArgs args)
{
if (args.TriggersContextMenu ()) {
TextEditor.Caret.Line = args.LineNumber;
TextEditor.Caret.Column = 1;
IdeApp.CommandService.ShowContextMenu (WorkbenchWindow.ExtensionContext, "/MonoDevelop/SourceEditor2/IconContextMenu/Editor");
} else if (args.Button == 1) {
if (!string.IsNullOrEmpty (this.Document.FileName)) {
if (args.LineSegment != null)
DebuggingService.Breakpoints.Toggle (this.Document.FileName, args.LineNumber);
}
}
}
示例2: MousePressed
protected internal override void MousePressed (MarginMouseEventArgs args)
{
base.MousePressed (args);
if (args.TriggersContextMenu ())
return;
InSelectionDrag = false;
inDrag = false;
Selection selection = textEditor.MainSelection;
int oldOffset = textEditor.Caret.Offset;
string link = GetLink != null ? GetLink (args) : null;
if (!String.IsNullOrEmpty (link)) {
textEditor.FireLinkEvent (link, args.Button, args.ModifierState);
return;
}
if (args.Button == 1) {
if (!CalculateClickLocation (args.X, args.Y, out clickLocation))
return;
DocumentLine line = Document.GetLine (clickLocation.Line);
bool isHandled = false;
if (line != null) {
foreach (TextLineMarker marker in line.Markers) {
if (marker is IActionTextLineMarker) {
isHandled |= ((IActionTextLineMarker)marker).MousePressed (textEditor, args);
if (isHandled)
break;
}
}
foreach (var marker in Document.GetTextSegmentMarkersAt (line).Where (m => m.IsVisible)) {
if (marker is IActionTextLineMarker) {
isHandled |= ((IActionTextLineMarker)marker).MousePressed (textEditor, args);
if (isHandled)
break;
}
}
}
if (isHandled)
return;
int offset = Document.LocationToOffset (clickLocation);
if (offset < 0) {
textEditor.RunAction (CaretMoveActions.ToDocumentEnd);
return;
}
if (args.Button == 2 && !selection.IsEmpty && selection.Contains (Document.OffsetToLocation (offset))) {
textEditor.ClearSelection ();
return;
}
if (args.Type == EventType.TwoButtonPress) {
var data = textEditor.GetTextEditorData ();
mouseWordStart = data.FindCurrentWordStart (offset);
mouseWordEnd = data.FindCurrentWordEnd (offset);
Caret.Offset = mouseWordEnd;
textEditor.MainSelection = new Selection (textEditor.Document.OffsetToLocation (mouseWordStart), textEditor.Document.OffsetToLocation (mouseWordEnd));
InSelectionDrag = true;
mouseSelectionMode = MouseSelectionMode.Word;
// folding marker
int lineNr = args.LineNumber;
foreach (var shownFolding in GetFoldRectangles (lineNr)) {
if (shownFolding.Item1.Contains ((int)(args.X + this.XOffset), (int)args.Y)) {
shownFolding.Item2.IsFolded = false;
return;
}
}
return;
} else if (args.Type == EventType.ThreeButtonPress) {
int lineNr = Document.OffsetToLineNumber (offset);
textEditor.SetSelectLines (lineNr, lineNr);
var range = textEditor.SelectionRange;
mouseWordStart = range.Offset;
mouseWordEnd = range.EndOffset;
InSelectionDrag = true;
mouseSelectionMode = MouseSelectionMode.WholeLine;
return;
}
mouseSelectionMode = MouseSelectionMode.SingleChar;
if (textEditor.IsSomethingSelected && textEditor.SelectionRange.Offset <= offset && offset < textEditor.SelectionRange.EndOffset && clickLocation != textEditor.Caret.Location) {
inDrag = true;
} else {
if ((args.ModifierState & Gdk.ModifierType.ShiftMask) == ModifierType.ShiftMask) {
InSelectionDrag = true;
Caret.PreserveSelection = true;
if (!textEditor.IsSomethingSelected) {
textEditor.MainSelection = new Selection (Caret.Location, clickLocation);
Caret.Location = clickLocation;
} else {
Caret.Location = clickLocation;
textEditor.ExtendSelectionTo (clickLocation);
}
Caret.PreserveSelection = false;
} else {
//.........这里部分代码省略.........
示例3: OnIconButtonPress
void OnIconButtonPress (object s, MarginMouseEventArgs args)
{
if (args.LineNumber < Mono.TextEditor.DocumentLocation.MinLine)
return;
if (args.TriggersContextMenu ()) {
if (TextEditor.Caret.Line != args.LineNumber) {
TextEditor.Caret.Line = args.LineNumber;
TextEditor.Caret.Column = 1;
}
IdeApp.CommandService.ShowContextMenu (
TextEditor,
args.RawEvent as Gdk.EventButton,
WorkbenchWindow.ExtensionContext ?? AddinManager.AddinEngine,
"/MonoDevelop/SourceEditor2/IconContextMenu/Editor");
} else if (args.Button == 1) {
if (!string.IsNullOrEmpty (Document.FileName)) {
if (args.LineSegment != null) {
int column = TextEditor.Caret.Line == args.LineNumber ? TextEditor.Caret.Column : 1;
lock (breakpoints)
breakpoints.Toggle (Document.FileName, args.LineNumber, column);
}
}
}
}
示例4: MousePressed
protected internal override void MousePressed (MarginMouseEventArgs args)
{
base.MousePressed (args);
if (args.TriggersContextMenu ())
return;
inSelectionDrag = false;
inDrag = false;
Selection selection = textEditor.MainSelection;
int anchor = selection != null ? selection.GetAnchorOffset (this.textEditor.GetTextEditorData ()) : -1;
int oldOffset = textEditor.Caret.Offset;
string link = GetLink != null ? GetLink (args) : null;
if (!String.IsNullOrEmpty (link)) {
textEditor.FireLinkEvent (link, args.Button, args.ModifierState);
return;
}
if (args.Button == 1) {
VisualLocationTranslator trans = new VisualLocationTranslator (this);
clickLocation = trans.PointToLocation (args.X, args.Y);
if (clickLocation.Line < DocumentLocation.MinLine || clickLocation.Column < DocumentLocation.MinColumn)
return;
LineSegment line = Document.GetLine (clickLocation.Line);
bool isHandled = false;
if (line != null) {
foreach (TextMarker marker in line.Markers) {
if (marker is IActionTextMarker) {
isHandled |= ((IActionTextMarker)marker).MousePressed (this.textEditor, args);
if (isHandled)
break;
}
}
}
if (isHandled)
return;
if (line != null && clickLocation.Column >= line.Length + 1 && GetWidth (Document.GetTextAt (line.SegmentIncludingDelimiter) + "-") < args.X) {
clickLocation = new DocumentLocation (clickLocation.Line, line.Length + 1);
if (textEditor.GetTextEditorData ().HasIndentationTracker && textEditor.Options.IndentStyle == IndentStyle.Virtual) {
int indentationColumn = this.textEditor.GetTextEditorData ().GetVirtualIndentationColumn (clickLocation);
if (indentationColumn > clickLocation.Column)
clickLocation = new DocumentLocation (clickLocation.Line, indentationColumn);
}
}
int offset = Document.LocationToOffset (clickLocation);
if (offset < 0) {
textEditor.RunAction (CaretMoveActions.ToDocumentEnd);
return;
}
if (args.Button == 2 && selection != null && selection.Contains (Document.OffsetToLocation (offset))) {
textEditor.ClearSelection ();
return;
}
if (args.Type == EventType.TwoButtonPress) {
var data = textEditor.GetTextEditorData ();
mouseWordStart = data.FindCurrentWordStart (offset);
mouseWordEnd = data.FindCurrentWordEnd (offset);
Caret.Offset = mouseWordEnd;
textEditor.MainSelection = new Selection (textEditor.Document.OffsetToLocation (mouseWordStart), textEditor.Document.OffsetToLocation (mouseWordEnd));
inSelectionDrag = true;
mouseSelectionMode = MouseSelectionMode.Word;
return;
} else if (args.Type == EventType.ThreeButtonPress) {
int lineNr = Document.OffsetToLineNumber (offset);
textEditor.SetSelectLines (lineNr, lineNr);
inSelectionDrag = true;
mouseSelectionMode = MouseSelectionMode.WholeLine;
return;
}
mouseSelectionMode = MouseSelectionMode.SingleChar;
if (textEditor.IsSomethingSelected && textEditor.SelectionRange.Offset <= offset && offset < textEditor.SelectionRange.EndOffset && clickLocation != textEditor.Caret.Location) {
inDrag = true;
} else {
if ((args.ModifierState & Gdk.ModifierType.ShiftMask) == ModifierType.ShiftMask) {
inSelectionDrag = true;
Caret.PreserveSelection = true;
if (!textEditor.IsSomethingSelected) {
textEditor.MainSelection = new Selection (Caret.Location, clickLocation);
Caret.Location = clickLocation;
} else {
Caret.Location = clickLocation;
textEditor.ExtendSelectionTo (clickLocation);
}
Caret.PreserveSelection = false;
} else {
inSelectionDrag = false;
textEditor.ClearSelection ();
Caret.Location = clickLocation;
}
textEditor.RequestResetCaretBlink ();
}
}
DocumentLocation docLocation = PointToLocation (args.X, args.Y);
if (docLocation.Line < DocumentLocation.MinLine || docLocation.Column < DocumentLocation.MinColumn)
//.........这里部分代码省略.........
示例5: MouseHover
internal protected override void MouseHover (MarginMouseEventArgs args)
{
base.MouseHover (args);
if (!args.TriggersContextMenu () && args.Button == 1) {
// DocumentLocation loc = editor.Document.LogicalToVisualLocation (editor.GetTextEditorData (), editor.Caret.Location);
int lineNumber = args.LineNumber >= DocumentLocation.MinLine ? args.LineNumber : editor.Document.LineCount;
editor.Caret.PreserveSelection = true;
editor.Caret.Location = new DocumentLocation (lineNumber, DocumentLocation.MinColumn);
editor.MainSelection = new Selection (anchorLocation, editor.Caret.Location);
editor.Caret.PreserveSelection = false;
}
}
示例6: OnIconButtonPress
void OnIconButtonPress (object s, MarginMouseEventArgs args)
{
if (args.LineNumber < DocumentLocation.MinLine)
return;
if (args.TriggersContextMenu ()) {
if (TextEditor.Caret.Line != args.LineNumber) {
TextEditor.Caret.Line = args.LineNumber;
TextEditor.Caret.Column = 1;
}
IdeApp.CommandService.ShowContextMenu (TextEditor, args.RawEvent as Gdk.EventButton, "/MonoDevelop/SourceEditor2/IconContextMenu/Editor");
} else if (args.Button == 1) {
if (!string.IsNullOrEmpty (this.Document.FileName)) {
if (args.LineSegment != null) {
int column = TextEditor.Caret.Line == args.LineNumber ? TextEditor.Caret.Column : 1;
DebuggingService.Breakpoints.Toggle (this.Document.FileName, args.LineNumber, column);
}
}
}
}