/// <returns>Taskオブジェクト</returns>
public async Task LoadFileAsync(System.IO.StreamReader sr, System.Threading.CancellationTokenSource token)
{
- this.IsEnabled = false;
- this.View.LayoutLines.IsFrozneDirtyFlag = true;
- WinFileReader fs = new WinFileReader(sr);
- await this.Document.LoadAsync(fs, token);
- this.View.LayoutLines.IsFrozneDirtyFlag = false;
- 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;
+ await this.Document.LoadAsync(sr, token);
}
/// <summary>
/// ドキュメントの内容をファイルに保存する
/// </summary>
/// <param name="sw">StreamWriter</param>
- /// <param name="enc">エンコード</param>
+ /// <param name="token">キャンセル用トークン</param>
/// <returns>Taskオブジェクト</returns>
public async Task SaveFile(System.IO.StreamWriter sw, System.Threading.CancellationTokenSource token)
{
- WinFileWriter fs = new WinFileWriter(sw);
- await this.Document.SaveAsync(fs, token);
+ await this.Document.SaveAsync(sw, token);
}
#region command
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)
{
}
}
+ 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;
+ }
+ }
+
/// <summary>
/// レイアウト行を表す
/// </summary>