whitespace forced changes (#6002)

This commit is contained in:
Clint Rutkas
2020-08-17 10:00:56 -07:00
committed by GitHub
parent 649e7e103d
commit d055ba1c3b
129 changed files with 14175 additions and 14175 deletions

View File

@@ -1,242 +1,242 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Common.Utilities
{
/// <summary>
/// Wraps <see cref="IStream"/> interface into <see cref="Stream"/> Class.
/// </summary>
/// <remarks>
/// Implements only read from the stream functionality.
/// </remarks>
public class StreamWrapper : Stream
{
private IStream stream;
/// <summary>
/// Initializes a new instance of the <see cref="StreamWrapper"/> class.
/// </summary>
/// <param name="stream">A pointer to an <see cref="IStream" /> interface that represents the stream source.</param>
public StreamWrapper(IStream stream)
{
this.stream = stream ?? throw new ArgumentNullException(nameof(stream));
}
/// <summary>
/// Gets a value indicating whether the current stream supports reading.
/// </summary>
public override bool CanRead
{
get
{
return true;
}
}
/// <summary>
/// Gets a value indicating whether the current stream supports seeking.
/// </summary>
public override bool CanSeek
{
get
{
return true;
}
}
/// <summary>
/// Gets a value indicating whether the current stream supports writing.
/// </summary>
public override bool CanWrite
{
get
{
return false;
}
}
/// <summary>
/// Gets the length in bytes of the stream.
/// </summary>
public override long Length
{
get
{
this.CheckDisposed();
System.Runtime.InteropServices.ComTypes.STATSTG stat;
// Stat called with STATFLAG_NONAME. The pwcsName is not required more details https://docs.microsoft.com/en-us/windows/win32/api/wtypes/ne-wtypes-statflag
this.stream.Stat(out stat, 1); // STATFLAG_NONAME
return stat.cbSize;
}
}
/// <summary>
/// Gets or Sets the position within the current.
/// </summary>
public override long Position
{
get
{
return this.Seek(0, SeekOrigin.Current);
}
set
{
this.Seek(value, SeekOrigin.Begin);
}
}
/// <summary>
/// Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
/// </summary>
/// <param name="buffer">An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.</param>
/// <param name="offset">The zero-based byte offset in buffer at which to begin storing the data read from the current stream.</param>
/// <param name="count">The maximum number of bytes to be read from the current stream.</param>
/// <returns>The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached.</returns>
public override int Read(byte[] buffer, int offset, int count)
{
this.CheckDisposed();
if (offset < 0 || count < 0 || offset + count > buffer.Length)
{
throw new ArgumentOutOfRangeException();
}
byte[] localBuffer = buffer;
if (offset > 0)
{
localBuffer = new byte[count];
}
IntPtr bytesReadPtr = Marshal.AllocCoTaskMem(sizeof(int));
try
{
this.stream.Read(localBuffer, count, bytesReadPtr);
int bytesRead = Marshal.ReadInt32(bytesReadPtr);
if (offset > 0)
{
Array.Copy(localBuffer, 0, buffer, offset, bytesRead);
}
return bytesRead;
}
finally
{
Marshal.FreeCoTaskMem(bytesReadPtr);
}
}
/// <summary>
/// Sets the position within the current stream.
/// </summary>
/// <param name="offset">A byte offset relative to the origin parameter.</param>
/// <param name="origin">A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.</param>
/// <returns>The new position within the current stream.</returns>
public override long Seek(long offset, SeekOrigin origin)
{
this.CheckDisposed();
int dwOrigin;
// Maps the SeekOrigin with dworigin more details: https://docs.microsoft.com/en-us/windows/win32/api/objidl/ne-objidl-stream_seek
switch (origin)
{
case SeekOrigin.Begin:
dwOrigin = 0; // STREAM_SEEK_SET
break;
case SeekOrigin.Current:
dwOrigin = 1; // STREAM_SEEK_CUR
break;
case SeekOrigin.End:
dwOrigin = 2; // STREAM_SEEK_END
break;
default:
throw new ArgumentOutOfRangeException();
}
IntPtr posPtr = Marshal.AllocCoTaskMem(sizeof(long));
try
{
this.stream.Seek(offset, dwOrigin, posPtr);
return Marshal.ReadInt64(posPtr);
}
finally
{
Marshal.FreeCoTaskMem(posPtr);
}
}
/// <summary>
/// Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
/// </summary>
/// <remarks>
/// Not implemented current implementation supports only read.
/// </remarks>
public override void Flush()
{
throw new NotImplementedException();
}
/// <summary>
/// Sets the length of the current stream.
/// </summary>
/// <param name="value">The desired length of the current stream in bytes.</param>
/// /// <remarks>
/// Not implemented current implementation supports only read.
/// </remarks>
public override void SetLength(long value)
{
throw new NotImplementedException();
}
/// <summary>
/// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
/// </summary>
/// <param name="buffer">An array of bytes. This method copies count bytes from buffer to the current stream.</param>
/// <param name="offset">The zero-based byte offset in buffer at which to begin copying bytes to the current stream.</param>
/// <param name="count">The number of bytes to be written to the current stream.</param>
/// <remarks>
/// Not implemented current implementation supports only read.
/// </remarks>
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
/// <inheritdoc/>
protected override void Dispose(bool disposing)
{
if (this.stream != null)
{
if (Marshal.IsComObject(this.stream))
{
Marshal.ReleaseComObject(this.stream);
}
this.stream = null;
}
}
private void CheckDisposed()
{
if (this.stream == null)
{
throw new ObjectDisposedException(nameof(StreamWrapper));
}
}
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Common.Utilities
{
/// <summary>
/// Wraps <see cref="IStream"/> interface into <see cref="Stream"/> Class.
/// </summary>
/// <remarks>
/// Implements only read from the stream functionality.
/// </remarks>
public class StreamWrapper : Stream
{
private IStream stream;
/// <summary>
/// Initializes a new instance of the <see cref="StreamWrapper"/> class.
/// </summary>
/// <param name="stream">A pointer to an <see cref="IStream" /> interface that represents the stream source.</param>
public StreamWrapper(IStream stream)
{
this.stream = stream ?? throw new ArgumentNullException(nameof(stream));
}
/// <summary>
/// Gets a value indicating whether the current stream supports reading.
/// </summary>
public override bool CanRead
{
get
{
return true;
}
}
/// <summary>
/// Gets a value indicating whether the current stream supports seeking.
/// </summary>
public override bool CanSeek
{
get
{
return true;
}
}
/// <summary>
/// Gets a value indicating whether the current stream supports writing.
/// </summary>
public override bool CanWrite
{
get
{
return false;
}
}
/// <summary>
/// Gets the length in bytes of the stream.
/// </summary>
public override long Length
{
get
{
this.CheckDisposed();
System.Runtime.InteropServices.ComTypes.STATSTG stat;
// Stat called with STATFLAG_NONAME. The pwcsName is not required more details https://docs.microsoft.com/en-us/windows/win32/api/wtypes/ne-wtypes-statflag
this.stream.Stat(out stat, 1); // STATFLAG_NONAME
return stat.cbSize;
}
}
/// <summary>
/// Gets or Sets the position within the current.
/// </summary>
public override long Position
{
get
{
return this.Seek(0, SeekOrigin.Current);
}
set
{
this.Seek(value, SeekOrigin.Begin);
}
}
/// <summary>
/// Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
/// </summary>
/// <param name="buffer">An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.</param>
/// <param name="offset">The zero-based byte offset in buffer at which to begin storing the data read from the current stream.</param>
/// <param name="count">The maximum number of bytes to be read from the current stream.</param>
/// <returns>The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached.</returns>
public override int Read(byte[] buffer, int offset, int count)
{
this.CheckDisposed();
if (offset < 0 || count < 0 || offset + count > buffer.Length)
{
throw new ArgumentOutOfRangeException();
}
byte[] localBuffer = buffer;
if (offset > 0)
{
localBuffer = new byte[count];
}
IntPtr bytesReadPtr = Marshal.AllocCoTaskMem(sizeof(int));
try
{
this.stream.Read(localBuffer, count, bytesReadPtr);
int bytesRead = Marshal.ReadInt32(bytesReadPtr);
if (offset > 0)
{
Array.Copy(localBuffer, 0, buffer, offset, bytesRead);
}
return bytesRead;
}
finally
{
Marshal.FreeCoTaskMem(bytesReadPtr);
}
}
/// <summary>
/// Sets the position within the current stream.
/// </summary>
/// <param name="offset">A byte offset relative to the origin parameter.</param>
/// <param name="origin">A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.</param>
/// <returns>The new position within the current stream.</returns>
public override long Seek(long offset, SeekOrigin origin)
{
this.CheckDisposed();
int dwOrigin;
// Maps the SeekOrigin with dworigin more details: https://docs.microsoft.com/en-us/windows/win32/api/objidl/ne-objidl-stream_seek
switch (origin)
{
case SeekOrigin.Begin:
dwOrigin = 0; // STREAM_SEEK_SET
break;
case SeekOrigin.Current:
dwOrigin = 1; // STREAM_SEEK_CUR
break;
case SeekOrigin.End:
dwOrigin = 2; // STREAM_SEEK_END
break;
default:
throw new ArgumentOutOfRangeException();
}
IntPtr posPtr = Marshal.AllocCoTaskMem(sizeof(long));
try
{
this.stream.Seek(offset, dwOrigin, posPtr);
return Marshal.ReadInt64(posPtr);
}
finally
{
Marshal.FreeCoTaskMem(posPtr);
}
}
/// <summary>
/// Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
/// </summary>
/// <remarks>
/// Not implemented current implementation supports only read.
/// </remarks>
public override void Flush()
{
throw new NotImplementedException();
}
/// <summary>
/// Sets the length of the current stream.
/// </summary>
/// <param name="value">The desired length of the current stream in bytes.</param>
/// /// <remarks>
/// Not implemented current implementation supports only read.
/// </remarks>
public override void SetLength(long value)
{
throw new NotImplementedException();
}
/// <summary>
/// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
/// </summary>
/// <param name="buffer">An array of bytes. This method copies count bytes from buffer to the current stream.</param>
/// <param name="offset">The zero-based byte offset in buffer at which to begin copying bytes to the current stream.</param>
/// <param name="count">The number of bytes to be written to the current stream.</param>
/// <remarks>
/// Not implemented current implementation supports only read.
/// </remarks>
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
/// <inheritdoc/>
protected override void Dispose(bool disposing)
{
if (this.stream != null)
{
if (Marshal.IsComObject(this.stream))
{
Marshal.ReleaseComObject(this.stream);
}
this.stream = null;
}
}
private void CheckDisposed()
{
if (this.stream == null)
{
throw new ObjectDisposedException(nameof(StreamWrapper));
}
}
}
}

View File

@@ -1,35 +1,35 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Drawing;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// The COLORREF value is used to specify an RGB color.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct COLORREF
{
/// <summary>
/// Stores an RGB color value in a 32 bit integer.
/// </summary>
public uint Dword;
/// <summary>
/// Gets RGB value stored in <see cref="Dword"/> in <see cref="Color"/> structure.
/// </summary>
public Color Color
{
get
{
return Color.FromArgb(
(int)(0x000000FFU & this.Dword),
(int)(0x0000FF00U & this.Dword) >> 8,
(int)(0x00FF0000U & this.Dword) >> 16);
}
}
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Drawing;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// The COLORREF value is used to specify an RGB color.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct COLORREF
{
/// <summary>
/// Stores an RGB color value in a 32 bit integer.
/// </summary>
public uint Dword;
/// <summary>
/// Gets RGB value stored in <see cref="Dword"/> in <see cref="Color"/> structure.
/// </summary>
public Color Color
{
get
{
return Color.FromArgb(
(int)(0x000000FFU & this.Dword),
(int)(0x0000FF00U & this.Dword) >> 8,
(int)(0x00FF0000U & this.Dword) >> 16);
}
}
}
}

View File

@@ -1,25 +1,25 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.Cominterop
{
/// <summary>
/// Exposes a method to initialize a handler, such as a property handler, thumbnail handler, or preview handler, with a file path.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("b7d14566-0509-4cce-a71f-0a554233bd9b")]
public interface IInitializeWithFile
{
/// <summary>
/// Initializes a handler with a file path.
/// </summary>
/// <param name="pszFilePath">File Path.</param>
/// <param name="grfMode">Indicate the Access Mode either STGM_READ (Read Only Access) or STGM_READWRITE (Read and Write Access).</param>
void Initialize([MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, uint grfMode);
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.Cominterop
{
/// <summary>
/// Exposes a method to initialize a handler, such as a property handler, thumbnail handler, or preview handler, with a file path.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("b7d14566-0509-4cce-a71f-0a554233bd9b")]
public interface IInitializeWithFile
{
/// <summary>
/// Initializes a handler with a file path.
/// </summary>
/// <param name="pszFilePath">File Path.</param>
/// <param name="grfMode">Indicate the Access Mode either STGM_READ (Read Only Access) or STGM_READWRITE (Read and Write Access).</param>
void Initialize([MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, uint grfMode);
}
}

View File

@@ -1,26 +1,26 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Common.ComInterlop
{
/// <summary>
/// Exposes a method that initializes a handler, such as a property handler, thumbnail handler, or preview handler, with a stream.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f")]
public interface IInitializeWithStream
{
/// <summary>
/// Initializes a handler with a stream.
/// </summary>
/// <param name="pstream">A pointer to an <see cref="IStream" /> interface that represents the stream source.</param>
/// <param name="grfMode">One of the <see href="https://docs.microsoft.com/en-us/windows/win32/stg/stgm-constants" >STGM</see> values that indicates the access mode for <paramref name="pstream"/>.</param>
void Initialize(IStream pstream, uint grfMode);
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Common.ComInterlop
{
/// <summary>
/// Exposes a method that initializes a handler, such as a property handler, thumbnail handler, or preview handler, with a stream.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f")]
public interface IInitializeWithStream
{
/// <summary>
/// Initializes a handler with a stream.
/// </summary>
/// <param name="pstream">A pointer to an <see cref="IStream" /> interface that represents the stream source.</param>
/// <param name="grfMode">One of the <see href="https://docs.microsoft.com/en-us/windows/win32/stg/stgm-constants" >STGM</see> values that indicates the access mode for <paramref name="pstream"/>.</param>
void Initialize(IStream pstream, uint grfMode);
}
}

View File

@@ -1,31 +1,31 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Provides a simplified way to support communication between an object and its site in the container.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("fc4801a3-2ba9-11cf-a229-00aa003d7352")]
public interface IObjectWithSite
{
/// <summary>
/// Provides the site's pointer to the site object.
/// </summary>
/// <param name="pUnkSite">Address of an interface pointer to the site managing this object.</param>
void SetSite([In, MarshalAs(UnmanagedType.IUnknown)] object pUnkSite);
/// <summary>
/// Retrieves the last site set using the <see cref="SetSite(object)" /> method. In cases where there is no known site, the object returns an exception.
/// </summary>
/// <param name="riid">Provides the IID of the interface pointer returned in the <paramref name="ppvSite"/> parameter.</param>
/// <param name="ppvSite">The address of the caller's void variable in which the object stores the interface pointer of the site last seen in the <see cref="SetSite(object)" />.</param>
void GetSite(ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppvSite);
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Provides a simplified way to support communication between an object and its site in the container.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("fc4801a3-2ba9-11cf-a229-00aa003d7352")]
public interface IObjectWithSite
{
/// <summary>
/// Provides the site's pointer to the site object.
/// </summary>
/// <param name="pUnkSite">Address of an interface pointer to the site managing this object.</param>
void SetSite([In, MarshalAs(UnmanagedType.IUnknown)] object pUnkSite);
/// <summary>
/// Retrieves the last site set using the <see cref="SetSite(object)" /> method. In cases where there is no known site, the object returns an exception.
/// </summary>
/// <param name="riid">Provides the IID of the interface pointer returned in the <paramref name="ppvSite"/> parameter.</param>
/// <param name="ppvSite">The address of the caller's void variable in which the object stores the interface pointer of the site last seen in the <see cref="SetSite(object)" />.</param>
void GetSite(ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppvSite);
}
}

View File

@@ -1,31 +1,31 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// The IOleWindow interface provides methods that allow an application to obtain the handle to the various windows that participate
/// in in-place activation, and also to enter and exit context-sensitive help mode.
/// </summary>
[ComImport]
[Guid("00000114-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleWindow
{
/// <summary>
/// Retrieves a handle to one of the windows participating in in-place activation (frame, document, parent, or in-place object window).
/// </summary>
/// <param name="phwnd">A pointer to a variable that receives the window handle.</param>
void GetWindow(out IntPtr phwnd);
/// <summary>
/// Determines whether context-sensitive help mode should be entered during an in-place activation session.
/// </summary>
/// <param name="fEnterMode">TRUE if help mode should be entered; FALSE if it should be exited.</param>
void ContextSensitiveHelp([MarshalAs(UnmanagedType.Bool)] bool fEnterMode);
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// The IOleWindow interface provides methods that allow an application to obtain the handle to the various windows that participate
/// in in-place activation, and also to enter and exit context-sensitive help mode.
/// </summary>
[ComImport]
[Guid("00000114-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleWindow
{
/// <summary>
/// Retrieves a handle to one of the windows participating in in-place activation (frame, document, parent, or in-place object window).
/// </summary>
/// <param name="phwnd">A pointer to a variable that receives the window handle.</param>
void GetWindow(out IntPtr phwnd);
/// <summary>
/// Determines whether context-sensitive help mode should be entered during an in-place activation session.
/// </summary>
/// <param name="fEnterMode">TRUE if help mode should be entered; FALSE if it should be exited.</param>
void ContextSensitiveHelp([MarshalAs(UnmanagedType.Bool)] bool fEnterMode);
}
}

View File

@@ -1,62 +1,62 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Exposes methods for the display of rich previews.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("8895b1c6-b41f-4c1c-a562-0d564250836f")]
public interface IPreviewHandler
{
/// <summary>
/// Sets the parent window of the previewer window, as well as the area within the parent to be used for the previewer window.
/// </summary>
/// <param name="hwnd">A handle to the parent window.</param>
/// <param name="rect">A pointer to a <see cref="RECT"/> defining the area for the previewer.</param>
void SetWindow(IntPtr hwnd, ref RECT rect);
/// <summary>
/// Directs the preview handler to change the area within the parent hwnd that it draws into.
/// </summary>
/// <param name="rect">A pointer to a <see cref="RECT"/> to be used for the preview.</param>
void SetRect(ref RECT rect);
/// <summary>
/// Directs the preview handler to load data from the source specified in an earlier Initialize method call, and to begin rendering to the previewer window.
/// </summary>
void DoPreview();
/// <summary>
/// Directs the preview handler to cease rendering a preview and to release all resources that have been allocated based on the item passed in during the initialization.
/// </summary>
void Unload();
/// <summary>
/// Directs the preview handler to set focus to itself.
/// </summary>
void SetFocus();
/// <summary>
/// Directs the preview handler to return the HWND from calling the GetFocus Function.
/// </summary>
/// <param name="phwnd">When this method returns, contains a pointer to the HWND returned from calling the GetFocus Function from the preview handler's foreground thread.</param>
void QueryFocus(out IntPtr phwnd);
/// <summary>
/// Directs the preview handler to handle a keystroke passed up from the message pump of the process in which the preview handler is running.
/// </summary>
/// <param name="pmsg">A pointer to a window message.</param>
/// <returns>If the keystroke message can be processed by the preview handler, the handler will process it and return S_OK(0). If the preview handler cannot process the keystroke message, it
/// will offer it to the host using <see cref="IPreviewHandlerFrame.TranslateAccelerator(ref MSG)"/>. If the host processes the message, this method will return S_OK(0). If the host does not process the message, this method will return S_FALSE(1).
/// </returns>
[PreserveSig]
uint TranslateAccelerator(ref MSG pmsg);
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Exposes methods for the display of rich previews.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("8895b1c6-b41f-4c1c-a562-0d564250836f")]
public interface IPreviewHandler
{
/// <summary>
/// Sets the parent window of the previewer window, as well as the area within the parent to be used for the previewer window.
/// </summary>
/// <param name="hwnd">A handle to the parent window.</param>
/// <param name="rect">A pointer to a <see cref="RECT"/> defining the area for the previewer.</param>
void SetWindow(IntPtr hwnd, ref RECT rect);
/// <summary>
/// Directs the preview handler to change the area within the parent hwnd that it draws into.
/// </summary>
/// <param name="rect">A pointer to a <see cref="RECT"/> to be used for the preview.</param>
void SetRect(ref RECT rect);
/// <summary>
/// Directs the preview handler to load data from the source specified in an earlier Initialize method call, and to begin rendering to the previewer window.
/// </summary>
void DoPreview();
/// <summary>
/// Directs the preview handler to cease rendering a preview and to release all resources that have been allocated based on the item passed in during the initialization.
/// </summary>
void Unload();
/// <summary>
/// Directs the preview handler to set focus to itself.
/// </summary>
void SetFocus();
/// <summary>
/// Directs the preview handler to return the HWND from calling the GetFocus Function.
/// </summary>
/// <param name="phwnd">When this method returns, contains a pointer to the HWND returned from calling the GetFocus Function from the preview handler's foreground thread.</param>
void QueryFocus(out IntPtr phwnd);
/// <summary>
/// Directs the preview handler to handle a keystroke passed up from the message pump of the process in which the preview handler is running.
/// </summary>
/// <param name="pmsg">A pointer to a window message.</param>
/// <returns>If the keystroke message can be processed by the preview handler, the handler will process it and return S_OK(0). If the preview handler cannot process the keystroke message, it
/// will offer it to the host using <see cref="IPreviewHandlerFrame.TranslateAccelerator(ref MSG)"/>. If the host processes the message, this method will return S_OK(0). If the host does not process the message, this method will return S_FALSE(1).
/// </returns>
[PreserveSig]
uint TranslateAccelerator(ref MSG pmsg);
}
}

View File

@@ -1,33 +1,33 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Enables preview handlers to pass keyboard shortcuts to the host. This interface retrieves a list of keyboard shortcuts and directs the host to handle a keyboard shortcut.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("fec87aaf-35f9-447a-adb7-20234491401a")]
public interface IPreviewHandlerFrame
{
/// <summary>
/// Gets a list of the keyboard shortcuts for the preview host.
/// </summary>
/// <param name="pinfo">A pointer to a <see href="https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ns-shobjidl_core-previewhandlerframeinfo">PREVIEWHANDLERFRAMEINFO</see> structure
/// that receives accelerator table information.</param>
void GetWindowContext(IntPtr pinfo);
/// <summary>
/// Directs the host to handle an keyboard shortcut passed from the preview handler.
/// </summary>
/// <param name="pmsg">A reference to <see cref="MSG"/> that corresponds to a keyboard shortcut.</param>
/// <returns>If the keyboard shortcut is one that the host intends to handle, the host will process it and return S_OK(0); otherwise, it returns S_FALSE(1).</returns>
[PreserveSig]
uint TranslateAccelerator(ref MSG pmsg);
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Enables preview handlers to pass keyboard shortcuts to the host. This interface retrieves a list of keyboard shortcuts and directs the host to handle a keyboard shortcut.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("fec87aaf-35f9-447a-adb7-20234491401a")]
public interface IPreviewHandlerFrame
{
/// <summary>
/// Gets a list of the keyboard shortcuts for the preview host.
/// </summary>
/// <param name="pinfo">A pointer to a <see href="https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ns-shobjidl_core-previewhandlerframeinfo">PREVIEWHANDLERFRAMEINFO</see> structure
/// that receives accelerator table information.</param>
void GetWindowContext(IntPtr pinfo);
/// <summary>
/// Directs the host to handle an keyboard shortcut passed from the preview handler.
/// </summary>
/// <param name="pmsg">A reference to <see cref="MSG"/> that corresponds to a keyboard shortcut.</param>
/// <returns>If the keyboard shortcut is one that the host intends to handle, the host will process it and return S_OK(0); otherwise, it returns S_FALSE(1).</returns>
[PreserveSig]
uint TranslateAccelerator(ref MSG pmsg);
}
}

View File

@@ -1,36 +1,36 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Exposes methods for applying color and font information to preview handlers.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("8327b13c-b63f-4b24-9b8a-d010dcc3f599")]
public interface IPreviewHandlerVisuals
{
/// <summary>
/// Sets the background color of the preview handler.
/// </summary>
/// <param name="color">A value of type <see cref="COLORREF"/> to use for the preview handler background.</param>
void SetBackgroundColor(COLORREF color);
/// <summary>
/// Sets the font attributes to be used for text within the preview handler.
/// </summary>
/// <param name="plf">A pointer to a <see cref="LOGFONT"/> Structure containing the necessary attributes for the font to use.</param>
void SetFont(ref LOGFONT plf);
/// <summary>
/// Sets the color of the text within the preview handler.
/// </summary>
/// <param name="color">A value of type <see cref="COLORREF"/> to use for the preview handler text color.</param>
void SetTextColor(COLORREF color);
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Exposes methods for applying color and font information to preview handlers.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("8327b13c-b63f-4b24-9b8a-d010dcc3f599")]
public interface IPreviewHandlerVisuals
{
/// <summary>
/// Sets the background color of the preview handler.
/// </summary>
/// <param name="color">A value of type <see cref="COLORREF"/> to use for the preview handler background.</param>
void SetBackgroundColor(COLORREF color);
/// <summary>
/// Sets the font attributes to be used for text within the preview handler.
/// </summary>
/// <param name="plf">A pointer to a <see cref="LOGFONT"/> Structure containing the necessary attributes for the font to use.</param>
void SetFont(ref LOGFONT plf);
/// <summary>
/// Sets the color of the text within the preview handler.
/// </summary>
/// <param name="color">A value of type <see cref="COLORREF"/> to use for the preview handler text color.</param>
void SetTextColor(COLORREF color);
}
}

View File

@@ -1,88 +1,88 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Defines the attributes of a font.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct LOGFONT
{
/// <summary>
/// Value of type INT that specifies the height, in logical units, of the font's character cell or character.
/// </summary>
public int LfHeight;
/// <summary>
/// Value of type INT that specifies the width, in logical units, of characters in the font.
/// </summary>
public int LfWidth;
/// <summary>
/// Value of type INT that contains the angle, in tenths of degrees, between the escapement vector and the x-axis of the device. The escapement
/// vector is parallel to the base line of a row of text.
/// </summary>
public int LfEscapement;
/// <summary>
/// Value of type INT that specifies the angle, in tenths of degrees, between each character's base line and the x-axis of the device.
/// </summary>
public int LfOrientation;
/// <summary>
/// Value of type INT that specifies the weight of the font in the range from 0 through 1000.
/// </summary>
public int LfWeight;
/// <summary>
/// Value of type BYTE that specifies an italic font if set to TRUE.
/// </summary>
public byte LfItalic;
/// <summary>
/// Value of type BYTE that specifies an underlined font if set to TRUE.
/// </summary>
public byte LfUnderline;
/// <summary>
/// Value of type BYTE that specifies a strikeout font if set to TRUE.
/// </summary>
public byte LfStrikeOut;
/// <summary>
/// Value of type BYTE that specifies the character set.
/// </summary>
public byte LfCharSet;
/// <summary>
/// Value of type BYTE that specifies the output precision. The output precision defines how closely the output must match the requested
/// font's height, width, character orientation, escapement, pitch, and font type.
/// </summary>
public byte LfOutPrecision;
/// <summary>
/// Value of type BYTE that specifies the clipping precision. The clipping precision defines how to clip characters that are partially outside the clipping region.
/// </summary>
public byte LfClipPrecision;
/// <summary>
/// Value of type BYTE that specifies the output quality. The output quality defines how carefully the GDI must attempt to match the logical-font attributes to those of an actual physical font.
/// </summary>
public byte LfQuality;
/// <summary>
/// Value of type BYTE that specifies the pitch and family of the font.
/// </summary>
public byte LfPitchAndFamily;
/// <summary>
/// Array of wide characters that contains a null-terminated string that specifies the typeface name of the font. The length of the string must not exceed 32 characters, including the NULL terminator.
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string LfFaceName;
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Defines the attributes of a font.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct LOGFONT
{
/// <summary>
/// Value of type INT that specifies the height, in logical units, of the font's character cell or character.
/// </summary>
public int LfHeight;
/// <summary>
/// Value of type INT that specifies the width, in logical units, of characters in the font.
/// </summary>
public int LfWidth;
/// <summary>
/// Value of type INT that contains the angle, in tenths of degrees, between the escapement vector and the x-axis of the device. The escapement
/// vector is parallel to the base line of a row of text.
/// </summary>
public int LfEscapement;
/// <summary>
/// Value of type INT that specifies the angle, in tenths of degrees, between each character's base line and the x-axis of the device.
/// </summary>
public int LfOrientation;
/// <summary>
/// Value of type INT that specifies the weight of the font in the range from 0 through 1000.
/// </summary>
public int LfWeight;
/// <summary>
/// Value of type BYTE that specifies an italic font if set to TRUE.
/// </summary>
public byte LfItalic;
/// <summary>
/// Value of type BYTE that specifies an underlined font if set to TRUE.
/// </summary>
public byte LfUnderline;
/// <summary>
/// Value of type BYTE that specifies a strikeout font if set to TRUE.
/// </summary>
public byte LfStrikeOut;
/// <summary>
/// Value of type BYTE that specifies the character set.
/// </summary>
public byte LfCharSet;
/// <summary>
/// Value of type BYTE that specifies the output precision. The output precision defines how closely the output must match the requested
/// font's height, width, character orientation, escapement, pitch, and font type.
/// </summary>
public byte LfOutPrecision;
/// <summary>
/// Value of type BYTE that specifies the clipping precision. The clipping precision defines how to clip characters that are partially outside the clipping region.
/// </summary>
public byte LfClipPrecision;
/// <summary>
/// Value of type BYTE that specifies the output quality. The output quality defines how carefully the GDI must attempt to match the logical-font attributes to those of an actual physical font.
/// </summary>
public byte LfQuality;
/// <summary>
/// Value of type BYTE that specifies the pitch and family of the font.
/// </summary>
public byte LfPitchAndFamily;
/// <summary>
/// Array of wide characters that contains a null-terminated string that specifies the typeface name of the font. The length of the string must not exceed 32 characters, including the NULL terminator.
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string LfFaceName;
}
}

View File

@@ -1,51 +1,51 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Contains message information from a thread's message queue.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct MSG
{
/// <summary>
/// A handle to the window whose window procedure receives the message. This member is NULL when the message is a thread message.
/// </summary>
public IntPtr Hwnd;
/// <summary>
/// The message identifier. Applications can only use the low word; the high word is reserved by the system.
/// </summary>
public int Message;
/// <summary>
/// Additional information about the message. The exact meaning depends on the value of the message member.
/// </summary>
public IntPtr WParam;
/// <summary>
/// Additional information about the message. The exact meaning depends on the value of the message member.
/// </summary>
public IntPtr LParam;
/// <summary>
/// The time at which the message was posted.
/// </summary>
public int Time;
/// <summary>
/// The x coordinate of cursor position, in screen coordinates, when the message was posted.
/// </summary>
public int PtX;
/// <summary>
/// The y coordinate of cursor position, in screen coordinates, when the message was posted.
/// </summary>
public int PtY;
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
namespace Common.ComInterlop
{
/// <summary>
/// Contains message information from a thread's message queue.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct MSG
{
/// <summary>
/// A handle to the window whose window procedure receives the message. This member is NULL when the message is a thread message.
/// </summary>
public IntPtr Hwnd;
/// <summary>
/// The message identifier. Applications can only use the low word; the high word is reserved by the system.
/// </summary>
public int Message;
/// <summary>
/// Additional information about the message. The exact meaning depends on the value of the message member.
/// </summary>
public IntPtr WParam;
/// <summary>
/// Additional information about the message. The exact meaning depends on the value of the message member.
/// </summary>
public IntPtr LParam;
/// <summary>
/// The time at which the message was posted.
/// </summary>
public int Time;
/// <summary>
/// The x coordinate of cursor position, in screen coordinates, when the message was posted.
/// </summary>
public int PtX;
/// <summary>
/// The y coordinate of cursor position, in screen coordinates, when the message was posted.
/// </summary>
public int PtY;
}
}