Base camera access sample for Windows RT added.

Microsoft Media Foundation Camera Sample for Windows RT added.
pull/1040/head
Alexander Smorkalov 12 years ago
parent ee591efb9f
commit 4990336760
  1. 81
      samples/winrt/ImageManipulations/C++/AdvancedCapture.xaml
  2. 1034
      samples/winrt/ImageManipulations/C++/AdvancedCapture.xaml.cpp
  3. 103
      samples/winrt/ImageManipulations/C++/AdvancedCapture.xaml.h
  4. 30
      samples/winrt/ImageManipulations/C++/App.xaml
  5. 114
      samples/winrt/ImageManipulations/C++/App.xaml.cpp
  6. 35
      samples/winrt/ImageManipulations/C++/App.xaml.h
  7. 62
      samples/winrt/ImageManipulations/C++/AudioCapture.xaml
  8. 366
      samples/winrt/ImageManipulations/C++/AudioCapture.xaml.cpp
  9. 70
      samples/winrt/ImageManipulations/C++/AudioCapture.xaml.h
  10. 87
      samples/winrt/ImageManipulations/C++/BasicCapture.xaml
  11. 535
      samples/winrt/ImageManipulations/C++/BasicCapture.xaml.cpp
  12. 88
      samples/winrt/ImageManipulations/C++/BasicCapture.xaml.h
  13. 24
      samples/winrt/ImageManipulations/C++/Constants.cpp
  14. 45
      samples/winrt/ImageManipulations/C++/Constants.h
  15. 166
      samples/winrt/ImageManipulations/C++/MainPage.xaml
  16. 315
      samples/winrt/ImageManipulations/C++/MainPage.xaml.cpp
  17. 105
      samples/winrt/ImageManipulations/C++/MainPage.xaml.h
  18. 52
      samples/winrt/ImageManipulations/C++/MediaCapture.sln
  19. 200
      samples/winrt/ImageManipulations/C++/MediaCapture.vcxproj
  20. 88
      samples/winrt/ImageManipulations/C++/MediaCapture.vcxproj.filters
  21. 81
      samples/winrt/ImageManipulations/C++/MediaExtensions/Common/AsyncCB.h
  22. 102
      samples/winrt/ImageManipulations/C++/MediaExtensions/Common/BufferLock.h
  23. 62
      samples/winrt/ImageManipulations/C++/MediaExtensions/Common/CritSec.h
  24. 516
      samples/winrt/ImageManipulations/C++/MediaExtensions/Common/LinkList.h
  25. 222
      samples/winrt/ImageManipulations/C++/MediaExtensions/Common/OpQueue.h
  26. 1783
      samples/winrt/ImageManipulations/C++/MediaExtensions/Grayscale/Grayscale.cpp
  27. 4
      samples/winrt/ImageManipulations/C++/MediaExtensions/Grayscale/Grayscale.def
  28. 266
      samples/winrt/ImageManipulations/C++/MediaExtensions/Grayscale/Grayscale.h
  29. 313
      samples/winrt/ImageManipulations/C++/MediaExtensions/Grayscale/Grayscale.vcxproj
  30. 22
      samples/winrt/ImageManipulations/C++/MediaExtensions/Grayscale/Grayscale.vcxproj.filters
  31. 11
      samples/winrt/ImageManipulations/C++/MediaExtensions/Grayscale/GrayscaleTransform.idl
  32. 58
      samples/winrt/ImageManipulations/C++/MediaExtensions/Grayscale/dllmain.cpp
  33. 39
      samples/winrt/ImageManipulations/C++/Package.appxmanifest
  34. BIN
      samples/winrt/ImageManipulations/C++/assets/microsoft-sdk.png
  35. BIN
      samples/winrt/ImageManipulations/C++/assets/placeholder-sdk.png
  36. BIN
      samples/winrt/ImageManipulations/C++/assets/smallTile-sdk.png
  37. BIN
      samples/winrt/ImageManipulations/C++/assets/splash-sdk.png
  38. BIN
      samples/winrt/ImageManipulations/C++/assets/squareTile-sdk.png
  39. BIN
      samples/winrt/ImageManipulations/C++/assets/storeLogo-sdk.png
  40. BIN
      samples/winrt/ImageManipulations/C++/assets/tile-sdk.png
  41. BIN
      samples/winrt/ImageManipulations/C++/assets/windows-sdk.png
  42. 452
      samples/winrt/ImageManipulations/C++/common/LayoutAwarePage.cpp
  43. 88
      samples/winrt/ImageManipulations/C++/common/LayoutAwarePage.h
  44. 978
      samples/winrt/ImageManipulations/C++/common/StandardStyles.xaml
  45. 481
      samples/winrt/ImageManipulations/C++/common/suspensionmanager.cpp
  46. 50
      samples/winrt/ImageManipulations/C++/common/suspensionmanager.h
  47. 16
      samples/winrt/ImageManipulations/C++/pch.cpp
  48. 23
      samples/winrt/ImageManipulations/C++/pch.h
  49. 51
      samples/winrt/ImageManipulations/C++/sample-utils/SampleTemplateStyles.xaml
  50. 238
      samples/winrt/ImageManipulations/description.html
  51. 0
      samples/winrt/ImageManipulations/description/4ee0dda0-3e7e-46df-b80b-1692acc1c812Combined.css
  52. 3629
      samples/winrt/ImageManipulations/description/Brand.css
  53. 0
      samples/winrt/ImageManipulations/description/Combined.css
  54. 418
      samples/winrt/ImageManipulations/description/Galleries.css
  55. 147
      samples/winrt/ImageManipulations/description/Layout.css
  56. 303
      samples/winrt/ImageManipulations/description/c2e69f54-1c43-4037-b90b-5f775f1d945fBrand.css
  57. 179
      samples/winrt/ImageManipulations/description/iframedescription.css
  58. 52
      samples/winrt/ImageManipulations/description/offline.js
  59. 25
      samples/winrt/ImageManipulations/license.rtf

@ -0,0 +1,81 @@
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<common:LayoutAwarePage
x:Class="SDKSample.MediaCapture.AdvancedCapture"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:$rootsnamespace$"
xmlns:common="using:SDKSample.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="Input" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock TextWrapping="Wrap" Grid.Row="0" Text="This scenario shows how to enumerate cameras in the system. Choose a camera from the list to preview, record or take a photo from the chosen camera. You can add the gray scale effect using the checkbox provided." Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left"/>
<StackPanel Orientation="Horizontal" Grid.Row="1" Margin="0,10,0,0">
<ListBox x:Name="EnumedDeviceList2" SelectionChanged="lstEnumedDevices_SelectionChanged" ></ListBox>
<Button x:Name="btnStartDevice2" Click="btnStartDevice_Click" IsEnabled="true" Margin="0,0,10,0">StartDevice</Button>
<Button x:Name="btnStartPreview2" Click="btnStartPreview_Click" IsEnabled="true" Margin="0,0,10,0">StartPreview</Button>
<Button x:Name="btnStartStopRecord2" Click="btnStartStopRecord_Click" IsEnabled="false" Margin="0,0,10,0">StartRecord</Button>
<Button x:Name="btnTakePhoto2" Click="btnTakePhoto_Click" IsEnabled="false" Margin="0,0,10,0">TakePhoto</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,10,0,0">
<CheckBox x:Name="chkAddRemoveEffect" Margin="0,0,10,0" Content="Grayscale Effect" IsEnabled="False" Checked="chkAddRemoveEffect_Checked" Unchecked="chkAddRemoveEffect_Unchecked"/>
</StackPanel>
</Grid>
<Grid x:Name="Output" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1">
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<StackPanel>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment='Center' VerticalAlignment='Center' TextAlignment='Center' Text='Preview' />
<Canvas x:Name="previewCanvas2" Width="320" Height="240" Background="Gray">
<CaptureElement x:Name="previewElement2" Width="320" Height="240" />
</Canvas>
</StackPanel>
<StackPanel>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment='Center' VerticalAlignment='Center' TextAlignment='Center' Text='Captured Video' />
<Canvas x:Name='playbackCanvas2' Width='320' Height ='240' >
<MediaElement x:Name='playbackElement2' Width="320" Height="240" />
</Canvas>
</StackPanel>
<StackPanel>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment='Center' VerticalAlignment='Center' TextAlignment='Center' Text='Captured Images' />
<Canvas x:Name="imageCanvas2" Width='320' Height ='240' >
<Image x:Name="imageElement2" Width="320" Height="240"/>
</Canvas>
</StackPanel>
</StackPanel>
</Grid>
<!-- Add Storyboards to the visual states below as necessary for supporting the various layouts -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="FullScreenLandscape"/>
<VisualState x:Name="Filled"/>
<VisualState x:Name="FullScreenPortrait"/>
<VisualState x:Name="Snapped"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</common:LayoutAwarePage>

@ -0,0 +1,103 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// AdvancedCapture.xaml.h
// Declaration of the AdvancedCapture class
//
#pragma once
#include "pch.h"
#include "AdvancedCapture.g.h"
#include "MainPage.xaml.h"
#include <ppl.h>
#define VIDEO_FILE_NAME "video.mp4"
#define PHOTO_FILE_NAME "photo.jpg"
#define TEMP_PHOTO_FILE_NAME "photoTmp.jpg"
using namespace concurrency;
using namespace Windows::Devices::Enumeration;
namespace SDKSample
{
namespace MediaCapture
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
[Windows::Foundation::Metadata::WebHostHidden]
public ref class AdvancedCapture sealed
{
public:
AdvancedCapture();
protected:
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
private:
MainPage^ rootPage;
void ScenarioInit();
void ScenarioReset();
void SoundLevelChanged(Object^ sender, Object^ e);
void RecordLimitationExceeded(Windows::Media::Capture::MediaCapture ^ mediaCapture);
void Failed(Windows::Media::Capture::MediaCapture ^ mediaCapture, Windows::Media::Capture::MediaCaptureFailedEventArgs ^ args);
void btnStartDevice_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void btnStartPreview_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void btnStartStopRecord_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void btnTakePhoto_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void lstEnumedDevices_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
void EnumerateWebcamsAsync();
void chkAddRemoveEffect_Checked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void chkAddRemoveEffect_Unchecked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void AddEffectToImageStream();
void ShowStatusMessage(Platform::String^ text);
void ShowExceptionMessage(Platform::Exception^ ex);
void EnableButton(bool enabled, Platform::String ^name);
void SwitchRecordButtonContent();
task<Windows::Storage::StorageFile^> ReencodePhotoAsync(
Windows::Storage::StorageFile ^tempStorageFile,
Windows::Storage::FileProperties::PhotoOrientation photoRotation);
Windows::Storage::FileProperties::PhotoOrientation GetCurrentPhotoRotation();
void PrepareForVideoRecording();
void DisplayProperties_OrientationChanged(Platform::Object^ sender);
Windows::Storage::FileProperties::PhotoOrientation PhotoRotationLookup(
Windows::Graphics::Display::DisplayOrientations displayOrientation, bool counterclockwise);
Windows::Media::Capture::VideoRotation VideoRotationLookup(
Windows::Graphics::Display::DisplayOrientations displayOrientation, bool counterclockwise);
Platform::Agile<Windows::Media::Capture::MediaCapture> m_mediaCaptureMgr;
Windows::Storage::StorageFile^ m_recordStorageFile;
bool m_bRecording;
bool m_bEffectAdded;
bool m_bEffectAddedToRecord;
bool m_bEffectAddedToPhoto;
bool m_bSuspended;
bool m_bPreviewing;
DeviceInformationCollection^ m_devInfoCollection;
Windows::Foundation::EventRegistrationToken m_eventRegistrationToken;
bool m_bRotateVideoOnOrientationChange;
bool m_bReversePreviewRotation;
Windows::Foundation::EventRegistrationToken m_orientationChangedEventToken;
};
}
}

@ -0,0 +1,30 @@
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SDKSample.App"
RequestedTheme="Light">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--
Styles that define common aspects of the platform look and feel
Required by Visual Studio project and item templates
-->
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
<ResourceDictionary Source="Sample-Utils/SampleTemplateStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

@ -0,0 +1,114 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// App.xaml.cpp
// Implementation of the App.xaml class.
//
#include "pch.h"
#include "MainPage.xaml.h"
#include "Common\SuspensionManager.h"
using namespace SDKSample;
using namespace SDKSample::Common;
using namespace Concurrency;
using namespace Platform;
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Interop;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
App::App()
{
InitializeComponent();
this->Suspending += ref new SuspendingEventHandler(this, &SDKSample::App::OnSuspending);
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points will
/// be used when the application is launched to open a specific file, to display search results,
/// and so forth.
/// </summary>
/// <param name="pArgs">Details about the launch request and process.</param>
void App::OnLaunched(LaunchActivatedEventArgs^ pArgs)
{
this->LaunchArgs = pArgs;
// Do not repeat app initialization when already running, just ensure that
// the window is active
if (pArgs->PreviousExecutionState == ApplicationExecutionState::Running)
{
Window::Current->Activate();
return;
}
// Create a Frame to act as the navigation context and associate it with
// a SuspensionManager key
auto rootFrame = ref new Frame();
SuspensionManager::RegisterFrame(rootFrame, "AppFrame");
auto prerequisite = task<void>([](){});
if (pArgs->PreviousExecutionState == ApplicationExecutionState::Terminated)
{
// Restore the saved session state only when appropriate, scheduling the
// final launch steps after the restore is complete
prerequisite = SuspensionManager::RestoreAsync();
}
prerequisite.then([=]()
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (rootFrame->Content == nullptr)
{
if (!rootFrame->Navigate(TypeName(MainPage::typeid)))
{
throw ref new FailureException("Failed to create initial page");
}
}
// Place the frame in the current Window and ensure that it is active
Window::Current->Content = rootFrame;
Window::Current->Activate();
}, task_continuation_context::use_current());
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
{
(void) sender; // Unused parameter
auto deferral = e->SuspendingOperation->GetDeferral();
SuspensionManager::SaveAsync().then([=]()
{
deferral->Complete();
});
}

@ -0,0 +1,35 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// App.xaml.h
// Declaration of the App.xaml class.
//
#pragma once
#include "pch.h"
#include "App.g.h"
#include "MainPage.g.h"
namespace SDKSample
{
ref class App
{
internal:
App();
virtual void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ pArgs);
Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ LaunchArgs;
protected:
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ pArgs) override;
private:
Windows::UI::Xaml::Controls::Frame^ rootFrame;
};
}

@ -0,0 +1,62 @@
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<common:LayoutAwarePage
x:Class="SDKSample.MediaCapture.AudioCapture"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:$rootsnamespace$"
xmlns:common="using:SDKSample.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="Input" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="InputTextBlock1" TextWrapping="Wrap" Grid.Row="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" >
This scenario shows how to do an audio only capture using the default microphone. Click on StartRecord to start recording.
</TextBlock>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" Grid.Row="1">
<Button x:Name="btnStartDevice3" Click="btnStartDevice_Click" IsEnabled="true" Margin="0,0,10,0">StartDevice</Button>
<Button x:Name="btnStartStopRecord3" Click="btnStartStopRecord_Click" IsEnabled="false" Margin="0,0,10,0">StartRecord</Button>
</StackPanel>
</Grid>
<Grid x:Name="Output" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1">
<StackPanel>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment='Center' VerticalAlignment='Center' TextAlignment='Center' Text='Captured Audio' />
<Canvas x:Name='playbackCanvas3' Width='320' Height ='240' >
<MediaElement x:Name='playbackElement3' Width="320" Height="240" Margin="10,5,10,5"/>
</Canvas>
</StackPanel>
</Grid>
<!-- Add Storyboards to the visual states below as necessary for supporting the various layouts -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="FullScreenLandscape"/>
<VisualState x:Name="Filled"/>
<VisualState x:Name="FullScreenPortrait"/>
<VisualState x:Name="Snapped"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</common:LayoutAwarePage>

@ -0,0 +1,366 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// AudioCapture.xaml.cpp
// Implementation of the AudioCapture class
//
#include "pch.h"
#include "AudioCapture.xaml.h"
#include <ppl.h>
using namespace concurrency;
using namespace SDKSample::MediaCapture;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::System;
using namespace Windows::Foundation;
using namespace Platform;
using namespace Windows::UI;
using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::Storage;
using namespace Windows::Media::MediaProperties;
using namespace Windows::Storage::Streams;
using namespace Windows::System;
using namespace Windows::UI::Xaml::Media::Imaging;
AudioCapture::AudioCapture()
{
InitializeComponent();
ScenarioInit();
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
void AudioCapture::OnNavigatedTo(NavigationEventArgs^ e)
{
// A pointer back to the main page. This is needed if you want to call methods in MainPage such
// as NotifyUser()
rootPage = MainPage::Current;
m_eventRegistrationToken = Windows::Media::MediaControl::SoundLevelChanged += ref new EventHandler<Object^>(this, &AudioCapture::SoundLevelChanged);
}
void AudioCapture::OnNavigatedFrom(NavigationEventArgs^ e)
{
// A pointer back to the main page. This is needed if you want to call methods in MainPage such
// as NotifyUser()
Windows::Media::MediaControl::SoundLevelChanged -= m_eventRegistrationToken;
}
void AudioCapture::ScenarioInit()
{
try
{
rootPage = MainPage::Current;
btnStartDevice3->IsEnabled = true;
btnStartStopRecord3->IsEnabled = false;
m_bRecording = false;
playbackElement3->Source = nullptr;
m_bSuspended = false;
ShowStatusMessage("");
}
catch (Exception ^e)
{
ShowExceptionMessage(e);
}
}
void AudioCapture::ScenarioReset()
{
ScenarioInit();
}
void AudioCapture::SoundLevelChanged(Object^ sender, Object^ e)
{
create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this]()
{
if(Windows::Media::MediaControl::SoundLevel != Windows::Media::SoundLevel::Muted)
{
ScenarioReset();
}
else
{
if (m_bRecording)
{
ShowStatusMessage("Stopping Record on invisibility");
create_task(m_mediaCaptureMgr->StopRecordAsync()).then([this](task<void> recordTask)
{
try
{
recordTask.get();
m_bRecording = false;
}catch (Exception ^e)
{
ShowExceptionMessage(e);
}
});
}
}
})));
}
void AudioCapture::RecordLimitationExceeded(Windows::Media::Capture::MediaCapture ^currentCaptureObject)
{
try
{
if (m_bRecording)
{
create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this](){
try
{
ShowStatusMessage("Stopping Record on exceeding max record duration");
EnableButton(false, "StartStopRecord");
create_task(m_mediaCaptureMgr->StopRecordAsync()).then([this](task<void> recordTask)
{
try
{
recordTask.get();
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowStatusMessage("Stopped record on exceeding max record duration:" + m_recordStorageFile->Path);
}
catch (Exception ^e)
{
ShowExceptionMessage(e);
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
}
});
}
catch (Exception ^e)
{
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowExceptionMessage(e);
}
})));
}
}
catch (Exception ^e)
{
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowExceptionMessage(e);
}
}
void AudioCapture::Failed(Windows::Media::Capture::MediaCapture ^currentCaptureObject, Windows::Media::Capture::MediaCaptureFailedEventArgs^ currentFailure)
{
String ^message = "Fatal error: " + currentFailure->Message;
create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High,
ref new Windows::UI::Core::DispatchedHandler([this, message]()
{
ShowStatusMessage(message);
})));
}
void AudioCapture::btnStartDevice_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
try
{
EnableButton(false, "StartDevice");
ShowStatusMessage("Starting device");
auto mediaCapture = ref new Windows::Media::Capture::MediaCapture();
m_mediaCaptureMgr = mediaCapture;
auto settings = ref new Windows::Media::Capture::MediaCaptureInitializationSettings();
settings->StreamingCaptureMode = Windows::Media::Capture::StreamingCaptureMode::Audio;
create_task(mediaCapture->InitializeAsync()).then([this](task<void> initTask)
{
try
{
initTask.get();
auto mediaCapture = m_mediaCaptureMgr.Get();
EnableButton(true, "StartPreview");
EnableButton(true, "StartStopRecord");
EnableButton(true, "TakePhoto");
ShowStatusMessage("Device initialized successful");
mediaCapture->RecordLimitationExceeded += ref new Windows::Media::Capture::RecordLimitationExceededEventHandler(this, &AudioCapture::RecordLimitationExceeded);
mediaCapture->Failed += ref new Windows::Media::Capture::MediaCaptureFailedEventHandler(this, &AudioCapture::Failed);
}
catch (Exception ^ e)
{
ShowExceptionMessage(e);
}
});
}
catch (Platform::Exception^ e)
{
ShowExceptionMessage(e);
}
}
void AudioCapture::btnStartStopRecord_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
try
{
String ^fileName;
EnableButton(false, "StartStopRecord");
if (!m_bRecording)
{
ShowStatusMessage("Starting Record");
fileName = AUDIO_FILE_NAME;
task<StorageFile^>(KnownFolders::VideosLibrary->CreateFileAsync(fileName, Windows::Storage::CreationCollisionOption::GenerateUniqueName)).then([this](task<StorageFile^> fileTask)
{
try
{
this->m_recordStorageFile = fileTask.get();
ShowStatusMessage("Create record file successful");
MediaEncodingProfile^ recordProfile= nullptr;
recordProfile = MediaEncodingProfile::CreateM4a(Windows::Media::MediaProperties::AudioEncodingQuality::Auto);
create_task(m_mediaCaptureMgr->StartRecordToStorageFileAsync(recordProfile, this->m_recordStorageFile)).then([this](task<void> recordTask)
{
try
{
recordTask.get();
m_bRecording = true;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowStatusMessage("Start Record successful");
}catch (Exception ^e)
{
ShowExceptionMessage(e);
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
}
});
}
catch (Exception ^e)
{
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowExceptionMessage(e);
}
}
);
}
else
{
ShowStatusMessage("Stopping Record");
create_task(m_mediaCaptureMgr->StopRecordAsync()).then([this](task<void>)
{
try
{
m_bRecording = false;
EnableButton(true, "StartStopRecord");
SwitchRecordButtonContent();
ShowStatusMessage("Stop record successful");
if (!m_bSuspended)
{
task<IRandomAccessStream^>(this->m_recordStorageFile->OpenAsync(FileAccessMode::Read)).then([this](task<IRandomAccessStream^> streamTask)
{
try
{
ShowStatusMessage("Record file opened");
auto stream = streamTask.get();
ShowStatusMessage(this->m_recordStorageFile->Path);
playbackElement3->AutoPlay = true;
playbackElement3->SetSource(stream, this->m_recordStorageFile->FileType);
playbackElement3->Play();
}
catch (Exception ^e)
{
ShowExceptionMessage(e);
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
}
});
}
}
catch (Exception ^e)
{
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowExceptionMessage(e);
}
});
}
}
catch (Platform::Exception^ e)
{
EnableButton(true, "StartStopRecord");
ShowExceptionMessage(e);
m_bRecording = false;
SwitchRecordButtonContent();
}
}
void AudioCapture::ShowStatusMessage(Platform::String^ text)
{
rootPage->NotifyUser(text, NotifyType::StatusMessage);
}
void AudioCapture::ShowExceptionMessage(Platform::Exception^ ex)
{
rootPage->NotifyUser(ex->Message, NotifyType::ErrorMessage);
}
void AudioCapture::SwitchRecordButtonContent()
{
{
if (m_bRecording)
{
btnStartStopRecord3->Content="StopRecord";
}
else
{
btnStartStopRecord3->Content="StartRecord";
}
}
}
void AudioCapture::EnableButton(bool enabled, String^ name)
{
if (name->Equals("StartDevice"))
{
btnStartDevice3->IsEnabled = enabled;
}
else if (name->Equals("StartStopRecord"))
{
btnStartStopRecord3->IsEnabled = enabled;
}
}

