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; }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); if (itemList.PreselectionLength > 0 && itemList.SuggestedItem == null) { string preselection = TextArea.Document.GetText(StartOffset, EndOffset - StartOffset); CompletionList.SelectItem(preselection); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.List = ((ICSharpCode.AvalonEdit.CodeCompletion.CompletionList)(target)); return; } this._contentLoaded = true; }
protected override void OnTextInput(TextCompositionEventArgs e) { base.OnTextInput(e); if (e.Handled) { return; } foreach (var c in e.Text) { switch (itemList.ProcessInput(c)) { case CompletionItemListKeyResult.BeforeStartKey: ExpectInsertionBeforeStart = true; break; case CompletionItemListKeyResult.NormalKey: break; case CompletionItemListKeyResult.InsertionKey: CompletionList.RequestInsertion(e); return; } } }