本文整理汇总了C#中ICSharpCode.AvalonEdit.CodeCompletion.CompletionWindow类的典型用法代码示例。如果您正苦于以下问题:C# CompletionWindow类的具体用法?C# CompletionWindow怎么用?C# CompletionWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompletionWindow类属于ICSharpCode.AvalonEdit.CodeCompletion命名空间,在下文中一共展示了CompletionWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Complete
public void Complete(TextArea textArea, ISegment completionSegment,
EventArgs insertionRequestEventArgs)
{
textArea.Document.Replace(completionSegment, this.Text);
if (autocompleteAgain_)
{
var completionWindow = new CompletionWindow(textArea);
completionWindow.Width = 256;
IList<ICompletionData> data = completionWindow.CompletionList.CompletionData;
var functions = App.MainViewModel.AutoCompleteCache.GetFunctions(Content as string);
(functions as List<ErlangEditor.AutoComplete.AcEntity>).Sort(new Tools.Reverser<ErlangEditor.AutoComplete.AcEntity>(new AutoComplete.AcEntity().GetType(), "FunctionName", Tools.ReverserInfo.Direction.ASC));
foreach (var i in functions)
{
data.Add(new CompletionData(false) { Text = "\'" + i.FunctionName + "\'(", Content = i.FunctionName + "/" + i.Arity, Description = i.Desc });
}
completionWindow.Show();
completionWindow.Closed += delegate
{
completionWindow = null;
};
}
}
示例2: InvokeCompletionWindow
public static void InvokeCompletionWindow(TextEditor textEditor)
{
completionWindow = new CompletionWindow(textEditor.TextArea);
completionWindow.Closed += delegate
{
completionWindow = null;
};
var text = textEditor.Text;
var offset = textEditor.TextArea.Caret.Offset;
var completedInput = CommandCompletion.CompleteInput(text, offset, null, PSConsolePowerShell.PowerShellInstance);
// var r = CommandCompletion.MapStringInputToParsedInput(text, offset);
"InvokeCompletedInput".ExecuteScriptEntryPoint(completedInput.CompletionMatches);
if (completedInput.CompletionMatches.Count > 0)
{
completedInput.CompletionMatches.ToList()
.ForEach(record =>
{
completionWindow.CompletionList.CompletionData.Add(
new CompletionData
{
CompletionText = record.CompletionText,
ToolTip = record.ToolTip,
Resultype = record.ResultType,
ReplacementLength = completedInput.ReplacementLength
});
});
completionWindow.Show();
}
}
示例3: ShowCompletionWindow
/// <summary>
/// Shows completion window for passed functions.
/// </summary>
/// <param name="identifierSegment">optional segment that should be included in the progressive search: eg. part of an identifier that's already typed before code completion was started</param>
/// <param name="functions"></param>
public void ShowCompletionWindow(ISegment identifierSegment, IList<Function> functions)
{
FunctionCompletionData first = null;
_completionWindow = new CompletionWindow(textEditor.TextArea);
foreach (var function in functions)
{
var tooltip = string.IsNullOrWhiteSpace(function.Definition) ? function.Description : string.Format("{0}\n\n{1}", function.Definition.Replace("|", Environment.NewLine), function.Description);
var item = new FunctionCompletionData(function.Name, tooltip);
if (first == null) first = item;
_completionWindow.CompletionList.CompletionData.Add(item);
}
_completionWindow.StartOffset = identifierSegment.Offset;
_completionWindow.EndOffset = identifierSegment.EndOffset;
if (first != null)
{
_completionWindow.CompletionList.SelectedItem = first;
}
_completionWindow.Show();
_completionWindow.Closed += (sender, args) => _completionWindow = null;
_completionWindow.PreviewTextInput += (sender, args) =>
{
if (args.Text == "(")
{
_completionWindow.CompletionList.RequestInsertion(EventArgs.Empty);
}
var c = args.Text[args.Text.Length - 1];
args.Handled = !char.IsLetterOrDigit(c) && c != '_';
};
}
示例4: textEditor_TextEntered
private void textEditor_TextEntered(object sender, TextCompositionEventArgs e)
{
if (e.Text == "<" || e.Text == " ")
{
CompletionData[] completions1;
if (completions.TryGetValue("!" + e.Text + "!" + GetActiveElement(1), out completions1))
{
completionWindow = new CompletionWindow(textEditor.TextArea);
var completions2 = completionWindow.CompletionList.CompletionData;
foreach (var completion in completions1)
completions2.Add(completion);
completionWindow.Show();
completionWindow.Closed += delegate
{
completionWindow = null;
};
}
}
if (e.Text == ">")
{
var tag = GetOpenTag(1);
if (tag != string.Empty)
textEditor.Document.Insert(textEditor.CaretOffset, tag.Insert(1, "/") + ">");
}
}
示例5: OnTextEntered
private void OnTextEntered(object sender, TextCompositionEventArgs e)
{
if (CaretOffset <= 0) return;
var isTrigger = _scriptManager.IsCompletionTriggerCharacter(CaretOffset - 1);
if (!isTrigger) return;
_completionWindow = new CompletionWindow(TextArea);
var data = _completionWindow.CompletionList.CompletionData;
var completion = _scriptManager.GetCompletion(CaretOffset, Text[CaretOffset - 1]).ToList();
if (!completion.Any())
{
_completionWindow = null;
return;
}
foreach (var completionData in completion)
{
data.Add(new CompletionData(completionData));
}
_completionWindow.Show();
_completionWindow.Closed += (o, args) => _completionWindow = null;
}
示例6: Resolve
public CompletionWindow Resolve()
{
var hiName = string.Empty;
if (_target.SyntaxHighlighting != null)
{
hiName = _target.SyntaxHighlighting.Name;
}
var cdata = _dataProviders.SelectMany(x => x.GetData(_text, _position, _input, hiName)).ToList();
int count = cdata.Count;
if (count > 0)
{
var completionWindow = new CompletionWindow(_target.TextArea);
var data = completionWindow.CompletionList.CompletionData;
foreach (var completionData in cdata)
{
data.Add(completionData);
}
completionWindow.Show();
completionWindow.Closed += delegate
{
completionWindow = null;
};
return completionWindow;
}
return null;
}
示例7: ScriptEditDialog
public ScriptEditDialog(string text) : base("Script edit", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize) {
InitializeComponent();
Extensions.SetMinimalSize(this);
AvalonLoader.Load(_textEditor);
AvalonLoader.SetSyntax(_textEditor, "Script");
string script = ItemParser.Format(text, 0);
_textEditor.Text = script;
_textEditor.TextArea.TextEntered += new TextCompositionEventHandler(_textArea_TextEntered);
_textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering);
_completionWindow = new CompletionWindow(_textEditor.TextArea);
_li = _completionWindow.CompletionList;
ListView lv = _li.ListBox;
lv.SelectionMode = SelectionMode.Single;
//Image
Extensions.GenerateListViewTemplate(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands"},
new ListViewDataTemplateHelper.GeneralColumnInfo {Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description"}
}, null, new string[] { }, "generateHeader", "false");
_completionWindow.Content = null;
_completionWindow = null;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
}
示例8: AttributeCompletionAvailable
private void AttributeCompletionAvailable(object sender, AttributeCompletionEventArgs e)
{
_completionWindow = new CompletionWindow(txtPlugin.TextArea);
IList<ICompletionData> data = _completionWindow.CompletionList.CompletionData;
foreach (CompletableXMLAttribute tag in e.Suggestions)
data.Add(new XMLAttributeCompletionData(tag, _completer));
_completionWindow.Show();
}
示例9: SetupCompletionWindow
protected void SetupCompletionWindow(TextArea area)
{
this._c = new CompletionWindow(area);
this._c.SizeToContent = System.Windows.SizeToContent.WidthAndHeight;
this._c.CompletionList.InsertionRequested += new EventHandler(CompletionList_InsertionRequested);
this._c.CloseAutomatically = true;
this._c.CloseWhenCaretAtBeginning = true;
this._c.Closed += new EventHandler(this.CompletionWindowClosed);
this._c.KeyDown += new KeyEventHandler(CompletionWindowKeyDown);
this._startOffset = this._c.StartOffset;
}
示例10: ShowCompletion
public void ShowCompletion(TextArea area)
{
var window = new CompletionWindow(area);
IList<ICompletionData> data = window.CompletionList.CompletionData;
foreach (CompletionData item in GenerateCompletionData("test.boo", area))
{
data.Add(item);
}
window.Show();
}
示例11: TextEditorTextAreaTextEntered
public void TextEditorTextAreaTextEntered(object sender, TextCompositionEventArgs e)
{
if (e.Text == ".")
{
// Open code completion after the user has pressed dot:
_completionWindow = new CompletionWindow(sender as TextArea);
IList<ICompletionData> data = _completionWindow.CompletionList.CompletionData;
data.Add(new MyCompletionData("Query"));
data.Add(new MyCompletionData("All()"));
data.Add(new MyCompletionData("ToString()"));
_completionWindow.Show();
_completionWindow.Closed += delegate { _completionWindow = null; };
}
}
示例12: textEditor_TextArea_TextEntered
private void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
{
if (e.Text != ".") return;
// open code completion after the user has pressed dot:
completionWindow = new CompletionWindow(TextEditor.TextArea);
// provide AvalonEdit with the data:
var data = completionWindow.CompletionList.CompletionData;
data.Add(new MyCompletionData("Item1"));
data.Add(new MyCompletionData("Item2"));
data.Add(new MyCompletionData("Item3"));
data.Add(new MyCompletionData("Another item"));
completionWindow.Show();
completionWindow.Closed += delegate { completionWindow = null; };
}
示例13: CreateNewCompletionWindow
CompletionWindow CreateNewCompletionWindow() {
if(_completionWindow != null)
_completionWindow.Close();
_completionWindow = new CompletionWindow(_texteditor.TextArea);
//_completionWindow.CompletionList.IsFiltering = false;
_completionWindow.StartOffset -= 1;
_completionWindow.Closed += delegate
{
_completionWindow = null;
};
return _completionWindow;
}
示例14: OpenCompletionWindow
private void OpenCompletionWindow(IEnumerable<CompletionData> completions)
{
if (this._completionWindow != null) return;
var wnd = new CompletionWindow(this.TextArea);
wnd.Closed += (o, e) =>
{
if (this._completionWindow == wnd)
this._completionWindow = null;
};
var elems = wnd.CompletionList.CompletionData;
completions.ForEach(wnd.CompletionList.CompletionData.Add);
// insert elements
this._completionWindow = wnd;
wnd.Show();
}
示例15: edSQL_TextArea_Sense
private void edSQL_TextArea_Sense(object sender, TextCompositionEventArgs e)
{
completionWindow = new CompletionWindow(edSQL.TextArea);
IList<ICompletionData> data = completionWindow.CompletionList.CompletionData;
// fill data (completion options) based on e (position, context etc)
completionHelper.Initialize(e, data);
completionWindow.Show();
completionWindow.CompletionList.IsFiltering = false;
completionWindow.CompletionList.SelectItem(completionHelper.Currentword);
completionWindow.Closed += delegate
{
completionWindow = null;
};
}