@ -0,0 +1,70 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// AudioCapture.xaml.h
// Declaration of the AudioCapture class
//
#pragma once
#include "pch.h"
#include "AudioCapture.g.h"
#include "MainPage.xaml.h"
#define AUDIO_FILE_NAME "audio.mp4"
namespace SDKSample
{
namespace MediaCapture
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
[Windows::Foundation::Metadata::WebHostHidden]
public ref class AudioCapture sealed
{
public:
AudioCapture();
protected:
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
private:
MainPage^ rootPage;
void ScenarioInit();
void ScenarioReset();
void SoundLevelChanged(Object^ sender, Object^ e);
void RecordLimitationExceeded(Windows::Media::Capture::MediaCapture ^ mediaCapture);
void Failed(Windows::Media::Capture::MediaCapture ^ mediaCapture, Windows::Media::Capture::MediaCaptureFailedEventArgs ^ args);
void btnStartDevice_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void btnStartPreview_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void btnStartStopRecord_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void ShowStatusMessage(Platform::String^ text);
void ShowExceptionMessage(Platform::Exception^ ex);
void EnableButton(bool enabled, Platform::String ^name);
void SwitchRecordButtonContent();
Platform::Agile<Windows::Media::Capture::MediaCapture> m_mediaCaptureMgr;
Windows::Storage::StorageFile^ m_photoStorageFile;
Windows::Storage::StorageFile^ m_recordStorageFile;
bool m_bRecording;
bool m_bSuspended;
Windows::Foundation::EventRegistrationToken m_eventRegistrationToken;
};
}
}

@ -0,0 +1,87 @@
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<common:LayoutAwarePage
x:Class="SDKSample.MediaCapture.BasicCapture"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:$rootsnamespace$"
xmlns:common="using:SDKSample.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="Input" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="InputTextBlock1" TextWrapping="Wrap" Grid.Row="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" >
This scenario demonstrates how to use the MediaCapture API to preview the camera stream, record a video, and take a picture using default initialization settings.
You can also adjust the brightness and contrast.
</TextBlock>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" Grid.Row="1">
<Button x:Name="btnStartDevice1" Click="btnStartDevice_Click" IsEnabled="true" Margin="0,0,10,0">StartDevice</Button>
<Button x:Name="btnStartPreview1" Click="btnStartPreview_Click" IsEnabled="true" Margin="0,0,10,0">StartPreview</Button>
<Button x:Name="btnStartStopRecord1" Click="btnStartStopRecord_Click" IsEnabled="false" Margin="0,0,10,0">StartRecord</Button>
<Button x:Name="btnTakePhoto1" Click="btnTakePhoto_Click" IsEnabled="false" Margin="0,0,10,0">TakePhoto</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" Grid.Row="2">
<TextBlock TextWrapping="Wrap" Text="Brightness" Style="{StaticResource BasicTextStyle}" Margin="0,0,10,0" VerticalAlignment="Center"/>
<Slider x:Name="sldBrightness" IsEnabled="False" ValueChanged="sldBrightness_ValueChanged" Width="207" Margin="0,0,10,0"/>
<TextBlock TextWrapping="Wrap" Text="Contrast" Style="{StaticResource BasicTextStyle}" Margin="0,0,10,0" VerticalAlignment="Center" />
<Slider x:Name="sldContrast" IsEnabled="False" ValueChanged="sldContrast_ValueChanged" Width="207" Margin="0,0,10,0"/>
</StackPanel>
</Grid>
<Grid x:Name="Output" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1">
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<StackPanel>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment='Center' VerticalAlignment='Center' TextAlignment='Center' Text='Preview' />
<Canvas x:Name="previewCanvas1" Width="320" Height="240" Background="Gray">
<CaptureElement x:Name="previewElement1" Width="320" Height="240" />
</Canvas>
</StackPanel>
<StackPanel>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment='Center' VerticalAlignment='Center' TextAlignment='Center' Text='Captured Video' />
<Canvas x:Name='playbackCanvas1' Width='320' Height ='240' >
<MediaElement x:Name='playbackElement1' Width="320" Height="240" />
</Canvas>
</StackPanel>
<StackPanel>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment='Center' VerticalAlignment='Center' TextAlignment='Center' Text='Captured Images' />
<Canvas x:Name="imageCanvas1" Width='320' Height ='240' >
<Image x:Name="imageElement1" Width="320" Height="240"/>
</Canvas>
</StackPanel>
</StackPanel>
</Grid>
<!-- Add Storyboards to the visual states below as necessary for supporting the various layouts -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="FullScreenLandscape"/>
<VisualState x:Name="Filled"/>
<VisualState x:Name="FullScreenPortrait"/>
<VisualState x:Name="Snapped"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</common:LayoutAwarePage>

@ -0,0 +1,535 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// BasicCapture.xaml.cpp
// Implementation of the BasicCapture class
//
#include "pch.h"
#include "BasicCapture.xaml.h"
#include "ppl.h"
using namespace Windows::System;
using namespace Windows::Foundation;
using namespace Platform;
using namespace Windows::UI;
using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::Storage;
using namespace Windows::Media::MediaProperties;
using namespace Windows::Storage::Streams;
using namespace Windows::System;
using namespace Windows::UI::Xaml::Media::Imaging;
using namespace SDKSample::MediaCapture;
using namespace concurrency;
BasicCapture::BasicCapture()
{
InitializeComponent();
ScenarioInit();
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
void BasicCapture::OnNavigatedTo(NavigationEventArgs^ e)
{
// A pointer back to the main page. This is needed if you want to call methods in MainPage such
// as NotifyUser()
rootPage = MainPage::Current;
m_eventRegistrationToken = Windows::Media::MediaControl::SoundLevelChanged += ref new EventHandler<Object^>(this, &BasicCapture::SoundLevelChanged);
}
void BasicCapture::OnNavigatedFrom(NavigationEventArgs^ e)
{
// A pointer back to the main page. This is needed if you want to call methods in MainPage such
// as NotifyUser()
Windows::Media::MediaControl::SoundLevelChanged -= m_eventRegistrationToken;
m_currentScenarioLoaded = false;
}
void BasicCapture::ScenarioInit()
{
try
{
btnStartDevice1->IsEnabled = true;
btnStartPreview1->IsEnabled = false;
btnStartStopRecord1->IsEnabled = false;
m_bRecording = false;
m_bPreviewing = false;
btnStartStopRecord1->Content = "StartRecord";
btnTakePhoto1->IsEnabled = false;
previewElement1->Source = nullptr;
playbackElement1->Source = nullptr;
imageElement1->Source= nullptr;
sldBrightness->IsEnabled = false;
sldContrast->IsEnabled = false;
m_bSuspended = false;
previewCanvas1->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
catch (Exception ^e)
{
ShowExceptionMessage(e);
}
}
void BasicCapture::ScenarioReset()
{
previewCanvas1->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
ScenarioInit();
}
void BasicCapture::SoundLevelChanged(Object^ sender, Object^ e)
{
create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this]()
{
if(Windows::Media::MediaControl::SoundLevel != Windows::Media::SoundLevel::Muted)
{
ScenarioReset();
}
else
{
if (m_bRecording)
{
ShowStatusMessage("Stopping Record on invisibility");
create_task(m_mediaCaptureMgr->StopRecordAsync()).then([this](task<void> recordTask)
{
m_bRecording = false;
});
}
if (m_bPreviewing)
{
ShowStatusMessage("Stopping Preview on invisibility");
create_task(m_mediaCaptureMgr->StopPreviewAsync()).then([this](task<void> previewTask)
{
try
{
previewTask.get();
m_bPreviewing = false;
}
catch (Exception ^e)
{
ShowExceptionMessage(e);
}
});
}
}
})));
}
void BasicCapture::RecordLimitationExceeded(Windows::Media::Capture::MediaCapture ^currentCaptureObject)
{
try
{
if (m_bRecording)
{
create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this](){
try
{
ShowStatusMessage("Stopping Record on exceeding max record duration");
EnableButton(false, "StartStopRecord");
create_task(m_mediaCaptureMgr->StopRecordAsync()).then([this](task<void> recordTask)
{
try
{
recordTask.get();
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowStatusMessage("Stopped record on exceeding max record duration:" + m_recordStorageFile->Path);
}
catch (Exception ^e)
{
ShowExceptionMessage(e);
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
}
});
}
catch (Exception ^e)
{
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowExceptionMessage(e);
}
})));
}
}
catch (Exception ^e)
{
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowExceptionMessage(e);
}
}
void BasicCapture::Failed(Windows::Media::Capture::MediaCapture ^currentCaptureObject, Windows::Media::Capture::MediaCaptureFailedEventArgs^ currentFailure)
{
String ^message = "Fatal error: " + currentFailure->Message;
create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High,
ref new Windows::UI::Core::DispatchedHandler([this, message]()
{
ShowStatusMessage(message);
})));
}
void BasicCapture::btnStartDevice_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
try
{
EnableButton(false, "StartDevice");
ShowStatusMessage("Starting device");
auto mediaCapture = ref new Windows::Media::Capture::MediaCapture();
m_mediaCaptureMgr = mediaCapture;
create_task(mediaCapture->InitializeAsync()).then([this](task<void> initTask)
{
try
{
initTask.get();
auto mediaCapture = m_mediaCaptureMgr.Get();
EnableButton(true, "StartPreview");
EnableButton(true, "StartStopRecord");
EnableButton(true, "TakePhoto");
ShowStatusMessage("Device initialized successful");
mediaCapture->RecordLimitationExceeded += ref new Windows::Media::Capture::RecordLimitationExceededEventHandler(this, &BasicCapture::RecordLimitationExceeded);
mediaCapture->Failed += ref new Windows::Media::Capture::MediaCaptureFailedEventHandler(this, &BasicCapture::Failed);
}
catch (Exception ^ e)
{
ShowExceptionMessage(e);
}
}
);
}
catch (Platform::Exception^ e)
{
ShowExceptionMessage(e);
}
}
void BasicCapture::btnStartPreview_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
m_bPreviewing = false;
try
{
ShowStatusMessage("Starting preview");
EnableButton(false, "StartPreview");
auto mediaCapture = m_mediaCaptureMgr.Get();
previewCanvas1->Visibility = Windows::UI::Xaml::Visibility::Visible;
previewElement1->Source = mediaCapture;
create_task(mediaCapture->StartPreviewAsync()).then([this](task<void> previewTask)
{
try
{
previewTask.get();
auto mediaCapture = m_mediaCaptureMgr.Get();
m_bPreviewing = true;
ShowStatusMessage("Start preview successful");
if(mediaCapture->VideoDeviceController->Brightness)
{
SetupVideoDeviceControl(mediaCapture->VideoDeviceController->Brightness, sldBrightness);
}
if(mediaCapture->VideoDeviceController->Contrast)
{
SetupVideoDeviceControl(mediaCapture->VideoDeviceController->Contrast, sldContrast);
}
}catch (Exception ^e)
{
ShowExceptionMessage(e);
}
});
}
catch (Platform::Exception^ e)
{
m_bPreviewing = false;
previewElement1->Source = nullptr;
EnableButton(true, "StartPreview");
ShowExceptionMessage(e);
}
}
void BasicCapture::btnTakePhoto_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
try
{
ShowStatusMessage("Taking photo");
EnableButton(false, "TakePhoto");
task<StorageFile^>(KnownFolders::PicturesLibrary->CreateFileAsync(PHOTO_FILE_NAME, Windows::Storage::CreationCollisionOption::GenerateUniqueName)).then([this](task<StorageFile^> getFileTask)
{
try
{
this->m_photoStorageFile = getFileTask.get();
ShowStatusMessage("Create photo file successful");
ImageEncodingProperties^ imageProperties = ImageEncodingProperties::CreateJpeg();
create_task(m_mediaCaptureMgr->CapturePhotoToStorageFileAsync(imageProperties, this->m_photoStorageFile)).then([this](task<void> photoTask)
{
try
{
photoTask.get();
EnableButton(true, "TakePhoto");
ShowStatusMessage("Photo taken");
task<IRandomAccessStream^>(this->m_photoStorageFile->OpenAsync(FileAccessMode::Read)).then([this](task<IRandomAccessStream^> getStreamTask)
{
try
{
auto photoStream = getStreamTask.get();
ShowStatusMessage("File open successful");
auto bmpimg = ref new BitmapImage();
bmpimg->SetSource(photoStream);
imageElement1->Source = bmpimg;
}
catch (Exception^ e)
{
ShowExceptionMessage(e);
EnableButton(true, "TakePhoto");
}
});
}
catch (Platform::Exception ^ e)
{
ShowExceptionMessage(e);
EnableButton(true, "TakePhoto");
}
});
}
catch (Exception^ e)
{
ShowExceptionMessage(e);
EnableButton(true, "TakePhoto");
}
});
}
catch (Platform::Exception^ e)
{
ShowExceptionMessage(e);
EnableButton(true, "TakePhoto");
}
}
void BasicCapture::btnStartStopRecord_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
try
{
String ^fileName;
EnableButton(false, "StartStopRecord");
if (!m_bRecording)
{
ShowStatusMessage("Starting Record");
fileName = VIDEO_FILE_NAME;
task<StorageFile^>(KnownFolders::VideosLibrary->CreateFileAsync(fileName,Windows::Storage::CreationCollisionOption::GenerateUniqueName )).then([this](task<StorageFile^> fileTask)
{
try
{
this->m_recordStorageFile = fileTask.get();
ShowStatusMessage("Create record file successful");
MediaEncodingProfile^ recordProfile= nullptr;
recordProfile = MediaEncodingProfile::CreateMp4(Windows::Media::MediaProperties::VideoEncodingQuality::Auto);
create_task(m_mediaCaptureMgr->StartRecordToStorageFileAsync(recordProfile, this->m_recordStorageFile)).then([this](task<void> recordTask)
{
try
{
recordTask.get();
m_bRecording = true;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowStatusMessage("Start Record successful");
}
catch (Exception ^e)
{
ShowExceptionMessage(e);
}
});
}
catch (Exception ^e)
{
m_bRecording = false;
SwitchRecordButtonContent();
EnableButton(true, "StartStopRecord");
ShowExceptionMessage(e);
}
}
);
}
else
{
ShowStatusMessage("Stopping Record");
create_task(m_mediaCaptureMgr->StopRecordAsync()).then([this](task<void> recordTask)
{
try
{
recordTask.get();
m_bRecording = false;
EnableButton(true, "StartStopRecord");
SwitchRecordButtonContent();
ShowStatusMessage("Stop record successful");
if (!m_bSuspended)
{
task<IRandomAccessStream^>(this->m_recordStorageFile->OpenAsync(FileAccessMode::Read)).then([this](task<IRandomAccessStream^> streamTask)
{
try
{
auto stream = streamTask.get();
ShowStatusMessage("Record file opened");
ShowStatusMessage(this->m_recordStorageFile->Path);
playbackElement1->AutoPlay = true;
playbackElement1->SetSource(stream, this->m_recordStorageFile->FileType);
playbackElement1->Play();
}
catch (Exception ^e)
{
ShowExceptionMessage(e);
m_bRecording = false;
EnableButton(true, "StartStopRecord");
SwitchRecordButtonContent();
}
});
}
}
catch (Exception ^e)
{
m_bRecording = false;
EnableButton(true, "StartStopRecord");
SwitchRecordButtonContent();
ShowExceptionMessage(e);
}
});
}
}
catch (Platform::Exception^ e)
{
EnableButton(true, "StartStopRecord");
ShowExceptionMessage(e);
SwitchRecordButtonContent();
m_bRecording = false;
}
}
void BasicCapture::SetupVideoDeviceControl(Windows::Media::Devices::MediaDeviceControl^ videoDeviceControl, Slider^ slider)
{
try
{
if ((videoDeviceControl->Capabilities)->Supported)
{
slider->IsEnabled = true;
slider->Maximum = videoDeviceControl->Capabilities->Max;
slider->Minimum = videoDeviceControl->Capabilities->Min;
slider->StepFrequency = videoDeviceControl->Capabilities->Step;
double controlValue = 0;
if (videoDeviceControl->TryGetValue(&controlValue))
{
slider->Value = controlValue;
}
}
else
{
slider->IsEnabled = false;
}
}
catch (Platform::Exception^ e)
{
ShowExceptionMessage(e);
}
}
// VideoDeviceControllers
void BasicCapture::sldBrightness_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e)
{
bool succeeded = m_mediaCaptureMgr->VideoDeviceController->Brightness->TrySetValue(sldBrightness->Value);
if (!succeeded)
{
ShowStatusMessage("Set Brightness failed");
}
}
void BasicCapture::sldContrast_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs ^e)
{
bool succeeded = m_mediaCaptureMgr->VideoDeviceController->Contrast->TrySetValue(sldContrast->Value);
if (!succeeded)
{
ShowStatusMessage("Set Contrast failed");
}
}
void BasicCapture::ShowStatusMessage(Platform::String^ text)
{
rootPage->NotifyUser(text, NotifyType::StatusMessage);
}
void BasicCapture::ShowExceptionMessage(Platform::Exception^ ex)
{
rootPage->NotifyUser(ex->Message, NotifyType::ErrorMessage);
}
void BasicCapture::SwitchRecordButtonContent()
{
if (m_bRecording)
{
btnStartStopRecord1->Content="StopRecord";
}
else
{
btnStartStopRecord1->Content="StartRecord";
}
}
void BasicCapture::EnableButton(bool enabled, String^ name)
{
if (name->Equals("StartDevice"))
{
btnStartDevice1->IsEnabled = enabled;
}
else if (name->Equals("StartPreview"))
{
btnStartPreview1->IsEnabled = enabled;
}
else if (name->Equals("StartStopRecord"))
{
btnStartStopRecord1->IsEnabled = enabled;
}
else if (name->Equals("TakePhoto"))
{
btnTakePhoto1->IsEnabled = enabled;
}
}

@ -0,0 +1,88 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// BasicCapture.xaml.h
// Declaration of the BasicCapture class
//
#pragma once
#include "pch.h"
#include "BasicCapture.g.h"
#include "MainPage.xaml.h"
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::Graphics::Display;
using namespace Windows::UI::ViewManagement;
using namespace Windows::Devices::Enumeration;
#define VIDEO_FILE_NAME "video.mp4"
#define PHOTO_FILE_NAME "photo.jpg"
namespace SDKSample
{
namespace MediaCapture
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
[Windows::Foundation::Metadata::WebHostHidden]
public ref class BasicCapture sealed
{
public:
BasicCapture();
protected:
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
private:
MainPage^ rootPage;
void ScenarioInit();
void ScenarioReset();
void Suspending(Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e);
void Resuming(Object^ sender, Object^ e);
void btnStartDevice_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void SoundLevelChanged(Object^ sender, Object^ e);
void RecordLimitationExceeded(Windows::Media::Capture::MediaCapture ^ mediaCapture);
void Failed(Windows::Media::Capture::MediaCapture ^ mediaCapture, Windows::Media::Capture::MediaCaptureFailedEventArgs ^ args);
void btnStartPreview_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void btnStartStopRecord_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void btnTakePhoto_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void SetupVideoDeviceControl(Windows::Media::Devices::MediaDeviceControl^ videoDeviceControl, Slider^ slider);
void sldBrightness_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e);
void sldContrast_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e);
void ShowStatusMessage(Platform::String^ text);
void ShowExceptionMessage(Platform::Exception^ ex);
void EnableButton(bool enabled, Platform::String ^name);
void SwitchRecordButtonContent();
Platform::Agile<Windows::Media::Capture::MediaCapture> m_mediaCaptureMgr;
Windows::Storage::StorageFile^ m_photoStorageFile;
Windows::Storage::StorageFile^ m_recordStorageFile;
bool m_bRecording;
bool m_bEffectAdded;
bool m_bSuspended;
bool m_bPreviewing;
Windows::UI::Xaml::WindowVisibilityChangedEventHandler ^m_visbilityHandler;
Windows::Foundation::EventRegistrationToken m_eventRegistrationToken;
bool m_currentScenarioLoaded;
};
}
}

@ -0,0 +1,24 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "MainPage.xaml.h"
#include "Constants.h"
using namespace SDKSample;
Platform::Array<Scenario>^ MainPage::scenariosInner = ref new Platform::Array<Scenario>
{
// The format here is the following:
// { "Description for the sample", "Fully quaified name for the class that implements the scenario" }
{ "Video preview, record and take pictures", "SDKSample.MediaCapture.BasicCapture" },
{ "Enumerate cameras and add a video effect", "SDKSample.MediaCapture.AdvancedCapture" },
{ "Audio Capture", "SDKSample.MediaCapture.AudioCapture" }
};

@ -0,0 +1,45 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
#include <collection.h>
namespace SDKSample
{
public value struct Scenario
{
Platform::String^ Title;
Platform::String^ ClassName;
};
partial ref class MainPage
{
public:
static property Platform::String^ FEATURE_NAME
{
Platform::String^ get()
{
return ref new Platform::String(L"MediaCapture CPP sample");
}
}
static property Platform::Array<Scenario>^ scenarios
{
Platform::Array<Scenario>^ get()
{
return scenariosInner;
}
}
private:
static Platform::Array<Scenario>^ scenariosInner;
};
}

@ -0,0 +1,166 @@
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<common:LayoutAwarePage
x:Class="SDKSample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:common="using:SDKSample.Common"
mc:Ignorable="d"
x:Name="RootPage">
<common:LayoutAwarePage.Resources>
<Style x:Key="BaseStatusStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI Semilight"/>
<Setter Property="FontSize" Value="14.667"/>
<Setter Property="Margin" Value="0,0,0,5"/>
</Style>
<Style x:Key="StatusStyle" BasedOn="{StaticResource BaseStatusStyle}" TargetType="TextBlock">
<Setter Property="Foreground" Value="Green"/>
</Style>
<Style x:Key="ErrorStyle" BasedOn="{StaticResource BaseStatusStyle}" TargetType="TextBlock">
<Setter Property="Foreground" Value="Blue"/>
</Style>
</common:LayoutAwarePage.Resources>
<Grid x:Name="LayoutRoot" Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid x:Name="ContentRoot" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Margin="100,20,100,20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Header -->
<StackPanel Orientation="Horizontal" Grid.Row="0">
<Image x:Name="WindowsLogo" Stretch="None" Source="Assets/windows-sdk.png" AutomationProperties.Name="Windows Logo" HorizontalAlignment="Left" Grid.Column="0"/>
<TextBlock Text="Windows 8 SDK Samples" VerticalAlignment="Bottom" Style="{StaticResource TitleTextStyle}" TextWrapping="Wrap" Grid.Column="1"/>
</StackPanel>
<ScrollViewer x:Name="MainScrollViewer" Grid.Row="1" ZoomMode="Disabled" IsTabStop="False" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Padding="0,0,0,20" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="FeatureName" Grid.Row="0" Text="Add Sample Title Here" Style="{StaticResource HeaderTextStyle}" TextWrapping="Wrap"/>
<!-- Content -->
<Grid Grid.Row="1">
<!-- All XAML in this section is purely for design time so you can see sample content in the designer. -->
<!-- This will be repaced at runtime by live content. -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Input" Style="{StaticResource H2Style}"/>
<TextBlock x:Name="ScenarioListLabel" Text="Select Scenario:" Grid.Row="1" Style="{StaticResource SubheaderTextStyle}" Margin="0,5,0,0" />
<ListBox x:Name="Scenarios" Margin="0,0,20,0" Grid.Row="2" AutomationProperties.Name="Scenarios" HorizontalAlignment="Left"
VerticalAlignment="Top" ScrollViewer.HorizontalScrollBarVisibility="Auto"
AutomationProperties.LabeledBy="{Binding ElementName=ScenarioListLabel}" MaxHeight="125">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock x:Name="DescriptionText" Margin="0,5,0,0" Text="Description:" Style="{StaticResource SubheaderTextStyle}" Grid.Row="1" Grid.Column="1"/>
<!-- Input Scenarios -->
<UserControl x:Name="InputSection" Margin="0,5,0,0" IsTabStop="False" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<!-- Output section -->
<TextBlock Text="Output" Grid.Row="5" Margin="0,25,0,20" Style="{StaticResource H2Style}" Grid.ColumnSpan="2"/>
<TextBlock x:Name="StatusBlock" Grid.Row="6" Margin="0,0,0,5" Grid.ColumnSpan="2"/>
<!-- Output Scenarios -->
<UserControl x:Name="OutputSection" Grid.Row="7" Grid.ColumnSpan="2" BorderThickness="0"/>
</Grid>
</Grid>
</Grid>
</ScrollViewer>
<!-- Footer -->
<Grid x:Name="Footer" Grid.Row="3" Margin="0,10,0,10" VerticalAlignment="Bottom" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Source="Assets/microsoft-sdk.png" AutomationProperties.Name="Microsoft Logo" Stretch="None" HorizontalAlignment="Left"/>
<TextBlock Style="{StaticResource FooterStyle}" Text="© Microsoft Corporation. All rights reserved." TextWrapping="Wrap" Grid.Row="1" HorizontalAlignment="Left"/>
<StackPanel x:Name="FooterPanel" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right">
<HyperlinkButton Content="Terms of use" Tag="http://www.microsoft.com/About/Legal/EN/US/IntellectualProperty/Copyright/default.aspx"
Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center"/>
<HyperlinkButton Content="Trademarks" Tag="http://www.microsoft.com/About/Legal/EN/US/IntellectualProperty/Trademarks/EN-US.aspx"
Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center"/>
<HyperlinkButton Content="Privacy Statement" Tag="http://privacy.microsoft.com" Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
</StackPanel>
</Grid>
</Grid>
<VisualStateManager.VisualStateGroups>
<!-- Visual states reflect the application's view state -->
<VisualStateGroup>
<VisualState x:Name="FullScreenLandscape">
<Storyboard>
</Storyboard>
</VisualState>
<VisualState x:Name="Filled">
<Storyboard>
</Storyboard>
</VisualState>
<VisualState x:Name="FullScreenPortrait">
<Storyboard>
</Storyboard>
</VisualState>
<VisualState x:Name="Snapped">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ContentRoot">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Thickness>20,20,20,20</Thickness>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</common:LayoutAwarePage>

