Merged PR 300794: Sample clean-up: (relative to future)

Sample clean-up:
- Fix DeviceLost to not register named event, since prevents multiple copies.
- Added copyright headers.
- Reordered to have construction / Dispose() at top for consistency.
- Reordered namespaces to be consistent group order (System, Windows, Microsoft, other) and alphabetical within group.
- Removed unused namespaces.
This commit is contained in:
Jeffrey Stall 2017-03-13 21:37:39 +00:00
Родитель 86eebe117f
Коммит 10354c64f1
18 изменённых файлов: 504 добавлений и 230 удалений

Просмотреть файл

@ -1,11 +1,27 @@
using Microsoft.Graphics.Canvas.Effects;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using Windows.UI;
using Windows.UI.Composition;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Hosting;
using Microsoft.Graphics.Canvas.Effects;
namespace SamplesCommon
{
public class BackDrop : Control

Просмотреть файл

@ -0,0 +1,82 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI.Composition;
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.UI.Composition;
namespace SamplesCommon
{
public class BitmapDrawer : IContentDrawer
{
Uri _uri;
LoadTimeEffectHandler _handler;
public BitmapDrawer(Uri uri, LoadTimeEffectHandler handler)
{
_uri = uri;
_handler = handler;
}
public Uri Uri
{
get { return _uri; }
}
public async Task Draw(CompositionGraphicsDevice device, Object drawingLock, CompositionDrawingSurface surface, Size size)
{
var canvasDevice = CanvasComposition.GetCanvasDevice(device);
using (var canvasBitmap = await CanvasBitmap.LoadAsync(canvasDevice, _uri))
{
var bitmapSize = canvasBitmap.Size;
//
// Because the drawing is done asynchronously and multiple threads could
// be trying to get access to the device/surface at the same time, we need
// to do any device/surface work under a lock.
//
lock (drawingLock)
{
Size surfaceSize = size;
if (surface.Size != size || surface.Size == new Size(0, 0))
{
// Resize the surface to the size of the image
CanvasComposition.Resize(surface, bitmapSize);
surfaceSize = bitmapSize;
}
// Allow the app to process the bitmap if requested
if (_handler != null)
{
_handler(surface, canvasBitmap, device);
}
else
{
// Draw the image to the surface
using (var session = CanvasComposition.CreateDrawingSession(surface))
{
session.Clear(Windows.UI.Color.FromArgb(0, 0, 0, 0));
session.DrawImage(canvasBitmap, new Rect(0, 0, surfaceSize.Width, surfaceSize.Height), new Rect(0, 0, bitmapSize.Width, bitmapSize.Height));
}
}
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,58 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Numerics;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Composition;
using Microsoft.Graphics.Canvas.UI.Composition;
namespace SamplesCommon
{
internal class CircleDrawer : IContentDrawer
{
private float _radius;
private Color _color;
public CircleDrawer(float radius, Color color)
{
_radius = radius;
_color = color;
}
public float Radius
{
get { return _radius; }
}
public Color Color
{
get { return _color; }
}
#pragma warning disable 1998
public async Task Draw(CompositionGraphicsDevice device, Object drawingLock, CompositionDrawingSurface surface, Size size)
{
using (var ds = CanvasComposition.CreateDrawingSession(surface))
{
ds.Clear(Colors.Transparent);
ds.FillCircle(new Vector2(_radius, _radius), _radius, _color);
}
}
}
}

Просмотреть файл

@ -1,133 +1,30 @@
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Text;
using Microsoft.Graphics.Canvas.UI.Composition;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Numerics;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Composition;
using Microsoft.Graphics.Canvas;
namespace SamplesCommon
{
public abstract class ContentDrawer
public interface IContentDrawer
{
public abstract Task Draw(CompositionGraphicsDevice device, Object drawingLock, CompositionDrawingSurface surface, Size size);
Task Draw(CompositionGraphicsDevice device, Object drawingLock, CompositionDrawingSurface surface, Size size);
}
public delegate void LoadTimeEffectHandler(CompositionDrawingSurface surface, CanvasBitmap bitmap, CompositionGraphicsDevice device);
public class BitmapDrawer : ContentDrawer
{
Uri _uri;
LoadTimeEffectHandler _handler;
public BitmapDrawer(Uri uri, LoadTimeEffectHandler handler)
{
_uri = uri;
_handler = handler;
}
public Uri Uri
{
get { return _uri; }
}
public override async Task Draw(CompositionGraphicsDevice device, Object drawingLock, CompositionDrawingSurface surface, Size size)
{
var canvasDevice = CanvasComposition.GetCanvasDevice(device);
using (var canvasBitmap = await CanvasBitmap.LoadAsync(canvasDevice, _uri))
{
var bitmapSize = canvasBitmap.Size;
//
// Because the drawing is done asynchronously and multiple threads could
// be trying to get access to the device/surface at the same time, we need
// to do any device/surface work under a lock.
//
lock (drawingLock)
{
Size surfaceSize = size;
if (surface.Size != size || surface.Size == new Size(0, 0))
{
// Resize the surface to the size of the image
CanvasComposition.Resize(surface, bitmapSize);
surfaceSize = bitmapSize;
}
// Allow the app to process the bitmap if requested
if (_handler != null)
{
_handler(surface, canvasBitmap, device);
}
else
{
// Draw the image to the surface
using (var session = CanvasComposition.CreateDrawingSession(surface))
{
session.Clear(Windows.UI.Color.FromArgb(0, 0, 0, 0));
session.DrawImage(canvasBitmap, new Rect(0, 0, surfaceSize.Width, surfaceSize.Height), new Rect(0, 0, bitmapSize.Width, bitmapSize.Height));
}
}
}
}
}
}
internal class CircleDrawer : ContentDrawer
{
private float _radius;
private Color _color;
public CircleDrawer(float radius, Color color)
{
_radius = radius;
_color = color;
}
public float Radius
{
get { return _radius; }
}
public Color Color
{
get { return _color; }
}
#pragma warning disable 1998
public override async Task Draw(CompositionGraphicsDevice device, Object drawingLock, CompositionDrawingSurface surface, Size size)
{
using (var ds = CanvasComposition.CreateDrawingSession(surface))
{
ds.Clear(Colors.Transparent);
ds.FillCircle(new Vector2(_radius, _radius), _radius, _color);
}
}
}
internal class TextDrawer : ContentDrawer
{
private string _text;
private CanvasTextFormat _textFormat;
private Color _textColor;
private Color _backgroundColor;
public TextDrawer(string text, CanvasTextFormat textFormat, Color textColor, Color bgColor)
{
_text = text;
_textFormat = textFormat;
_textColor = textColor;
_backgroundColor = bgColor;
}
public override async Task Draw(CompositionGraphicsDevice device, Object drawingLock, CompositionDrawingSurface surface, Size size)
{
using (var ds = CanvasComposition.CreateDrawingSession(surface))
{
ds.Clear(_backgroundColor);
ds.DrawText(_text, new Rect(0, 0, surface.Size.Width, surface.Size.Height), _textColor, _textFormat);
}
}
}
}

Просмотреть файл

@ -1,14 +1,32 @@
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.UI.Composition;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Graphics.DirectX;
using Windows.UI;
using Windows.UI.Composition;
using SamplesNative;
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Text;
using Microsoft.Graphics.Canvas.UI.Composition;
using SamplesNative;
namespace SamplesCommon
{
@ -54,7 +72,28 @@ namespace SamplesCommon
_graphicsDevice.RenderingDeviceReplaced += RenderingDeviceReplaced;
}
public void Dispose()
{
lock (_drawingLock)
{
_compositor = null;
if (_canvasDevice != null)
{
_canvasDevice.DeviceLost -= DeviceLost;
_canvasDevice.Dispose();
_canvasDevice = null;
}
if (_graphicsDevice != null)
{
_graphicsDevice.RenderingDeviceReplaced -= RenderingDeviceReplaced;
_graphicsDevice.Dispose();
_graphicsDevice = null;
}
}
}
static public void Initialize(Compositor compositor)
{
Debug.Assert(!_intialized);
@ -75,33 +114,6 @@ namespace SamplesCommon
}
}
private void DeviceRemoved(DeviceLostHelper sender, object args)
{
_canvasDevice.RaiseDeviceLost();
}
private void DeviceLost(CanvasDevice sender, object args)
{
sender.DeviceLost -= DeviceLost;
_canvasDevice = new CanvasDevice();
_canvasDevice.DeviceLost += DeviceLost;
_deviceLostHelper.WatchDevice(_canvasDevice);
CanvasComposition.SetCanvasDevice(_graphicsDevice, _canvasDevice);
}
private void RenderingDeviceReplaced(CompositionGraphicsDevice sender, RenderingDeviceReplacedEventArgs args)
{
Task.Run(() =>
{
if (_deviceReplacedEvent != null)
{
RaiseDeviceReplacedEvent();
}
});
}
public void RegisterSurface(ManagedSurface surface)
{
_deviceReplacedEvent += surface.OnDeviceReplaced;
@ -136,14 +148,6 @@ namespace SamplesCommon
return surface;
}
private async Task<ManagedSurface> LoadFromUriAsyncWorker(Uri uri, Size size, LoadTimeEffectHandler handler)
{
ManagedSurface surface = new ManagedSurface(CreateSurface(size));
await surface.Draw(_graphicsDevice, _drawingLock, new BitmapDrawer(uri, handler));
return surface;
}
public IAsyncOperation<ManagedSurface> LoadFromUriAsync(Uri uri)
{
return LoadFromUriAsyncWorker(uri, Size.Empty, null).AsAsyncOperation<ManagedSurface>();
@ -175,6 +179,14 @@ namespace SamplesCommon
return surface;
}
private async Task<ManagedSurface> LoadFromUriAsyncWorker(Uri uri, Size size, LoadTimeEffectHandler handler)
{
ManagedSurface surface = new ManagedSurface(CreateSurface(size));
await surface.Draw(_graphicsDevice, _drawingLock, new BitmapDrawer(uri, handler));
return surface;
}
private CompositionDrawingSurface CreateSurface(Size size)
{
Size surfaceSize = size;
@ -184,7 +196,7 @@ namespace SamplesCommon
// We start out with a size of 0,0 for the surface, because we don't know
// the size of the image at this time. We resize the surface later.
//
surfaceSize = new Size(0, 0);
surfaceSize = default(Size);
}
var surface = _graphicsDevice.CreateDrawingSurface(surfaceSize, DirectXPixelFormat.B8G8R8A8UIntNormalized, DirectXAlphaMode.Premultiplied);
@ -192,26 +204,31 @@ namespace SamplesCommon
return surface;
}
public void Dispose()
private void DeviceRemoved(DeviceLostHelper sender, object args)
{
lock (_drawingLock)
_canvasDevice.RaiseDeviceLost();
}
private void DeviceLost(CanvasDevice sender, object args)
{
sender.DeviceLost -= DeviceLost;
_canvasDevice = new CanvasDevice();
_canvasDevice.DeviceLost += DeviceLost;
_deviceLostHelper.WatchDevice(_canvasDevice);
CanvasComposition.SetCanvasDevice(_graphicsDevice, _canvasDevice);
}
private void RenderingDeviceReplaced(CompositionGraphicsDevice sender, RenderingDeviceReplacedEventArgs args)
{
Task.Run(() =>
{
_compositor = null;
if (_canvasDevice != null)
if (_deviceReplacedEvent != null)
{
_canvasDevice.DeviceLost -= DeviceLost;
_canvasDevice.Dispose();
_canvasDevice = null;
RaiseDeviceReplacedEvent();
}
if (_graphicsDevice != null)
{
_graphicsDevice.RenderingDeviceReplaced -= RenderingDeviceReplaced;
_graphicsDevice.Dispose();
_graphicsDevice = null;
}
}
});
}
}
}

Просмотреть файл

@ -1,6 +1,21 @@
using System;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI.Composition;
@ -9,9 +24,36 @@ namespace SamplesCommon
public class ManagedSurface
{
private CompositionDrawingSurface _surface;
private ContentDrawer _drawer;
private IContentDrawer _drawer;
private CompositionSurfaceBrush _brush;
public ManagedSurface(CompositionDrawingSurface surface)
{
Debug.Assert(surface != null);
_surface = surface;
ImageLoader.Instance.RegisterSurface(this);
}
public void Dispose()
{
if (_surface != null)
{
_surface.Dispose();
_surface = null;
}
if (_brush != null)
{
_brush.Dispose();
_brush = null;
}
_drawer = null;
ImageLoader.Instance.UnregisterSurface(this);
}
public CompositionDrawingSurface Surface
{
get { return _surface; }
@ -37,16 +79,8 @@ namespace SamplesCommon
return (_surface != null) ? _surface.Size : Size.Empty;
}
}
public ManagedSurface(CompositionDrawingSurface surface)
{
Debug.Assert(surface != null);
_surface = surface;
ImageLoader.Instance.RegisterSurface(this);
}
public async Task Draw(CompositionGraphicsDevice device, Object drawingLock, ContentDrawer drawer)
public async Task Draw(CompositionGraphicsDevice device, Object drawingLock, IContentDrawer drawer)
{
Debug.Assert(_surface != null);
@ -54,34 +88,15 @@ namespace SamplesCommon
await _drawer.Draw(device, drawingLock, _surface, _surface.Size);
}
private async Task ReloadContent(CompositionGraphicsDevice device, Object drawingLock)
{
await _drawer.Draw(device, drawingLock, _surface, _surface.Size);
}
public async void OnDeviceReplaced(object sender, object e)
{
DeviceReplacedEventArgs args = (DeviceReplacedEventArgs)e;
await ReloadContent(args.GraphicsDevce, args.DrawingLock);
}
public void Dispose()
private async Task ReloadContent(CompositionGraphicsDevice device, Object drawingLock)
{
if (_surface != null)
{
_surface.Dispose();
_surface = null;
}
if (_brush != null)
{
_brush.Dispose();
_brush = null;
}
_drawer = null;
ImageLoader.Instance.UnregisterSurface(this);
await _drawer.Draw(device, drawingLock, _surface, _surface.Size);
}
}
}

