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,92 @@
|
||||
//BitmapMetadata.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::IO;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Imaging;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Security;
|
||||
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private: Window^ mainWindow;
|
||||
|
||||
protected: virtual void OnStartup (StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private: void CreateAndShowMainWindow ()
|
||||
{
|
||||
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew Window();
|
||||
mainWindow->Title = "Image Metadata";
|
||||
|
||||
// <SnippetSetQuery>
|
||||
Stream^ pngStream = gcnew FileStream("smiley.png", FileMode::Open, FileAccess::ReadWrite, FileShare::ReadWrite);
|
||||
PngBitmapDecoder^ pngDecoder = gcnew PngBitmapDecoder(pngStream, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapFrame^ pngFrame = pngDecoder->Frames[0];
|
||||
InPlaceBitmapMetadataWriter^ pngInplace = pngFrame->CreateInPlaceBitmapMetadataWriter();
|
||||
if (pngInplace->TrySave() == true)
|
||||
{
|
||||
pngInplace->SetQuery("/Text/Description", "Have a nice day.");
|
||||
}
|
||||
pngStream->Close();
|
||||
// </SnippetSetQuery>
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage = gcnew Image();
|
||||
myImage->Source = gcnew BitmapImage(gcnew System::Uri("smiley.png", UriKind::Relative));
|
||||
myImage->Stretch = Stretch::None;
|
||||
myImage->Margin = System::Windows::Thickness(20);
|
||||
|
||||
// <SnippetGetQuery>
|
||||
|
||||
// Add the metadata of the bitmap image to the text block.
|
||||
TextBlock^ myTextBlock = gcnew TextBlock();
|
||||
myTextBlock->Text = "The Description metadata of this image is: " + pngInplace->GetQuery("/Text/Description")->ToString();
|
||||
// </SnippetGetQuery>
|
||||
|
||||
// Define a StackPanel to host Controls
|
||||
StackPanel^ myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->Orientation = Orientation::Vertical;
|
||||
myStackPanel->Height = 200;
|
||||
myStackPanel->VerticalAlignment = VerticalAlignment::Top;
|
||||
myStackPanel->HorizontalAlignment = HorizontalAlignment::Center;
|
||||
|
||||
// Add the Image and TextBlock to the parent Grid
|
||||
myStackPanel->Children->Add(myImage);
|
||||
myStackPanel->Children->Add(myTextBlock);
|
||||
|
||||
// Add the StackPanel as the Content of the Parent Window Object
|
||||
mainWindow->Content = myStackPanel;
|
||||
mainWindow->Show();
|
||||
};
|
||||
};
|
||||
|
||||
// Define a static entry class
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir>.\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="BitmapMetadata.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,46 @@
|
||||
//BitmapFrame.h file
|
||||
|
||||
#pragma once
|
||||
|
||||
/*#using <C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll>
|
||||
#using <C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll>
|
||||
#using <C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\UIAutomationProvider.dll>
|
||||
#using <C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll>
|
||||
#using <C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll>
|
||||
#using <system.dll>
|
||||
#using <system.XML.dll>
|
||||
#using <system.drawing.dll>
|
||||
#using <system.windows.forms.dll> */
|
||||
namespace SDKSample {
|
||||
ref class app;
|
||||
ref class EntryClass;
|
||||
}
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::IO;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Imaging;
|
||||
using namespace System::Threading;
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private: System::Windows::Window^ mainWindow;
|
||||
|
||||
protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override ;
|
||||
|
||||
private: void CreateAndShowMainWindow () ;
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main () ;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::IO;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Imaging;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Security;
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private: System::Windows::Window^ mainWindow;
|
||||
|
||||
protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private: void CreateAndShowMainWindow ()
|
||||
{
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew System::Windows::Window();
|
||||
mainWindow->Title = "BMP Imaging Sample";
|
||||
ScrollViewer^ mySV = gcnew ScrollViewer();
|
||||
|
||||
//<Snippet4>
|
||||
int width = 128;
|
||||
int height = width;
|
||||
int stride = width / 8;
|
||||
array<System::Byte>^ pixels = gcnew array<System::Byte>(height * stride);
|
||||
|
||||
List<Color>^ colors = gcnew List<Color>();
|
||||
colors->Add(Colors::Red);
|
||||
colors->Add(Colors::Blue);
|
||||
colors->Add(Colors::Green);
|
||||
BitmapPalette^ myPalette = gcnew BitmapPalette(colors);
|
||||
|
||||
// Creates a new empty image with the pre-defined palette
|
||||
|
||||
//<Snippet2>
|
||||
BitmapSource^ image = BitmapSource::Create(
|
||||
width,
|
||||
height,
|
||||
96,
|
||||
96,
|
||||
PixelFormats::Indexed1,
|
||||
myPalette,
|
||||
pixels,
|
||||
stride);
|
||||
//</Snippet2>
|
||||
|
||||
//<Snippet3>
|
||||
FileStream^ stream = gcnew FileStream("new.bmp", FileMode::Create);
|
||||
BmpBitmapEncoder^ encoder = gcnew BmpBitmapEncoder();
|
||||
TextBlock^ myTextBlock = gcnew TextBlock();
|
||||
myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString();
|
||||
encoder->Frames->Add(BitmapFrame::Create(image));
|
||||
encoder->Save(stream);
|
||||
//</Snippet3>
|
||||
|
||||
//</Snippet4>
|
||||
|
||||
//<Snippet1>
|
||||
|
||||
// Open a Stream and decode a BMP image
|
||||
Stream^ imageStreamSource = gcnew FileStream("tulipfarm.bmp", FileMode::Open, FileAccess::Read, FileShare::Read);
|
||||
BmpBitmapDecoder^ decoder = gcnew BmpBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource = decoder->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage = gcnew Image();
|
||||
myImage->Source = bitmapSource;
|
||||
myImage->Stretch = Stretch::None;
|
||||
myImage->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet1>
|
||||
|
||||
//<Snippet5>
|
||||
|
||||
// Open a Uri and decode a BMP image
|
||||
System::Uri^ myUri = gcnew System::Uri("tulipfarm.bmp", UriKind::RelativeOrAbsolute);
|
||||
BmpBitmapDecoder^ decoder2 = gcnew BmpBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource2 = decoder2->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage2 = gcnew Image();
|
||||
myImage2->Source = bitmapSource2;
|
||||
myImage2->Stretch = Stretch::None;
|
||||
myImage2->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet5>
|
||||
|
||||
// Define a StackPanel to host the decoded BMP images
|
||||
StackPanel^ myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->Orientation = Orientation::Vertical;
|
||||
myStackPanel->VerticalAlignment = VerticalAlignment::Stretch;
|
||||
myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch;
|
||||
|
||||
// Add the Image and TextBlock to the parent Grid
|
||||
myStackPanel->Children->Add(myImage);
|
||||
myStackPanel->Children->Add(myImage2);
|
||||
myStackPanel->Children->Add(myTextBlock);
|
||||
|
||||
// Add the StackPanel as the Content of the Parent Window Object
|
||||
mySV->Content = myStackPanel;
|
||||
mainWindow->Content = mySV;
|
||||
mainWindow->Show();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{6900EB9F-8008-437C-BB1E-3C7C06662F84}</ProjectGuid>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
<RootNamespace>AnotherProject</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>.\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AnotherFile.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BitmapFrame.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="tulipfarm.bmp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AnotherFile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BitmapFrame.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="tulipfarm.bmp">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
After Width: | Height: | Size: 900 KiB |
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CanvasAttachedProps.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,95 @@
|
||||
//CanvasAttachedProps.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Threading;
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private:
|
||||
Window^ mainWindow;
|
||||
|
||||
protected:
|
||||
virtual void OnStartup (StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// <Snippet1>
|
||||
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew System::Windows::Window();
|
||||
mainWindow->Title = "Canvas Attached Properties Sample";
|
||||
|
||||
// Add a Border
|
||||
Border^ myBorder = gcnew Border();
|
||||
myBorder->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myBorder->VerticalAlignment = VerticalAlignment::Top;
|
||||
myBorder->BorderBrush = Brushes::Black;
|
||||
myBorder->BorderThickness = System::Windows::Thickness(2);
|
||||
|
||||
// Create the Canvas
|
||||
Canvas^ myCanvas = gcnew Canvas();
|
||||
myCanvas->Background = Brushes::LightBlue;
|
||||
myCanvas->Width = 400;
|
||||
myCanvas->Height = 400;
|
||||
|
||||
// Create the child Button elements
|
||||
Button^ myButton1 = gcnew Button();
|
||||
Button^ myButton2 = gcnew Button();
|
||||
Button^ myButton3 = gcnew Button();
|
||||
Button^ myButton4 = gcnew Button();
|
||||
|
||||
// Set Positioning attached properties on Button elements
|
||||
Canvas::SetTop(myButton1, 50);
|
||||
myButton1->Content = "Canvas.Top=50";
|
||||
Canvas::SetBottom(myButton2, 50);
|
||||
myButton2->Content = "Canvas.Bottom=50";
|
||||
Canvas::SetLeft(myButton3, 50);
|
||||
myButton3->Content = "Canvas.Left=50";
|
||||
Canvas::SetRight(myButton4, 50);
|
||||
myButton4->Content = "Canvas.Right=50";
|
||||
|
||||
// Add Buttons to the Canvas' Children collection
|
||||
myCanvas->Children->Add(myButton1);
|
||||
myCanvas->Children->Add(myButton2);
|
||||
myCanvas->Children->Add(myButton3);
|
||||
myCanvas->Children->Add(myButton4);
|
||||
|
||||
// Add the Canvas as the lone Child of the Border
|
||||
myBorder->Child = myCanvas;
|
||||
|
||||
// Add the Border as the Content of the Parent Window Object
|
||||
mainWindow->Content = myBorder;
|
||||
mainWindow->Show();
|
||||
|
||||
//</Snippet1>
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
//Program.cpp file
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Text;
|
||||
using namespace System::Printing;
|
||||
using namespace System::IO;
|
||||
|
||||
namespace DiagnoseProblematicPrintJob {
|
||||
|
||||
//<SnippetTimeConverter>
|
||||
private ref class TimeConverter {
|
||||
|
||||
internal:
|
||||
static DateTime ConvertToLocalHumanReadableTime (Int32 timeInMinutesAfterUTCMidnight)
|
||||
{
|
||||
// Construct a UTC midnight object.
|
||||
// Must start with current date so that the local Daylight Savings system, if any, will be taken into account.
|
||||
DateTime utcNow = DateTime::UtcNow;
|
||||
DateTime utcMidnight = DateTime(utcNow.Year, utcNow.Month, utcNow.Day, 0, 0, 0, DateTimeKind::Utc);
|
||||
|
||||
// Add the minutes passed into the method in order to get the intended UTC time.
|
||||
Double minutesAfterUTCMidnight = ((Double)timeInMinutesAfterUTCMidnight);
|
||||
DateTime utcTime = utcMidnight.AddMinutes(minutesAfterUTCMidnight);
|
||||
|
||||
// Convert to local time.
|
||||
DateTime localTime = utcTime.ToLocalTime();
|
||||
|
||||
return localTime;
|
||||
};
|
||||
};
|
||||
//</SnippetTimeConverter>
|
||||
|
||||
private ref class TroubleSpotter {
|
||||
|
||||
internal:
|
||||
// <SnippetSpotTroubleUsingJobProperties>
|
||||
// Check for possible trouble states of a print job using its properties
|
||||
static void SpotTroubleUsingProperties (PrintSystemJobInfo^ theJob)
|
||||
{
|
||||
if (theJob->IsBlocked)
|
||||
{
|
||||
Console::WriteLine("The job is blocked.");
|
||||
}
|
||||
if (theJob->IsCompleted || theJob->IsPrinted)
|
||||
{
|
||||
Console::WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
|
||||
}
|
||||
if (theJob->IsDeleted || theJob->IsDeleting)
|
||||
{
|
||||
Console::WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
|
||||
}
|
||||
if (theJob->IsInError)
|
||||
{
|
||||
Console::WriteLine("The job has errored.");
|
||||
}
|
||||
if (theJob->IsOffline)
|
||||
{
|
||||
Console::WriteLine("The printer is offline. Have user put it online with printer front panel.");
|
||||
}
|
||||
if (theJob->IsPaperOut)
|
||||
{
|
||||
Console::WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
|
||||
}
|
||||
|
||||
if (theJob->IsPaused || theJob->HostingPrintQueue->IsPaused)
|
||||
{
|
||||
HandlePausedJob(theJob);
|
||||
//HandlePausedJob is defined in the complete example.
|
||||
}
|
||||
|
||||
if (theJob->IsPrinting)
|
||||
{
|
||||
Console::WriteLine("The job is printing now.");
|
||||
}
|
||||
if (theJob->IsSpooling)
|
||||
{
|
||||
Console::WriteLine("The job is spooling now.");
|
||||
}
|
||||
if (theJob->IsUserInterventionRequired)
|
||||
{
|
||||
Console::WriteLine("The printer needs human intervention.");
|
||||
}
|
||||
};
|
||||
// </SnippetSpotTroubleUsingJobProperties>
|
||||
|
||||
// <SnippetSpotTroubleUsingJobAttributes>
|
||||
// Check for possible trouble states of a print job using the flags of the JobStatus property
|
||||
static void SpotTroubleUsingJobAttributes (PrintSystemJobInfo^ theJob)
|
||||
{
|
||||
if ((theJob->JobStatus & PrintJobStatus::Blocked) == PrintJobStatus::Blocked)
|
||||
{
|
||||
Console::WriteLine("The job is blocked.");
|
||||
}
|
||||
if (((theJob->JobStatus & PrintJobStatus::Completed) == PrintJobStatus::Completed)
|
||||
||
|
||||
((theJob->JobStatus & PrintJobStatus::Printed) == PrintJobStatus::Printed))
|
||||
{
|
||||
Console::WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
|
||||
}
|
||||
if (((theJob->JobStatus & PrintJobStatus::Deleted) == PrintJobStatus::Deleted)
|
||||
||
|
||||
((theJob->JobStatus & PrintJobStatus::Deleting) == PrintJobStatus::Deleting))
|
||||
{
|
||||
Console::WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
|
||||
}
|
||||
if ((theJob->JobStatus & PrintJobStatus::Error) == PrintJobStatus::Error)
|
||||
{
|
||||
Console::WriteLine("The job has errored.");
|
||||
}
|
||||
if ((theJob->JobStatus & PrintJobStatus::Offline) == PrintJobStatus::Offline)
|
||||
{
|
||||
Console::WriteLine("The printer is offline. Have user put it online with printer front panel.");
|
||||
}
|
||||
if ((theJob->JobStatus & PrintJobStatus::PaperOut) == PrintJobStatus::PaperOut)
|
||||
{
|
||||
Console::WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
|
||||
}
|
||||
if (((theJob->JobStatus & PrintJobStatus::Paused) == PrintJobStatus::Paused)
|
||||
||
|
||||
((theJob->HostingPrintQueue->QueueStatus & PrintQueueStatus::Paused) == PrintQueueStatus::Paused))
|
||||
{
|
||||
HandlePausedJob(theJob);
|
||||
//HandlePausedJob is defined in the complete example.
|
||||
}
|
||||
|
||||
if ((theJob->JobStatus & PrintJobStatus::Printing) == PrintJobStatus::Printing)
|
||||
{
|
||||
Console::WriteLine("The job is printing now.");
|
||||
}
|
||||
if ((theJob->JobStatus & PrintJobStatus::Spooling) == PrintJobStatus::Spooling)
|
||||
{
|
||||
Console::WriteLine("The job is spooling now.");
|
||||
}
|
||||
if ((theJob->JobStatus & PrintJobStatus::UserIntervention) == PrintJobStatus::UserIntervention)
|
||||
{
|
||||
Console::WriteLine("The printer needs human intervention.");
|
||||
}
|
||||
};
|
||||
// </SnippetSpotTroubleUsingJobAttributes>
|
||||
|
||||
//<SnippetHandlePausedJob>
|
||||
static void HandlePausedJob (PrintSystemJobInfo^ theJob)
|
||||
{
|
||||
// If there's no good reason for the queue to be paused, resume it and
|
||||
// give user choice to resume or cancel the job.
|
||||
Console::WriteLine("The user or someone with administrative rights to the queue" + "\nhas paused the job or queue." + "\nResume the queue? (Has no effect if queue is not paused.)" + "\nEnter \"Y\" to resume, otherwise press return: ");
|
||||
String^ resume = Console::ReadLine();
|
||||
if (resume == "Y")
|
||||
{
|
||||
theJob->HostingPrintQueue->Resume();
|
||||
|
||||
// It is possible the job is also paused. Find out how the user wants to handle that.
|
||||
Console::WriteLine("Does user want to resume print job or cancel it?" + "\nEnter \"Y\" to resume (any other key cancels the print job): ");
|
||||
String^ userDecision = Console::ReadLine();
|
||||
if (userDecision == "Y")
|
||||
{
|
||||
theJob->Resume();
|
||||
} else
|
||||
{
|
||||
theJob->Cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
//</SnippetHandlePausedJob>
|
||||
|
||||
//<SnippetReportQueueAndJobAvailability>
|
||||
static void ReportQueueAndJobAvailability (PrintSystemJobInfo^ theJob)
|
||||
{
|
||||
if (!(ReportAvailabilityAtThisTime(theJob->HostingPrintQueue) && ReportAvailabilityAtThisTime(theJob)))
|
||||
{
|
||||
if (!ReportAvailabilityAtThisTime(theJob->HostingPrintQueue))
|
||||
{
|
||||
Console::WriteLine("\nThat queue is not available at this time of day." + "\nJobs in the queue will start printing again at {0}", TimeConverter::ConvertToLocalHumanReadableTime(theJob->HostingPrintQueue->StartTimeOfDay).ToShortTimeString());
|
||||
// TimeConverter class is defined in the complete sample
|
||||
}
|
||||
if (!ReportAvailabilityAtThisTime(theJob))
|
||||
{
|
||||
Console::WriteLine("\nThat job is set to print only between {0} and {1}", TimeConverter::ConvertToLocalHumanReadableTime(theJob->StartTimeOfDay).ToShortTimeString(), TimeConverter::ConvertToLocalHumanReadableTime(theJob->UntilTimeOfDay).ToShortTimeString());
|
||||
}
|
||||
Console::WriteLine("\nThe job will begin printing as soon as it reaches the top of the queue after:");
|
||||
if (theJob->StartTimeOfDay > theJob->HostingPrintQueue->StartTimeOfDay)
|
||||
{
|
||||
Console::WriteLine(TimeConverter::ConvertToLocalHumanReadableTime(theJob->StartTimeOfDay).ToShortTimeString());
|
||||
} else
|
||||
{
|
||||
Console::WriteLine(TimeConverter::ConvertToLocalHumanReadableTime(theJob->HostingPrintQueue->StartTimeOfDay).ToShortTimeString());
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
//</SnippetReportQueueAndJobAvailability>
|
||||
|
||||
|
||||
//<SnippetPrintQueueStartUntil>
|
||||
static Boolean ReportAvailabilityAtThisTime (PrintQueue^ pq)
|
||||
{
|
||||
Boolean available = true;
|
||||
if (pq->StartTimeOfDay != pq->UntilTimeOfDay)
|
||||
{
|
||||
DateTime utcNow = DateTime::UtcNow;
|
||||
Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;
|
||||
|
||||
// If now is not within the range of available times . . .
|
||||
if (!((pq->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < pq->UntilTimeOfDay)))
|
||||
{
|
||||
available = false;
|
||||
}
|
||||
}
|
||||
return available;
|
||||
};
|
||||
//</SnippetPrintQueueStartUntil>
|
||||
|
||||
|
||||
// <SnippetUsingJobStartAndUntilTimes>
|
||||
static Boolean ReportAvailabilityAtThisTime (PrintSystemJobInfo^ theJob)
|
||||
{
|
||||
Boolean available = true;
|
||||
if (theJob->StartTimeOfDay != theJob->UntilTimeOfDay)
|
||||
{
|
||||
DateTime utcNow = DateTime::UtcNow;
|
||||
Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;
|
||||
|
||||
// If "now" is not within the range of available times . . .
|
||||
if (!((theJob->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < theJob->UntilTimeOfDay)))
|
||||
{
|
||||
available = false;
|
||||
}
|
||||
}
|
||||
return available;
|
||||
}
|
||||
// </SnippetUsingJobStartAndUntilTimes>
|
||||
|
||||
};
|
||||
|
||||
|
||||
private ref class Program {
|
||||
|
||||
public:
|
||||
static void Main (array<String^>^ args)
|
||||
{
|
||||
// Obtain a list of print servers.
|
||||
Console::Write("Enter path and file name of CRLF-delimited list of print servers" + "\n(press Return for default \"C:\\PrintServers.txt\"): ");
|
||||
String^ pathToListOfPrintServers = Console::ReadLine();
|
||||
if (pathToListOfPrintServers == "")
|
||||
{
|
||||
pathToListOfPrintServers = "C:\\PrintServers.txt";
|
||||
}
|
||||
StreamReader^ fileOfPrintServers = gcnew StreamReader(pathToListOfPrintServers);
|
||||
|
||||
// Obtain the username of the person with the problematic print job.
|
||||
Console::Write("\nEnter username of person that submitted print job" + "\n(press Return for the current user {0}: ", Environment::UserName);
|
||||
String^ userName = Console::ReadLine();
|
||||
if (userName == "")
|
||||
{
|
||||
userName = Environment::UserName;
|
||||
}
|
||||
|
||||
// Prompt user to determine the method that will be used to read the queue status.
|
||||
Console::Write("\nEnter \"Y\" to check the problematic job using its JobStatus attributes." + "\nOtherwise, press Return and the job will be checked using its specific properties: ");
|
||||
String^ useAttributesResponse = Console::ReadLine();
|
||||
|
||||
// Create list of all jobs submitted by user.
|
||||
String^ line;
|
||||
Boolean atLeastOne = false;
|
||||
String^ jobList = "\n\nAll print jobs submitted by the user are listed here:\n\n";
|
||||
while ((line = fileOfPrintServers->ReadLine()) != nullptr)
|
||||
{
|
||||
PrintServer^ myPS = gcnew PrintServer(line, PrintSystemDesiredAccess::AdministrateServer);
|
||||
PrintQueueCollection^ myPrintQueues = myPS->GetPrintQueues();
|
||||
|
||||
//<SnippetEnumerateJobsInQueues>
|
||||
for each (PrintQueue^ pq in myPrintQueues)
|
||||
{
|
||||
pq->Refresh();
|
||||
PrintJobInfoCollection^ jobs = pq->GetPrintJobInfoCollection();
|
||||
for each (PrintSystemJobInfo^ job in jobs)
|
||||
{
|
||||
// Since the user may not be able to articulate which job is problematic,
|
||||
// present information about each job the user has submitted.
|
||||
if (job->Submitter == userName)
|
||||
{
|
||||
atLeastOne = true;
|
||||
jobList = jobList + "\nServer:" + line;
|
||||
jobList = jobList + "\n\tQueue:" + pq->Name;
|
||||
jobList = jobList + "\n\tLocation:" + pq->Location;
|
||||
jobList = jobList + "\n\t\tJob: " + job->JobName + " ID: " + job->JobIdentifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
//</SnippetEnumerateJobsInQueues>
|
||||
}
|
||||
|
||||
fileOfPrintServers->Close();
|
||||
|
||||
if (!atLeastOne)
|
||||
{
|
||||
jobList = "\n\nNo jobs submitted by " + userName + " were found.\n\n";
|
||||
Console::WriteLine(jobList);
|
||||
} else
|
||||
{
|
||||
jobList = jobList + "\n\nIf multiple jobs are listed, use the information provided" + " above and by the user to identify the job needing diagnosis.\n\n";
|
||||
Console::WriteLine(jobList);
|
||||
//<SnippetIdentifyAndDiagnoseProblematicJob>
|
||||
// When the problematic print job has been identified, enter information about it.
|
||||
Console::Write("\nEnter the print server hosting the job (including leading slashes \\\\): " + "\n(press Return for the current computer \\\\{0}): ", Environment::MachineName);
|
||||
String^ pServer = Console::ReadLine();
|
||||
if (pServer == "")
|
||||
{
|
||||
pServer = "\\\\" + Environment::MachineName;
|
||||
}
|
||||
Console::Write("\nEnter the print queue hosting the job: ");
|
||||
String^ pQueue = Console::ReadLine();
|
||||
Console::Write("\nEnter the job ID: ");
|
||||
Int16 jobID = Convert::ToInt16(Console::ReadLine());
|
||||
|
||||
// Create objects to represent the server, queue, and print job.
|
||||
PrintServer^ hostingServer = gcnew PrintServer(pServer, PrintSystemDesiredAccess::AdministrateServer);
|
||||
PrintQueue^ hostingQueue = gcnew PrintQueue(hostingServer, pQueue, PrintSystemDesiredAccess::AdministratePrinter);
|
||||
PrintSystemJobInfo^ theJob = hostingQueue->GetJob(jobID);
|
||||
|
||||
if (useAttributesResponse == "Y")
|
||||
{
|
||||
TroubleSpotter::SpotTroubleUsingJobAttributes(theJob);
|
||||
// TroubleSpotter class is defined in the complete example.
|
||||
} else
|
||||
{
|
||||
TroubleSpotter::SpotTroubleUsingProperties(theJob);
|
||||
}
|
||||
|
||||
TroubleSpotter::ReportQueueAndJobAvailability(theJob);
|
||||
//</SnippetIdentifyAndDiagnoseProblematicJob>
|
||||
}
|
||||
Console::WriteLine("\nPress Return to end.");
|
||||
Console::ReadLine();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
int main (array<String^>^ args)
|
||||
{
|
||||
DiagnoseProblematicPrintJob::Program::Main(args);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21208.0</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System.Printing">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="ReachFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Program.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,123 @@
|
||||
//DockPanel_Ovw_Sample.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Shapes;
|
||||
using namespace System::Threading;
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private:
|
||||
Window^ mainWindow;
|
||||
|
||||
protected:
|
||||
virtual void OnStartup (StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// <Snippet1>
|
||||
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew Window();
|
||||
mainWindow->Title = "DockPanel Sample";
|
||||
|
||||
// Create the DockPanel
|
||||
DockPanel^ myDockPanel = gcnew DockPanel();
|
||||
myDockPanel->LastChildFill = true;
|
||||
|
||||
// Define the child content
|
||||
Border^ myBorder1 = gcnew Border();
|
||||
myBorder1->Height = 25;
|
||||
myBorder1->Background = Brushes::SkyBlue;
|
||||
myBorder1->BorderBrush = Brushes::Black;
|
||||
myBorder1->BorderThickness = Thickness(1);
|
||||
DockPanel::SetDock(myBorder1, Dock::Top);
|
||||
TextBlock^ myTextBlock1 = gcnew TextBlock();
|
||||
myTextBlock1->Foreground = Brushes::Black;
|
||||
myTextBlock1->Text = "Dock = Top";
|
||||
myBorder1->Child = myTextBlock1;
|
||||
|
||||
Border^ myBorder2 = gcnew Border();
|
||||
myBorder2->Height = 25;
|
||||
myBorder2->Background = Brushes::SkyBlue;
|
||||
myBorder2->BorderBrush = Brushes::Black;
|
||||
myBorder2->BorderThickness = Thickness(1);
|
||||
DockPanel::SetDock(myBorder2, Dock::Top);
|
||||
TextBlock^ myTextBlock2 = gcnew TextBlock();
|
||||
myTextBlock2->Foreground = Brushes::Black;
|
||||
myTextBlock2->Text = "Dock = Top";
|
||||
myBorder2->Child = myTextBlock2;
|
||||
|
||||
Border^ myBorder3 = gcnew Border();
|
||||
myBorder3->Height = 25;
|
||||
myBorder3->Background = Brushes::LemonChiffon;
|
||||
myBorder3->BorderBrush = Brushes::Black;
|
||||
myBorder3->BorderThickness = Thickness(1);
|
||||
DockPanel::SetDock(myBorder3, Dock::Bottom);
|
||||
TextBlock^ myTextBlock3 = gcnew TextBlock();
|
||||
myTextBlock3->Foreground = Brushes::Black;
|
||||
myTextBlock3->Text = "Dock = Bottom";
|
||||
myBorder3->Child = myTextBlock3;
|
||||
|
||||
Border^ myBorder4 = gcnew Border();
|
||||
myBorder4->Width = 200;
|
||||
myBorder4->Background = Brushes::PaleGreen;
|
||||
myBorder4->BorderBrush = Brushes::Black;
|
||||
myBorder4->BorderThickness = Thickness(1);
|
||||
DockPanel::SetDock(myBorder4, Dock::Left);
|
||||
TextBlock^ myTextBlock4 = gcnew TextBlock();
|
||||
myTextBlock4->Foreground = Brushes::Black;
|
||||
myTextBlock4->Text = "Dock = Left";
|
||||
myBorder4->Child = myTextBlock4;
|
||||
|
||||
Border^ myBorder5 = gcnew Border();
|
||||
myBorder5->Background = Brushes::White;
|
||||
myBorder5->BorderBrush = Brushes::Black;
|
||||
myBorder5->BorderThickness = Thickness(1);
|
||||
TextBlock^ myTextBlock5 = gcnew TextBlock();
|
||||
myTextBlock5->Foreground = Brushes::Black;
|
||||
myTextBlock5->Text = "This content will Fill the remaining space";
|
||||
myBorder5->Child = myTextBlock5;
|
||||
|
||||
// Add child elements to the DockPanel Children collection
|
||||
myDockPanel->Children->Add(myBorder1);
|
||||
myDockPanel->Children->Add(myBorder2);
|
||||
myDockPanel->Children->Add(myBorder3);
|
||||
myDockPanel->Children->Add(myBorder4);
|
||||
myDockPanel->Children->Add(myBorder5);
|
||||
|
||||
// Add the parent Canvas as the Content of the Window Object
|
||||
mainWindow->Content = myDockPanel;
|
||||
mainWindow->Show();
|
||||
|
||||
//</Snippet1>
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DockPanel_Ovw_Sample.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,44 @@
|
||||
//Program.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Text;
|
||||
using namespace System::Printing;
|
||||
using namespace System::Collections;
|
||||
|
||||
namespace EnumerateSubsetOfPrintQueues {
|
||||
|
||||
private ref class Program {
|
||||
|
||||
public:
|
||||
static void Main (array<System::String^>^ args)
|
||||
{
|
||||
//<SnippetListSubsetOfPrintQueues>
|
||||
// Specify that the list will contain only the print queues that are installed as local and are shared
|
||||
array<System::Printing::EnumeratedPrintQueueTypes>^ enumerationFlags = {EnumeratedPrintQueueTypes::Local,EnumeratedPrintQueueTypes::Shared};
|
||||
|
||||
LocalPrintServer^ printServer = gcnew LocalPrintServer();
|
||||
|
||||
//Use the enumerationFlags to filter out unwanted print queues
|
||||
PrintQueueCollection^ printQueuesOnLocalServer = printServer->GetPrintQueues(enumerationFlags);
|
||||
|
||||
Console::WriteLine("These are your shared, local print queues:\n\n");
|
||||
|
||||
for each (PrintQueue^ printer in printQueuesOnLocalServer)
|
||||
{
|
||||
Console::WriteLine("\tThe shared printer " + printer->Name + " is located at " + printer->Location + "\n");
|
||||
}
|
||||
Console::WriteLine("Press enter to continue.");
|
||||
Console::ReadLine();
|
||||
//</SnippetListSubsetOfPrintQueues>
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
int main (array<System::String^>^ args)
|
||||
{
|
||||
EnumerateSubsetOfPrintQueues::Program::Main(args);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21208.0</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="ReachFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System.Printing">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Program.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,133 @@
|
||||
//GifEncoderDecoder.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::IO;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Imaging;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Security;
|
||||
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private: System::Windows::Window^ mainWindow;
|
||||
|
||||
protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
[SecuritySafeCritical]
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew System::Windows::Window();
|
||||
mainWindow->Title = "GIF Imaging Sample";
|
||||
ScrollViewer^ mySV = gcnew ScrollViewer();
|
||||
|
||||
//<Snippet4>
|
||||
int width = 128;
|
||||
int height = width;
|
||||
int stride = width / 8;
|
||||
array<System::Byte>^ pixels = gcnew array<System::Byte>(height * stride);
|
||||
|
||||
// Define the image palette
|
||||
|
||||
BitmapPalette^ myPalette = BitmapPalettes::WebPalette;
|
||||
|
||||
// Creates a new empty image with the pre-defined palette
|
||||
|
||||
//<Snippet2>
|
||||
BitmapSource^ image = BitmapSource::Create(
|
||||
width,
|
||||
height,
|
||||
96,
|
||||
96,
|
||||
PixelFormats::Indexed1,
|
||||
myPalette,
|
||||
pixels,
|
||||
stride);
|
||||
//</Snippet2>
|
||||
|
||||
//<Snippet3>
|
||||
FileStream^ stream = gcnew FileStream("new.gif", FileMode::Create);
|
||||
GifBitmapEncoder^ encoder = gcnew GifBitmapEncoder();
|
||||
TextBlock^ myTextBlock = gcnew TextBlock();
|
||||
myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString();
|
||||
encoder->Frames->Add(BitmapFrame::Create(image));
|
||||
encoder->Save(stream);
|
||||
//</Snippet3>
|
||||
|
||||
//</Snippet4>
|
||||
|
||||
//<Snippet1>
|
||||
|
||||
// Open a Stream and decode a GIF image
|
||||
Stream^ imageStreamSource = gcnew FileStream("tulipfarm.gif", FileMode::Open, FileAccess::Read, FileShare::Read);
|
||||
GifBitmapDecoder^ decoder = gcnew GifBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource = decoder->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage = gcnew Image();
|
||||
myImage->Source = bitmapSource;
|
||||
myImage->Stretch = Stretch::None;
|
||||
myImage->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet1>
|
||||
|
||||
//<Snippet5>
|
||||
|
||||
// Open a Uri and decode a GIF image
|
||||
System::Uri^ myUri = gcnew System::Uri("tulipfarm.gif", UriKind::RelativeOrAbsolute);
|
||||
GifBitmapDecoder^ decoder2 = gcnew GifBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource2 = decoder2->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage2 = gcnew Image();
|
||||
myImage2->Source = bitmapSource2;
|
||||
myImage2->Stretch = Stretch::None;
|
||||
myImage2->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet5>
|
||||
|
||||
// Define a StackPanel to host the decoded GIF images
|
||||
StackPanel^ myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->Orientation = Orientation::Vertical;
|
||||
myStackPanel->VerticalAlignment = VerticalAlignment::Stretch;
|
||||
myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch;
|
||||
|
||||
// Add the Image and TextBlock to the parent Grid
|
||||
myStackPanel->Children->Add(myImage);
|
||||
myStackPanel->Children->Add(myImage2);
|
||||
myStackPanel->Children->Add(myTextBlock);
|
||||
|
||||
// Add the StackPanel as the Content of the Parent Window Object
|
||||
mySV->Content = myStackPanel;
|
||||
mainWindow->Content = mySV;
|
||||
mainWindow->Show();
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main () {
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir>.\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="GifEncoderDecoder.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="tulipfarm.gif" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
After Width: | Height: | Size: 167 KiB |
@@ -0,0 +1,133 @@
|
||||
//jpegencoderdecoder.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::IO;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Imaging;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Security;
|
||||
|
||||
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private:
|
||||
System::Windows::Window^ mainWindow;
|
||||
|
||||
protected:
|
||||
virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew System::Windows::Window();
|
||||
mainWindow->Title = "JPEG Imaging Sample";
|
||||
System::Windows::Controls::ScrollViewer^ mySV = gcnew System::Windows::Controls::ScrollViewer();
|
||||
|
||||
//<Snippet4>
|
||||
int width = 128;
|
||||
int height = width;
|
||||
int stride = width / 8;
|
||||
array<System::Byte>^ pixels = gcnew array<System::Byte>(height * stride);
|
||||
|
||||
// Define the image palette
|
||||
BitmapPalette^ myPalette = BitmapPalettes::Halftone256;
|
||||
|
||||
// Creates a new empty image with the pre-defined palette.
|
||||
//<Snippet2>
|
||||
BitmapSource^ image = BitmapSource::Create(
|
||||
width, height,
|
||||
96, 96,
|
||||
PixelFormats::Indexed1,
|
||||
myPalette,
|
||||
pixels,
|
||||
stride);
|
||||
//</Snippet2>
|
||||
//<Snippet3>
|
||||
|
||||
System::IO::FileStream^ stream = gcnew System::IO::FileStream("new.jpg", FileMode::Create);
|
||||
JpegBitmapEncoder^ encoder = gcnew JpegBitmapEncoder();
|
||||
TextBlock^ myTextBlock = gcnew System::Windows::Controls::TextBlock();
|
||||
myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString();
|
||||
encoder->FlipHorizontal = true;
|
||||
encoder->FlipVertical = false;
|
||||
encoder->QualityLevel = 30;
|
||||
encoder->Rotation = Rotation::Rotate90;
|
||||
encoder->Frames->Add(BitmapFrame::Create(image));
|
||||
encoder->Save(stream);
|
||||
//</Snippet3>
|
||||
//</Snippet4>
|
||||
|
||||
//<Snippet1>
|
||||
// Open a Stream and decode a JPEG image
|
||||
Stream^ imageStreamSource = gcnew FileStream("tulipfarm.jpg", FileMode::Open, FileAccess::Read, FileShare::Read);
|
||||
JpegBitmapDecoder^ decoder = gcnew JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource = decoder->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage = gcnew Image();
|
||||
myImage->Source = bitmapSource;
|
||||
myImage->Stretch = Stretch::None;
|
||||
myImage->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet1>
|
||||
|
||||
//<Snippet5>
|
||||
// Open a Uri and decode a JPEG image
|
||||
System::Uri^ myUri = gcnew System::Uri("tulipfarm.jpg", UriKind::RelativeOrAbsolute);
|
||||
JpegBitmapDecoder^ decoder2 = gcnew JpegBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource2 = decoder2->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage2 = gcnew Image();
|
||||
myImage2->Source = bitmapSource2;
|
||||
myImage2->Stretch = Stretch::None;
|
||||
myImage2->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet5>
|
||||
|
||||
// Define a StackPanel to host the decoded JPEG images
|
||||
StackPanel^ myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->Orientation = Orientation::Vertical;
|
||||
myStackPanel->VerticalAlignment = VerticalAlignment::Stretch;
|
||||
myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch;
|
||||
|
||||
// Add the Image and TextBlock to the parent Grid.
|
||||
myStackPanel->Children->Add(myImage);
|
||||
myStackPanel->Children->Add(myImage2);
|
||||
myStackPanel->Children->Add(myTextBlock);
|
||||
|
||||
// Add the StackPanel as the content of the parent window.
|
||||
mySV->Content = myStackPanel;
|
||||
mainWindow->Content = mySV;
|
||||
mainWindow->Show();
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThreadAttribute()]
|
||||
static void Main ()
|
||||
{
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
}
|
||||
;
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
int main(array<System::String ^> ^args)
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{6EFA9BEA-6237-4CCC-BFD8-87EB6499E919}</ProjectGuid>
|
||||
<RootNamespace>SDKSample</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir>.\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="jpegencoderdecoder.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="tulipfarm.jpg" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
After Width: | Height: | Size: 108 KiB |
@@ -0,0 +1,220 @@
|
||||
//Margin_Padding_Alignment_Sample.cpp file
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Shapes;
|
||||
using namespace System::Threading;
|
||||
|
||||
namespace Margin_Padding_Alignment_Sample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private:
|
||||
Border^ myBorder;
|
||||
Grid^ myGrid;
|
||||
Window^ mainWindow;
|
||||
|
||||
protected:
|
||||
virtual void OnStartup (StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// <Snippet4>
|
||||
mainWindow = gcnew Window();
|
||||
|
||||
// <Snippet3>
|
||||
myBorder = gcnew Border();
|
||||
myBorder->Background = Brushes::LightBlue;
|
||||
myBorder->BorderBrush = Brushes::Black;
|
||||
myBorder->BorderThickness = Thickness(2);
|
||||
myBorder->CornerRadius = CornerRadius(45);
|
||||
myBorder->Padding = Thickness(25);
|
||||
//</Snippet3>
|
||||
|
||||
// Define the Grid.
|
||||
myGrid = gcnew Grid();
|
||||
myGrid->Background = Brushes::White;
|
||||
myGrid->ShowGridLines = true;
|
||||
|
||||
// Define the Columns.
|
||||
ColumnDefinition^ myColDef1 = gcnew ColumnDefinition();
|
||||
myColDef1->Width = GridLength(1, GridUnitType::Auto);
|
||||
ColumnDefinition^ myColDef2 = gcnew ColumnDefinition();
|
||||
myColDef2->Width = GridLength(1, GridUnitType::Star);
|
||||
ColumnDefinition^ myColDef3 = gcnew ColumnDefinition();
|
||||
myColDef3->Width = GridLength(1, GridUnitType::Auto);
|
||||
|
||||
// Add the ColumnDefinitions to the Grid.
|
||||
myGrid->ColumnDefinitions->Add(myColDef1);
|
||||
myGrid->ColumnDefinitions->Add(myColDef2);
|
||||
myGrid->ColumnDefinitions->Add(myColDef3);
|
||||
|
||||
// Add the first child StackPanel.
|
||||
StackPanel^ myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myStackPanel->VerticalAlignment = VerticalAlignment::Top;
|
||||
Grid::SetColumn(myStackPanel, 0);
|
||||
Grid::SetRow(myStackPanel, 0);
|
||||
TextBlock^ myTextBlock1 = gcnew TextBlock();
|
||||
myTextBlock1->FontSize = 18;
|
||||
myTextBlock1->HorizontalAlignment = HorizontalAlignment::Center;
|
||||
myTextBlock1->Margin = Thickness(0, 0, 0, 15);
|
||||
myTextBlock1->Text = "StackPanel 1";
|
||||
// <Snippet2>
|
||||
Button^ myButton1 = gcnew Button();
|
||||
myButton1->Margin = Thickness(0, 10, 0, 10);
|
||||
myButton1->Content = "Button 1";
|
||||
Button^ myButton2 = gcnew Button();
|
||||
myButton2->Margin = Thickness(0, 10, 0, 10);
|
||||
myButton2->Content = "Button 2";
|
||||
Button^ myButton3 = gcnew Button();
|
||||
myButton3->Margin = Thickness(0, 10, 0, 10);
|
||||
//</Snippet2>
|
||||
TextBlock^ myTextBlock2 = gcnew TextBlock();
|
||||
myTextBlock2->Text = "ColumnDefinition.Width = \"Auto\"";
|
||||
TextBlock^ myTextBlock3 = gcnew TextBlock();
|
||||
myTextBlock3->Text = "StackPanel.HorizontalAlignment = \"Left\"";
|
||||
TextBlock^ myTextBlock4 = gcnew TextBlock();
|
||||
myTextBlock4->Text = "StackPanel.VerticalAlignment = \"Top\"";
|
||||
TextBlock^ myTextBlock5 = gcnew TextBlock();
|
||||
myTextBlock5->Text = "StackPanel.Orientation = \"Vertical\"";
|
||||
TextBlock^ myTextBlock6 = gcnew TextBlock();
|
||||
myTextBlock6->Text = "Button.Margin = \"1,10,0,10\"";
|
||||
myStackPanel->Children->Add(myTextBlock1);
|
||||
myStackPanel->Children->Add(myButton1);
|
||||
myStackPanel->Children->Add(myButton2);
|
||||
myStackPanel->Children->Add(myButton3);
|
||||
myStackPanel->Children->Add(myTextBlock2);
|
||||
myStackPanel->Children->Add(myTextBlock3);
|
||||
myStackPanel->Children->Add(myTextBlock4);
|
||||
myStackPanel->Children->Add(myTextBlock5);
|
||||
myStackPanel->Children->Add(myTextBlock6);
|
||||
|
||||
// Add the second child StackPanel.
|
||||
StackPanel^ myStackPanel2 = gcnew StackPanel();
|
||||
myStackPanel2->HorizontalAlignment = HorizontalAlignment::Stretch;
|
||||
myStackPanel2->VerticalAlignment = VerticalAlignment::Top;
|
||||
myStackPanel2->Orientation = Orientation::Vertical;
|
||||
Grid::SetColumn(myStackPanel2, 1);
|
||||
Grid::SetRow(myStackPanel2, 0);
|
||||
TextBlock^ myTextBlock7 = gcnew TextBlock();
|
||||
myTextBlock7->FontSize = 18;
|
||||
myTextBlock7->HorizontalAlignment = HorizontalAlignment::Center;
|
||||
myTextBlock7->Margin = Thickness(0, 0, 0, 15);
|
||||
myTextBlock7->Text = "StackPanel 2";
|
||||
Button^ myButton4 = gcnew Button();
|
||||
myButton4->Margin = Thickness(10, 0, 10, 0);
|
||||
myButton4->Content = "Button 4";
|
||||
Button^ myButton5 = gcnew Button();
|
||||
myButton5->Margin = Thickness(10, 0, 10, 0);
|
||||
myButton5->Content = "Button 5";
|
||||
Button^ myButton6 = gcnew Button();
|
||||
myButton6->Margin = Thickness(10, 0, 10, 0);
|
||||
myButton6->Content = "Button 6";
|
||||
TextBlock^ myTextBlock8 = gcnew TextBlock();
|
||||
myTextBlock8->HorizontalAlignment = HorizontalAlignment::Center;
|
||||
myTextBlock8->Text = "ColumnDefinition.Width = \"*\"";
|
||||
TextBlock^ myTextBlock9 = gcnew TextBlock();
|
||||
myTextBlock9->HorizontalAlignment = HorizontalAlignment::Center;
|
||||
myTextBlock9->Text = "StackPanel.HorizontalAlignment = \"Stretch\"";
|
||||
TextBlock^ myTextBlock10 = gcnew TextBlock();
|
||||
myTextBlock10->HorizontalAlignment = HorizontalAlignment::Center;
|
||||
myTextBlock10->Text = "StackPanel.VerticalAlignment = \"Top\"";
|
||||
TextBlock^ myTextBlock11 = gcnew TextBlock();
|
||||
myTextBlock11->HorizontalAlignment = HorizontalAlignment::Center;
|
||||
myTextBlock11->Text = "StackPanel.Orientation = \"Horizontal\"";
|
||||
TextBlock^ myTextBlock12 = gcnew TextBlock();
|
||||
myTextBlock12->HorizontalAlignment = HorizontalAlignment::Center;
|
||||
myTextBlock12->Text = "Button.Margin = \"10,0,10,0\"";
|
||||
myStackPanel2->Children->Add(myTextBlock7);
|
||||
myStackPanel2->Children->Add(myButton4);
|
||||
myStackPanel2->Children->Add(myButton5);
|
||||
myStackPanel2->Children->Add(myButton6);
|
||||
myStackPanel2->Children->Add(myTextBlock8);
|
||||
myStackPanel2->Children->Add(myTextBlock9);
|
||||
myStackPanel2->Children->Add(myTextBlock10);
|
||||
myStackPanel2->Children->Add(myTextBlock11);
|
||||
myStackPanel2->Children->Add(myTextBlock12);
|
||||
|
||||
// Add the final child StackPanel.
|
||||
StackPanel^ myStackPanel3 = gcnew StackPanel();
|
||||
myStackPanel3->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myStackPanel3->VerticalAlignment = VerticalAlignment::Top;
|
||||
Grid::SetColumn(myStackPanel3, 2);
|
||||
Grid::SetRow(myStackPanel3, 0);
|
||||
TextBlock^ myTextBlock13 = gcnew TextBlock();
|
||||
myTextBlock13->FontSize = 18;
|
||||
myTextBlock13->HorizontalAlignment = HorizontalAlignment::Center;
|
||||
myTextBlock13->Margin = Thickness(0, 0, 0, 15);
|
||||
myTextBlock13->Text = "StackPanel 3";
|
||||
// <Snippet1>
|
||||
Button^ myButton7 = gcnew Button();
|
||||
myButton7->Margin = Thickness(10);
|
||||
myButton7->Content = "Button 7";
|
||||
Button^ myButton8 = gcnew Button();
|
||||
myButton8->Margin = Thickness(10);
|
||||
myButton8->Content = "Button 8";
|
||||
Button^ myButton9 = gcnew Button();
|
||||
myButton9->Margin = Thickness(10);
|
||||
myButton9->Content = "Button 9";
|
||||
//</Snippet1>
|
||||
TextBlock^ myTextBlock14 = gcnew TextBlock();
|
||||
myTextBlock14->Text = "ColumnDefinition.Width = \"Auto\"";
|
||||
TextBlock^ myTextBlock15 = gcnew TextBlock();
|
||||
myTextBlock15->Text = "StackPanel.HorizontalAlignment = \"Left\"";
|
||||
TextBlock^ myTextBlock16 = gcnew TextBlock();
|
||||
myTextBlock16->Text = "StackPanel.VerticalAlignment = \"Top\"";
|
||||
TextBlock^ myTextBlock17 = gcnew TextBlock();
|
||||
myTextBlock17->Text = "StackPanel.Orientation = \"Vertical\"";
|
||||
TextBlock^ myTextBlock18 = gcnew TextBlock();
|
||||
myTextBlock18->Text = "Button.Margin = \"10\"";
|
||||
myStackPanel3->Children->Add(myTextBlock13);
|
||||
myStackPanel3->Children->Add(myButton7);
|
||||
myStackPanel3->Children->Add(myButton8);
|
||||
myStackPanel3->Children->Add(myButton9);
|
||||
myStackPanel3->Children->Add(myTextBlock14);
|
||||
myStackPanel3->Children->Add(myTextBlock15);
|
||||
myStackPanel3->Children->Add(myTextBlock16);
|
||||
myStackPanel3->Children->Add(myTextBlock17);
|
||||
myStackPanel3->Children->Add(myTextBlock18);
|
||||
|
||||
// Add child content to the parent Grid.
|
||||
myGrid->Children->Add(myStackPanel);
|
||||
myGrid->Children->Add(myStackPanel2);
|
||||
myGrid->Children->Add(myStackPanel3);
|
||||
|
||||
// Add the Grid as the lone child of the Border.
|
||||
myBorder->Child = myGrid;
|
||||
|
||||
// Add the Border to the Window as Content and show the Window.
|
||||
mainWindow->Content = myBorder;
|
||||
mainWindow->Title = "Margin, Padding, and Alignment Sample";
|
||||
mainWindow->Show();
|
||||
//</Snippet4>
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
Margin_Padding_Alignment_Sample::app^ app = gcnew Margin_Padding_Alignment_Sample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return Margin_Padding_Alignment_Sample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21230.0</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Margin_Padding_Alignment_Sample.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,101 @@
|
||||
//PlotPanel.cpp file
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Shapes;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Threading;
|
||||
|
||||
namespace PlotPanel {
|
||||
|
||||
public ref class app : System::Windows::Application {
|
||||
|
||||
// <Snippet1>
|
||||
public:
|
||||
ref class PlotPanel : Panel {
|
||||
|
||||
public:
|
||||
PlotPanel () {};
|
||||
|
||||
protected:
|
||||
// Override the default Measure method of Panel
|
||||
// <Snippet2>
|
||||
virtual Size MeasureOverride(Size availableSize) override
|
||||
{
|
||||
Size^ panelDesiredSize = gcnew Size();
|
||||
|
||||
// In our example, we just have one child.
|
||||
// Report that our panel requires just the size of its only child.
|
||||
for each (UIElement^ child in InternalChildren)
|
||||
{
|
||||
child->Measure(availableSize);
|
||||
panelDesiredSize = child->DesiredSize;
|
||||
}
|
||||
return *panelDesiredSize ;
|
||||
}
|
||||
//</Snippet2>
|
||||
|
||||
protected:
|
||||
virtual System::Windows::Size ArrangeOverride (Size finalSize) override
|
||||
{
|
||||
for each (UIElement^ child in InternalChildren)
|
||||
{
|
||||
double x = 50;
|
||||
double y = 50;
|
||||
child->Arrange(Rect(Point(x, y), child->DesiredSize));
|
||||
}
|
||||
return finalSize;
|
||||
};
|
||||
};
|
||||
//</Snippet1>
|
||||
|
||||
private:
|
||||
PlotPanel^ plot1;
|
||||
Window^ mainWindow;
|
||||
Shapes::Rectangle^ rect1;
|
||||
|
||||
protected:
|
||||
virtual void OnStartup (StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// Create the application's main window
|
||||
|
||||
mainWindow = gcnew Window();
|
||||
plot1 = gcnew PlotPanel();
|
||||
plot1->Background = Brushes::White;
|
||||
|
||||
rect1 = gcnew Shapes::Rectangle();
|
||||
rect1->Fill = Brushes::CornflowerBlue;
|
||||
rect1->Width = 200;
|
||||
rect1->Height = 200;
|
||||
mainWindow->Content = plot1;
|
||||
plot1->Children->Add(rect1);
|
||||
mainWindow->Title = "Custom Panel Sample";
|
||||
mainWindow->Show();
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
PlotPanel::app^ app = gcnew PlotPanel::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return PlotPanel::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="PlotPanel.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,130 @@
|
||||
//PngEncoderDecoder.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::IO;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Imaging;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Security;
|
||||
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private: Window^ mainWindow;
|
||||
|
||||
protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private: void CreateAndShowMainWindow ()
|
||||
{
|
||||
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew System::Windows::Window();
|
||||
mainWindow->Title = "PNG Imaging Sample";
|
||||
ScrollViewer^ mySV = gcnew ScrollViewer();
|
||||
|
||||
//<Snippet4>
|
||||
int width = 128;
|
||||
int height = 128;
|
||||
int stride = width;
|
||||
array<System::Byte>^ pixels = gcnew array<System::Byte>(height * stride);
|
||||
|
||||
// Define the image palette
|
||||
BitmapPalette^ myPalette = BitmapPalettes::Halftone256;
|
||||
|
||||
// Creates a new empty image with the pre-defined palette
|
||||
|
||||
//<Snippet2>
|
||||
BitmapSource^ image = BitmapSource::Create(width,
|
||||
height,
|
||||
96,
|
||||
96,
|
||||
PixelFormats::Indexed8,
|
||||
myPalette,
|
||||
pixels,
|
||||
stride);
|
||||
//</Snippet2>
|
||||
|
||||
//<Snippet3>
|
||||
FileStream^ stream = gcnew FileStream("new.png", FileMode::Create);
|
||||
PngBitmapEncoder^ encoder = gcnew PngBitmapEncoder();
|
||||
TextBlock^ myTextBlock = gcnew TextBlock();
|
||||
myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString();
|
||||
encoder->Interlace = PngInterlaceOption::On;
|
||||
encoder->Frames->Add(BitmapFrame::Create(image));
|
||||
encoder->Save(stream);
|
||||
//</Snippet3>
|
||||
|
||||
//</Snippet4>
|
||||
|
||||
//<Snippet1>
|
||||
|
||||
// Open a Stream and decode a PNG image
|
||||
Stream^ imageStreamSource = gcnew FileStream("smiley.png", FileMode::Open, FileAccess::Read, FileShare::Read);
|
||||
PngBitmapDecoder^ decoder = gcnew PngBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource = decoder->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage = gcnew Image();
|
||||
myImage->Source = bitmapSource;
|
||||
myImage->Stretch = Stretch::None;
|
||||
myImage->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet1>
|
||||
|
||||
//<Snippet5>
|
||||
|
||||
// Open a Uri and decode a PNG image
|
||||
System::Uri^ myUri = gcnew System::Uri("smiley.png", UriKind::RelativeOrAbsolute);
|
||||
PngBitmapDecoder^ decoder2 = gcnew PngBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource2 = decoder2->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage2 = gcnew Image();
|
||||
myImage2->Source = bitmapSource2;
|
||||
myImage2->Stretch = Stretch::None;
|
||||
myImage2->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet5>
|
||||
|
||||
// Define a StackPanel to host the decoded PNG images
|
||||
StackPanel^ myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->Orientation = Orientation::Vertical;
|
||||
myStackPanel->VerticalAlignment = VerticalAlignment::Stretch;
|
||||
myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch;
|
||||
|
||||
// Add the Image and TextBlock to the parent Grid
|
||||
myStackPanel->Children->Add(myImage);
|
||||
myStackPanel->Children->Add(myImage2);
|
||||
myStackPanel->Children->Add(myTextBlock);
|
||||
|
||||
// Add the StackPanel as the Content of the Parent Window Object
|
||||
mySV->Content = myStackPanel;
|
||||
mainWindow->Content = mySV;
|
||||
mainWindow->Show();
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main () {
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir>.\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="PngEncoderDecoder.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="smiley.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,213 @@
|
||||
//Program.cpp file
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Text;
|
||||
using namespace System::Printing;
|
||||
using namespace System::Collections;
|
||||
using namespace System::IO;
|
||||
|
||||
namespace PrinterStatusSurvey {
|
||||
|
||||
private ref class TroubleSpotter {
|
||||
|
||||
// <SnippetSpotTroubleUsingQueueProperties>
|
||||
internal:
|
||||
// Check for possible trouble states of a printer using its properties
|
||||
static void SpotTroubleUsingProperties (System::String^% statusReport, System::Printing::PrintQueue^ pq)
|
||||
{
|
||||
if (pq->HasPaperProblem)
|
||||
{
|
||||
statusReport = statusReport + "Has a paper problem. ";
|
||||
}
|
||||
if (!(pq->HasToner))
|
||||
{
|
||||
statusReport = statusReport + "Is out of toner. ";
|
||||
}
|
||||
if (pq->IsDoorOpened)
|
||||
{
|
||||
statusReport = statusReport + "Has an open door. ";
|
||||
}
|
||||
if (pq->IsInError)
|
||||
{
|
||||
statusReport = statusReport + "Is in an error state. ";
|
||||
}
|
||||
if (pq->IsNotAvailable)
|
||||
{
|
||||
statusReport = statusReport + "Is not available. ";
|
||||
}
|
||||
if (pq->IsOffline)
|
||||
{
|
||||
statusReport = statusReport + "Is off line. ";
|
||||
}
|
||||
if (pq->IsOutOfMemory)
|
||||
{
|
||||
statusReport = statusReport + "Is out of memory. ";
|
||||
}
|
||||
if (pq->IsOutOfPaper)
|
||||
{
|
||||
statusReport = statusReport + "Is out of paper. ";
|
||||
}
|
||||
if (pq->IsOutputBinFull)
|
||||
{
|
||||
statusReport = statusReport + "Has a full output bin. ";
|
||||
}
|
||||
if (pq->IsPaperJammed)
|
||||
{
|
||||
statusReport = statusReport + "Has a paper jam. ";
|
||||
}
|
||||
if (pq->IsPaused)
|
||||
{
|
||||
statusReport = statusReport + "Is paused. ";
|
||||
}
|
||||
if (pq->IsTonerLow)
|
||||
{
|
||||
statusReport = statusReport + "Is low on toner. ";
|
||||
}
|
||||
if (pq->NeedUserIntervention)
|
||||
{
|
||||
statusReport = statusReport + "Needs user intervention. ";
|
||||
}
|
||||
|
||||
// Check if queue is even available at this time of day
|
||||
// The following method is defined in the complete example.
|
||||
ReportAvailabilityAtThisTime(statusReport, pq);
|
||||
};
|
||||
// </SnippetSpotTroubleUsingQueueProperties>
|
||||
|
||||
// <SnippetSpotTroubleUsingQueueAttributes>
|
||||
internal:
|
||||
// Check for possible trouble states of a printer using the flags of the QueueStatus property
|
||||
static void SpotTroubleUsingQueueAttributes (System::String^% statusReport, System::Printing::PrintQueue^ pq)
|
||||
{
|
||||
if ((pq->QueueStatus & PrintQueueStatus::PaperProblem) == PrintQueueStatus::PaperProblem)
|
||||
{
|
||||
statusReport = statusReport + "Has a paper problem. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::NoToner) == PrintQueueStatus::NoToner)
|
||||
{
|
||||
statusReport = statusReport + "Is out of toner. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::DoorOpen) == PrintQueueStatus::DoorOpen)
|
||||
{
|
||||
statusReport = statusReport + "Has an open door. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::Error) == PrintQueueStatus::Error)
|
||||
{
|
||||
statusReport = statusReport + "Is in an error state. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::NotAvailable) == PrintQueueStatus::NotAvailable)
|
||||
{
|
||||
statusReport = statusReport + "Is not available. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::Offline) == PrintQueueStatus::Offline)
|
||||
{
|
||||
statusReport = statusReport + "Is off line. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::OutOfMemory) == PrintQueueStatus::OutOfMemory)
|
||||
{
|
||||
statusReport = statusReport + "Is out of memory. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::PaperOut) == PrintQueueStatus::PaperOut)
|
||||
{
|
||||
statusReport = statusReport + "Is out of paper. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::OutputBinFull) == PrintQueueStatus::OutputBinFull)
|
||||
{
|
||||
statusReport = statusReport + "Has a full output bin. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::PaperJam) == PrintQueueStatus::PaperJam)
|
||||
{
|
||||
statusReport = statusReport + "Has a paper jam. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::Paused) == PrintQueueStatus::Paused)
|
||||
{
|
||||
statusReport = statusReport + "Is paused. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::TonerLow) == PrintQueueStatus::TonerLow)
|
||||
{
|
||||
statusReport = statusReport + "Is low on toner. ";
|
||||
}
|
||||
if ((pq->QueueStatus & PrintQueueStatus::UserIntervention) == PrintQueueStatus::UserIntervention)
|
||||
{
|
||||
statusReport = statusReport + "Needs user intervention. ";
|
||||
}
|
||||
|
||||
// Check if queue is even available at this time of day
|
||||
// The method below is defined in the complete example.
|
||||
ReportAvailabilityAtThisTime(statusReport, pq);
|
||||
};
|
||||
// </SnippetSpotTroubleUsingQueueAttributes>
|
||||
|
||||
// <SnippetUsingStartAndUntilTimes>
|
||||
private:
|
||||
static void ReportAvailabilityAtThisTime (System::String^% statusReport, System::Printing::PrintQueue^ pq)
|
||||
{
|
||||
if (pq->StartTimeOfDay != pq->UntilTimeOfDay)
|
||||
{
|
||||
System::DateTime utcNow = DateTime::UtcNow;
|
||||
System::Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;
|
||||
|
||||
// If now is not within the range of available times . . .
|
||||
if (!((pq->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < pq->UntilTimeOfDay)))
|
||||
{
|
||||
statusReport = statusReport + " Is not available at this time of day. ";
|
||||
}
|
||||
}
|
||||
};
|
||||
// </SnippetUsingStartAndUntilTimes>
|
||||
};
|
||||
|
||||
private ref class Program {
|
||||
|
||||
public:
|
||||
static void Main (array<System::String^>^ args)
|
||||
{
|
||||
// Obtain a list of print servers
|
||||
Console::Write("Enter path and file name of CRLF-delimited list of print servers: ");
|
||||
System::String^ pathToListOfPrintServers = Console::ReadLine();
|
||||
System::IO::StreamReader^ fileOfPrintServers = gcnew System::IO::StreamReader(pathToListOfPrintServers);
|
||||
|
||||
// Prompt user to determine the method of reading queue status that will be used
|
||||
Console::Write("Enter \"y\" to check queues using their QueueStatus attributes.\nOtherwise, press Return and they will be checked using their specific properties: ");
|
||||
System::String^ useAttributesResponse = Console::ReadLine();
|
||||
|
||||
//<SnippetSurveyQueues>
|
||||
// Survey queue status for every queue on every print server
|
||||
System::String^ line;
|
||||
System::String^ statusReport = "\n\nAny problem states are indicated below:\n\n";
|
||||
while ((line = fileOfPrintServers->ReadLine()) != nullptr)
|
||||
{
|
||||
System::Printing::PrintServer^ myPS = gcnew System::Printing::PrintServer(line, PrintSystemDesiredAccess::AdministrateServer);
|
||||
System::Printing::PrintQueueCollection^ myPrintQueues = myPS->GetPrintQueues();
|
||||
statusReport = statusReport + "\n" + line;
|
||||
for each (System::Printing::PrintQueue^ pq in myPrintQueues)
|
||||
{
|
||||
pq->Refresh();
|
||||
statusReport = statusReport + "\n\t" + pq->Name + ":";
|
||||
if (useAttributesResponse == "y")
|
||||
{
|
||||
TroubleSpotter::SpotTroubleUsingQueueAttributes(statusReport, pq);
|
||||
// TroubleSpotter class is defined in the complete example.
|
||||
} else
|
||||
{
|
||||
TroubleSpotter::SpotTroubleUsingProperties(statusReport, pq);
|
||||
}
|
||||
}
|
||||
}
|
||||
fileOfPrintServers->Close();
|
||||
Console::WriteLine(statusReport);
|
||||
Console::WriteLine("\nPress Return to continue.");
|
||||
Console::ReadLine();
|
||||
//</SnippetSurveyQueues>
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
int main (array<System::String^>^ args)
|
||||
{
|
||||
PrinterStatusSurvey::Program::Main(args);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21208.0</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System.Printing">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Program.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,86 @@
|
||||
//ScrollViewer_wcp.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Shapes;
|
||||
using namespace System::Threading;
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private:
|
||||
ScrollViewer^ myScrollViewer;
|
||||
StackPanel^ myStackPanel;
|
||||
Window^ mainWindow;
|
||||
|
||||
protected:
|
||||
virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// <Snippet1>
|
||||
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew System::Windows::Window();
|
||||
mainWindow->Title = "ScrollViewer Sample";
|
||||
|
||||
// Define a ScrollViewer
|
||||
myScrollViewer = gcnew ScrollViewer();
|
||||
myScrollViewer->HorizontalScrollBarVisibility = ScrollBarVisibility::Auto;
|
||||
|
||||
// Add Layout control
|
||||
myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myStackPanel->VerticalAlignment = VerticalAlignment::Top;
|
||||
|
||||
TextBlock^ myTextBlock = gcnew TextBlock();
|
||||
myTextBlock->TextWrapping = TextWrapping::Wrap;
|
||||
myTextBlock->Margin = System::Windows::Thickness(0, 0, 0, 20);
|
||||
myTextBlock->Text = "Scrolling is enabled when it is necessary. Resize the Window, making it larger and smaller.";
|
||||
|
||||
Rectangle^ myRectangle = gcnew Rectangle();
|
||||
myRectangle->Fill = Brushes::Red;
|
||||
myRectangle->Width = 500;
|
||||
myRectangle->Height = 500;
|
||||
|
||||
// Add child elements to the parent StackPanel
|
||||
myStackPanel->Children->Add(myTextBlock);
|
||||
myStackPanel->Children->Add(myRectangle);
|
||||
|
||||
// Add the StackPanel as the lone Child of the Border
|
||||
myScrollViewer->Content = myStackPanel;
|
||||
|
||||
// Add the Border as the Content of the Parent Window Object
|
||||
mainWindow->Content = myScrollViewer;
|
||||
mainWindow->Show();
|
||||
|
||||
//</Snippet1>
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>ScrollViewer</ProjectName>
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30109.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ScrollViewer_wcp.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,264 @@
|
||||
//ShapesProcedural.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Shapes;
|
||||
using namespace System::Threading;
|
||||
|
||||
namespace ShapesProcedural {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private:
|
||||
Border^ myBorder;
|
||||
Rectangle^ myRect;
|
||||
Ellipse^ myEllipse;
|
||||
Line^ myLine;
|
||||
Path^ myPath;
|
||||
Polygon^ myPolygon;
|
||||
Polyline^ myPolyline;
|
||||
Grid^ myGrid;
|
||||
TextBlock^ myTextBlock;
|
||||
ColumnDefinition^ myColDef1;
|
||||
ColumnDefinition^ myColDef2;
|
||||
RowDefinition^ myRowDef;
|
||||
RowDefinition^ myRowDef1;
|
||||
RowDefinition^ myRowDef2;
|
||||
RowDefinition^ myRowDef3;
|
||||
RowDefinition^ myRowDef4;
|
||||
RowDefinition^ myRowDef5;
|
||||
RowDefinition^ myRowDef6;
|
||||
Window^ myWindow;
|
||||
|
||||
protected: virtual void OnStartup (StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private: void CreateAndShowMainWindow ()
|
||||
{
|
||||
// Create the application's main window
|
||||
myWindow = gcnew Window();
|
||||
|
||||
// Add a Border
|
||||
myBorder = gcnew Border();
|
||||
myBorder->BorderBrush = Brushes::Black;
|
||||
myBorder->BorderThickness = Thickness(2);
|
||||
myBorder->Width = 400;
|
||||
myBorder->Height = 600;
|
||||
myBorder->Padding = Thickness(15);
|
||||
myBorder->Background = Brushes::White;
|
||||
|
||||
// Create a Grid to host the Shapes
|
||||
myGrid = gcnew Grid();
|
||||
myGrid->Margin = Thickness(15);
|
||||
myColDef1 = gcnew ColumnDefinition();
|
||||
myColDef1->Width = GridLength(125);
|
||||
myColDef2 = gcnew ColumnDefinition();
|
||||
myColDef2->Width = GridLength(1, GridUnitType::Star);
|
||||
myGrid->ColumnDefinitions->Add(myColDef1);
|
||||
myGrid->ColumnDefinitions->Add(myColDef2);
|
||||
myRowDef = gcnew RowDefinition();
|
||||
myRowDef1 = gcnew RowDefinition();
|
||||
myRowDef2 = gcnew RowDefinition();
|
||||
myRowDef3 = gcnew RowDefinition();
|
||||
myRowDef4 = gcnew RowDefinition();
|
||||
myRowDef5 = gcnew RowDefinition();
|
||||
myRowDef6 = gcnew RowDefinition();
|
||||
myGrid->RowDefinitions->Add(myRowDef);
|
||||
myGrid->RowDefinitions->Add(myRowDef1);
|
||||
myGrid->RowDefinitions->Add(myRowDef2);
|
||||
myGrid->RowDefinitions->Add(myRowDef3);
|
||||
myGrid->RowDefinitions->Add(myRowDef4);
|
||||
myGrid->RowDefinitions->Add(myRowDef5);
|
||||
myGrid->RowDefinitions->Add(myRowDef6);
|
||||
myTextBlock = gcnew TextBlock();
|
||||
myTextBlock->FontSize = 20;
|
||||
myTextBlock->Text = "WPF Shapes Gallery";
|
||||
myTextBlock->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myTextBlock->VerticalAlignment = VerticalAlignment::Center;
|
||||
myGrid->Children->Add(myTextBlock);
|
||||
Grid::SetRow(myTextBlock, 0);
|
||||
Grid::SetColumnSpan(myTextBlock, 2);
|
||||
|
||||
//<SnippetShapesProceduralRectangle>
|
||||
|
||||
// Add a Rectangle Element
|
||||
myRect = gcnew Rectangle();
|
||||
myRect->Stroke = Brushes::Black;
|
||||
myRect->Fill = Brushes::SkyBlue;
|
||||
myRect->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myRect->VerticalAlignment = VerticalAlignment::Center;
|
||||
myRect->Height = 50;
|
||||
myRect->Width = 50;
|
||||
myGrid->Children->Add(myRect);
|
||||
//</SnippetShapesProceduralRectangle>
|
||||
Grid::SetRow(myRect, 1);
|
||||
Grid::SetColumn(myRect, 0);
|
||||
TextBlock^ myTextBlock1 = gcnew TextBlock();
|
||||
myTextBlock1->FontSize = 14;
|
||||
myTextBlock1->Text = "A Rectangle Element";
|
||||
myTextBlock1->VerticalAlignment = VerticalAlignment::Center;
|
||||
myGrid->Children->Add(myTextBlock1);
|
||||
Grid::SetRow(myTextBlock1, 1);
|
||||
Grid::SetColumn(myTextBlock1, 1);
|
||||
|
||||
//<SnippetShapesProceduralEllipse>
|
||||
|
||||
// Add an Ellipse Element
|
||||
myEllipse = gcnew Ellipse();
|
||||
myEllipse->Stroke = Brushes::Black;
|
||||
myEllipse->Fill = Brushes::DarkBlue;
|
||||
myEllipse->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myEllipse->VerticalAlignment = VerticalAlignment::Center;
|
||||
myEllipse->Width = 50;
|
||||
myEllipse->Height = 75;
|
||||
myGrid->Children->Add(myEllipse);
|
||||
//</SnippetShapesProceduralEllipse>
|
||||
Grid::SetRow(myEllipse, 2);
|
||||
Grid::SetColumn(myEllipse, 0);
|
||||
TextBlock^ myTextBlock2 = gcnew TextBlock();
|
||||
myTextBlock2->FontSize = 14;
|
||||
myTextBlock2->Text = "An Ellipse Element";
|
||||
myTextBlock2->VerticalAlignment = VerticalAlignment::Center;
|
||||
myGrid->Children->Add(myTextBlock2);
|
||||
Grid::SetRow(myTextBlock2, 2);
|
||||
Grid::SetColumn(myTextBlock2, 1);
|
||||
|
||||
//<SnippetShapesProceduralLine>
|
||||
|
||||
// Add a Line Element
|
||||
myLine = gcnew Line();
|
||||
myLine->Stroke = Brushes::LightSteelBlue;
|
||||
myLine->X1 = 1;
|
||||
myLine->X2 = 50;
|
||||
myLine->Y1 = 1;
|
||||
myLine->Y2 = 50;
|
||||
myLine->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myLine->VerticalAlignment = VerticalAlignment::Center;
|
||||
myLine->StrokeThickness = 2;
|
||||
myGrid->Children->Add(myLine);
|
||||
//</SnippetShapesProceduralLine>
|
||||
Grid::SetRow(myLine, 3);
|
||||
Grid::SetColumn(myLine, 0);
|
||||
TextBlock^ myTextBlock3 = gcnew TextBlock();
|
||||
myTextBlock3->FontSize = 14;
|
||||
myTextBlock3->Text = "A Line Element";
|
||||
myTextBlock3->VerticalAlignment = VerticalAlignment::Center;
|
||||
myGrid->Children->Add(myTextBlock3);
|
||||
Grid::SetRow(myTextBlock3, 3);
|
||||
Grid::SetColumn(myTextBlock3, 1);
|
||||
|
||||
//<SnippetShapesProceduralPath>
|
||||
|
||||
//Add the Path Element
|
||||
myPath = gcnew Path();
|
||||
myPath->Stroke = Brushes::Black;
|
||||
myPath->Fill = Brushes::MediumSlateBlue;
|
||||
myPath->StrokeThickness = 4;
|
||||
myPath->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myPath->VerticalAlignment = VerticalAlignment::Center;
|
||||
EllipseGeometry^ myEllipseGeometry = gcnew EllipseGeometry();
|
||||
myEllipseGeometry->Center = Point(50, 50);
|
||||
myEllipseGeometry->RadiusX = 25;
|
||||
myEllipseGeometry->RadiusY = 25;
|
||||
myPath->Data = myEllipseGeometry;
|
||||
myGrid->Children->Add(myPath);
|
||||
//</SnippetShapesProceduralPath>
|
||||
Grid::SetRow(myPath, 4);
|
||||
Grid::SetColumn(myPath, 0);
|
||||
TextBlock^ myTextBlock4 = gcnew TextBlock();
|
||||
myTextBlock4->FontSize = 14;
|
||||
myTextBlock4->Text = "A Path Element";
|
||||
myTextBlock4->VerticalAlignment = VerticalAlignment::Center;
|
||||
myGrid->Children->Add(myTextBlock4);
|
||||
Grid::SetRow(myTextBlock4, 4);
|
||||
Grid::SetColumn(myTextBlock4, 1);
|
||||
|
||||
//<SnippetShapesProceduralPolygon>
|
||||
|
||||
//Add the Polygon Element
|
||||
myPolygon = gcnew Polygon();
|
||||
myPolygon->Stroke = Brushes::Black;
|
||||
myPolygon->Fill = Brushes::LightSeaGreen;
|
||||
myPolygon->StrokeThickness = 2;
|
||||
myPolygon->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myPolygon->VerticalAlignment = VerticalAlignment::Center;
|
||||
Point Point1 = Point(1, 50);
|
||||
Point Point2 = Point(10, 80);
|
||||
Point Point3 = Point(50, 50);
|
||||
PointCollection^ myPointCollection = gcnew PointCollection();
|
||||
myPointCollection->Add(Point1);
|
||||
myPointCollection->Add(Point2);
|
||||
myPointCollection->Add(Point3);
|
||||
myPolygon->Points = myPointCollection;
|
||||
myGrid->Children->Add(myPolygon);
|
||||
//</SnippetShapesProceduralPolygon>
|
||||
Grid::SetRow(myPolygon, 5);
|
||||
Grid::SetColumn(myPolygon, 0);
|
||||
TextBlock^ myTextBlock5 = gcnew TextBlock();
|
||||
myTextBlock5->Text = "A Polygon Element";
|
||||
myTextBlock5->FontSize = 14;
|
||||
myTextBlock5->VerticalAlignment = VerticalAlignment::Center;
|
||||
myGrid->Children->Add(myTextBlock5);
|
||||
Grid::SetRow(myTextBlock5, 5);
|
||||
Grid::SetColumn(myTextBlock5, 1);
|
||||
|
||||
//<SnippetShapesProceduralPolyline>
|
||||
|
||||
// Add the Polyline Element
|
||||
myPolyline = gcnew Polyline();
|
||||
myPolyline->Stroke = Brushes::SlateGray;
|
||||
myPolyline->StrokeThickness = 2;
|
||||
myPolyline->FillRule = FillRule::EvenOdd;
|
||||
Point Point4 = Point(1, 50);
|
||||
Point Point5 = Point(10, 80);
|
||||
Point Point6 = Point(20, 40);
|
||||
PointCollection^ myPointCollection2 = gcnew PointCollection();
|
||||
myPointCollection2->Add(Point4);
|
||||
myPointCollection2->Add(Point5);
|
||||
myPointCollection2->Add(Point6);
|
||||
myPolyline->Points = myPointCollection2;
|
||||
myGrid->Children->Add(myPolyline);
|
||||
//</SnippetShapesProceduralPolyline>
|
||||
Grid::SetRow(myPolyline, 6);
|
||||
Grid::SetColumn(myPolyline, 0);
|
||||
TextBlock^ myTextBlock6 = gcnew TextBlock();
|
||||
myTextBlock6->FontSize = 14;
|
||||
myTextBlock6->Text = "A Polyline Element";
|
||||
myTextBlock6->VerticalAlignment = VerticalAlignment::Center;
|
||||
myGrid->Children->Add(myTextBlock6);
|
||||
Grid::SetRow(myTextBlock6, 6);
|
||||
Grid::SetColumn(myTextBlock6, 1);
|
||||
|
||||
// Add the Grid to the Window as Content and show the Window
|
||||
myBorder->Child = myGrid;
|
||||
myWindow->Content = myBorder;
|
||||
myWindow->Background = Brushes::LightSlateGray;
|
||||
myWindow->Title = "Shapes Sample";
|
||||
myWindow->Show();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
ShapesProcedural::app^ app = gcnew ShapesProcedural::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return ShapesProcedural::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21230.0</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ShapesProcedural.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,141 @@
|
||||
//StackPanel_Ovw_Sample4.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Imaging;
|
||||
using namespace System::Threading;
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private:
|
||||
Border^ myBorder;
|
||||
Grid^ myGrid;
|
||||
StackPanel^ myStackPanel;
|
||||
DockPanel^ myDockPanel;
|
||||
System::Windows::Window^ mainWindow;
|
||||
|
||||
protected:
|
||||
virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// <Snippet1>
|
||||
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew Window();
|
||||
mainWindow->Title = "StackPanel vs. DockPanel";
|
||||
|
||||
// Add root Grid
|
||||
myGrid = gcnew Grid();
|
||||
myGrid->Width = 175;
|
||||
myGrid->Height = 150;
|
||||
RowDefinition^ myRowDef1 = gcnew RowDefinition();
|
||||
RowDefinition^ myRowDef2 = gcnew RowDefinition();
|
||||
myGrid->RowDefinitions->Add(myRowDef1);
|
||||
myGrid->RowDefinitions->Add(myRowDef2);
|
||||
|
||||
// Define the DockPanel
|
||||
myDockPanel = gcnew DockPanel();
|
||||
Grid::SetRow(myDockPanel, 0);
|
||||
|
||||
//Define an Image and Source
|
||||
Image^ myImage = gcnew Image();
|
||||
BitmapImage^ bi = gcnew BitmapImage();
|
||||
bi->BeginInit();
|
||||
bi->UriSource = gcnew System::Uri("smiley_stackpanel.png", UriKind::Relative);
|
||||
bi->EndInit();
|
||||
myImage->Source = bi;
|
||||
|
||||
Image^ myImage2 = gcnew Image();
|
||||
BitmapImage^ bi2 = gcnew BitmapImage();
|
||||
bi2->BeginInit();
|
||||
bi2->UriSource = gcnew System::Uri("smiley_stackpanel.png", UriKind::Relative);
|
||||
bi2->EndInit();
|
||||
myImage2->Source = bi2;
|
||||
|
||||
// <Snippet3>
|
||||
Image^ myImage3 = gcnew Image();
|
||||
BitmapImage^ bi3 = gcnew BitmapImage();
|
||||
bi3->BeginInit();
|
||||
bi3->UriSource = gcnew System::Uri("smiley_stackpanel.PNG", UriKind::Relative);
|
||||
bi3->EndInit();
|
||||
myImage3->Stretch = Stretch::Fill;
|
||||
myImage3->Source = bi3;
|
||||
//</Snippet3>
|
||||
|
||||
// Add the images to the parent DockPanel
|
||||
myDockPanel->Children->Add(myImage);
|
||||
myDockPanel->Children->Add(myImage2);
|
||||
myDockPanel->Children->Add(myImage3);
|
||||
|
||||
//Define a StackPanel
|
||||
myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->Orientation = Orientation::Horizontal;
|
||||
Grid::SetRow(myStackPanel, 1);
|
||||
|
||||
Image^ myImage4 = gcnew Image();
|
||||
BitmapImage^ bi4 = gcnew BitmapImage();
|
||||
bi4->BeginInit();
|
||||
bi4->UriSource = gcnew System::Uri("smiley_stackpanel.png", UriKind::Relative);
|
||||
bi4->EndInit();
|
||||
myImage4->Source = bi4;
|
||||
|
||||
Image^ myImage5 = gcnew Image();
|
||||
BitmapImage^ bi5 = gcnew BitmapImage();
|
||||
bi5->BeginInit();
|
||||
bi5->UriSource = gcnew System::Uri("smiley_stackpanel.png", UriKind::Relative);
|
||||
bi5->EndInit();
|
||||
myImage5->Source = bi5;
|
||||
|
||||
Image^ myImage6 = gcnew Image();
|
||||
BitmapImage^ bi6 = gcnew BitmapImage();
|
||||
bi6->BeginInit();
|
||||
bi6->UriSource = gcnew System::Uri("smiley_stackpanel.PNG", UriKind::Relative);
|
||||
bi6->EndInit();
|
||||
myImage6->Stretch = Stretch::Fill;
|
||||
myImage6->Source = bi6;
|
||||
|
||||
// Add the images to the parent StackPanel
|
||||
myStackPanel->Children->Add(myImage4);
|
||||
myStackPanel->Children->Add(myImage5);
|
||||
myStackPanel->Children->Add(myImage6);
|
||||
|
||||
// Add the layout panels as children of the Grid
|
||||
myGrid->Children->Add(myDockPanel);
|
||||
myGrid->Children->Add(myStackPanel);
|
||||
|
||||
// Add the Grid as the Content of the Parent Window Object
|
||||
mainWindow->Content = myGrid;
|
||||
mainWindow->Show();
|
||||
|
||||
//</Snippet1>
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="StackPanel_Ovw_Sample4.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<Application x:Class="D3DHost.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,93 @@
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.20821</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D1FC6F31-1F0B-4085-96A6-B9B55944CCC0}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>D3DHost</RootNamespace>
|
||||
<AssemblyName>D3DHost</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<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>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<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>
|
||||
</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="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="dllmain.cpp" />
|
||||
<None Include="Renderer.cpp" />
|
||||
<None Include="Renderer.h" />
|
||||
<None Include="RendererManager.cpp" />
|
||||
<None Include="RendererManager.h" />
|
||||
<None Include="stdafx.h" />
|
||||
<None Include="TriangleRenderer.cpp" />
|
||||
<None Include="TriangleRenderer.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,100 @@
|
||||
// <snippetDllMain>
|
||||
// dllmain.cpp : Defines the entry point for the DLL application.
|
||||
#include "stdafx.h"
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static CRendererManager *pManager = NULL;
|
||||
|
||||
static HRESULT EnsureRendererManager()
|
||||
{
|
||||
return pManager ? S_OK : CRendererManager::Create(&pManager);
|
||||
}
|
||||
|
||||
extern "C" HRESULT WINAPI SetSize(UINT uWidth, UINT uHeight)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
IFC(EnsureRendererManager());
|
||||
|
||||
pManager->SetSize(uWidth, uHeight);
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
extern "C" HRESULT WINAPI SetAlpha(BOOL fUseAlpha)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
IFC(EnsureRendererManager());
|
||||
|
||||
pManager->SetAlpha(!!fUseAlpha);
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
extern "C" HRESULT WINAPI SetNumDesiredSamples(UINT uNumSamples)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
IFC(EnsureRendererManager());
|
||||
|
||||
pManager->SetNumDesiredSamples(uNumSamples);
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
extern "C" HRESULT WINAPI SetAdapter(POINT screenSpacePoint)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
IFC(EnsureRendererManager());
|
||||
|
||||
pManager->SetAdapter(screenSpacePoint);
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
extern "C" HRESULT WINAPI GetBackBufferNoRef(IDirect3DSurface9 **ppSurface)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
IFC(EnsureRendererManager());
|
||||
|
||||
IFC(pManager->GetBackBufferNoRef(ppSurface));
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
extern "C" HRESULT WINAPI Render()
|
||||
{
|
||||
assert(pManager);
|
||||
|
||||
return pManager->Render();
|
||||
}
|
||||
|
||||
extern "C" void WINAPI Destroy()
|
||||
{
|
||||
delete pManager;
|
||||
pManager = NULL;
|
||||
}
|
||||
// </snippetDllMain>
|
||||
@@ -0,0 +1,168 @@
|
||||
// <snippetRendererCPP>
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// CRenderer
|
||||
//
|
||||
// An abstract base class that creates a device and a target render
|
||||
// surface. Derive from this class and override Init() and Render()
|
||||
// to do your own rendering. See CTriangleRenderer for an example.
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRenderer ctor
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
CRenderer::CRenderer() : m_pd3dDevice(NULL), m_pd3dDeviceEx(NULL), m_pd3dRTS(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRenderer dtor
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
CRenderer::~CRenderer()
|
||||
{
|
||||
SAFE_RELEASE(m_pd3dDevice);
|
||||
SAFE_RELEASE(m_pd3dDeviceEx);
|
||||
SAFE_RELEASE(m_pd3dRTS);
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRenderer::CheckDeviceState
|
||||
//
|
||||
// Synopsis:
|
||||
// Returns the status of the device. 9Ex devices are a special case because
|
||||
// TestCooperativeLevel() has been deprecated in 9Ex.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
HRESULT
|
||||
CRenderer::CheckDeviceState()
|
||||
{
|
||||
if (m_pd3dDeviceEx)
|
||||
{
|
||||
return m_pd3dDeviceEx->CheckDeviceState(NULL);
|
||||
}
|
||||
else if (m_pd3dDevice)
|
||||
{
|
||||
return m_pd3dDevice->TestCooperativeLevel();
|
||||
}
|
||||
else
|
||||
{
|
||||
return D3DERR_DEVICELOST;
|
||||
}
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRenderer::CreateSurface
|
||||
//
|
||||
// Synopsis:
|
||||
// Creates and sets the render target
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// <snippetRenderer_CreateSurface>
|
||||
HRESULT
|
||||
CRenderer::CreateSurface(UINT uWidth, UINT uHeight, bool fUseAlpha, UINT m_uNumSamples)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
SAFE_RELEASE(m_pd3dRTS);
|
||||
|
||||
IFC(m_pd3dDevice->CreateRenderTarget(
|
||||
uWidth,
|
||||
uHeight,
|
||||
fUseAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8,
|
||||
static_cast<D3DMULTISAMPLE_TYPE>(m_uNumSamples),
|
||||
0,
|
||||
m_pd3dDeviceEx ? FALSE : TRUE, // Lockable RT required for good XP perf
|
||||
&m_pd3dRTS,
|
||||
NULL
|
||||
));
|
||||
|
||||
IFC(m_pd3dDevice->SetRenderTarget(0, m_pd3dRTS));
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
// </snippetRenderer_CreateSurface>
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRenderer::Init
|
||||
//
|
||||
// Synopsis:
|
||||
// Creates the device
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// <snippetRenderer_Init>
|
||||
HRESULT
|
||||
CRenderer::Init(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
ZeroMemory(&d3dpp, sizeof(d3dpp));
|
||||
d3dpp.Windowed = TRUE;
|
||||
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
||||
d3dpp.BackBufferHeight = 1;
|
||||
d3dpp.BackBufferWidth = 1;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
|
||||
D3DCAPS9 caps;
|
||||
DWORD dwVertexProcessing;
|
||||
IFC(pD3D->GetDeviceCaps(uAdapter, D3DDEVTYPE_HAL, &caps));
|
||||
if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == D3DDEVCAPS_HWTRANSFORMANDLIGHT)
|
||||
{
|
||||
dwVertexProcessing = D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
||||
}
|
||||
else
|
||||
{
|
||||
dwVertexProcessing = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||
}
|
||||
|
||||
if (pD3DEx)
|
||||
{
|
||||
IDirect3DDevice9Ex *pd3dDevice = NULL;
|
||||
IFC(pD3DEx->CreateDeviceEx(
|
||||
uAdapter,
|
||||
D3DDEVTYPE_HAL,
|
||||
hwnd,
|
||||
dwVertexProcessing | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
|
||||
&d3dpp,
|
||||
NULL,
|
||||
&m_pd3dDeviceEx
|
||||
));
|
||||
|
||||
IFC(m_pd3dDeviceEx->QueryInterface(__uuidof(IDirect3DDevice9), reinterpret_cast<void**>(&m_pd3dDevice)));
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(pD3D);
|
||||
|
||||
IFC(pD3D->CreateDevice(
|
||||
uAdapter,
|
||||
D3DDEVTYPE_HAL,
|
||||
hwnd,
|
||||
dwVertexProcessing | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
|
||||
&d3dpp,
|
||||
&m_pd3dDevice
|
||||
));
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
// </snippetRenderer_Init>
|
||||
// </snippetRendererCPP>
|
||||
@@ -0,0 +1,28 @@
|
||||
// <snippetRendererH>
|
||||
|
||||
#pragma once
|
||||
|
||||
class CRenderer
|
||||
{
|
||||
public:
|
||||
virtual ~CRenderer();
|
||||
|
||||
HRESULT CheckDeviceState();
|
||||
HRESULT CreateSurface(UINT uWidth, UINT uHeight, bool fUseAlpha, UINT m_uNumSamples);
|
||||
|
||||
virtual HRESULT Render() = 0;
|
||||
|
||||
IDirect3DSurface9 *GetSurfaceNoRef() { return m_pd3dRTS; }
|
||||
|
||||
protected:
|
||||
CRenderer();
|
||||
|
||||
virtual HRESULT Init(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter);
|
||||
|
||||
IDirect3DDevice9 *m_pd3dDevice;
|
||||
IDirect3DDevice9Ex *m_pd3dDeviceEx;
|
||||
|
||||
IDirect3DSurface9 *m_pd3dRTS;
|
||||
|
||||
};
|
||||
// </snippetRendererH>
|
||||
@@ -0,0 +1,518 @@
|
||||
// <snippetRendererManagerCPP>
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// CRendererManager
|
||||
//
|
||||
// Manages the list of CRenderers. Managed code pinvokes into this class
|
||||
// and this class forwards to the appropriate CRenderer.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
const static TCHAR szAppName[] = TEXT("D3DImageSample");
|
||||
typedef HRESULT (WINAPI *DIRECT3DCREATE9EXFUNCTION)(UINT SDKVersion, IDirect3D9Ex**);
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager ctor
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
CRendererManager::CRendererManager()
|
||||
:
|
||||
m_pD3D(NULL),
|
||||
m_pD3DEx(NULL),
|
||||
m_cAdapters(0),
|
||||
m_hwnd(NULL),
|
||||
m_pCurrentRenderer(NULL),
|
||||
m_rgRenderers(NULL),
|
||||
m_uWidth(1024),
|
||||
m_uHeight(1024),
|
||||
m_uNumSamples(0),
|
||||
m_fUseAlpha(false),
|
||||
m_fSurfaceSettingsChanged(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager dtor
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
CRendererManager::~CRendererManager()
|
||||
{
|
||||
DestroyResources();
|
||||
|
||||
if (m_hwnd)
|
||||
{
|
||||
DestroyWindow(m_hwnd);
|
||||
UnregisterClass(szAppName, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::Create
|
||||
//
|
||||
// Synopsis:
|
||||
// Creates the manager
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
HRESULT
|
||||
CRendererManager::Create(CRendererManager **ppManager)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
*ppManager = new CRendererManager();
|
||||
IFCOOM(*ppManager);
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::EnsureRenderers
|
||||
//
|
||||
// Synopsis:
|
||||
// Makes sure the CRenderer objects exist
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
HRESULT
|
||||
CRendererManager::EnsureRenderers()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (!m_rgRenderers)
|
||||
{
|
||||
IFC(EnsureHWND());
|
||||
|
||||
assert(m_cAdapters);
|
||||
m_rgRenderers = new CRenderer*[m_cAdapters];
|
||||
IFCOOM(m_rgRenderers);
|
||||
ZeroMemory(m_rgRenderers, m_cAdapters * sizeof(m_rgRenderers[0]));
|
||||
|
||||
for (UINT i = 0; i < m_cAdapters; ++i)
|
||||
{
|
||||
IFC(CTriangleRenderer::Create(m_pD3D, m_pD3DEx, m_hwnd, i, &m_rgRenderers[i]));
|
||||
}
|
||||
|
||||
// Default to the default adapter
|
||||
m_pCurrentRenderer = m_rgRenderers[0];
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::EnsureHWND
|
||||
//
|
||||
// Synopsis:
|
||||
// Makes sure an HWND exists if we need it
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// <snippetRendererManager_EnsureHWND>
|
||||
HRESULT
|
||||
CRendererManager::EnsureHWND()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (!m_hwnd)
|
||||
{
|
||||
WNDCLASS wndclass;
|
||||
|
||||
wndclass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wndclass.lpfnWndProc = DefWindowProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = NULL;
|
||||
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
|
||||
wndclass.lpszMenuName = NULL;
|
||||
wndclass.lpszClassName = szAppName;
|
||||
|
||||
if (!RegisterClass(&wndclass))
|
||||
{
|
||||
IFC(E_FAIL);
|
||||
}
|
||||
|
||||
m_hwnd = CreateWindow(szAppName,
|
||||
TEXT("D3DImageSample"),
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
0, // Initial X
|
||||
0, // Initial Y
|
||||
0, // Width
|
||||
0, // Height
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
// </snippetRendererManager_EnsureHWND>
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::EnsureD3DObjects
|
||||
//
|
||||
// Synopsis:
|
||||
// Makes sure the D3D objects exist
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// <snippetRendererManager_EnsureD3DObjects>
|
||||
HRESULT
|
||||
CRendererManager::EnsureD3DObjects()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
HMODULE hD3D = NULL;
|
||||
if (!m_pD3D)
|
||||
{
|
||||
hD3D = LoadLibrary(TEXT("d3d9.dll"));
|
||||
DIRECT3DCREATE9EXFUNCTION pfnCreate9Ex = (DIRECT3DCREATE9EXFUNCTION)GetProcAddress(hD3D, "Direct3DCreate9Ex");
|
||||
if (pfnCreate9Ex)
|
||||
{
|
||||
IFC((*pfnCreate9Ex)(D3D_SDK_VERSION, &m_pD3DEx));
|
||||
IFC(m_pD3DEx->QueryInterface(__uuidof(IDirect3D9), reinterpret_cast<void **>(&m_pD3D)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
if (!m_pD3D)
|
||||
{
|
||||
IFC(E_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
m_cAdapters = m_pD3D->GetAdapterCount();
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
if (hD3D)
|
||||
{
|
||||
FreeLibrary(hD3D);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
// </snippetRendererManager_EnsureD3DObjects>
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::CleanupInvalidDevices
|
||||
//
|
||||
// Synopsis:
|
||||
// Checks to see if any devices are bad and if so, deletes all resources
|
||||
//
|
||||
// We could delete resources and wait for D3DERR_DEVICENOTRESET and reset
|
||||
// the devices, but if the device is lost because of an adapter order
|
||||
// change then our existing D3D objects would have stale adapter
|
||||
// information. We'll delete everything to be safe rather than sorry.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
CRendererManager::CleanupInvalidDevices()
|
||||
{
|
||||
for (UINT i = 0; i < m_cAdapters; ++i)
|
||||
{
|
||||
if (FAILED(m_rgRenderers[i]->CheckDeviceState()))
|
||||
{
|
||||
DestroyResources();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::GetBackBufferNoRef
|
||||
//
|
||||
// Synopsis:
|
||||
// Returns the surface of the current renderer without adding a reference
|
||||
//
|
||||
// This can return NULL if we're in a bad device state.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
HRESULT
|
||||
CRendererManager::GetBackBufferNoRef(IDirect3DSurface9 **ppSurface)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
// Make sure we at least return NULL
|
||||
*ppSurface = NULL;
|
||||
|
||||
CleanupInvalidDevices();
|
||||
|
||||
IFC(EnsureD3DObjects());
|
||||
|
||||
//
|
||||
// Even if we never render to another adapter, this sample creates devices
|
||||
// and resources on each one. This is a potential waste of video memory,
|
||||
// but it guarantees that we won't have any problems (e.g. out of video
|
||||
// memory) when switching to render on another adapter. In your own code
|
||||
// you may choose to delay creation but you'll need to handle the issues
|
||||
// that come with it.
|
||||
//
|
||||
|
||||
IFC(EnsureRenderers());
|
||||
|
||||
if (m_fSurfaceSettingsChanged)
|
||||
{
|
||||
if (FAILED(TestSurfaceSettings()))
|
||||
{
|
||||
IFC(E_FAIL);
|
||||
}
|
||||
|
||||
for (UINT i = 0; i < m_cAdapters; ++i)
|
||||
{
|
||||
IFC(m_rgRenderers[i]->CreateSurface(m_uWidth, m_uHeight, m_fUseAlpha, m_uNumSamples));
|
||||
}
|
||||
|
||||
m_fSurfaceSettingsChanged = false;
|
||||
}
|
||||
|
||||
if (m_pCurrentRenderer)
|
||||
{
|
||||
*ppSurface = m_pCurrentRenderer->GetSurfaceNoRef();
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
// If we failed because of a bad device, ignore the failure for now and
|
||||
// we'll clean up and try again next time.
|
||||
if (hr == D3DERR_DEVICELOST)
|
||||
{
|
||||
hr = S_OK;
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::TestSurfaceSettings
|
||||
//
|
||||
// Synopsis:
|
||||
// Checks to see if our current surface settings are allowed on all
|
||||
// adapters.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// <snippetRendererManager_TestSurfaceSettings>
|
||||
HRESULT
|
||||
CRendererManager::TestSurfaceSettings()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
D3DFORMAT fmt = m_fUseAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8;
|
||||
|
||||
//
|
||||
// We test all adapters because because we potentially use all adapters.
|
||||
// But even if this sample only rendered to the default adapter, you
|
||||
// should check all adapters because WPF may move your surface to
|
||||
// another adapter for you!
|
||||
//
|
||||
|
||||
for (UINT i = 0; i < m_cAdapters; ++i)
|
||||
{
|
||||
// Can we get HW rendering?
|
||||
IFC(m_pD3D->CheckDeviceType(
|
||||
i,
|
||||
D3DDEVTYPE_HAL,
|
||||
D3DFMT_X8R8G8B8,
|
||||
fmt,
|
||||
TRUE
|
||||
));
|
||||
|
||||
// Is the format okay?
|
||||
IFC(m_pD3D->CheckDeviceFormat(
|
||||
i,
|
||||
D3DDEVTYPE_HAL,
|
||||
D3DFMT_X8R8G8B8,
|
||||
D3DUSAGE_RENDERTARGET | D3DUSAGE_DYNAMIC, // We'll use dynamic when on XP
|
||||
D3DRTYPE_SURFACE,
|
||||
fmt
|
||||
));
|
||||
|
||||
// D3DImage only allows multisampling on 9Ex devices. If we can't
|
||||
// multisample, overwrite the desired number of samples with 0.
|
||||
if (m_pD3DEx && m_uNumSamples > 1)
|
||||
{
|
||||
assert(m_uNumSamples <= 16);
|
||||
|
||||
if (FAILED(m_pD3D->CheckDeviceMultiSampleType(
|
||||
i,
|
||||
D3DDEVTYPE_HAL,
|
||||
fmt,
|
||||
TRUE,
|
||||
static_cast<D3DMULTISAMPLE_TYPE>(m_uNumSamples),
|
||||
NULL
|
||||
)))
|
||||
{
|
||||
m_uNumSamples = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_uNumSamples = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
// </snippetRendererManager_TestSurfaceSettings>
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::DestroyResources
|
||||
//
|
||||
// Synopsis:
|
||||
// Delete all D3D resources
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
CRendererManager::DestroyResources()
|
||||
{
|
||||
SAFE_RELEASE(m_pD3D);
|
||||
SAFE_RELEASE(m_pD3DEx);
|
||||
|
||||
for (UINT i = 0; i < m_cAdapters; ++i)
|
||||
{
|
||||
delete m_rgRenderers[i];
|
||||
}
|
||||
delete [] m_rgRenderers;
|
||||
m_rgRenderers = NULL;
|
||||
|
||||
m_pCurrentRenderer = NULL;
|
||||
m_cAdapters = 0;
|
||||
|
||||
m_fSurfaceSettingsChanged = true;
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::SetSize
|
||||
//
|
||||
// Synopsis:
|
||||
// Update the size of the surface. Next render will create a new surface.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
CRendererManager::SetSize(UINT uWidth, UINT uHeight)
|
||||
{
|
||||
if (uWidth != m_uWidth || uHeight != m_uHeight)
|
||||
{
|
||||
m_uWidth = uWidth;
|
||||
m_uHeight = uHeight;
|
||||
m_fSurfaceSettingsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::SetAlpha
|
||||
//
|
||||
// Synopsis:
|
||||
// Update the format of the surface. Next render will create a new surface.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
CRendererManager::SetAlpha(bool fUseAlpha)
|
||||
{
|
||||
if (fUseAlpha != m_fUseAlpha)
|
||||
{
|
||||
m_fUseAlpha = fUseAlpha;
|
||||
m_fSurfaceSettingsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::SetNumDesiredSamples
|
||||
//
|
||||
// Synopsis:
|
||||
// Update the MSAA settings of the surface. Next render will create a
|
||||
// new surface.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
CRendererManager::SetNumDesiredSamples(UINT uNumSamples)
|
||||
{
|
||||
if (m_uNumSamples != uNumSamples)
|
||||
{
|
||||
m_uNumSamples = uNumSamples;
|
||||
m_fSurfaceSettingsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::SetAdapter
|
||||
//
|
||||
// Synopsis:
|
||||
// Update the current renderer. Next render will use the new renderer.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// <snippetRendererManager_SetAdapter>
|
||||
void
|
||||
CRendererManager::SetAdapter(POINT screenSpacePoint)
|
||||
{
|
||||
CleanupInvalidDevices();
|
||||
|
||||
//
|
||||
// After CleanupInvalidDevices, we may not have any D3D objects. Rather than
|
||||
// recreate them here, ignore the adapter update and wait for render to recreate.
|
||||
//
|
||||
|
||||
if (m_pD3D && m_rgRenderers)
|
||||
{
|
||||
HMONITOR hMon = MonitorFromPoint(screenSpacePoint, MONITOR_DEFAULTTONULL);
|
||||
|
||||
for (UINT i = 0; i < m_cAdapters; ++i)
|
||||
{
|
||||
if (hMon == m_pD3D->GetAdapterMonitor(i))
|
||||
{
|
||||
m_pCurrentRenderer = m_rgRenderers[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// </snippetRendererManager_SetAdapter>
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CRendererManager::Render
|
||||
//
|
||||
// Synopsis:
|
||||
// Forward to the current renderer
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
HRESULT
|
||||
CRendererManager::Render()
|
||||
{
|
||||
return m_pCurrentRenderer ? m_pCurrentRenderer->Render() : S_OK;
|
||||
}
|
||||
// </snippetRendererManagerCPP>
|
||||
@@ -0,0 +1,49 @@
|
||||
// <snippetRendererManagerH>
|
||||
|
||||
#pragma once
|
||||
|
||||
class CRenderer;
|
||||
|
||||
class CRendererManager
|
||||
{
|
||||
public:
|
||||
static HRESULT Create(CRendererManager **ppManager);
|
||||
~CRendererManager();
|
||||
|
||||
HRESULT EnsureDevices();
|
||||
|
||||
void SetSize(UINT uWidth, UINT uHeight);
|
||||
void SetAlpha(bool fUseAlpha);
|
||||
void SetNumDesiredSamples(UINT uNumSamples);
|
||||
void SetAdapter(POINT screenSpacePoint);
|
||||
|
||||
HRESULT GetBackBufferNoRef(IDirect3DSurface9 **ppSurface);
|
||||
|
||||
HRESULT Render();
|
||||
|
||||
private:
|
||||
CRendererManager();
|
||||
|
||||
void CleanupInvalidDevices();
|
||||
HRESULT EnsureRenderers();
|
||||
HRESULT EnsureHWND();
|
||||
HRESULT EnsureD3DObjects();
|
||||
HRESULT TestSurfaceSettings();
|
||||
void DestroyResources();
|
||||
|
||||
IDirect3D9 *m_pD3D;
|
||||
IDirect3D9Ex *m_pD3DEx;
|
||||
|
||||
UINT m_cAdapters;
|
||||
CRenderer **m_rgRenderers;
|
||||
CRenderer *m_pCurrentRenderer;
|
||||
|
||||
HWND m_hwnd;
|
||||
|
||||
UINT m_uWidth;
|
||||
UINT m_uHeight;
|
||||
UINT m_uNumSamples;
|
||||
bool m_fUseAlpha;
|
||||
bool m_fSurfaceSettingsChanged;
|
||||
};
|
||||
// </snippetRendererManagerH>
|
||||
@@ -0,0 +1,26 @@
|
||||
// <snippetStdafxH>
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "RendererManager.h"
|
||||
#include "Renderer.h"
|
||||
#include "TriangleRenderer.h"
|
||||
|
||||
#define IFC(x) { hr = (x); if (FAILED(hr)) goto Cleanup; }
|
||||
#define IFCOOM(x) { if ((x) == NULL) { hr = E_OUTOFMEMORY; IFC(hr); } }
|
||||
#define SAFE_RELEASE(x) { if (x) { x->Release(); x = NULL; } }
|
||||
|
||||
// </snippetStdafxH>
|
||||
@@ -0,0 +1,161 @@
|
||||
// <snippetTriangleRendererCPP>
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// CTriangleRenderer
|
||||
//
|
||||
// Subclass of CRenderer that renders a single, spinning triangle
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
struct CUSTOMVERTEX
|
||||
{
|
||||
FLOAT x, y, z;
|
||||
DWORD color;
|
||||
};
|
||||
|
||||
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE)
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CTriangleRenderer ctor
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
CTriangleRenderer::CTriangleRenderer() : CRenderer(), m_pd3dVB(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CTriangleRenderer dtor
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
CTriangleRenderer::~CTriangleRenderer()
|
||||
{
|
||||
SAFE_RELEASE(m_pd3dVB);
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CTriangleRenderer::Create
|
||||
//
|
||||
// Synopsis:
|
||||
// Creates the renderer
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
HRESULT
|
||||
CTriangleRenderer::Create(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter, CRenderer **ppRenderer)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
CTriangleRenderer *pRenderer = new CTriangleRenderer();
|
||||
IFCOOM(pRenderer);
|
||||
|
||||
IFC(pRenderer->Init(pD3D, pD3DEx, hwnd, uAdapter));
|
||||
|
||||
*ppRenderer = pRenderer;
|
||||
pRenderer = NULL;
|
||||
|
||||
Cleanup:
|
||||
delete pRenderer;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CTriangleRenderer::Init
|
||||
//
|
||||
// Synopsis:
|
||||
// Override of CRenderer::Init that calls base to create the device and
|
||||
// then creates the CTriangleRenderer-specific resources
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
HRESULT
|
||||
CTriangleRenderer::Init(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
D3DXMATRIXA16 matView, matProj;
|
||||
D3DXVECTOR3 vEyePt(0.0f, 0.0f,-5.0f);
|
||||
D3DXVECTOR3 vLookatPt(0.0f, 0.0f, 0.0f);
|
||||
D3DXVECTOR3 vUpVec(0.0f, 1.0f, 0.0f);
|
||||
|
||||
// Call base to create the device and render target
|
||||
IFC(CRenderer::Init(pD3D, pD3DEx, hwnd, uAdapter));
|
||||
|
||||
// Set up the VB
|
||||
CUSTOMVERTEX vertices[] =
|
||||
{
|
||||
{ -1.0f, -1.0f, 0.0f, 0xffff0000, }, // x, y, z, color
|
||||
{ 1.0f, -1.0f, 0.0f, 0xff00ff00, },
|
||||
{ 0.0f, 1.0f, 0.0f, 0xff00ffff, },
|
||||
};
|
||||
|
||||
IFC(m_pd3dDevice->CreateVertexBuffer(sizeof(vertices), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &m_pd3dVB, NULL));
|
||||
|
||||
void *pVertices;
|
||||
IFC(m_pd3dVB->Lock(0, sizeof(vertices), &pVertices, 0));
|
||||
memcpy(pVertices, vertices, sizeof(vertices));
|
||||
m_pd3dVB->Unlock();
|
||||
|
||||
// Set up the camera
|
||||
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);
|
||||
IFC(m_pd3dDevice->SetTransform(D3DTS_VIEW, &matView));
|
||||
D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI / 4, 1.0f, 1.0f, 100.0f);
|
||||
IFC(m_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj));
|
||||
|
||||
// Set up the global state
|
||||
IFC(m_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE));
|
||||
IFC(m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE));
|
||||
IFC(m_pd3dDevice->SetStreamSource(0, m_pd3dVB, 0, sizeof(CUSTOMVERTEX)));
|
||||
IFC(m_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX));
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
// Member:
|
||||
// CTriangleRenderer::Render
|
||||
//
|
||||
// Synopsis:
|
||||
// Renders the rotating triangle
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
HRESULT
|
||||
CTriangleRenderer::Render()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
D3DXMATRIXA16 matWorld;
|
||||
|
||||
IFC(m_pd3dDevice->BeginScene());
|
||||
IFC(m_pd3dDevice->Clear(
|
||||
0,
|
||||
NULL,
|
||||
D3DCLEAR_TARGET,
|
||||
D3DCOLOR_ARGB(128, 0, 0, 128), // NOTE: Premultiplied alpha!
|
||||
1.0f,
|
||||
0
|
||||
));
|
||||
|
||||
// Set up the rotation
|
||||
UINT iTime = GetTickCount() % 1000;
|
||||
FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f;
|
||||
D3DXMatrixRotationY(&matWorld, fAngle);
|
||||
IFC(m_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld));
|
||||
|
||||
IFC(m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1));
|
||||
|
||||
IFC(m_pd3dDevice->EndScene());
|
||||
|
||||
Cleanup:
|
||||
return hr;
|
||||
}
|
||||
// </snippetTriangleRendererCPP>
|
||||
@@ -0,0 +1,20 @@
|
||||
// <snippetTriangleRendererH>
|
||||
#pragma once
|
||||
|
||||
class CTriangleRenderer : public CRenderer
|
||||
{
|
||||
public:
|
||||
static HRESULT Create(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter, CRenderer **ppRenderer);
|
||||
~CTriangleRenderer();
|
||||
|
||||
HRESULT Render();
|
||||
|
||||
protected:
|
||||
HRESULT Init(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter);
|
||||
|
||||
private:
|
||||
CTriangleRenderer();
|
||||
|
||||
IDirect3DVertexBuffer9 *m_pd3dVB;
|
||||
};
|
||||
// </snippetTriangleRendererH>
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
<Window x:Class="D3DHost.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:i="clr-namespace:System.Windows.Interop;assembly=PresentationCore"
|
||||
Title="MainWindow" Height="300" Width="300" Background="PaleGoldenrod">
|
||||
<Grid>
|
||||
<Image x:Name="imgelt">
|
||||
<Image.Source>
|
||||
<i:D3DImage x:Name="d3dimg" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace D3DHost
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// Set up the initial state for the D3DImage.
|
||||
HRESULT.Check(SetSize(512, 512));
|
||||
HRESULT.Check(SetAlpha(false));
|
||||
HRESULT.Check(SetNumDesiredSamples(4));
|
||||
|
||||
//
|
||||
// Optional: Subscribing to the IsFrontBufferAvailableChanged event.
|
||||
//
|
||||
// If you don't render every frame (e.g. you only render in
|
||||
// reaction to a button click), you should subscribe to the
|
||||
// IsFrontBufferAvailableChanged event to be notified when rendered content
|
||||
// is no longer being displayed. This event also notifies you when
|
||||
// the D3DImage is capable of being displayed again.
|
||||
|
||||
// For example, in the button click case, if you don't render again when
|
||||
// the IsFrontBufferAvailable property is set to true, your
|
||||
// D3DImage won't display anything until the next button click.
|
||||
//
|
||||
// Because this application renders every frame, there is no need to
|
||||
// handle the IsFrontBufferAvailableChanged event.
|
||||
//
|
||||
CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
|
||||
|
||||
//
|
||||
// Optional: Multi-adapter optimization
|
||||
//
|
||||
// The surface is created initially on a particular adapter.
|
||||
// If the WPF window is dragged to another adapter, WPF
|
||||
// ensures that the D3DImage still shows up on the new
|
||||
// adapter.
|
||||
//
|
||||
// This process is slow on Windows XP.
|
||||
//
|
||||
// Performance is better on Vista with a 9Ex device. It's only
|
||||
// slow when the D3DImage crosses a video-card boundary.
|
||||
//
|
||||
// To work around this issue, you can move your surface when
|
||||
// the D3DImage is displayed on another adapter. To
|
||||
// determine when that is the case, transform a point on the
|
||||
// D3DImage into screen space and find out which adapter
|
||||
// contains that screen space point.
|
||||
//
|
||||
// When your D3DImage straddles two adapters, nothing
|
||||
// can be done, because one will be updating slowly.
|
||||
//
|
||||
_adapterTimer = new DispatcherTimer();
|
||||
_adapterTimer.Tick += new EventHandler(AdapterTimer_Tick);
|
||||
_adapterTimer.Interval = new TimeSpan(0, 0, 0, 0, 500);
|
||||
_adapterTimer.Start();
|
||||
|
||||
//
|
||||
// Optional: Surface resizing
|
||||
//
|
||||
// The D3DImage is scaled when WPF renders it at a size
|
||||
// different from the natural size of the surface. If the
|
||||
// D3DImage is scaled up significantly, image quality
|
||||
// degrades.
|
||||
//
|
||||
// To avoid this, you can either create a very large
|
||||
// texture initially, or you can create new surfaces as
|
||||
// the size changes. Below is a very simple example of
|
||||
// how to do the latter.
|
||||
//
|
||||
// By creating a timer at Render priority, you are guaranteed
|
||||
// that new surfaces are created while the element
|
||||
// is still being arranged. A 200 ms interval gives
|
||||
// a good balance between image quality and performance.
|
||||
// You must be careful not to create new surfaces too
|
||||
// frequently. Frequently allocating a new surface may
|
||||
// fragment or exhaust video memory. This issue is more
|
||||
// significant on XDDM than it is on WDDM, because WDDM
|
||||
// can page out video memory.
|
||||
//
|
||||
// Another approach is deriving from the Image class,
|
||||
// participating in layout by overriding the ArrangeOverride method, and
|
||||
// updating size in the overriden method. Performance will degrade
|
||||
// if you resize too frequently.
|
||||
//
|
||||
// Blurry D3DImages can still occur due to subpixel
|
||||
// alignments.
|
||||
//
|
||||
_sizeTimer = new DispatcherTimer(DispatcherPriority.Render);
|
||||
_sizeTimer.Tick += new EventHandler(SizeTimer_Tick);
|
||||
_sizeTimer.Interval = new TimeSpan(0, 0, 0, 0, 200);
|
||||
_sizeTimer.Start();
|
||||
}
|
||||
|
||||
~MainWindow()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void AdapterTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
POINT p = new POINT(imgelt.PointToScreen(new Point(0, 0)));
|
||||
|
||||
HRESULT.Check(SetAdapter(p));
|
||||
}
|
||||
|
||||
void SizeTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// The following code does not account for RenderTransforms.
|
||||
// To handle that case, you must transform up to the root and
|
||||
// check the size there.
|
||||
|
||||
// Given that the D3DImage is at 96.0 DPI, its Width and Height
|
||||
// properties will always be integers. ActualWidth/Height
|
||||
// may not be integers, so they are cast to integers.
|
||||
uint actualWidth = (uint)imgelt.ActualWidth;
|
||||
uint actualHeight = (uint)imgelt.ActualHeight;
|
||||
if ((actualWidth > 0 && actualHeight > 0) &&
|
||||
(actualWidth != (uint)d3dimg.Width || actualHeight != (uint)d3dimg.Height))
|
||||
{
|
||||
HRESULT.Check(SetSize(actualWidth, actualHeight));
|
||||
}
|
||||
}
|
||||
|
||||
void CompositionTarget_Rendering(object sender, EventArgs e)
|
||||
{
|
||||
RenderingEventArgs args = (RenderingEventArgs)e;
|
||||
|
||||
// It's possible for Rendering to call back twice in the same frame
|
||||
// so only render when we haven't already rendered in this frame.
|
||||
if (d3dimg.IsFrontBufferAvailable && _lastRender != args.RenderingTime)
|
||||
{
|
||||
IntPtr pSurface = IntPtr.Zero;
|
||||
HRESULT.Check(GetBackBufferNoRef(out pSurface));
|
||||
if (pSurface != IntPtr.Zero)
|
||||
{
|
||||
|
||||
d3dimg.Lock();
|
||||
// Repeatedly calling SetBackBuffer with the same IntPtr is
|
||||
// a no-op. There is no performance penalty.
|
||||
d3dimg.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSurface);
|
||||
HRESULT.Check(Render());
|
||||
d3dimg.AddDirtyRect(new Int32Rect(0, 0, d3dimg.PixelWidth, d3dimg.PixelHeight));
|
||||
d3dimg.Unlock();
|
||||
|
||||
_lastRender = args.RenderingTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DispatcherTimer _sizeTimer;
|
||||
DispatcherTimer _adapterTimer;
|
||||
TimeSpan _lastRender;
|
||||
|
||||
// Import the methods exported by the unmanaged Direct3D content.
|
||||
|
||||
[DllImport("D3DCode.dll")]
|
||||
static extern int GetBackBufferNoRef(out IntPtr pSurface);
|
||||
|
||||
[DllImport("D3DCode.dll")]
|
||||
static extern int SetSize(uint width, uint height);
|
||||
|
||||
[DllImport("D3DCode.dll")]
|
||||
static extern int SetAlpha(bool useAlpha);
|
||||
|
||||
[DllImport("D3DCode.dll")]
|
||||
static extern int SetNumDesiredSamples(uint numSamples);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct POINT
|
||||
{
|
||||
public POINT(Point p)
|
||||
{
|
||||
x = (int)p.X;
|
||||
y = (int)p.Y;
|
||||
}
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
}
|
||||
|
||||
[DllImport("D3DCode.dll")]
|
||||
static extern int SetAdapter(POINT screenSpacePoint);
|
||||
|
||||
[DllImport("D3DCode.dll")]
|
||||
static extern int Render();
|
||||
|
||||
[DllImport("D3DCode.dll")]
|
||||
static extern void Destroy();
|
||||
}
|
||||
|
||||
public static class HRESULT
|
||||
{
|
||||
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
|
||||
public static void Check(int hr)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(hr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
//TiffEncoderDecoder.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::IO;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Imaging;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Security;
|
||||
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private: System::Windows::Window^ mainWindow;
|
||||
|
||||
protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private: void CreateAndShowMainWindow ()
|
||||
{
|
||||
|
||||
// Create the application's main window.
|
||||
mainWindow = gcnew System::Windows::Window();
|
||||
mainWindow->Title = "TIFF Imaging Sample";
|
||||
ScrollViewer^ mySV = gcnew ScrollViewer();
|
||||
|
||||
//<Snippet4>
|
||||
int width = 128;
|
||||
int height = width;
|
||||
int stride = width / 8;
|
||||
array<System::Byte>^ pixels = gcnew array<System::Byte>(height * stride);
|
||||
|
||||
// Define the image palette.
|
||||
BitmapPalette^ myPalette = BitmapPalettes::WebPalette;
|
||||
|
||||
// Creates a new empty image with the pre-defined palette.
|
||||
|
||||
//<Snippet2>
|
||||
BitmapSource^ image = BitmapSource::Create(width,
|
||||
height,
|
||||
96,
|
||||
96,
|
||||
PixelFormats::Indexed1,
|
||||
myPalette,
|
||||
pixels,
|
||||
stride);
|
||||
//</Snippet2>
|
||||
|
||||
//<Snippet3>
|
||||
FileStream^ stream = gcnew FileStream("new.tif", FileMode::Create);
|
||||
TiffBitmapEncoder^ encoder = gcnew TiffBitmapEncoder();
|
||||
TextBlock^ myTextBlock = gcnew TextBlock();
|
||||
myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString();
|
||||
encoder->Compression = TiffCompressOption::Zip;
|
||||
encoder->Frames->Add(BitmapFrame::Create(image));
|
||||
encoder->Save(stream);
|
||||
//</Snippet3>
|
||||
|
||||
//</Snippet4>
|
||||
|
||||
//<Snippet1>
|
||||
// Open a Stream and decode a TIFF image.
|
||||
Stream^ imageStreamSource = gcnew FileStream("tulipfarm.tif", FileMode::Open, FileAccess::Read, FileShare::Read);
|
||||
TiffBitmapDecoder^ decoder = gcnew TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource = decoder->Frames[0];
|
||||
|
||||
// Draw the Image.
|
||||
Image^ myImage = gcnew Image();
|
||||
myImage->Source = bitmapSource;
|
||||
myImage->Stretch = Stretch::None;
|
||||
myImage->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet1>
|
||||
|
||||
//<Snippet5>
|
||||
|
||||
// Open a Uri and decode a TIFF image.
|
||||
System::Uri^ myUri = gcnew System::Uri("tulipfarm.tif", UriKind::RelativeOrAbsolute);
|
||||
TiffBitmapDecoder^ decoder2 = gcnew TiffBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource2 = decoder2->Frames[0];
|
||||
|
||||
// Draw the Image.
|
||||
Image^ myImage2 = gcnew Image();
|
||||
myImage2->Source = bitmapSource2;
|
||||
myImage2->Stretch = Stretch::None;
|
||||
myImage2->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet5>
|
||||
|
||||
// Define a StackPanel to host the decoded TIFF images.
|
||||
StackPanel^ myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->Orientation = Orientation::Vertical;
|
||||
myStackPanel->VerticalAlignment = VerticalAlignment::Stretch;
|
||||
myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch;
|
||||
|
||||
// Add the Image and TextBlock to the parent Grid.
|
||||
myStackPanel->Children->Add(myImage);
|
||||
myStackPanel->Children->Add(myImage2);
|
||||
myStackPanel->Children->Add(myTextBlock);
|
||||
|
||||
// Add the StackPanel as the Content of the Parent Window Object.
|
||||
mySV->Content = myStackPanel;
|
||||
mainWindow->Content = mySV;
|
||||
mainWindow->Show();
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir>.\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="TiffEncoderDecoder.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="tulipfarm.tif" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,142 @@
|
||||
//WDPEncoderDecoder.cpp file
|
||||
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::IO;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Imaging;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Security;
|
||||
|
||||
|
||||
namespace SDKSample {
|
||||
|
||||
public ref class app : Application {
|
||||
|
||||
private: Window^ mainWindow;
|
||||
|
||||
protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private: void CreateAndShowMainWindow ()
|
||||
{
|
||||
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew System::Windows::Window();
|
||||
mainWindow->Title = "WDP Imaging Sample";
|
||||
ScrollViewer^ mySV = gcnew ScrollViewer();
|
||||
|
||||
//<Snippet4>
|
||||
int width = 128;
|
||||
int height = width;
|
||||
int stride = width / 8;
|
||||
array<System::Byte>^ pixels = gcnew array<System::Byte>(height * stride);
|
||||
|
||||
// Define the image palette
|
||||
BitmapPalette^ myPalette = BitmapPalettes::WebPalette;
|
||||
|
||||
// Creates a new empty image with the pre-defined palette
|
||||
|
||||
//<Snippet2>
|
||||
BitmapSource^ image = BitmapSource::Create(
|
||||
width,
|
||||
height,
|
||||
96,
|
||||
96,
|
||||
PixelFormats::Indexed1,
|
||||
myPalette,
|
||||
pixels,
|
||||
stride);
|
||||
//</Snippet2>
|
||||
|
||||
//<Snippet3>
|
||||
FileStream^ stream = gcnew FileStream("new.wdp", FileMode::Create);
|
||||
WmpBitmapEncoder^ encoder = gcnew WmpBitmapEncoder();
|
||||
TextBlock^ myTextBlock = gcnew TextBlock();
|
||||
myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString();
|
||||
encoder->Frames->Add(BitmapFrame::Create(image));
|
||||
encoder->Save(stream);
|
||||
//</Snippet3>
|
||||
|
||||
//</Snippet4>
|
||||
|
||||
//<Snippet1>
|
||||
|
||||
// Open a Stream and decode a WDP image
|
||||
Stream^ imageStreamSource = gcnew FileStream("tulipfarm.wdp", FileMode::Open, FileAccess::Read, FileShare::Read);
|
||||
WmpBitmapDecoder^ decoder = gcnew WmpBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource = decoder->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage = gcnew Image();
|
||||
myImage->Source = bitmapSource;
|
||||
myImage->Stretch = Stretch::None;
|
||||
myImage->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet1>
|
||||
|
||||
//<Snippet5>
|
||||
|
||||
// Open a Uri and decode a WDP image
|
||||
System::Uri^ myUri = gcnew System::Uri("tulipfarm.wdp", UriKind::RelativeOrAbsolute);
|
||||
WmpBitmapDecoder^ decoder3 = gcnew WmpBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource3 = decoder3->Frames[0];
|
||||
|
||||
// Draw the Image
|
||||
Image^ myImage2 = gcnew Image();
|
||||
myImage2->Source = bitmapSource3;
|
||||
myImage2->Stretch = Stretch::None;
|
||||
myImage2->Margin = System::Windows::Thickness(20);
|
||||
//</Snippet5>
|
||||
|
||||
//<Snippet6>
|
||||
FileStream^ stream2 = gcnew FileStream("tulipfarm.jpg", FileMode::Open);
|
||||
JpegBitmapDecoder^ decoder2 = gcnew JpegBitmapDecoder(stream2, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
|
||||
BitmapSource^ bitmapSource2 = decoder2->Frames[0];
|
||||
FileStream^ stream3 = gcnew FileStream("new2.wdp", FileMode::Create);
|
||||
WmpBitmapEncoder^ encoder2 = gcnew WmpBitmapEncoder();
|
||||
encoder2->Frames->Add(BitmapFrame::Create(bitmapSource2));
|
||||
encoder2->Save(stream3);
|
||||
//</Snippet6>
|
||||
|
||||
// Define a StackPanel to host the decoded WDP images
|
||||
StackPanel^ myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->Orientation = Orientation::Vertical;
|
||||
myStackPanel->VerticalAlignment = VerticalAlignment::Stretch;
|
||||
myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch;
|
||||
|
||||
// Add the Image and TextBlock to the parent Grid
|
||||
myStackPanel->Children->Add(myImage);
|
||||
myStackPanel->Children->Add(myImage2);
|
||||
myStackPanel->Children->Add(myTextBlock);
|
||||
|
||||
// Add the StackPanel as the Content of the Parent Window Object
|
||||
mySV->Content = myStackPanel;
|
||||
mainWindow->Content = mySV;
|
||||
mainWindow->Show();
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
SDKSample::app^ app = gcnew SDKSample::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return SDKSample::EntryClass::Main();
|
||||
}
|
||||
|
After Width: | Height: | Size: 108 KiB |
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir>.\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="WDPEncoderDecoder.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="tulipfarm.wdp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,31 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by Win32HostingWPFPage.rc
|
||||
//
|
||||
|
||||
#define IDS_APP_TITLE 103
|
||||
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDD_WIN32HOSTINGWPFPAGE_DIALOG 102
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDM_EXIT 105
|
||||
#define IDI_WIN32HOSTINGWPFPAGE 107
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_WIN32HOSTINGWPFPAGE 109
|
||||
#define IDC_MYICON 2
|
||||
#ifndef IDC_STATIC
|
||||
#define IDC_STATIC -1
|
||||
#endif
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#define _APS_NO_MFC 130
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
win32_hosting_avalon_page_cpp
|
||||
@@ -0,0 +1,202 @@
|
||||
#include "stdafx.h"
|
||||
#include "WPFPage.h"
|
||||
|
||||
WPFPage::WPFPage() {}
|
||||
//<SnippetWPFPageCtor>
|
||||
//<SnippetWPFPageCtorToGridDef>
|
||||
WPFPage::WPFPage(int allottedWidth, int allotedHeight)
|
||||
{
|
||||
array<ColumnDefinition ^> ^ columnDef = gcnew array<ColumnDefinition ^> (4);
|
||||
array<RowDefinition ^> ^ rowDef = gcnew array<RowDefinition ^> (6);
|
||||
|
||||
this->Height = allotedHeight;
|
||||
this->Width = allottedWidth;
|
||||
this->Background = gcnew SolidColorBrush(Colors::LightGray);
|
||||
|
||||
//Set up the Grid's row and column definitions
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
columnDef[i] = gcnew ColumnDefinition();
|
||||
columnDef[i]->Width = GridLength(1, GridUnitType::Auto);
|
||||
this->ColumnDefinitions->Add(columnDef[i]);
|
||||
}
|
||||
for(int i=0; i<6; i++)
|
||||
{
|
||||
rowDef[i] = gcnew RowDefinition();
|
||||
rowDef[i]->Height = GridLength(1, GridUnitType::Auto);
|
||||
this->RowDefinitions->Add(rowDef[i]);
|
||||
}
|
||||
//</SnippetWPFPageCtorToGridDef>
|
||||
//<SnippetWPFPageCtorTitle>
|
||||
//Add the title
|
||||
titleText = gcnew Label();
|
||||
titleText->Content = "Simple WPF Control";
|
||||
titleText->HorizontalAlignment = System::Windows::HorizontalAlignment::Center;
|
||||
titleText->Margin = Thickness(10, 5, 10, 0);
|
||||
titleText->FontWeight = FontWeights::Bold;
|
||||
titleText->FontSize = 14;
|
||||
Grid::SetColumn(titleText, 0);
|
||||
Grid::SetRow(titleText, 0);
|
||||
Grid::SetColumnSpan(titleText, 4);
|
||||
this->Children->Add(titleText);
|
||||
//</SnippetWPFPageCtorTitle>
|
||||
//<SnippetWPFPageCtorName>
|
||||
//Add the Name Label and TextBox
|
||||
nameLabel = CreateLabel(0, 1, "Name");
|
||||
this->Children->Add(nameLabel);
|
||||
nameTextBox = CreateTextBox(1, 1, 3);
|
||||
this->Children->Add(nameTextBox);
|
||||
//</SnippetWPFPageCtorName>
|
||||
//Add the Address Label and TextBox
|
||||
addressLabel = CreateLabel(0, 2, "Address");
|
||||
this->Children->Add(addressLabel);
|
||||
addressTextBox = CreateTextBox(1, 2, 3);
|
||||
this->Children->Add(addressTextBox);
|
||||
|
||||
//Add the City Label and TextBox
|
||||
cityLabel = CreateLabel(0, 3, "City");
|
||||
this->Children->Add(cityLabel);
|
||||
cityTextBox = CreateTextBox(1, 3, 1);
|
||||
cityTextBox->Width = 100;
|
||||
this->Children->Add(cityTextBox);
|
||||
|
||||
//Add the State Label and TextBox
|
||||
stateLabel = CreateLabel(2, 3, "State");
|
||||
this->Children->Add(stateLabel);
|
||||
stateTextBox = CreateTextBox(3, 3, 1);
|
||||
stateTextBox->Width = 50;
|
||||
this->Children->Add(stateTextBox);
|
||||
|
||||
//Add the Zip Label and TextBox
|
||||
zipLabel = CreateLabel(0, 4, "Zip");
|
||||
this->Children->Add(zipLabel);
|
||||
zipTextBox = CreateTextBox(1, 4, 1);
|
||||
this->Children->Add(zipTextBox);
|
||||
//<SnippetWPFPageCtorButtonsEvents>
|
||||
//Add the Buttons and atttach event handlers
|
||||
okButton = CreateButton(0, 5, "OK");
|
||||
cancelButton = CreateButton(1, 5, "Cancel");
|
||||
this->Children->Add(okButton);
|
||||
this->Children->Add(cancelButton);
|
||||
okButton->Click += gcnew RoutedEventHandler(this, &WPFPage::ButtonClicked);
|
||||
cancelButton->Click += gcnew RoutedEventHandler(this, &WPFPage::ButtonClicked);
|
||||
//</SnippetWPFPageCtorButtonsEvents>
|
||||
//Set the default font properties
|
||||
DefaultFontFamily = nameLabel->FontFamily;
|
||||
DefaultFontStyle = nameLabel->FontStyle;
|
||||
DefaultFontSize = nameLabel->FontSize;
|
||||
DefaultFontWeight = nameLabel->FontWeight;
|
||||
DefaultForeBrush = nameLabel->Foreground;
|
||||
|
||||
}
|
||||
//</SnippetWPFPageCtor>
|
||||
//<SnippetWPFPageCreateHelpers>
|
||||
Label ^WPFPage::CreateLabel(int column, int row, String ^ text)
|
||||
{
|
||||
Label ^ newLabel = gcnew Label();
|
||||
newLabel->Content = text;
|
||||
newLabel->Margin = Thickness(10, 5, 10, 0);
|
||||
newLabel->FontWeight = FontWeights::Normal;
|
||||
newLabel->FontSize = 12;
|
||||
Grid::SetColumn(newLabel, column);
|
||||
Grid::SetRow(newLabel, row);
|
||||
return newLabel;
|
||||
}
|
||||
TextBox ^WPFPage::CreateTextBox(int column, int row, int span)
|
||||
{
|
||||
TextBox ^newTextBox = gcnew TextBox();
|
||||
newTextBox->Margin = Thickness(10, 5, 10, 0);
|
||||
Grid::SetColumn(newTextBox, column);
|
||||
Grid::SetRow(newTextBox, row);
|
||||
Grid::SetColumnSpan(newTextBox, span);
|
||||
return newTextBox;
|
||||
}
|
||||
//</SnippetWPFPageCreateHelpers>
|
||||
Button ^WPFPage::CreateButton(int column, int row, String ^text)
|
||||
{
|
||||
Button ^newButton = gcnew Button();
|
||||
newButton->Content = text;
|
||||
newButton->Margin = Thickness(10, 10, 10, 10);
|
||||
newButton->Width = 60;
|
||||
Grid::SetColumn(newButton, column);
|
||||
Grid::SetRow(newButton, row);
|
||||
return newButton;
|
||||
}
|
||||
//<SnippetWPFPageButtonClicked>
|
||||
void WPFPage::ButtonClicked(Object ^sender, RoutedEventArgs ^args)
|
||||
{
|
||||
|
||||
//TODO: validate input data
|
||||
bool okClicked = true;
|
||||
if(sender == cancelButton)
|
||||
okClicked = false;
|
||||
EnteredName = nameTextBox->Text;
|
||||
EnteredAddress = addressTextBox->Text;
|
||||
EnteredCity = cityTextBox->Text;
|
||||
EnteredState = stateTextBox->Text;
|
||||
EnteredZip = zipTextBox->Text;
|
||||
OnButtonClicked(this, gcnew MyPageEventArgs(okClicked));
|
||||
}
|
||||
//</SnippetWPFPageButtonClicked>
|
||||
//<SnippetWPFPageSetFontFamily>
|
||||
void WPFPage::SetFontFamily(FontFamily^ newFontFamily)
|
||||
{
|
||||
_defaultFontFamily = newFontFamily;
|
||||
titleText->FontFamily = newFontFamily;
|
||||
nameLabel->FontFamily = newFontFamily;
|
||||
addressLabel->FontFamily = newFontFamily;
|
||||
cityLabel->FontFamily = newFontFamily;
|
||||
stateLabel->FontFamily = newFontFamily;
|
||||
zipLabel->FontFamily = newFontFamily;
|
||||
}
|
||||
//</SnippetWPFPageSetFontFamily>
|
||||
void WPFPage::SetFontStyle(FontStyle newFontStyle)
|
||||
{
|
||||
_defaultFontStyle = newFontStyle;
|
||||
titleText->FontStyle = newFontStyle;
|
||||
nameLabel->FontStyle = newFontStyle;
|
||||
addressLabel->FontStyle = newFontStyle;
|
||||
cityLabel->FontStyle = newFontStyle;
|
||||
stateLabel->FontStyle = newFontStyle;
|
||||
zipLabel->FontStyle = newFontStyle;
|
||||
}
|
||||
|
||||
void WPFPage::SetFontSize(double newFontSize)
|
||||
{
|
||||
_defaultFontSize = newFontSize;
|
||||
titleText->FontSize = newFontSize;
|
||||
nameLabel->FontSize = newFontSize;
|
||||
addressLabel->FontSize = newFontSize;
|
||||
cityLabel->FontSize = newFontSize;
|
||||
stateLabel->FontSize = newFontSize;
|
||||
zipLabel->FontSize = newFontSize;
|
||||
}
|
||||
|
||||
void WPFPage::SetFontWeight(FontWeight newFontWeight)
|
||||
{
|
||||
_defaultFontWeight = newFontWeight;
|
||||
titleText->FontWeight = newFontWeight;
|
||||
nameLabel->FontWeight = newFontWeight;
|
||||
addressLabel->FontWeight = newFontWeight;
|
||||
cityLabel->FontWeight = newFontWeight;
|
||||
stateLabel->FontWeight = newFontWeight;
|
||||
zipLabel->FontWeight = newFontWeight;
|
||||
}
|
||||
|
||||
void WPFPage::SetForeBrush(Brush^ newForeBrush)
|
||||
{
|
||||
_defaultForeBrush = newForeBrush;
|
||||
titleText->Foreground = newForeBrush;
|
||||
nameLabel->Foreground = newForeBrush;
|
||||
addressLabel->Foreground = newForeBrush;
|
||||
cityLabel->Foreground = newForeBrush;
|
||||
stateLabel->Foreground = newForeBrush;
|
||||
zipLabel->Foreground = newForeBrush;
|
||||
}
|
||||
|
||||
MyPageEventArgs::MyPageEventArgs() {}
|
||||
|
||||
MyPageEventArgs::MyPageEventArgs(bool okClicked)
|
||||
{
|
||||
IsOK = okClicked;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Documents;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
|
||||
public ref class MyPageEventArgs : EventArgs
|
||||
{
|
||||
public:
|
||||
MyPageEventArgs();
|
||||
MyPageEventArgs(bool isOK);
|
||||
|
||||
property bool IsOK;
|
||||
};
|
||||
|
||||
public ref class WPFPage : public Grid
|
||||
{
|
||||
private:
|
||||
Label ^titleText, ^nameLabel, ^addressLabel, ^cityLabel, ^stateLabel, ^zipLabel;
|
||||
TextBox ^nameTextBox, ^addressTextBox, ^cityTextBox, ^stateTextBox, ^zipTextBox;
|
||||
Button ^okButton, ^cancelButton;
|
||||
String ^_name, ^_address, ^_city, ^_state, ^_zip;
|
||||
FontFamily ^_defaultFontFamily;
|
||||
void SetFontFamily(FontFamily^ newFont);
|
||||
FontStyle _defaultFontStyle;
|
||||
void SetFontStyle(FontStyle newFont);
|
||||
double _defaultFontSize;
|
||||
void SetFontSize(double newSize);
|
||||
FontWeight _defaultFontWeight;
|
||||
void SetFontWeight(FontWeight newWeight);
|
||||
Brush^ _defaultForeBrush;
|
||||
void SetForeBrush(Brush^ newForeBrush);
|
||||
|
||||
Label ^ CreateLabel(int column, int row, String ^text);
|
||||
TextBox ^ CreateTextBox(int column, int row, int span);
|
||||
Button ^CreateButton(int column, int row, String ^text);
|
||||
void ButtonClicked(Object ^sender, RoutedEventArgs ^args);
|
||||
|
||||
//<SnippetWPFPageEventDecl>
|
||||
public:
|
||||
delegate void ButtonClickHandler(Object ^, MyPageEventArgs ^);
|
||||
WPFPage();
|
||||
WPFPage(int height, int width);
|
||||
event ButtonClickHandler ^OnButtonClicked;
|
||||
//</SnippetWPFPageEventDecl>
|
||||
//properties
|
||||
//<SnippetWPFPageFontFamilyProperty>
|
||||
property FontFamily^ DefaultFontFamily
|
||||
{
|
||||
FontFamily^ get() {return _defaultFontFamily;}
|
||||
void set(FontFamily^ value) {SetFontFamily(value);}
|
||||
};
|
||||
//</SnippetWPFPageFontFamilyProperty>
|
||||
property FontStyle DefaultFontStyle
|
||||
{
|
||||
FontStyle get() {return _defaultFontStyle;}
|
||||
void set(FontStyle value) {SetFontStyle(value);}
|
||||
};
|
||||
property double DefaultFontSize
|
||||
{
|
||||
double get() {return _defaultFontSize;}
|
||||
void set(double value) {SetFontSize(value);}
|
||||
};
|
||||
property FontWeight DefaultFontWeight
|
||||
{
|
||||
FontWeight get() {return _defaultFontWeight;}
|
||||
void set(FontWeight value) {SetFontWeight(value);}
|
||||
};
|
||||
|
||||
property Brush^ DefaultForeBrush
|
||||
{
|
||||
Brush^ get() {return _defaultForeBrush;}
|
||||
void set(Brush^ value) {SetForeBrush(value);}
|
||||
};
|
||||
|
||||
property String ^EnteredName;
|
||||
property String ^EnteredAddress;
|
||||
property String ^EnteredCity;
|
||||
property String ^EnteredState;
|
||||
property String ^EnteredZip;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,602 @@
|
||||
// Win32HostingWPFPage.cpp : Defines the entry point for the application.
|
||||
//
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Runtime;
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Win32HostingWPFPage.h"
|
||||
#include <gcroot.h>
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
// Global Variables:
|
||||
HINSTANCE hInst; // current instance
|
||||
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
|
||||
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
|
||||
HWND wpfHwnd; //The hwnd associated with the hosted WPF page
|
||||
|
||||
// Forward declarations of functions included in this code module:
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
||||
BOOL InitInstance(HINSTANCE, int);
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||
//<SnippetWinMain>
|
||||
[System::STAThreadAttribute] //Needs to be an STA thread to play nicely with WPF
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPTSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
//</SnippetWinMain>
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
// TODO: Place code here.
|
||||
|
||||
MSG msg;
|
||||
HACCEL hAccelTable;
|
||||
|
||||
// Initialize global strings
|
||||
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
LoadString(hInstance, IDC_WIN32HOSTINGWPFPAGE, szWindowClass, MAX_LOADSTRING);
|
||||
MyRegisterClass(hInstance);
|
||||
|
||||
// Perform application initialization:
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WIN32HOSTINGWPFPAGE));
|
||||
|
||||
// Main message loop:
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
return (int) msg.wParam;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: MyRegisterClass()
|
||||
//
|
||||
// PURPOSE: Registers the window class.
|
||||
//
|
||||
// COMMENTS:
|
||||
//
|
||||
// This function and its usage are only necessary if you want this code
|
||||
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
|
||||
// function that was added to Windows 95. It is important to call this function
|
||||
// so that the application will get 'well formed' small icons associated
|
||||
// with it.
|
||||
//
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEX wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WIN32HOSTINGWPFPAGE));
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_BTNSHADOW);
|
||||
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_WIN32HOSTINGWPFPAGE);
|
||||
wcex.lpszClassName = szWindowClass;
|
||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
||||
|
||||
return RegisterClassEx(&wcex);
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: InitInstance(HINSTANCE, int)
|
||||
//
|
||||
// PURPOSE: Saves instance handle and creates main window
|
||||
//
|
||||
// COMMENTS:
|
||||
//
|
||||
// In this function, we save the instance handle in a global variable and
|
||||
// create and display the main program window.
|
||||
//
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
hInst = hInstance; // Store instance handle in our global variable
|
||||
|
||||
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
|
||||
|
||||
if (!hWnd)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
|
||||
//
|
||||
// PURPOSE: Processes messages for the main window.
|
||||
//
|
||||
// WM_COMMAND - process the application menu
|
||||
// WM_PAINT - Paint the main window
|
||||
// WM_DESTROY - post a quit message and return
|
||||
//
|
||||
//
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int wmId, wmEvent;
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
//<SnippetWMCreate>
|
||||
case WM_CREATE :
|
||||
GetClientRect(hWnd, &rect);
|
||||
wpfHwnd = GetHwnd(hWnd, rect.right-375, 0, 375, 250);
|
||||
CreateDataDisplay(hWnd, 275, rect.right-375, 375);
|
||||
CreateRadioButtons(hWnd);
|
||||
break;
|
||||
//</SnippetWMCreate>
|
||||
//<SnippetWMCommandToBG>
|
||||
case WM_COMMAND:
|
||||
wmId = LOWORD(wParam);
|
||||
wmEvent = HIWORD(wParam);
|
||||
|
||||
switch (wmId)
|
||||
{
|
||||
//Menu selections
|
||||
case IDM_ABOUT:
|
||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
||||
break;
|
||||
case IDM_EXIT:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
//RadioButtons
|
||||
case IDC_ORIGINALBACKGROUND :
|
||||
WPFPageHost::hostedPage->Background = WPFPageHost::initBackBrush;
|
||||
break;
|
||||
case IDC_LIGHTGREENBACKGROUND :
|
||||
WPFPageHost::hostedPage->Background = gcnew SolidColorBrush(Colors::LightGreen);
|
||||
break;
|
||||
case IDC_LIGHTSALMONBACKGROUND :
|
||||
WPFPageHost::hostedPage->Background = gcnew SolidColorBrush(Colors::LightSalmon);
|
||||
break;
|
||||
//</SnippetWMCommandToBG>
|
||||
|
||||
case IDC_ORIGINALFONTFAMILY :
|
||||
WPFPageHost::hostedPage->DefaultFontFamily = WPFPageHost::initFontFamily;
|
||||
break;
|
||||
case IDC_TIMESNEWROMAN :
|
||||
WPFPageHost::hostedPage->DefaultFontFamily = gcnew FontFamily("Times New Roman");
|
||||
break;
|
||||
case IDC_WINGDINGS:
|
||||
WPFPageHost::hostedPage->DefaultFontFamily = gcnew FontFamily("WingDings");
|
||||
break;
|
||||
case IDC_ORIGINALFONTSTYLE :
|
||||
WPFPageHost::hostedPage->DefaultFontStyle = WPFPageHost::initFontStyle;
|
||||
break;
|
||||
case IDC_ITALIC :
|
||||
WPFPageHost::hostedPage->DefaultFontStyle = System::Windows::FontStyles::Italic;
|
||||
break;
|
||||
case IDC_ORIGINALFONTSIZE :
|
||||
WPFPageHost::hostedPage->DefaultFontSize = WPFPageHost::initFontSize;
|
||||
break;
|
||||
case IDC_TENPOINT :
|
||||
WPFPageHost::hostedPage->DefaultFontSize = 10;
|
||||
break;
|
||||
case IDC_TWELVEPOINT :
|
||||
WPFPageHost::hostedPage->DefaultFontSize = 12;
|
||||
break;
|
||||
case IDC_ORIGINALFONTWEIGHT :
|
||||
WPFPageHost::hostedPage->DefaultFontWeight = WPFPageHost::initFontWeight;
|
||||
break;
|
||||
case IDC_BOLD :
|
||||
WPFPageHost::hostedPage->DefaultFontWeight = FontWeights::Bold;
|
||||
break;
|
||||
case IDC_ORIGINALFOREGROUND :
|
||||
WPFPageHost::hostedPage->DefaultForeBrush = WPFPageHost::initForeBrush;
|
||||
break;
|
||||
case IDC_REDFOREGROUND :
|
||||
WPFPageHost::hostedPage->DefaultForeBrush = gcnew SolidColorBrush(Colors::Red);
|
||||
break;
|
||||
case IDC_YELLOWFOREGROUND :
|
||||
WPFPageHost::hostedPage->DefaultForeBrush = gcnew SolidColorBrush(Colors::Yellow);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
// TODO: Add any drawing code here...
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Message handler for about box.
|
||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (INT_PTR)FALSE;
|
||||
}
|
||||
|
||||
WPFPageHost::WPFPageHost(){}
|
||||
//<SnippetGetHwnd>
|
||||
HWND GetHwnd(HWND parent, int x, int y, int width, int height)
|
||||
{
|
||||
System::Windows::Interop::HwndSourceParameters^ sourceParams = gcnew System::Windows::Interop::HwndSourceParameters(
|
||||
"hi" // NAME
|
||||
);
|
||||
sourceParams->PositionX = x;
|
||||
sourceParams->PositionY = y;
|
||||
sourceParams->Height = height;
|
||||
sourceParams->Width = width;
|
||||
sourceParams->ParentWindow = IntPtr(parent);
|
||||
sourceParams->WindowStyle = WS_VISIBLE | WS_CHILD; // style
|
||||
System::Windows::Interop::HwndSource^ source = gcnew System::Windows::Interop::HwndSource(*sourceParams);
|
||||
WPFPage ^myPage = gcnew WPFPage(width, height);
|
||||
//Assign a reference to the WPF page and a set of UI properties to a set of static properties in a class
|
||||
//that is designed for that purpose.
|
||||
WPFPageHost::hostedPage = myPage;
|
||||
WPFPageHost::initBackBrush = myPage->Background;
|
||||
WPFPageHost::initFontFamily = myPage->DefaultFontFamily;
|
||||
WPFPageHost::initFontSize = myPage->DefaultFontSize;
|
||||
WPFPageHost::initFontStyle = myPage->DefaultFontStyle;
|
||||
WPFPageHost::initFontWeight = myPage->DefaultFontWeight;
|
||||
WPFPageHost::initForeBrush = myPage->DefaultForeBrush;
|
||||
myPage->OnButtonClicked += gcnew WPFPage::ButtonClickHandler(WPFButtonClicked);
|
||||
source->RootVisual = myPage;
|
||||
return (HWND) source->Handle.ToPointer();
|
||||
}
|
||||
//</SnippetGetHwnd>
|
||||
//<SnippetWPFButtonClicked>
|
||||
void WPFButtonClicked(Object ^sender, MyPageEventArgs ^args)
|
||||
{
|
||||
if(args->IsOK) //display data if OK button was clicked
|
||||
{
|
||||
WPFPage ^myPage = WPFPageHost::hostedPage;
|
||||
LPCWSTR userName = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("Name: " + myPage->EnteredName).ToPointer();
|
||||
SetWindowText(nameLabel, userName);
|
||||
LPCWSTR userAddress = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("Address: " + myPage->EnteredAddress).ToPointer();
|
||||
SetWindowText(addressLabel, userAddress);
|
||||
LPCWSTR userCity = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("City: " + myPage->EnteredCity).ToPointer();
|
||||
SetWindowText(cityLabel, userCity);
|
||||
LPCWSTR userState = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("State: " + myPage->EnteredState).ToPointer();
|
||||
SetWindowText(stateLabel, userState);
|
||||
LPCWSTR userZip = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("Zip: " + myPage->EnteredZip).ToPointer();
|
||||
SetWindowText(zipLabel, userZip);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowText(nameLabel, L"Name: ");
|
||||
SetWindowText(addressLabel, L"Address: ");
|
||||
SetWindowText(cityLabel, L"City: ");
|
||||
SetWindowText(stateLabel, L"State: ");
|
||||
SetWindowText(zipLabel, L"Zip: ");
|
||||
}
|
||||
}
|
||||
//</SnippetWPFButtonClicked>
|
||||
|
||||
void CreateDataDisplay(HWND hWnd, int top, int left, int width)
|
||||
{
|
||||
dataDisplayLabel = CreateWindowEx(0, L"static", L"Data From WPF Control",
|
||||
WS_CHILD | WS_VISIBLE | SS_LEFT,
|
||||
left, top+25,
|
||||
width, 25,
|
||||
hWnd,
|
||||
(HMENU) 1,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
nameLabel = CreateWindowEx(0, L"static", L"Name: ",
|
||||
WS_CHILD | WS_VISIBLE | SS_LEFT,
|
||||
left, top+60,
|
||||
width, 25,
|
||||
hWnd,
|
||||
(HMENU) 1,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
addressLabel = CreateWindowEx(0, L"static", L"Address: ",
|
||||
WS_CHILD | WS_VISIBLE | SS_LEFT,
|
||||
left, top+85,
|
||||
width, 25,
|
||||
hWnd,
|
||||
(HMENU) 1,
|
||||
hInst,
|
||||
NULL);
|
||||
cityLabel = CreateWindowEx(0, L"static", L"City: ",
|
||||
WS_CHILD | WS_VISIBLE | SS_LEFT,
|
||||
left, top+110,
|
||||
width, 25,
|
||||
hWnd,
|
||||
(HMENU) 1,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
stateLabel = CreateWindowEx(0, L"static", L"State: ",
|
||||
WS_CHILD | WS_VISIBLE | SS_LEFT,
|
||||
left, top+135,
|
||||
width, 25,
|
||||
hWnd,
|
||||
(HMENU) 1,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
zipLabel = CreateWindowEx(0, L"static", L"Zip: ",
|
||||
WS_CHILD | WS_VISIBLE | SS_LEFT,
|
||||
left, top+160,
|
||||
width, 25,
|
||||
hWnd,
|
||||
(HMENU) 1,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
void CreateRadioButtons(HWND hWnd)
|
||||
{
|
||||
//Background color
|
||||
int top = 25;
|
||||
controlDisplayLabel = CreateWindowEx(0, L"static", L"ControlProperties",
|
||||
WS_CHILD | WS_VISIBLE | SS_LEFT,
|
||||
10, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
NULL,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
//Background radio buttons
|
||||
top += 35;
|
||||
backgroundGroup = CreateWindowEx(0, L"button", L"Background Color",
|
||||
WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
|
||||
10, top,
|
||||
175, 100,
|
||||
hWnd,
|
||||
(HMENU) IDC_ORIGINALBACKGROUND,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
originalBackgroundButton = CreateWindowEx(0, L"button", L"Original",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_ORIGINALBACKGROUND,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
lightGreenBackgroundButton = CreateWindowEx(0, L"button", L"Light Green",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_LIGHTGREENBACKGROUND,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
top += 20;
|
||||
lightSalmonBackgroundButton = CreateWindowEx(0, L"button", L"Light Salmon",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_LIGHTSALMONBACKGROUND,
|
||||
hInst,
|
||||
NULL);
|
||||
//Foreground color
|
||||
top += 45;
|
||||
foregroundGroup = CreateWindowEx(0, L"button", L"Foreground Color",
|
||||
WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
|
||||
10, top,
|
||||
175, 100,
|
||||
hWnd,
|
||||
NULL,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
originalForegroundButton = CreateWindowEx(0, L"button", L"Original",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_ORIGINALFOREGROUND,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
redForegroundButton = CreateWindowEx(0, L"button", L"Red",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_REDFOREGROUND,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
top += 20;
|
||||
yellowForegroundButton = CreateWindowEx(0, L"button", L"Yellow",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_YELLOWFOREGROUND,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
//Font family
|
||||
top += 45;
|
||||
fontFamilyGroup = CreateWindowEx(0, L"button", L"Font Family",
|
||||
WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
|
||||
10, top,
|
||||
175, 100,
|
||||
hWnd,
|
||||
NULL,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
originalFontFamily = CreateWindowEx(0, L"button", L"Original",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_ORIGINALFONTFAMILY,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
timesFontFamily = CreateWindowEx(0, L"button", L"Times New Roman",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
140, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_TIMESNEWROMAN,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
top += 20;
|
||||
wingdingsFontFamily = CreateWindowEx(0, L"button", L"WingDings",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_WINGDINGS,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
//Font size
|
||||
top += 45;
|
||||
fontSizeGroup = CreateWindowEx(0, L"button", L"Font Size",
|
||||
WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
|
||||
10, top,
|
||||
175, 100,
|
||||
hWnd,
|
||||
NULL,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
originalFontSize = CreateWindowEx(0, L"button", L"Original",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_ORIGINALFONTSIZE,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
tenpointFontSize = CreateWindowEx(0, L"button", L"10",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_TENPOINT,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
top += 20;
|
||||
twelvepointFontSize = CreateWindowEx(0, L"button", L"12",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_TWELVEPOINT,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
//Font style
|
||||
top += 45;
|
||||
fontStyleGroup = CreateWindowEx(0, L"button", L"Font Style",
|
||||
WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
|
||||
10, top,
|
||||
175, 70,
|
||||
hWnd,
|
||||
NULL,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
originalFontStyle = CreateWindowEx(0, L"button", L"Original",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_ORIGINALFONTSTYLE,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
italicFontStyle = CreateWindowEx(0, L"button", L"Italic",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_ITALIC,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
//Font weight
|
||||
top += 45;
|
||||
fontWeightGroup = CreateWindowEx(0, L"button", L"Font Weight",
|
||||
WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
|
||||
10, top,
|
||||
175, 70,
|
||||
hWnd,
|
||||
NULL,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
originalFontWeight = CreateWindowEx(0, L"button", L"Original",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_ORIGINALFONTWEIGHT,
|
||||
hInst,
|
||||
NULL);
|
||||
top += 20;
|
||||
boldFontWeight = CreateWindowEx(0, L"button", L"Bold",
|
||||
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
|
||||
15, top,
|
||||
125, 25,
|
||||
hWnd,
|
||||
(HMENU) IDC_BOLD,
|
||||
hInst,
|
||||
NULL);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource.h"
|
||||
#include "WPFPage.h"
|
||||
#include <vcclr.h>
|
||||
#include <string.h>
|
||||
|
||||
//Radiobutton IDs
|
||||
#define IDC_ORIGINALBACKGROUND 1
|
||||
#define IDC_LIGHTGREENBACKGROUND 2
|
||||
#define IDC_LIGHTSALMONBACKGROUND 3
|
||||
#define IDC_ORIGINALFOREGROUND 4
|
||||
#define IDC_REDFOREGROUND 5
|
||||
#define IDC_YELLOWFOREGROUND 6
|
||||
#define IDC_ORIGINALFONTFAMILY 7
|
||||
#define IDC_TIMESNEWROMAN 8
|
||||
#define IDC_WINGDINGS 9
|
||||
#define IDC_ORIGINALFONTSIZE 10
|
||||
#define IDC_TENPOINT 11
|
||||
#define IDC_TWELVEPOINT 12
|
||||
#define IDC_ORIGINALFONTSTYLE 13
|
||||
#define IDC_ITALIC 14
|
||||
#define IDC_ORIGINALFONTWEIGHT 15
|
||||
#define IDC_BOLD 16
|
||||
//<SnippetWPFPageHost>
|
||||
public ref class WPFPageHost
|
||||
{
|
||||
public:
|
||||
WPFPageHost();
|
||||
static WPFPage^ hostedPage;
|
||||
//initial property settings
|
||||
static System::Windows::Media::Brush^ initBackBrush;
|
||||
static System::Windows::Media::Brush^ initForeBrush;
|
||||
static System::Windows::Media::FontFamily^ initFontFamily;
|
||||
static System::Windows::FontStyle initFontStyle;
|
||||
static System::Windows::FontWeight initFontWeight;
|
||||
static double initFontSize;
|
||||
};
|
||||
//</SnippetWPFPageHost>
|
||||
|
||||
RECT rect;
|
||||
HWND GetHwnd(HWND parent, int x, int y, int width, int height);
|
||||
HWND dataDisplayLabel, nameLabel, addressLabel, cityLabel, stateLabel, zipLabel;
|
||||
HWND controlDisplayLabel, foregroundLabel, fontLabel, sizeLabel, styleLabel, weightLabel;
|
||||
HWND backgroundGroup, originalBackgroundButton, lightGreenBackgroundButton, lightSalmonBackgroundButton;
|
||||
HWND foregroundGroup, originalForegroundButton, redForegroundButton, yellowForegroundButton;
|
||||
HWND fontFamilyGroup, originalFontFamily, timesFontFamily, wingdingsFontFamily;
|
||||
HWND fontSizeGroup, originalFontSize, tenpointFontSize, twelvepointFontSize;
|
||||
HWND fontStyleGroup, originalFontStyle, italicFontStyle;
|
||||
HWND fontWeightGroup, originalFontWeight, boldFontWeight;
|
||||
void WPFButtonClicked(Object ^sender, MyPageEventArgs ^args);
|
||||
void CreateDataDisplay(HWND hWnd, int top, int left, int width);
|
||||
void CreateRadioButtons(HWND hWnd);
|
||||
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,127 @@
|
||||
//Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
|
||||
IDI_WIN32HOSTINGWPFPAGE ICON "Win32HostingWPFPage.ico"
|
||||
IDI_SMALL ICON "small.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDC_WIN32HOSTINGWPFPAGE MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "E&xit", IDM_EXIT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About ...", IDM_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDC_WIN32HOSTINGWPFPAGE ACCELERATORS
|
||||
BEGIN
|
||||
"?", IDM_ABOUT, ASCII, ALT
|
||||
"/", IDM_ABOUT, ASCII, ALT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG 22, 17, 230, 75
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About"
|
||||
FONT 8, "System"
|
||||
BEGIN
|
||||
ICON IDI_WIN32HOSTINGWPFPAGE,IDC_MYICON,14,9,16,16
|
||||
LTEXT "Win32HostingWPFPage Version 1.0",IDC_STATIC,49,10,119,8,SS_NOPREFIX
|
||||
LTEXT "Copyright (C) 2005",IDC_STATIC,49,20,119,8
|
||||
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""windows.h""\r\n"
|
||||
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDC_WIN32HOSTINGWPFPAGE "WIN32HOSTINGWPFPAGE"
|
||||
IDS_APP_TITLE "Win32HostingWPFPage"
|
||||
END
|
||||
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{8E4A7F4E-64A9-4313-AAD8-C0E888223A32}</ProjectGuid>
|
||||
<RootNamespace>Win32HostingWPFPage</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21230.0</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>mscoree.lib %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalLibraryDirectories>C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationProvider">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="UIAutomationTypes">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Win32HostingWPFPage.cpp" />
|
||||
<ClCompile Include="WPFPage.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="Win32HostingWPFPage.h" />
|
||||
<ClInclude Include="WPFPage.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="small.ico" />
|
||||
<None Include="Win32HostingWPFPage.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Win32HostingWPFPage.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// Win32HostingWPFPag.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
@@ -0,0 +1,37 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
// Modify the following defines if you have to target a platform prior to the ones specified below.
|
||||
// Refer to MSDN for the latest info on corresponding values for different platforms.
|
||||
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
|
||||
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
|
||||
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
|
||||
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
|
||||
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
|
||||
#endif
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
|
||||
// C RunTime Header Files
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
@@ -0,0 +1,92 @@
|
||||
//WrapPanel_Code.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Threading;
|
||||
|
||||
namespace WrapPanel_Demo {
|
||||
|
||||
public ref class app : System::Windows::Application {
|
||||
|
||||
private:
|
||||
System::Windows::Controls::Button^ btn1;
|
||||
System::Windows::Controls::Button^ btn2;
|
||||
System::Windows::Controls::Button^ btn3;
|
||||
System::Windows::Controls::WrapPanel^ myWrapPanel;
|
||||
System::Windows::Window^ mainWindow;
|
||||
|
||||
protected:
|
||||
virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// <Snippet1>
|
||||
|
||||
// Create the application's main window
|
||||
mainWindow = gcnew System::Windows::Window();
|
||||
mainWindow->Title = "WrapPanel Sample";
|
||||
|
||||
// <Snippet2>
|
||||
|
||||
// Instantiate a new WrapPanel and set properties
|
||||
myWrapPanel = gcnew WrapPanel();
|
||||
myWrapPanel->Background = Brushes::Azure;
|
||||
myWrapPanel->Orientation = Orientation::Horizontal;
|
||||
// <Snippet4>
|
||||
myWrapPanel->ItemHeight = 25;
|
||||
// </Snippet4>
|
||||
|
||||
// <Snippet3>
|
||||
myWrapPanel->ItemWidth = 75;
|
||||
// </Snippet3>
|
||||
myWrapPanel->Width = 150;
|
||||
myWrapPanel->HorizontalAlignment = HorizontalAlignment::Left;
|
||||
myWrapPanel->VerticalAlignment = VerticalAlignment::Top;
|
||||
|
||||
// Define 3 button elements. Each button is sized at width of 75, so the third button wraps to the next line.
|
||||
btn1 = gcnew Button();
|
||||
btn1->Content = "Button 1";
|
||||
btn2 = gcnew Button();
|
||||
btn2->Content = "Button 2";
|
||||
btn3 = gcnew Button();
|
||||
btn3->Content = "Button 3";
|
||||
|
||||
// Add the buttons to the parent WrapPanel using the Children.Add method.
|
||||
myWrapPanel->Children->Add(btn1);
|
||||
myWrapPanel->Children->Add(btn2);
|
||||
myWrapPanel->Children->Add(btn3);
|
||||
|
||||
// Add the WrapPanel to the MainWindow as Content
|
||||
mainWindow->Content = myWrapPanel;
|
||||
mainWindow->Show();
|
||||
// </Snippet2>
|
||||
|
||||
//</Snippet1>
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass {
|
||||
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
WrapPanel_Demo::app^ app = gcnew WrapPanel_Demo::app();
|
||||
app->Run();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return WrapPanel_Demo::EntryClass::Main();
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>WrapPanel_Code</ProjectName>
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21125.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="WrapPanel_Code.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,459 @@
|
||||
//XpsCreate.cpp file
|
||||
|
||||
using namespace System;
|
||||
using namespace System::IO;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::IO::Packaging;
|
||||
using namespace System::Xml;
|
||||
using namespace System::Windows::Forms;
|
||||
using namespace System::Windows::Xps;
|
||||
using namespace System::Windows::Xps::Packaging;
|
||||
using namespace System::Printing;
|
||||
|
||||
public ref class XpsCreate {
|
||||
|
||||
private:
|
||||
literal System::String^ packageWithPrintTicketName = "XpsDocument-withPrintTicket.xps";
|
||||
literal System::String^ packageName = "XpsDocument.xps";
|
||||
literal System::String^ image1 = "picture.jpg";
|
||||
literal System::String^ image2 = "image.tif";
|
||||
literal System::String^ font1 = "courier.ttf";
|
||||
literal System::String^ font2 = "arial.ttf";
|
||||
literal System::String^ fontContentType = "application/vnd.ms-package.obfuscated-opentype";
|
||||
|
||||
public:
|
||||
[STAThread()]
|
||||
static void Main (array<System::String^>^ args)
|
||||
{
|
||||
XpsCreate^ xpsCreate = gcnew XpsCreate();
|
||||
xpsCreate->Run();
|
||||
};
|
||||
|
||||
public:
|
||||
// -------------------------------- Run -----------------------------------
|
||||
/// <summary>
|
||||
/// Creates two XpsDocument packages, the first without a PrintTicket
|
||||
/// and a second with a PrintTicket.</summary>
|
||||
void Run ()
|
||||
{
|
||||
// First, create an XpsDocument without a PrintTicket. - - - - - - - -
|
||||
|
||||
// If the document package exists from a previous run, delete it.
|
||||
if (File::Exists(packageName))
|
||||
{
|
||||
File::Delete(packageName);
|
||||
}
|
||||
//<SnippetXpsCreatePackageOpen>
|
||||
// Create an XpsDocument package (without PrintTicket).
|
||||
{
|
||||
Package^ package = Package::Open(packageName);
|
||||
try
|
||||
{
|
||||
XpsDocument^ xpsDocument = gcnew XpsDocument(package);
|
||||
|
||||
// Add the package content (false=without PrintTicket).
|
||||
AddPackageContent(xpsDocument, false);
|
||||
|
||||
// Close the package.
|
||||
xpsDocument->Close();
|
||||
} finally
|
||||
{
|
||||
delete package;
|
||||
}
|
||||
//</SnippetXpsCreatePackageOpen>
|
||||
|
||||
// Next, create a second XpsDocument with a PrintTicket. - - - - - - -
|
||||
|
||||
// If the document package exists from a previous run, delete it.
|
||||
if (File::Exists(packageWithPrintTicketName))
|
||||
{
|
||||
File::Delete(packageWithPrintTicketName);
|
||||
}
|
||||
|
||||
// Create an XpsDocument with PrintTicket.
|
||||
{
|
||||
Package^ package2 = Package::Open(packageWithPrintTicketName);
|
||||
try
|
||||
{
|
||||
XpsDocument^ xpsDocumentWithPrintTicket = gcnew XpsDocument(package2);
|
||||
|
||||
// Add the package content (true=with PrintTicket).
|
||||
AddPackageContent(xpsDocumentWithPrintTicket, true);
|
||||
|
||||
// Close the package.
|
||||
xpsDocumentWithPrintTicket->Close();
|
||||
} finally
|
||||
{
|
||||
delete package2;
|
||||
}
|
||||
}
|
||||
|
||||
System::String^ msg = "Created two XPS document packages:\n - " + packageName + "\n - " + packageWithPrintTicketName;
|
||||
MessageBox::Show(msg, "Normal Completion", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
//<SnippetXpsCreateAddPkgContent>
|
||||
// ------------------------- AddPackageContent ----------------------------
|
||||
/// <summary>
|
||||
/// Adds a predefined set of content to a given XPS document.</summary>
|
||||
/// <param name="xpsDocument">
|
||||
/// The package to add the document content to.</param>
|
||||
/// <param name="attachPrintTicket">
|
||||
/// true to include a PrintTicket with the
|
||||
/// document; otherwise, false.</param>
|
||||
void AddPackageContent (XpsDocument^ xpsDocument, bool attachPrintTicket)
|
||||
{
|
||||
try
|
||||
{
|
||||
PrintTicket^ printTicket = GetPrintTicketFromPrinter();
|
||||
// PrintTicket is null, there is no need to attach one.
|
||||
if (printTicket == nullptr)
|
||||
{
|
||||
attachPrintTicket = false;
|
||||
}
|
||||
// Add a FixedDocumentSequence at the Package root
|
||||
IXpsFixedDocumentSequenceWriter^ documentSequenceWriter = xpsDocument->AddFixedDocumentSequence();
|
||||
|
||||
// Add the 1st FixedDocument to the FixedDocumentSequence. - - - - -
|
||||
IXpsFixedDocumentWriter^ fixedDocumentWriter = documentSequenceWriter->AddFixedDocument();
|
||||
|
||||
AddDocumentContent(fixedDocumentWriter);
|
||||
|
||||
// Commit the 1st Document
|
||||
fixedDocumentWriter->Commit();
|
||||
|
||||
// Add a 2nd FixedDocument to the FixedDocumentSequence. - - - - - -
|
||||
fixedDocumentWriter = documentSequenceWriter->AddFixedDocument();
|
||||
|
||||
// Add content to the 2nd document.
|
||||
AddDocumentContent(fixedDocumentWriter);
|
||||
|
||||
// If attaching PrintTickets, attach one at the FixedDocument level.
|
||||
if (attachPrintTicket)
|
||||
{
|
||||
fixedDocumentWriter->PrintTicket = printTicket;
|
||||
}
|
||||
// Commit the 2nd document.
|
||||
fixedDocumentWriter->Commit();
|
||||
|
||||
// If attaching PrintTickets, attach one at
|
||||
// the package FixedDocumentSequence level.
|
||||
if (attachPrintTicket)
|
||||
{
|
||||
documentSequenceWriter->PrintTicket = printTicket;
|
||||
}
|
||||
// Commit the FixedDocumentSequence
|
||||
documentSequenceWriter->Commit();
|
||||
} catch (XpsPackagingException^ xpsException)
|
||||
{
|
||||
throw xpsException;
|
||||
|
||||
}
|
||||
};// end:AddPackageContent()
|
||||
//</SnippetXpsCreateAddPkgContent>
|
||||
|
||||
|
||||
//<SnippetXpsCreateAddDocContent>
|
||||
// ------------------------- AddDocumentContent ---------------------------
|
||||
/// <summary>
|
||||
/// Adds a predefined set of content to a given document writer.</summary>
|
||||
/// <param name="fixedDocumentWriter">
|
||||
/// The document writer to add the content to.</param>
|
||||
void AddDocumentContent (IXpsFixedDocumentWriter^ fixedDocumentWriter)
|
||||
{
|
||||
// Collection of image and font resources used on the current page.
|
||||
// Key: "XpsImage", "XpsFont"
|
||||
// Value: List of XpsImage or XpsFont resources
|
||||
Dictionary<System::String^,List<XpsResource^>^>^ resources;
|
||||
|
||||
try
|
||||
{
|
||||
// Add Page 1 to current document.
|
||||
IXpsFixedPageWriter^ fixedPageWriter = fixedDocumentWriter->AddFixedPage();
|
||||
// Add the resources for Page 1 and get the resource collection.
|
||||
resources = AddPageResources(fixedPageWriter);
|
||||
|
||||
// Write page content for Page 1.
|
||||
WritePageContent(fixedPageWriter->XmlWriter, "Page 1 of " + fixedDocumentWriter->Uri->ToString(), resources);
|
||||
// Commit Page 1.
|
||||
fixedPageWriter->Commit();
|
||||
|
||||
// Add Page 2 to current document.
|
||||
fixedPageWriter = fixedDocumentWriter->AddFixedPage();
|
||||
|
||||
// Add the resources for Page 2 and get the resource collection.
|
||||
resources = AddPageResources(fixedPageWriter);
|
||||
|
||||
// Write page content to Page 2.
|
||||
WritePageContent(fixedPageWriter->XmlWriter, "Page 2 of " + fixedDocumentWriter->Uri->ToString(), resources);
|
||||
// Commit Page 2.
|
||||
fixedPageWriter->Commit();
|
||||
} catch (XpsPackagingException^ xpsException)
|
||||
{
|
||||
throw xpsException;
|
||||
|
||||
}
|
||||
};// end:AddDocumentContent()
|
||||
//</SnippetXpsCreateAddDocContent>
|
||||
|
||||
|
||||
//<SnippetXpsCreateAddPageResources>
|
||||
// -------------------------- AddPageResources ----------------------------
|
||||
Dictionary<System::String^,List<XpsResource^>^>^ AddPageResources (IXpsFixedPageWriter^ fixedPageWriter)
|
||||
{
|
||||
// Collection of all resources for this page.
|
||||
// Key: "XpsImage", "XpsFont"
|
||||
// Value: List of XpsImage or XpsFont
|
||||
Dictionary<System::String^,List<XpsResource^>^>^ resources = gcnew Dictionary<System::String^,List<XpsResource^>^>();
|
||||
|
||||
// Collections of images and fonts used in the current page.
|
||||
List<XpsResource^>^ xpsImages = gcnew List<XpsResource^>();
|
||||
List<XpsResource^>^ xpsFonts = gcnew List<XpsResource^>();
|
||||
|
||||
try
|
||||
{
|
||||
XpsImage^ xpsImage;
|
||||
XpsFont^ xpsFont;
|
||||
|
||||
// Add, Write, and Commit image1 to the current page.
|
||||
xpsImage = fixedPageWriter->AddImage(XpsImageType::JpegImageType);
|
||||
WriteToStream(xpsImage->GetStream(), image1);
|
||||
xpsImage->Commit();
|
||||
xpsImages->Add(xpsImage); // Add image1 as a required resource.
|
||||
|
||||
// Add, Write, and Commit font 1 to the current page.
|
||||
xpsFont = fixedPageWriter->AddFont();
|
||||
WriteObfuscatedStream(xpsFont->Uri->ToString(), xpsFont->GetStream(), font1);
|
||||
xpsFont->Commit();
|
||||
xpsFonts->Add(xpsFont); // Add font1 as a required resource.
|
||||
|
||||
// Add, Write, and Commit image2 to the current page.
|
||||
xpsImage = fixedPageWriter->AddImage(XpsImageType::TiffImageType);
|
||||
WriteToStream(xpsImage->GetStream(), image2);
|
||||
xpsImage->Commit();
|
||||
xpsImages->Add(xpsImage); // Add image2 as a required resource.
|
||||
|
||||
// Add, Write, and Commit font2 to the current page.
|
||||
xpsFont = fixedPageWriter->AddFont(false);
|
||||
WriteToStream(xpsFont->GetStream(), font2);
|
||||
xpsFont->Commit();
|
||||
xpsFonts->Add(xpsFont); // Add font2 as a required resource.
|
||||
|
||||
// Return the image and font resources in a combined collection.
|
||||
resources->Add("XpsImage", xpsImages);
|
||||
resources->Add("XpsFont", xpsFonts);
|
||||
return resources;
|
||||
} catch (XpsPackagingException^ xpsException)
|
||||
{
|
||||
throw xpsException;
|
||||
|
||||
}
|
||||
};// end:AddPageResources()
|
||||
//</SnippetXpsCreateAddPageResources>
|
||||
|
||||
|
||||
//<SnippetPrinterCapabilities>
|
||||
// ---------------------- GetPrintTicketFromPrinter -----------------------
|
||||
/// <summary>
|
||||
/// Returns a PrintTicket based on the current default printer.</summary>
|
||||
/// <returns>
|
||||
/// A PrintTicket for the current local default printer.</returns>
|
||||
PrintTicket^ GetPrintTicketFromPrinter ()
|
||||
{
|
||||
PrintQueue^ printQueue = nullptr;
|
||||
|
||||
LocalPrintServer^ localPrintServer = gcnew LocalPrintServer();
|
||||
|
||||
// Retrieving collection of local printer on user machine
|
||||
PrintQueueCollection^ localPrinterCollection = localPrintServer->GetPrintQueues();
|
||||
|
||||
System::Collections::IEnumerator^ localPrinterEnumerator = localPrinterCollection->GetEnumerator();
|
||||
|
||||
if (localPrinterEnumerator->MoveNext())
|
||||
{
|
||||
// Get PrintQueue from first available printer
|
||||
printQueue = ((PrintQueue^)localPrinterEnumerator->Current);
|
||||
} else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
// Get default PrintTicket from printer
|
||||
PrintTicket^ printTicket = printQueue->DefaultPrintTicket;
|
||||
|
||||
PrintCapabilities^ printCapabilites = printQueue->GetPrintCapabilities();
|
||||
|
||||
// Modify PrintTicket
|
||||
if (printCapabilites->CollationCapability->Contains(Collation::Collated))
|
||||
{
|
||||
printTicket->Collation = Collation::Collated;
|
||||
}
|
||||
if (printCapabilites->DuplexingCapability->Contains(Duplexing::TwoSidedLongEdge))
|
||||
{
|
||||
printTicket->Duplexing = Duplexing::TwoSidedLongEdge;
|
||||
}
|
||||
if (printCapabilites->StaplingCapability->Contains(Stapling::StapleDualLeft))
|
||||
{
|
||||
printTicket->Stapling = Stapling::StapleDualLeft;
|
||||
}
|
||||
return printTicket;
|
||||
};// end:GetPrintTicketFromPrinter()
|
||||
//</SnippetPrinterCapabilities>
|
||||
|
||||
|
||||
//<SnippetXpsCreateWritePageContent>
|
||||
// --------------------------- WritePageContent ---------------------------
|
||||
void WritePageContent (System::Xml::XmlWriter^ xmlWriter, System::String^ documentUri, Dictionary<System::String^,List<XpsResource^>^>^ resources)
|
||||
{
|
||||
List<XpsResource^>^ xpsImages = resources["XpsImage"];
|
||||
List<XpsResource^>^ xpsFonts = resources["XpsFont"];
|
||||
|
||||
// Element are indented for reading purposes only
|
||||
xmlWriter->WriteStartElement("FixedPage");
|
||||
xmlWriter->WriteAttributeString("Width", "816");
|
||||
xmlWriter->WriteAttributeString("Height", "1056");
|
||||
xmlWriter->WriteAttributeString("xmlns", "http://schemas.microsoft.com/xps/2005/06");
|
||||
xmlWriter->WriteAttributeString("xml:lang", "en-US");
|
||||
|
||||
xmlWriter->WriteStartElement("Glyphs");
|
||||
xmlWriter->WriteAttributeString("Fill", "#ff000000");
|
||||
xmlWriter->WriteAttributeString("FontUri", xpsFonts[0]->Uri->ToString());
|
||||
xmlWriter->WriteAttributeString("FontRenderingEmSize", "18");
|
||||
xmlWriter->WriteAttributeString("OriginX", "120");
|
||||
xmlWriter->WriteAttributeString("OriginY", "110");
|
||||
xmlWriter->WriteAttributeString("UnicodeString", documentUri);
|
||||
xmlWriter->WriteEndElement();
|
||||
|
||||
xmlWriter->WriteStartElement("Glyphs");
|
||||
xmlWriter->WriteAttributeString("Fill", "#ff000000");
|
||||
xmlWriter->WriteAttributeString("FontUri", xpsFonts[1]->Uri->ToString());
|
||||
xmlWriter->WriteAttributeString("FontRenderingEmSize", "16");
|
||||
xmlWriter->WriteAttributeString("OriginX", "120");
|
||||
xmlWriter->WriteAttributeString("OriginY", "130");
|
||||
xmlWriter->WriteAttributeString("UnicodeString", "Test String in Arial");
|
||||
xmlWriter->WriteEndElement();
|
||||
|
||||
xmlWriter->WriteStartElement("Path");
|
||||
xmlWriter->WriteAttributeString("Data", "M 120,187 L 301,187 301,321 120,321 z");
|
||||
xmlWriter->WriteStartElement("Path.Fill");
|
||||
xmlWriter->WriteStartElement("ImageBrush");
|
||||
xmlWriter->WriteAttributeString("ImageSource", xpsImages[0]->Uri->ToString());
|
||||
xmlWriter->WriteAttributeString("Viewbox", "0,0,181,134");
|
||||
xmlWriter->WriteAttributeString("TileMode", "None");
|
||||
xmlWriter->WriteAttributeString("ViewboxUnits", "Absolute");
|
||||
xmlWriter->WriteAttributeString("ViewportUnits", "Absolute");
|
||||
xmlWriter->WriteAttributeString("Viewport", "120,187,181,134");
|
||||
xmlWriter->WriteEndElement();
|
||||
xmlWriter->WriteEndElement();
|
||||
xmlWriter->WriteEndElement();
|
||||
|
||||
xmlWriter->WriteStartElement("Path");
|
||||
xmlWriter->WriteAttributeString("Data", "M 120,357 L 324,357 324,510 120,510 z");
|
||||
xmlWriter->WriteStartElement("Path.Fill");
|
||||
xmlWriter->WriteStartElement("ImageBrush");
|
||||
xmlWriter->WriteAttributeString("ImageSource", xpsImages[1]->Uri->ToString());
|
||||
xmlWriter->WriteAttributeString("Viewbox", "0,0,204,153");
|
||||
xmlWriter->WriteAttributeString("TileMode", "None");
|
||||
xmlWriter->WriteAttributeString("ViewboxUnits", "Absolute");
|
||||
xmlWriter->WriteAttributeString("ViewportUnits", "Absolute");
|
||||
xmlWriter->WriteAttributeString("Viewport", "120,357,204,153");
|
||||
xmlWriter->WriteEndElement();
|
||||
xmlWriter->WriteEndElement();
|
||||
xmlWriter->WriteEndElement();
|
||||
xmlWriter->WriteEndElement();
|
||||
};// end:WritePageContent()
|
||||
//</SnippetXpsCreateWritePageContent>
|
||||
|
||||
|
||||
// ----------------------------- WriteToStream ----------------------------
|
||||
void WriteToStream (System::IO::Stream^ stream, System::String^ resource)
|
||||
{
|
||||
int bufSize = 0x1000;
|
||||
array<System::Byte>^ buf = gcnew array<System::Byte>(bufSize);
|
||||
int bytesRead = 0;
|
||||
{
|
||||
System::IO::FileStream^ fileStream = gcnew System::IO::FileStream(resource, FileMode::Open, FileAccess::Read);
|
||||
try
|
||||
{
|
||||
while ((bytesRead = fileStream->Read(buf, 0, bufSize)) > 0)
|
||||
{
|
||||
stream->Write(buf, 0, bytesRead);
|
||||
}
|
||||
} finally
|
||||
{
|
||||
delete fileStream;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------- WriteObfuscatedStream ------------------------
|
||||
void WriteObfuscatedStream (System::String^ resourceName, System::IO::Stream^ stream, System::String^ resource) {
|
||||
int bufSize = 0x1000;
|
||||
int guidByteSize = 16;
|
||||
int obfuscatedByte = 32;
|
||||
|
||||
// Get the GUID byte from the resource name. Typical Font name:
|
||||
// /Resources/Fonts/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.ODTTF
|
||||
int startPos = resourceName->LastIndexOf('/') + 1;
|
||||
int length = resourceName->LastIndexOf('.') - startPos;
|
||||
resourceName = resourceName->Substring(startPos, length);
|
||||
|
||||
System::Guid guid = System::Guid(resourceName);
|
||||
|
||||
System::String^ guidString = guid.ToString("N");
|
||||
|
||||
// Parsing the guid string and coverted into byte value
|
||||
array<System::Byte>^ guidBytes = gcnew array<System::Byte>(guidByteSize);
|
||||
|
||||
for (
|
||||
int i = 0;
|
||||
i < guidBytes->Length;
|
||||
i++)
|
||||
{
|
||||
guidBytes[i] = Convert::ToByte(guidString->Substring(i * 2, 2), 16);
|
||||
}
|
||||
|
||||
{
|
||||
System::IO::FileStream^ filestream = gcnew System::IO::FileStream(resource, FileMode::Open);
|
||||
try
|
||||
{
|
||||
// XOR the first 32 bytes of the source
|
||||
// resource stream with GUID byte.
|
||||
array<System::Byte>^ buf = gcnew array<System::Byte>(obfuscatedByte);
|
||||
filestream->Read(buf, 0, obfuscatedByte);
|
||||
|
||||
for (
|
||||
int i = 0;
|
||||
i < obfuscatedByte;
|
||||
i++)
|
||||
{
|
||||
int guidBytesPos = guidBytes->Length - (i % guidBytes->Length) - 1;
|
||||
buf[i] ^= guidBytes[guidBytesPos];
|
||||
}
|
||||
|
||||
stream->Write(buf, 0, obfuscatedByte);
|
||||
|
||||
// copy remaining stream from source without obfuscation
|
||||
buf = gcnew array<System::Byte>(bufSize);
|
||||
int bytesRead = 0;
|
||||
while ((bytesRead = filestream->Read(buf, 0, bufSize)) > 0)
|
||||
{
|
||||
stream->Write(buf, 0, bytesRead);
|
||||
}
|
||||
} finally
|
||||
{
|
||||
delete filestream;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
//Entry Point:
|
||||
int main (array<System::String^>^ args)
|
||||
{
|
||||
XpsCreate::Main(args);
|
||||
return 0;
|
||||
}
|
||||
|
After Width: | Height: | Size: 18 KiB |
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9E46617A-3919-4B6F-94D6-B3873EC9E79C}</ProjectGuid>
|
||||
<RootNamespace>TemplateNamespace</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21208.0</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="ReachFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System.Printing">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="XpsCreate.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,125 @@
|
||||
//InteractiveExample.cpp file
|
||||
//<SnippetInteractiveAnimationExampleWholePage>
|
||||
/*
|
||||
|
||||
This sample animates the position of an ellipse when
|
||||
the user clicks within the main border. If the user
|
||||
left-clicks, the SnapshotAndReplace HandoffBehavior
|
||||
is used when applying the animations. If the user
|
||||
right-clicks, the Compose HandoffBehavior is used
|
||||
instead.
|
||||
|
||||
*/
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Navigation;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Animation;
|
||||
using namespace System::Windows::Shapes;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Input;
|
||||
|
||||
namespace Microsoft {
|
||||
namespace Samples {
|
||||
namespace Animation {
|
||||
namespace LocalAnimations {
|
||||
public ref class InteractiveAnimationExample : Page {
|
||||
private:
|
||||
TranslateTransform^ interactiveTranslateTransform;
|
||||
Border^ containerBorder;
|
||||
Ellipse^ interactiveEllipse;
|
||||
|
||||
public:
|
||||
InteractiveAnimationExample ()
|
||||
{
|
||||
WindowTitle = "Interactive Animation Example";
|
||||
DockPanel^ myPanel = gcnew DockPanel();
|
||||
myPanel->Margin = Thickness(20.0);
|
||||
|
||||
containerBorder = gcnew Border();
|
||||
containerBorder->Background = Brushes::White;
|
||||
containerBorder->BorderBrush = Brushes::Black;
|
||||
containerBorder->BorderThickness = Thickness(2.0);
|
||||
containerBorder->VerticalAlignment = System::Windows::VerticalAlignment::Stretch;
|
||||
|
||||
interactiveEllipse = gcnew Ellipse();
|
||||
interactiveEllipse->Fill = Brushes::Lime;
|
||||
interactiveEllipse->Stroke = Brushes::Black;
|
||||
interactiveEllipse->StrokeThickness = 2.0;
|
||||
interactiveEllipse->Width = 25;
|
||||
interactiveEllipse->Height = 25;
|
||||
interactiveEllipse->HorizontalAlignment = System::Windows::HorizontalAlignment::Left;
|
||||
interactiveEllipse->VerticalAlignment = System::Windows::VerticalAlignment::Top;
|
||||
|
||||
interactiveTranslateTransform = gcnew TranslateTransform();
|
||||
interactiveEllipse->RenderTransform = interactiveTranslateTransform;
|
||||
|
||||
containerBorder->MouseLeftButtonDown +=
|
||||
gcnew MouseButtonEventHandler(this, &Microsoft::Samples::Animation::LocalAnimations::InteractiveAnimationExample::border_mouseLeftButtonDown);
|
||||
containerBorder->MouseRightButtonDown +=
|
||||
gcnew MouseButtonEventHandler(this, &Microsoft::Samples::Animation::LocalAnimations::InteractiveAnimationExample::border_mouseRightButtonDown);
|
||||
containerBorder->Child = interactiveEllipse;
|
||||
|
||||
myPanel->Children->Add(containerBorder);
|
||||
this->Content = myPanel;
|
||||
};
|
||||
|
||||
private:
|
||||
// When the user left-clicks, use the
|
||||
// SnapshotAndReplace HandoffBehavior when applying the animation.
|
||||
void border_mouseLeftButtonDown (System::Object^ sender, System::Windows::Input::MouseButtonEventArgs^ e)
|
||||
{
|
||||
System::Windows::Point clickPoint = Mouse::GetPosition(containerBorder);
|
||||
|
||||
// Set the target point so the center of the ellipse
|
||||
// ends up at the clicked point.
|
||||
Point targetPoint = Point();
|
||||
targetPoint.X = clickPoint.X - interactiveEllipse->Width / 2;
|
||||
targetPoint.Y = clickPoint.Y - interactiveEllipse->Height / 2;
|
||||
|
||||
// Animate to the target point.
|
||||
DoubleAnimation^ xAnimation = gcnew DoubleAnimation(targetPoint.X,
|
||||
Duration(TimeSpan::FromSeconds(4)));
|
||||
interactiveTranslateTransform->BeginAnimation(TranslateTransform::XProperty, xAnimation, HandoffBehavior::SnapshotAndReplace);
|
||||
|
||||
DoubleAnimation^ yAnimation = gcnew DoubleAnimation(targetPoint.Y,
|
||||
Duration(TimeSpan::FromSeconds(4)));
|
||||
interactiveTranslateTransform->BeginAnimation(TranslateTransform::YProperty, yAnimation, HandoffBehavior::SnapshotAndReplace);
|
||||
|
||||
// Chage the color of the ellipse.
|
||||
interactiveEllipse->Fill = Brushes::Lime;
|
||||
}
|
||||
|
||||
private:
|
||||
// When the user right-clicks, use the
|
||||
// Compose HandoffBehavior when applying the animation.
|
||||
void border_mouseRightButtonDown (System::Object^ sender, System::Windows::Input::MouseButtonEventArgs^ e)
|
||||
{
|
||||
// Find the point where the use clicked.
|
||||
Point clickPoint = Mouse::GetPosition(containerBorder);
|
||||
|
||||
// Set the target point so the center of the ellipse
|
||||
// ends up at the clicked point.
|
||||
Point targetPoint = System::Windows::Point();
|
||||
targetPoint.X = clickPoint.X - interactiveEllipse->Width / 2;
|
||||
targetPoint.Y = clickPoint.Y - interactiveEllipse->Height / 2;
|
||||
|
||||
// Animate to the target point.
|
||||
DoubleAnimation^ xAnimation = gcnew DoubleAnimation(targetPoint.X,
|
||||
Duration(TimeSpan::FromSeconds(4)));
|
||||
interactiveTranslateTransform->BeginAnimation(TranslateTransform::XProperty, xAnimation, HandoffBehavior::Compose);
|
||||
|
||||
DoubleAnimation^ yAnimation = gcnew DoubleAnimation(targetPoint.Y,
|
||||
Duration(TimeSpan::FromSeconds(4)));
|
||||
|
||||
// Change the color of the ellipse.
|
||||
interactiveTranslateTransform->BeginAnimation(TranslateTransform::YProperty, yAnimation, HandoffBehavior::Compose);
|
||||
interactiveEllipse->Fill = Brushes::Orange;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//</SnippetInteractiveAnimationExampleWholePage>
|
||||
@@ -0,0 +1,72 @@
|
||||
//LocalAnimationExample.cpp file
|
||||
//<Snippet11>
|
||||
/*
|
||||
|
||||
This sample demonstrates how to apply non-storyboard animations to a property.
|
||||
To animate in markup, you must use storyboards.
|
||||
|
||||
*/
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Navigation;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Animation;
|
||||
using namespace System::Windows::Shapes;
|
||||
using namespace System::Windows::Controls;
|
||||
|
||||
|
||||
namespace Microsoft {
|
||||
namespace Samples {
|
||||
namespace Animation {
|
||||
namespace LocalAnimations {
|
||||
// Create the demonstration.
|
||||
public ref class LocalAnimationExample : Page {
|
||||
|
||||
public:
|
||||
LocalAnimationExample ()
|
||||
{
|
||||
WindowTitle = "Local Animation Example";
|
||||
StackPanel^ myStackPanel = gcnew StackPanel();
|
||||
myStackPanel->Margin = Thickness(20);
|
||||
|
||||
// Create and set the Button.
|
||||
Button^ aButton = gcnew Button();
|
||||
aButton->Content = "A Button";
|
||||
|
||||
// Animate the Button's Width.
|
||||
DoubleAnimation^ myDoubleAnimation = gcnew DoubleAnimation();
|
||||
myDoubleAnimation->From = 75;
|
||||
myDoubleAnimation->To = 300;
|
||||
myDoubleAnimation->Duration = Duration(TimeSpan::FromSeconds(5));
|
||||
myDoubleAnimation->AutoReverse = true;
|
||||
myDoubleAnimation->RepeatBehavior = RepeatBehavior::Forever;
|
||||
|
||||
// Apply the animation to the button's Width property.
|
||||
aButton->BeginAnimation(Button::WidthProperty, myDoubleAnimation);
|
||||
|
||||
// Create and animate a Brush to set the button's Background.
|
||||
SolidColorBrush^ myBrush = gcnew SolidColorBrush();
|
||||
myBrush->Color = Colors::Blue;
|
||||
|
||||
ColorAnimation^ myColorAnimation = gcnew ColorAnimation();
|
||||
myColorAnimation->From = Colors::Blue;
|
||||
myColorAnimation->To = Colors::Red;
|
||||
myColorAnimation->Duration = Duration(TimeSpan::FromMilliseconds(7000));
|
||||
myColorAnimation->AutoReverse = true;
|
||||
myColorAnimation->RepeatBehavior = RepeatBehavior::Forever;
|
||||
|
||||
// Apply the animation to the brush's Color property.
|
||||
myBrush->BeginAnimation(SolidColorBrush::ColorProperty, myColorAnimation);
|
||||
aButton->Background = myBrush;
|
||||
|
||||
// Add the Button to the panel.
|
||||
myStackPanel->Children->Add(aButton);
|
||||
this->Content = myStackPanel;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//</Snippet11>
|
||||
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>LocalAnimationsExample</ProjectName>
|
||||
<ProjectGuid>{1006019E-21B6-40FF-915C-EBB1C580417E}</ProjectGuid>
|
||||
<RootNamespace>Microsoft.Samples.Animation.LocalAnimations</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>Pure</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21230.0</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="app.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="interactiveexample.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="localanimationexample.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,99 @@
|
||||
//app.cpp file
|
||||
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Windows;
|
||||
using namespace System::Windows::Navigation;
|
||||
using namespace System::Windows::Media;
|
||||
using namespace System::Windows::Media::Animation;
|
||||
using namespace System::Windows::Shapes;
|
||||
using namespace System::Windows::Controls;
|
||||
using namespace System::Windows::Input;
|
||||
|
||||
|
||||
namespace Microsoft {
|
||||
namespace Samples {
|
||||
namespace Animation {
|
||||
namespace LocalAnimations {
|
||||
|
||||
// Forward class declaration.
|
||||
public ref class LocalAnimationExample : Page {
|
||||
public:
|
||||
LocalAnimationExample () ;
|
||||
};
|
||||
|
||||
// Forward class declaration.
|
||||
public ref class InteractiveAnimationExample : Page {
|
||||
public:
|
||||
InteractiveAnimationExample () ;
|
||||
private:
|
||||
TranslateTransform^ interactiveTranslateTransform;
|
||||
Border^ containerBorder;
|
||||
Ellipse^ interactiveEllipse;
|
||||
void border_mouseLeftButtonDown (System::Object^ sender, MouseButtonEventArgs^ e) ;
|
||||
void border_mouseRightButtonDown (System::Object^ sender, MouseButtonEventArgs^ e) ;
|
||||
};
|
||||
|
||||
// SampleViewer class.
|
||||
public ref class SampleViewer : Window {
|
||||
public:
|
||||
SampleViewer (){
|
||||
TabControl^ tControl = gcnew TabControl();
|
||||
TabItem^ tItem = gcnew TabItem();
|
||||
tItem->Header = "Local Animation Example";
|
||||
Frame^ contentFrame = gcnew Frame();
|
||||
contentFrame->Content = gcnew LocalAnimationExample();
|
||||
tItem->Content = contentFrame;
|
||||
tControl->Items->Add(tItem);
|
||||
tItem = gcnew System::Windows::Controls::TabItem();
|
||||
tItem->Header = "Interactive Animation Example";
|
||||
contentFrame = gcnew System::Windows::Controls::Frame();
|
||||
contentFrame->Content = gcnew InteractiveAnimationExample();
|
||||
tItem->Content = contentFrame;
|
||||
tControl->Items->Add(tItem);
|
||||
this->Content = tControl;
|
||||
this->Title = "Local Animations Example";
|
||||
} ;
|
||||
};
|
||||
|
||||
// Application class.
|
||||
public ref class app : Application {
|
||||
protected:
|
||||
virtual void OnStartup (System::Windows::StartupEventArgs^ e) override
|
||||
{
|
||||
Application::OnStartup(e);
|
||||
CreateAndShowMainWindow();
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateAndShowMainWindow ()
|
||||
{
|
||||
// Create the application's main window.
|
||||
Window^ sViewer = gcnew SampleViewer();
|
||||
MainWindow = sViewer;
|
||||
sViewer->Show();
|
||||
};
|
||||
};
|
||||
|
||||
private ref class EntryClass sealed {
|
||||
public:
|
||||
[System::STAThread()]
|
||||
static void Main ()
|
||||
{
|
||||
LocalAnimations::app^ app = gcnew LocalAnimations::app();
|
||||
app->Run();
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Entry Point:
|
||||
[System::STAThreadAttribute()]
|
||||
void main ()
|
||||
{
|
||||
return Microsoft::Samples::Animation::LocalAnimations::EntryClass::Main();
|
||||
}
|
||||