@ -0,0 +1,315 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// MainPage.xaml.cpp
// Implementation of the MainPage.xaml class.
//
#include "pch.h"
#include "MainPage.xaml.h"
#include "App.xaml.h"
#include <collection.h>
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Platform;
using namespace SDKSample;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::Xaml::Interop;
using namespace Windows::Graphics::Display;
using namespace Windows::UI::ViewManagement;
MainPage^ MainPage::Current = nullptr;
MainPage::MainPage()
{
InitializeComponent();
// This frame is hidden, meaning it is never shown. It is simply used to load
// each scenario page and then pluck out the input and output sections and
// place them into the UserControls on the main page.
HiddenFrame = ref new Windows::UI::Xaml::Controls::Frame();
HiddenFrame->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
ContentRoot->Children->Append(HiddenFrame);
FeatureName->Text = FEATURE_NAME;
this->SizeChanged += ref new SizeChangedEventHandler(this, &MainPage::MainPage_SizeChanged);
Scenarios->SelectionChanged += ref new SelectionChangedEventHandler(this, &MainPage::Scenarios_SelectionChanged);
MainPage::Current = this;
autoSizeInputSectionWhenSnapped = true;
}
/// <summary>
/// We need to handle SizeChanged so that we can make the sample layout property
/// in the various layouts.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void MainPage::MainPage_SizeChanged(Object^ sender, SizeChangedEventArgs^ e)
{
InvalidateSize();
MainPageSizeChangedEventArgs^ args = ref new MainPageSizeChangedEventArgs();
args->ViewState = ApplicationView::Value;
MainPageResized(this, args);
}
void MainPage::InvalidateSize()
{
// Get the window width
double windowWidth = this->ActualWidth;
if (windowWidth != 0.0)
{
// Get the width of the ListBox.
double listBoxWidth = Scenarios->ActualWidth;
// Is the ListBox using any margins that we need to consider?
double listBoxMarginLeft = Scenarios->Margin.Left;
double listBoxMarginRight = Scenarios->Margin.Right;
// Figure out how much room is left after considering the list box width
double availableWidth = windowWidth - listBoxWidth;
// Is the top most child using margins?
double layoutRootMarginLeft = ContentRoot->Margin.Left;
double layoutRootMarginRight = ContentRoot->Margin.Right;
// We have different widths to use depending on the view state
if (ApplicationView::Value != ApplicationViewState::Snapped)
{
// Make us as big as the the left over space, factoring in the ListBox width, the ListBox margins.
// and the LayoutRoot's margins
InputSection->Width = ((availableWidth) -
(layoutRootMarginLeft + layoutRootMarginRight + listBoxMarginLeft + listBoxMarginRight));
}
else
{
// Make us as big as the left over space, factoring in just the LayoutRoot's margins.
if (autoSizeInputSectionWhenSnapped)
{
InputSection->Width = (windowWidth - (layoutRootMarginLeft + layoutRootMarginRight));
}
}
}
InvalidateViewState();
}
void MainPage::InvalidateViewState()
{
// Are we going to snapped mode?
if (ApplicationView::Value == ApplicationViewState::Snapped)
{
Grid::SetRow(DescriptionText, 3);
Grid::SetColumn(DescriptionText, 0);
Grid::SetRow(InputSection, 4);
Grid::SetColumn(InputSection, 0);
Grid::SetRow(FooterPanel, 2);
Grid::SetColumn(FooterPanel, 0);
}
else
{
Grid::SetRow(DescriptionText, 1);
Grid::SetColumn(DescriptionText, 1);
Grid::SetRow(InputSection, 2);
Grid::SetColumn(InputSection, 1);
Grid::SetRow(FooterPanel, 1);
Grid::SetColumn(FooterPanel, 1);
}
// Since we don't load the scenario page in the traditional manner (we just pluck out the
// input and output sections from the page) we need to ensure that any VSM code used
// by the scenario's input and output sections is fired.
VisualStateManager::GoToState(InputSection, "Input" + LayoutAwarePage::DetermineVisualState(ApplicationView::Value), false);
VisualStateManager::GoToState(OutputSection, "Output" + LayoutAwarePage::DetermineVisualState(ApplicationView::Value), false);
}
void MainPage::PopulateScenarios()
{
ScenarioList = ref new Platform::Collections::Vector<Object^>();
// Populate the ListBox with the list of scenarios as defined in Constants.cpp.
for (unsigned int i = 0; i < scenarios->Length; ++i)
{
Scenario s = scenarios[i];
ListBoxItem^ item = ref new ListBoxItem();
item->Name = s.ClassName;
item->Content = (i + 1).ToString() + ") " + s.Title;
ScenarioList->Append(item);
}
// Bind the ListBox to the scenario list.
Scenarios->ItemsSource = ScenarioList;
Scenarios->ScrollIntoView(Scenarios->SelectedItem);
}
/// <summary>
/// This method is responsible for loading the individual input and output sections for each scenario. This
/// is based on navigating a hidden Frame to the ScenarioX.xaml page and then extracting out the input
/// and output sections into the respective UserControl on the main page.
/// </summary>
/// <param name="scenarioName"></param>
void MainPage::LoadScenario(String^ scenarioName)
{
autoSizeInputSectionWhenSnapped = true;
// Load the ScenarioX.xaml file into the Frame.
TypeName scenarioType = {scenarioName, TypeKind::Custom};
HiddenFrame->Navigate(scenarioType, this);
// Get the top element, the Page, so we can look up the elements
// that represent the input and output sections of the ScenarioX file.
Page^ hiddenPage = safe_cast<Page^>(HiddenFrame->Content);
// Get each element.
UIElement^ input = safe_cast<UIElement^>(hiddenPage->FindName("Input"));
UIElement^ output = safe_cast<UIElement^>(hiddenPage->FindName("Output"));
if (input == nullptr)
{
// Malformed input section.
NotifyUser("Cannot load scenario input section for " + scenarioName +
" Make sure root of input section markup has x:Name of 'Input'", NotifyType::ErrorMessage);
return;
}
if (output == nullptr)
{
// Malformed output section.
NotifyUser("Cannot load scenario output section for " + scenarioName +
" Make sure root of output section markup has x:Name of 'Output'", NotifyType::ErrorMessage);
return;
}
// Find the LayoutRoot which parents the input and output sections in the main page.
Panel^ panel = safe_cast<Panel^>(hiddenPage->FindName("LayoutRoot"));
if (panel != nullptr)
{
unsigned int index = 0;
UIElementCollection^ collection = panel->Children;
// Get rid of the content that is currently in the intput and output sections.
collection->IndexOf(input, &index);
collection->RemoveAt(index);
collection->IndexOf(output, &index);
collection->RemoveAt(index);
// Populate the input and output sections with the newly loaded content.
InputSection->Content = input;
OutputSection->Content = output;
ScenarioLoaded(this, nullptr);
}
else
{
// Malformed Scenario file.
NotifyUser("Cannot load scenario: " + scenarioName + ". Make sure root tag in the '" +
scenarioName + "' file has an x:Name of 'LayoutRoot'", NotifyType::ErrorMessage);
}
}
void MainPage::Scenarios_SelectionChanged(Object^ sender, SelectionChangedEventArgs^ e)
{
if (Scenarios->SelectedItem != nullptr)
{
NotifyUser("", NotifyType::StatusMessage);
LoadScenario((safe_cast<ListBoxItem^>(Scenarios->SelectedItem))->Name);
InvalidateSize();
}
}
void MainPage::NotifyUser(String^ strMessage, NotifyType type)
{
switch (type)
{
case NotifyType::StatusMessage:
// Use the status message style.
StatusBlock->Style = safe_cast<Windows::UI::Xaml::Style^>(this->Resources->Lookup("StatusStyle"));
break;
case NotifyType::ErrorMessage:
// Use the error message style.
StatusBlock->Style = safe_cast<Windows::UI::Xaml::Style^>(this->Resources->Lookup("ErrorStyle"));
break;
default:
break;
}
StatusBlock->Text = strMessage;
// Collapsed the StatusBlock if it has no text to conserve real estate.
if (StatusBlock->Text != "")
{
StatusBlock->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
else
{
StatusBlock->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
}
void MainPage::Footer_Click(Object^ sender, RoutedEventArgs^ e)
{
auto uri = ref new Uri((String^)((HyperlinkButton^)sender)->Tag);
Windows::System::Launcher::LaunchUriAsync(uri);
}
/// <summary>
/// Populates the page with content passed during navigation. Any saved state is also
/// provided when recreating a page from a prior session.
/// </summary>
/// <param name="navigationParameter">The parameter value passed to
/// <see cref="Frame::Navigate(Type, Object)"/> when this page was initially requested.
/// </param>
/// <param name="pageState">A map of state preserved by this page during an earlier
/// session. This will be null the first time a page is visited.</param>
void MainPage::LoadState(Object^ navigationParameter, IMap<String^, Object^>^ pageState)
{
(void) navigationParameter; // Unused parameter
PopulateScenarios();
// Starting scenario is the first or based upon a previous state.
ListBoxItem^ startingScenario = nullptr;
int startingScenarioIndex = -1;
if (pageState != nullptr && pageState->HasKey("SelectedScenarioIndex"))
{
startingScenarioIndex = safe_cast<int>(pageState->Lookup("SelectedScenarioIndex"));
}
Scenarios->SelectedIndex = startingScenarioIndex != -1 ? startingScenarioIndex : 0;
InvalidateViewState();
}
/// <summary>
/// Preserves state associated with this page in case the application is suspended or the
/// page is discarded from the navigation cache. Values must conform to the serialization
/// requirements of <see cref="SuspensionManager::SessionState"/>.
/// </summary>
/// <param name="pageState">An empty map to be populated with serializable state.</param>
void MainPage::SaveState(IMap<String^, Object^>^ pageState)
{
int selectedListBoxItemIndex = Scenarios->SelectedIndex;
pageState->Insert("SelectedScenarioIndex", selectedListBoxItemIndex);
}

@ -0,0 +1,105 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// MainPage.xaml.h
// Declaration of the MainPage.xaml class.
//
#pragma once
#include "pch.h"
#include "MainPage.g.h"
#include "Common\LayoutAwarePage.h" // Required by generated header
#include "Constants.h"
namespace SDKSample
{
public enum class NotifyType
{
StatusMessage,
ErrorMessage
};
public ref class MainPageSizeChangedEventArgs sealed
{
public:
property Windows::UI::ViewManagement::ApplicationViewState ViewState
{
Windows::UI::ViewManagement::ApplicationViewState get()
{
return viewState;
}
void set(Windows::UI::ViewManagement::ApplicationViewState value)
{
viewState = value;
}
}
private:
Windows::UI::ViewManagement::ApplicationViewState viewState;
};
public ref class MainPage sealed
{
public:
MainPage();
protected:
virtual void LoadState(Platform::Object^ navigationParameter,
Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState) override;
virtual void SaveState(Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState) override;
internal:
property bool AutoSizeInputSectionWhenSnapped
{
bool get()
{
return autoSizeInputSectionWhenSnapped;
}
void set(bool value)
{
autoSizeInputSectionWhenSnapped = value;
}
}
property Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ LaunchArgs
{
Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ get()
{
return safe_cast<App^>(App::Current)->LaunchArgs;
}
}
void NotifyUser(Platform::String^ strMessage, NotifyType type);
void LoadScenario(Platform::String^ scenarioName);
event Windows::Foundation::EventHandler<Platform::Object^>^ ScenarioLoaded;
event Windows::Foundation::EventHandler<MainPageSizeChangedEventArgs^>^ MainPageResized;
private:
void PopulateScenarios();
void InvalidateSize();
void InvalidateViewState();
Platform::Collections::Vector<Object^>^ ScenarioList;
Windows::UI::Xaml::Controls::Frame^ HiddenFrame;
void Footer_Click(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
bool autoSizeInputSectionWhenSnapped;
void MainPage_SizeChanged(Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
void Scenarios_SelectionChanged(Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
internal:
static MainPage^ Current;
};
}

@ -0,0 +1,52 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 11 Express for Windows 8
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MediaCapture", "MediaCapture.vcxproj", "{C5B886A7-8300-46FF-B533-9613DE2AF637}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GrayscaleTransform", "MediaExtensions\Grayscale\Grayscale.vcxproj", "{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|ARM = Release|ARM
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Debug|ARM.ActiveCfg = Debug|ARM
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Debug|ARM.Build.0 = Debug|ARM
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Debug|Win32.ActiveCfg = Debug|Win32
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Debug|Win32.Build.0 = Debug|Win32
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Debug|x64.ActiveCfg = Debug|x64
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Debug|x64.Build.0 = Debug|x64
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Release|ARM.ActiveCfg = Release|ARM
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Release|ARM.Build.0 = Release|ARM
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Release|Win32.ActiveCfg = Release|Win32
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Release|Win32.Build.0 = Release|Win32
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Release|x64.ActiveCfg = Release|x64
{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}.Release|x64.Build.0 = Release|x64
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Debug|ARM.ActiveCfg = Debug|ARM
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Debug|ARM.Build.0 = Debug|ARM
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Debug|ARM.Deploy.0 = Debug|ARM
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Debug|Win32.ActiveCfg = Debug|Win32
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Debug|Win32.Build.0 = Debug|Win32
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Debug|Win32.Deploy.0 = Debug|Win32
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Debug|x64.ActiveCfg = Debug|x64
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Debug|x64.Build.0 = Debug|x64
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Debug|x64.Deploy.0 = Debug|x64
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Release|ARM.ActiveCfg = Release|ARM
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Release|ARM.Build.0 = Release|ARM
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Release|ARM.Deploy.0 = Release|ARM
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Release|Win32.ActiveCfg = Release|Win32
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Release|Win32.Build.0 = Release|Win32
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Release|Win32.Deploy.0 = Release|Win32
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Release|x64.ActiveCfg = Release|x64
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Release|x64.Build.0 = Release|x64
{C5B886A7-8300-46FF-B533-9613DE2AF637}.Release|x64.Deploy.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,200 @@
<?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|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C5B886A7-8300-46FF-B533-9613DE2AF637}</ProjectGuid>
<RootNamespace>SDKSample</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and '$(VisualStudioVersion)' == ''">$(VCTargetsPath11)</VCTargetsPath>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ProjectName>MediaCapture</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</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>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<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|ARM'">
<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)'=='Debug|x64'">
<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|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="AdvancedCapture.xaml.h">
<DependentUpon>AdvancedCapture.xaml</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="AudioCapture.xaml.h">
<DependentUpon>AudioCapture.xaml</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="BasicCapture.xaml.h">
<DependentUpon>BasicCapture.xaml</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="Constants.h" />
<ClInclude Include="MainPage.xaml.h">
<DependentUpon>MainPage.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="pch.h" />
<ClInclude Include="Common\LayoutAwarePage.h" />
<ClInclude Include="Common\SuspensionManager.h" />
<ClInclude Include="App.xaml.h">
<DependentUpon>App.xaml</DependentUpon>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="AdvancedCapture.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="AudioCapture.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="BasicCapture.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="Common\StandardStyles.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="Sample-Utils\SampleTemplateStyles.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AdvancedCapture.xaml.cpp">
<DependentUpon>AdvancedCapture.xaml</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="App.xaml.cpp">
<DependentUpon>App.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="AudioCapture.xaml.cpp">
<DependentUpon>AudioCapture.xaml</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="BasicCapture.xaml.cpp">
<DependentUpon>BasicCapture.xaml</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="Common\LayoutAwarePage.cpp" />
<ClCompile Include="Constants.cpp" />
<ClCompile Include="Common\SuspensionManager.cpp" />
<ClCompile Include="MainPage.xaml.cpp">
<DependentUpon>MainPage.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="Assets\microsoft-sdk.png" />
<Image Include="Assets\placeholder-sdk.png" />
<Image Include="Assets\smallTile-sdk.png" />
<Image Include="Assets\splash-sdk.png" />
<Image Include="Assets\squareTile-sdk.png" />
<Image Include="Assets\storeLogo-sdk.png" />
<Image Include="Assets\tile-sdk.png" />
<Image Include="Assets\windows-sdk.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="MediaExtensions\Grayscale\Grayscale.vcxproj">
<Project>{ba69218f-da5c-4d14-a78d-21a9e4dec669}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Image Include="Assets\microsoft-sdk.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\placeholder-sdk.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\smallTile-sdk.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\splash-sdk.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\squareTile-sdk.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\storeLogo-sdk.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\tile-sdk.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\windows-sdk.png">
<Filter>Assets</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest" />
</ItemGroup>
<ItemGroup>
<Page Include="MainPage.xaml" />
<Page Include="Common\StandardStyles.xaml">
<Filter>Common</Filter>
</Page>
<Page Include="Sample-Utils\SampleTemplateStyles.xaml">
<Filter>Sample-Utils</Filter>
</Page>
<Page Include="BasicCapture.xaml" />
<Page Include="AdvancedCapture.xaml" />
<Page Include="AudioCapture.xaml" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="MainPage.xaml.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="App.xaml.h" />
<ClInclude Include="Common\SuspensionManager.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\LayoutAwarePage.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Constants.h" />
<ClInclude Include="AdvancedCapture.xaml.h" />
<ClInclude Include="AudioCapture.xaml.h" />
<ClInclude Include="BasicCapture.xaml.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="App.xaml.cpp" />
<ClCompile Include="MainPage.xaml.cpp" />
<ClCompile Include="pch.cpp" />
<ClCompile Include="Common\LayoutAwarePage.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="Common\SuspensionManager.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="Constants.cpp" />
<ClCompile Include="AdvancedCapture.xaml.cpp" />
<ClCompile Include="AudioCapture.xaml.cpp" />
<ClCompile Include="BasicCapture.xaml.cpp" />
</ItemGroup>
<ItemGroup>
<Filter Include="Assets">
<UniqueIdentifier>{132eec18-b164-4b15-a746-643880e9c5d9}</UniqueIdentifier>
</Filter>
<Filter Include="Common">
<UniqueIdentifier>{476b4177-f316-4458-8e13-cab3dc2381c5}</UniqueIdentifier>
</Filter>
<Filter Include="Sample-Utils">
<UniqueIdentifier>{54f287f8-e4cb-4f47-97d0-4c469de6992e}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

@ -0,0 +1,81 @@
#pragma once
//////////////////////////////////////////////////////////////////////////
// AsyncCallback [template]
//
// Description:
// Helper class that routes IMFAsyncCallback::Invoke calls to a class
// method on the parent class.
//
// Usage:
// Add this class as a member variable. In the parent class constructor,
// initialize the AsyncCallback class like this:
// m_cb(this, &CYourClass::OnInvoke)
// where
// m_cb = AsyncCallback object
// CYourClass = parent class
// OnInvoke = Method in the parent class to receive Invoke calls.
//
// The parent's OnInvoke method (you can name it anything you like) must
// have a signature that matches the InvokeFn typedef below.
//////////////////////////////////////////////////////////////////////////
// T: Type of the parent object
template<class T>
class AsyncCallback : public IMFAsyncCallback
{
public:
typedef HRESULT (T::*InvokeFn)(IMFAsyncResult *pAsyncResult);
AsyncCallback(T *pParent, InvokeFn fn) : m_pParent(pParent), m_pInvokeFn(fn)
{
}
// IUnknown
STDMETHODIMP_(ULONG) AddRef() {
// Delegate to parent class.
return m_pParent->AddRef();
}
STDMETHODIMP_(ULONG) Release() {
// Delegate to parent class.
return m_pParent->Release();
}
STDMETHODIMP QueryInterface(REFIID iid, void** ppv)
{
if (!ppv)
{
return E_POINTER;
}
if (iid == __uuidof(IUnknown))
{
*ppv = static_cast<IUnknown*>(static_cast<IMFAsyncCallback*>(this));
}
else if (iid == __uuidof(IMFAsyncCallback))
{
*ppv = static_cast<IMFAsyncCallback*>(this);
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
// IMFAsyncCallback methods
STDMETHODIMP GetParameters(DWORD*, DWORD*)
{
// Implementation of this method is optional.
return E_NOTIMPL;
}
STDMETHODIMP Invoke(IMFAsyncResult* pAsyncResult)
{
return (m_pParent->*m_pInvokeFn)(pAsyncResult);
}
T *m_pParent;
InvokeFn m_pInvokeFn;
};

@ -0,0 +1,102 @@
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved
#pragma once
//////////////////////////////////////////////////////////////////////////
// VideoBufferLock
//
// Description:
// Locks a video buffer that might or might not support IMF2DBuffer.
//
//////////////////////////////////////////////////////////////////////////
class VideoBufferLock
{
public:
VideoBufferLock(IMFMediaBuffer *pBuffer) : m_p2DBuffer(NULL)
{
m_pBuffer = pBuffer;
m_pBuffer->AddRef();
// Query for the 2-D buffer interface. OK if this fails.
m_pBuffer->QueryInterface(IID_PPV_ARGS(&m_p2DBuffer));
}
~VideoBufferLock()
{
UnlockBuffer();
SafeRelease(&m_pBuffer);
SafeRelease(&m_p2DBuffer);
}
// LockBuffer:
// Locks the buffer. Returns a pointer to scan line 0 and returns the stride.
// The caller must provide the default stride as an input parameter, in case
// the buffer does not expose IMF2DBuffer. You can calculate the default stride
// from the media type.
HRESULT LockBuffer(
LONG lDefaultStride, // Minimum stride (with no padding).
DWORD dwHeightInPixels, // Height of the image, in pixels.
BYTE **ppbScanLine0, // Receives a pointer to the start of scan line 0.
LONG *plStride // Receives the actual stride.
)
{
HRESULT hr = S_OK;
// Use the 2-D version if available.
if (m_p2DBuffer)
{
hr = m_p2DBuffer->Lock2D(ppbScanLine0, plStride);
}
else
{
// Use non-2D version.
BYTE *pData = NULL;
hr = m_pBuffer->Lock(&pData, NULL, NULL);
if (SUCCEEDED(hr))
{
*plStride = lDefaultStride;
if (lDefaultStride < 0)
{
// Bottom-up orientation. Return a pointer to the start of the
// last row *in memory* which is the top row of the image.
*ppbScanLine0 = pData + abs(lDefaultStride) * (dwHeightInPixels - 1);
}
else
{
// Top-down orientation. Return a pointer to the start of the
// buffer.
*ppbScanLine0 = pData;
}
}
}
return hr;
}
HRESULT UnlockBuffer()
{
if (m_p2DBuffer)
{
return m_p2DBuffer->Unlock2D();
}
else
{
return m_pBuffer->Unlock();
}
}
private:
IMFMediaBuffer *m_pBuffer;
IMF2DBuffer *m_p2DBuffer;
};

@ -0,0 +1,62 @@
#pragma once
//////////////////////////////////////////////////////////////////////////
// CritSec
// Description: Wraps a critical section.
//////////////////////////////////////////////////////////////////////////
class CritSec
{
public:
CRITICAL_SECTION m_criticalSection;
public:
CritSec()
{
InitializeCriticalSectionEx(&m_criticalSection, 100, 0);
}
~CritSec()
{
DeleteCriticalSection(&m_criticalSection);
}
_Acquires_lock_(m_criticalSection)
void Lock()
{
EnterCriticalSection(&m_criticalSection);
}
_Releases_lock_(m_criticalSection)
void Unlock()
{
LeaveCriticalSection(&m_criticalSection);
}
};
//////////////////////////////////////////////////////////////////////////
// AutoLock
// Description: Provides automatic locking and unlocking of a
// of a critical section.
//
// Note: The AutoLock object must go out of scope before the CritSec.
//////////////////////////////////////////////////////////////////////////
class AutoLock
{
private:
CritSec *m_pCriticalSection;
public:
_Acquires_lock_(m_pCriticalSection)
AutoLock(CritSec& crit)
{
m_pCriticalSection = &crit;
m_pCriticalSection->Lock();
}
_Releases_lock_(m_pCriticalSection)
~AutoLock()
{
m_pCriticalSection->Unlock();
}
};

@ -0,0 +1,516 @@
//-----------------------------------------------------------------------------
// File: Linklist.h
// Desc: Linked list class.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#pragma once
// Notes:
//
// The List class template implements a simple double-linked list.
// It uses STL's copy semantics.
// There are two versions of the Clear() method:
// Clear(void) clears the list w/out cleaning up the object.
// Clear(FN fn) takes a functor object that releases the objects, if they need cleanup.
// The List class supports enumeration. Example of usage:
//
// List<T>::POSIITON pos = list.GetFrontPosition();
// while (pos != list.GetEndPosition())
// {
// T item;
// hr = list.GetItemPos(&item);
// pos = list.Next(pos);
// }
// The ComPtrList class template derives from List<> and implements a list of COM pointers.
template <class T>
struct NoOp
{
void operator()(T& t)
{
}
};
template <class T>
class List
{
protected:
// Nodes in the linked list
struct Node
{
Node *prev;
Node *next;
T item;
Node() : prev(nullptr), next(nullptr)
{
}
Node(T item) : prev(nullptr), next(nullptr)
{
this->item = item;
}
T Item() const { return item; }
};
public:
// Object for enumerating the list.
class POSITION
{
friend class List<T>;
public:
POSITION() : pNode(nullptr)
{
}
bool operator==(const POSITION &p) const
{
return pNode == p.pNode;
}
bool operator!=(const POSITION &p) const
{
return pNode != p.pNode;
}
private:
const Node *pNode;
POSITION(Node *p) : pNode(p)
{
}
};
protected:
Node m_anchor; // Anchor node for the linked list.
DWORD m_count; // Number of items in the list.
Node* Front() const
{
return m_anchor.next;
}
Node* Back() const
{
return m_anchor.prev;
}
virtual HRESULT InsertAfter(T item, Node *pBefore)
{
if (pBefore == nullptr)
{
return E_POINTER;
}
Node *pNode = new Node(item);
if (pNode == nullptr)
{
return E_OUTOFMEMORY;
}
Node *pAfter = pBefore->next;
pBefore->next = pNode;
pAfter->prev = pNode;
pNode->prev = pBefore;
pNode->next = pAfter;
m_count++;
return S_OK;
}
virtual HRESULT GetItem(const Node *pNode, T* ppItem)
{
if (pNode == nullptr || ppItem == nullptr)
{
return E_POINTER;
}
*ppItem = pNode->item;
return S_OK;
}
// RemoveItem:
// Removes a node and optionally returns the item.
// ppItem can be nullptr.
virtual HRESULT RemoveItem(Node *pNode, T *ppItem)
{
if (pNode == nullptr)
{
return E_POINTER;
}
assert(pNode != &m_anchor); // We should never try to remove the anchor node.
if (pNode == &m_anchor)
{
return E_INVALIDARG;
}
T item;
// The next node's previous is this node's previous.
pNode->next->prev = pNode->prev;
// The previous node's next is this node's next.
pNode->prev->next = pNode->next;
item = pNode->item;
delete pNode;
m_count--;
if (ppItem)
{
*ppItem = item;
}
return S_OK;
}
public:
List()
{
m_anchor.next = &m_anchor;
m_anchor.prev = &m_anchor;
m_count = 0;
}
virtual ~List()
{
Clear();
}
// Insertion functions
HRESULT InsertBack(T item)
{
return InsertAfter(item, m_anchor.prev);
}
HRESULT InsertFront(T item)
{
return InsertAfter(item, &m_anchor);
}
HRESULT InsertPos(POSITION pos, T item)
{
if (pos.pNode == nullptr)
{
return InsertBack(item);
}
return InsertAfter(item, pos.pNode->prev);
}
// RemoveBack: Removes the tail of the list and returns the value.
// ppItem can be nullptr if you don't want the item back. (But the method does not release the item.)
HRESULT RemoveBack(T *ppItem)
{
if (IsEmpty())
{
return E_FAIL;
}
else
{
return RemoveItem(Back(), ppItem);
}
}
// RemoveFront: Removes the head of the list and returns the value.
// ppItem can be nullptr if you don't want the item back. (But the method does not release the item.)
HRESULT RemoveFront(T *ppItem)
{
if (IsEmpty())
{
return E_FAIL;
}
else
{
return RemoveItem(Front(), ppItem);
}
}
// GetBack: Gets the tail item.
HRESULT GetBack(T *ppItem)
{
if (IsEmpty())
{
return E_FAIL;
}
else
{
return GetItem(Back(), ppItem);
}
}
// GetFront: Gets the front item.
HRESULT GetFront(T *ppItem)
{
if (IsEmpty())
{
return E_FAIL;
}
else
{
return GetItem(Front(), ppItem);
}
}
// GetCount: Returns the number of items in the list.
DWORD GetCount() const { return m_count; }
bool IsEmpty() const
{
return (GetCount() == 0);
}
// Clear: Takes a functor object whose operator()
// frees the object on the list.
template <class FN>
void Clear(FN& clear_fn)
{
Node *n = m_anchor.next;
// Delete the nodes
while (n != &m_anchor)
{
clear_fn(n->item);
Node *tmp = n->next;
delete n;
n = tmp;
}
// Reset the anchor to point at itself
m_anchor.next = &m_anchor;
m_anchor.prev = &m_anchor;
m_count = 0;
}
// Clear: Clears the list. (Does not delete or release the list items.)
virtual void Clear()
{
NoOp<T> clearOp;
Clear<>(clearOp);
}
// Enumerator functions
POSITION FrontPosition()
{
if (IsEmpty())
{
return POSITION(nullptr);
}
else
{
return POSITION(Front());
}
}
POSITION EndPosition() const
{
return POSITION();
}
HRESULT GetItemPos(POSITION pos, T *ppItem)
{
if (pos.pNode)
{
return GetItem(pos.pNode, ppItem);
}
else
{
return E_FAIL;
}
}
POSITION Next(const POSITION pos)
{
if (pos.pNode && (pos.pNode->next != &m_anchor))
{
return POSITION(pos.pNode->next);
}
else
{
return POSITION(nullptr);
}
}
// Remove an item at a position.
// The item is returns in ppItem, unless ppItem is nullptr.
// NOTE: This method invalidates the POSITION object.
HRESULT Remove(POSITION& pos, T *ppItem)
{
if (pos.pNode)
{
// Remove const-ness temporarily...
Node *pNode = const_cast<Node*>(pos.pNode);
pos = POSITION();
return RemoveItem(pNode, ppItem);
}
else
{
return E_INVALIDARG;
}
}
};
// Typical functors for Clear method.
// ComAutoRelease: Releases COM pointers.
// MemDelete: Deletes pointers to new'd memory.
class ComAutoRelease
{
public:
void operator()(IUnknown *p)
{
if (p)
{
p->Release();
}
}
};
class MemDelete
{
public:
void operator()(void *p)
{
if (p)
{
delete p;
}
}
};
// ComPtrList class
// Derived class that makes it safer to store COM pointers in the List<> class.
// It automatically AddRef's the pointers that are inserted onto the list
// (unless the insertion method fails).
//
// T must be a COM interface type.
// example: ComPtrList<IUnknown>
//
// NULLABLE: If true, client can insert nullptr pointers. This means GetItem can
// succeed but return a nullptr pointer. By default, the list does not allow nullptr
// pointers.
template <class T, bool NULLABLE = FALSE>
class ComPtrList : public List<T*>
{
public:
typedef T* Ptr;
void Clear()
{
ComAutoRelease car;
List<Ptr>::Clear(car);
}
~ComPtrList()
{
Clear();
}
protected:
HRESULT InsertAfter(Ptr item, Node *pBefore)
{
// Do not allow nullptr item pointers unless NULLABLE is true.
if (item == nullptr && !NULLABLE)
{
return E_POINTER;
}
if (item)
{
item->AddRef();
}
HRESULT hr = List<Ptr>::InsertAfter(item, pBefore);
if (FAILED(hr) && item != nullptr)
{
item->Release();
}
return hr;
}
HRESULT GetItem(const Node *pNode, Ptr* ppItem)
{
Ptr pItem = nullptr;
// The base class gives us the pointer without AddRef'ing it.
// If we return the pointer to the caller, we must AddRef().
HRESULT hr = List<Ptr>::GetItem(pNode, &pItem);
if (SUCCEEDED(hr))
{
assert(pItem || NULLABLE);
if (pItem)
{
*ppItem = pItem;
(*ppItem)->AddRef();
}
}
return hr;
}
HRESULT RemoveItem(Node *pNode, Ptr *ppItem)
{
// ppItem can be nullptr, but we need to get the
// item so that we can release it.
// If ppItem is not nullptr, we will AddRef it on the way out.
Ptr pItem = nullptr;
HRESULT hr = List<Ptr>::RemoveItem(pNode, &pItem);
if (SUCCEEDED(hr))
{
assert(pItem || NULLABLE);
if (ppItem && pItem)
{
*ppItem = pItem;
(*ppItem)->AddRef();
}
if (pItem)
{
pItem->Release();
pItem = nullptr;
}
}
return hr;
}
};

@ -0,0 +1,222 @@
//////////////////////////////////////////////////////////////////////////
//
// OpQueue.h
// Async operation queue.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////
#pragma once
#pragma warning( push )
#pragma warning( disable : 4355 ) // 'this' used in base member initializer list
/*
This header file defines an object to help queue and serialize
asynchronous operations.
Background:
To perform an operation asynchronously in Media Foundation, an object
does one of the following:
1. Calls MFPutWorkItem(Ex), using either a standard work queue
identifier or a caller-allocated work queue. The work-queue
thread invokes the object's callback.
2. Creates an async result object (IMFAsyncResult) and calls
MFInvokeCallback to invoke the object's callback.
Ultimately, either of these cause the object's callback to be invoked
from a work-queue thread. The object can then complete the operation
inside the callback.
However, the Media Foundation platform may dispatch async callbacks in
parallel on several threads. Putting an item on a work queue does NOT
guarantee that one operation will complete before the next one starts,
or even that work items will be dispatched in the same order they were
called.
To serialize async operations that should not overlap, an object should
use a queue. While one operation is pending, subsequent operations are
put on the queue, and only dispatched after the previous operation is
complete.
The granularity of a single "operation" depends on the requirements of
that particular object. A single operation might involve several
asynchronous calls before the object dispatches the next operation on
the queue.
*/
//-------------------------------------------------------------------
// OpQueue class template
//
// Base class for an async operation queue.
//
// TOperation: The class used to describe operations. This class must
// implement IUnknown.
//
// The OpQueue class is an abstract class. The derived class must
// implement the following pure-virtual methods:
//
// - IUnknown methods (AddRef, Release, QI)
//
// - DispatchOperation:
//
// Performs the asynchronous operation specified by pOp.
//
// At the end of each operation, the derived class must call
// ProcessQueue to process the next operation in the queue.
//
// NOTE: An operation is not required to complete inside the
// DispatchOperation method. A single operation might consist
// of several asynchronous method calls.
//
// - ValidateOperation:
//
// Checks whether the object can perform the operation specified
// by pOp at this time.
//
// If the object cannot perform the operation now (e.g., because
// another operation is still in progress) the method should
// return MF_E_NOTACCEPTING.
//
//-------------------------------------------------------------------
#include "linklist.h"
#include "AsyncCB.h"
template <class T, class TOperation>
class OpQueue //: public IUnknown
{
public:
typedef ComPtrList<TOperation> OpList;
HRESULT QueueOperation(TOperation *pOp);
protected:
HRESULT ProcessQueue();
HRESULT ProcessQueueAsync(IMFAsyncResult *pResult);
virtual HRESULT DispatchOperation(TOperation *pOp) = 0;
virtual HRESULT ValidateOperation(TOperation *pOp) = 0;
OpQueue(CRITICAL_SECTION& critsec)
: m_OnProcessQueue(static_cast<T *>(this), &OpQueue::ProcessQueueAsync),
m_critsec(critsec)
{
}
virtual ~OpQueue()
{
}
protected:
OpList m_OpQueue; // Queue of operations.
CRITICAL_SECTION& m_critsec; // Protects the queue state.
AsyncCallback<T> m_OnProcessQueue; // ProcessQueueAsync callback.
};
//-------------------------------------------------------------------
// Place an operation on the queue.
// Public method.
//-------------------------------------------------------------------
template <class T, class TOperation>
HRESULT OpQueue<T, TOperation>::QueueOperation(TOperation *pOp)
{
HRESULT hr = S_OK;
EnterCriticalSection(&m_critsec);
hr = m_OpQueue.InsertBack(pOp);
if (SUCCEEDED(hr))
{
hr = ProcessQueue();
}
LeaveCriticalSection(&m_critsec);
return hr;
}
//-------------------------------------------------------------------
// Process the next operation on the queue.
// Protected method.
//
// Note: This method dispatches the operation to a work queue.
//-------------------------------------------------------------------
template <class T, class TOperation>
HRESULT OpQueue<T, TOperation>::ProcessQueue()
{
HRESULT hr = S_OK;
if (m_OpQueue.GetCount() > 0)
{
hr = MFPutWorkItem2(
MFASYNC_CALLBACK_QUEUE_STANDARD, // Use the standard work queue.
0, // Default priority
&m_OnProcessQueue, // Callback method.
nullptr // State object.
);
}
return hr;
}
//-------------------------------------------------------------------
// Process the next operation on the queue.
// Protected method.
//
// Note: This method is called from a work-queue thread.
//-------------------------------------------------------------------
template <class T, class TOperation>
HRESULT OpQueue<T, TOperation>::ProcessQueueAsync(IMFAsyncResult *pResult)
{
HRESULT hr = S_OK;
TOperation *pOp = nullptr;
EnterCriticalSection(&m_critsec);
if (m_OpQueue.GetCount() > 0)
{
hr = m_OpQueue.GetFront(&pOp);
if (SUCCEEDED(hr))
{
hr = ValidateOperation(pOp);
}
if (SUCCEEDED(hr))
{
hr = m_OpQueue.RemoveFront(nullptr);
}
if (SUCCEEDED(hr))
{
(void)DispatchOperation(pOp);
}
}
if (pOp != nullptr)
{
pOp->Release();
}
LeaveCriticalSection(&m_critsec);
return hr;
}
#pragma warning( pop )

@ -0,0 +1,4 @@
EXPORTS
DllCanUnloadNow PRIVATE
DllGetActivationFactory PRIVATE
DllGetClassObject PRIVATE

@ -0,0 +1,266 @@
// Defines the transform class.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
#ifndef GRAYSCALE_H
#define GRAYSCALE_H
#include <new>
#include <mfapi.h>
#include <mftransform.h>
#include <mfidl.h>
#include <mferror.h>
#include <strsafe.h>
#include <assert.h>
// Note: The Direct2D helper library is included for its 2D matrix operations.
#include <D2d1helper.h>
#include <wrl\implements.h>
#include <wrl\module.h>
#include <windows.media.h>
#include "GrayscaleTransform.h"
// CLSID of the MFT.
DEFINE_GUID(CLSID_GrayscaleMFT,
0x2f3dbc05, 0xc011, 0x4a8f, 0xb2, 0x64, 0xe4, 0x2e, 0x35, 0xc6, 0x7b, 0xf4);
//
// * IMPORTANT: If you implement your own MFT, create a new GUID for the CLSID. *
//
// Configuration attributes
// {7BBBB051-133B-41F5-B6AA-5AFF9B33A2CB}
DEFINE_GUID(MFT_GRAYSCALE_DESTINATION_RECT,
0x7bbbb051, 0x133b, 0x41f5, 0xb6, 0xaa, 0x5a, 0xff, 0x9b, 0x33, 0xa2, 0xcb);
// {14782342-93E8-4565-872C-D9A2973D5CBF}
DEFINE_GUID(MFT_GRAYSCALE_SATURATION,
0x14782342, 0x93e8, 0x4565, 0x87, 0x2c, 0xd9, 0xa2, 0x97, 0x3d, 0x5c, 0xbf);
// {E0BADE5D-E4B9-4689-9DBA-E2F00D9CED0E}
DEFINE_GUID(MFT_GRAYSCALE_CHROMA_ROTATION,
0xe0bade5d, 0xe4b9, 0x4689, 0x9d, 0xba, 0xe2, 0xf0, 0xd, 0x9c, 0xed, 0xe);
template <class T> void SafeRelease(T **ppT)
{
if (*ppT)
{
(*ppT)->Release();
*ppT = NULL;
}
}
// Function pointer for the function that transforms the image.
typedef void (*IMAGE_TRANSFORM_FN)(
const D2D1::Matrix3x2F& mat, // Chroma transform matrix.
const D2D_RECT_U& rcDest, // Destination rectangle for the transformation.
BYTE* pDest, // Destination buffer.
LONG lDestStride, // Destination stride.
const BYTE* pSrc, // Source buffer.
LONG lSrcStride, // Source stride.
DWORD dwWidthInPixels, // Image width in pixels.
DWORD dwHeightInPixels // Image height in pixels.
);
// CGrayscale class:
// Implements a grayscale video effect.
class CGrayscale
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::WinRtClassicComMix >,
ABI::Windows::Media::IMediaExtension,
IMFTransform >
{
InspectableClass(RuntimeClass_GrayscaleTransform_GrayscaleEffect, BaseTrust)
public:
CGrayscale();
~CGrayscale();
STDMETHOD(RuntimeClassInitialize)();
// IMediaExtension
STDMETHODIMP SetProperties(ABI::Windows::Foundation::Collections::IPropertySet *pConfiguration);
// IMFTransform
STDMETHODIMP GetStreamLimits(
DWORD *pdwInputMinimum,
DWORD *pdwInputMaximum,
DWORD *pdwOutputMinimum,
DWORD *pdwOutputMaximum
);
STDMETHODIMP GetStreamCount(
DWORD *pcInputStreams,
DWORD *pcOutputStreams
);
STDMETHODIMP GetStreamIDs(
DWORD dwInputIDArraySize,
DWORD *pdwInputIDs,
DWORD dwOutputIDArraySize,
DWORD *pdwOutputIDs
);
STDMETHODIMP GetInputStreamInfo(
DWORD dwInputStreamID,
MFT_INPUT_STREAM_INFO * pStreamInfo
);
STDMETHODIMP GetOutputStreamInfo(
DWORD dwOutputStreamID,
MFT_OUTPUT_STREAM_INFO * pStreamInfo
);
STDMETHODIMP GetAttributes(IMFAttributes** pAttributes);
STDMETHODIMP GetInputStreamAttributes(
DWORD dwInputStreamID,
IMFAttributes **ppAttributes
);
STDMETHODIMP GetOutputStreamAttributes(
DWORD dwOutputStreamID,
IMFAttributes **ppAttributes
);
STDMETHODIMP DeleteInputStream(DWORD dwStreamID);
STDMETHODIMP AddInputStreams(
DWORD cStreams,
DWORD *adwStreamIDs
);
STDMETHODIMP GetInputAvailableType(
DWORD dwInputStreamID,
DWORD dwTypeIndex, // 0-based
IMFMediaType **ppType
);
STDMETHODIMP GetOutputAvailableType(
DWORD dwOutputStreamID,
DWORD dwTypeIndex, // 0-based
IMFMediaType **ppType
);
STDMETHODIMP SetInputType(
DWORD dwInputStreamID,
IMFMediaType *pType,
DWORD dwFlags
);
STDMETHODIMP SetOutputType(
DWORD dwOutputStreamID,
IMFMediaType *pType,
DWORD dwFlags
);
STDMETHODIMP GetInputCurrentType(
DWORD dwInputStreamID,
IMFMediaType **ppType
);
STDMETHODIMP GetOutputCurrentType(
DWORD dwOutputStreamID,
IMFMediaType **ppType
);
STDMETHODIMP GetInputStatus(
DWORD dwInputStreamID,
DWORD *pdwFlags
);
STDMETHODIMP GetOutputStatus(DWORD *pdwFlags);
STDMETHODIMP SetOutputBounds(
LONGLONG hnsLowerBound,
LONGLONG hnsUpperBound
);
STDMETHODIMP ProcessEvent(
DWORD dwInputStreamID,
IMFMediaEvent *pEvent
);
STDMETHODIMP ProcessMessage(
MFT_MESSAGE_TYPE eMessage,
ULONG_PTR ulParam
);
STDMETHODIMP ProcessInput(
DWORD dwInputStreamID,
IMFSample *pSample,
DWORD dwFlags
);
STDMETHODIMP ProcessOutput(
DWORD dwFlags,
DWORD cOutputBufferCount,
MFT_OUTPUT_DATA_BUFFER *pOutputSamples, // one per stream
DWORD *pdwStatus
);
private:
// HasPendingOutput: Returns TRUE if the MFT is holding an input sample.
BOOL HasPendingOutput() const { return m_pSample != NULL; }
// IsValidInputStream: Returns TRUE if dwInputStreamID is a valid input stream identifier.
BOOL IsValidInputStream(DWORD dwInputStreamID) const
{
return dwInputStreamID == 0;
}
// IsValidOutputStream: Returns TRUE if dwOutputStreamID is a valid output stream identifier.
BOOL IsValidOutputStream(DWORD dwOutputStreamID) const
{
return dwOutputStreamID == 0;
}
HRESULT OnGetPartialType(DWORD dwTypeIndex, IMFMediaType **ppmt);
HRESULT OnCheckInputType(IMFMediaType *pmt);
HRESULT OnCheckOutputType(IMFMediaType *pmt);
HRESULT OnCheckMediaType(IMFMediaType *pmt);
void OnSetInputType(IMFMediaType *pmt);
void OnSetOutputType(IMFMediaType *pmt);
HRESULT BeginStreaming();
HRESULT EndStreaming();
HRESULT OnProcessOutput(IMFMediaBuffer *pIn, IMFMediaBuffer *pOut);
HRESULT OnFlush();
HRESULT UpdateFormatInfo();
CRITICAL_SECTION m_critSec;
// Transformation parameters
D2D1::Matrix3x2F m_transform; // Chroma transform matrix.
D2D_RECT_U m_rcDest; // Destination rectangle for the effect.
// Streaming
bool m_bStreamingInitialized;
IMFSample *m_pSample; // Input sample.
IMFMediaType *m_pInputType; // Input media type.
IMFMediaType *m_pOutputType; // Output media type.
// Fomat information
UINT32 m_imageWidthInPixels;
UINT32 m_imageHeightInPixels;
DWORD m_cbImageSize; // Image size, in bytes.
IMFAttributes *m_pAttributes;
// Image transform function. (Changes based on the media type.)
IMAGE_TRANSFORM_FN m_pTransformFn;
};
#endif

@ -0,0 +1,313 @@
<?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|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and '$(VisualStudioVersion)' == ''">$(VCTargetsPath11)</VCTargetsPath>
<ProjectGuid>{BA69218F-DA5C-4D14-A78D-21A9E4DEC669}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>GrayscaleTransform</RootNamespace>
<ProjectName>GrayscaleTransform</ProjectName>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<PropertyGroup>
<DefaultLanguage>en-US</DefaultLanguage>
</PropertyGroup>
<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 Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" 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|x64'" Label="PropertySheets">
<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>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" 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)'=='Release|x64'" 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 />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<GenerateManifest>false</GenerateManifest>
<OutDir>$(Configuration)\$(MSBuildProjectName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<GenerateManifest>false</GenerateManifest>
<OutDir>$(Configuration)\$(MSBuildProjectName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories);$(ProjectDir)\..\Common;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies);mf.lib;mfuuid.lib;mfplat.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>Grayscale.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(ProjectDir)$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial</Command>
<Outputs>$(ProjectDir)$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories);$(ProjectDir)\..\Common;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies);mf.lib;mfuuid.lib;mfplat.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>Grayscale.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial</Command>
<Outputs>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories);$(ProjectDir)\..\Common;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies);mf.lib;mfuuid.lib;mfplat.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>Grayscale.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial</Command>
<Outputs>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories);$(ProjectDir)\..\Common;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies);mf.lib;mfuuid.lib;mfplat.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>Grayscale.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(ProjectDir)$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial</Command>
<Outputs>$(ProjectDir)$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories);$(ProjectDir)\..\Common;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies);mf.lib;mfuuid.lib;mfplat.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>Grayscale.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial</Command>
<Outputs>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories);$(ProjectDir)\..\Common;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies);mf.lib;mfuuid.lib;mfplat.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>Grayscale.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial</Command>
<Outputs>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Grayscale.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="Grayscale.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="Grayscale.def" />
</ItemGroup>
<ItemGroup>
<Midl Include="GrayscaleTransform.idl">
<MetadataFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</MetadataFileName>
<MetadataFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</MetadataFileName>
<MetadataFileName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
</MetadataFileName>
<MetadataFileName Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
</MetadataFileName>
<MetadataFileName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</MetadataFileName>
<MetadataFileName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</MetadataFileName>
<AdditionalMetadataDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(WindowsSDK_MetadataPath)</AdditionalMetadataDirectories>
<AdditionalMetadataDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(WindowsSDK_MetadataPath)</AdditionalMetadataDirectories>
<AdditionalMetadataDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(WindowsSDK_MetadataPath)</AdditionalMetadataDirectories>
<AdditionalMetadataDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(WindowsSDK_MetadataPath)</AdditionalMetadataDirectories>
<AdditionalMetadataDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(WindowsSDK_MetadataPath)</AdditionalMetadataDirectories>
<AdditionalMetadataDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(WindowsSDK_MetadataPath)</AdditionalMetadataDirectories>
<EnableWindowsRuntime Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</EnableWindowsRuntime>
<EnableWindowsRuntime Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableWindowsRuntime>
<EnableWindowsRuntime Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</EnableWindowsRuntime>
<EnableWindowsRuntime Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</EnableWindowsRuntime>
<EnableWindowsRuntime Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</EnableWindowsRuntime>
<EnableWindowsRuntime Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</EnableWindowsRuntime>
<HeaderFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).h</HeaderFileName>
<HeaderFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).h</HeaderFileName>
<HeaderFileName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">%(Filename).h</HeaderFileName>
<HeaderFileName Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">%(Filename).h</HeaderFileName>
<HeaderFileName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).h</HeaderFileName>
<HeaderFileName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).h</HeaderFileName>
</Midl>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ItemGroup>
<_MdMergeOutput Condition="'$(Platform)' == 'Win32'" Include="$(ProjectDir)$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd" />
<_MdMergeOutput Condition="'$(Platform)' != 'Win32'" Include="$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd" />
</ItemGroup>
<Target Name="CopyWinmdArtifactsOutputGroup" Returns="@(CopyWinmdArtifactsOutputGroupOutputs)">
<ItemGroup>
<CopyWinmdArtifactsOutputGroupOutputs Include="@(_MdMergeOutput)">
<TargetPath>$(ProjectName).winmd</TargetPath>
<Implementation>$(TargetName)$(TargetExt)</Implementation>
</CopyWinmdArtifactsOutputGroupOutputs>
</ItemGroup>
</Target>
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Resources">
<UniqueIdentifier>bdc52ff6-58cb-464b-bf4f-0c1804b135ff</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>
<None Include="Grayscale.def" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="Grayscale.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Grayscale.h" />
</ItemGroup>
<ItemGroup>
<Midl Include="GrayscaleTransform.idl" />
</ItemGroup>
</Project>

