Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4034 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
14 changed files with 276 additions and 8 deletions
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows; |
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using System.Windows.Controls; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.CodeCompletion |
||||
{ |
||||
/// <summary>
|
||||
/// A popup-like window.
|
||||
/// </summary>
|
||||
public class InsightWindow : CompletionWindowBase |
||||
{ |
||||
TextDocument document; |
||||
int startOffset; |
||||
int endOffset; |
||||
|
||||
/// <summary>
|
||||
/// Creates a new InsightWindow.
|
||||
/// </summary>
|
||||
public InsightWindow(TextArea textArea) : base(textArea) |
||||
{ |
||||
this.SizeToContent = SizeToContent.WidthAndHeight; |
||||
// prevent user from resizing window to 0x0
|
||||
this.MinHeight = 15; |
||||
this.MinWidth = 30; |
||||
|
||||
startOffset = endOffset = this.TextArea.Caret.Offset; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets whether the insight window should close automatically.
|
||||
/// The default value is true.
|
||||
/// </summary>
|
||||
public bool CloseAutomatically { get; set; } |
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool CloseOnFocusLost { |
||||
get { return this.CloseAutomatically; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the start of the text range in which the insight window stays open.
|
||||
/// Has no effect if CloseAutomatically is false.
|
||||
/// </summary>
|
||||
public int StartOffset { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the end of the text range in which the insight window stays open.
|
||||
/// Has no effect if CloseAutomatically is false.
|
||||
/// </summary>
|
||||
public int EndOffset { get; set; } |
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void AttachEvents() |
||||
{ |
||||
base.AttachEvents(); |
||||
document = this.TextArea.Document; |
||||
if (document != null) { |
||||
document.Changing += textArea_Document_Changing; |
||||
} |
||||
this.TextArea.Caret.PositionChanged += CaretPositionChanged; |
||||
} |
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void DetachEvents() |
||||
{ |
||||
if (document != null) { |
||||
document.Changing -= textArea_Document_Changing; |
||||
} |
||||
this.TextArea.Caret.PositionChanged -= CaretPositionChanged; |
||||
base.DetachEvents(); |
||||
} |
||||
|
||||
void textArea_Document_Changing(object sender, DocumentChangeEventArgs e) |
||||
{ |
||||
startOffset = e.GetNewOffset(startOffset, AnchorMovementType.BeforeInsertion); |
||||
endOffset = e.GetNewOffset(endOffset, AnchorMovementType.AfterInsertion); |
||||
} |
||||
|
||||
void CaretPositionChanged(object sender, EventArgs e) |
||||
{ |
||||
int offset = this.TextArea.Caret.Offset; |
||||
if (offset < startOffset || offset > endOffset) { |
||||
Close(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.AvalonEdit; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using ICSharpCode.AvalonEdit.CodeCompletion; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Editor |
||||
{ |
||||
public class AvalonEditInsightWindow : InsightWindow, IInsightWindow |
||||
{ |
||||
public AvalonEditInsightWindow(TextArea textArea) : base(textArea) |
||||
{ |
||||
} |
||||
|
||||
ObservableCollection<IInsightItem> items = new ObservableCollection<IInsightItem>(); |
||||
|
||||
public IList<IInsightItem> Items { |
||||
get { return items; } |
||||
} |
||||
|
||||
public IInsightItem SelectedItem { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Editor |
||||
{ |
||||
/// <summary>
|
||||
/// An item in the insight window.
|
||||
/// </summary>
|
||||
public interface IInsightItem |
||||
{ |
||||
object Header { get; } |
||||
object Content { get; } |
||||
} |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Editor |
||||
{ |
||||
/// <summary>
|
||||
/// Describes a set of insight items (e.g. multiple overloads of a method) to be displayed in the insight window.
|
||||
/// </summary>
|
||||
public interface IInsightWindow |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the items to display.
|
||||
/// </summary>
|
||||
IList<IInsightItem> Items { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the item that is currently selected.
|
||||
/// </summary>
|
||||
IInsightItem SelectedItem { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets whether the insight window should close automatically.
|
||||
/// The default value is true.
|
||||
/// </summary>
|
||||
bool CloseAutomatically { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the start of the text range in which the insight window stays open.
|
||||
/// Has no effect if CloseAutomatically is false.
|
||||
/// </summary>
|
||||
int StartOffset { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the end of the text range in which the insight window stays open.
|
||||
/// Has no effect if CloseAutomatically is false.
|
||||
/// </summary>
|
||||
int EndOffset { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Closes the insight window.
|
||||
/// </summary>
|
||||
void Close(); |
||||
} |
||||
} |
Loading…
Reference in new issue