private void Refresh() { RefreshStatus = "Updating image..."; var task = Task.Factory.StartNew(() => this._webSequenceDiagramsResult = WebSequenceDiagrams.DownloadDiagram(this._wsdScript, this.Style.ToString().ToLower().Replace('_', '-'), "png", this.ApiKey)); task.ContinueWith(t => { this.Errors.Clear(); if (task.Exception != null) { RefreshStatus = "Error(s) detected"; var ex = task.Exception.InnerException; if (ex is WebSequenceDiagramsException) { foreach (var error in (ex as WebSequenceDiagramsException).Errors) { this.Errors.Add(new ErrorViewModel(error.Line, error.Message)); } } else { this.Errors.Add(new ErrorViewModel(0, ex.Message)); } } else { RefreshStatus = "Ready"; } this.WsdImage = this._webSequenceDiagramsResult.GetBitmapImage(); this.OnPropertyChanged(() => this.WsdImage); this.ActualWsdImageWidth = this._webSequenceDiagramsResult.ActualImageWidth; }); }
private void DownloadImage() { this._webSequenceDiagramsResult = WebSequenceDiagrams.DownloadDiagram(this._wsdScript, this.Style.ToString().ToLower().Replace('_', '-'), "png", this.ApiKey); }