@ -0,0 +1,11 @@
import "Windows.Media.idl";
#include <sdkddkver.h>
namespace GrayscaleTransform
{
[version(NTDDI_WIN8)]
runtimeclass GrayscaleEffect
{
}
}

@ -0,0 +1,58 @@
//////////////////////////////////////////////////////////////////////////
//
// dllmain.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////
#include <initguid.h>
#include "Grayscale.h"
using namespace Microsoft::WRL;
namespace Microsoft { namespace Samples {
ActivatableClass(CGrayscale);
}}
BOOL WINAPI DllMain( _In_ HINSTANCE hInstance, _In_ DWORD dwReason, _In_opt_ LPVOID lpReserved )
{
if( DLL_PROCESS_ATTACH == dwReason )
{
//
// Don't need per-thread callbacks
//
DisableThreadLibraryCalls( hInstance );
Module<InProc>::GetModule().Create();
}
else if( DLL_PROCESS_DETACH == dwReason )
{
Module<InProc>::GetModule().Terminate();
}
return TRUE;
}
HRESULT WINAPI DllGetActivationFactory( _In_ HSTRING activatibleClassId, _Outptr_ IActivationFactory** factory )
{
auto &module = Microsoft::WRL::Module< Microsoft::WRL::InProc >::GetModule();
return module.GetActivationFactory( activatibleClassId, factory );
}
HRESULT WINAPI DllCanUnloadNow()
{
auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
return (module.Terminate()) ? S_OK : S_FALSE;
}
STDAPI DllGetClassObject( _In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID FAR* ppv )
{
auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
return module.GetClassObject( rclsid, riid, ppv );
}

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
<Identity Name="Microsoft.SDKSamples.MediaCapture.CPP" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="1.0.0.0" />
<Properties>
<DisplayName>MediaCapture CPP sample</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\storeLogo-sdk.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.2.1</OSMinVersion>
<OSMaxVersionTested>6.2.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="MediaCapture.App" Executable="$targetnametoken$.exe" EntryPoint="MediaCapture.App">
<VisualElements DisplayName="MediaCapture CPP sample" Logo="Assets\squareTile-sdk.png" SmallLogo="Assets\smallTile-sdk.png" Description="MediaCapture CPP sample" ForegroundText="light" BackgroundColor="#00b2f0">
<DefaultTile ShortName="MC CPP" ShowName="allLogos" />
<SplashScreen Image="Assets\splash-sdk.png" BackgroundColor="#00b2f0" />
</VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="picturesLibrary" />
<Capability Name="musicLibrary" />
<Capability Name="videosLibrary" />
<DeviceCapability Name="webcam" />
<DeviceCapability Name="microphone" />
</Capabilities>
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>GrayscaleTransform.dll</Path>
<ActivatableClass ActivatableClassId="GrayscaleTransform.GrayscaleEffect" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
</Package>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

