}
/// <summary>
+ /// イベントパラメーターイベントパラメーター
+ /// </summary>
+ public sealed class CollectCompleteItemEventArgs : EventArgs
+ {
+ /// <summary>
+ /// 入力された行
+ /// </summary>
+ public int InputedRow;
+ /// <summary>
+ /// 補完対象のテキストボックス
+ /// </summary>
+ public Document textbox;
+ /// <summary>
+ /// コンストラクター
+ /// </summary>
+ /// <param name="word"></param>
+ /// <param name="inputing_word"></param>
+ /// <param name="textbox"></param>
+ public CollectCompleteItemEventArgs(Document textbox)
+ {
+ this.textbox = textbox;
+ this.InputedRow = textbox.CaretPostion.row - 1;
+ if (this.InputedRow < 0)
+ this.InputedRow = 0;
+ }
+ }
+
+ /// <summary>
/// イベントパンドラーの定義
/// </summary>
/// <param name="sender"></param>
}
}
};
+ this.CollectItems = (s, e) =>
+ {
+ AutoCompleteBoxBase box = (AutoCompleteBoxBase)s;
+ CompleteHelper.AddCompleteWords(box.Items, box.Operators, e.textbox.LayoutLines[e.InputedRow]);
+ };
this.Operators = new char[] { ' ', '\t', Document.NewLine };
this.Document = document;
}
internal void ParseInput(string input_text)
{
if (this.Operators == null ||
- input_text == "\r" ||
- input_text == "\n" ||
this.ShowingCompleteBox == null ||
(this.IsCloseCompleteBox == false && input_text == "\b"))
return;
+ if (input_text == "\r" || input_text == "\n")
+ {
+ this.CollectItems(this, new CollectCompleteItemEventArgs(this.Document));
+ return;
+ }
+
this.OpenCompleteBox(input_text);
}
-
+ public EventHandler<CollectCompleteItemEventArgs> CollectItems;
/// <summary>
/// 補完すべき単語が選択されたときに発生するイベント
/// </summary>
if (this.FireUpdateEvent && UserInput)
{
- if(this.AutoComplete != null)
- this.AutoComplete.ParseInput(string.Empty); //入力は終わっているので空文字を渡す
+ var input_str = string.Empty;
+ if (s == Document.NewLine.ToString())
+ input_str = s;
+ //入力は終わっているので空文字を渡すが処理の都合で一部文字だけはそのまま渡す
+ if (this.AutoComplete != null)
+ this.AutoComplete.ParseInput(input_str);
if (s == Document.NewLine.ToString())
this.AutoIndentHook(this, null);
}
var doc = new Document() { Title = "test1" };
doc.AutoComplete = new AutoCompleteBox(doc);
doc.AutoComplete.Items = complete_collection;
+ doc.AutoComplete.Enabled = true;
this._list.Add(doc);
doc = new Document() { Title = "test2" };