Просмотреть файл

@ -0,0 +1,51 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Composition;
using Microsoft.Graphics.Canvas.Text;
using Microsoft.Graphics.Canvas.UI.Composition;
namespace SamplesCommon
{
internal class TextDrawer : IContentDrawer
{
private string _text;
private CanvasTextFormat _textFormat;
private Color _textColor;
private Color _backgroundColor;
public TextDrawer(string text, CanvasTextFormat textFormat, Color textColor, Color bgColor)
{
_text = text;
_textFormat = textFormat;
_textColor = textColor;
_backgroundColor = bgColor;
}
public async Task Draw(CompositionGraphicsDevice device, Object drawingLock, CompositionDrawingSurface surface, Size size)
{
using (var ds = CanvasComposition.CreateDrawingSession(surface))
{
ds.Clear(_backgroundColor);
ds.DrawText(_text, new Rect(0, 0, surface.Size.Width, surface.Size.Height), _textColor, _textFormat);
}
}
}
}

Просмотреть файл

@ -1,4 +1,18 @@
using System;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;

Просмотреть файл

@ -1,4 +1,18 @@
using Windows.UI.Xaml;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using Windows.UI.Xaml;
namespace SamplesCommon
{

Просмотреть файл

@ -1,4 +1,18 @@
using System;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

Просмотреть файл

@ -115,7 +115,10 @@
<Compile Include="ColorMixer.xaml.cs">
<DependentUpon>ColorMixer.xaml</DependentUpon>
</Compile>
<Compile Include="ImageLoader\BitmapDrawer.cs" />
<Compile Include="ImageLoader\CircleDrawer.cs" />
<Compile Include="ImageLoader\ContentDrawer.cs" />
<Compile Include="ImageLoader\TextDrawer.cs" />
<Compile Include="LightControl.xaml.cs" />
<Compile Include="OrientationTrigger.cs" />
<Compile Include="PennerEquationBuilder.cs" />

Просмотреть файл

@ -1,18 +1,26 @@
using Microsoft.Graphics.Canvas.Effects;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Composition;
using Windows.UI.Composition.Interactions;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Hosting;
using Windows.UI.Xaml.Media;
namespace SamplesCommon
{

Просмотреть файл

@ -1,4 +1,19 @@
using System;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using Windows.UI.Composition;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Hosting;

Просмотреть файл

@ -1,4 +1,18 @@
using System;
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using System.Threading;
namespace SamplesCommon

Просмотреть файл

@ -1,4 +1,18 @@
#include "pch.h"
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
#include "pch.h"
#include "DeviceLostHelper.h"
using namespace SamplesNative;
@ -43,7 +57,7 @@ DeviceLostHelper::WatchDevice(IDirect3DDevice^ device)
OnDeviceLostHandler = CreateThreadpoolWait(DeviceLostHelper::OnDeviceLost, (PVOID)this, NULL);
// Create a handle and a cookie
m_eventHandle = CreateEvent(NULL, FALSE, FALSE, L"DeviceLost");
m_eventHandle = CreateEvent(NULL, FALSE, FALSE, nullptr);
m_cookie = NULL;
// Register for device lost

Просмотреть файл

@ -1,4 +1,18 @@
#pragma once
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
#pragma once
using namespace Windows::Graphics::DirectX::Direct3D11;

Просмотреть файл

@ -1 +1,15 @@
#include "pch.h"
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
#include "pch.h"

Просмотреть файл

@ -1,4 +1,18 @@
#pragma once
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
#pragma once
#include <collection.h>
#include <ppltasks.h>