@ -0,0 +1,452 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "LayoutAwarePage.h"
#include "SuspensionManager.h"
using namespace SDKSample::Common;
using namespace Platform;
using namespace Platform::Collections;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::System;
using namespace Windows::UI::Core;
using namespace Windows::UI::ViewManagement;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Interop;
using namespace Windows::UI::Xaml::Navigation;
/// <summary>
/// Initializes a new instance of the <see cref="LayoutAwarePage"/> class.
/// </summary>
LayoutAwarePage::LayoutAwarePage()
{
if (Windows::ApplicationModel::DesignMode::DesignModeEnabled)
{
return;
}
// Create an empty default view model
DefaultViewModel = ref new Map<String^, Object^>(std::less<String^>());
// When this page is part of the visual tree make two changes:
// 1) Map application view state to visual state for the page
// 2) Handle keyboard and mouse navigation requests
Loaded += ref new RoutedEventHandler(this, &LayoutAwarePage::OnLoaded);
// Undo the same changes when the page is no longer visible
Unloaded += ref new RoutedEventHandler(this, &LayoutAwarePage::OnUnloaded);
}
static DependencyProperty^ _defaultViewModelProperty =
DependencyProperty::Register("DefaultViewModel",
TypeName(IObservableMap<String^, Object^>::typeid), TypeName(LayoutAwarePage::typeid), nullptr);
/// <summary>
/// Identifies the <see cref="DefaultViewModel"/> dependency property.
/// </summary>
DependencyProperty^ LayoutAwarePage::DefaultViewModelProperty::get()
{
return _defaultViewModelProperty;
}
/// <summary>
/// Gets an implementation of <see cref="IObservableMap&lt;String, Object&gt;"/> designed to be
/// used as a trivial view model.
/// </summary>
IObservableMap<String^, Object^>^ LayoutAwarePage::DefaultViewModel::get()
{
return safe_cast<IObservableMap<String^, Object^>^>(GetValue(DefaultViewModelProperty));
}
/// <summary>
/// Sets an implementation of <see cref="IObservableMap&lt;String, Object&gt;"/> designed to be
/// used as a trivial view model.
/// </summary>
void LayoutAwarePage::DefaultViewModel::set(IObservableMap<String^, Object^>^ value)
{
SetValue(DefaultViewModelProperty, value);
}
/// <summary>
/// Invoked when the page is part of the visual tree
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="e">Event data describing the conditions that led to the event.</param>
void LayoutAwarePage::OnLoaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
this->StartLayoutUpdates(sender, e);
// Keyboard and mouse navigation only apply when occupying the entire window
if (this->ActualHeight == Window::Current->Bounds.Height &&
this->ActualWidth == Window::Current->Bounds.Width)
{
// Listen to the window directly so focus isn't required
_acceleratorKeyEventToken = Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated +=
ref new TypedEventHandler<CoreDispatcher^, AcceleratorKeyEventArgs^>(this,
&LayoutAwarePage::CoreDispatcher_AcceleratorKeyActivated);
_pointerPressedEventToken = Window::Current->CoreWindow->PointerPressed +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this,
&LayoutAwarePage::CoreWindow_PointerPressed);
_navigationShortcutsRegistered = true;
}
}
/// <summary>
/// Invoked when the page is removed from visual tree
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="e">Event data describing the conditions that led to the event.</param>
void LayoutAwarePage::OnUnloaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
if (_navigationShortcutsRegistered)
{
Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated -= _acceleratorKeyEventToken;
Window::Current->CoreWindow->PointerPressed -= _pointerPressedEventToken;
_navigationShortcutsRegistered = false;
}
StopLayoutUpdates(sender, e);
}
#pragma region Navigation support
/// <summary>
/// Invoked as an event handler to navigate backward in the page's associated <see cref="Frame"/>
/// until it reaches the top of the navigation stack.
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="e">Event data describing the conditions that led to the event.</param>
void LayoutAwarePage::GoHome(Object^ sender, RoutedEventArgs^ e)
{
(void) sender; // Unused parameter
(void) e; // Unused parameter
// Use the navigation frame to return to the topmost page
if (Frame != nullptr)
{
while (Frame->CanGoBack)
{
Frame->GoBack();
}
}
}
/// <summary>
/// Invoked as an event handler to navigate backward in the navigation stack
/// associated with this page's <see cref="Frame"/>.
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="e">Event data describing the conditions that led to the event.</param>
void LayoutAwarePage::GoBack(Object^ sender, RoutedEventArgs^ e)
{
(void) sender; // Unused parameter
(void) e; // Unused parameter
// Use the navigation frame to return to the previous page
if (Frame != nullptr && Frame->CanGoBack)
{
Frame->GoBack();
}
}
/// <summary>
/// Invoked as an event handler to navigate forward in the navigation stack
/// associated with this page's <see cref="Frame"/>.
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="e">Event data describing the conditions that led to the event.</param>
void LayoutAwarePage::GoForward(Object^ sender, RoutedEventArgs^ e)
{
(void) sender; // Unused parameter
(void) e; // Unused parameter
// Use the navigation frame to advance to the next page
if (Frame != nullptr && Frame->CanGoForward)
{
Frame->GoForward();
}
}
/// <summary>
/// Invoked on every keystroke, including system keys such as Alt key combinations, when
/// this page is active and occupies the entire window. Used to detect keyboard navigation
/// between pages even when the page itself doesn't have focus.
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="args">Event data describing the conditions that led to the event.</param>
void LayoutAwarePage::CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher^ sender, AcceleratorKeyEventArgs^ args)
{
auto virtualKey = args->VirtualKey;
// Only investigate further when Left, Right, or the dedicated Previous or Next keys
// are pressed
if ((args->EventType == CoreAcceleratorKeyEventType::SystemKeyDown ||
args->EventType == CoreAcceleratorKeyEventType::KeyDown) &&
(virtualKey == VirtualKey::Left || virtualKey == VirtualKey::Right ||
(int)virtualKey == 166 || (int)virtualKey == 167))
{
auto coreWindow = Window::Current->CoreWindow;
auto downState = Windows::UI::Core::CoreVirtualKeyStates::Down;
bool menuKey = (coreWindow->GetKeyState(VirtualKey::Menu) & downState) == downState;
bool controlKey = (coreWindow->GetKeyState(VirtualKey::Control) & downState) == downState;
bool shiftKey = (coreWindow->GetKeyState(VirtualKey::Shift) & downState) == downState;
bool noModifiers = !menuKey && !controlKey && !shiftKey;
bool onlyAlt = menuKey && !controlKey && !shiftKey;
if (((int)virtualKey == 166 && noModifiers) ||
(virtualKey == VirtualKey::Left && onlyAlt))
{
// When the previous key or Alt+Left are pressed navigate back
args->Handled = true;
GoBack(this, ref new RoutedEventArgs());
}
else if (((int)virtualKey == 167 && noModifiers) ||
(virtualKey == VirtualKey::Right && onlyAlt))
{
// When the next key or Alt+Right are pressed navigate forward
args->Handled = true;
GoForward(this, ref new RoutedEventArgs());
}
}
}
/// <summary>
/// Invoked on every mouse click, touch screen tap, or equivalent interaction when this
/// page is active and occupies the entire window. Used to detect browser-style next and
/// previous mouse button clicks to navigate between pages.
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="args">Event data describing the conditions that led to the event.</param>
void LayoutAwarePage::CoreWindow_PointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
{
auto properties = args->CurrentPoint->Properties;
// Ignore button chords with the left, right, and middle buttons
if (properties->IsLeftButtonPressed || properties->IsRightButtonPressed ||
properties->IsMiddleButtonPressed) return;
// If back or foward are pressed (but not both) navigate appropriately
bool backPressed = properties->IsXButton1Pressed;
bool forwardPressed = properties->IsXButton2Pressed;
if (backPressed ^ forwardPressed)
{
args->Handled = true;
if (backPressed) GoBack(this, ref new RoutedEventArgs());
if (forwardPressed) GoForward(this, ref new RoutedEventArgs());
}
}
#pragma endregion
#pragma region Visual state switching
/// <summary>
/// Invoked as an event handler, typically on the <see cref="Loaded"/> event of a
/// <see cref="Control"/> within the page, to indicate that the sender should start receiving
/// visual state management changes that correspond to application view state changes.
/// </summary>
/// <param name="sender">Instance of <see cref="Control"/> that supports visual state management
/// corresponding to view states.</param>
/// <param name="e">Event data that describes how the request was made.</param>
/// <remarks>The current view state will immediately be used to set the corresponding visual state
/// when layout updates are requested. A corresponding <see cref="Unloaded"/> event handler
/// connected to <see cref="StopLayoutUpdates"/> is strongly encouraged. Instances of
/// <see cref="LayoutAwarePage"/> automatically invoke these handlers in their Loaded and Unloaded
/// events.</remarks>
/// <seealso cref="DetermineVisualState"/>
/// <seealso cref="InvalidateVisualState"/>
void LayoutAwarePage::StartLayoutUpdates(Object^ sender, RoutedEventArgs^ e)
{
(void) e; // Unused parameter
auto control = safe_cast<Control^>(sender);
if (_layoutAwareControls == nullptr)
{
// Start listening to view state changes when there are controls interested in updates
_layoutAwareControls = ref new Vector<Control^>();
_windowSizeEventToken = Window::Current->SizeChanged += ref new WindowSizeChangedEventHandler(this, &LayoutAwarePage::WindowSizeChanged);
// Page receives notifications for children. Protect the page until we stopped layout updates for all controls.
_this = this;
}
_layoutAwareControls->Append(control);
// Set the initial visual state of the control
VisualStateManager::GoToState(control, DetermineVisualState(ApplicationView::Value), false);
}
void LayoutAwarePage::WindowSizeChanged(Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e)
{
(void) sender; // Unused parameter
(void) e; // Unused parameter
InvalidateVisualState();
}
/// <summary>
/// Invoked as an event handler, typically on the <see cref="Unloaded"/> event of a
/// <see cref="Control"/>, to indicate that the sender should start receiving visual state
/// management changes that correspond to application view state changes.
/// </summary>
/// <param name="sender">Instance of <see cref="Control"/> that supports visual state management
/// corresponding to view states.</param>
/// <param name="e">Event data that describes how the request was made.</param>
/// <remarks>The current view state will immediately be used to set the corresponding visual state
/// when layout updates are requested.</remarks>
/// <seealso cref="StartLayoutUpdates"/>
void LayoutAwarePage::StopLayoutUpdates(Object^ sender, RoutedEventArgs^ e)
{
(void) e; // Unused parameter
auto control = safe_cast<Control^>(sender);
unsigned int index;
if (_layoutAwareControls != nullptr && _layoutAwareControls->IndexOf(control, &index))
{
_layoutAwareControls->RemoveAt(index);
if (_layoutAwareControls->Size == 0)
{
// Stop listening to view state changes when no controls are interested in updates
Window::Current->SizeChanged -= _windowSizeEventToken;
_layoutAwareControls = nullptr;
// Last control has received the Unload notification.
_this = nullptr;
}
}
}
/// <summary>
/// Translates <see cref="ApplicationViewState"/> values into strings for visual state management
/// within the page. The default implementation uses the names of enum values. Subclasses may
/// override this method to control the mapping scheme used.
/// </summary>
/// <param name="viewState">View state for which a visual state is desired.</param>
/// <returns>Visual state name used to drive the <see cref="VisualStateManager"/></returns>
/// <seealso cref="InvalidateVisualState"/>
String^ LayoutAwarePage::DetermineVisualState(ApplicationViewState viewState)
{
switch (viewState)
{
case ApplicationViewState::Filled:
return "Filled";
case ApplicationViewState::Snapped:
return "Snapped";
case ApplicationViewState::FullScreenPortrait:
return "FullScreenPortrait";
case ApplicationViewState::FullScreenLandscape:
default:
return "FullScreenLandscape";
}
}
/// <summary>
/// Updates all controls that are listening for visual state changes with the correct visual
/// state.
/// </summary>
/// <remarks>
/// Typically used in conjunction with overriding <see cref="DetermineVisualState"/> to
/// signal that a different value may be returned even though the view state has not changed.
/// </remarks>
void LayoutAwarePage::InvalidateVisualState()
{
if (_layoutAwareControls != nullptr)
{
String^ visualState = DetermineVisualState(ApplicationView::Value);
auto controlIterator = _layoutAwareControls->First();
while (controlIterator->HasCurrent)
{
auto control = controlIterator->Current;
VisualStateManager::GoToState(control, visualState, false);
controlIterator->MoveNext();
}
}
}
#pragma endregion
#pragma region Process lifetime management
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property provides the group to be displayed.</param>
void LayoutAwarePage::OnNavigatedTo(NavigationEventArgs^ e)
{
// Returning to a cached page through navigation shouldn't trigger state loading
if (_pageKey != nullptr) return;
auto frameState = SuspensionManager::SessionStateForFrame(Frame);
_pageKey = "Page-" + Frame->BackStackDepth;
if (e->NavigationMode == NavigationMode::New)
{
// Clear existing state for forward navigation when adding a new page to the
// navigation stack
auto nextPageKey = _pageKey;
int nextPageIndex = Frame->BackStackDepth;
while (frameState->HasKey(nextPageKey))
{
frameState->Remove(nextPageKey);
nextPageIndex++;
nextPageKey = "Page-" + nextPageIndex;
}
// Pass the navigation parameter to the new page
LoadState(e->Parameter, nullptr);
}
else
{
// Pass the navigation parameter and preserved page state to the page, using
// the same strategy for loading suspended state and recreating pages discarded
// from cache
LoadState(e->Parameter, safe_cast<IMap<String^, Object^>^>(frameState->Lookup(_pageKey)));
}
}
/// <summary>
/// Invoked when this page will no longer be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property provides the group to be displayed.</param>
void LayoutAwarePage::OnNavigatedFrom(NavigationEventArgs^ e)
{
auto frameState = SuspensionManager::SessionStateForFrame(Frame);
auto pageState = ref new Map<String^, Object^>();
SaveState(pageState);
frameState->Insert(_pageKey, pageState);
}
/// <summary>
/// Populates the page with content passed during navigation. Any saved state is also
/// provided when recreating a page from a prior session.
/// </summary>
/// <param name="navigationParameter">The parameter value passed to
/// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
/// </param>
/// <param name="pageState">A map of state preserved by this page during an earlier
/// session. This will be null the first time a page is visited.</param>
void LayoutAwarePage::LoadState(Object^ navigationParameter, IMap<String^, Object^>^ pageState)
{
}
/// <summary>
/// Preserves state associated with this page in case the application is suspended or the
/// page is discarded from the navigation cache. Values must conform to the serialization
/// requirements of <see cref="SuspensionManager.SessionState"/>.
/// </summary>
/// <param name="pageState">An empty map to be populated with serializable state.</param>
void LayoutAwarePage::SaveState(IMap<String^, Object^>^ pageState)
{
}
#pragma endregion

