Ejemplo n.º 1
0
        void RunTest(string name, string asmPath, string sourcePath)
        {
            using (var fileStream = new FileStream(asmPath, FileMode.Open, FileAccess.Read))
            {
                var module   = new PEFile(asmPath, fileStream);
                var resolver = new UniversalAssemblyResolver(asmPath, false, module.Reader.DetectTargetFrameworkId());
                resolver.RemoveSearchDirectory(".");
                resolver.AddSearchDirectory(Path.GetDirectoryName(asmPath));
                var    res        = module.Resources.First();
                Stream bamlStream = LoadBaml(res, name + ".baml");
                Assert.IsNotNull(bamlStream);

                BamlDecompilerTypeSystem typeSystem = new BamlDecompilerTypeSystem(module, resolver);
                var decompiler = new XamlDecompiler(typeSystem, new BamlDecompilerSettings());

                XDocument document = decompiler.Decompile(bamlStream).Xaml;

                XamlIsEqual(File.ReadAllText(sourcePath), document.ToString());
            }
        }
        private void ComputeXAML()
        {
            //MeshGeometry3D mesh = (MeshGeometry3D)GM3D_pyramid.Geometry;

            XamlDecompiler XD = new XamlDecompiler(10);

            string xamlstring = XD.GenerateXaml(
                this.ModelsOnTurntable);

            String xaml =
                @"<Page
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
Title='Pyramid'>

<Page.Resources>

		<DiffuseMaterial x:Key='BRUSHgrey'
						 Brush='#999999'/>

		<MeshGeometry3D x:Key='MG3D_Camel_FOOT' 
                 ... huge amount of data not shown here ... />
		<MeshGeometry3D x:Key='MG3D_Camel_SHIN' 
                 ... huge amount of data not shown here ... />
		<MeshGeometry3D x:Key='MG3D_Camel_THIGH' 
                 ... huge amount of data not shown here ... />
		<MeshGeometry3D x:Key='MG3D_Camel_HEAD' 
                 ... huge amount of data not shown here ... />
		<MeshGeometry3D x:Key='MG3D_Camel_TRUNK' 
                 ... huge amount of data not shown here ... />


</Page.Resources>
            

<Viewport3D x:Name='VP3D' Height='380' Width='600'>

  <Viewport3D.Camera>
   <PerspectiveCamera
         Position='" + CAMMY.Position + @"'
         LookDirection='" + CAMMY.LookDirection + @"'
         UpDirection='" + CAMMY.UpDirection + @"'
         NearPlaneDistance='0.02'
         FarPlaneDistance='1000'
         FieldOfView='" + CAMMY.FieldOfView + @"'
      />
  </Viewport3D.Camera>


  <ModelVisual3D>
    <ModelVisual3D.Content>

      <Model3DGroup>

          <DirectionalLight  Color='" + LITEdirectional.Color + @"'
                             Direction='1, 1, -1' />



          <!-- NOW COMES THE XAML FOR THE ACTUAL CAMEL MODEL ON THE TURNTABLE -->
"
                + xamlstring + @"


      </Model3DGroup>

    </ModelVisual3D.Content>
  </ModelVisual3D>
    
</Viewport3D>

</Page>
";



            if (TEXTBOXshowxaml != null)
            {
                TEXTBOXshowxaml.Text = xaml;
            }
        }