/// <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;
-
- CoreTextRange modified_range = new CoreTextRange();
- modified_range.StartCaretPosition = 0;
- modified_range.EndCaretPosition = 0;
- //キャレット位置はロード前と同じにしないと違和感を感じる
- if(this.textEditContext != null)
- this.textEditContext.NotifyTextChanged(modified_range, this.Document.Length, modified_range);
+ await this.Document.LoadAsync(sr, token);
+ }
- if (this.verticalScrollBar != null)
- this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
- this.View.CalculateLineCountOnScreen();
- this.IsEnabled = true;
+ private void Document_LoadProgress(object sender, ProgressEventArgs e)
+ {
+ if(e.state == ProgressState.Start)
+ {
+ this.IsEnabled = false;
+ }
+ else if(e.state == ProgressState.Complete)
+ {
+ CoreTextRange modified_range = new CoreTextRange();
+ modified_range.StartCaretPosition = 0;
+ modified_range.EndCaretPosition = 0;
+ //キャレット位置はロード前と同じにしないと違和感を感じる
+ if (this.textEditContext != null)
+ this.textEditContext.NotifyTextChanged(modified_range, this.Document.Length, modified_range);
+
+ if (this.verticalScrollBar != null)
+ this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
+ this.View.CalculateLineCountOnScreen();
+ this.IsEnabled = true;
+ }
}
/// <summary>
/// <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
{
old_doc.Update -= new DocumentUpdateEventHandler(Document_Update);
this._Document.SelectionChanged -= Controller_SelectionChanged;
+ this._Document.LoadProgress -= Document_LoadProgress;
//NotifyTextChanged()を呼び出すと落ちるのでTextConextをごっそり作り替える
this.RemoveTextContext();
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)
{