@ -0,0 +1,88 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
#include <collection.h>
namespace SDKSample
{
namespace Common
{
/// <summary>
/// Typical implementation of Page that provides several important conveniences:
/// <list type="bullet">
/// <item>
/// <description>Application view state to visual state mapping</description>
/// </item>
/// <item>
/// <description>GoBack, GoForward, and GoHome event handlers</description>
/// </item>
/// <item>
/// <description>Mouse and keyboard shortcuts for navigation</description>
/// </item>
/// <item>
/// <description>State management for navigation and process lifetime management</description>
/// </item>
/// <item>
/// <description>A default view model</description>
/// </item>
/// </list>
/// </summary>
[Windows::Foundation::Metadata::WebHostHidden]
public ref class LayoutAwarePage : Windows::UI::Xaml::Controls::Page
{
internal:
LayoutAwarePage();
public:
void StartLayoutUpdates(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void StopLayoutUpdates(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void InvalidateVisualState();
static property Windows::UI::Xaml::DependencyProperty^ DefaultViewModelProperty
{
Windows::UI::Xaml::DependencyProperty^ get();
};
property Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::Object^>^ DefaultViewModel
{
Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::Object^>^ get();
void set(Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::Object^>^ value);
}
protected:
virtual void GoHome(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
virtual void GoBack(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
virtual void GoForward(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
virtual Platform::String^ DetermineVisualState(Windows::UI::ViewManagement::ApplicationViewState viewState);
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
virtual void LoadState(Platform::Object^ navigationParameter,
Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState);
virtual void SaveState(Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState);
private:
Platform::String^ _pageKey;
bool _navigationShortcutsRegistered;
Platform::Collections::Map<Platform::String^, Platform::Object^>^ _defaultViewModel;
Windows::Foundation::EventRegistrationToken _windowSizeEventToken,
_acceleratorKeyEventToken, _pointerPressedEventToken;
Platform::Collections::Vector<Windows::UI::Xaml::Controls::Control^>^ _layoutAwareControls;
void WindowSizeChanged(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e);
void OnLoaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnUnloaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void CoreDispatcher_AcceleratorKeyActivated(Windows::UI::Core::CoreDispatcher^ sender,
Windows::UI::Core::AcceleratorKeyEventArgs^ args);
void CoreWindow_PointerPressed(Windows::UI::Core::CoreWindow^ sender,
Windows::UI::Core::PointerEventArgs^ args);
LayoutAwarePage^ _this; // Strong reference to self, cleaned up in OnUnload
};
}
}

@ -0,0 +1,978 @@
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Non-brush values that vary across themes -->
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<x:String x:Key="BackButtonGlyph">&#xE071;</x:String>
<x:String x:Key="BackButtonSnappedGlyph">&#xE0BA;</x:String>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<x:String x:Key="BackButtonGlyph">&#xE0A6;</x:String>
<x:String x:Key="BackButtonSnappedGlyph">&#xE0C4;</x:String>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<!-- RichTextBlock styles -->
<Style x:Key="BasicRichTextStyle" TargetType="RichTextBlock">
<Setter Property="Foreground" Value="{StaticResource ApplicationForegroundThemeBrush}"/>
<Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}"/>
<Setter Property="FontFamily" Value="{StaticResource ContentControlThemeFontFamily}"/>
<Setter Property="TextTrimming" Value="WordEllipsis"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Typography.StylisticSet20" Value="True"/>
<Setter Property="Typography.DiscretionaryLigatures" Value="True"/>
</Style>
<Style x:Key="BaselineRichTextStyle" TargetType="RichTextBlock" BasedOn="{StaticResource BasicRichTextStyle}">
<Setter Property="LineHeight" Value="20"/>
<Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>
<!-- Properly align text along its baseline -->
<Setter Property="RenderTransform">
<Setter.Value>
<TranslateTransform X="-1" Y="4"/>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ItemRichTextStyle" TargetType="RichTextBlock" BasedOn="{StaticResource BaselineRichTextStyle}"/>
<Style x:Key="BodyRichTextStyle" TargetType="RichTextBlock" BasedOn="{StaticResource BaselineRichTextStyle}">
<Setter Property="FontWeight" Value="SemiLight"/>
</Style>
<!-- TextBlock styles -->
<Style x:Key="BasicTextStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource ApplicationForegroundThemeBrush}"/>
<Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}"/>
<Setter Property="FontFamily" Value="{StaticResource ContentControlThemeFontFamily}"/>
<Setter Property="TextTrimming" Value="WordEllipsis"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Typography.StylisticSet20" Value="True"/>
<Setter Property="Typography.DiscretionaryLigatures" Value="True"/>
</Style>
<Style x:Key="BaselineTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BasicTextStyle}">
<Setter Property="LineHeight" Value="20"/>
<Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>
<!-- Properly align text along its baseline -->
<Setter Property="RenderTransform">
<Setter.Value>
<TranslateTransform X="-1" Y="4"/>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="HeaderTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
<Setter Property="FontSize" Value="56"/>
<Setter Property="FontWeight" Value="Light"/>
<Setter Property="LineHeight" Value="40"/>
<Setter Property="RenderTransform">
<Setter.Value>
<TranslateTransform X="-2" Y="8"/>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SubheaderTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
<Setter Property="FontSize" Value="26.667"/>
<Setter Property="FontWeight" Value="Light"/>
<Setter Property="LineHeight" Value="30"/>
<Setter Property="RenderTransform">
<Setter.Value>
<TranslateTransform X="-1" Y="6"/>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TitleTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
<Setter Property="FontWeight" Value="SemiBold"/>
</Style>
<Style x:Key="ItemTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}"/>
<Style x:Key="BodyTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
<Setter Property="FontWeight" Value="SemiLight"/>
</Style>
<Style x:Key="CaptionTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
<Setter Property="FontSize" Value="12"/>
<Setter Property="Foreground" Value="{StaticResource ApplicationSecondaryForegroundThemeBrush}"/>
</Style>
<!-- Button styles -->
<!--
TextButtonStyle is used to style a Button using subheader-styled text with no other adornment. This
style is used in the GroupedItemsPage as a group header and in the FileOpenPickerPage for triggering
commands.
-->
<Style x:Key="TextButtonStyle" TargetType="Button">
<Setter Property="MinWidth" Value="0"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="Transparent">
<TextBlock
x:Name="Text"
Text="{TemplateBinding Content}"
Margin="3,-7,3,10"
TextWrapping="NoWrap"
Style="{StaticResource SubheaderTextStyle}"/>
<Rectangle
x:Name="FocusVisualWhite"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="1.5"/>
<Rectangle
x:Name="FocusVisualBlack"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="0.5"/>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ApplicationPointerOverForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ApplicationPressedForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonDisabledForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualWhite" Storyboard.TargetProperty="Opacity"/>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualBlack" Storyboard.TargetProperty="Opacity"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--
TextRadioButtonStyle is used to style a RadioButton using subheader-styled text with no other adornment.
This style is used in the SearchResultsPage to allow selection among filters.
-->
<Style x:Key="TextRadioButtonStyle" TargetType="RadioButton">
<Setter Property="MinWidth" Value="0"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid Background="Transparent">
<TextBlock
x:Name="Text"
Text="{TemplateBinding Content}"
Margin="3,-7,3,10"
TextWrapping="NoWrap"
Style="{StaticResource SubheaderTextStyle}"/>
<Rectangle
x:Name="FocusVisualWhite"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="1.5"/>
<Rectangle
x:Name="FocusVisualBlack"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="0.5"/>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ApplicationPointerOverForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ApplicationPressedForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonDisabledForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualWhite" Storyboard.TargetProperty="Opacity"/>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualBlack" Storyboard.TargetProperty="Opacity"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Checked"/>
<VisualState x:Name="Unchecked">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ApplicationSecondaryForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Indeterminate"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--
AppBarButtonStyle is used to style a Button for use in an App Bar. Content will be centered and should fit within
the 40-pixel radius glyph provided. 16-point Segoe UI Symbol is used for content text to simplify the use of glyphs
from that font. AutomationProperties.Name is used for the text below the glyph.
-->
<Style x:Key="AppBarButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="{StaticResource AppBarItemForegroundThemeBrush}"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="FontFamily" Value="Segoe UI Symbol"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="AutomationProperties.ItemType" Value="App Bar Button"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Width="100" Background="Transparent">
<StackPanel VerticalAlignment="Top" Margin="0,14,0,13">
<Grid Width="40" Height="40" Margin="0,0,0,5" HorizontalAlignment="Center">
<TextBlock x:Name="BackgroundGlyph" Text="&#xE0A8;" FontFamily="Segoe UI Symbol" FontSize="53.333" Margin="-4,-19,0,0" Foreground="{StaticResource AppBarItemBackgroundThemeBrush}"/>
<TextBlock x:Name="OutlineGlyph" Text="&#xE0A7;" FontFamily="Segoe UI Symbol" FontSize="53.333" Margin="-4,-19,0,0"/>
<ContentPresenter x:Name="Content" HorizontalAlignment="Center" Margin="-1,-1,0,0" VerticalAlignment="Center"/>
</Grid>
<TextBlock
x:Name="TextLabel"
Text="{TemplateBinding AutomationProperties.Name}"
Margin="0,0,2,0"
FontSize="12"
TextAlignment="Center"
Width="88"
MaxHeight="32"
TextTrimming="WordEllipsis"
Style="{StaticResource BasicTextStyle}"/>
</StackPanel>
<Rectangle
x:Name="FocusVisualWhite"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="1.5"/>
<Rectangle
x:Name="FocusVisualBlack"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="0.5"/>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemPointerOverBackgroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemPointerOverForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="OutlineGlyph"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0"/>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemPressedForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="OutlineGlyph" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemDisabledForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemDisabledForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemDisabledForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="FocusVisualWhite"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0"/>
<DoubleAnimation
Storyboard.TargetName="FocusVisualBlack"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused" />
<VisualState x:Name="PointerFocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Standard App Bar buttons -->
<Style x:Key="SkipBackAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="SkipBackAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Skip Back"/>
<Setter Property="Content" Value="&#xE100;"/>
</Style>
<Style x:Key="SkipAheadAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="SkipAheadAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Skip Ahead"/>
<Setter Property="Content" Value="&#xE101;"/>
</Style>
<Style x:Key="PlayAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="PlayAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Play"/>
<Setter Property="Content" Value="&#xE102;"/>
</Style>
<Style x:Key="PauseAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="PauseAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Pause"/>
<Setter Property="Content" Value="&#xE103;"/>
</Style>
<Style x:Key="EditAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="EditAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Edit"/>
<Setter Property="Content" Value="&#xE104;"/>
</Style>
<Style x:Key="SaveAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="SaveAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Save"/>
<Setter Property="Content" Value="&#xE105;"/>
</Style>
<Style x:Key="DeleteAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="DeleteAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Delete"/>
<Setter Property="Content" Value="&#xE106;"/>
</Style>
<Style x:Key="DiscardAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="DiscardAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Discard"/>
<Setter Property="Content" Value="&#xE107;"/>
</Style>
<Style x:Key="RemoveAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="RemoveAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Remove"/>
<Setter Property="Content" Value="&#xE108;"/>
</Style>
<Style x:Key="AddAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="AddAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Add"/>
<Setter Property="Content" Value="&#xE109;"/>
</Style>
<Style x:Key="NoAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="NoAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="No"/>
<Setter Property="Content" Value="&#xE10A;"/>
</Style>
<Style x:Key="YesAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="YesAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Yes"/>
<Setter Property="Content" Value="&#xE10B;"/>
</Style>
<Style x:Key="MoreAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="MoreAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="More"/>
<Setter Property="Content" Value="&#xE10C;"/>
</Style>
<Style x:Key="RedoAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="RedoAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Redo"/>
<Setter Property="Content" Value="&#xE10D;"/>
</Style>
<Style x:Key="UndoAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="UndoAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Undo"/>
<Setter Property="Content" Value="&#xE10E;"/>
</Style>
<Style x:Key="HomeAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="HomeAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Home"/>
<Setter Property="Content" Value="&#xE10F;"/>
</Style>
<Style x:Key="OutAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="OutAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Out"/>
<Setter Property="Content" Value="&#xE110;"/>
</Style>
<Style x:Key="NextAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="NextAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Next"/>
<Setter Property="Content" Value="&#xE111;"/>
</Style>
<Style x:Key="PreviousAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="PreviousAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Previous"/>
<Setter Property="Content" Value="&#xE112;"/>
</Style>
<Style x:Key="FavoriteAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="FavoriteAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Favorite"/>
<Setter Property="Content" Value="&#xE113;"/>
</Style>
<Style x:Key="PhotoAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="PhotoAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Photo"/>
<Setter Property="Content" Value="&#xE114;"/>
</Style>
<Style x:Key="SettingsAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="SettingsAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Settings"/>
<Setter Property="Content" Value="&#xE115;"/>
</Style>
<Style x:Key="VideoAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="VideoAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Video"/>
<Setter Property="Content" Value="&#xE116;"/>
</Style>
<Style x:Key="RefreshAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="RefreshAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Refresh"/>
<Setter Property="Content" Value="&#xE117;"/>
</Style>
<Style x:Key="DownloadAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="DownloadAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Download"/>
<Setter Property="Content" Value="&#xE118;"/>
</Style>
<Style x:Key="MailAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="MailAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Mail"/>
<Setter Property="Content" Value="&#xE119;"/>
</Style>
<Style x:Key="SearchAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="SearchAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Search"/>
<Setter Property="Content" Value="&#xE11A;"/>
</Style>
<Style x:Key="HelpAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="HelpAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Help"/>
<Setter Property="Content" Value="&#xE11B;"/>
</Style>
<Style x:Key="UploadAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="UploadAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Upload"/>
<Setter Property="Content" Value="&#xE11C;"/>
</Style>
<Style x:Key="PinAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="PinAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Pin"/>
<Setter Property="Content" Value="&#xE141;"/>
</Style>
<Style x:Key="UnpinAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="UnpinAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Unpin"/>
<Setter Property="Content" Value="&#xE196;"/>
</Style>
<!-- Title area styles -->
<Style x:Key="PageHeaderTextStyle" TargetType="TextBlock" BasedOn="{StaticResource HeaderTextStyle}">
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Margin" Value="0,0,40,40"/>
</Style>
<Style x:Key="PageSubheaderTextStyle" TargetType="TextBlock" BasedOn="{StaticResource SubheaderTextStyle}">
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Margin" Value="0,0,0,40"/>
</Style>
<Style x:Key="SnappedPageHeaderTextStyle" TargetType="TextBlock" BasedOn="{StaticResource PageSubheaderTextStyle}">
<Setter Property="Margin" Value="0,0,18,40"/>
</Style>
<!--
BackButtonStyle is used to style a Button for use in the title area of a page. Margins appropriate for
the conventional page layout are included as part of the style.
-->
<Style x:Key="BackButtonStyle" TargetType="Button">
<Setter Property="MinWidth" Value="0"/>
<Setter Property="Width" Value="48"/>
<Setter Property="Height" Value="48"/>
<Setter Property="Margin" Value="36,0,36,36"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="FontFamily" Value="Segoe UI Symbol"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="FontSize" Value="56"/>
<Setter Property="AutomationProperties.AutomationId" Value="BackButton"/>
<Setter Property="AutomationProperties.Name" Value="Back"/>
<Setter Property="AutomationProperties.ItemType" Value="Navigation Button"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="RootGrid">
<Grid Margin="-1,-16,0,0">
<TextBlock x:Name="BackgroundGlyph" Text="&#xE0A8;" Foreground="{StaticResource BackButtonBackgroundThemeBrush}"/>
<TextBlock x:Name="NormalGlyph" Text="{StaticResource BackButtonGlyph}" Foreground="{StaticResource BackButtonForegroundThemeBrush}"/>
<TextBlock x:Name="ArrowGlyph" Text="&#xE0A6;" Foreground="{StaticResource BackButtonPressedForegroundThemeBrush}" Opacity="0"/>
</Grid>
<Rectangle
x:Name="FocusVisualWhite"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="1.5"/>
<Rectangle
x:Name="FocusVisualBlack"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="0.5"/>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonPointerOverBackgroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="NormalGlyph" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonPointerOverForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation
Storyboard.TargetName="ArrowGlyph"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0"/>
<DoubleAnimation
Storyboard.TargetName="NormalGlyph"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="FocusVisualWhite"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0"/>
<DoubleAnimation
Storyboard.TargetName="FocusVisualBlack"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused" />
<VisualState x:Name="PointerFocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--
PortraitBackButtonStyle is used to style a Button for use in the title area of a portrait page. Margins appropriate
for the conventional page layout are included as part of the style.
-->
<Style x:Key="PortraitBackButtonStyle" TargetType="Button" BasedOn="{StaticResource BackButtonStyle}">
<Setter Property="Margin" Value="26,0,26,36"/>
</Style>
<!--
SnappedBackButtonStyle is used to style a Button for use in the title area of a snapped page. Margins appropriate
for the conventional page layout are included as part of the style.
The obvious duplication here is necessary as the glyphs used in snapped are not merely smaller versions of the same
glyph but are actually distinct.
-->
<Style x:Key="SnappedBackButtonStyle" TargetType="Button">
<Setter Property="MinWidth" Value="0"/>
<Setter Property="Margin" Value="20,0,0,0"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="FontFamily" Value="Segoe UI Symbol"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="FontSize" Value="26.66667"/>
<Setter Property="AutomationProperties.AutomationId" Value="BackButton"/>
<Setter Property="AutomationProperties.Name" Value="Back"/>
<Setter Property="AutomationProperties.ItemType" Value="Navigation Button"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="RootGrid" Width="36" Height="36" Margin="-3,0,7,33">
<Grid Margin="-1,-1,0,0">
<TextBlock x:Name="BackgroundGlyph" Text="&#xE0D4;" Foreground="{StaticResource BackButtonBackgroundThemeBrush}"/>
<TextBlock x:Name="NormalGlyph" Text="{StaticResource BackButtonSnappedGlyph}" Foreground="{StaticResource BackButtonForegroundThemeBrush}"/>
<TextBlock x:Name="ArrowGlyph" Text="&#xE0C4;" Foreground="{StaticResource BackButtonPressedForegroundThemeBrush}" Opacity="0"/>
</Grid>
<Rectangle
x:Name="FocusVisualWhite"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="1.5"/>
<Rectangle
x:Name="FocusVisualBlack"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="0.5"/>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonPointerOverBackgroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="NormalGlyph" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonPointerOverForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation
Storyboard.TargetName="ArrowGlyph"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0"/>
<DoubleAnimation
Storyboard.TargetName="NormalGlyph"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="FocusVisualWhite"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0"/>
<DoubleAnimation
Storyboard.TargetName="FocusVisualBlack"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused" />
<VisualState x:Name="PointerFocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Item templates -->
<!-- Grid-appropriate 250 pixel square item template as seen in the GroupedItemsPage and ItemsPage -->
<DataTemplate x:Key="Standard250x250ItemTemplate">
<Grid HorizontalAlignment="Left" Width="250" Height="250">
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Image Source="{Binding Image}" Stretch="UniformToFill"/>
</Border>
<StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextStyle}" Height="60" Margin="15,0,15,0"/>
<TextBlock Text="{Binding Subtitle}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10"/>
</StackPanel>
</Grid>
</DataTemplate>
<!-- Grid-appropriate 500 by 130 pixel item template as seen in the GroupDetailPage -->
<DataTemplate x:Key="Standard500x130ItemTemplate">
<Grid Height="110" Width="480" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="110" Height="110">
<Image Source="{Binding Image}" Stretch="UniformToFill"/>
</Border>
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0">
<TextBlock Text="{Binding Title}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Subtitle}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Description}" Style="{StaticResource BodyTextStyle}" MaxHeight="60"/>
</StackPanel>
</Grid>
</DataTemplate>
<!-- List-appropriate 130 pixel high item template as seen in the SplitPage -->
<DataTemplate x:Key="Standard130ItemTemplate">
<Grid Height="110" Margin="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="110" Height="110">
<Image Source="{Binding Image}" Stretch="UniformToFill"/>
</Border>
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0">
<TextBlock Text="{Binding Title}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Subtitle}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Description}" Style="{StaticResource BodyTextStyle}" MaxHeight="60"/>
</StackPanel>
</Grid>
</DataTemplate>
<!--
List-appropriate 80 pixel high item template as seen in the SplitPage when Filled, and
the following pages when snapped: GroupedItemsPage, GroupDetailPage, and ItemsPage
-->
<DataTemplate x:Key="Standard80ItemTemplate">
<Grid Margin="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="60" Height="60">
<Image Source="{Binding Image}" Stretch="UniformToFill"/>
</Border>
<StackPanel Grid.Column="1" Margin="10,0,0,0">
<TextBlock Text="{Binding Title}" Style="{StaticResource ItemTextStyle}" MaxHeight="40"/>
<TextBlock Text="{Binding Subtitle}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap"/>
</StackPanel>
</Grid>
</DataTemplate>
<!-- Grid-appropriate 300 by 70 pixel item template as seen in the SearchResultsPage -->
<DataTemplate x:Key="StandardSmallIcon300x70ItemTemplate">
<Grid Width="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="10,10,0,20" Width="40" Height="40">
<Image Source="{Binding Image}" Stretch="UniformToFill"/>
</Border>
<StackPanel Grid.Column="1" Margin="10,0,10,10">
<TextBlock Text="{Binding Title}" Style="{StaticResource BodyTextStyle}" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Subtitle}" Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource ApplicationSecondaryForegroundThemeBrush}" Height="40"/>
</StackPanel>
</Grid>
</DataTemplate>
<!-- List-appropriate 70 pixel high item template as seen in the SearchResultsPage when Snapped -->
<DataTemplate x:Key="StandardSmallIcon70ItemTemplate">
<Grid Margin="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="0,0,0,10" Width="40" Height="40">
<Image Source="{Binding Image}" Stretch="UniformToFill"/>
</Border>
<StackPanel Grid.Column="1" Margin="10,-10,0,0">
<TextBlock Text="{Binding Title}" Style="{StaticResource BodyTextStyle}" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Subtitle}" Style="{StaticResource BodyTextStyle}" Foreground="{StaticResource ApplicationSecondaryForegroundThemeBrush}" Height="40"/>
</StackPanel>
</Grid>
</DataTemplate>
<!--
190x130 pixel item template for displaying file previews as seen in the FileOpenPickerPage
Includes an elaborate tooltip to display title and description text
-->
<DataTemplate x:Key="StandardFileWithTooltip190x130ItemTemplate">
<Grid>
<Grid Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Image
Source="{Binding Image}"
Width="190"
Height="130"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="Uniform"/>
</Grid>
<ToolTipService.Placement>Mouse</ToolTipService.Placement>
<ToolTipService.ToolTip>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="20">
<Image
Source="{Binding Image}"
Width="160"
Height="160"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="Uniform"/>
</Grid>
<StackPanel Width="200" Grid.Column="1" Margin="0,20,20,20">
<TextBlock Text="{Binding Title}" TextWrapping="NoWrap" Style="{StaticResource BodyTextStyle}"/>
<TextBlock Text="{Binding Description}" MaxHeight="140" Foreground="{StaticResource ApplicationSecondaryForegroundThemeBrush}" Style="{StaticResource BodyTextStyle}"/>
</StackPanel>
</Grid>
</ToolTipService.ToolTip>
</Grid>
</DataTemplate>
<!-- Default to 10-pixel spacing between grid items (after accounting for 4-pixel insets for focus) -->
<Style TargetType="GridViewItem">
<Setter Property="Margin" Value="0,0,2,2" />
</Style>
<!-- ScrollViewer styles -->
<Style x:Key="HorizontalScrollViewerStyle" TargetType="ScrollViewer">
<Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="VerticalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Enabled" />
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Disabled" />
<Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
</Style>
<Style x:Key="VerticalScrollViewerStyle" TargetType="ScrollViewer">
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" />
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Enabled" />
<Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
</Style>
<!-- Page layout roots typically use entrance animations and a theme-appropriate background color -->
<Style x:Key="LayoutRootStyle" TargetType="Panel">
<Setter Property="Background" Value="{StaticResource ApplicationPageBackgroundThemeBrush}"/>
<Setter Property="ChildrenTransitions">
<Setter.Value>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

