Initial WPF content migrated (#17)
* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
@@ -0,0 +1,68 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<!-- MSBUILD Project File -->
|
||||
<PropertyGroup>
|
||||
<DefaultClrNameSpace>SDKSamples</DefaultClrNameSpace>
|
||||
<AssemblyName>ImagingSnippetGallery_csharp</AssemblyName>
|
||||
<TargetType>winexe</TargetType>
|
||||
<Configuration>Release</Configuration>
|
||||
<BuildSystem>MSBuild</BuildSystem>
|
||||
<HostInBrowser>False</HostInBrowser>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{99E90579-62FC-4898-B168-24F7DBD3A34D}</ProjectGuid>
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<!--Import the target file that contains all the common targets -->
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="MyApp.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="SampleViewer.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MyApp.xaml.cs">
|
||||
<DependentUpon>MyApp.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SampleViewer.xaml.cs">
|
||||
<DependentUpon>SampleViewer.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Basic3DShapeExample.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Misc3DOperationsExample.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Viewport3DVisualExample.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="EmissiveMaterialExample.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MultipleTransformationsExample.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,133 @@
|
||||
// <SnippetBasic3DShapeCodeExampleWholePage>
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Media3D;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
public partial class Basic3DShapeExample : Page
|
||||
{
|
||||
public Basic3DShapeExample()
|
||||
{
|
||||
|
||||
// Declare scene objects.
|
||||
Viewport3D myViewport3D = new Viewport3D();
|
||||
Model3DGroup myModel3DGroup = new Model3DGroup();
|
||||
GeometryModel3D myGeometryModel = new GeometryModel3D();
|
||||
ModelVisual3D myModelVisual3D = new ModelVisual3D();
|
||||
// <SnippetBasic3DShapeCodeExampleInline1>
|
||||
// Defines the camera used to view the 3D object. In order to view the 3D object,
|
||||
// the camera must be positioned and pointed such that the object is within view
|
||||
// of the camera.
|
||||
PerspectiveCamera myPCamera = new PerspectiveCamera();
|
||||
|
||||
// Specify where in the 3D scene the camera is.
|
||||
myPCamera.Position = new Point3D(0, 0, 2);
|
||||
|
||||
// Specify the direction that the camera is pointing.
|
||||
myPCamera.LookDirection = new Vector3D(0, 0, -1);
|
||||
|
||||
// Define camera's horizontal field of view in degrees.
|
||||
myPCamera.FieldOfView = 60;
|
||||
|
||||
// Asign the camera to the viewport
|
||||
myViewport3D.Camera = myPCamera;
|
||||
// </SnippetBasic3DShapeCodeExampleInline1>
|
||||
// Define the lights cast in the scene. Without light, the 3D object cannot
|
||||
// be seen. Note: to illuminate an object from additional directions, create
|
||||
// additional lights.
|
||||
DirectionalLight myDirectionalLight = new DirectionalLight();
|
||||
myDirectionalLight.Color = Colors.White;
|
||||
myDirectionalLight.Direction = new Vector3D(-0.61, -0.5, -0.61);
|
||||
|
||||
myModel3DGroup.Children.Add(myDirectionalLight);
|
||||
|
||||
// The geometry specifes the shape of the 3D plane. In this sample, a flat sheet
|
||||
// is created.
|
||||
MeshGeometry3D myMeshGeometry3D = new MeshGeometry3D();
|
||||
|
||||
// Create a collection of normal vectors for the MeshGeometry3D.
|
||||
Vector3DCollection myNormalCollection = new Vector3DCollection();
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myMeshGeometry3D.Normals = myNormalCollection;
|
||||
|
||||
// Create a collection of vertex positions for the MeshGeometry3D.
|
||||
Point3DCollection myPositionCollection = new Point3DCollection();
|
||||
myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, -0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(-0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
myMeshGeometry3D.Positions = myPositionCollection;
|
||||
|
||||
// Create a collection of texture coordinates for the MeshGeometry3D.
|
||||
PointCollection myTextureCoordinatesCollection = new PointCollection();
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 0));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 0));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 0));
|
||||
myMeshGeometry3D.TextureCoordinates = myTextureCoordinatesCollection;
|
||||
|
||||
// Create a collection of triangle indices for the MeshGeometry3D.
|
||||
Int32Collection myTriangleIndicesCollection = new Int32Collection();
|
||||
myTriangleIndicesCollection.Add(0);
|
||||
myTriangleIndicesCollection.Add(1);
|
||||
myTriangleIndicesCollection.Add(2);
|
||||
myTriangleIndicesCollection.Add(3);
|
||||
myTriangleIndicesCollection.Add(4);
|
||||
myTriangleIndicesCollection.Add(5);
|
||||
myMeshGeometry3D.TriangleIndices = myTriangleIndicesCollection;
|
||||
|
||||
// Apply the mesh to the geometry model.
|
||||
myGeometryModel.Geometry = myMeshGeometry3D;
|
||||
|
||||
// The material specifies the material applied to the 3D object. In this sample a
|
||||
// linear gradient covers the surface of the 3D object.
|
||||
|
||||
// Create a horizontal linear gradient with four stops.
|
||||
LinearGradientBrush myHorizontalGradient = new LinearGradientBrush();
|
||||
myHorizontalGradient.StartPoint = new Point(0, 0.5);
|
||||
myHorizontalGradient.EndPoint = new Point(1, 0.5);
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Red, 0.25));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Blue, 0.75));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.LimeGreen, 1.0));
|
||||
|
||||
// Define material and apply to the mesh geometries.
|
||||
DiffuseMaterial myMaterial = new DiffuseMaterial(myHorizontalGradient);
|
||||
myGeometryModel.Material = myMaterial;
|
||||
|
||||
// Apply a transform to the object. In this sample, a rotation transform is applied,
|
||||
// rendering the 3D object rotated.
|
||||
RotateTransform3D myRotateTransform3D = new RotateTransform3D();
|
||||
AxisAngleRotation3D myAxisAngleRotation3d = new AxisAngleRotation3D();
|
||||
myAxisAngleRotation3d.Axis = new Vector3D(0,3,0);
|
||||
myAxisAngleRotation3d.Angle = 40;
|
||||
myRotateTransform3D.Rotation = myAxisAngleRotation3d;
|
||||
myGeometryModel.Transform = myRotateTransform3D;
|
||||
|
||||
// Add the geometry model to the model group.
|
||||
myModel3DGroup.Children.Add(myGeometryModel);
|
||||
|
||||
// Add the group of models to the ModelVisual3d.
|
||||
myModelVisual3D.Content = myModel3DGroup;
|
||||
|
||||
//
|
||||
myViewport3D.Children.Add(myModelVisual3D);
|
||||
|
||||
// Apply the viewport to the page so it will be rendered.
|
||||
this.Content = myViewport3D;
|
||||
}
|
||||
}
|
||||
}
|
||||
// </SnippetBasic3DShapeCodeExampleWholePage>
|
||||
@@ -0,0 +1,151 @@
|
||||
// <SnippetEmissiveMaterialCodeExampleWholePage>
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Media3D;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
public partial class EmissiveMaterialExample : Page
|
||||
{
|
||||
public EmissiveMaterialExample()
|
||||
{
|
||||
|
||||
// Declare scene objects.
|
||||
Viewport3D myViewport3D = new Viewport3D();
|
||||
Model3DGroup myModel3DGroup = new Model3DGroup();
|
||||
GeometryModel3D myGeometryModel = new GeometryModel3D();
|
||||
ModelVisual3D myModelVisual3D = new ModelVisual3D();
|
||||
|
||||
// Defines the camera used to view the 3D object. In order to view the 3D object,
|
||||
// the camera must be positioned and pointed such that the object is within view
|
||||
// of the camera.
|
||||
PerspectiveCamera myPCamera = new PerspectiveCamera();
|
||||
|
||||
// Specify where in the 3D scene the camera is.
|
||||
myPCamera.Position = new Point3D(0, 0, 2);
|
||||
|
||||
// Specify the direction that the camera is pointing.
|
||||
myPCamera.LookDirection = new Vector3D(0, 0, -1);
|
||||
|
||||
// Define camera's horizontal field of view in degrees.
|
||||
myPCamera.FieldOfView = 60;
|
||||
|
||||
// Asign the camera to the viewport
|
||||
myViewport3D.Camera = myPCamera;
|
||||
|
||||
// Define the lights cast in the scene. Without light, the 3D object cannot
|
||||
// be seen. Note: to illuminate an object from additional directions, create
|
||||
// additional lights.
|
||||
DirectionalLight myDirectionalLight = new DirectionalLight();
|
||||
myDirectionalLight.Color = Colors.White;
|
||||
myDirectionalLight.Direction = new Vector3D(-0.61, -0.5, -0.61);
|
||||
|
||||
myModel3DGroup.Children.Add(myDirectionalLight);
|
||||
|
||||
// The geometry specifes the shape of the 3D plane. In this sample, a flat sheet
|
||||
// is created.
|
||||
MeshGeometry3D myMeshGeometry3D = new MeshGeometry3D();
|
||||
|
||||
// Create a collection of normal vectors for the MeshGeometry3D.
|
||||
Vector3DCollection myNormalCollection = new Vector3DCollection();
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myMeshGeometry3D.Normals = myNormalCollection;
|
||||
|
||||
// Create a collection of vertex positions for the MeshGeometry3D.
|
||||
Point3DCollection myPositionCollection = new Point3DCollection();
|
||||
myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, -0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(-0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
myMeshGeometry3D.Positions = myPositionCollection;
|
||||
|
||||
// Create a collection of texture coordinates for the MeshGeometry3D.
|
||||
PointCollection myTextureCoordinatesCollection = new PointCollection();
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 0));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 0));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 0));
|
||||
myMeshGeometry3D.TextureCoordinates = myTextureCoordinatesCollection;
|
||||
|
||||
// Create a collection of triangle indices for the MeshGeometry3D.
|
||||
Int32Collection myTriangleIndicesCollection = new Int32Collection();
|
||||
myTriangleIndicesCollection.Add(0);
|
||||
myTriangleIndicesCollection.Add(1);
|
||||
myTriangleIndicesCollection.Add(2);
|
||||
myTriangleIndicesCollection.Add(3);
|
||||
myTriangleIndicesCollection.Add(4);
|
||||
myTriangleIndicesCollection.Add(5);
|
||||
myMeshGeometry3D.TriangleIndices = myTriangleIndicesCollection;
|
||||
|
||||
// Apply the mesh to the geometry model.
|
||||
myGeometryModel.Geometry = myMeshGeometry3D;
|
||||
// <SnippetEmissiveMaterialCodeExampleInline1>
|
||||
// The material property of GeometryModel3D specifies the material applied to the 3D object.
|
||||
// In this sample the material applied to the 3D object is made up of two materials layered
|
||||
// on top of each other - a DiffuseMaterial (gradient brush) with an EmissiveMaterial
|
||||
// layered on top (blue SolidColorBrush). The EmmisiveMaterial alters the appearance of
|
||||
// the gradient toward blue.
|
||||
|
||||
// Create a horizontal linear gradient with four stops.
|
||||
LinearGradientBrush myHorizontalGradient = new LinearGradientBrush();
|
||||
myHorizontalGradient.StartPoint = new Point(0, 0.5);
|
||||
myHorizontalGradient.EndPoint = new Point(1, 0.5);
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Red, 0.25));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Blue, 0.75));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.LimeGreen, 1.0));
|
||||
|
||||
// Define material that will use the gradient.
|
||||
DiffuseMaterial myDiffuseMaterial = new DiffuseMaterial(myHorizontalGradient);
|
||||
|
||||
// Add this gradient to a MaterialGroup.
|
||||
MaterialGroup myMaterialGroup = new MaterialGroup();
|
||||
myMaterialGroup.Children.Add(myDiffuseMaterial);
|
||||
|
||||
// Define an Emissive Material with a blue brush.
|
||||
Color c = new Color();
|
||||
c.ScA = 1;
|
||||
c.ScB = 255;
|
||||
c.ScR = 0;
|
||||
c.ScG = 0;
|
||||
EmissiveMaterial myEmissiveMaterial = new EmissiveMaterial(new SolidColorBrush(c));
|
||||
|
||||
// Add the Emmisive Material to the Material Group.
|
||||
myMaterialGroup.Children.Add(myEmissiveMaterial);
|
||||
|
||||
// Add the composite material to the 3D model.
|
||||
myGeometryModel.Material = myMaterialGroup;
|
||||
// </SnippetEmissiveMaterialCodeExampleInline1>
|
||||
// Apply a transform to the object. In this sample, a rotation transform is applied,
|
||||
// rendering the 3D object rotated.
|
||||
RotateTransform3D myRotateTransform3D = new RotateTransform3D();
|
||||
AxisAngleRotation3D myAxisAngleRotation3d = new AxisAngleRotation3D();
|
||||
myAxisAngleRotation3d.Axis = new Vector3D(0,3,0);
|
||||
myAxisAngleRotation3d.Angle = 40;
|
||||
myRotateTransform3D.Rotation = myAxisAngleRotation3d;
|
||||
myGeometryModel.Transform = myRotateTransform3D;
|
||||
|
||||
// Add the geometry model to the model group.
|
||||
myModel3DGroup.Children.Add(myGeometryModel);
|
||||
|
||||
// Add the group of models to the ModelVisual3d.
|
||||
myModelVisual3D.Content = myModel3DGroup;
|
||||
myViewport3D.Children.Add(myModelVisual3D);
|
||||
|
||||
// Apply the viewport to the page so it will be rendered.
|
||||
this.Content = myViewport3D;
|
||||
}
|
||||
}
|
||||
}
|
||||
// </SnippetEmissiveMaterialCodeExampleWholePage>
|
||||
@@ -0,0 +1,176 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Media3D;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
|
||||
public class Misc3DOperationsExample : Page
|
||||
{
|
||||
|
||||
public Misc3DOperationsExample()
|
||||
{
|
||||
|
||||
StackPanel mainPanel = new StackPanel();
|
||||
|
||||
TextBlock subtract3DPointsExampleText = new TextBlock();
|
||||
subtract3DPointsExampleText.Text = "subtract3DPointsExample: " + subtract3DPointsExample();
|
||||
mainPanel.Children.Add(subtract3DPointsExampleText);
|
||||
|
||||
TextBlock subtract3DVectorsExampleText = new TextBlock();
|
||||
subtract3DVectorsExampleText.Text = "subtract3DVectorsExample: " + subtract3DVectorsExample();
|
||||
mainPanel.Children.Add(subtract3DVectorsExampleText);
|
||||
|
||||
TextBlock point4DEqualityExampleText = new TextBlock();
|
||||
point4DEqualityExampleText.Text = "point4DEqualityExample: " + point4DEqualityExample();
|
||||
mainPanel.Children.Add(point4DEqualityExampleText);
|
||||
|
||||
TextBlock size3DEqualityExampleText = new TextBlock();
|
||||
size3DEqualityExampleText.Text = "size3DEqualityExample: " + size3DEqualityExample().ToString();
|
||||
mainPanel.Children.Add(size3DEqualityExampleText);
|
||||
|
||||
this.Content = mainPanel;
|
||||
}
|
||||
|
||||
private string subtract3DPointsExample()
|
||||
{
|
||||
// <SnippetSubtract3DPointsExample_csharp>
|
||||
// instantiate variables
|
||||
Point3D point1 = new Point3D();
|
||||
Point3D point2 = new Point3D(15, 40, 60);
|
||||
Vector3D vector1 = new Vector3D(20, 30, 40);
|
||||
Point3D pointResult1 = new Point3D();
|
||||
Point3D pointResult2 = new Point3D();
|
||||
Vector3D vectorResult1 = new Vector3D();
|
||||
Vector3D vectorResult2 = new Vector3D();
|
||||
|
||||
// defining x,y,z of point1
|
||||
point1.X = 10;
|
||||
point1.Y = 5;
|
||||
point1.Z = 1;
|
||||
|
||||
vectorResult1 = Point3D.Subtract(point1, point2);
|
||||
// vectorResult1 is equal to (-5, -35, -59)
|
||||
|
||||
vectorResult2 = point2 - point1;
|
||||
// vectorResult2 is equal to (5, 35, 59)
|
||||
|
||||
pointResult1 = Point3D.Subtract(point1, vector1);
|
||||
// pointResult1 is equal to (-10, -25, -39)
|
||||
|
||||
pointResult2 = vector1 - point1;
|
||||
// pointResult2 is equal to (10, 25, 39)
|
||||
// </SnippetSubtract3DPointsExample_csharp>
|
||||
|
||||
string stringResults = "pointResult1: " + pointResult1.ToString();
|
||||
stringResults = stringResults + " pointResult2: " + pointResult2.ToString();
|
||||
stringResults = stringResults + " vectorResult1: " + vectorResult1.ToString();
|
||||
stringResults = stringResults + " vectorResult2: " + vectorResult2.ToString();
|
||||
return stringResults;
|
||||
}
|
||||
|
||||
private string subtract3DVectorsExample()
|
||||
{
|
||||
// <SnippetSubtract3DVectorsExample_csharp>
|
||||
// Subtracts two 3-D Vectors using the Subtract method and -
|
||||
|
||||
// Declaring vector1 and initializing x,y,z values
|
||||
Vector3D vector1 = new Vector3D(20, 30, 40);
|
||||
|
||||
// Declaring vector2 without initializing x,y,z values
|
||||
Vector3D vector2 = new Vector3D();
|
||||
|
||||
// Assigning values to vector2
|
||||
vector2.X = 45;
|
||||
vector2.Y = 70;
|
||||
vector2.Z = 80;
|
||||
|
||||
// Subtracting vectors using overload - operator
|
||||
Vector3D vectorResult1 = new Vector3D();
|
||||
vectorResult1 = vector1 - vector2;
|
||||
// vectorResult1 is equal to (-25, -40, -40)
|
||||
|
||||
// Subtracting vectors using static Subtract method
|
||||
Vector3D vectorResult2 = new Vector3D();
|
||||
vectorResult2 = Vector3D.Subtract(vector1, vector2);
|
||||
// vector2 is equal to (-25, -40, -40)
|
||||
// </SnippetSubtract3DVectorsExample_csharp>
|
||||
|
||||
string stringResults = "vectorResult1: " + vectorResult1.ToString();
|
||||
stringResults = stringResults + " vectorResult2: " + vectorResult2.ToString();
|
||||
return stringResults;
|
||||
}
|
||||
|
||||
private string point4DEqualityExample()
|
||||
{
|
||||
// <SnippetPoint4DEqualityExample_csharp>
|
||||
// instantiate Points
|
||||
Point4D point4D1 = new Point4D();
|
||||
Point4D point4D2 = new Point4D(15, 40, 60, 75);
|
||||
Point3D point3D1 = new Point3D(15, 40, 60);
|
||||
|
||||
// result variables
|
||||
Boolean areEqual;
|
||||
Boolean areNotEqual;
|
||||
String stringResult;
|
||||
|
||||
// defining x,y,z,w of point1
|
||||
point4D1.X = 10;
|
||||
point4D1.Y = 5;
|
||||
point4D1.Z = 1;
|
||||
point4D1.W = 4;
|
||||
|
||||
// checking if Points are equal
|
||||
areEqual = point4D1 == point4D2;
|
||||
|
||||
// areEqual is False
|
||||
|
||||
// checking if Points are not equal
|
||||
areNotEqual = point4D1 != point4D2;
|
||||
// areNotEqual is True
|
||||
|
||||
if (Point4D.Equals(point4D1, point3D1))
|
||||
{
|
||||
// the if condition is not true, so this block will not execute
|
||||
stringResult = "Both objects are Point4D structures and they are equal";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// the if condition is false, so this branch will execute
|
||||
stringResult = "Parameters are not both Point4D strucutres, or they are but are not equal";
|
||||
}
|
||||
// </SnippetPoint4DEqualityExample_csharp>
|
||||
|
||||
return stringResult;
|
||||
}
|
||||
// <SnippetSize3DEqualityExample_csharp>
|
||||
private bool size3DEqualityExample()
|
||||
{
|
||||
|
||||
// Checks if two Size3D structures are equal using the static Equals method.
|
||||
// Returns a Boolean.
|
||||
|
||||
// Declaring Size3D structure without initializing x,y,z values
|
||||
Size3D size1 = new Size3D();
|
||||
|
||||
// Delcaring Size3D structure and initializing x,y,z values
|
||||
Size3D size2 = new Size3D(5, 10, 15);
|
||||
Boolean areEqual;
|
||||
|
||||
// Assigning values to size1
|
||||
size1.X = 2;
|
||||
size1.Y = 4;
|
||||
size1.Z = 6;
|
||||
|
||||
// checking for equality
|
||||
areEqual = Size3D.Equals(size1, size2);
|
||||
|
||||
// areEqual is False
|
||||
return areEqual;
|
||||
}
|
||||
// </SnippetSize3DEqualityExample_csharp>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
// <SnippetMultiple3DTransformationsCodeExampleWholePage>
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Media3D;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
public partial class MultipleTransformationsExample : Page
|
||||
{
|
||||
public MultipleTransformationsExample()
|
||||
{
|
||||
|
||||
// Declare scene objects.
|
||||
Viewport3D myViewport3D = new Viewport3D();
|
||||
Model3DGroup myModel3DGroup = new Model3DGroup();
|
||||
GeometryModel3D myGeometryModel = new GeometryModel3D();
|
||||
ModelVisual3D myModelVisual3D = new ModelVisual3D();
|
||||
|
||||
// Defines the camera used to view the 3D object. In order to view the 3D object,
|
||||
// the camera must be positioned and pointed such that the object is within view
|
||||
// of the camera.
|
||||
PerspectiveCamera myPCamera = new PerspectiveCamera();
|
||||
|
||||
// Specify where in the 3D scene the camera is.
|
||||
myPCamera.Position = new Point3D(0, 0, 2);
|
||||
|
||||
// Specify the direction that the camera is pointing.
|
||||
myPCamera.LookDirection = new Vector3D(0, 0, -1);
|
||||
|
||||
// Define camera's horizontal field of view in degrees.
|
||||
myPCamera.FieldOfView = 60;
|
||||
|
||||
// Asign the camera to the viewport
|
||||
myViewport3D.Camera = myPCamera;
|
||||
|
||||
// Define the lights cast in the scene. Without light, the 3D object cannot
|
||||
// be seen. Note: to illuminate an object from additional directions, create
|
||||
// additional lights.
|
||||
DirectionalLight myDirectionalLight = new DirectionalLight();
|
||||
myDirectionalLight.Color = Colors.White;
|
||||
myDirectionalLight.Direction = new Vector3D(-0.61, -0.5, -0.61);
|
||||
|
||||
myModel3DGroup.Children.Add(myDirectionalLight);
|
||||
|
||||
// The geometry specifes the shape of the 3D plane. In this sample, a flat sheet
|
||||
// is created.
|
||||
MeshGeometry3D myMeshGeometry3D = new MeshGeometry3D();
|
||||
|
||||
// Create a collection of normal vectors for the MeshGeometry3D.
|
||||
Vector3DCollection myNormalCollection = new Vector3DCollection();
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myNormalCollection.Add(new Vector3D(0,0,1));
|
||||
myMeshGeometry3D.Normals = myNormalCollection;
|
||||
|
||||
// Create a collection of vertex positions for the MeshGeometry3D.
|
||||
Point3DCollection myPositionCollection = new Point3DCollection();
|
||||
myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, -0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(-0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
myMeshGeometry3D.Positions = myPositionCollection;
|
||||
|
||||
// Create a collection of texture coordinates for the MeshGeometry3D.
|
||||
PointCollection myTextureCoordinatesCollection = new PointCollection();
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 0));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 0));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 0));
|
||||
myMeshGeometry3D.TextureCoordinates = myTextureCoordinatesCollection;
|
||||
|
||||
// Create a collection of triangle indices for the MeshGeometry3D.
|
||||
Int32Collection myTriangleIndicesCollection = new Int32Collection();
|
||||
myTriangleIndicesCollection.Add(0);
|
||||
myTriangleIndicesCollection.Add(1);
|
||||
myTriangleIndicesCollection.Add(2);
|
||||
myTriangleIndicesCollection.Add(3);
|
||||
myTriangleIndicesCollection.Add(4);
|
||||
myTriangleIndicesCollection.Add(5);
|
||||
myMeshGeometry3D.TriangleIndices = myTriangleIndicesCollection;
|
||||
|
||||
// Apply the mesh to the geometry model.
|
||||
myGeometryModel.Geometry = myMeshGeometry3D;
|
||||
|
||||
// The material specifies the material applied to the 3D object. In this sample a
|
||||
// linear gradient covers the surface of the 3D object.
|
||||
|
||||
// Create a horizontal linear gradient with four stops.
|
||||
LinearGradientBrush myHorizontalGradient = new LinearGradientBrush();
|
||||
myHorizontalGradient.StartPoint = new Point(0, 0.5);
|
||||
myHorizontalGradient.EndPoint = new Point(1, 0.5);
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Red, 0.25));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Blue, 0.75));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.LimeGreen, 1.0));
|
||||
|
||||
// Define material and apply to the mesh geometries.
|
||||
DiffuseMaterial myMaterial = new DiffuseMaterial(myHorizontalGradient);
|
||||
myGeometryModel.Material = myMaterial;
|
||||
// <SnippetMultiple3DTransformationsCodeExampleInline1>
|
||||
// Apply multiple transformations to the object. In this sample, a rotation and scale
|
||||
// transform is applied.
|
||||
|
||||
// Create and apply a transformation that rotates the object.
|
||||
RotateTransform3D myRotateTransform3D = new RotateTransform3D();
|
||||
AxisAngleRotation3D myAxisAngleRotation3d = new AxisAngleRotation3D();
|
||||
myAxisAngleRotation3d.Axis = new Vector3D(0,3,0);
|
||||
myAxisAngleRotation3d.Angle = 40;
|
||||
myRotateTransform3D.Rotation = myAxisAngleRotation3d;
|
||||
|
||||
// Add the rotation transform to a Transform3DGroup
|
||||
Transform3DGroup myTransform3DGroup = new Transform3DGroup();
|
||||
myTransform3DGroup.Children.Add(myRotateTransform3D);
|
||||
|
||||
// Create and apply a scale transformation that stretches the object along the local x-axis
|
||||
// by 200 percent and shrinks it along the local y-axis by 50 percent.
|
||||
ScaleTransform3D myScaleTransform3D = new ScaleTransform3D();
|
||||
myScaleTransform3D.ScaleX = 2;
|
||||
myScaleTransform3D.ScaleY = 0.5;
|
||||
myScaleTransform3D.ScaleZ = 1;
|
||||
|
||||
// Add the scale transform to the Transform3DGroup.
|
||||
myTransform3DGroup.Children.Add(myScaleTransform3D);
|
||||
|
||||
// Set the Transform property of the GeometryModel to the Transform3DGroup which includes
|
||||
// both transformations. The 3D object now has two Transformations applied to it.
|
||||
myGeometryModel.Transform = myTransform3DGroup;
|
||||
// </SnippetMultiple3DTransformationsCodeExampleInline1>
|
||||
// Add the geometry model to the model group.
|
||||
myModel3DGroup.Children.Add(myGeometryModel);
|
||||
|
||||
// Add the group of models to the ModelVisual3d.
|
||||
myModelVisual3D.Content = myModel3DGroup;
|
||||
|
||||
myViewport3D.Children.Add(myModelVisual3D);
|
||||
|
||||
// Apply the viewport to the page so it will be rendered.
|
||||
this.Content = myViewport3D;
|
||||
}
|
||||
}
|
||||
}
|
||||
// </SnippetMultiple3DTransformationsCodeExampleWholePage>
|
||||
@@ -0,0 +1,7 @@
|
||||
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:my="clr-namespace:SDKSample"
|
||||
x:Class="SDKSample.MyApp"
|
||||
xmlns:SampleControls="SampleControls"
|
||||
Startup="myAppStartup">
|
||||
</Application>
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.IO;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
public partial class MyApp : Application
|
||||
{
|
||||
|
||||
public MyApp()
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
}
|
||||
|
||||
void myAppStartup(object sender, StartupEventArgs e)
|
||||
{
|
||||
Window myWindow = new Window();
|
||||
myWindow.Content = new SampleViewer();
|
||||
MainWindow = myWindow;
|
||||
myWindow.Show();
|
||||
}
|
||||
|
||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
try {
|
||||
StreamWriter wr = new StreamWriter("error.txt");
|
||||
wr.Write(args.ExceptionObject.ToString());
|
||||
wr.Close();
|
||||
}catch( Exception e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
MessageBox.Show("Unhandled exception: " + args.ExceptionObject.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="SDKSample.SampleViewer"
|
||||
xmlns:Examples="clr-namespace:SDKSample" >
|
||||
<DockPanel Background="White">
|
||||
<TabControl Name="sampleSelector">
|
||||
|
||||
<TabItem Header="Multiple Transformations Example">
|
||||
<Frame Name="MyMultipleTransformationsExampleFrame" Background="White" />
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="EmissiveMaterial Example">
|
||||
<Frame Name="MyEmissiveMaterialExampleFrame" Background="White" />
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Viewport3DVisual Example">
|
||||
<Frame Name="MyViewport3DVisualExampleFrame" Background="White" />
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Basic 3D Shape Example">
|
||||
<Frame Name="MyBasic3DShapeExampleFrame" Background="White" />
|
||||
</TabItem>
|
||||
<TabItem Header="Miscellaneous 3D Operations Example">
|
||||
<Frame Name="MyMisc3DOperationsExampleFrame" Background="White" />
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</DockPanel>
|
||||
</Page>
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
public partial class SampleViewer : Page
|
||||
{
|
||||
public SampleViewer()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
MyBasic3DShapeExampleFrame.Content = new Basic3DShapeExample();
|
||||
MyMisc3DOperationsExampleFrame.Content = new Misc3DOperationsExample();
|
||||
MyViewport3DVisualExampleFrame.Content = new Viewport3dVisualExample();
|
||||
MyEmissiveMaterialExampleFrame.Content = new EmissiveMaterialExample();
|
||||
MyMultipleTransformationsExampleFrame.Content = new MultipleTransformationsExample();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
// <SnippetViewport3DVisualExampleWholePage>
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Media3D;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
public class Viewport3dVisualExample : Page
|
||||
{
|
||||
public Viewport3dVisualExample()
|
||||
{
|
||||
// Instantiate the host visual that hosts the 3D object.
|
||||
MyVisualHost vh = new MyVisualHost();
|
||||
StackPanel mainPanel = new StackPanel();
|
||||
|
||||
// Add the drawing (3D object) to the page.
|
||||
mainPanel.Children.Add(vh);
|
||||
this.Content = mainPanel;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a host visual derived from the FrameworkElement class.
|
||||
// This class provides layout, event handling, and container support for
|
||||
// the child visual objects.
|
||||
public class MyVisualHost : FrameworkElement
|
||||
{
|
||||
// Create a collection of child visual objects.
|
||||
private VisualCollection _children;
|
||||
|
||||
public MyVisualHost()
|
||||
{
|
||||
_children = new VisualCollection(this);
|
||||
|
||||
// Add the DrawingVisual that represents the 3D object to the collection.
|
||||
_children.Add(Create3DVisualObject());
|
||||
}
|
||||
|
||||
// Create a DrawingVisual that contains a 3D object.
|
||||
private DrawingVisual Create3DVisualObject()
|
||||
{
|
||||
|
||||
// Declare scene objects.
|
||||
|
||||
// The Viewport3DVisual is used instead of the Viewport3D object because this 3D
|
||||
// object is drawn directly to the WPF visual layer. Using Viepwor3dVisual can provide
|
||||
// performance benefits over using Viewport3D although it does not support many of the
|
||||
// features that Viewport3D does.
|
||||
Viewport3DVisual myViewport3D = new Viewport3DVisual();
|
||||
Model3DGroup myModel3DGroup = new Model3DGroup();
|
||||
GeometryModel3D myGeometryModel = new GeometryModel3D();
|
||||
ModelVisual3D myModelVisual3D = new ModelVisual3D();
|
||||
|
||||
// Defines the camera used to view the 3D object. In order to view the 3D object,
|
||||
// the camera must be positioned and pointed such that the object is within view
|
||||
// of the camera.
|
||||
PerspectiveCamera myPCamera = new PerspectiveCamera();
|
||||
|
||||
// Specify where in the 3D scene the camera is.
|
||||
myPCamera.Position = new Point3D(0, 0, 2);
|
||||
|
||||
// Specify the direction that the camera is pointing.
|
||||
myPCamera.LookDirection = new Vector3D(0, 0, -1);
|
||||
|
||||
// Define camera's horizontal field of view in degrees.
|
||||
myPCamera.FieldOfView = 60;
|
||||
|
||||
// Asign the camera to the viewport
|
||||
myViewport3D.Camera = myPCamera;
|
||||
|
||||
// Define the lights cast in the scene. Without light, the 3D object cannot
|
||||
// be seen. Note: to illuminate an object from additional directions, create
|
||||
// additional lights.
|
||||
DirectionalLight myDirectionalLight = new DirectionalLight();
|
||||
myDirectionalLight.Color = Colors.White;
|
||||
myDirectionalLight.Direction = new Vector3D(-0.61, -0.5, -0.61);
|
||||
|
||||
myModel3DGroup.Children.Add(myDirectionalLight);
|
||||
|
||||
// The geometry specifes the shape of the 3D plane. In this sample, a flat sheet
|
||||
// is created.
|
||||
MeshGeometry3D myMeshGeometry3D = new MeshGeometry3D();
|
||||
|
||||
// Create a collection of normal vectors for the MeshGeometry3D.
|
||||
Vector3DCollection myNormalCollection = new Vector3DCollection();
|
||||
myNormalCollection.Add(new Vector3D(0, 0, 1));
|
||||
myNormalCollection.Add(new Vector3D(0, 0, 1));
|
||||
myNormalCollection.Add(new Vector3D(0, 0, 1));
|
||||
myNormalCollection.Add(new Vector3D(0, 0, 1));
|
||||
myNormalCollection.Add(new Vector3D(0, 0, 1));
|
||||
myNormalCollection.Add(new Vector3D(0, 0, 1));
|
||||
myMeshGeometry3D.Normals = myNormalCollection;
|
||||
|
||||
// Create a collection of vertex positions for the MeshGeometry3D.
|
||||
Point3DCollection myPositionCollection = new Point3DCollection();
|
||||
myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, -0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(-0.5, 0.5, 0.5));
|
||||
myPositionCollection.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
myMeshGeometry3D.Positions = myPositionCollection;
|
||||
|
||||
// Create a collection of texture coordinates for the MeshGeometry3D.
|
||||
PointCollection myTextureCoordinatesCollection = new PointCollection();
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 0));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 0));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(1, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 1));
|
||||
myTextureCoordinatesCollection.Add(new Point(0, 0));
|
||||
myMeshGeometry3D.TextureCoordinates = myTextureCoordinatesCollection;
|
||||
|
||||
// Create a collection of triangle indices for the MeshGeometry3D.
|
||||
Int32Collection myTriangleIndicesCollection = new Int32Collection();
|
||||
myTriangleIndicesCollection.Add(0);
|
||||
myTriangleIndicesCollection.Add(1);
|
||||
myTriangleIndicesCollection.Add(2);
|
||||
myTriangleIndicesCollection.Add(3);
|
||||
myTriangleIndicesCollection.Add(4);
|
||||
myTriangleIndicesCollection.Add(5);
|
||||
myMeshGeometry3D.TriangleIndices = myTriangleIndicesCollection;
|
||||
|
||||
// Apply the mesh to the geometry model.
|
||||
myGeometryModel.Geometry = myMeshGeometry3D;
|
||||
|
||||
// The material specifies the material applied to the 3D object. In this sample a
|
||||
// linear gradient covers the surface of the 3D object.
|
||||
|
||||
// Create a horizontal linear gradient with four stops.
|
||||
LinearGradientBrush myHorizontalGradient = new LinearGradientBrush();
|
||||
myHorizontalGradient.StartPoint = new Point(0, 0.5);
|
||||
myHorizontalGradient.EndPoint = new Point(1, 0.5);
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Red, 0.25));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Blue, 0.75));
|
||||
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.LimeGreen, 1.0));
|
||||
|
||||
// Define material and apply to the mesh geometries.
|
||||
DiffuseMaterial myMaterial = new DiffuseMaterial(myHorizontalGradient);
|
||||
myGeometryModel.Material = myMaterial;
|
||||
|
||||
// Apply a transform to the object. In this sample, a rotation transform is applied,
|
||||
// rendering the 3D object rotated.
|
||||
RotateTransform3D myRotateTransform3D = new RotateTransform3D();
|
||||
AxisAngleRotation3D myAxisAngleRotation3d = new AxisAngleRotation3D();
|
||||
myAxisAngleRotation3d.Axis = new Vector3D(0, 3, 0);
|
||||
myAxisAngleRotation3d.Angle = 40;
|
||||
myRotateTransform3D.Rotation = myAxisAngleRotation3d;
|
||||
myGeometryModel.Transform = myRotateTransform3D;
|
||||
|
||||
// Add the geometry model to the model group.
|
||||
myModel3DGroup.Children.Add(myGeometryModel);
|
||||
|
||||
// Add the group of models to the ModelVisual3d.
|
||||
myModelVisual3D.Content = myModel3DGroup;
|
||||
|
||||
// Create a rectangle to view the 3D object in.
|
||||
Rect myRectangle = new Rect();
|
||||
myRectangle.Location = new Point(10, 5);
|
||||
myRectangle.Size = new Size(900, 900);
|
||||
|
||||
myViewport3D.Children.Add(myModelVisual3D);
|
||||
myViewport3D.Viewport = myRectangle;
|
||||
|
||||
DrawingVisual dv = new DrawingVisual();
|
||||
dv.Children.Add(myViewport3D);
|
||||
return dv;
|
||||
}
|
||||
|
||||
// Provide a required override for the VisualChildCount property.
|
||||
protected override int VisualChildrenCount
|
||||
{
|
||||
get { return _children.Count; }
|
||||
}
|
||||
|
||||
// Provide a required override for the GetVisualChild method.
|
||||
protected override Visual GetVisualChild(int index)
|
||||
{
|
||||
if (index < 0 || index > _children.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
return (Visual)_children[index];
|
||||
}
|
||||
|
||||
// Provide a required override for the MeasureOverride method.
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
// Return the value of the parameter.
|
||||
return base.MeasureOverride(availableSize);
|
||||
}
|
||||
|
||||
// Provide a required override for the ArrangeOverride method.
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
// Return the value of the parameter.
|
||||
return base.ArrangeOverride(finalSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
// </SnippetViewport3DVisualExampleWholePage>
|
||||
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 129 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,57 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>SDKSample</AssemblyName>
|
||||
<TargetType>winexe</TargetType>
|
||||
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
|
||||
<ApplicationIcon>App.ico</ApplicationIcon>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<CLRDefaultNamespace>SDKSample</CLRDefaultNamespace>
|
||||
<ProjectGuid>{32AAFFC0-6E41-44E8-87FA-D82F6C1601E7}</ProjectGuid>
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- The rest of the References are currently in one of the .target files. Eventually, post-PDC we'll put them all here -->
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="MyApp.xaml" />
|
||||
<Page Include="Sampleviewer.xaml" />
|
||||
<Page Include="Basic3DShapeExample.xaml" />
|
||||
<Page Include="ApplyDrawingToMaterialExample.xaml" />
|
||||
<Page Include="EmissiveMaterialExample.xaml" />
|
||||
<Page Include="ScaleTransform3DExample.xaml" />
|
||||
<Page Include="MultipleTransformationsExample.xaml" />
|
||||
<Page Include="SpotLightExample.xaml" />
|
||||
<Page Include="SpecularMaterialExample.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MyApp.xaml.cs">
|
||||
<DependentUpon>MyApp.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="sample_images\*.*" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,87 @@
|
||||
<!-- <SnippetApplyDrawingToMaterialExampleWholePage> -->
|
||||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||
<DockPanel>
|
||||
<Viewbox>
|
||||
<Canvas Width="321" Height="201">
|
||||
|
||||
<!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
|
||||
<Viewport3D ClipToBounds="True" Width="150" Height="150" Canvas.Left="0" Canvas.Top="10">
|
||||
|
||||
<!-- Defines the camera used to view the 3D object. -->
|
||||
<Viewport3D.Camera>
|
||||
<PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1" FieldOfView="60" />
|
||||
</Viewport3D.Camera>
|
||||
|
||||
<!-- The ModelVisual3D children contain the 3D models -->
|
||||
<Viewport3D.Children>
|
||||
|
||||
<!-- This ModelVisual3D defines the light cast in the scene. Without light, the 3D
|
||||
object cannot be seen. Also, the direction of the lights affect shadowing. If desired,
|
||||
you can create multiple lights with different colors that shine from different directions. -->
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D>
|
||||
|
||||
<!-- The geometry specifies the shape of the 3D plane. In this sample, a flat sheet is created. -->
|
||||
<GeometryModel3D.Geometry>
|
||||
<MeshGeometry3D
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
|
||||
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
|
||||
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
|
||||
</GeometryModel3D.Geometry>
|
||||
<!-- <SnippetApplyDrawingToMaterialInline1> -->
|
||||
<!-- The material specifies the material applied to the 3D object. In this sample a tiled drawing
|
||||
covers the surface of the 3D object.-->
|
||||
<GeometryModel3D.Material>
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<DrawingBrush Viewport="0,0,0.1,0.1" TileMode="Tile">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Geometry="M0,0.1 L0.1,0 1,0.9, 0.9,1z"
|
||||
Brush="Gray" />
|
||||
<GeometryDrawing Geometry="M0.9,0 L1,0.1 0.1,1 0,0.9z"
|
||||
Brush="Gray" />
|
||||
<GeometryDrawing Geometry="M0.25,0.25 L0.5,0.125 0.75,0.25 0.5,0.5z"
|
||||
Brush="#FFFF00" />
|
||||
<GeometryDrawing Geometry="M0.25,0.75 L0.5,0.875 0.75,0.75 0.5,0.5z"
|
||||
Brush="Black" />
|
||||
<GeometryDrawing Geometry="M0.25,0.75 L0.125,0.5 0.25,0.25 0.5,0.5z"
|
||||
Brush="#FF0000" />
|
||||
<GeometryDrawing Geometry="M0.75,0.25 L0.875,0.5 0.75,0.75 0.5,0.5z"
|
||||
Brush="MediumBlue" />
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
</GeometryModel3D.Material>
|
||||
<!-- </SnippetApplyDrawingToMaterialInline1> -->
|
||||
<!-- Apply a transform to the object. In this sample, a rotation transform is applied, rendering the
|
||||
3D object rotated. -->
|
||||
<GeometryModel3D.Transform>
|
||||
<RotateTransform3D>
|
||||
<RotateTransform3D.Rotation>
|
||||
<AxisAngleRotation3D Axis="0,3,0" Angle="40" />
|
||||
</RotateTransform3D.Rotation>
|
||||
</RotateTransform3D>
|
||||
</GeometryModel3D.Transform>
|
||||
</GeometryModel3D>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
</Viewport3D.Children>
|
||||
</Viewport3D>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</DockPanel>
|
||||
</Page>
|
||||
<!-- </SnippetApplyDrawingToMaterialExampleWholePage> -->
|
||||
@@ -0,0 +1,78 @@
|
||||
<!-- <SnippetBasic3DShapeExampleWholePage> -->
|
||||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||
<DockPanel>
|
||||
<Viewbox>
|
||||
<Canvas Width="321" Height="201">
|
||||
|
||||
<!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
|
||||
<Viewport3D ClipToBounds="True" Width="150" Height="150" Canvas.Left="0" Canvas.Top="10">
|
||||
|
||||
<!-- Defines the camera used to view the 3D object. -->
|
||||
<Viewport3D.Camera>
|
||||
<PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1" FieldOfView="60" />
|
||||
</Viewport3D.Camera>
|
||||
|
||||
<!-- The ModelVisual3D children contain the 3D models -->
|
||||
<Viewport3D.Children>
|
||||
|
||||
<!-- This ModelVisual3D defines the light cast in the scene. Without light, the 3D
|
||||
object cannot be seen. Also, the direction of the lights affect shadowing. If desired,
|
||||
you can create multiple lights with different colors that shine from different directions. -->
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D>
|
||||
|
||||
<!-- The geometry specifies the shape of the 3D plane. In this sample, a flat sheet is created. -->
|
||||
<GeometryModel3D.Geometry>
|
||||
<MeshGeometry3D
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
|
||||
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
|
||||
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
|
||||
</GeometryModel3D.Geometry>
|
||||
|
||||
<!-- The material specifies the material applied to the 3D object. In this sample a linear gradient
|
||||
covers the surface of the 3D object.-->
|
||||
<GeometryModel3D.Material>
|
||||
<MaterialGroup>
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStop Color="Yellow" Offset="0" />
|
||||
<GradientStop Color="Red" Offset="0.25" />
|
||||
<GradientStop Color="Blue" Offset="0.75" />
|
||||
<GradientStop Color="LimeGreen" Offset="1" />
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
</MaterialGroup>
|
||||
</GeometryModel3D.Material>
|
||||
|
||||
<!-- Apply a transform to the object. In this sample, a rotation transform is applied, rendering the
|
||||
3D object rotated. -->
|
||||
<GeometryModel3D.Transform>
|
||||
<RotateTransform3D>
|
||||
<RotateTransform3D.Rotation>
|
||||
<AxisAngleRotation3D Axis="0,3,0" Angle="40" />
|
||||
</RotateTransform3D.Rotation>
|
||||
</RotateTransform3D>
|
||||
</GeometryModel3D.Transform>
|
||||
</GeometryModel3D>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
</Viewport3D.Children>
|
||||
|
||||
</Viewport3D>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</DockPanel>
|
||||
</Page>
|
||||
<!-- </SnippetBasic3DShapeExampleWholePage> -->
|
||||
@@ -0,0 +1,83 @@
|
||||
<!-- <SnippetEmissiveMaterialExampleWholePage> -->
|
||||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||
<DockPanel>
|
||||
<Viewbox>
|
||||
<Canvas Width="321" Height="201">
|
||||
|
||||
<!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
|
||||
<Viewport3D ClipToBounds="True" Width="150" Height="150"
|
||||
Canvas.Left="0" Canvas.Top="10">
|
||||
|
||||
<!-- Defines the camera used to view the 3D object. -->
|
||||
<Viewport3D.Camera>
|
||||
<PerspectiveCamera x:Name="myPerspectiveCamera" Position="0,0,2" LookDirection="0,0,-1"
|
||||
FieldOfView="60" />
|
||||
</Viewport3D.Camera>
|
||||
|
||||
<!-- The ModelVisual3D children contain the 3D models -->
|
||||
<Viewport3D.Children>
|
||||
|
||||
<!-- This ModelVisual3D defines the lights cast in the scene. Without light, the
|
||||
3D object cannot be seen. -->
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D>
|
||||
|
||||
<!-- The geometry specifies the shape of the 3D plane. In this case, a flat sheet is created. -->
|
||||
<GeometryModel3D.Geometry>
|
||||
<MeshGeometry3D
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
|
||||
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
|
||||
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
|
||||
</GeometryModel3D.Geometry>
|
||||
<!-- <SnippetEmmisiveMaterialAnimationExampleInline1> -->
|
||||
<!-- The material applied to the 3D object is made up of a DiffuseMaterial (gradient brush) with
|
||||
an EmissiveMaterial layered on top (blue SolidColorBrush). The EmissiveMaterial adds blue to the gradient. -->
|
||||
<GeometryModel3D.Material>
|
||||
<MaterialGroup>
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStop Color="Yellow" Offset="0" />
|
||||
<GradientStop Color="Red" Offset="0.25" />
|
||||
<GradientStop Color="Blue" Offset="0.75" />
|
||||
<GradientStop Color="LimeGreen" Offset="1" />
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
<EmissiveMaterial>
|
||||
<EmissiveMaterial.Brush>
|
||||
<SolidColorBrush x:Name="mySolidColorBrush" Color="Blue" />
|
||||
</EmissiveMaterial.Brush>
|
||||
</EmissiveMaterial>
|
||||
</MaterialGroup>
|
||||
</GeometryModel3D.Material>
|
||||
<!-- </SnippetEmmisiveMaterialAnimationExampleInline1> -->
|
||||
<!-- The Transform specifies how to transform the 3D object. This transform
|
||||
rotates the object.-->
|
||||
<GeometryModel3D.Transform>
|
||||
<RotateTransform3D>
|
||||
<RotateTransform3D.Rotation>
|
||||
<AxisAngleRotation3D x:Name="myAngleRotation" Axis="0,3,0" Angle="40" />
|
||||
</RotateTransform3D.Rotation>
|
||||
</RotateTransform3D>
|
||||
</GeometryModel3D.Transform>
|
||||
</GeometryModel3D>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
</Viewport3D.Children>
|
||||
</Viewport3D>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</DockPanel>
|
||||
</Page>
|
||||
<!-- </SnippetEmissiveMaterialExampleWholePage> -->
|
||||
@@ -0,0 +1,89 @@
|
||||
<!-- <SnippetMultiple3DTransformationsExampleWholePage> -->
|
||||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||
<DockPanel>
|
||||
<Viewbox>
|
||||
<Canvas Width="321" Height="201">
|
||||
|
||||
<!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
|
||||
<Viewport3D ClipToBounds="True" Width="150" Height="150" Canvas.Left="0" Canvas.Top="10">
|
||||
|
||||
<!-- Defines the camera used to view the 3D object. -->
|
||||
<Viewport3D.Camera>
|
||||
<PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1" FieldOfView="60" />
|
||||
</Viewport3D.Camera>
|
||||
|
||||
<!-- The ModelVisual3D children contain the 3D models -->
|
||||
<Viewport3D.Children>
|
||||
|
||||
<!-- This ModelVisual3D defines the light cast in the scene. Without light, the 3D
|
||||
object cannot be seen. Also, the direction of the lights affect shadowing. If desired,
|
||||
you can create multiple lights with different colors that shine from different directions. -->
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D>
|
||||
|
||||
<!-- The geometry specifies the shape of the 3D plane. In this sample, a flat sheet is created. -->
|
||||
<GeometryModel3D.Geometry>
|
||||
<MeshGeometry3D
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
|
||||
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
|
||||
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
|
||||
</GeometryModel3D.Geometry>
|
||||
|
||||
<!-- The material specifies the material applied to the 3D object. In this sample a linear gradient
|
||||
covers the surface of the 3D object.-->
|
||||
<GeometryModel3D.Material>
|
||||
<MaterialGroup>
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStop Color="Yellow" Offset="0" />
|
||||
<GradientStop Color="Red" Offset="0.25" />
|
||||
<GradientStop Color="Blue" Offset="0.75" />
|
||||
<GradientStop Color="LimeGreen" Offset="1" />
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
</MaterialGroup>
|
||||
</GeometryModel3D.Material>
|
||||
<!-- <SnippetMultiple3DTransformationsExampleInline1> -->
|
||||
<!-- Apply multiple transformations to the object. In this sample, a rotation and scale transform
|
||||
is applied. -->
|
||||
<GeometryModel3D.Transform>
|
||||
<Transform3DGroup>
|
||||
<Transform3DGroup.Children>
|
||||
<RotateTransform3D>
|
||||
<RotateTransform3D.Rotation>
|
||||
|
||||
<!-- This transformation rotates the object. -->
|
||||
<AxisAngleRotation3D Axis="0,3,0" Angle="40" />
|
||||
</RotateTransform3D.Rotation>
|
||||
</RotateTransform3D>
|
||||
|
||||
<!-- This Scale Transform stretches the object horizontally by 200 percent and shrinks it
|
||||
vertically by 50 percent. -->
|
||||
<ScaleTransform3D ScaleX="2" ScaleY="0.5" ScaleZ="1" CenterX="0" CenterY="0" CenterZ="0" />
|
||||
</Transform3DGroup.Children>
|
||||
</Transform3DGroup>
|
||||
</GeometryModel3D.Transform>
|
||||
<!-- </SnippetMultiple3DTransformationsExampleInline1> -->
|
||||
</GeometryModel3D>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
</Viewport3D.Children>
|
||||
|
||||
</Viewport3D>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</DockPanel>
|
||||
</Page>
|
||||
<!-- </SnippetMultiple3DTransformationsExampleWholePage> -->
|
||||
@@ -0,0 +1,200 @@
|
||||
<!-- If you change the root element of this file, be sure to change the class that is subclassed in MyApp.xaml.cs -->
|
||||
<Application
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="SDKSample.MyApp"
|
||||
StartupUri="SampleViewer.xaml"
|
||||
>
|
||||
<!-- Defines the resources and styles used by the application. -->
|
||||
<Application.Resources>
|
||||
|
||||
|
||||
<!-- Styles & Templates -->
|
||||
|
||||
<Style TargetType="{x:Type Viewport3D}">
|
||||
<Setter Property="IsHitTestVisible" Value="False" />
|
||||
</Style>
|
||||
|
||||
|
||||
<!-- 3D Models -->
|
||||
<MeshGeometry3D x:Key="CubeSide01"
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="-1,0,0 -1,0,0 -1,0,0 -1,0,0 -1,0,0 -1,0,0 "
|
||||
TextureCoordinates="0,1 0,0 1,0 1,0 1,1 0,1 "
|
||||
Positions="-0.5,0.5,-0.5 -0.5,-0.5,-0.5 -0.5,-0.5,0.5 -0.5,-0.5,0.5 -0.5,0.5,0.5 -0.5,0.5,-0.5 " />
|
||||
|
||||
<MeshGeometry3D x:Key="CubeSide02"
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
|
||||
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
|
||||
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
|
||||
|
||||
<MeshGeometry3D x:Key="CubeSide03"
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
|
||||
TextureCoordinates="1,0 1,1 0,1 0,1 0,0 1,0 "
|
||||
Positions="0.5,-0.5,-0.5 0.5,0.5,-0.5 0.5,0.5,0.5 0.5,0.5,0.5 0.5,-0.5,0.5 0.5,-0.5,-0.5 " />
|
||||
|
||||
<MeshGeometry3D x:Key="CubeSide04"
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="1,0,0 1,0,0 1,0,0 1,0,0 1,0,0 1,0,0 "
|
||||
TextureCoordinates="1,0 1,1 0,1 0,1 0,0 1,0 "
|
||||
Positions="-0.5,-0.5,-0.5 -0.5,0.5,-0.5 0.5,0.5,-0.5 0.5,0.5,-0.5 0.5,-0.5,-0.5 -0.5,-0.5,-0.5 " />
|
||||
|
||||
<MeshGeometry3D x:Key="CubeSide05"
|
||||
TriangleIndices="0,1,2 3,4,5 6,7,8 9,10,11 "
|
||||
Normals="0,-1,0 0,-1,0 0,-1,0 0,-1,0 0,-1,0 0,-1,0 0,1,0 0,1,0 0,1,0 0,1,0 0,1,0 0,1,0 "
|
||||
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 1,1 0,1 0,0 0,0 1,0 1,1 "
|
||||
Positions="-0.5,-0.5,-0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 0.5,-0.5,0.5 -0.5,-0.5,-0.5 -0.5,0.5,-0.5
|
||||
0.5,0.5,-0.5 -0.5,0.5,-0.5 -0.5,0.5,0.5 -0.5,0.5,0.5 0.5,0.5,0.5 0.5,0.5,-0.5 " />
|
||||
|
||||
<MeshGeometry3D x:Key="CubeSide06"
|
||||
TriangleIndices="0,1,2 3,4,5 6,7,8 9,10,11 "
|
||||
Normals="-1,0,0 -1,0,0 -1,0,0 -1,0,0 -1,0,0 -1,0,0 "
|
||||
TextureCoordinates="1,0 1,1 0,1 0,1 0,0 1,0 "
|
||||
Positions="-0.5,-0.5,0.5 -0.5,-0.5,-0.5 0.5,-0.5,-0.5 0.5,-0.5,-0.5 0.5,-0.5,0.5 -0.5,-0.5,0.5" />
|
||||
|
||||
<!-- 3D Materials -->
|
||||
<MaterialGroup x:Key="LeavesMaterial1">
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<ImageBrush Stretch="UniformToFill" ImageSource="sample_images\leaves_closeup.png" TileMode="None" ViewportUnits="Absolute" Viewport="0 0 1 1" AlignmentX="Left" AlignmentY="Top" Opacity="1.000000" />
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
<SpecularMaterial SpecularPower="85.3333">
|
||||
<SpecularMaterial.Brush>
|
||||
<SolidColorBrush Color="#FFFFFF" Opacity="1.000000"/>
|
||||
</SpecularMaterial.Brush>
|
||||
</SpecularMaterial>
|
||||
</MaterialGroup>
|
||||
|
||||
<MaterialGroup x:Key="RocksMaterial">
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<ImageBrush Stretch="UniformToFill" ImageSource="sample_images\rocks.png" TileMode="None" ViewportUnits="Absolute" Viewport="0 0 1 1" AlignmentX="Left" AlignmentY="Top" Opacity="1.000000" />
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
<SpecularMaterial SpecularPower="85.3333">
|
||||
<SpecularMaterial.Brush>
|
||||
<SolidColorBrush Color="#FFFFFF" Opacity="1.000000"/>
|
||||
</SpecularMaterial.Brush>
|
||||
</SpecularMaterial>
|
||||
</MaterialGroup>
|
||||
|
||||
<MaterialGroup x:Key="BranchesMaterial">
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<ImageBrush Stretch="UniformToFill" ImageSource="sample_images\branches.png" TileMode="None" ViewportUnits="Absolute" Viewport="0 0 1 1" AlignmentX="Left" AlignmentY="Top" Opacity="1.000000" />
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
<SpecularMaterial SpecularPower="85.3333">
|
||||
<SpecularMaterial.Brush>
|
||||
<SolidColorBrush Color="#FFFFFF" Opacity="1.000000"/>
|
||||
</SpecularMaterial.Brush>
|
||||
</SpecularMaterial>
|
||||
</MaterialGroup>
|
||||
<MaterialGroup x:Key="BerriesMaterial">
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<ImageBrush Stretch="UniformToFill" ImageSource="sample_images\berries.jpg" TileMode="None" ViewportUnits="Absolute" Viewport="0 0 1 1" AlignmentX="Left" AlignmentY="Top" Opacity="1.000000" />
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
<SpecularMaterial SpecularPower="85.3333">
|
||||
<SpecularMaterial.Brush>
|
||||
<SolidColorBrush Color="#FFFFFF" Opacity="1.000000"/>
|
||||
</SpecularMaterial.Brush>
|
||||
</SpecularMaterial>
|
||||
</MaterialGroup>
|
||||
<MaterialGroup x:Key="FlowersMaterial">
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<ImageBrush Stretch="UniformToFill" ImageSource="sample_images\Waterlilies.png" ViewportUnits="Absolute"
|
||||
Viewport="0 0 1 1" AlignmentX="Left" AlignmentY="Top" Opacity="1.000000" />
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
<SpecularMaterial SpecularPower="85.3333">
|
||||
<SpecularMaterial.Brush>
|
||||
<SolidColorBrush Color="#FFFFFF" Opacity="1.000000"/>
|
||||
</SpecularMaterial.Brush>
|
||||
</SpecularMaterial>
|
||||
</MaterialGroup>
|
||||
<MaterialGroup x:Key="SunsetMaterial">
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<ImageBrush Stretch="UniformToFill" ImageSource="sample_images\Sunset.jpg" ViewportUnits="Absolute"
|
||||
Viewport="0 0 1 1" AlignmentX="Left" AlignmentY="Top" Opacity="1.000000" />
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
<SpecularMaterial SpecularPower="85.3333">
|
||||
<SpecularMaterial.Brush>
|
||||
<SolidColorBrush Color="#FFFFFF" Opacity="1.000000"/>
|
||||
</SpecularMaterial.Brush>
|
||||
</SpecularMaterial>
|
||||
</MaterialGroup>
|
||||
<MaterialGroup x:Key="SolidColorMaterial">
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<SolidColorBrush Color="Orange" Opacity="1.000000"/>
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
<SpecularMaterial SpecularPower="85.3333">
|
||||
<SpecularMaterial.Brush>
|
||||
<SolidColorBrush Color="#FFFFFF" Opacity="1.000000"/>
|
||||
</SpecularMaterial.Brush>
|
||||
</SpecularMaterial>
|
||||
</MaterialGroup>
|
||||
|
||||
|
||||
<!-- Model3DVisuals -->
|
||||
<ModelVisual3D x:Key="PictureCubeModelVisual3DResource" x:Shared="False">
|
||||
<ModelVisual3D.Children>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<AmbientLight Color="#333333" />
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<DirectionalLight Color="#FFFFFF" Direction="0.612372,-0.5,-0.612372" />
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D Geometry="{StaticResource CubeSide01}" Material="{StaticResource BranchesMaterial}"/>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D Geometry="{StaticResource CubeSide02}" Material="{StaticResource FlowersMaterial}"/>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D Geometry="{StaticResource CubeSide03}" Material="{StaticResource BerriesMaterial}"/>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D Geometry="{StaticResource CubeSide04}" Material="{StaticResource LeavesMaterial1}"/>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D Geometry="{StaticResource CubeSide05}" Material="{StaticResource RocksMaterial}"/>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D Geometry="{StaticResource CubeSide06}" Material="{StaticResource SunsetMaterial}"/>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
</ModelVisual3D.Children>
|
||||
</ModelVisual3D>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MyApp.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class MyApp : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<!-- Displays the different animation examples. -->
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="keyframes_markup.SampleViewer"
|
||||
Title="3D Gallery (Markup)">
|
||||
|
||||
|
||||
<DockPanel>
|
||||
<TabControl Background="White">
|
||||
|
||||
<TabItem Header="SpecularMaterial Example">
|
||||
<Frame Source="SpecularMaterialExample.xaml" />
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="SpotLight Example">
|
||||
<Frame Source="SpotLightExample.xaml" />
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Multiple Transformations Example">
|
||||
<Frame Source="MultipleTransformationsExample.xaml" />
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="ScaleTransform3D Example">
|
||||
<Frame Source="ScaleTransform3DExample.xaml" />
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="EmissiveMaterial Example">
|
||||
<Frame Source="EmissiveMaterialExample.xaml" />
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Apply a Drawing to a Material Example">
|
||||
<Frame Source="ApplyDrawingToMaterialExample.xaml" />
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Basic 3D Shape Example">
|
||||
<Frame Source="Basic3DShapeExample.xaml" />
|
||||
</TabItem>
|
||||
|
||||
</TabControl>
|
||||
|
||||
</DockPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,26 @@
|
||||
//This is a list of commonly used namespaces for a window.
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace keyframes_markup
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SampleViewer.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class SampleViewer : Window
|
||||
{
|
||||
public SampleViewer()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<!-- <SnippetScaleTransform3DExampleWholePage> -->
|
||||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||
<DockPanel>
|
||||
<Viewbox>
|
||||
<Canvas Width="321" Height="201">
|
||||
|
||||
<!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
|
||||
<Viewport3D ClipToBounds="True" Width="150" Height="150" Canvas.Left="0" Canvas.Top="10">
|
||||
|
||||
<!-- Defines the camera used to view the 3D object. -->
|
||||
<Viewport3D.Camera>
|
||||
<PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1" FieldOfView="60" />
|
||||
</Viewport3D.Camera>
|
||||
|
||||
<!-- The ModelVisual3D children contain the 3D models -->
|
||||
<Viewport3D.Children>
|
||||
|
||||
<!-- This ModelVisual3D defines the light cast in the scene. Without light, the 3D
|
||||
object cannot be seen. Also, the direction of the lights affect shadowing. If desired,
|
||||
you can create multiple lights with different colors that shine from different directions. -->
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D>
|
||||
|
||||
<!-- The geometry specifies the shape of the 3D plane. In this sample, a flat sheet is created. -->
|
||||
<GeometryModel3D.Geometry>
|
||||
<MeshGeometry3D
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
|
||||
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
|
||||
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
|
||||
</GeometryModel3D.Geometry>
|
||||
|
||||
<!-- The material specifies the material applied to the 3D object. In this sample a linear gradient
|
||||
covers the surface of the 3D object.-->
|
||||
<GeometryModel3D.Material>
|
||||
<MaterialGroup>
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStop Color="Yellow" Offset="0" />
|
||||
<GradientStop Color="Red" Offset="0.25" />
|
||||
<GradientStop Color="Blue" Offset="0.75" />
|
||||
<GradientStop Color="LimeGreen" Offset="1" />
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
</MaterialGroup>
|
||||
</GeometryModel3D.Material>
|
||||
<!-- <SnippetScaleTransform3DExampleInline1> -->
|
||||
<!-- Apply a scale transform to the object. You can transform the scale of the object
|
||||
for the X, Y, or Z axis. The ScaleX, ScaleY, and ScaleZ properties resize the object
|
||||
by the factor you specify. For example, a ScaleX value of 1.5 stretches the object to
|
||||
150 percent of its original width. A ScaleY value of 0.5 shrinks the height of an object
|
||||
by 50 percent. -->
|
||||
<GeometryModel3D.Transform>
|
||||
|
||||
<!-- This Scale Transform stretches the object horizontally by 200 percent and shrinks it
|
||||
vertically by 50 percent. -->
|
||||
<ScaleTransform3D ScaleX="2" ScaleY="0.5" ScaleZ="1" CenterX="0" CenterY="0" CenterZ="0" />
|
||||
</GeometryModel3D.Transform>
|
||||
<!-- </SnippetScaleTransform3DExampleInline1> -->
|
||||
</GeometryModel3D>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
</Viewport3D.Children>
|
||||
|
||||
</Viewport3D>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</DockPanel>
|
||||
</Page>
|
||||
<!-- </SnippetScaleTransform3DExampleWholePage> -->
|
||||
@@ -0,0 +1,80 @@
|
||||
<!-- <SnippetSpecularMaterialExampleWholePage> -->
|
||||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||
<DockPanel>
|
||||
<Viewbox>
|
||||
<Canvas Width="321" Height="201" Background="Black">
|
||||
|
||||
<!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
|
||||
<Viewport3D ClipToBounds="True" Width="150" Height="150" Canvas.Left="0" Canvas.Top="10">
|
||||
|
||||
<!-- Defines the camera used to view the 3D object. -->
|
||||
<Viewport3D.Camera>
|
||||
<PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1" FieldOfView="60" />
|
||||
</Viewport3D.Camera>
|
||||
|
||||
<!-- The ModelVisual3D children contain the 3D models -->
|
||||
<Viewport3D.Children>
|
||||
<!-- This ModelVisual3D defines the lights cast in the scene. Without light, the
|
||||
3D object cannot be seen. Also, the direction of the lights affect shadowing. -->
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D>
|
||||
|
||||
<!-- The geometry specifies the shape of the 3D plane. In this sample, a flat sheet is created. -->
|
||||
<GeometryModel3D.Geometry>
|
||||
<MeshGeometry3D
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
|
||||
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
|
||||
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
|
||||
</GeometryModel3D.Geometry>
|
||||
|
||||
<!-- The material specifies the material applied to the 3D object. In this sample a linear gradient
|
||||
covers the surface of the 3D object.-->
|
||||
<GeometryModel3D.Material>
|
||||
<MaterialGroup>
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStop Color="Yellow" Offset="0" />
|
||||
<GradientStop Color="Red" Offset="0.25" />
|
||||
<GradientStop Color="Blue" Offset="0.75" />
|
||||
<GradientStop Color="LimeGreen" Offset="1" />
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
<SpecularMaterial SpecularPower="100">
|
||||
<SpecularMaterial.Brush>
|
||||
<SolidColorBrush Color="#FFFFFF" Opacity="1.000000"/>
|
||||
</SpecularMaterial.Brush>
|
||||
</SpecularMaterial>
|
||||
</MaterialGroup>
|
||||
</GeometryModel3D.Material>
|
||||
<!-- The Transform specifies how to transform the 3D object. This transform
|
||||
rotates the object.-->
|
||||
<GeometryModel3D.Transform>
|
||||
<RotateTransform3D>
|
||||
<RotateTransform3D.Rotation>
|
||||
<AxisAngleRotation3D Axis="0,3,0" Angle="40" />
|
||||
</RotateTransform3D.Rotation>
|
||||
</RotateTransform3D>
|
||||
</GeometryModel3D.Transform>
|
||||
</GeometryModel3D>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
</Viewport3D.Children>
|
||||
|
||||
</Viewport3D>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</DockPanel>
|
||||
</Page>
|
||||
<!-- </SnippetSpecularMaterialExampleWholePage> -->
|
||||
@@ -0,0 +1,72 @@
|
||||
<!-- <SnippetSpotLightExampleWholePage> -->
|
||||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||
<DockPanel>
|
||||
<Viewbox>
|
||||
<Canvas Width="321" Height="201">
|
||||
|
||||
<!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
|
||||
<Viewport3D ClipToBounds="True" Width="150" Height="150" Canvas.Left="0" Canvas.Top="10">
|
||||
|
||||
<!-- Defines the camera used to view the 3D object. -->
|
||||
<Viewport3D.Camera>
|
||||
<PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1" FieldOfView="60" />
|
||||
</Viewport3D.Camera>
|
||||
|
||||
<!-- The ModelVisual3D children contain the 3D models -->
|
||||
<Viewport3D.Children>
|
||||
<!-- <SnippetSpotLightExampleInline1> -->
|
||||
<!-- A SpotLight is used to light the scene. The InnerConeAngle and OuterConeAngle are used
|
||||
to control the size of the light cone created by the SpotLight. The Direction and Position
|
||||
properties determine where the SpotLight is pointing in the scene. In this example, the Position
|
||||
of the SpotLight is set so that the SpotLight is only illuminating the upper right-hand corner
|
||||
of the 3D object. -->
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<SpotLight x:Name="mySpotLight" InnerConeAngle="20" OuterConeAngle="20" Color="#FFFFFF" Direction="0,0,-1"
|
||||
Position="1,1,6" Range="20"/>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
<!-- </SnippetSpotLightExampleInline1> -->
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<GeometryModel3D>
|
||||
|
||||
<!-- The geometry specifies the shape of the 3D plane. In this sample, a flat sheet is created. -->
|
||||
<GeometryModel3D.Geometry>
|
||||
<MeshGeometry3D
|
||||
TriangleIndices="0,1,2 3,4,5 "
|
||||
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
|
||||
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
|
||||
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
|
||||
</GeometryModel3D.Geometry>
|
||||
|
||||
<!-- The material specifies the material applied to the 3D object. In this sample a linear gradient
|
||||
covers the surface of the 3D object.-->
|
||||
<GeometryModel3D.Material>
|
||||
<MaterialGroup>
|
||||
<DiffuseMaterial>
|
||||
<DiffuseMaterial.Brush>
|
||||
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStop Color="Yellow" Offset="0" />
|
||||
<GradientStop Color="Red" Offset="0.25" />
|
||||
<GradientStop Color="Blue" Offset="0.75" />
|
||||
<GradientStop Color="LimeGreen" Offset="1" />
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
</DiffuseMaterial.Brush>
|
||||
</DiffuseMaterial>
|
||||
</MaterialGroup>
|
||||
</GeometryModel3D.Material>
|
||||
</GeometryModel3D>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
</Viewport3D.Children>
|
||||
|
||||
</Viewport3D>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</DockPanel>
|
||||
</Page>
|
||||
<!-- </SnippetSpotLightExampleWholePage> -->
|
||||
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 684 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 531 KiB |
|
After Width: | Height: | Size: 246 KiB |
|
After Width: | Height: | Size: 285 KiB |
|
After Width: | Height: | Size: 364 KiB |
|
After Width: | Height: | Size: 129 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 258 KiB |
@@ -0,0 +1,35 @@
|
||||
#region Using directives
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("create_cube")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("create_cube")]
|
||||
[assembly: AssemblyCopyright("Copyright @ Microsoft 2005")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//In order to begin building localizable applications, set <UICulture>CultureYouAreCodingWith</UICulture> in your
|
||||
//.csproj file inside a <PropertyGroup>. For example, if you are using US english in your source files, set the
|
||||
//<UICulture> to en-US. Then uncomment the NeutralResourceLanguage attribute below.
|
||||
//Update the "en-US" in the line below to match the UICulture setting in the project file.
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateFallbackResourceLocation.Satellite)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
@@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50215.44
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace create_cube.Properties
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Resources;
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the Strongly Typed Resource Builder
|
||||
// class via a tool like ResGen or Visual Studio.NET.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
class Resources
|
||||
{
|
||||
|
||||
private static System.Resources.ResourceManager _resMgr;
|
||||
|
||||
private static System.Globalization.CultureInfo _resCulture;
|
||||
|
||||
/*FamANDAssem*/
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((_resMgr == null))
|
||||
{
|
||||
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Resources", typeof(Resources).Assembly);
|
||||
_resMgr = temp;
|
||||
}
|
||||
return _resMgr;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return _resCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
_resCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,42 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50215.44
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace create_cube.Properties
|
||||
{
|
||||
public partial class Settings : System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
private static Settings m_Value;
|
||||
|
||||
private static object m_SyncObject = new object();
|
||||
|
||||
public static Settings Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((Settings.m_Value == null))
|
||||
{
|
||||
System.Threading.Monitor.Enter(Settings.m_SyncObject);
|
||||
if ((Settings.m_Value == null))
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.m_Value = new Settings();
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Threading.Monitor.Exit(Settings.m_SyncObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Settings.m_Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,9 @@
|
||||
<Window x:Class="create_cube.Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="create_cube"
|
||||
Loaded="WindowLoaded"
|
||||
Name="mainWindow"
|
||||
>
|
||||
|
||||
</Window>
|
||||
@@ -0,0 +1,373 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace create_cube
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
//<Snippet3DOverview3DN18>
|
||||
//some scene objects
|
||||
Viewport3D myViewport = new Viewport3D();
|
||||
//</Snippet3DOverview3DN18>
|
||||
GeometryModel3D side1 = new GeometryModel3D();
|
||||
GeometryModel3D side2 = new GeometryModel3D();
|
||||
GeometryModel3D side3 = new GeometryModel3D();
|
||||
GeometryModel3D side4 = new GeometryModel3D();
|
||||
GeometryModel3D side5 = new GeometryModel3D();
|
||||
GeometryModel3D side6 = new GeometryModel3D();
|
||||
PerspectiveCamera myPCamera = new PerspectiveCamera();
|
||||
DirectionalLight myDLight = new DirectionalLight();
|
||||
AmbientLight myAmbLight = new AmbientLight();
|
||||
MaterialGroup myMaterials = new MaterialGroup();
|
||||
Transform3DGroup cube1TransformGroup = new Transform3DGroup();
|
||||
Transform3DGroup cube2TransformGroup = new Transform3DGroup();
|
||||
Transform3DGroup cube3TransformGroup = new Transform3DGroup();
|
||||
Transform3DGroup allModelsTransformGroup = new Transform3DGroup();
|
||||
Model3DGroup allModels = new Model3DGroup();
|
||||
Model3DGroup cubeModel_1 = new Model3DGroup();
|
||||
Model3DGroup cubeModel_2 = new Model3DGroup();
|
||||
Model3DGroup cubeModel_3 = new Model3DGroup();
|
||||
//<Snippet3DOverview3DN6>
|
||||
MeshGeometry3D side1Plane = new MeshGeometry3D();
|
||||
//</Snippet3DOverview3DN6>
|
||||
MeshGeometry3D side2Plane = new MeshGeometry3D();
|
||||
MeshGeometry3D side3Plane = new MeshGeometry3D();
|
||||
MeshGeometry3D side4Plane = new MeshGeometry3D();
|
||||
MeshGeometry3D side5Plane = new MeshGeometry3D();
|
||||
MeshGeometry3D side6Plane = new MeshGeometry3D();
|
||||
DiffuseMaterial side1Material = new DiffuseMaterial();
|
||||
DiffuseMaterial side2Material = new DiffuseMaterial();
|
||||
DiffuseMaterial side3Material = new DiffuseMaterial();
|
||||
DiffuseMaterial side4Material = new DiffuseMaterial();
|
||||
DiffuseMaterial side5Material = new DiffuseMaterial();
|
||||
DiffuseMaterial side6Material = new DiffuseMaterial();
|
||||
|
||||
private void WindowLoaded(object sender, EventArgs e)
|
||||
{
|
||||
DrawMeshes();
|
||||
DrawSomeModels();
|
||||
}
|
||||
|
||||
private void DrawSomeModels()
|
||||
{
|
||||
myViewport.Name = "myViewport";
|
||||
ModelVisual3D myModelVisual = new ModelVisual3D();
|
||||
|
||||
//Define lights and cameras
|
||||
myPCamera.FarPlaneDistance = 20;
|
||||
myPCamera.NearPlaneDistance = 0;
|
||||
myPCamera.FieldOfView = 50;
|
||||
myPCamera.Position = new Point3D(-5, 2, 3);
|
||||
myPCamera.LookDirection = new Vector3D(5, -2, -3);
|
||||
myPCamera.UpDirection = new Vector3D(0, 1, 0);
|
||||
|
||||
myDLight.Color = Colors.White;
|
||||
myDLight.Direction = new Vector3D(-3, -4, -5);
|
||||
|
||||
myAmbLight.Color = Colors.White;
|
||||
|
||||
//set Geometry property of MeshGeometry3D
|
||||
side2.Geometry = side2Plane;
|
||||
side6.Geometry = side6Plane;
|
||||
side1.Geometry = side1Plane;
|
||||
side3.Geometry = side3Plane;
|
||||
side4.Geometry = side4Plane;
|
||||
side5.Geometry = side5Plane;
|
||||
|
||||
//create translations
|
||||
//<Snippet3DOverview3DN19>
|
||||
TranslateTransform3D cube2Translation = new TranslateTransform3D(new Vector3D(2, 0, 0));
|
||||
//</Snippet3DOverview3DN19>
|
||||
TranslateTransform3D cube3Translation = new TranslateTransform3D(new Vector3D(4, 0, 0));
|
||||
//<Snippet3DOverview3DN1>
|
||||
//Define a rotation
|
||||
RotateTransform3D myRotateTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 1));
|
||||
//</Snippet3DOverview3DN1>
|
||||
//<Snippet3DOverview3DN2>
|
||||
//Define an animation for the rotation
|
||||
DoubleAnimation myAnimation = new DoubleAnimation();
|
||||
myAnimation.From = 1;
|
||||
myAnimation.To = 361;
|
||||
myAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(5000));
|
||||
myAnimation.RepeatBehavior = RepeatBehavior.Forever;
|
||||
//</Snippet3DOverview3DN2>
|
||||
|
||||
//Define another animation
|
||||
//<Snippet3DOverview3DN3>
|
||||
Vector3DAnimation myVectorAnimation = new Vector3DAnimation(new Vector3D(-1, -1, -1), new Duration(TimeSpan.FromMilliseconds(5000)));
|
||||
myVectorAnimation.RepeatBehavior = RepeatBehavior.Forever;
|
||||
//</Snippet3DOverview3DN3>
|
||||
|
||||
myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, myAnimation);
|
||||
//<Snippet3DOverview3DN4>
|
||||
myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AxisProperty, myVectorAnimation);
|
||||
//</Snippet3DOverview3DN4>
|
||||
//<Snippet3DOverview3DN5>
|
||||
//Add transformation to the model
|
||||
cube1TransformGroup.Children.Add(myRotateTransform);
|
||||
//</Snippet3DOverview3DN5>
|
||||
|
||||
cube2TransformGroup.Children.Add(myRotateTransform);
|
||||
cube2TransformGroup.Children.Add(cube2Translation);
|
||||
|
||||
cube3TransformGroup.Children.Add(myRotateTransform);
|
||||
cube3TransformGroup.Children.Add(cube3Translation);
|
||||
|
||||
allModelsTransformGroup.Children.Add(myRotateTransform);
|
||||
|
||||
cubeModel_1.Children.Add(side1);
|
||||
cubeModel_1.Children.Add(side2);
|
||||
cubeModel_1.Children.Add(side3);
|
||||
cubeModel_1.Children.Add(side4);
|
||||
cubeModel_1.Children.Add(side5);
|
||||
cubeModel_1.Children.Add(side6);
|
||||
cubeModel_1.Transform = cube1TransformGroup;
|
||||
|
||||
cubeModel_2.Children.Add(side1);
|
||||
cubeModel_2.Children.Add(side2);
|
||||
cubeModel_2.Children.Add(side3);
|
||||
cubeModel_2.Children.Add(side4);
|
||||
cubeModel_2.Children.Add(side5);
|
||||
cubeModel_2.Children.Add(side6);
|
||||
cubeModel_2.Transform = cube2TransformGroup;
|
||||
|
||||
cubeModel_3.Children.Add(side1);
|
||||
cubeModel_3.Children.Add(side2);
|
||||
cubeModel_3.Children.Add(side3);
|
||||
cubeModel_3.Children.Add(side4);
|
||||
cubeModel_3.Children.Add(side5);
|
||||
cubeModel_3.Children.Add(side6);
|
||||
cubeModel_3.Transform = cube3TransformGroup;
|
||||
|
||||
allModels.Transform = allModelsTransformGroup;
|
||||
allModels.Children.Add(cubeModel_3);
|
||||
allModels.Children.Add(cubeModel_2);
|
||||
allModels.Children.Add(cubeModel_1);
|
||||
|
||||
allModels.Children.Add(myAmbLight);
|
||||
|
||||
myViewport.Camera = myPCamera;
|
||||
myModelVisual.Content = allModels;
|
||||
myViewport.Children.Add(myModelVisual);
|
||||
|
||||
mainWindow.Content = myViewport;
|
||||
}
|
||||
|
||||
private void DrawMeshes()
|
||||
{
|
||||
//side1-------------------------------------------------
|
||||
//<Snippet3DOverview3DN7>
|
||||
side1Plane.Positions.Add(new Point3D(-0.5, -0.5, -0.5));
|
||||
side1Plane.Positions.Add(new Point3D(-0.5, 0.5, -0.5));
|
||||
side1Plane.Positions.Add(new Point3D(0.5, 0.5, -0.5));
|
||||
side1Plane.Positions.Add(new Point3D(0.5, 0.5, -0.5));
|
||||
side1Plane.Positions.Add(new Point3D(0.5, -0.5, -0.5));
|
||||
side1Plane.Positions.Add(new Point3D(-0.5, -0.5, -0.5));
|
||||
|
||||
side1Plane.TriangleIndices.Add(0);
|
||||
side1Plane.TriangleIndices.Add(1);
|
||||
side1Plane.TriangleIndices.Add(2);
|
||||
side1Plane.TriangleIndices.Add(3);
|
||||
side1Plane.TriangleIndices.Add(4);
|
||||
side1Plane.TriangleIndices.Add(5);
|
||||
|
||||
side1Plane.Normals.Add(new Vector3D(0, 0, -1));
|
||||
side1Plane.Normals.Add(new Vector3D(0, 0, -1));
|
||||
side1Plane.Normals.Add(new Vector3D(0, 0, -1));
|
||||
side1Plane.Normals.Add(new Vector3D(0, 0, -1));
|
||||
side1Plane.Normals.Add(new Vector3D(0, 0, -1));
|
||||
side1Plane.Normals.Add(new Vector3D(0, 0, -1));
|
||||
|
||||
side1Plane.TextureCoordinates.Add(new Point(1, 0));
|
||||
side1Plane.TextureCoordinates.Add(new Point(1, 1));
|
||||
side1Plane.TextureCoordinates.Add(new Point(0, 1));
|
||||
side1Plane.TextureCoordinates.Add(new Point(0, 1));
|
||||
side1Plane.TextureCoordinates.Add(new Point(0, 0));
|
||||
side1Plane.TextureCoordinates.Add(new Point(1, 0));
|
||||
//</Snippet3DOverview3DN7>
|
||||
|
||||
//side2-------------------------------------------------
|
||||
side2Plane.Positions.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
side2Plane.Positions.Add(new Point3D(0.5, -0.5, 0.5));
|
||||
side2Plane.Positions.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
side2Plane.Positions.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
side2Plane.Positions.Add(new Point3D(-0.5, 0.5, 0.5));
|
||||
side2Plane.Positions.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
|
||||
side2Plane.TriangleIndices.Add(0);
|
||||
side2Plane.TriangleIndices.Add(1);
|
||||
side2Plane.TriangleIndices.Add(2);
|
||||
side2Plane.TriangleIndices.Add(3);
|
||||
side2Plane.TriangleIndices.Add(4);
|
||||
side2Plane.TriangleIndices.Add(5);
|
||||
|
||||
side2Plane.Normals.Add(new Vector3D(0, 0, 1));
|
||||
side2Plane.Normals.Add(new Vector3D(0, 0, 1));
|
||||
side2Plane.Normals.Add(new Vector3D(0, 0, 1));
|
||||
side2Plane.Normals.Add(new Vector3D(0, 0, 1));
|
||||
side2Plane.Normals.Add(new Vector3D(0, 0, 1));
|
||||
side2Plane.Normals.Add(new Vector3D(0, 0, 1));
|
||||
|
||||
side2Plane.TextureCoordinates.Add(new Point(0, 0));
|
||||
side2Plane.TextureCoordinates.Add(new Point(1, 0));
|
||||
side2Plane.TextureCoordinates.Add(new Point(1, 1));
|
||||
side2Plane.TextureCoordinates.Add(new Point(1, 1));
|
||||
side2Plane.TextureCoordinates.Add(new Point(0, 1));
|
||||
side2Plane.TextureCoordinates.Add(new Point(0, 0));
|
||||
|
||||
//side3-------------------------------------------------
|
||||
side3Plane.Positions.Add(new Point3D(-0.5, -0.5, -0.5));
|
||||
side3Plane.Positions.Add(new Point3D(0.5, -0.5, -0.5));
|
||||
side3Plane.Positions.Add(new Point3D(0.5, -0.5, 0.5));
|
||||
side3Plane.Positions.Add(new Point3D(0.5, -0.5, 0.5));
|
||||
side3Plane.Positions.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
side3Plane.Positions.Add(new Point3D(-0.5, -0.5, -0.5));
|
||||
|
||||
side3Plane.TriangleIndices.Add(0);
|
||||
side3Plane.TriangleIndices.Add(1);
|
||||
side3Plane.TriangleIndices.Add(2);
|
||||
side3Plane.TriangleIndices.Add(3);
|
||||
side3Plane.TriangleIndices.Add(4);
|
||||
side3Plane.TriangleIndices.Add(5);
|
||||
|
||||
side3Plane.Normals.Add(new Vector3D(0, -1, 0));
|
||||
side3Plane.Normals.Add(new Vector3D(0, -1, 0));
|
||||
side3Plane.Normals.Add(new Vector3D(0, -1, 0));
|
||||
side3Plane.Normals.Add(new Vector3D(0, -1, 0));
|
||||
side3Plane.Normals.Add(new Vector3D(0, -1, 0));
|
||||
side3Plane.Normals.Add(new Vector3D(0, -1, 0));
|
||||
|
||||
side3Plane.TextureCoordinates.Add(new Point(0, 0));
|
||||
side3Plane.TextureCoordinates.Add(new Point(1, 0));
|
||||
side3Plane.TextureCoordinates.Add(new Point(1, 1));
|
||||
side3Plane.TextureCoordinates.Add(new Point(1, 1));
|
||||
side3Plane.TextureCoordinates.Add(new Point(0, 1));
|
||||
side3Plane.TextureCoordinates.Add(new Point(0, 0));
|
||||
|
||||
//side4-------------------------------------------------
|
||||
side4Plane.Positions.Add(new Point3D(0.5, -0.5, -0.5));
|
||||
side4Plane.Positions.Add(new Point3D(0.5, 0.5, -0.5));
|
||||
side4Plane.Positions.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
side4Plane.Positions.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
side4Plane.Positions.Add(new Point3D(0.5, -0.5, 0.5));
|
||||
side4Plane.Positions.Add(new Point3D(0.5, -0.5, -0.5));
|
||||
|
||||
side4Plane.TriangleIndices.Add(0);
|
||||
side4Plane.TriangleIndices.Add(1);
|
||||
side4Plane.TriangleIndices.Add(2);
|
||||
side4Plane.TriangleIndices.Add(3);
|
||||
side4Plane.TriangleIndices.Add(4);
|
||||
side4Plane.TriangleIndices.Add(5);
|
||||
|
||||
side4Plane.Normals.Add(new Vector3D(1, 0, 0));
|
||||
side4Plane.Normals.Add(new Vector3D(1, 0, 0));
|
||||
side4Plane.Normals.Add(new Vector3D(1, 0, 0));
|
||||
side4Plane.Normals.Add(new Vector3D(1, 0, 0));
|
||||
side4Plane.Normals.Add(new Vector3D(1, 0, 0));
|
||||
side4Plane.Normals.Add(new Vector3D(1, 0, 0));
|
||||
|
||||
side4Plane.TextureCoordinates.Add(new Point(1, 0));
|
||||
side4Plane.TextureCoordinates.Add(new Point(1, 1));
|
||||
side4Plane.TextureCoordinates.Add(new Point(0, 1));
|
||||
side4Plane.TextureCoordinates.Add(new Point(0, 1));
|
||||
side4Plane.TextureCoordinates.Add(new Point(0, 0));
|
||||
side4Plane.TextureCoordinates.Add(new Point(1, 0));
|
||||
|
||||
//side5-------------------------------------------------
|
||||
side5Plane.Positions.Add(new Point3D(0.5, 0.5, -0.5));
|
||||
side5Plane.Positions.Add(new Point3D(-0.5, 0.5, -0.5));
|
||||
side5Plane.Positions.Add(new Point3D(-0.5, 0.5, 0.5));
|
||||
side5Plane.Positions.Add(new Point3D(-0.5, 0.5, 0.5));
|
||||
side5Plane.Positions.Add(new Point3D(0.5, 0.5, 0.5));
|
||||
side5Plane.Positions.Add(new Point3D(0.5, 0.5, -0.5));
|
||||
|
||||
side5Plane.TriangleIndices.Add(0);
|
||||
side5Plane.TriangleIndices.Add(1);
|
||||
side5Plane.TriangleIndices.Add(2);
|
||||
side5Plane.TriangleIndices.Add(3);
|
||||
side5Plane.TriangleIndices.Add(4);
|
||||
side5Plane.TriangleIndices.Add(5);
|
||||
|
||||
side5Plane.Normals.Add(new Vector3D(0, 1, 0));
|
||||
side5Plane.Normals.Add(new Vector3D(0, 1, 0));
|
||||
side5Plane.Normals.Add(new Vector3D(0, 1, 0));
|
||||
side5Plane.Normals.Add(new Vector3D(0, 1, 0));
|
||||
side5Plane.Normals.Add(new Vector3D(0, 1, 0));
|
||||
side5Plane.Normals.Add(new Vector3D(0, 1, 0));
|
||||
|
||||
side5Plane.TextureCoordinates.Add(new Point(1, 1));
|
||||
side5Plane.TextureCoordinates.Add(new Point(0, 1));
|
||||
side5Plane.TextureCoordinates.Add(new Point(0, 0));
|
||||
side5Plane.TextureCoordinates.Add(new Point(0, 0));
|
||||
side5Plane.TextureCoordinates.Add(new Point(1, 0));
|
||||
side5Plane.TextureCoordinates.Add(new Point(1, 1));
|
||||
|
||||
//side6-------------------------------------------------
|
||||
side6Plane.Positions.Add(new Point3D(-0.5, 0.5, -0.5));
|
||||
side6Plane.Positions.Add(new Point3D(-0.5, -0.5, -0.5));
|
||||
side6Plane.Positions.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
side6Plane.Positions.Add(new Point3D(-0.5, -0.5, 0.5));
|
||||
side6Plane.Positions.Add(new Point3D(-0.5, 0.5, 0.5));
|
||||
side6Plane.Positions.Add(new Point3D(-0.5, 0.5, -0.5));
|
||||
|
||||
side6Plane.TriangleIndices.Add(0);
|
||||
side6Plane.TriangleIndices.Add(1);
|
||||
side6Plane.TriangleIndices.Add(2);
|
||||
side6Plane.TriangleIndices.Add(3);
|
||||
side6Plane.TriangleIndices.Add(4);
|
||||
side6Plane.TriangleIndices.Add(5);
|
||||
|
||||
side6Plane.Normals.Add(new Vector3D(-1, 0, 0));
|
||||
side6Plane.Normals.Add(new Vector3D(-1, 0, 0));
|
||||
side6Plane.Normals.Add(new Vector3D(-1, 0, 0));
|
||||
side6Plane.Normals.Add(new Vector3D(-1, 0, 0));
|
||||
side6Plane.Normals.Add(new Vector3D(-1, 0, 0));
|
||||
side6Plane.Normals.Add(new Vector3D(-1, 0, 0));
|
||||
|
||||
side6Plane.TextureCoordinates.Add(new Point(0, 1));
|
||||
side6Plane.TextureCoordinates.Add(new Point(0, 0));
|
||||
side6Plane.TextureCoordinates.Add(new Point(1, 0));
|
||||
side6Plane.TextureCoordinates.Add(new Point(1, 0));
|
||||
side6Plane.TextureCoordinates.Add(new Point(1, 1));
|
||||
side6Plane.TextureCoordinates.Add(new Point(0, 1));
|
||||
|
||||
//Set Brush property for the Material applied to each face
|
||||
DiffuseMaterial side2Material = new DiffuseMaterial((Brush)Application.Current.Resources["yellowBrush"]);
|
||||
DiffuseMaterial side6Material = new DiffuseMaterial((Brush)Application.Current.Resources["orangeBrush"]);
|
||||
|
||||
//<Snippet_MIL3D_3DOverview_csharp_n1>
|
||||
//DiffuseMaterial side1Material = new DiffuseMaterial((Brush)Application.Current.Resources["gradientBrush"]);
|
||||
//</Snippet_MIL3D_3DOverview_csharp_n1>
|
||||
|
||||
DiffuseMaterial side1Material = new DiffuseMaterial((Brush)Application.Current.Resources["blueBrush"]);
|
||||
DiffuseMaterial side3Material = new DiffuseMaterial((Brush)Application.Current.Resources["redBrush"]);
|
||||
DiffuseMaterial side4Material = new DiffuseMaterial((Brush)Application.Current.Resources["cyanBrush"]);
|
||||
//DiffuseMaterial side5Material = new DiffuseMaterial((Brush)Application.Current.Resources["purpleBrush"]);
|
||||
//<Snippet3DOverview3DN8>
|
||||
DiffuseMaterial side5Material = new DiffuseMaterial((Brush)Application.Current.Resources["patternBrush"]);
|
||||
//</Snippet3DOverview3DN8>
|
||||
|
||||
side2.Material = side2Material;
|
||||
side6.Material = side6Material;
|
||||
side1.Material = side1Material;
|
||||
side3.Material = side3Material;
|
||||
side4.Material = side4Material;
|
||||
side5.Material = side5Material;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<Application x:Class="create_cube.app"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Startup="AppStartingUp"
|
||||
>
|
||||
<Application.Resources>
|
||||
|
||||
<SolidColorBrush x:Key="blueBrush" Color="Blue" Opacity="1.0" />
|
||||
<SolidColorBrush x:Key="orangeBrush" Color="Orange" Opacity="1.0" />
|
||||
<SolidColorBrush x:Key="yellowBrush" Color="Yellow" Opacity="1.0" />
|
||||
<SolidColorBrush x:Key="redBrush" Color="Red" Opacity="1.0" />
|
||||
<SolidColorBrush x:Key="purpleBrush" Color="Purple" Opacity="1.0" />
|
||||
<SolidColorBrush x:Key="cyanBrush" Color="Cyan" Opacity="1.0" />
|
||||
|
||||
<!--<Snippet3DOverview3DN9>-->
|
||||
<DrawingBrush x:Key="patternBrush" Viewport="0,0,0.1,0.1" TileMode="Tile">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Geometry="M0,0.1 L0.1,0 1,0.9, 0.9,1z"
|
||||
Brush="Gray" />
|
||||
<GeometryDrawing Geometry="M0.9,0 L1,0.1 0.1,1 0,0.9z"
|
||||
Brush="Gray" />
|
||||
<GeometryDrawing Geometry="M0.25,0.25 L0.5,0.125 0.75,0.25 0.5,0.5z"
|
||||
Brush="#FFFF00" />
|
||||
<GeometryDrawing Geometry="M0.25,0.75 L0.5,0.875 0.75,0.75 0.5,0.5z"
|
||||
Brush="Black" />
|
||||
<GeometryDrawing Geometry="M0.25,0.75 L0.125,0.5 0.25,0.25 0.5,0.5z"
|
||||
Brush="#FF0000" />
|
||||
<GeometryDrawing Geometry="M0.75,0.25 L0.875,0.5 0.75,0.75 0.5,0.5z"
|
||||
Brush="MediumBlue" />
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
<!--</Snippet3DOverview3DN9>-->
|
||||
|
||||
<!-- <Snippet_MIL3D_3DOverview_xaml_n1> -->
|
||||
<LinearGradientBrush x:Key="gradientBrush" SpreadMethod="Repeat">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStop Color="Green" Offset="0" />
|
||||
<GradientStop Color="Blue" Offset="1" />
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
<!-- </Snippet_MIL3D_3DOverview_xaml_n1> -->
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
|
||||
namespace create_cube
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for app.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class app : Application
|
||||
{
|
||||
void AppStartingUp(object sender, StartupEventArgs e)
|
||||
{
|
||||
Window1 mainWindow = new Window1();
|
||||
mainWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{80C83525-676F-4A42-AE1D-41B6FE3293F6}</ProjectGuid>
|
||||
<RootNamespace>create_cube</RootNamespace>
|
||||
<AssemblyName>create_cube</AssemblyName>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputType>winexe</OutputType>
|
||||
<ApplicationVersion>1.0.0.*</ApplicationVersion>
|
||||
<!-- Most people will use Publish dialog in Visual Studio to increment this -->
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>.\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="WindowsFormsIntegration" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="app.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Window1.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="app.xaml.cs">
|
||||
<DependentUpon>app.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Window1.xaml.cs" />
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1 @@
|
||||
wcpsamp_graphicsmm_3Dcubes_code
|
||||
@@ -0,0 +1,71 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{94FDF812-AE88-4310-AF76-73BC5610711B}</ProjectGuid>
|
||||
<RootNamespace>ADODataSetSample</RootNamespace>
|
||||
<AssemblyName>ADODataSetSample</AssemblyName>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputType>winexe</OutputType>
|
||||
<TargetType>$(OutputType)</TargetType>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<UICulture>en-US</UICulture>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>.\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<!-- Imports must come after all PropertyGroups and before ItemGroup -->
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="app.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Window1.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="app.xaml.cs" />
|
||||
<Compile Include="IntColorConverter.cs" />
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- To workaround a VisualStudio Beta1 problem -->
|
||||
<TemporaryHackCompile Include="$(BaseOutputPath)**\*$(GeneratedFileExtension)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
|
||||
copy BookData.mdb "%APPDATA%"
|
||||
|
||||
@echo Copied BookData.mdb sample database to "%APPDATA%"
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Data;
|
||||
using System.Globalization;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
public class IntColorConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
int numValue = (int)value;
|
||||
if (numValue < 350)
|
||||
return System.Windows.Media.Brushes.Green;
|
||||
else
|
||||
return System.Windows.Media.Brushes.Red;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
ADODataSetSample
|
||||
|
||||
Demonstrates filling a DataSet by connecting to an Access *.mdb file using
|
||||
ADO API in the Loaded event
|
||||
|
||||
To run:
|
||||
(1) Execute the CopyMDB.cmd. This copies the BookData.mdb to your
|
||||
"Application Data" folder, typically located at
|
||||
C:\Documents and Settings\YourAlias\Application Data/ADODataSetSample
|
||||
|
||||
(2) Using MSBUILD or from within Visual Studio build the sample using the
|
||||
csproj file and execute bin\debug\ADODataSetSample.exe
|
||||
@@ -0,0 +1,41 @@
|
||||
<Window x:Class="SDKSample.Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:c="clr-namespace:SDKSample"
|
||||
Title="ADODataSetSample"
|
||||
Loaded="OnInit"
|
||||
Background="White"
|
||||
Height="250"
|
||||
Width="450">
|
||||
|
||||
<StackPanel>
|
||||
<!-- <Snippet3> -->
|
||||
<StackPanel.Resources>
|
||||
<c:IntColorConverter x:Key="MyConverter"/>
|
||||
|
||||
<DataTemplate x:Key="BookItemTemplate">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="250" />
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Path=Title}" Grid.Column="0"
|
||||
FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding Path=ISBN}" Grid.Column="1" />
|
||||
<TextBlock Grid.Column="2" Text="{Binding Path=NumPages}"
|
||||
Background="{Binding Path=NumPages,
|
||||
Converter={StaticResource MyConverter}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</StackPanel.Resources>
|
||||
<!-- </Snippet3> -->
|
||||
|
||||
<!-- <Snippet2> -->
|
||||
<ListBox Name="myListBox" Height="200"
|
||||
ItemsSource="{Binding Path=BookTable}"
|
||||
ItemTemplate ="{StaticResource BookItemTemplate}"/>
|
||||
<!-- </Snippet2> -->
|
||||
<Button Click="OnClick">Add Record</Button>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
public Window1()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private string appPath;
|
||||
private string AppDataPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(appPath))
|
||||
{
|
||||
appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
}
|
||||
return appPath;
|
||||
}
|
||||
}
|
||||
|
||||
//<Snippet1>
|
||||
DataSet myDataSet;
|
||||
|
||||
private void OnInit(object sender, EventArgs e)
|
||||
{
|
||||
string mdbFile = Path.Combine(AppDataPath, "BookData.mdb");
|
||||
string connString = string.Format(
|
||||
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}", mdbFile);
|
||||
OleDbConnection conn = new OleDbConnection(connString);
|
||||
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM BookTable;", conn);
|
||||
|
||||
myDataSet = new DataSet();
|
||||
adapter.Fill(myDataSet, "BookTable");
|
||||
|
||||
// myListBox is a ListBox control.
|
||||
// Set the DataContext of the ListBox to myDataSet
|
||||
myListBox.DataContext = myDataSet;
|
||||
}
|
||||
//</Snippet1>
|
||||
|
||||
private void OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DataTable myDataTable = myDataSet.Tables["BookTable"];
|
||||
DataRow row = myDataTable.NewRow();
|
||||
|
||||
row["Title"] = "Microsoft C# Language Specifications";
|
||||
row["ISBN"] = "0-7356-1448-2";
|
||||
row["NumPages"] = 431;
|
||||
myDataTable.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
</configuration>
|
||||
@@ -0,0 +1,8 @@
|
||||
<Application x:Class="SDKSample.app"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Startup="AppStartingUp"
|
||||
>
|
||||
<Application.Resources>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for app.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class app : Application
|
||||
{
|
||||
void AppStartingUp(object sender, StartupEventArgs e)
|
||||
{
|
||||
Window1 mainWindow = new Window1();
|
||||
mainWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0F66248C-0E72-4C78-B6C1-6F1CDF0AAF36}</ProjectGuid>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<RootNamespace>AdornerForStrokes</RootNamespace>
|
||||
<AssemblyName>AdornerForStrokes</AssemblyName>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputType>winexe</OutputType>
|
||||
<MinFrameworkVersionRequired>3.0</MinFrameworkVersionRequired>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Web</InstallFrom>
|
||||
<UpdateEnabled>true</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationVersion>1.0.0.*</ApplicationVersion>
|
||||
<IsWebBootstrapper>true</IsWebBootstrapper>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<PublishUrl>Publish\</PublishUrl>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>.\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
<Reference Include="ReachFramework" />
|
||||
<Reference Include="System.Printing" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.IdentityModel" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml" />
|
||||
<Page Include="Window1.xaml" />
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="RotatingAdornerForStrokes.cs" />
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="AdornerForStrokes.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="Window1.xaml"
|
||||
>
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
|
||||
namespace AdornerForStrokes
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#region Using directives
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Resources;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AdornerForStrokes")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("MS")]
|
||||
[assembly: AssemblyProduct("AdornerForStrokes")]
|
||||
[assembly: AssemblyCopyright("Copyright @ MS 2006")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
@@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.42
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AdornerForStrokes.Properties
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Resources;
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the Strongly Typed Resource Builder
|
||||
// class via a tool like ResGen or Visual Studio.NET.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
class Resources
|
||||
{
|
||||
|
||||
private static System.Resources.ResourceManager _resMgr;
|
||||
|
||||
private static System.Globalization.CultureInfo _resCulture;
|
||||
|
||||
/*FamANDAssem*/
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((_resMgr == null))
|
||||
{
|
||||
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Resources", typeof(Resources).Assembly);
|
||||
_resMgr = temp;
|
||||
}
|
||||
return _resMgr;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return _resCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
_resCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,42 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.42
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AdornerForStrokes.Properties
|
||||
{
|
||||
public partial class Settings : System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
private static Settings m_Value;
|
||||
|
||||
private static object m_SyncObject = new object();
|
||||
|
||||
public static Settings Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((Settings.m_Value == null))
|
||||
{
|
||||
System.Threading.Monitor.Enter(Settings.m_SyncObject);
|
||||
if ((Settings.m_Value == null))
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.m_Value = new Settings();
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Threading.Monitor.Exit(Settings.m_SyncObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Settings.m_Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,197 @@
|
||||
//<Snippet1>
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Ink;
|
||||
|
||||
public class RotatingStrokesAdorner : Adorner
|
||||
{
|
||||
// The Thumb to drag to rotate the strokes.
|
||||
Thumb rotateHandle;
|
||||
|
||||
// The surrounding boarder.
|
||||
Path outline;
|
||||
|
||||
VisualCollection visualChildren;
|
||||
|
||||
// The center of the strokes.
|
||||
Point center;
|
||||
double lastAngle;
|
||||
|
||||
RotateTransform rotation;
|
||||
|
||||
const int HANDLEMARGIN = 10;
|
||||
|
||||
// The bounds of the Strokes;
|
||||
Rect strokeBounds = Rect.Empty;
|
||||
|
||||
public RotatingStrokesAdorner(UIElement adornedElement)
|
||||
: base(adornedElement)
|
||||
{
|
||||
|
||||
visualChildren = new VisualCollection(this);
|
||||
rotateHandle = new Thumb();
|
||||
rotateHandle.Cursor = Cursors.SizeNWSE;
|
||||
rotateHandle.Width = 20;
|
||||
rotateHandle.Height = 20;
|
||||
rotateHandle.Background = Brushes.Blue;
|
||||
|
||||
rotateHandle.DragDelta += new DragDeltaEventHandler(rotateHandle_DragDelta);
|
||||
rotateHandle.DragCompleted += new DragCompletedEventHandler(rotateHandle_DragCompleted);
|
||||
|
||||
outline = new Path();
|
||||
outline.Stroke = Brushes.Blue;
|
||||
outline.StrokeThickness = 1;
|
||||
|
||||
visualChildren.Add(outline);
|
||||
visualChildren.Add(rotateHandle);
|
||||
|
||||
strokeBounds = AdornedStrokes.GetBounds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw the rotation handle and the outline of
|
||||
/// the element.
|
||||
/// </summary>
|
||||
/// <param name="finalSize">The final area within the
|
||||
/// parent that this element should use to arrange
|
||||
/// itself and its children.</param>
|
||||
/// <returns>The actual size used. </returns>
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
if (strokeBounds.IsEmpty)
|
||||
{
|
||||
return finalSize;
|
||||
}
|
||||
|
||||
center = new Point(strokeBounds.X + strokeBounds.Width / 2,
|
||||
strokeBounds.Y + strokeBounds.Height / 2);
|
||||
|
||||
// The rectangle that determines the position of the Thumb.
|
||||
Rect handleRect = new Rect(strokeBounds.X,
|
||||
strokeBounds.Y - (strokeBounds.Height / 2 +
|
||||
HANDLEMARGIN),
|
||||
strokeBounds.Width, strokeBounds.Height);
|
||||
|
||||
if (rotation != null)
|
||||
{
|
||||
handleRect.Transform(rotation.Value);
|
||||
}
|
||||
|
||||
// Draws the thumb and the rectangle around the strokes.
|
||||
rotateHandle.Arrange(handleRect);
|
||||
outline.Data = new RectangleGeometry(strokeBounds);
|
||||
outline.Arrange(new Rect(finalSize));
|
||||
return finalSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rotates the rectangle representing the
|
||||
/// strokes' bounds as the user drags the
|
||||
/// Thumb.
|
||||
/// </summary>
|
||||
void rotateHandle_DragDelta(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
// Find the angle of which to rotate the shape. Use the right
|
||||
// triangle that uses the center and the mouse's position
|
||||
// as vertices for the hypotenuse.
|
||||
|
||||
Point pos = Mouse.GetPosition(this);
|
||||
|
||||
double deltaX = pos.X - center.X;
|
||||
double deltaY = pos.Y - center.Y;
|
||||
|
||||
if (deltaY.Equals(0))
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
double tan = deltaX / deltaY;
|
||||
double angle = Math.Atan(tan);
|
||||
|
||||
// Convert to degrees.
|
||||
angle = angle * 180 / Math.PI;
|
||||
|
||||
// If the mouse crosses the vertical center,
|
||||
// find the complementary angle.
|
||||
if (deltaY > 0)
|
||||
{
|
||||
angle = 180 - Math.Abs(angle);
|
||||
}
|
||||
|
||||
// Rotate left if the mouse moves left and right
|
||||
// if the mouse moves right.
|
||||
if (deltaX < 0)
|
||||
{
|
||||
angle = -Math.Abs(angle);
|
||||
}
|
||||
else
|
||||
{
|
||||
angle = Math.Abs(angle);
|
||||
}
|
||||
|
||||
if (Double.IsNaN(angle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply the rotation to the strokes' outline.
|
||||
rotation = new RotateTransform(angle, center.X, center.Y);
|
||||
outline.RenderTransform = rotation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rotates the strokes to the same angle as outline.
|
||||
/// </summary>
|
||||
void rotateHandle_DragCompleted(object sender,
|
||||
DragCompletedEventArgs e)
|
||||
{
|
||||
if (rotation == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Rotate the strokes to match the new angle.
|
||||
Matrix mat = new Matrix();
|
||||
mat.RotateAt(rotation.Angle - lastAngle, center.X, center.Y);
|
||||
AdornedStrokes.Transform(mat, true);
|
||||
|
||||
// Save the angle of the last rotation.
|
||||
lastAngle = rotation.Angle;
|
||||
|
||||
// Redraw rotateHandle.
|
||||
this.InvalidateArrange();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strokes of the adorned element
|
||||
/// (in this case, an InkPresenter).
|
||||
/// </summary>
|
||||
private StrokeCollection AdornedStrokes
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((InkPresenter)AdornedElement).Strokes;
|
||||
}
|
||||
}
|
||||
|
||||
// Override the VisualChildrenCount and
|
||||
// GetVisualChild properties to interface with
|
||||
// the adorner's visual collection.
|
||||
protected override int VisualChildrenCount
|
||||
{
|
||||
get { return visualChildren.Count; }
|
||||
}
|
||||
|
||||
protected override Visual GetVisualChild(int index)
|
||||
{
|
||||
return visualChildren[index];
|
||||
}
|
||||
}
|
||||
//</Snippet1>
|
||||
@@ -0,0 +1,22 @@
|
||||
<!--<Snippet2>-->
|
||||
<Window x:Class="Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Rotating Strokes Adorner" Height="500" Width="500"
|
||||
Loaded="Window_Loaded"
|
||||
>
|
||||
<InkPresenter Name="inkPresenter1" >
|
||||
<InkPresenter.Strokes>
|
||||
ALMDAwRIEEU1BQE4GSAyCQD0/wIB6SI6RTMJAPifAgFaIDpFOAgA/gMAAACAfxEAAIA/
|
||||
HwkRAAAAAAAA8D8KlwE1h/CPd4SB4NA4OicCjcGjcClcDj8Lh8DgUSkUmmU6nUmoUuk
|
||||
0ukUCQKVyehz+rzuly+bzORx+BReRQ+RTaRCH8JyXhPbgcPicPh8Pg8Oh0qk1SoVGrV
|
||||
Oo0mi0Xi8rm9Xr9Dqc/p87pc/k8XicHicOj1CoVKtVmv1GqUaiUHlYg8el4akXK7m7T
|
||||
cSJgQgghEyym5zx6+PACk4dhPwg/fhCbxY8dp4p2tqnqxyvbPO85z1X1aswhvCd94Tq
|
||||
55DRUGi4+Tk6OLn4KLkoOejo6ig5KTioOPCD9LlHmrzNxMRCCc3ec8+fe4AKQBmE/Cw
|
||||
9+FkPNvlOdkrYsWa+acp3Z8erOIT8JaX4S6+FbFilbHNvvPXNJbFqluxghKc5DkwrVF
|
||||
GEEIJ1w5eLKYAKShuF+Dnr4Oa8HVHXNPFFFFho8VFkqsMRYuuvJxiF+F9r4Xx8HFiqs
|
||||
FNcirnweDw9+LvvvixdV0+GhONmlj3wjNOcSCEYTnfLy4oA
|
||||
</InkPresenter.Strokes>
|
||||
</InkPresenter>
|
||||
</Window>
|
||||
<!--</Snippet2>-->
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Ink;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
RotatingStrokesAdorner adorner;
|
||||
AdornerLayer adornerLayer;
|
||||
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
//<Snippet3>
|
||||
void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Add the rotating strokes adorner to the InkPresenter.
|
||||
adornerLayer = AdornerLayer.GetAdornerLayer(inkPresenter1);
|
||||
adorner = new RotatingStrokesAdorner(inkPresenter1);
|
||||
|
||||
adornerLayer.Add(adorner);
|
||||
}
|
||||
//</Snippet3>
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{EBD6662E-7DCC-439C-872A-5C9846264604}</ProjectGuid>
|
||||
<RootNamespace>AdornersMiscCode</RootNamespace>
|
||||
<AssemblyName>AdornersMiscCode</AssemblyName>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputType>winexe</OutputType>
|
||||
<ApplicationVersion>1.0.0.*</ApplicationVersion>
|
||||
<!-- Most people will use Publish dialog in Visual Studio to increment this -->
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>.\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="MyApp.xaml">
|
||||
<SubType>
|
||||
</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Window1.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="MyApp.xaml.cs">
|
||||
<DependentUpon>MyApp.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="AdornersMiscCode.MyApp"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Startup="AppStartup"
|
||||
>
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
|
||||
namespace AdornersMiscCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MyApp.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class MyApp : Application
|
||||
{
|
||||
|
||||
void AppStartup(object sender, StartupEventArgs args)
|
||||
{
|
||||
Window1 mainWindow = new Window1();
|
||||
mainWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<Window x:Class="AdornersMiscCode.Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="AdornersMiscCode" Loaded="WindowLoaded"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBox
|
||||
Name="myTextBox"
|
||||
Height="50" Width="150"
|
||||
Grid.Row="0"
|
||||
Text="My adorned TextBox."
|
||||
/>
|
||||
<StackPanel Name="myStackPanel" Grid.Row="1">
|
||||
<Button
|
||||
Width="150"
|
||||
Content="My adorned button."
|
||||
/>
|
||||
<Button
|
||||
Width="150"
|
||||
Content="My other adorned button."
|
||||
/>
|
||||
</StackPanel>
|
||||
<AdornerDecorator Name="myAD" Grid.Row="2">
|
||||
<StackPanel Grid.Row="2">
|
||||
<Button
|
||||
Width="150"
|
||||
Content="My adorned button."
|
||||
/>
|
||||
<Button
|
||||
Width="150"
|
||||
Content="My other adorned button."
|
||||
/>
|
||||
</StackPanel>
|
||||
</AdornerDecorator>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace AdornersMiscCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
AdornerLayer myAdornerLayer;
|
||||
|
||||
private void WindowLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
{
|
||||
myAdornerLayer = AdornerLayer.GetAdornerLayer(myTextBox);
|
||||
// myAdornerLayer.Add(new SimpleCircleAdorner(myTextBox));
|
||||
|
||||
// <Snippet_RemoveSpecificAdornerLong>
|
||||
Adorner[] toRemoveArray = myAdornerLayer.GetAdorners(myTextBox);
|
||||
Adorner toRemove;
|
||||
if (toRemoveArray != null)
|
||||
{
|
||||
toRemove = toRemoveArray[0];
|
||||
myAdornerLayer.Remove(toRemove);
|
||||
}
|
||||
// </Snippet_RemoveSpecificAdornerLong>
|
||||
|
||||
// <Snippet_RemoveSpecificAdornerShort>
|
||||
try { myAdornerLayer.Remove((myAdornerLayer.GetAdorners(myTextBox))[0]); } catch { }
|
||||
// </Snippet_RemoveSpecificAdornerShort>
|
||||
}
|
||||
{
|
||||
foreach (UIElement toAdorn in myStackPanel.Children)
|
||||
myAdornerLayer.Add(new SimpleCircleAdorner(toAdorn));
|
||||
|
||||
// <Snippet_RemoveAllAdornersLong>
|
||||
Adorner[] toRemoveArray = myAdornerLayer.GetAdorners(myTextBox);
|
||||
if (toRemoveArray != null)
|
||||
{
|
||||
for (int x = 0; x < toRemoveArray.Length; x++)
|
||||
{
|
||||
myAdornerLayer.Remove(toRemoveArray[x]);
|
||||
}
|
||||
}
|
||||
// </Snippet_RemoveAllAdornersLong>
|
||||
|
||||
// <Snippet_RemoveAllAdornersShort>
|
||||
try { foreach (Adorner toRemove in myAdornerLayer.GetAdorners(myTextBox)) myAdornerLayer.Remove(toRemove); } catch { }
|
||||
// </Snippet_RemoveAllAdornersShort>
|
||||
}
|
||||
}
|
||||
|
||||
// Sample event handler:
|
||||
// private void ButtonClick(object sender, RoutedEventArgs e) {}
|
||||
|
||||
// Adorners must subclass the abstract base class Adorner.
|
||||
public class SimpleCircleAdorner : Adorner
|
||||
{
|
||||
// Be sure to call the base class constructor.
|
||||
public SimpleCircleAdorner(UIElement adornedElement)
|
||||
: base(adornedElement)
|
||||
{
|
||||
// Any constructor implementation...
|
||||
}
|
||||
|
||||
// A common way to implement an adorner's rendering behavior is to override the OnRender
|
||||
// method, which is called by the layout subsystem as part of a rendering pass.
|
||||
//<SnippetUIElementDesiredSize>
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
// Get a rectangle that represents the desired size of the rendered element
|
||||
// after the rendering pass. This will be used to draw at the corners of the
|
||||
// adorned element.
|
||||
Rect adornedElementRect = new Rect(this.AdornedElement.RenderSize);
|
||||
|
||||
// Some arbitrary drawing implements.
|
||||
SolidColorBrush renderBrush = new SolidColorBrush(Colors.Green);
|
||||
renderBrush.Opacity = 0.2;
|
||||
Pen renderPen = new Pen(new SolidColorBrush(Colors.Navy), 1.5);
|
||||
double renderRadius = 5.0;
|
||||
|
||||
// Just draw a circle at each corner.
|
||||
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopLeft, renderRadius, renderRadius);
|
||||
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopRight, renderRadius, renderRadius);
|
||||
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomLeft, renderRadius, renderRadius);
|
||||
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomRight, renderRadius, renderRadius);
|
||||
}
|
||||
//</SnippetUIElementDesiredSize>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
wcsdk_edocs_editing_adorners_simplecircleadorner_sample
|
||||
@@ -0,0 +1,46 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<AssemblyName>SDKSample</AssemblyName>
|
||||
<OutputType>winexe</OutputType>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<ProjectGuid>{B6865F44-5F76-427E-B819-4EF235F129D3}</ProjectGuid>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="app.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Window1.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,31 @@
|
||||
<Window x:Class="SDKSample.Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="SimpleAdorner" Loaded="WindowLoaded" Height="400" Width="600"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<!-- An arbitrary UIElement to adorn, with arbitrary characteristics. -->
|
||||
<TextBox
|
||||
Name="myTextBox"
|
||||
Height="50" Width="150"
|
||||
Grid.Row="0"
|
||||
Text="My adorned TextBox."
|
||||
/>
|
||||
<StackPanel Name="myStackPanel" Grid.Row="1">
|
||||
<Button
|
||||
Name="myButton1"
|
||||
Width="150"
|
||||
Content="My adorned button."
|
||||
/>
|
||||
<Button
|
||||
Name="myButton2"
|
||||
Width="150"
|
||||
Content="My other adorned button."
|
||||
/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using System.Collections;
|
||||
|
||||
namespace SDKSample
|
||||
{
|
||||
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
AdornerLayer myAdornerLayer;
|
||||
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void WindowLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//<Snippet_AdornSingleElement>
|
||||
myAdornerLayer = AdornerLayer.GetAdornerLayer(myTextBox);
|
||||
myAdornerLayer.Add(new SimpleCircleAdorner(myTextBox));
|
||||
//</Snippet_AdornSingleElement>
|
||||
|
||||
//<Snippet_AdornChildren>
|
||||
foreach (UIElement toAdorn in myStackPanel.Children)
|
||||
myAdornerLayer.Add(new SimpleCircleAdorner(toAdorn));
|
||||
//</Snippet_AdornChildren>
|
||||
}
|
||||
|
||||
// Sample event handler:
|
||||
// private void ButtonClick(object sender, RoutedEventArgs e) {}
|
||||
|
||||
//<Snippet_SimpleCircleAdornerBody>
|
||||
// Adorners must subclass the abstract base class Adorner.
|
||||
public class SimpleCircleAdorner : Adorner
|
||||
{
|
||||
// Be sure to call the base class constructor.
|
||||
public SimpleCircleAdorner(UIElement adornedElement)
|
||||
: base(adornedElement)
|
||||
{
|
||||
}
|
||||
|
||||
// A common way to implement an adorner's rendering behavior is to override the OnRender
|
||||
// method, which is called by the layout system as part of a rendering pass.
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);
|
||||
|
||||
// Some arbitrary drawing implements.
|
||||
SolidColorBrush renderBrush = new SolidColorBrush(Colors.Green);
|
||||
renderBrush.Opacity = 0.2;
|
||||
Pen renderPen = new Pen(new SolidColorBrush(Colors.Navy), 1.5);
|
||||
double renderRadius = 5.0;
|
||||
|
||||
// Draw a circle at each corner.
|
||||
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopLeft, renderRadius, renderRadius);
|
||||
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopRight, renderRadius, renderRadius);
|
||||
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomLeft, renderRadius, renderRadius);
|
||||
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomRight, renderRadius, renderRadius);
|
||||
}
|
||||
}
|
||||
//</Snippet_SimpleCircleAdornerBody>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<Application
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="window1.xaml"/>
|
||||
@@ -0,0 +1,86 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{355F32A3-E070-4609-AEF0-3259A2141EB4}</ProjectGuid>
|
||||
<RootNamespace>AdavancedInkTopicsSamples</RootNamespace>
|
||||
<AssemblyName>ImageRenderingInkCanvas</AssemblyName>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputType>winexe</OutputType>
|
||||
<ApplicationVersion>1.0.0.*</ApplicationVersion>
|
||||
<!-- Most people will use Publish dialog in Visual Studio to increment this -->
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>.\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
<Reference Include="ReachFramework" />
|
||||
<Reference Include="System.Printing" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security.Authorization" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="MyApp.xaml" />
|
||||
<Page Include="Window1.xaml" />
|
||||
<Compile Include="MyApp.xaml.cs">
|
||||
<DependentUpon>MyApp.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DynamicRenderer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="StylusControl.cs" />
|
||||
<Compile Include="StylusControlSnippets.cs" />
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,162 @@
|
||||
//<Snippet19>
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
using System.Windows;
|
||||
using System.Windows.Input.StylusPlugIns;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Ink;
|
||||
//</Snippet19>
|
||||
|
||||
namespace AdavancedInkTopicsSamples
|
||||
{
|
||||
//<Snippet1>
|
||||
// A StylusPlugin that renders ink with a linear gradient brush effect.
|
||||
class CustomDynamicRenderer : DynamicRenderer
|
||||
{
|
||||
[ThreadStatic]
|
||||
static private Brush brush = null;
|
||||
|
||||
[ThreadStatic]
|
||||
static private Pen pen = null;
|
||||
|
||||
private Point prevPoint;
|
||||
|
||||
protected override void OnStylusDown(RawStylusInput rawStylusInput)
|
||||
{
|
||||
// Allocate memory to store the previous point to draw from.
|
||||
prevPoint = new Point(double.NegativeInfinity, double.NegativeInfinity);
|
||||
base.OnStylusDown(rawStylusInput);
|
||||
}
|
||||
|
||||
protected override void OnDraw(DrawingContext drawingContext,
|
||||
StylusPointCollection stylusPoints,
|
||||
Geometry geometry, Brush fillBrush)
|
||||
{
|
||||
// Create a new Brush, if necessary.
|
||||
brush ??= new LinearGradientBrush(Colors.Red, Colors.Blue, 20d);
|
||||
|
||||
// Create a new Pen, if necessary.
|
||||
pen ??= new Pen(brush, 2d);
|
||||
|
||||
// Draw linear gradient ellipses between
|
||||
// all the StylusPoints that have come in.
|
||||
for (int i = 0; i < stylusPoints.Count; i++)
|
||||
{
|
||||
Point pt = (Point)stylusPoints[i];
|
||||
Vector v = Point.Subtract(prevPoint, pt);
|
||||
|
||||
// Only draw if we are at least 4 units away
|
||||
// from the end of the last ellipse. Otherwise,
|
||||
// we're just redrawing and wasting cycles.
|
||||
if (v.Length > 4)
|
||||
{
|
||||
// Set the thickness of the stroke based
|
||||
// on how hard the user pressed.
|
||||
double radius = stylusPoints[i].PressureFactor * 10d;
|
||||
drawingContext.DrawEllipse(brush, pen, pt, radius, radius);
|
||||
prevPoint = pt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//</Snippet1>
|
||||
|
||||
//<Snippet2>
|
||||
// A class for rendering custom strokes
|
||||
class CustomStroke : Stroke
|
||||
{
|
||||
Brush brush;
|
||||
Pen pen;
|
||||
|
||||
public CustomStroke(StylusPointCollection stylusPoints)
|
||||
: base(stylusPoints)
|
||||
{
|
||||
// Create the Brush and Pen used for drawing.
|
||||
brush = new LinearGradientBrush(Colors.Red, Colors.Blue, 20d);
|
||||
pen = new Pen(brush, 2d);
|
||||
}
|
||||
|
||||
protected override void DrawCore(DrawingContext drawingContext,
|
||||
DrawingAttributes drawingAttributes)
|
||||
{
|
||||
// Allocate memory to store the previous point to draw from.
|
||||
Point prevPoint = new Point(double.NegativeInfinity,
|
||||
double.NegativeInfinity);
|
||||
|
||||
// Draw linear gradient ellipses between
|
||||
// all the StylusPoints in the Stroke.
|
||||
for (int i = 0; i < this.StylusPoints.Count; i++)
|
||||
{
|
||||
Point pt = (Point)this.StylusPoints[i];
|
||||
Vector v = Point.Subtract(prevPoint, pt);
|
||||
|
||||
// Only draw if we are at least 4 units away
|
||||
// from the end of the last ellipse. Otherwise,
|
||||
// we're just redrawing and wasting cycles.
|
||||
if (v.Length > 4)
|
||||
{
|
||||
// Set the thickness of the stroke
|
||||
// based on how hard the user pressed.
|
||||
double radius = this.StylusPoints[i].PressureFactor * 10d;
|
||||
drawingContext.DrawEllipse(brush, pen, pt, radius, radius);
|
||||
prevPoint = pt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//</Snippet2>
|
||||
|
||||
//<Snippet3>
|
||||
// A StylusPlugin that restricts the input area.
|
||||
class FilterPlugin : StylusPlugIn
|
||||
{
|
||||
protected override void OnStylusDown(RawStylusInput rawStylusInput)
|
||||
{
|
||||
// Call the base class before modifying the data.
|
||||
base.OnStylusDown(rawStylusInput);
|
||||
|
||||
// Restrict the stylus input.
|
||||
Filter(rawStylusInput);
|
||||
}
|
||||
|
||||
protected override void OnStylusMove(RawStylusInput rawStylusInput)
|
||||
{
|
||||
// Call the base class before modifying the data.
|
||||
base.OnStylusMove(rawStylusInput);
|
||||
|
||||
// Restrict the stylus input.
|
||||
Filter(rawStylusInput);
|
||||
}
|
||||
|
||||
protected override void OnStylusUp(RawStylusInput rawStylusInput)
|
||||
{
|
||||
// Call the base class before modifying the data.
|
||||
base.OnStylusUp(rawStylusInput);
|
||||
|
||||
// Restrict the stylus input
|
||||
Filter(rawStylusInput);
|
||||
}
|
||||
|
||||
private void Filter(RawStylusInput rawStylusInput)
|
||||
{
|
||||
// Get the StylusPoints that have come in.
|
||||
StylusPointCollection stylusPoints = rawStylusInput.GetStylusPoints();
|
||||
|
||||
// Modify the (X,Y) data to move the points
|
||||
// inside the acceptable input area, if necessary.
|
||||
for (int i = 0; i < stylusPoints.Count; i++)
|
||||
{
|
||||
StylusPoint sp = stylusPoints[i];
|
||||
if (sp.X < 50) sp.X = 50;
|
||||
if (sp.X > 250) sp.X = 250;
|
||||
if (sp.Y < 50) sp.Y = 50;
|
||||
if (sp.Y > 250) sp.Y = 250;
|
||||
stylusPoints[i] = sp;
|
||||
}
|
||||
|
||||
// Copy the modified StylusPoints back to the RawStylusInput.
|
||||
rawStylusInput.SetStylusPoints(stylusPoints);
|
||||
}
|
||||
}
|
||||
//</Snippet3>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<Application x:Class="AdavancedInkTopicsSamples.MyApp"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Startup="AppStartup" >
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
|
||||
namespace AdavancedInkTopicsSamples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MyApp.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class MyApp : Application
|
||||
{
|
||||
//public MyApp()
|
||||
// : base()
|
||||
//{
|
||||
// Window1 win = new Window1();
|
||||
// win.Show();
|
||||
//}
|
||||
|
||||
void AppStartup(object sender, StartupEventArgs args)
|
||||
{
|
||||
Window1 mainWindow = new Window1();
|
||||
mainWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#region Using directives
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Resources;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ImageRenderingInkCanvas")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("MS")]
|
||||
[assembly: AssemblyProduct("ImageRenderingInkCanvas")]
|
||||
[assembly: AssemblyCopyright("Copyright @ MS 2005")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.42
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AdavancedInkTopicsSamples.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AdavancedInkTopicsSamples.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.42
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AdavancedInkTopicsSamples.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,178 @@
|
||||
//<Snippet20>
|
||||
using System;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Input.StylusPlugIns;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
//</Snippet20>
|
||||
|
||||
namespace AdavancedInkTopicsSamples
|
||||
{
|
||||
//<Snippet6>
|
||||
// A control for managing ink input
|
||||
class InkControl : Label
|
||||
{
|
||||
InkPresenter ip;
|
||||
DynamicRenderer dr;
|
||||
|
||||
// The StylusPointsCollection that gathers points
|
||||
// before Stroke from is created.
|
||||
StylusPointCollection stylusPoints = null;
|
||||
|
||||
public InkControl()
|
||||
{
|
||||
// Add an InkPresenter for drawing.
|
||||
ip = new InkPresenter();
|
||||
this.Content = ip;
|
||||
|
||||
// Add a dynamic renderer that
|
||||
// draws ink as it "flows" from the stylus.
|
||||
dr = new DynamicRenderer();
|
||||
ip.AttachVisuals(dr.RootVisual, dr.DrawingAttributes);
|
||||
this.StylusPlugIns.Add(dr);
|
||||
}
|
||||
|
||||
static InkControl()
|
||||
{
|
||||
// Allow ink to be drawn only within the bounds of the control.
|
||||
Type owner = typeof(InkControl);
|
||||
ClipToBoundsProperty.OverrideMetadata(owner,
|
||||
new FrameworkPropertyMetadata(true));
|
||||
}
|
||||
|
||||
//<Snippet7>
|
||||
protected override void OnStylusDown(StylusDownEventArgs e)
|
||||
{
|
||||
// Capture the stylus so all stylus input is routed to this control.
|
||||
Stylus.Capture(this);
|
||||
|
||||
// Allocate memory for the StylusPointsCollection and
|
||||
// add the StylusPoints that have come in so far.
|
||||
stylusPoints = new StylusPointCollection();
|
||||
StylusPointCollection eventPoints =
|
||||
e.GetStylusPoints(this, stylusPoints.Description);
|
||||
|
||||
stylusPoints.Add(eventPoints);
|
||||
}
|
||||
//</Snippet7>
|
||||
|
||||
//<Snippet8>
|
||||
protected override void OnStylusMove(StylusEventArgs e)
|
||||
{
|
||||
if (stylusPoints == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the StylusPoints that have come in since the
|
||||
// last call to OnStylusMove.
|
||||
StylusPointCollection newStylusPoints =
|
||||
e.GetStylusPoints(this, stylusPoints.Description);
|
||||
stylusPoints.Add(newStylusPoints);
|
||||
}
|
||||
//</Snippet8>
|
||||
|
||||
//<Snippet10>
|
||||
protected override void OnStylusUp(StylusEventArgs e)
|
||||
{
|
||||
if (stylusPoints == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the StylusPoints that have come in since the
|
||||
// last call to OnStylusMove.
|
||||
StylusPointCollection newStylusPoints =
|
||||
e.GetStylusPoints(this, stylusPoints.Description);
|
||||
stylusPoints.Add(newStylusPoints);
|
||||
|
||||
// Create a new stroke from all the StylusPoints since OnStylusDown.
|
||||
Stroke stroke = new Stroke(stylusPoints);
|
||||
|
||||
// Add the new stroke to the Strokes collection of the InkPresenter.
|
||||
ip.Strokes.Add(stroke);
|
||||
|
||||
// Clear the StylusPointsCollection.
|
||||
stylusPoints = null;
|
||||
|
||||
// Release stylus capture.
|
||||
Stylus.Capture(null);
|
||||
}
|
||||
//</Snippet10>
|
||||
|
||||
//<Snippet11>
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
base.OnMouseLeftButtonDown(e);
|
||||
|
||||
// If a stylus generated this event, return.
|
||||
if (e.StylusDevice != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Start collecting the points.
|
||||
stylusPoints = new StylusPointCollection();
|
||||
Point pt = e.GetPosition(this);
|
||||
stylusPoints.Add(new StylusPoint(pt.X, pt.Y));
|
||||
}
|
||||
//</Snippet11>
|
||||
|
||||
//<Snippet12>
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
|
||||
base.OnMouseMove(e);
|
||||
|
||||
// If a stylus generated this event, return.
|
||||
if (e.StylusDevice != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't collect points unless the left mouse button
|
||||
// is down.
|
||||
if (e.LeftButton == MouseButtonState.Released ||
|
||||
stylusPoints == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Point pt = e.GetPosition(this);
|
||||
stylusPoints.Add(new StylusPoint(pt.X, pt.Y));
|
||||
}
|
||||
//</Snippet12>
|
||||
|
||||
//<Snippet13>
|
||||
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
base.OnMouseLeftButtonUp(e);
|
||||
|
||||
// If a stylus generated this event, return.
|
||||
if (e.StylusDevice != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (stylusPoints == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Point pt = e.GetPosition(this);
|
||||
stylusPoints.Add(new StylusPoint(pt.X, pt.Y));
|
||||
|
||||
// Create a stroke and add it to the InkPresenter.
|
||||
Stroke stroke = new Stroke(stylusPoints);
|
||||
stroke.DrawingAttributes = dr.DrawingAttributes;
|
||||
ip.Strokes.Add(stroke);
|
||||
|
||||
stylusPoints = null;
|
||||
}
|
||||
//</Snippet13>
|
||||
}
|
||||
//</Snippet6>
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Input.StylusPlugIns;
|
||||
|
||||
namespace StylusControlSnippets
|
||||
{
|
||||
//<Snippet14>
|
||||
class InkControl : Label
|
||||
{
|
||||
//</Snippet14>
|
||||
|
||||
DynamicRenderer dr;
|
||||
|
||||
InkPresenter ip;
|
||||
|
||||
//<Snippet17>
|
||||
public InkControl()
|
||||
{
|
||||
//</Snippet17>
|
||||
|
||||
// Add an InkPresenter for drawing.
|
||||
ip = new InkPresenter();
|
||||
this.Content = ip;
|
||||
|
||||
//<Snippet18>
|
||||
// Add a dynamic renderer that
|
||||
// draws ink as it "flows" from the stylus.
|
||||
dr = new DynamicRenderer();
|
||||
ip.AttachVisuals(dr.RootVisual, dr.DrawingAttributes);
|
||||
this.StylusPlugIns.Add(dr);
|
||||
}
|
||||
//</Snippet18>
|
||||
//<Snippet15>
|
||||
}
|
||||
//</Snippet15>
|
||||
}
|
||||
|
||||
namespace snippets2
|
||||
{
|
||||
class InkControl : Label
|
||||
{
|
||||
//<Snippet16>
|
||||
InkPresenter ip;
|
||||
|
||||
public InkControl()
|
||||
{
|
||||
// Add an InkPresenter for drawing.
|
||||
ip = new InkPresenter();
|
||||
this.Content = ip;
|
||||
}
|
||||
//</Snippet16>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<Window x:Class="AdavancedInkTopicsSamples.Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="ImageRenderingInkCanvas"
|
||||
>
|
||||
<DockPanel Name="root">
|
||||
<StackPanel>
|
||||
<Button Name="ClearStrokes"></Button>
|
||||
</StackPanel>
|
||||
<!--<InkCanvas Name="ic2"></InkCanvas>-->
|
||||
</DockPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input.StylusPlugIns;
|
||||
|
||||
namespace AdavancedInkTopicsSamples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
CustomRenderingInkCanvas customInkCanvas;
|
||||
InkCanvas ic;
|
||||
FilterInkCanvas filterInkCanvas;
|
||||
TextBox textbox1;
|
||||
InkControl control;
|
||||
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
//customInkCanvas = new CustomRenderingInkCanvas();
|
||||
//root.Children.Add(customInkCanvas);
|
||||
//customInkCanvas.EditingModeInverted = InkCanvasEditingMode.EraseByPoint;
|
||||
//customInkCanvas.StrokeCollected += new InkCanvasStrokeCollectedEventHandler(customInkCanvas_StrokeCollected);
|
||||
|
||||
//filterInkCanvas = new FilterInkCanvas();
|
||||
//root.Children.Add(filterInkCanvas);
|
||||
|
||||
//ic = new InkCanvas();
|
||||
//root.Children.Add(ic);
|
||||
//ic.StrokeCollected += new InkCanvasStrokeCollectedEventHandler(customInkCanvas_StrokeCollected);
|
||||
|
||||
//textbox1 = new TextBox();
|
||||
//InkCanvas.SetTop(textbox1, 30);
|
||||
//InkCanvas.SetLeft(textbox1, 100);
|
||||
//textbox1.Text = "Hello world";
|
||||
//ic.Children.Add(textbox1);
|
||||
|
||||
control = new InkControl();
|
||||
root.Children.Add(control);
|
||||
|
||||
ClearStrokes.Click += new RoutedEventHandler(ClearStrokes_Click);
|
||||
WindowState = WindowState.Maximized;
|
||||
}
|
||||
|
||||
void ClearStrokes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
customInkCanvas.Strokes.Clear();
|
||||
}
|
||||
|
||||
void customInkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("customInkCanvase_StrokeCollected");
|
||||
e.Stroke.DrawingAttributes.Color = Colors.Green;
|
||||
if (e.Stroke is CustomStroke)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("stroke is custom");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("stroke is not custom");
|
||||
}
|
||||
|
||||
if (customInkCanvas.Strokes.Contains(e.Stroke))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("stroke is in ink canvas");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("stroke is not in ink canvas"); //always lands here
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("");
|
||||
}
|
||||
}
|
||||
|
||||
//<Snippet4>
|
||||
public class FilterInkCanvas : InkCanvas
|
||||
{
|
||||
FilterPlugin filter = new FilterPlugin();
|
||||
|
||||
public FilterInkCanvas()
|
||||
: base()
|
||||
{
|
||||
this.StylusPlugIns.Add(filter);
|
||||
}
|
||||
}
|
||||
//</Snippet4>
|
||||
|
||||
//<Snippet5>
|
||||
public class DynamicallyFilteredInkCanvas : InkCanvas
|
||||
{
|
||||
FilterPlugin filter = new FilterPlugin();
|
||||
|
||||
public DynamicallyFilteredInkCanvas()
|
||||
: base()
|
||||
{
|
||||
int dynamicRenderIndex =
|
||||
this.StylusPlugIns.IndexOf(this.DynamicRenderer);
|
||||
|
||||
this.StylusPlugIns.Insert(dynamicRenderIndex, filter);
|
||||
}
|
||||
}
|
||||
//</Snippet5>
|
||||
|
||||
//<Snippet9>
|
||||
public class CustomRenderingInkCanvas : InkCanvas
|
||||
{
|
||||
CustomDynamicRenderer customRenderer = new CustomDynamicRenderer();
|
||||
|
||||
public CustomRenderingInkCanvas() : base()
|
||||
{
|
||||
// Use the custom dynamic renderer on the
|
||||
// custom InkCanvas.
|
||||
this.DynamicRenderer = customRenderer;
|
||||
}
|
||||
|
||||
protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
|
||||
{
|
||||
// Remove the original stroke and add a custom stroke.
|
||||
this.Strokes.Remove(e.Stroke);
|
||||
CustomStroke customStroke = new CustomStroke(e.Stroke.StylusPoints);
|
||||
this.Strokes.Add(customStroke);
|
||||
|
||||
// Pass the custom stroke to base class' OnStrokeCollected method.
|
||||
InkCanvasStrokeCollectedEventArgs args =
|
||||
new InkCanvasStrokeCollectedEventArgs(customStroke);
|
||||
base.OnStrokeCollected(args);
|
||||
}
|
||||
}
|
||||
//</Snippet9>
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>AnimatingWithStoryboards_csharp</AssemblyName>
|
||||
<TargetType>winexe</TargetType>
|
||||
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
|
||||
<ApplicationIcon>App.ico</ApplicationIcon>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<RootNamespace>Microsoft.Samples.Animation.AnimatingWithStoryboards</RootNamespace>
|
||||
<ProjectGuid>{D1CC167E-90AF-44E2-AEA5-ACD3FAFD233D}</ProjectGuid>
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="app.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="app.xaml.cs">
|
||||
<DependentUpon>app.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="StoryboardExample.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="App.ico" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,121 @@
|
||||
//<Snippet11>
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
|
||||
{
|
||||
|
||||
// Uses a storyboard to animate the properties
|
||||
// of two buttons.
|
||||
public class StoryboardExample : Page
|
||||
{
|
||||
|
||||
public StoryboardExample()
|
||||
{
|
||||
// Create a name scope for the page.
|
||||
NameScope.SetNameScope(this, new NameScope());
|
||||
|
||||
this.WindowTitle = "Animate Properties using Storyboards";
|
||||
StackPanel myStackPanel = new StackPanel();
|
||||
myStackPanel.MinWidth = 500;
|
||||
myStackPanel.Margin = new Thickness(30);
|
||||
myStackPanel.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
TextBlock myTextBlock = new TextBlock();
|
||||
myTextBlock.Text = "Storyboard Animation Example";
|
||||
myStackPanel.Children.Add(myTextBlock);
|
||||
|
||||
//
|
||||
// Create and animate the first button.
|
||||
//
|
||||
|
||||
// Create a button.
|
||||
Button myWidthAnimatedButton = new Button();
|
||||
myWidthAnimatedButton.Height = 30;
|
||||
myWidthAnimatedButton.Width = 200;
|
||||
myWidthAnimatedButton.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
myWidthAnimatedButton.Content = "A Button";
|
||||
|
||||
// Set the Name of the button so that it can be referred
|
||||
// to in the storyboard that's created later.
|
||||
// The ID doesn't have to match the variable name;
|
||||
// it can be any unique identifier.
|
||||
myWidthAnimatedButton.Name = "myWidthAnimatedButton";
|
||||
|
||||
// Register the name with the page to which the button belongs.
|
||||
this.RegisterName(myWidthAnimatedButton.Name, myWidthAnimatedButton);
|
||||
|
||||
// Create a DoubleAnimation to animate the width of the button.
|
||||
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
|
||||
myDoubleAnimation.From = 200;
|
||||
myDoubleAnimation.To = 300;
|
||||
myDoubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(3000));
|
||||
|
||||
// Configure the animation to target the button's Width property.
|
||||
Storyboard.SetTargetName(myDoubleAnimation, myWidthAnimatedButton.Name);
|
||||
Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Button.WidthProperty));
|
||||
|
||||
// Create a storyboard to contain the animation.
|
||||
Storyboard myWidthAnimatedButtonStoryboard = new Storyboard();
|
||||
myWidthAnimatedButtonStoryboard.Children.Add(myDoubleAnimation);
|
||||
|
||||
// Animate the button width when it's clicked.
|
||||
myWidthAnimatedButton.Click += delegate(object sender, RoutedEventArgs args)
|
||||
{
|
||||
myWidthAnimatedButtonStoryboard.Begin(myWidthAnimatedButton);
|
||||
};
|
||||
|
||||
myStackPanel.Children.Add(myWidthAnimatedButton);
|
||||
|
||||
//
|
||||
// Create and animate the second button.
|
||||
//
|
||||
|
||||
// Create a second button.
|
||||
Button myColorAnimatedButton = new Button();
|
||||
myColorAnimatedButton.Height = 30;
|
||||
myColorAnimatedButton.Width = 200;
|
||||
myColorAnimatedButton.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
myColorAnimatedButton.Content = "Another Button";
|
||||
|
||||
// Create a SolidColorBrush to paint the button's background.
|
||||
SolidColorBrush myBackgroundBrush = new SolidColorBrush();
|
||||
myBackgroundBrush.Color = Colors.Blue;
|
||||
|
||||
// Because a Brush isn't a FrameworkElement, it doesn't
|
||||
// have a Name property to set. Instead, you just
|
||||
// register a name for the SolidColorBrush with
|
||||
// the page where it's used.
|
||||
this.RegisterName("myAnimatedBrush", myBackgroundBrush);
|
||||
|
||||
// Use the brush to paint the background of the button.
|
||||
myColorAnimatedButton.Background = myBackgroundBrush;
|
||||
|
||||
// Create a ColorAnimation to animate the button's background.
|
||||
ColorAnimation myColorAnimation = new ColorAnimation();
|
||||
myColorAnimation.From = Colors.Red;
|
||||
myColorAnimation.To = Colors.Blue;
|
||||
myColorAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(7000));
|
||||
|
||||
// Configure the animation to target the brush's Color property.
|
||||
Storyboard.SetTargetName(myColorAnimation, "myAnimatedBrush");
|
||||
Storyboard.SetTargetProperty(myColorAnimation, new PropertyPath(SolidColorBrush.ColorProperty));
|
||||
|
||||
// Create a storyboard to contain the animation.
|
||||
Storyboard myColorAnimatedButtonStoryboard = new Storyboard();
|
||||
myColorAnimatedButtonStoryboard.Children.Add(myColorAnimation);
|
||||
|
||||
// Animate the button background color when it's clicked.
|
||||
myColorAnimatedButton.Click += delegate(object sender, RoutedEventArgs args)
|
||||
{
|
||||
myColorAnimatedButtonStoryboard.Begin(myColorAnimatedButton);
|
||||
};
|
||||
|
||||
myStackPanel.Children.Add(myColorAnimatedButton);
|
||||
this.Content = myStackPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
//</Snippet11>
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
<Application
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Microsoft.Samples.Animation.AnimatingWithStoryboards.app">
|
||||
|
||||
<!-- Resources & Styles defined in this section will impact the entire application. -->
|
||||
<Application.Resources>
|
||||
|
||||
<Style TargetType="{x:Type Canvas}" >
|
||||
<Setter Property="Canvas.HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="Canvas.Background">
|
||||
<Setter.Value>
|
||||
|
||||
<DrawingBrush Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile"
|
||||
AlignmentX="Left" AlignmentY="Top">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Brush="#99FFFFFF">
|
||||
<GeometryDrawing.Geometry>
|
||||
<RectangleGeometry Rect="0,0,1,1" />
|
||||
</GeometryDrawing.Geometry>
|
||||
</GeometryDrawing>
|
||||
<GeometryDrawing Geometry="M0,0 L1,0 1,0.1, 0,0.1Z" Brush="#99CCCCFF" />
|
||||
<GeometryDrawing Geometry="M0,0 L0,1 0.1,1, 0.1,0Z" Brush="#99CCCCFF" />
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Button.MinWidth" Value="120"/>
|
||||
<Setter Property="Button.HorizontalAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type StackPanel}">
|
||||
<Setter Property="StackPanel.HorizontalAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||