summaryrefslogtreecommitdiff
path: root/Source/ModelViewer
diff options
context:
space:
mode:
authorGravatar wuestholz <unknown>2013-07-14 18:45:12 -0700
committerGravatar wuestholz <unknown>2013-07-14 18:45:12 -0700
commit1a55e51994e8c147ea27ead66cfc25c8cc8fb512 (patch)
treeb262642a6916554ac09b52f4d96ad7d53ee333af /Source/ModelViewer
parentad34aee0bb9e9090418fd1cb2e2fced7ddb625d8 (diff)
Split up the model viewer into a library and an application and added some functionality.
Diffstat (limited to 'Source/ModelViewer')
-rw-r--r--Source/ModelViewer/Main.cs51
-rw-r--r--Source/ModelViewer/ModelViewer.csproj14
-rw-r--r--Source/ModelViewer/Program.cs28
3 files changed, 41 insertions, 52 deletions
diff --git a/Source/ModelViewer/Main.cs b/Source/ModelViewer/Main.cs
index 2e612aa1..1caed654 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)
diff --git a/Source/ModelViewer/ModelViewer.csproj b/Source/ModelViewer/ModelViewer.csproj
index ae46767b..f708ddda 100644
--- a/Source/ModelViewer/ModelViewer.csproj
+++ b/Source/ModelViewer/ModelViewer.csproj
@@ -6,10 +6,10 @@
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A678C6EB-B329-46A9-BBFC-7585F01ACD7C}</ProjectGuid>
- <OutputType>WinExe</OutputType>
+ <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Boogie.ModelViewer</RootNamespace>
- <AssemblyName>BVD</AssemblyName>
+ <AssemblyName>ModelViewer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
@@ -98,18 +98,17 @@
<CodeContractsReferenceAssembly>Build</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
</PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="System.Numerics" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
+ <Reference Include="System.Numerics" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
- <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BaseProvider.cs" />
@@ -124,7 +123,6 @@
</Compile>
<Compile Include="..\Model\Model.cs" />
<Compile Include="Namer.cs" />
- <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SourceView.cs">
<SubType>Form</SubType>
diff --git a/Source/ModelViewer/Program.cs b/Source/ModelViewer/Program.cs
deleted file mode 100644
index 669ea995..00000000
--- a/Source/ModelViewer/Program.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Forms;
-
-namespace Microsoft.Boogie.ModelViewer
-{
- static class Program
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- try
- {
- Application.Run(new Main(System.Environment.GetCommandLineArgs()));
- }
- catch (Exception exc)
- {
- MessageBox.Show(exc.Message, "Model Viewer Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
- }
- }
- }
-}