@ -0,0 +1,481 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// SuspensionManager.cpp
// Implementation of the SuspensionManager class
//
#include "pch.h"
#include "SuspensionManager.h"
#include <collection.h>
#include <algorithm>
using namespace SDKSample::Common;
using namespace Concurrency;
using namespace Platform;
using namespace Platform::Collections;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Storage;
using namespace Windows::Storage::FileProperties;
using namespace Windows::Storage::Streams;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Interop;
namespace
{
Map<String^, Object^>^ _sessionState = ref new Map<String^, Object^>();
String^ sessionStateFilename = "_sessionState.dat";
// Forward declarations for object object read / write support
void WriteObject(Windows::Storage::Streams::DataWriter^ writer, Platform::Object^ object);
Platform::Object^ ReadObject(Windows::Storage::Streams::DataReader^ reader);
}
/// <summary>
/// Provides access to global session state for the current session. This state is serialized by
/// <see cref="SaveAsync"/> and restored by <see cref="RestoreAsync"/> which require values to be
/// one of the following: boxed values including integers, floating-point singles and doubles,
/// wide characters, boolean, Strings and Guids, or Map<String^, Object^> where map values are
/// subject to the same constraints. Session state should be as compact as possible.
/// </summary>
IMap<String^, Object^>^ SuspensionManager::SessionState::get(void)
{
return _sessionState;
}
/// <summary>
/// Wrap a WeakReference as a reference object for use in a collection.
/// </summary>
private ref class WeakFrame sealed
{
private:
WeakReference _frameReference;
internal:
WeakFrame(Frame^ frame) { _frameReference = frame; }
property Frame^ ResolvedFrame
{
Frame^ get(void) { return _frameReference.Resolve<Frame>(); }
};
};
namespace
{
std::vector<WeakFrame^> _registeredFrames;
DependencyProperty^ FrameSessionStateKeyProperty =
DependencyProperty::RegisterAttached("_FrameSessionStateKeyProperty",
TypeName(String::typeid), TypeName(SuspensionManager::typeid), nullptr);
DependencyProperty^ FrameSessionStateProperty =
DependencyProperty::RegisterAttached("_FrameSessionStateProperty",
TypeName(IMap<String^, Object^>::typeid), TypeName(SuspensionManager::typeid), nullptr);
}
/// <summary>
/// Registers a <see cref="Frame"/> instance to allow its navigation history to be saved to
/// and restored from <see cref="SessionState"/>. Frames should be registered once
/// immediately after creation if they will participate in session state management. Upon
/// registration if state has already been restored for the specified key
/// the navigation history will immediately be restored. Subsequent invocations of
/// <see cref="RestoreAsync(String)"/> will also restore navigation history.
/// </summary>
/// <param name="frame">An instance whose navigation history should be managed by
/// <see cref="SuspensionManager"/></param>
/// <param name="sessionStateKey">A unique key into <see cref="SessionState"/> used to
/// store navigation-related information.</param>
void SuspensionManager::RegisterFrame(Frame^ frame, String^ sessionStateKey)
{
if (frame->GetValue(FrameSessionStateKeyProperty) != nullptr)
{
throw ref new FailureException("Frames can only be registered to one session state key");
}
if (frame->GetValue(FrameSessionStateProperty) != nullptr)
{
throw ref new FailureException("Frames must be either be registered before accessing frame session state, or not registered at all");
}
// Use a dependency property to associate the session key with a frame, and keep a list of frames whose
// navigation state should be managed
frame->SetValue(FrameSessionStateKeyProperty, sessionStateKey);
_registeredFrames.insert(_registeredFrames.begin(), ref new WeakFrame(frame));
// Check to see if navigation state can be restored
RestoreFrameNavigationState(frame);
}
/// <summary>
/// Disassociates a <see cref="Frame"/> previously registered by <see cref="RegisterFrame"/>
/// from <see cref="SessionState"/>. Any navigation state previously captured will be
/// removed.
/// </summary>
/// <param name="frame">An instance whose navigation history should no longer be
/// managed.</param>
void SuspensionManager::UnregisterFrame(Frame^ frame)
{
// Remove session state and remove the frame from the list of frames whose navigation
// state will be saved (along with any weak references that are no longer reachable)
auto key = safe_cast<String^>(frame->GetValue(FrameSessionStateKeyProperty));
if (SessionState->HasKey(key)) SessionState->Remove(key);
_registeredFrames.erase(
std::remove_if(_registeredFrames.begin(), _registeredFrames.end(), [=](WeakFrame^& e)
{
auto testFrame = e->ResolvedFrame;
return testFrame == nullptr || testFrame == frame;
}),
_registeredFrames.end()
);
}
/// <summary>
/// Provides storage for session state associated with the specified <see cref="Frame"/>.
/// Frames that have been previously registered with <see cref="RegisterFrame"/> have
/// their session state saved and restored automatically as a part of the global
/// <see cref="SessionState"/>. Frames that are not registered have transient state
/// that can still be useful when restoring pages that have been discarded from the
/// navigation cache.
/// </summary>
/// <remarks>Apps may choose to rely on <see cref="LayoutAwarePage"/> to manage
/// page-specific state instead of working with frame session state directly.</remarks>
/// <param name="frame">The instance for which session state is desired.</param>
/// <returns>A collection of state subject to the same serialization mechanism as
/// <see cref="SessionState"/>.</returns>
IMap<String^, Object^>^ SuspensionManager::SessionStateForFrame(Frame^ frame)
{
auto frameState = safe_cast<IMap<String^, Object^>^>(frame->GetValue(FrameSessionStateProperty));
if (frameState == nullptr)
{
auto frameSessionKey = safe_cast<String^>(frame->GetValue(FrameSessionStateKeyProperty));
if (frameSessionKey != nullptr)
{
// Registered frames reflect the corresponding session state
if (!_sessionState->HasKey(frameSessionKey))
{
_sessionState->Insert(frameSessionKey, ref new Map<String^, Object^>());
}
frameState = safe_cast<IMap<String^, Object^>^>(_sessionState->Lookup(frameSessionKey));
}
else
{
// Frames that aren't registered have transient state
frameState = ref new Map<String^, Object^>();
}
frame->SetValue(FrameSessionStateProperty, frameState);
}
return frameState;
}
void SuspensionManager::RestoreFrameNavigationState(Frame^ frame)
{
auto frameState = SessionStateForFrame(frame);
if (frameState->HasKey("Navigation"))
{
frame->SetNavigationState(safe_cast<String^>(frameState->Lookup("Navigation")));
}
}
void SuspensionManager::SaveFrameNavigationState(Frame^ frame)
{
auto frameState = SessionStateForFrame(frame);
frameState->Insert("Navigation", frame->GetNavigationState());
}
/// <summary>
/// Save the current <see cref="SessionState"/>. Any <see cref="Frame"/> instances
/// registered with <see cref="RegisterFrame"/> will also preserve their current
/// navigation stack, which in turn gives their active <see cref="Page"/> an opportunity
/// to save its state.
/// </summary>
/// <returns>An asynchronous task that reflects when session state has been saved.</returns>
task<void> SuspensionManager::SaveAsync(void)
{
// Save the navigation state for all registered frames
for (auto&& weakFrame : _registeredFrames)
{
auto frame = weakFrame->ResolvedFrame;
if (frame != nullptr) SaveFrameNavigationState(frame);
}
// Serialize the session state synchronously to avoid asynchronous access to shared
// state
auto sessionData = ref new InMemoryRandomAccessStream();
auto sessionDataWriter = ref new DataWriter(sessionData->GetOutputStreamAt(0));
WriteObject(sessionDataWriter, _sessionState);
// Once session state has been captured synchronously, begin the asynchronous process
// of writing the result to disk
return task<unsigned int>(sessionDataWriter->StoreAsync()).then([=](unsigned int)
{
return sessionDataWriter->FlushAsync();
}).then([=](bool flushSucceeded)
{
(void)flushSucceeded; // Unused parameter
return ApplicationData::Current->LocalFolder->CreateFileAsync(sessionStateFilename,
CreationCollisionOption::ReplaceExisting);
}).then([=](StorageFile^ createdFile)
{
return createdFile->OpenAsync(FileAccessMode::ReadWrite);
}).then([=](IRandomAccessStream^ newStream)
{
return RandomAccessStream::CopyAndCloseAsync(
sessionData->GetInputStreamAt(0), newStream->GetOutputStreamAt(0));
}).then([=](UINT64 copiedBytes)
{
(void)copiedBytes; // Unused parameter
return;
});
}
/// <summary>
/// Restores previously saved <see cref="SessionState"/>. Any <see cref="Frame"/> instances
/// registered with <see cref="RegisterFrame"/> will also restore their prior navigation
/// state, which in turn gives their active <see cref="Page"/> an opportunity restore its
/// state.
/// </summary>
/// <param name="version">A version identifer compared to the session state to prevent
/// incompatible versions of session state from reaching app code. Saved state with a
/// different version will be ignored, resulting in an empty <see cref="SessionState"/>
/// dictionary.</param>
/// <returns>An asynchronous task that reflects when session state has been read. The
/// content of <see cref="SessionState"/> should not be relied upon until this task
/// completes.</returns>
task<void> SuspensionManager::RestoreAsync(void)
{
_sessionState->Clear();
task<StorageFile^> getFileTask(ApplicationData::Current->LocalFolder->GetFileAsync(sessionStateFilename));
return getFileTask.then([=](StorageFile^ stateFile)
{
task<BasicProperties^> getBasicPropertiesTask(stateFile->GetBasicPropertiesAsync());
return getBasicPropertiesTask.then([=](BasicProperties^ stateFileProperties)
{
auto size = unsigned int(stateFileProperties->Size);
if (size != stateFileProperties->Size) throw ref new FailureException("Session state larger than 4GB");
task<IRandomAccessStreamWithContentType^> openReadTask(stateFile->OpenReadAsync());
return openReadTask.then([=](IRandomAccessStreamWithContentType^ stateFileStream)
{
auto stateReader = ref new DataReader(stateFileStream);
return task<unsigned int>(stateReader->LoadAsync(size)).then([=](unsigned int bytesRead)
{
(void)bytesRead; // Unused parameter
// Deserialize the Session State
Object^ content = ReadObject(stateReader);
_sessionState = (Map<String^, Object^>^)content;
// Restore any registered frames to their saved state
for (auto&& weakFrame : _registeredFrames)
{
auto frame = weakFrame->ResolvedFrame;
if (frame != nullptr)
{
frame->ClearValue(FrameSessionStateProperty);
RestoreFrameNavigationState(frame);
}
}
}, task_continuation_context::use_current());
});
});
});
}
#pragma region Object serialization for a known set of types
namespace
{
// Codes used for identifying serialized types
enum StreamTypes {
NullPtrType = 0,
// Supported IPropertyValue types
UInt8Type, UInt16Type, UInt32Type, UInt64Type, Int16Type, Int32Type, Int64Type,
SingleType, DoubleType, BooleanType, Char16Type, GuidType, StringType,
// Additional supported types
StringToObjectMapType,
// Marker values used to ensure stream integrity
MapEndMarker
};
void WriteString(DataWriter^ writer, String^ string)
{
writer->WriteByte(StringType);
writer->WriteUInt32(writer->MeasureString(string));
writer->WriteString(string);
}
void WriteProperty(DataWriter^ writer, IPropertyValue^ propertyValue)
{
switch (propertyValue->Type)
{
case PropertyType::UInt8:
writer->WriteByte(UInt8Type);
writer->WriteByte(propertyValue->GetUInt8());
return;
case PropertyType::UInt16:
writer->WriteByte(UInt16Type);
writer->WriteUInt16(propertyValue->GetUInt16());
return;
case PropertyType::UInt32:
writer->WriteByte(UInt32Type);
writer->WriteUInt32(propertyValue->GetUInt32());
return;
case PropertyType::UInt64:
writer->WriteByte(UInt64Type);
writer->WriteUInt64(propertyValue->GetUInt64());
return;
case PropertyType::Int16:
writer->WriteByte(Int16Type);
writer->WriteUInt16(propertyValue->GetInt16());
return;
case PropertyType::Int32:
writer->WriteByte(Int32Type);
writer->WriteUInt32(propertyValue->GetInt32());
return;
case PropertyType::Int64:
writer->WriteByte(Int64Type);
writer->WriteUInt64(propertyValue->GetInt64());
return;
case PropertyType::Single:
writer->WriteByte(SingleType);
writer->WriteSingle(propertyValue->GetSingle());
return;
case PropertyType::Double:
writer->WriteByte(DoubleType);
writer->WriteDouble(propertyValue->GetDouble());
return;
case PropertyType::Boolean:
writer->WriteByte(BooleanType);
writer->WriteBoolean(propertyValue->GetBoolean());
return;
case PropertyType::Char16:
writer->WriteByte(Char16Type);
writer->WriteUInt16(propertyValue->GetChar16());
return;
case PropertyType::Guid:
writer->WriteByte(GuidType);
writer->WriteGuid(propertyValue->GetGuid());
return;
case PropertyType::String:
WriteString(writer, propertyValue->GetString());
return;
default:
throw ref new InvalidArgumentException("Unsupported property type");
}
}
void WriteStringToObjectMap(DataWriter^ writer, IMap<String^, Object^>^ map)
{
writer->WriteByte(StringToObjectMapType);
writer->WriteUInt32(map->Size);
for (auto&& pair : map)
{
WriteObject(writer, pair->Key);
WriteObject(writer, pair->Value);
}
writer->WriteByte(MapEndMarker);
}
void WriteObject(DataWriter^ writer, Object^ object)
{
if (object == nullptr)
{
writer->WriteByte(NullPtrType);
return;
}
auto propertyObject = dynamic_cast<IPropertyValue^>(object);
if (propertyObject != nullptr)
{
WriteProperty(writer, propertyObject);
return;
}
auto mapObject = dynamic_cast<IMap<String^, Object^>^>(object);
if (mapObject != nullptr)
{
WriteStringToObjectMap(writer, mapObject);
return;
}
throw ref new InvalidArgumentException("Unsupported data type");
}
String^ ReadString(DataReader^ reader)
{
int length = reader->ReadUInt32();
String^ string = reader->ReadString(length);
return string;
}
IMap<String^, Object^>^ ReadStringToObjectMap(DataReader^ reader)
{
auto map = ref new Map<String^, Object^>();
auto size = reader->ReadUInt32();
for (unsigned int index = 0; index < size; index++)
{
auto key = safe_cast<String^>(ReadObject(reader));
auto value = ReadObject(reader);
map->Insert(key, value);
}
if (reader->ReadByte() != MapEndMarker)
{
throw ref new InvalidArgumentException("Invalid stream");
}
return map;
}
Object^ ReadObject(DataReader^ reader)
{
auto type = reader->ReadByte();
switch (type)
{
case NullPtrType:
return nullptr;
case UInt8Type:
return reader->ReadByte();
case UInt16Type:
return reader->ReadUInt16();
case UInt32Type:
return reader->ReadUInt32();
case UInt64Type:
return reader->ReadUInt64();
case Int16Type:
return reader->ReadInt16();
case Int32Type:
return reader->ReadInt32();
case Int64Type:
return reader->ReadInt64();
case SingleType:
return reader->ReadSingle();
case DoubleType:
return reader->ReadDouble();
case BooleanType:
return reader->ReadBoolean();
case Char16Type:
return (char16_t)reader->ReadUInt16();
case GuidType:
return reader->ReadGuid();
case StringType:
return ReadString(reader);
case StringToObjectMapType:
return ReadStringToObjectMap(reader);
default:
throw ref new InvalidArgumentException("Unsupported property type");
}
}
}
#pragma endregion

@ -0,0 +1,50 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// SuspensionManager.h
// Declaration of the SuspensionManager class
//
#pragma once
#include <ppltasks.h>
namespace SDKSample
{
namespace Common
{
/// <summary>
/// SuspensionManager captures global session state to simplify process lifetime management
/// for an application. Note that session state will be automatically cleared under a variety
/// of conditions and should only be used to store information that would be convenient to
/// carry across sessions, but that should be disacarded when an application crashes or is
/// upgraded.
/// </summary>
ref class SuspensionManager sealed
{
internal:
static void RegisterFrame(Windows::UI::Xaml::Controls::Frame^ frame, Platform::String^ sessionStateKey);
static void UnregisterFrame(Windows::UI::Xaml::Controls::Frame^ frame);
static Concurrency::task<void> SaveAsync(void);
static Concurrency::task<void> RestoreAsync(void);
static property Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ SessionState
{
Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ get(void);
};
static Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ SessionStateForFrame(
Windows::UI::Xaml::Controls::Frame^ frame);
private:
static void RestoreFrameNavigationState(Windows::UI::Xaml::Controls::Frame^ frame);
static void SaveFrameNavigationState(Windows::UI::Xaml::Controls::Frame^ frame);
};
}
}

@ -0,0 +1,16 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// pch.cpp
// Include the standard header and generate the precompiled header.
//
#include "pch.h"

@ -0,0 +1,23 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// pch.h
// Header for standard system include files.
//
#pragma once
#include <collection.h>
#include <ppltasks.h>
#include <agile.h>
#include "Common\LayoutAwarePage.h"
#include "Common\SuspensionManager.h"
#include "App.xaml.h"

@ -0,0 +1,51 @@
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="TitleTextStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI Light" />
<Setter Property="FontSize" Value="16" />
</Style>
<Style x:Key="HeaderTextStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI Semilight" />
<Setter Property="FontSize" Value="26.667" />
<Setter Property="Margin" Value="0,0,0,25" />
</Style>
<Style x:Key="H2Style" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="14.667" />
<Setter Property="Margin" Value="0,0,0,0" />
</Style>
<Style x:Key="SubheaderTextStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI Semilight" />
<Setter Property="FontSize" Value="14.667" />
<Setter Property="Margin" Value="0,0,0,5" />
</Style>
<Style x:Key="BasicTextStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI Light" />
<Setter Property="FontSize" Value="16" />
</Style>
<Style x:Key="SeparatorStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="9" />
</Style>
<Style x:Key="FooterStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Margin" Value="0,8,0,0" />
</Style>
<Style x:Key="HyperlinkStyle" TargetType="HyperlinkButton">
<Setter Property="Padding" Value="5"/>
</Style>
</ResourceDictionary>

