Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/22/10 23:33:13 (14 years ago)
Author:
swagner
Message:

Finished refactoring of saving and loading items (#990)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/UserDefinedAlgorithmView.cs

    r3455 r3500  
    8080      openFileDialog.Title = "Open Operator Graph";
    8181      if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
    82         this.Cursor = Cursors.AppStarting;
    8382        newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = false;
    8483        operatorGraphViewHost.Enabled = false;
    8584
    86         var call = new Func<string, object>(XmlParser.Deserialize);
    87         call.BeginInvoke(openFileDialog.FileName, delegate(IAsyncResult a) {
    88           OperatorGraph operatorGraph = null;
     85        ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) {
    8986          try {
    90             operatorGraph = call.EndInvoke(a) as OperatorGraph;
     87            if (error != null) throw error;
     88            OperatorGraph operatorGraph = content as OperatorGraph;
     89            if (operatorGraph == null)
     90              MessageBox.Show(this, "The selected file does not contain an operator graph.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);
     91            else
     92              Content.OperatorGraph = operatorGraph;
    9193          }
    9294          catch (Exception ex) {
    9395            Auxiliary.ShowErrorMessageBox(ex);
    9496          }
    95           Invoke(new Action(delegate() {
    96             if (operatorGraph == null)
    97               MessageBox.Show(this, "The selected file does not contain an operator graph.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);
    98             else
    99               Content.OperatorGraph = operatorGraph;
    100             operatorGraphViewHost.Enabled = true;
    101             newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = true;
    102             this.Cursor = Cursors.Default;
    103           }));
    104         }, null);
     97          finally {
     98            Invoke(new Action(delegate() {
     99              operatorGraphViewHost.Enabled = true;
     100              newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = true;
     101            }));
     102          }
     103        });
    105104      }
    106105    }
Note: See TracChangeset for help on using the changeset viewer.