+ get
+ {
+ return this._Document;
+ }
+ set
+ {
+ Document old_doc = this._Document;
+ int oldLength = 0;
+ if (this._Document != null)
+ {
+ old_doc.Update -= new DocumentUpdateEventHandler(Document_Update);
+ old_doc.LoadProgress -= _Document_LoadProgress;
+ oldLength = old_doc.Length;
+ }
+
+ this._Document = value;
+ this._Document.LayoutLines.Render = this.Render;
+ this._Document.Update += new DocumentUpdateEventHandler(Document_Update);
+ this._Document.LoadProgress += _Document_LoadProgress;
+ //初期化が終わっていればすべて存在する
+ if (this.Controller != null && this.View != null && this.textStore != null)
+ {
+ this.Controller.Document = value;
+ this.View.Document = value;
+ this.Controller.AdjustCaret();
+ this.textStore.NotifyTextChanged(oldLength, value.Length);
+
+ //依存プロパティとドキュメント内容が食い違っているので再設定する
+ this.ShowFullSpace = value.ShowFullSpace;
+ this.ShowHalfSpace = value.ShowHalfSpace;
+ this.ShowLineBreak = value.ShowLineBreak;
+ this.ShowTab = value.ShowTab;
+ this.FlowDirection = value.RightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
+ this.IndentMode = value.IndentMode;
+ this.DrawCaretLine = !value.HideLineMarker;
+ this.InsertMode = value.InsertMode;
+ this.DrawRuler = !value.HideRuler;
+ this.DrawLineNumber = value.DrawLineNumber;
+ this.MarkURL = value.UrlMark;
+ this.LineBreakMethod = value.LineBreak;
+ this.LineBreakCharCount = value.LineBreakCharCount;
+ this.TabChars = value.TabStops;
+
+ this.Refresh();
+ }
+ }
+ }
+
+ private void _Document_LoadProgress(object sender, ProgressEventArgs e)
+ {
+ if(e.state == ProgressState.Start)
+ this.IsEnabled = false;
+ else if(e.state == ProgressState.Complete)
+ {
+ TextStoreHelper.NotifyTextChanged(this.textStore, 0, 0, this.Document.Length);
+ if (this.verticalScrollBar != null)
+ this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
+ this.View.CalculateLineCountOnScreen();
+ this.IsEnabled = true;
+ }