@ -0,0 +1,238 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><link rel="stylesheet" type="text/css" href="description/Combined.css,0:SearchBox,0:ImageSprite;/Areas/Epx/Themes/Metro/Content:0&amp;amp;hashKey=E778FABBB649835AFE4E73BCAC4F643A" xmlns="http://www.w3.org/1999/xhtml" />
<link rel="stylesheet" type="text/css" href="description/4ee0dda0-3e7e-46df-b80b-1692acc1c812Combined.css,0:ImageSprite;/Areas/Epx/Themes/Metro/Content:0&amp;amp;hashKey=B88AD897C8197B762EA1BF0238A60A9F" xmlns="http://www.w3.org/1999/xhtml" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Media capture using capture device sample</title>
<link href="description/Galleries.css" type="text/css" rel="Stylesheet" /><link href="description/Layout.css" type="text/css" rel="Stylesheet" /><link href="description/Brand.css" type="text/css" rel="Stylesheet" /><link href="description/c2e69f54-1c43-4037-b90b-5f775f1d945fBrand.css" type="text/css" rel="Stylesheet" />
<link href="description/iframedescription.css" rel="Stylesheet" type="text/css" />
<script src="description/offline.js" type="text/javascript"></script>
<style type="text/css">
#projectInfo {
overflow: auto;
}
#longDesc {
clear:both;
margin: 25px 0 10px 0;
}
#SampleIndexList{
margin-left: 15px;
}
</style>
</head>
<body>
<div id="offlineDescription">
<h1>Media capture using capture device sample</h1>
<br/>
<div id="projectInfo">
<div class="section">
<div class="itemBarLong tagsContainer">
<label for="Technologies">Technologies</label>
<div id="Technologies">
Windows Runtime
</div>
</div>
<div class="itemBarLong tagsContainer">
<label for="Topics">Topics</label>
<div id="Topics">
Devices and sensors
</div>
</div>
<div class="itemBarLong">
<label for="Platforms">Platforms</label>
<div id="Platforms">
Windows RT
</div>
</div>
<div class="itemBarLong">
<label for="Requirements">Requirements</label>
<div id="Requirements">
</div>
</div>
<div class="itemBar">
<label for="LastUpdated">Primary Language</label>
<div id="LastUpdated">en-US</div>
</div>
<div class="itemBar">
<label for="LastUpdated">Last Updated</label>
<div id="LastUpdated">4/9/2013</div>
</div>
<div class="itemBarLong">
<label for="License">License</label>
<div id="License">
<a href="license.rtf">MS-LPL</a></div>
</div>
<div class="itemBar">
<div class="viewonlinecont">
<a data-link="online" href="http://code.msdn.microsoft.com/windowsapps/Media-Capture-Sample-adf87622">View this sample online</a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function initializePage() {
var otherTabClass = 'otherTab';
var hiddenPreClass = 'hidden';
var htmlDecode = function(encodedData) {
var decodedData = "";
if (encodedData) {
var div = document.createElement('div');
div.innerHTML = encodedData;
decodedData = div.firstChild.nodeValue.replace( /\\r\\n/ig , '\r\n');
}
return decodedData;
};
Galleries.iterateElem(Galleries.findElem(null, 'div', 'scriptcode'), function (index, scriptBlock) {
var titleElem = Galleries.findElem(scriptBlock, 'div', 'title')[0];
var labelElems = Galleries.findElem(titleElem, 'span');
if (labelElems.length == 0) {
labelElems = titleElem;
}
var languageSpans = Galleries.findElem(scriptBlock, 'span', 'hidden');
var pres = Galleries.findElem(scriptBlock, 'pre');
if (languageSpans.length > 0 && pres.length > 1) {
Galleries.iterateElem(labelElems, function(index, elem) {
var codePre = pres[index];
var labelSpan = elem;
var languageSpan = languageSpans[index];
elem.code = codePre.innerHTML.replace( /(\r(\n)?)|((\r)?\n)/ig , '\\r\\n');
codePre.className = codePre.className.replace(hiddenPreClass, '');
languageSpan.parentNode.removeChild(languageSpan);
});
pres = Galleries.findElem(scriptBlock, 'pre');
Galleries.iterateElem(labelElems, function(index, elem) {
var codePre = pres[index];
var labelSpan = elem;
if (index == 0) {
scriptBlock.activeTab = 0;
}
else {
labelSpan.className += otherTabClass;
codePre.className += hiddenPreClass;
}
Galleries.attachEventHandler(labelSpan, 'click', function(e) {
var activeTab = scriptBlock.activeTab;
labelElems[activeTab].className += otherTabClass;
pres[activeTab].className += hiddenPreClass;
codePre.className = codePre.className.replace(hiddenPreClass, '');
labelSpan.className = labelSpan.className.replace(otherTabClass, '');
scriptBlock.activeTab = index;
});
});
var preview = Galleries.findElem(scriptBlock, 'div', 'preview');
if (preview.length == 0) {
preview.push(pres[pres.length - 1]);
}
Galleries.iterateElem(preview, function(index, elem) {
elem.parentNode.removeChild(elem);
});
if (window.clipboardData && clipboardData.setData) {
var copyLink = document.createElement('a');
copyLink.href = 'javascript:void(0);';
copyLink.className = 'copyCode';
copyLink.innerHTML = 'Copy Code';
Galleries.attachEventHandler(copyLink, 'click', function (e) {
clipboardData.setData("Text", htmlDecode(labelElems[scriptBlock.activeTab].code));
return false;
});
scriptBlock.insertBefore(copyLink, scriptBlock.childNodes[0]);
}
}
});
}
Galleries.onWindowLoad(function(){
initializePage();
});
</script>
<div id="longDesc">
<div id="mainSection">
<p>This sample demonstrates how to use the <a href="http://msdn.microsoft.com/library/windows/apps/BR241124">
<b>MediaCapture</b> </a>API to capture video, audio, and pictures from a capture device, such as a webcam.
</p>
<p>Specifically, this sample covers: </p>
<ul>
<li>Previewing video from a capture device, such as a webcam, connected to the computer.
</li><li>Capturing video from a capture device, such as a webcam, connected to the computer.
</li><li>Taking a picture from a capture device, such as a webcam, connected to the computer.
</li><li>Enumerating cameras connected to the computer. </li><li>Adding a video effect to a video. </li><li>Recording audio from a capture device connected to the computer. </li></ul>
<p></p>
<p>For more information on capturing video in your app, see <a href="http://msdn.microsoft.com/library/windows/apps/Hh465152">
Quickstart: capturing a photo or video using the camera dialog</a> and <a href="http://msdn.microsoft.com/library/windows/apps/Hh452791">
Quickstart: capturing video using the MediaCapture API</a>.</p>
<p class="note"><b>Important</b>&nbsp;&nbsp; </p>
<p class="note">This sample uses the Media Extension feature of Windows&nbsp;8 to add functionality to the Microsoft Media Foundation pipeline. A Media Extension consists of a hybrid object that implements both Component Object Model (COM) and Windows Runtime
interfaces. The COM interfaces interact with the Media Foundation pipeline. The Windows Runtime interfaces activate the component and interact with the Windows Store app.
</p>
<p class="note">In most situations, it is recommended that you use Visual C&#43;&#43; with Component Extensions (C&#43;&#43;/CX ) to interact with the Windows Runtime. But in the case of hybrid components that implement both COM and Windows Runtime interfaces, such as Media
Extensions, this is not possible. C&#43;&#43;/CX can only create Windows Runtime objects. So, for hybrid objects it is recommended that you use
<a href="http://go.microsoft.com/fwlink/p/?linkid=243149">Windows Runtime C&#43;&#43; Template Library</a> to interact with the Windows Runtime. Be aware that Windows Runtime C&#43;&#43; Template Library has limited support for implementing COM interfaces.</p>
<p></p>
<p>To obtain an evaluation copy of Windows&nbsp;8, go to <a href="http://go.microsoft.com/fwlink/p/?linkid=241655">
Windows&nbsp;8</a>.</p>
<p>To obtain an evaluation copy of Microsoft Visual Studio&nbsp;2012, go to <a href="http://go.microsoft.com/fwlink/p/?linkid=241656">
Visual Studio&nbsp;2012</a>.</p>
<h3><a id="related_topics"></a>Related topics</h3>
<dl><dt><a href="http://go.microsoft.com/fwlink/p/?LinkID=227694">Windows 8 app samples</a>
</dt><dt><b>Roadmaps</b> </dt><dt><a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh465134">Adding multimedia</a>
</dt><dt><a href="http://msdn.microsoft.com/library/windows/apps/Hh465156">Capturing or rendering audio, video, and images</a>
</dt><dt><a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh767284">Designing UX for apps</a>
</dt><dt><a href="http://msdn.microsoft.com/library/windows/apps/BR229583">Roadmap for apps using C# and Visual Basic</a>
</dt><dt><a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh700360">Roadmap for apps using C&#43;&#43;</a>
</dt><dt><a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh465037">Roadmap for apps using JavaScript</a>
</dt><dt><b>Tasks</b> </dt><dt><a href="http://msdn.microsoft.com/library/windows/apps/Hh465152">Quickstart: capturing a photo or video using the camera dialog</a>
</dt><dt><a href="http://msdn.microsoft.com/library/windows/apps/Hh452791">Quickstart: capturing video using the MediaCapture API</a>
</dt><dt><b>Reference</b> </dt><dt><a href="http://msdn.microsoft.com/en-us/library/windows/apps/BR211961"><b>AddEffectAsync</b>
</a></dt><dt><a href="http://msdn.microsoft.com/en-us/library/windows/apps/BR226592"><b>ClearEffectsAsync</b>
</a></dt><dt><a href="http://msdn.microsoft.com/library/windows/apps/BR241124"><b>MediaCapture</b>
</a></dt><dt><a href="http://msdn.microsoft.com/en-us/library/windows/apps/BR226581"><b>MediaCaptureSettings</b>
</a></dt><dt><a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh701026"><b>MediaEncodingProfile</b>
</a></dt><dt><a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh700863"><b>StartRecordToStorageFileAsync</b>
</a></dt><dt><b>Windows.Media.Capture</b> </dt></dl>
<h3>Operating system requirements</h3>
<table>
<tbody>
<tr>
<th>Client</th>
<td><dt>Windows&nbsp;8 </dt></td>
</tr>
<tr>
<th>Server</th>
<td><dt>Windows Server&nbsp;2012 </dt></td>
</tr>
</tbody>
</table>
<h3>Build the sample</h3>
<p></p>
<ol>
<li>Start Visual Studio Express&nbsp;2012 for Windows&nbsp;8 and select <b>File</b> &gt; <b>
Open</b> &gt; <b>Project/Solution</b>. </li><li>Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio Express&nbsp;2012 for Windows&nbsp;8 Solution (.sln) file.
</li><li>Press F7 or use <b>Build</b> &gt; <b>Build Solution</b> to build the sample. </li></ol>
<p></p>
<h3>Run the sample</h3>
<p>To debug the app and then run it, press F5 or use <b>Debug</b> &gt; <b>Start Debugging</b>. To run the app without debugging, press Ctrl&#43;F5 or use
<b>Debug</b> &gt; <b>Start Without Debugging</b>.</p>
</div>
</div>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,418 @@
/* ***************************************************
Galleries.css - Common Structure
This is where we define common layout for structures that are truly close to common across the different
Galleries sites. To make sure this works we need to follow certain conventions.
1. Define each logical structure in its own section with its own comment block that gives the section
a Name, Description and defines the root element if one exists (i.e #someElement). Also, mark the closing block.
2. Indent styles in a section to represent if it is a child of a previous element.
i.e. #someDiv{
}
#someDiv ul {
}
3. Do not include brand specific information here like colors and fonts unless they are *really* common.
4. If there is an element that you know will be overridden in each brand stylesheet still include it here with an empty definition.
This will aid in knowing what section to override and what selectors to use.
i.e. #someSction a {
}
5. When you add a new section also update the Table of Contents below so that we have a quick overview of the sections
*****************************************************/
/****************************************************
Table of Contents
Global - global classes
FileAttachmentDisplay - The list of attached files under the editor
Eyebrow - The breadcrumb control at the top of the master page
Pager - The common paging control, used for browsing pages of search results
Profile User Card - Elements in the profile usercard control
SideNav - The navigation side bar that contains the search filters
*****************************************************/
/********************************
Name: Global
Root: none
Description: truly global classes
********************************/
body {
text-align: left;
direction: ltr;
}
img.rss {
background: url(../../../GlobalResources/Images/Rss.png) no-repeat;
background-position: 0px 0px;
height: 17px;
width: 17px;
}
/* End Global Section */
/********************************
Name: FileAttachmentDisplay
Root: #fileAttachmentDisplay
Description: The list of attached files under the editor
********************************/
#fileAttachmentDisplay {
}
#fileAttachmentDisplay .attachment {
margin-right: 10px;
float: left;
}
#fileAttachmentDisplay .attachment .displayAttachment {
padding: 0px 0 13px 0;
float: left;
}
#fileAttachmentDisplay .attachment .removeAttachment {
background-image: url('/Content/Common/delete.png');
display: block;
width: 16px;
height: 16px;
float: left;
}
/* End FileAttachmentDisplay Section */
/********************************
Name: Eyebrow
Root: .EyebrowContainer
Description: The breadcrumb control at the top of the master page
********************************/
.EyebrowContainer {
}
.EyebrowContainer div.EyebrowElement{
display:inline;
}
.EyebrowContainer .EyebrowElement{
font-weight:normal
}
.EyebrowContainer .EyebrowLeafLink{
color:#000;
}
/* End Eyebrow Section */
/********************************
Name: Pager
Root: #Pager
Description: The common paging control, used for browsing pages of search results
********************************/
#Pager {
}
#Pager div{
display:inline;
}
/* End Pager Section */
/********************************
Name: Profile User Card
Root: #dashboardPage #userCard
Description: Elements in the profile usercard control
********************************/
#dashboardPage #userCard .profile-usercard-inline {
margin: 5px 0 10px 0;
}
/* #dashboardPage #userCard .profile-usercard {
width: 288px;
}
/* End Profile User Card Section */
/********************************
Name: Discussion
Root: #DiscussionsTabPane
Description: Defines the layout of the dicussion
********************************/
#DiscussionsTabPane {
}
#DiscussionsTabPane .itemHidden
{
background: lightgrey;
}
#discussionListItem {
}
.discussion .postActions
{
float: right;
}
#discussionListItem .postItem
{
white-space: pre-wrap;
word-wrap: break-word;
font-size:1em;
}
/* End Discussion Section */
/********************************
Name: SearchDefaultLocale
Root: .searchDefaultLocale
Description: Defines the layout of the include english result checkbox on the Browse Page
********************************/
.searchDefaultLocale
{
float: right;
margin: 20px 0 0 5px;
}
.searchDefaultLocale input
{
vertical-align:top;
}
.searchDefaultLocale span
{
margin-left: -3px;
}
/*-------- End SearchDefaultLocale --------*/
/********************************
Name: SideNav
Root: #sideNav
Description: Defines the layout of the naviation elements on the side of the Browse Page
These represent the different filters like Code Language, Category and Tag
********************************/
#sideNav {
width: 250px;
vertical-align:top;
background-color:#eee;
}
#sideNav h3 {
}
#sideNav .section {
padding: 0 0 10px 0;
position: relative;
}
#sideNav .section a {
}
#sideNav .section a:hover {
}
#sideNav .section > div {
padding:5px 5px 5px 0;
line-height:150%;
}
#sideNav .section ul {
list-style-type:none;
padding:0px;
margin:0px;
}
#sideNav .section ul li {
position: relative;
padding: 5px 5px 5px 0;
}
#sideNav .section ul li .selectedFilter {
float: left;
padding-right: 5px;
}
#sideNav .section div.itemCount {
float: right;
}
#sideNav .section form input[ type = "checkbox"] {
margin: 0px 4px 0px 0px;
vertical-align: middle;
}
/* End SideNav Section */
/*----------- Contribution Logos *******/
.contributionLogo {
float: left;
position: relative;
margin-right: 6px;
}
.logo_visualstudio {
background: transparent url('../common/logos/visualstudio.png') no-repeat;
width: 23px;
height: 12px;
margin-top: 3px;
}
.logo_allinonecode {
background: transparent url('../common/logos/1code.png') no-repeat;
width: 14px;
height: 16px;
}
.logo_exchange {
background: transparent url('../common/logos/exchange.png') no-repeat;
width: 14px;
height: 16px;
}
.logo_ie {
background: transparent url('../common/logos/ie.png') no-repeat;
width: 16px;
height: 16px;
}
.logo_office {
background: transparent url('../common/logos/office.png') no-repeat;
width: 17px;
height: 16px;
}
.logo_windows {
background: transparent url('../common/logos/windows.png') no-repeat;
width: 17px;
height: 16px;
}
.logo_azure {
background: transparent url('../common/logos/windowsazuredark.png') no-repeat;
width: 16px;
height: 16px;
}
.logo_windowsphone {
background: transparent url('../common/logos/windowsphone.png') no-repeat;
width: 16px;
height: 16px;
}
.contributionLogoTip {
position: absolute;
display: none;
border: solid 1px #CCC;
color: #333;
background-color: #F0F0F0;
font-size: 11px;
font-family: "Segoe UI",Sans-Serif;
box-shadow: 3px 3px 5px #888;
-moz-box-shadow: 3px 3px 5px #888;
z-index: 1003;
padding: 5px;
min-width: 250px;
}
/*----------- End Contribution Logos *******/
.clear
{
clear: both;
}
.customcontributionLogoTip {
position: absolute;
display: none;
border: solid 1px #CCC;
background-color: white;
color: #333;
font-size: 11px;
font-family: "Segoe UI",Sans-Serif;
box-shadow: 3px 3px 5px #888;
-moz-box-shadow: 3px 3px 5px #888;
z-index: 1004;
padding: 5px;
min-width: 250px;
}
.customcontributionTittle {
font-size: 14px;
margin-left: 90px;
}
.customcontributionDiscription {
font-size: 13px;
margin: 10px 5px;
text-align: justify;
}
.customcontribution {
float: left;
position: relative;
margin-right: 6px;
}
.customcontributionLink {
margin-left: 5px;
}
.customcontributionlogo {
float: left;
padding: 0 10px;
margin: 0;
width: 70px;
height: 70px;
background-repeat: no-repeat;
}
.logo_azure_large {
background-image: url('../common/logos/windowsazure_large.png');
}
.logo_visualstudio_large {
background-image: url('../common/logos/visualstudio_large.png');
}
.logo_exchange_large {
background-image: url('../common/logos/exchange_large.png');
}
.logo_ie_large {
background-image: url('../common/logos/ie_large.png');
}
.logo_office_large {
background-image: url('../common/logos/office_large.png');
}
.logo_windows_large {
background-image: url('../common/logos/windows_large.png');
}
.logo_windowsphone_large {
background-image: url('../common/logos/windowsphone_large.png');
}
/* Custome Header */
.dirSubHeading .windowssdk .container
{
background: #FF3300 url('wpappsbackground.png') no-repeat;
color: white;
padding: 8px 10px 18px 170px;
}
.dirSubHeading .windowssdk .container h1, .dirSubHeading .windowssdk .container h2 {
color: white !important;
}
.dirSubHeading .windowssdk .container p {
margin: 20px 0 0 0 !important;
}
.dirSubHeading .windowssdk .container a {
background-color:#ffd800;
color: #2a2a2a !important;
cursor:pointer;
font-size:13px;
font-family:'Segoe UI Semibold','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;
padding:4px 12px 6px;
}

@ -0,0 +1,147 @@
#container {
min-height: 768px;
}
#leftSubHeaderContainer
{
margin-top:20px;
}
#title h1
{
font-size:25px;
}
#subtitle h2
{
font-size:15px;
}
#subtitle
{
margin-left:10px;
}
#formContainer
{
margin-left:10px;
margin-top:30px;
}
.formLabel
{
float:left;
width: 250px;
}
.formRow
{
clear:both;
padding: 10px 0 10px 10px;
}
.formRecaptchaRow
{
clear:both;
float:left;
margin-top:20px;
margin-left:10px;
margin-bottom:20px;
}
.formSubmitRow
{
clear:both;
margin-top:20px;
margin-left:300px;
margin-bottom:20px;
}
.formControl {
width:300px;
float:left;
}
.formControl .textInput
{
width:300px;
}
.formControl textarea
{
width:425px;
height:100px;
}
.formControl .tag
{
width:425px;
}
.formControl .richText
{
margin-top:10px;
width:500px;
height:440px;
}
.formWideLabel
{
width:500px;
}
.formBigLabel
{
margin-top:20px;
font-size:20px;
}
.formControlBelow
{
clear:both;
margin-top:10px;
width:500px;
}
.required
{
color: Red;
}
.helpText
{
color: #9D9D9D;
font-style: italic;
}
#agreementSummary
{
clear:both;
margin-top:10px;
width:800px;
}
.field-validation-error, .validation-summary-errors
{
color: #FF0000;
font-weight: bold;
}
.tinyMCETemplate {
position: relative;
left: 400px;
width: 300px;
max-height: 300px;
overflow: auto;
}
.IE6 .tinyMCETemplate {
left: 25px;
}
.ownerBar {
padding: 5px;
}
.ownerBar .ownerBarOptions {
float: right;
}

@ -0,0 +1,303 @@
/*Global*/
h1 {
font-size: 36px;
font-family: 'Segoe UI Light';
color: #707070;
font-weight: normal;
margin-bottom: 17px !important;
}
h2, h3, h4, h5, h6, #searchPage h3 {
font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important;
font-weight:normal;
color: #2A2A2A !important;
}
a, a:link, a:visited {
color: #0095c4;
}
body {
color:#707070;
}
.profile-usercard {
color:#707070 !important;
}
/*temporary setting to override msdn_windows.css
can remove once conflicting settings are removed from that file*/
.LocalNavigation, .LocalNavigation .TabOn, .LocalNavigation .TabOn:hover, .LocalNavigation .TabOff, .LocalNavigation .TabOff a:hover {
display: block;
background-color:transparent !important;
color: #0095c4;
}
.LocalNavigation .TabOff a {
color:#707070 ;
}
/*End Global*/
.EyebrowContainer
{
margin-bottom: 0 !important;
}
#sideNav
{
width: 215px !important;
}
#searchPage #mainContentContainer
{
margin-right:0 !important;
margin-left:243px !important;
}
#searchPage .dirSubHeading h2
{
font-size: 14px !important;
font-weight: normal !important;
color: #454545 !important;
line-height: 1.45;
}
#searchPage #directoryListFooter, #searchPage #Pager {
font-size: 14px;
}
#searchPage h2, #searchPage h3
{
font-size: 1.25em !important;
}
#sideNav #contributeSection h3, .sidebar #contributeSection h3, #contributeSection h3
{
font-size: 1.65em !important;
}
.subMenu > h2
{
font-family: 'Segoe UI Light','Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important;
font-weight:normal;
font-size:30px;
margin: 15px 10px 5px 0;
padding-bottom:0px;
}
.itemRow {
}
.itemRow .itemBody, .itemRow .itemInfo {
padding: 18px 17px 20px 0;
font-size: 14px;
line-height: 1.45em;
}
.itemRow .itemTitle {
font-weight: normal;
}
.itemRow .summaryBox{
color: #454545;
}
.Samples #MainContent .itemRow .itemTitle a {
font-weight: 600 !important;
line-height: 1.45;
}
#MainContent a.officialMicrosoftLabel
{
color: #ACACAC;
}
.tabContents {
border-top-width:0px;
}
#UploadPage {
margin: 0px 0px 0px 10px;
}
#UploadPage h1 {
padding: 0;
font-size: 22px;
}
#UploadPage h2 {
color:#F39700 !important;
}
#UploadPage #uploadPageInstruction {
margin-top:10px;
}
#UploadPage fieldset {
margin-left:0px;
}
#UploadPage fieldset h2 {
font-weight:normal;
}
#UploadPage fieldset#uploadsForm{
margin-top:25px;
}
#UploadPage fieldset#summary textarea {
margin-left:0px;
}
#UploadPage .projectTypeChoice > div {
height: 250px;
}
#sideNav {
}
#sideNav .section h3 {
background-color: transparent;
}
#sideNav .section UL LI {
border-bottom-width: 0px;
}
#sideNav .section form > div {
border-bottom: none;
color: #707070;
}
#sideNav .section ul li > div.itemCount
{
color: #707070;
}
#searchPage {
}
#searchPage h2, #searchPage h3 {
text-transform:none;
background-color:transparent;
font-weight:normal;
font-size:1.2em;
}
#searchPage .browseFilterBar {
background-color:transparent;
border-width:0px;
font-weight:normal;
}
#requestsPage {
padding-top:15px;
}
#requestsPage .tabHeaders {
overflow: visible;
}
#requestsPage #requestsList {
border: none;
}
#requestsPage h2, #requestsPage h3 {
text-transform:none;
background-color:transparent;
font-weight:normal;
font-size:1.2em;
}
.reqBrowseContent .title {
font-weight: bold !important;
color:#000 !important;
font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important;
}
.reqDescPage #header #votenumber {
height: 30px;
padding: 9px 12px 3px 12px;
}
#extraActions {
}
#extraActions .section
{
margin-bottom: 10px;
}
#extraActions .section a
{
font-weight:normal;
}
#extraActions #contributeSection div img {
width:0px;
}
#projectPage {
}
#projectPage .projectTitle {
color: #707070;
margin: 5px 0px 15px 0px;
}
#projectPage h2.projectSummary, #projectPage #projectInfo, #projectPage .tabHeaders {
font-size: 14px !important;
line-height: 1.45em;
color: #454545 !important;
font-weight: normal !important;
}
#projectPage #projectInfo a {
color: #00749e;
}
#projectPage #Downloads a, #projectPage #Downloads label {
font-size: 14px;
}
#projectPage #reportAbuse {
font-size: 1em;
}
#projectPage #publishBar a, #projectPage #publishBar a:visited {
color: #0095c4;
font-weight: normal;
}
#projectPage #Collections .bevelButton{
background-color: #F8F8F8;
color: #0095C4;
border: 1px solid #707070;
}
#projectPage #DiscussionsTabPane .threadHeader .title {
font-weight:bold !important;
color:Black !important;#F8F8F8;
font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important;
}
#projectPage .sidebar .section .titleBar h3 {
font-weight:normal;
font-size:1.2em;
}
#LocalNav {
}
#LocalNav.HeaderTabs {
margin-left:11px;
}
#searchPage .dirSubHeading h1
{
margin-bottom:17px !important;
}

@ -0,0 +1,179 @@
body {
color: #000000;
font-family: 'Segoe UI',Verdana,Arial;
font-size: 0.813em;
font-style: normal;
word-wrap: break-word;
}
/*BEGIN HEADERS*/
.h1, h1 {
color: #3A3E43;
font-family: 'Segoe UI',Verdana,Arial;
font-size: 1.4em;
font-weight: bold;
margin: 0;
}
.h2, h2 {
color: #3A3E43;
font-family: 'Segoe UI',Verdana,Arial;
font-size: 1.2em;
font-weight: bold;
}
.h3, h3 {
color: #3A3E43;
font-family: 'Segoe UI',Verdana,Arial;
font-size: 1.077em;
font-weight: bold;
}
.h4, h4 {
color: #3A3E43;
font-family: 'Segoe UI',Verdana,Arial;
font-size: 1em;
font-weight: bold;
}
h4.subHeading {
margin-bottom: 7px;
margin-top: 13px;
}
/*END HEADERS*/
/*BEGIN LINKS*/
a:link {
color: #00749E;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:visited {
color: #960BB4;
text-decoration: none;
}
a:focus {
outline: 1px dotted #000000;
}
a.libraryLink:link {
text-decoration:none;
border-bottom:1px dotted;
}
/*END LINKS*/
/*BEGIN IMAGES*/
img {
border: 0 none;
}
/*END IMAGES*/
/*BEGIN TABLE*/
.title table {
color: #000000;
font-family: 'Segoe UI',Verdana,Arial;
font-size: 1.077em;
font-style: normal;
}
table {
border-collapse: collapse;
}
table, table th, table td {
border:1px solid #BBBBBB;
}
/*END TABLE*/
/*BEGIN LIST*/
ul {
list-style-type: disc;
margin-left:40px;
padding-left: 0;
}
ul li {
padding-bottom: 10px;
}
ol {
margin-left:40px;
padding-left: 0;
}
ol li {
padding-bottom: 10px;
}
/*END LIST*/
.scriptcode {
position: relative;
padding: 8px 8px 8px 8px;
background: #FFFFFF;
font-size: 12px;
line-height: 125%;
font-weight:normal;
}
.scriptcode pre
{
white-space: pre-wrap !important; /* css-3 */
word-wrap: break-word !important; /* Internet Explorer 5.5+ */
margin:0 0 10px 0 !important;
padding: 10px;
border-top: solid 2px #D0D2D2;
border-bottom: solid 2px #D0D2D2;
border-left: solid 1px #D0D2D2;
border-right: solid 1px #D0D2D2;
}
.scriptcode .title {
color:#E66A38;
font-size: 12px;
font-weight:bold;
margin: 0;
min-height: 23px;
}
.scriptcode .title > span:first-child {
border-left: solid 1px #D0D2D2;
}
.scriptcode .title > span {
padding: 4px 8px 4px 8px;
display: inline-block;
border-top: 1px solid #D0D2D2;
border-right: 1px solid #D0D2D2;
border-collapse: collapse;
text-align: center;
background: white;
}
.scriptcode .title > span.otherTab {
color: #1364C4;
background: #EFF5FF;
cursor: pointer;
}
.scriptcode .hidden {
display: none !important;
visibility: hidden !important;
}
.scriptcode .copyCode {
padding: 8px 2px 0 2px !important;
margin-right: 15px;
position: absolute !important;
right: 0 !important;
top: 17px;
display:block !important;
background: #FFFFFF;
}
.scriptcode .pluginLinkHolder {
display: none;
}
.scriptcode .pluginEditHolderLink {
display: none;
}
.Opera wbr
{
display: inline-block;
}
.IE9 wbr:after
{
content: "\00200B";
}

@ -0,0 +1,52 @@
var Galleries = Galleries || { };
(function() {
function findElem(parent, tagName, className) {
var elemToSearch = (parent) ? parent : document.body;
var tagMatch = elemToSearch.getElementsByTagName(tagName);
var evaluator = function(elem) {
return (className) ? (elem.className.indexOf(className) > -1) : true;
};
return findArrayElem(tagMatch, evaluator);
}
function findArrayElem(array, evaluator) {
var newArray = new Array();
for (var count = 0; count < array.length; count++) {
if (evaluator(array[count])) {
newArray.push(array[count]);
}
}
return newArray;
}
function iterateElem(elems, delegate) {
for(var count = 0; count < elems.length; count++) {
delegate(count, elems[count]);
}
}
function isHidden(elem) {
return (elem.offsetHeight === 0 && elem.offsetWidth === 0) || elem.style && elem.style.display === "none";
}
function onWindowLoad(callback) {
attachEventHandler(null, 'load', callback);
}
function attachEventHandler(elem, event, callback) {
var elemToAttach = (elem) ? elem : window;
if (document.addEventListener) {
elemToAttach.addEventListener(event, callback, false);
} else if ( document.attachEvent ) {
elemToAttach.attachEvent('on' + event, callback);
}
}
Galleries.findElem = findElem;
Galleries.iterateElem = iterateElem;
Galleries.attachEventHandler = attachEventHandler;
Galleries.onWindowLoad = onWindowLoad;
})();

@ -0,0 +1,25 @@
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 MS Shell Dlg;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs16\f2\cf0 \cf0\ql{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
{\fs40\f2 {\ltrch MICROSOFT LIMITED PUBLIC LICENSE version 1.1}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 \line {\ltrch ----------------------}\line \li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch This license governs use of code marked as \ldblquote sample\rdblquote or \ldblquote example\rdblquote available on this web site without a license agreement, as provided under the section above titled \ldblquote NOTICE SPECIFIC TO SOFTWARE AVAILABLE ON THIS WEB SITE.\rdblquote If you use such code (the \ldblquote software\rdblquote ), you accept this license. If you do not accept the license, do not use the software.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch 1. Definitions}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch The terms \ldblquote reproduce,\rdblquote \ldblquote reproduction,\rdblquote \ldblquote derivative works,\rdblquote and \ldblquote distribution\rdblquote have the same meaning here as under U.S. copyright law. }\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch A \ldblquote contribution\rdblquote is the original software, or any additions or changes to the software.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch A \ldblquote contributor\rdblquote is any person that distributes its contribution under this license.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch \ldblquote Licensed patents\rdblquote are a contributor\rquote s patent claims that read directly on its contribution.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch 2. Grant of Rights}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch (A) Copyright Grant - Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch (B) Patent Grant - Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch 3. Conditions and Limitations}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch (A) No Trademark License- This license does not grant you rights to use any contributors\rquote name, logo, or trademarks.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch (E) The software is licensed \ldblquote as-is.\rdblquote You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch (F) Platform Limitation - The licenses granted in sections 2(A) and 2(B) extend only to the software or derivative works that you create that run directly on a Microsoft Windows operating system product, Microsoft run-time technology (such as the .NET Framework or Silverlight), or Microsoft application platform (such as Microsoft Office or Microsoft Dynamics).}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
}
}
Loading…
Cancel
Save