diff options
author | 2013-07-19 11:13:36 +0100 | |
---|---|---|
committer | 2013-07-19 11:13:36 +0100 | |
commit | 5f26d6075b8493f3e240c5d356b5fc588c5d7985 (patch) | |
tree | 834d1be7b2127bb49b4da949e523ca291a1e6144 /Source/ModelViewer/Main.cs | |
parent | 3c5116cd8a4b58bc220f0d1ff068564556c7ab07 (diff) | |
parent | 51f2fa80a101ffae855c848ed83b889f1becbdd3 (diff) |
merge
Diffstat (limited to 'Source/ModelViewer/Main.cs')
-rw-r--r-- | Source/ModelViewer/Main.cs | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/Source/ModelViewer/Main.cs b/Source/ModelViewer/Main.cs index 09dce05f..bd01cc16 100644 --- a/Source/ModelViewer/Main.cs +++ b/Source/ModelViewer/Main.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using System.IO;
using Microsoft.Boogie;
+using System.Diagnostics.Contracts;
namespace Microsoft.Boogie.ModelViewer
{
@@ -92,6 +93,18 @@ namespace Microsoft.Boogie.ModelViewer }
}
+ public void ReadModel(string model, int setModelIdTo = 0)
+ {
+ Contract.Requires(model != null);
+
+ using (var rd = new StringReader(model))
+ {
+ allModels = Model.ParseModels(rd).ToArray();
+ }
+
+ AddAndLoadModel(setModelIdTo);
+ }
+
public void ReadModels(string modelFileName, int setModelIdTo)
{
this.lastModelFileName = modelFileName;
@@ -102,28 +115,34 @@ namespace Microsoft.Boogie.ModelViewer allModels = Model.ParseModels(rd,"").ToArray();
}
- modelId = setModelIdTo;
-
- if (modelId >= allModels.Length)
- modelId = 0;
-
- currentModel = allModels[modelId];
- AddModelMenu();
-
- foreach (var p in Providers()) {
- if (p.IsMyModel(currentModel)) {
- this.langProvider = p;
- break;
- }
- }
-
- LoadModel(modelId);
+ AddAndLoadModel(setModelIdTo);
} else {
currentModel = new Model();
}
this.SetWindowTitle(modelFileName);
+ }
+
+ private void AddAndLoadModel(int setModelIdTo)
+ {
+ modelId = setModelIdTo;
+
+ if (modelId >= allModels.Length)
+ modelId = 0;
+
+ currentModel = allModels[modelId];
+ AddModelMenu();
+
+ foreach (var p in Providers())
+ {
+ if (p.IsMyModel(currentModel))
+ {
+ this.langProvider = p;
+ break;
+ }
+ }
+ LoadModel(modelId);
}
private void LoadModel(int idx)
|