set;
}
+ public event EventHandler AutoCompleteChanged;
+
+ AutoCompleteBoxBase _AutoComplete;
public AutoCompleteBoxBase AutoComplete
{
- get;
- set;
+ get
+ {
+ return this._AutoComplete;
+ }
+ set
+ {
+ this._AutoComplete = value;
+ if (this.AutoCompleteChanged != null)
+ this.AutoCompleteChanged(this, null);
+ }
}
public event ProgressEventHandler LoadProgress;
old_doc.Update -= new DocumentUpdateEventHandler(Document_Update);
this._Document.SelectionChanged -= Controller_SelectionChanged;
this._Document.LoadProgress -= Document_LoadProgress;
+ this._Document.AutoCompleteChanged -= _Document_AutoCompleteChanged;
if (this._Document.AutoComplete != null)
{
this._Document.AutoComplete.GetPostion = null;
this._Document.LayoutLines.Render = this.Render;
this._Document.Update += new DocumentUpdateEventHandler(Document_Update);
this._Document.LoadProgress += Document_LoadProgress;
- if(this._Document.AutoComplete != null)
- {
- this._Document.AutoComplete.GetPostion = (tp,doc) =>
- {
- var p = this.View.GetPostionFromTextPoint(tp);
- int height = (int)doc.LayoutLines.GetLayout(doc.CaretPostion.row).Height;
-
- if (p.Y + AutoCompleteBox.CompleteListBoxHeight + height > doc.LayoutLines.Render.TextArea.Height)
- p.Y -= AutoCompleteBox.CompleteListBoxHeight;
- else
- p.Y += height;
- //AutoCompleteBox内ではCanvasで位置を指定しているので変換する必要がある
- var pointInWindow = Util.GetPointInWindow(p, this);
- return pointInWindow;
- };
- }
+ this._Document.AutoCompleteChanged += _Document_AutoCompleteChanged;
+ if (this._Document.AutoComplete != null && this._Document.AutoComplete.GetPostion == null)
+ this._Document_AutoCompleteChanged(this._Document, null);
//初期化が終わっていればすべて存在する
if (this.Controller != null && this.View != null)
{
this._Document.SelectionChanged += Controller_SelectionChanged;
}
+ private void _Document_AutoCompleteChanged(object sender, EventArgs e)
+ {
+ Document doc = (Document)sender;
+ doc.AutoComplete.GetPostion = (tp, e_doc) =>
+ {
+ var p = this.View.GetPostionFromTextPoint(tp);
+ int height = (int)e_doc.LayoutLines.GetLayout(e_doc.CaretPostion.row).Height;
+
+ if (p.Y + AutoCompleteBox.CompleteListBoxHeight + height > e_doc.LayoutLines.Render.TextArea.Height)
+ p.Y -= AutoCompleteBox.CompleteListBoxHeight;
+ else
+ p.Y += height;
+ //AutoCompleteBox内ではCanvasで位置を指定しているので変換する必要がある
+ var pointInWindow = Util.GetPointInWindow(p, this);
+ return pointInWindow;
+ };
+ }
+
/// <inheritdoc/>
public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
{
{
old_doc.Update -= new DocumentUpdateEventHandler(Document_Update);
old_doc.LoadProgress -= Document_LoadProgress;
- old_doc.SelectionChanged += new EventHandler(Controller_SelectionChanged);
+ old_doc.SelectionChanged -= new EventHandler(Controller_SelectionChanged);
+ old_doc.AutoCompleteChanged -= _Document_AutoCompleteChanged;
oldLength = old_doc.Length;
if (this._Document.AutoComplete != null)
{
this._Document.LayoutLines.Render = this.Render;
this._Document.Update += new DocumentUpdateEventHandler(Document_Update);
this._Document.LoadProgress += Document_LoadProgress;
- if (this._Document.AutoComplete != null)
- {
- ((AutoCompleteBox)this._Document.AutoComplete).TargetPopup = this.popup;
- this._Document.AutoComplete.GetPostion = (tp, doc) =>
- {
- var p = this.View.GetPostionFromTextPoint(tp);
- int height = (int)doc.LayoutLines.GetLayout(doc.CaretPostion.row).Height;
- p.Y += height;
- return PointToScreen(this.TranslatePoint(p.Scale(Util.GetScale()), this));
- };
- }
+ this._Document.AutoCompleteChanged += _Document_AutoCompleteChanged;
+ if (this._Document.AutoComplete != null && this.Document.AutoComplete.GetPostion == null)
+ this._Document_AutoCompleteChanged(this.Document, null);
//初期化が終わっていればすべて存在する
if (this.Controller != null && this.View != null && this.textStore != null)
{
this.Refresh();
}
}
+
+ private void _Document_AutoCompleteChanged(object sender, EventArgs e)
+ {
+ Document doc = (Document)sender;
+ ((AutoCompleteBox)this._Document.AutoComplete).TargetPopup = this.popup;
+ this._Document.AutoComplete.GetPostion = (tp, edoc) =>
+ {
+ var p = this.View.GetPostionFromTextPoint(tp);
+ int height = (int)doc.LayoutLines.GetLayout(edoc.CaretPostion.row).Height;
+ p.Y += height;
+ return PointToScreen(this.TranslatePoint(p.Scale(Util.GetScale()), this));
+ };
+ }
+
/// <summary>
/// プロパティーが変更されたときに呼ばれます
/// </summary>