diff --git a/Microsoft.Dotnet.Wpf.sln b/Microsoft.Dotnet.Wpf.sln
index c3d86130ea5..1d2d8602bc3 100644
--- a/Microsoft.Dotnet.Wpf.sln
+++ b/Microsoft.Dotnet.Wpf.sln
@@ -381,6 +381,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Windows.Primitives-r
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PresentationFramework.Fluent.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\PresentationFramework.Fluent.Tests\PresentationFramework.Fluent.Tests.csproj", "{56833D74-2D0B-5516-C1D6-B93D4FFF7612}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Windows.Primitives.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\System.Windows.Primitives.Tests\System.Windows.Primitives.Tests.csproj", "{88CF4EED-8617-D414-D538-A7DE83E7780C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|arm64 = Debug|arm64
@@ -1653,6 +1655,18 @@ Global
{56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Release|x64.Build.0 = Release|x64
{56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Release|x86.ActiveCfg = Release|x86
{56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Release|x86.Build.0 = Release|x86
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Debug|arm64.ActiveCfg = Debug|arm64
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Debug|arm64.Build.0 = Debug|arm64
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Debug|x64.ActiveCfg = Debug|x64
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Debug|x64.Build.0 = Debug|x64
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Debug|x86.ActiveCfg = Debug|x86
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Debug|x86.Build.0 = Debug|x86
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Release|arm64.ActiveCfg = Release|arm64
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Release|arm64.Build.0 = Release|arm64
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Release|x64.ActiveCfg = Release|x64
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Release|x64.Build.0 = Release|x64
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Release|x86.ActiveCfg = Release|x86
+ {88CF4EED-8617-D414-D538-A7DE83E7780C}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1780,6 +1794,7 @@ Global
{5306FA93-178C-4535-ADEE-86B1DE1B68CB} = {2EE4A2DA-70B3-4767-9D18-618DA0FE3105}
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42} = {D0AED517-9972-41CB-8751-983E4EB8F511}
{56833D74-2D0B-5516-C1D6-B93D4FFF7612} = {A48B585E-6AB0-4F8D-8484-77F37CB44437}
+ {88CF4EED-8617-D414-D538-A7DE83E7780C} = {A48B585E-6AB0-4F8D-8484-77F37CB44437}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B4340004-DAC0-497D-B69D-CFA7CD93F567}
diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1
index bd80ccccb51..5de8ff8b099 100644
--- a/eng/common/tools.ps1
+++ b/eng/common/tools.ps1
@@ -299,7 +299,7 @@ function InstallDotNet([string] $dotnetRoot,
$dotnetVersionLabel = "runtime toolset '$runtime/$architecture v$version'"
if (Test-Path $runtimePath) {
- Write-Host " Runtime toolset '$runtime/$architecture v$version' already installed."
+ Write-Host " Runtime toolset '$runtime/$architecture v$version' already installed at '$runtimePath'."
$installSuccess = $true
Exit
}
diff --git a/global.json b/global.json
index 0c542875e4d..1cdf22deaf0 100644
--- a/global.json
+++ b/global.json
@@ -2,7 +2,11 @@
"tools": {
"dotnet": "10.0.100-alpha.1.24573.1",
"runtimes": {
- "dotnet": [
+ "dotnet/x64": [
+ "2.1.7",
+ "$(VSRedistCommonNetCoreSharedFrameworkx64100PackageVersion)"
+ ],
+ "dotnet/x86": [
"2.1.7",
"$(VSRedistCommonNetCoreSharedFrameworkx64100PackageVersion)"
]
diff --git a/src/Microsoft.DotNet.Wpf/src/Common/Graphics/exports.cs b/src/Microsoft.DotNet.Wpf/src/Common/Graphics/exports.cs
index 92069b2a676..31df5c9bc61 100644
--- a/src/Microsoft.DotNet.Wpf/src/Common/Graphics/exports.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Common/Graphics/exports.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -14,7 +14,8 @@
using MS.Win32;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
-using HRESULT = MS.Internal.HRESULT;
+using HRESULT = Windows.Win32.Foundation.HRESULT;
+using Windows.Win32.Foundation;
/*
*
@@ -111,101 +112,101 @@ internal static unsafe void CopyBytes(byte* pbTo,
private static class UnsafeNativeMethods
{
[DllImport(DllImport.MilCore)]
- internal static extern /*HRESULT*/ int MilResource_CreateOrAddRefOnChannel(
+ internal static extern HRESULT MilResource_CreateOrAddRefOnChannel(
IntPtr pChannel,
- DUCE.ResourceType resourceType,
- ref DUCE.ResourceHandle hResource
+ ResourceType resourceType,
+ ref ResourceHandle hResource
);
[DllImport(DllImport.MilCore)]
- internal static extern /*HRESULT*/ int MilResource_DuplicateHandle(
+ internal static extern HRESULT MilResource_DuplicateHandle(
IntPtr pSourceChannel,
- DUCE.ResourceHandle original,
+ ResourceHandle original,
IntPtr pTargetChannel,
- ref DUCE.ResourceHandle duplicate
+ ref ResourceHandle duplicate
);
[DllImport(DllImport.MilCore, EntryPoint = "MilConnection_CreateChannel")]//CASRemoval:
- internal static extern int MilConnection_CreateChannel(
+ internal static extern HRESULT MilConnection_CreateChannel(
IntPtr pTransport,
IntPtr hChannel,
out IntPtr channelHandle);
[DllImport(DllImport.MilCore, EntryPoint = "MilConnection_DestroyChannel")]//CASRemoval:
- internal static extern int MilConnection_DestroyChannel(
+ internal static extern HRESULT MilConnection_DestroyChannel(
IntPtr channelHandle);
[DllImport(DllImport.MilCore, EntryPoint = "MilChannel_CloseBatch")]//CASRemoval:
- internal static extern int MilConnection_CloseBatch(
+ internal static extern HRESULT MilConnection_CloseBatch(
IntPtr channelHandle);
[DllImport(DllImport.MilCore, EntryPoint = "MilChannel_CommitChannel")]//CASRemoval:
- internal static extern int MilConnection_CommitChannel(
+ internal static extern HRESULT MilConnection_CommitChannel(
IntPtr channelHandle);
[DllImport(DllImport.MilCore)]//CASRemoval:
- internal static extern int WgxConnection_SameThreadPresent(
+ internal static extern HRESULT WgxConnection_SameThreadPresent(
IntPtr pConnection);
[DllImport(DllImport.MilCore, EntryPoint = "MilChannel_GetMarshalType")]
- internal static extern int MilChannel_GetMarshalType(IntPtr channelHandle, out ChannelMarshalType marshalType);
+ internal static extern HRESULT MilChannel_GetMarshalType(IntPtr channelHandle, out ChannelMarshalType marshalType);
- [DllImport (DllImport.MilCore, EntryPoint = "MilResource_SendCommand")]//CASRemoval:
- unsafe internal static extern int MilResource_SendCommand(
- byte *pbData,
+ [DllImport(DllImport.MilCore, EntryPoint = "MilResource_SendCommand")]//CASRemoval:
+ internal static extern unsafe HRESULT MilResource_SendCommand(
+ byte* pbData,
uint cbSize,
bool sendInSeparateBatch,
IntPtr pChannel);
- [DllImport (DllImport.MilCore, EntryPoint = "MilChannel_BeginCommand")]//CASRemoval:
- unsafe internal static extern int MilChannel_BeginCommand(
+ [DllImport(DllImport.MilCore, EntryPoint = "MilChannel_BeginCommand")]//CASRemoval:
+ internal static extern unsafe HRESULT MilChannel_BeginCommand(
IntPtr pChannel,
- byte *pbData,
+ byte* pbData,
uint cbSize,
uint cbExtra
);
- [DllImport (DllImport.MilCore, EntryPoint = "MilChannel_AppendCommandData")]//CASRemoval:
- unsafe internal static extern int MilChannel_AppendCommandData(
+ [DllImport(DllImport.MilCore, EntryPoint = "MilChannel_AppendCommandData")]//CASRemoval:
+ internal static extern unsafe HRESULT MilChannel_AppendCommandData(
IntPtr pChannel,
- byte *pbData,
+ byte* pbData,
uint cbSize
);
- [DllImport (DllImport.MilCore, EntryPoint = "MilChannel_EndCommand")]//CASRemoval:
- unsafe internal static extern int MilChannel_EndCommand(
+ [DllImport(DllImport.MilCore, EntryPoint = "MilChannel_EndCommand")]//CASRemoval:
+ internal static extern unsafe HRESULT MilChannel_EndCommand(
IntPtr pChannel);
- [DllImport (DllImport.MilCore, EntryPoint = "MilResource_SendCommandMedia")]//CASRemoval:
- unsafe internal static extern int MilResource_SendCommandMedia(
+ [DllImport(DllImport.MilCore, EntryPoint = "MilResource_SendCommandMedia")]//CASRemoval:
+ internal static extern unsafe HRESULT MilResource_SendCommandMedia(
ResourceHandle handle,
SafeMediaHandle pMedia,
IntPtr pChannel,
- bool notifyUceDirect
+ bool notifyUceDirect
);
- [DllImport (DllImport.MilCore, EntryPoint = "MilResource_SendCommandBitmapSource")]//CASRemoval:
- unsafe internal static extern int MilResource_SendCommandBitmapSource(
+ [DllImport(DllImport.MilCore, EntryPoint = "MilResource_SendCommandBitmapSource")]//CASRemoval:
+ internal static extern unsafe HRESULT MilResource_SendCommandBitmapSource(
ResourceHandle handle,
BitmapSourceSafeMILHandle /* IWICBitmapSource */ pBitmapSource,
IntPtr pChannel);
[DllImport(DllImport.MilCore, EntryPoint = "MilResource_ReleaseOnChannel")]//CASRemoval:
- internal static extern /*HRESULT*/ int MilResource_ReleaseOnChannel(
+ internal static extern HRESULT MilResource_ReleaseOnChannel(
IntPtr pChannel,
- DUCE.ResourceHandle hResource,
+ ResourceHandle hResource,
out int deleted
);
[DllImport(DllImport.MilCore)]
- internal static extern int MilChannel_SetNotificationWindow(
+ internal static extern HRESULT MilChannel_SetNotificationWindow(
IntPtr pChannel,
IntPtr hwnd,
WindowMessage message
);
[DllImport(DllImport.MilCore)]
- internal static extern int MilComposition_WaitForNextMessage(
+ internal static extern HRESULT MilComposition_WaitForNextMessage(
IntPtr pChannel,
int nCount,
IntPtr[] handles,
@@ -215,7 +216,7 @@ out int waitReturn
);
[DllImport(DllImport.MilCore)]
- internal static extern int MilComposition_PeekNextMessage(
+ internal static extern HRESULT MilComposition_PeekNextMessage(
IntPtr pChannel,
out MilMessage.Message message,
/* size_t */ IntPtr messageSize,
@@ -223,9 +224,9 @@ out int messageRetrieved
);
[DllImport(DllImport.MilCore, EntryPoint = "MilResource_GetRefCountOnChannel")]
- internal static extern /*HRESULT*/ int MilResource_GetRefCountOnChannel(
+ internal static extern HRESULT MilResource_GetRefCountOnChannel(
IntPtr pChannel,
- DUCE.ResourceHandle hResource,
+ ResourceHandle hResource,
out uint refCount
);
}
@@ -233,7 +234,7 @@ out uint refCount
///
/// Define the value of an infinte wait in WaitForNextMessage.
///
- internal const UInt32 waitInfinite = UInt32.MaxValue;
+ internal const uint InfiniteWait = uint.MaxValue;
internal static class MilMessage
{
@@ -242,16 +243,16 @@ internal static class MilMessage
///
internal enum Type
{
- Invalid = 0x00,
+ Invalid = 0x00,
- SyncFlushReply = 0x01,
- Caps = 0x04,
- PartitionIsZombie = 0x06,
- SyncModeStatus = 0x09,
- Presented = 0x0A,
- BadPixelShader = 0x10,
+ SyncFlushReply = 0x01,
+ Caps = 0x04,
+ PartitionIsZombie = 0x06,
+ SyncModeStatus = 0x09,
+ Presented = 0x0A,
+ BadPixelShader = 0x10,
- ForceDWORD = unchecked((int)0xffffffff)
+ ForceDWORD = unchecked((int)0xffffffff)
};
[StructLayout(LayoutKind.Explicit, Pack = 1)]
@@ -350,11 +351,11 @@ public Channel(Channel referenceChannel, bool isOutOfBandChannel, IntPtr pConnec
referenceChannelHandle = referenceChannel._hChannel;
}
- HRESULT.Check(UnsafeNativeMethods.MilConnection_CreateChannel(
+ UnsafeNativeMethods.MilConnection_CreateChannel(
_pConnection,
referenceChannelHandle,
- out _hChannel));
-}
+ out _hChannel).ThrowOnFailureExtended();
+ }
///
@@ -374,8 +375,8 @@ internal void Commit()
return;
}
- HRESULT.Check(UnsafeNativeMethods.MilConnection_CommitChannel(
- _hChannel));
+ UnsafeNativeMethods.MilConnection_CommitChannel(
+ _hChannel).ThrowOnFailureExtended();
}
///
@@ -395,8 +396,8 @@ internal void CloseBatch()
return;
}
- HRESULT.Check(UnsafeNativeMethods.MilConnection_CloseBatch(
- _hChannel));
+ UnsafeNativeMethods.MilConnection_CloseBatch(
+ _hChannel).ThrowOnFailureExtended();
}
///
@@ -417,8 +418,8 @@ internal void SyncFlush()
return;
}
- HRESULT.Check(MilCoreApi.MilComposition_SyncFlush(_hChannel));
-}
+ MilCoreApi.MilComposition_SyncFlush(_hChannel).ThrowOnFailureExtended();
+ }
///
/// Commits the channel and then closes it.
@@ -427,15 +428,15 @@ internal void Close()
{
if (_hChannel != IntPtr.Zero)
{
- HRESULT.Check(UnsafeNativeMethods.MilConnection_CloseBatch(_hChannel));
- HRESULT.Check(UnsafeNativeMethods.MilConnection_CommitChannel(_hChannel));
+ UnsafeNativeMethods.MilConnection_CloseBatch(_hChannel).ThrowOnFailureExtended();
+ UnsafeNativeMethods.MilConnection_CommitChannel(_hChannel).ThrowOnFailureExtended();
}
_referenceChannel = null;
if (_hChannel != IntPtr.Zero)
{
- HRESULT.Check(UnsafeNativeMethods.MilConnection_DestroyChannel(_hChannel));
+ UnsafeNativeMethods.MilConnection_DestroyChannel(_hChannel).ThrowOnFailureExtended();
_hChannel = IntPtr.Zero;
}
@@ -446,7 +447,7 @@ internal void Close()
///
internal void Present()
{
- HRESULT.Check(UnsafeNativeMethods.WgxConnection_SameThreadPresent(_pConnection));
+ UnsafeNativeMethods.WgxConnection_SameThreadPresent(_pConnection).ThrowOnFailureExtended();
}
///
@@ -457,21 +458,21 @@ internal void Present()
/// Returns true iff the resource was created on the channel. The caller is responsible to
/// update the resource appropriately.
///
- internal bool CreateOrAddRefOnChannel(object instance, ref DUCE.ResourceHandle handle, DUCE.ResourceType resourceType)
+ internal bool CreateOrAddRefOnChannel(object instance, ref ResourceHandle handle, ResourceType resourceType)
{
bool handleNeedsCreation = handle.IsNull;
Invariant.Assert(_hChannel != IntPtr.Zero);
- HRESULT.Check(UnsafeNativeMethods.MilResource_CreateOrAddRefOnChannel(
+ UnsafeNativeMethods.MilResource_CreateOrAddRefOnChannel(
_hChannel,
resourceType,
ref handle
- ));
+ ).ThrowOnFailureExtended();
if (EventTrace.IsEnabled(EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW))
{
- EventTrace.EventProvider.TraceEvent(EventTrace.Event.CreateOrAddResourceOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, PerfService.GetPerfElementID(instance), _hChannel, (uint) handle, (uint) resourceType);
+ EventTrace.EventProvider.TraceEvent(EventTrace.Event.CreateOrAddResourceOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, PerfService.GetPerfElementID(instance), _hChannel, (uint)handle, (uint)resourceType);
}
return handleNeedsCreation;
@@ -491,21 +492,21 @@ ref handle
/// Returns the duplicated handle (valid on the target channel) or the null
/// handle if duplication failed.
///
- internal DUCE.ResourceHandle DuplicateHandle(
- DUCE.ResourceHandle original,
- DUCE.Channel targetChannel
+ internal ResourceHandle DuplicateHandle(
+ ResourceHandle original,
+ Channel targetChannel
)
{
- DUCE.ResourceHandle duplicate = DUCE.ResourceHandle.Null;
+ ResourceHandle duplicate = ResourceHandle.Null;
//Debug.WriteLine(string.Format("DuplicateHandle: Channel: {0}, Resource: {1}, Target channel: {2}, ", _hChannel, original._handle, targetChannel));
- HRESULT.Check(UnsafeNativeMethods.MilResource_DuplicateHandle(
+ UnsafeNativeMethods.MilResource_DuplicateHandle(
_hChannel,
original,
targetChannel._hChannel,
ref duplicate
- ));
+ ).ThrowOnFailureExtended();
return duplicate;
}
@@ -518,7 +519,7 @@ ref duplicate
///
/// Returns true iff the resource is not on this channel anymore.
///
- internal bool ReleaseOnChannel(DUCE.ResourceHandle handle)
+ internal bool ReleaseOnChannel(ResourceHandle handle)
{
Invariant.Assert(_hChannel != IntPtr.Zero);
Debug.Assert(!handle.IsNull);
@@ -527,15 +528,15 @@ internal bool ReleaseOnChannel(DUCE.ResourceHandle handle)
int releasedOnChannel;
- HRESULT.Check(UnsafeNativeMethods.MilResource_ReleaseOnChannel(
+ UnsafeNativeMethods.MilResource_ReleaseOnChannel(
_hChannel,
handle,
out releasedOnChannel
- ));
+ ).ThrowOnFailureExtended();
if ((releasedOnChannel != 0) && EventTrace.IsEnabled(EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW))
{
- EventTrace.EventProvider.TraceEvent(EventTrace.Event.ReleaseOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, _hChannel, (uint) handle);
+ EventTrace.EventProvider.TraceEvent(EventTrace.Event.ReleaseOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, _hChannel, (uint)handle);
}
return (releasedOnChannel != 0);
@@ -548,18 +549,18 @@ out releasedOnChannel
///
/// Returns the ref count for a resource on this channel.
///
- internal uint GetRefCount(DUCE.ResourceHandle handle)
+ internal uint GetRefCount(ResourceHandle handle)
{
Invariant.Assert(_hChannel != IntPtr.Zero);
Debug.Assert(!handle.IsNull);
uint refCount;
- HRESULT.Check(UnsafeNativeMethods.MilResource_GetRefCountOnChannel(
+ UnsafeNativeMethods.MilResource_GetRefCountOnChannel(
_hChannel,
handle,
out refCount
- ));
+ ).ThrowOnFailureExtended();
return refCount;
}
@@ -586,10 +587,10 @@ internal ChannelMarshalType MarshalType
Invariant.Assert(_hChannel != IntPtr.Zero);
ChannelMarshalType marshalType;
- HRESULT.Check(UnsafeNativeMethods.MilChannel_GetMarshalType(
+ UnsafeNativeMethods.MilChannel_GetMarshalType(
_hChannel,
out marshalType
- ));
+ ).ThrowOnFailureExtended();
return marshalType;
}
@@ -620,8 +621,8 @@ internal bool IsOutOfBandChannel
///
/// SendCommand sends a command struct through the composition thread.
///
- unsafe internal void SendCommand(
- byte *pCommandData,
+ internal unsafe void SendCommand(
+ byte* pCommandData,
int cSize)
{
SendCommand(pCommandData, cSize, false);
@@ -633,8 +634,8 @@ unsafe internal void SendCommand(
/// current open batch, or whether it will be added to a new and separate batch
/// which is then immediately closed, leaving the current batch untouched.
///
- unsafe internal void SendCommand(
- byte *pCommandData,
+ internal unsafe void SendCommand(
+ byte* pCommandData,
int cSize,
bool sendInSeparateBatch)
{
@@ -642,8 +643,6 @@ unsafe internal void SendCommand(
{
Invariant.Assert(pCommandData != (byte*)0 && cSize > 0);
- int hr = HRESULT.S_OK;
-
if (_hChannel == IntPtr.Zero)
{
//
@@ -656,21 +655,19 @@ unsafe internal void SendCommand(
return;
}
- hr = UnsafeNativeMethods.MilResource_SendCommand(
+ UnsafeNativeMethods.MilResource_SendCommand(
pCommandData,
(uint)cSize,
sendInSeparateBatch,
- _hChannel);
-
- HRESULT.Check(hr);
+ _hChannel).ThrowOnFailureExtended();
}
}
///
/// BeginCommand opens a command on a channel
///
- unsafe internal void BeginCommand(
- byte *pbCommandData,
+ internal unsafe void BeginCommand(
+ byte* pbCommandData,
int cbSize,
int cbExtra)
{
@@ -678,8 +675,6 @@ unsafe internal void BeginCommand(
{
Invariant.Assert(cbSize > 0);
- int hr = HRESULT.S_OK;
-
if (_hChannel == IntPtr.Zero)
{
//
@@ -692,30 +687,26 @@ unsafe internal void BeginCommand(
return;
}
- hr = UnsafeNativeMethods.MilChannel_BeginCommand(
+ UnsafeNativeMethods.MilChannel_BeginCommand(
_hChannel,
pbCommandData,
(uint)cbSize,
(uint)cbExtra
- );
-
- HRESULT.Check(hr);
+ ).ThrowOnFailureExtended();
}
}
///
/// AppendCommandData appends data to an open command on a channel
///
- unsafe internal void AppendCommandData(
- byte *pbCommandData,
+ internal unsafe void AppendCommandData(
+ byte* pbCommandData,
int cbSize)
{
checked
{
Invariant.Assert(pbCommandData != (byte*)0 && cbSize > 0);
- int hr = HRESULT.S_OK;
-
if (_hChannel == IntPtr.Zero)
{
//
@@ -728,13 +719,11 @@ unsafe internal void AppendCommandData(
return;
}
- hr = UnsafeNativeMethods.MilChannel_AppendCommandData(
+ UnsafeNativeMethods.MilChannel_AppendCommandData(
_hChannel,
pbCommandData,
(uint)cbSize
- );
-
- HRESULT.Check(hr);
+ ).ThrowOnFailureExtended();
}
}
@@ -755,31 +744,31 @@ internal void EndCommand()
return;
}
- HRESULT.Check(UnsafeNativeMethods.MilChannel_EndCommand(_hChannel));
+ UnsafeNativeMethods.MilChannel_EndCommand(_hChannel).ThrowOnFailureExtended();
}
///
/// SendCommand that creates an slave bitmap resource
///
internal void SendCommandBitmapSource(
- DUCE.ResourceHandle imageHandle,
+ ResourceHandle imageHandle,
BitmapSourceSafeMILHandle pBitmapSource
)
{
Invariant.Assert(pBitmapSource != null && !pBitmapSource.IsInvalid);
Invariant.Assert(_hChannel != IntPtr.Zero);
- HRESULT.Check(UnsafeNativeMethods.MilResource_SendCommandBitmapSource(
+ UnsafeNativeMethods.MilResource_SendCommandBitmapSource(
imageHandle,
pBitmapSource,
- _hChannel));
+ _hChannel).ThrowOnFailureExtended();
}
///
/// SendCommand that creates an slave media resource
///
internal void SendCommandMedia(
- DUCE.ResourceHandle mediaHandle,
+ ResourceHandle mediaHandle,
SafeMediaHandle pMedia,
bool notifyUceDirect
)
@@ -788,12 +777,12 @@ bool notifyUceDirect
Invariant.Assert(_hChannel != IntPtr.Zero);
- HRESULT.Check(UnsafeNativeMethods.MilResource_SendCommandMedia(
+ UnsafeNativeMethods.MilResource_SendCommandMedia(
mediaHandle,
pMedia,
_hChannel,
notifyUceDirect
- ));
+ ).ThrowOnFailureExtended();
}
///
@@ -812,11 +801,11 @@ internal void SetNotificationWindow(IntPtr hwnd, WindowMessage message)
{
Invariant.Assert(_hChannel != IntPtr.Zero);
- HRESULT.Check(UnsafeNativeMethods.MilChannel_SetNotificationWindow(
+ UnsafeNativeMethods.MilChannel_SetNotificationWindow(
_hChannel,
hwnd,
message
- ));
+ ).ThrowOnFailureExtended();
}
///
@@ -831,14 +820,14 @@ internal void WaitForNextMessage()
{
int waitReturn;
- HRESULT.Check(UnsafeNativeMethods.MilComposition_WaitForNextMessage(
+ UnsafeNativeMethods.MilComposition_WaitForNextMessage(
_hChannel,
0,
null,
1, /* true */
- waitInfinite,
+ InfiniteWait,
out waitReturn
- ));
+ ).ThrowOnFailureExtended();
}
///
@@ -861,12 +850,12 @@ internal bool PeekNextMessage(out MilMessage.Message message)
{
unsafe
{
- HRESULT.Check(UnsafeNativeMethods.MilComposition_PeekNextMessage(
+ UnsafeNativeMethods.MilComposition_PeekNextMessage(
_hChannel,
out message,
(IntPtr)sizeof(MilMessage.Message),
out messageRetrieved
- ));
+ ).ThrowOnFailureExtended();
}
}
@@ -884,9 +873,9 @@ out messageRetrieved
///
internal struct Resource
{
- public static readonly Resource Null = new Resource(DUCE.ResourceHandle.Null);
+ public static readonly Resource Null = new Resource(ResourceHandle.Null);
- private DUCE.ResourceHandle _handle;
+ private ResourceHandle _handle;
#if DEBUG
private Channel _debugOnly_Channel;
#endif
@@ -896,7 +885,7 @@ internal struct Resource
/// Creates a resource from a type and ResourceHandle.
/// This is currently only used for some hwnd interop code in the VisualManager.
///
- public Resource(DUCE.ResourceHandle h)
+ public Resource(ResourceHandle h)
{
_handle = h;
#if DEBUG
@@ -907,7 +896,7 @@ public Resource(DUCE.ResourceHandle h)
///
/// CreatesOrAddRefs the resource on the specified channel.
///
- public bool CreateOrAddRefOnChannel(object instance, Channel channel, DUCE.ResourceType type)
+ public bool CreateOrAddRefOnChannel(object instance, Channel channel, ResourceType type)
{
Debug.Assert(channel != null);
#if DEBUG
@@ -935,7 +924,7 @@ public bool ReleaseOnChannel(Channel channel)
#endif
if (channel.ReleaseOnChannel(_handle))
{
- _handle = DUCE.ResourceHandle.Null;
+ _handle = ResourceHandle.Null;
return true;
}
return false;
@@ -960,7 +949,7 @@ public bool IsOnChannel(Channel channel)
/// Consider moving to an abstract handle type in the future.
///
- public DUCE.ResourceHandle Handle { get { return _handle; } }
+ public ResourceHandle Handle { get { return _handle; } }
}
///
@@ -1125,7 +1114,7 @@ public bool Remove(object key)
if (_others != null)
{
Debug.Assert(_others.Count > 0);
- int j = _others.Count-1;
+ int j = _others.Count - 1;
_first = _others[j];
if (j == 0) // Only one entry in the array.
{
@@ -1138,8 +1127,8 @@ public bool Remove(object key)
}
else
{
- _first = new Entry();
-}
+ _first = new Entry();
+ }
return true;
}
@@ -1228,7 +1217,7 @@ public object Get(int index)
return _others[index - 1]._key;
}
-}
+ }
///
/// This is a generic map that maps a key to a value. It is heavily optimized
@@ -1246,14 +1235,14 @@ internal struct Map
///
private struct Entry
{
- public Entry(object k, DUCE.ResourceHandle v)
+ public Entry(object k, ResourceHandle v)
{
_key = k;
_value = v;
}
public object _key;
- public DUCE.ResourceHandle _value;
+ public ResourceHandle _value;
}
private const int FOUND_IN_INLINE_STORAGE = -1;
@@ -1308,7 +1297,7 @@ private int Find(object key)
///
/// Associates a key with the specified value. If the entry already exits the old value is overriden.
///
- public void Set(object key, DUCE.ResourceHandle value)
+ public void Set(object key, ResourceHandle value)
{
int index = Find(key);
@@ -1341,8 +1330,8 @@ public void Set(object key, DUCE.ResourceHandle value)
// ... and replace the single entry
_head._key = others;
- _head._value = DUCE.ResourceHandle.Null;
-}
+ _head._value = ResourceHandle.Null;
+ }
else
{
// There's already a List - simply add the new entry to the list.
@@ -1405,11 +1394,11 @@ public bool Remove(object key)
/// Gets the value for the specified key. If the entry for the specified key could not
/// be found the Get method returns false otherwise true.
///
- public bool Get(object key, out DUCE.ResourceHandle value)
+ public bool Get(object key, out ResourceHandle value)
{
int index = Find(key);
- value = DUCE.ResourceHandle.Null;
+ value = ResourceHandle.Null;
if (index == FOUND_IN_INLINE_STORAGE)
{
@@ -1467,7 +1456,7 @@ public object Get(int index)
return ((List)_head._key)[index]._key;
}
-}
+ }
///
/// ShareableDUCEMultiChannelResource class - this class simply wraps a MultiChannelResource,
@@ -1497,10 +1486,10 @@ internal struct MultiChannelResource
/// The method is not synchronized. If the resource is used in a multi-threaded scenario, the
/// caller is responsible for taking a lock before calling CreateOrAddRefOnChannel or ReleaseOnChannel.
///
- public bool CreateOrAddRefOnChannel(object instance, Channel channel, DUCE.ResourceType type)
+ public bool CreateOrAddRefOnChannel(object instance, Channel channel, ResourceType type)
{
Debug.Assert(channel != null);
- DUCE.ResourceHandle handle;
+ ResourceHandle handle;
bool inmap = _map.Get(channel, out handle);
bool created = channel.CreateOrAddRefOnChannel(instance, ref handle, type);
@@ -1522,12 +1511,12 @@ public bool CreateOrAddRefOnChannel(object instance, Channel channel, DUCE.Resou
///
/// The channel to duplicate the handle from.
/// The channel to duplicate the handle to.
- public DUCE.ResourceHandle DuplicateHandle(Channel sourceChannel, Channel targetChannel)
+ public ResourceHandle DuplicateHandle(Channel sourceChannel, Channel targetChannel)
{
Debug.Assert(sourceChannel != null);
- DUCE.ResourceHandle duplicate = DUCE.ResourceHandle.Null;
+ ResourceHandle duplicate = ResourceHandle.Null;
- DUCE.ResourceHandle handle = DUCE.ResourceHandle.Null;
+ ResourceHandle handle = ResourceHandle.Null;
bool found = _map.Get(sourceChannel, out handle);
Debug.Assert(found);
@@ -1564,7 +1553,7 @@ public bool ReleaseOnChannel(Channel channel)
{
Debug.Assert(channel != null);
- DUCE.ResourceHandle handle;
+ ResourceHandle handle;
bool found = _map.Get(channel, out handle);
Debug.Assert(found);
@@ -1583,9 +1572,9 @@ public bool ReleaseOnChannel(Channel channel)
///
/// Returns the ResourceHandle for this resource on the specified channel.
///
- public DUCE.ResourceHandle GetHandle(Channel channel)
+ public ResourceHandle GetHandle(Channel channel)
{
- DUCE.ResourceHandle h;
+ ResourceHandle h;
if (channel != null)
{
@@ -1622,9 +1611,9 @@ public int GetChannelCount()
return _map.Count();
}
- public DUCE.Channel GetChannel(int index)
+ public Channel GetChannel(int index)
{
- return _map.Get(index) as DUCE.Channel;
+ return _map.Get(index) as Channel;
}
@@ -1632,7 +1621,7 @@ public uint GetRefCountOnChannel(Channel channel)
{
Debug.Assert(channel != null);
- DUCE.ResourceHandle handle;
+ ResourceHandle handle;
bool found = _map.Get(channel, out handle);
Debug.Assert(found);
@@ -1647,11 +1636,11 @@ internal static class CompositionNode
// Public imports for composition nodes.
//
internal static void SetTransform(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hTransform,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hTransform,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETTRANSFORM command;
+ MILCMD_VISUAL_SETTRANSFORM command;
command.Type = MILCMD.MilCmdVisualSetTransform;
command.Handle = hCompositionNode;
@@ -1661,18 +1650,18 @@ internal static void SetTransform(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETTRANSFORM)
+ sizeof(MILCMD_VISUAL_SETTRANSFORM)
);
}
}
internal static void SetEffect(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hEffect,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hEffect,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETEFFECT command;
+ MILCMD_VISUAL_SETEFFECT command;
command.Type = MILCMD.MilCmdVisualSetEffect;
command.Handle = hCompositionNode;
@@ -1682,18 +1671,18 @@ internal static void SetEffect(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETEFFECT)
+ sizeof(MILCMD_VISUAL_SETEFFECT)
);
}
}
internal static void SetCacheMode(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hCacheMode,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hCacheMode,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETCACHEMODE command;
+ MILCMD_VISUAL_SETCACHEMODE command;
command.Type = MILCMD.MilCmdVisualSetCacheMode;
command.Handle = hCompositionNode;
@@ -1703,18 +1692,18 @@ internal static void SetCacheMode(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETCACHEMODE)
+ sizeof(MILCMD_VISUAL_SETCACHEMODE)
);
}
}
internal static void SetOffset(
- DUCE.ResourceHandle hCompositionNode,
+ ResourceHandle hCompositionNode,
double offsetX,
double offsetY,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETOFFSET command;
+ MILCMD_VISUAL_SETOFFSET command;
command.Type = MILCMD.MilCmdVisualSetOffset;
command.Handle = hCompositionNode;
command.offsetX = offsetX;
@@ -1724,17 +1713,17 @@ internal static void SetOffset(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETOFFSET)
+ sizeof(MILCMD_VISUAL_SETOFFSET)
);
}
}
internal static void SetContent(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hContent,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hContent,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETCONTENT command;
+ MILCMD_VISUAL_SETCONTENT command;
command.Type = MILCMD.MilCmdVisualSetContent;
command.Handle = hCompositionNode;
@@ -1744,17 +1733,17 @@ internal static void SetContent(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETCONTENT)
+ sizeof(MILCMD_VISUAL_SETCONTENT)
);
}
}
internal static void SetAlpha(
- DUCE.ResourceHandle hCompositionNode,
+ ResourceHandle hCompositionNode,
double alpha,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETALPHA command;
+ MILCMD_VISUAL_SETALPHA command;
command.Type = MILCMD.MilCmdVisualSetAlpha;
command.Handle = hCompositionNode;
@@ -1764,17 +1753,17 @@ internal static void SetAlpha(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETALPHA)
+ sizeof(MILCMD_VISUAL_SETALPHA)
);
}
}
internal static void SetAlphaMask(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hAlphaMaskBrush,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hAlphaMaskBrush,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETALPHAMASK command;
+ MILCMD_VISUAL_SETALPHAMASK command;
command.Type = MILCMD.MilCmdVisualSetAlphaMask;
command.Handle = hCompositionNode;
@@ -1784,21 +1773,21 @@ internal static void SetAlphaMask(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETALPHAMASK)
+ sizeof(MILCMD_VISUAL_SETALPHAMASK)
);
}
}
internal static void SetScrollableAreaClip(
- DUCE.ResourceHandle hCompositionNode,
+ ResourceHandle hCompositionNode,
Rect? clip,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETSCROLLABLEAREACLIP command;
+ MILCMD_VISUAL_SETSCROLLABLEAREACLIP command;
command.Type = MILCMD.MilCmdVisualSetScrollableAreaClip;
command.Handle = hCompositionNode;
- command.IsEnabled = (uint) (clip.HasValue ? 1 : 0);
+ command.IsEnabled = (uint)(clip.HasValue ? 1 : 0);
if (clip.HasValue)
{
@@ -1813,17 +1802,17 @@ internal static void SetScrollableAreaClip(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETSCROLLABLEAREACLIP)
+ sizeof(MILCMD_VISUAL_SETSCROLLABLEAREACLIP)
);
}
}
internal static void SetClip(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hClip,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hClip,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETCLIP command;
+ MILCMD_VISUAL_SETCLIP command;
command.Type = MILCMD.MilCmdVisualSetClip;
command.Handle = hCompositionNode;
@@ -1833,17 +1822,17 @@ internal static void SetClip(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETCLIP)
+ sizeof(MILCMD_VISUAL_SETCLIP)
);
}
}
internal static void SetRenderOptions(
- DUCE.ResourceHandle hCompositionNode,
+ ResourceHandle hCompositionNode,
MilRenderOptions renderOptions,
Channel channel)
{
- DUCE.MILCMD_VISUAL_SETRENDEROPTIONS command;
+ MILCMD_VISUAL_SETRENDEROPTIONS command;
command.Type = MILCMD.MilCmdVisualSetRenderOptions;
command.Handle = hCompositionNode;
@@ -1853,17 +1842,17 @@ internal static void SetRenderOptions(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETRENDEROPTIONS)
+ sizeof(MILCMD_VISUAL_SETRENDEROPTIONS)
);
}
-}
+ }
internal static void RemoveChild(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hChild,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hChild,
Channel channel)
{
- DUCE.MILCMD_VISUAL_REMOVECHILD command;
+ MILCMD_VISUAL_REMOVECHILD command;
command.Type = MILCMD.MilCmdVisualRemoveChild;
command.Handle = hCompositionNode;
@@ -1873,16 +1862,16 @@ internal static void RemoveChild(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_REMOVECHILD)
+ sizeof(MILCMD_VISUAL_REMOVECHILD)
);
}
}
internal static void RemoveAllChildren(
- DUCE.ResourceHandle hCompositionNode,
+ ResourceHandle hCompositionNode,
Channel channel)
{
- DUCE.MILCMD_VISUAL_REMOVEALLCHILDREN command;
+ MILCMD_VISUAL_REMOVEALLCHILDREN command;
command.Type = MILCMD.MilCmdVisualRemoveAllChildren;
command.Handle = hCompositionNode;
@@ -1891,18 +1880,18 @@ internal static void RemoveAllChildren(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_REMOVEALLCHILDREN)
+ sizeof(MILCMD_VISUAL_REMOVEALLCHILDREN)
);
}
}
internal static void InsertChildAt(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hChild,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hChild,
UInt32 iPosition,
Channel channel)
{
- DUCE.MILCMD_VISUAL_INSERTCHILDAT command;
+ MILCMD_VISUAL_INSERTCHILDAT command;
Debug.Assert(!hCompositionNode.IsNull);
command.Type = MILCMD.MilCmdVisualInsertChildAt;
@@ -1914,13 +1903,13 @@ internal static void InsertChildAt(
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_INSERTCHILDAT)
+ sizeof(MILCMD_VISUAL_INSERTCHILDAT)
);
}
}
internal static void SetGuidelineCollection(
- DUCE.ResourceHandle hCompositionNode,
+ ResourceHandle hCompositionNode,
DoubleCollection guidelinesX,
DoubleCollection guidelinesY,
Channel channel
@@ -1928,7 +1917,7 @@ Channel channel
{
checked
{
- DUCE.MILCMD_VISUAL_SETGUIDELINECOLLECTION command;
+ MILCMD_VISUAL_SETGUIDELINECOLLECTION command;
Debug.Assert(!hCompositionNode.IsNull);
int countX = guidelinesX == null ? 0 : guidelinesX.Count;
@@ -1946,7 +1935,7 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETGUIDELINECOLLECTION)
+ sizeof(MILCMD_VISUAL_SETGUIDELINECOLLECTION)
);
}
}
@@ -1976,7 +1965,7 @@ Channel channel
{
channel.BeginCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL_SETGUIDELINECOLLECTION),
+ sizeof(MILCMD_VISUAL_SETGUIDELINECOLLECTION),
sizeof(float) * countXY
);
@@ -1998,13 +1987,13 @@ Channel channel
internal static class Viewport3DVisualNode
{
internal static void SetCamera(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hCamera,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hCamera,
Channel channel)
{
unsafe
{
- DUCE.MILCMD_VIEWPORT3DVISUAL_SETCAMERA command;
+ MILCMD_VIEWPORT3DVISUAL_SETCAMERA command;
command.Type = MILCMD.MilCmdViewport3DVisualSetCamera;
command.Handle = hCompositionNode;
@@ -2012,19 +2001,19 @@ internal static void SetCamera(
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VIEWPORT3DVISUAL_SETCAMERA)
+ sizeof(MILCMD_VIEWPORT3DVISUAL_SETCAMERA)
);
}
}
internal static void SetViewport(
- DUCE.ResourceHandle hCompositionNode,
+ ResourceHandle hCompositionNode,
Rect viewport,
Channel channel)
{
unsafe
{
- DUCE.MILCMD_VIEWPORT3DVISUAL_SETVIEWPORT command;
+ MILCMD_VIEWPORT3DVISUAL_SETVIEWPORT command;
command.Type = MILCMD.MilCmdViewport3DVisualSetViewport;
command.Handle = hCompositionNode;
@@ -2032,19 +2021,19 @@ internal static void SetViewport(
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VIEWPORT3DVISUAL_SETVIEWPORT)
+ sizeof(MILCMD_VIEWPORT3DVISUAL_SETVIEWPORT)
);
}
}
internal static void Set3DChild(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hVisual3D,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hVisual3D,
Channel channel)
{
unsafe
{
- DUCE.MILCMD_VIEWPORT3DVISUAL_SET3DCHILD command;
+ MILCMD_VIEWPORT3DVISUAL_SET3DCHILD command;
command.Type = MILCMD.MilCmdViewport3DVisualSet3DChild;
command.Handle = hCompositionNode;
@@ -2052,7 +2041,7 @@ internal static void Set3DChild(
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VIEWPORT3DVISUAL_SET3DCHILD)
+ sizeof(MILCMD_VIEWPORT3DVISUAL_SET3DCHILD)
);
}
}
@@ -2061,13 +2050,13 @@ internal static void Set3DChild(
internal static class Visual3DNode
{
internal static void RemoveChild(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hChild,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hChild,
Channel channel)
{
unsafe
{
- DUCE.MILCMD_VISUAL3D_REMOVECHILD command;
+ MILCMD_VISUAL3D_REMOVECHILD command;
command.Type = MILCMD.MilCmdVisual3DRemoveChild;
command.Handle = hCompositionNode;
@@ -2075,38 +2064,38 @@ internal static void RemoveChild(
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL3D_REMOVECHILD)
+ sizeof(MILCMD_VISUAL3D_REMOVECHILD)
);
}
}
internal static void RemoveAllChildren(
- DUCE.ResourceHandle hCompositionNode,
+ ResourceHandle hCompositionNode,
Channel channel)
{
unsafe
{
- DUCE.MILCMD_VISUAL3D_REMOVEALLCHILDREN command;
+ MILCMD_VISUAL3D_REMOVEALLCHILDREN command;
command.Type = MILCMD.MilCmdVisual3DRemoveAllChildren;
command.Handle = hCompositionNode;
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL3D_REMOVEALLCHILDREN)
+ sizeof(MILCMD_VISUAL3D_REMOVEALLCHILDREN)
);
}
}
internal static void InsertChildAt(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hChild,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hChild,
UInt32 iPosition,
Channel channel)
{
unsafe
{
- DUCE.MILCMD_VISUAL3D_INSERTCHILDAT command;
+ MILCMD_VISUAL3D_INSERTCHILDAT command;
Debug.Assert(!hCompositionNode.IsNull);
command.Type = MILCMD.MilCmdVisual3DInsertChildAt;
@@ -2116,19 +2105,19 @@ internal static void InsertChildAt(
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL3D_INSERTCHILDAT)
+ sizeof(MILCMD_VISUAL3D_INSERTCHILDAT)
);
}
}
internal static void SetContent(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hContent,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hContent,
Channel channel)
{
unsafe
{
- DUCE.MILCMD_VISUAL3D_SETCONTENT command;
+ MILCMD_VISUAL3D_SETCONTENT command;
command.Type = MILCMD.MilCmdVisual3DSetContent;
command.Handle = hCompositionNode;
@@ -2136,19 +2125,19 @@ internal static void SetContent(
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL3D_SETCONTENT)
+ sizeof(MILCMD_VISUAL3D_SETCONTENT)
);
}
}
internal static void SetTransform(
- DUCE.ResourceHandle hCompositionNode,
- DUCE.ResourceHandle hTransform,
+ ResourceHandle hCompositionNode,
+ ResourceHandle hTransform,
Channel channel)
{
unsafe
{
- DUCE.MILCMD_VISUAL3D_SETTRANSFORM command;
+ MILCMD_VISUAL3D_SETTRANSFORM command;
command.Type = MILCMD.MilCmdVisual3DSetTransform;
command.Handle = hCompositionNode;
@@ -2156,7 +2145,7 @@ internal static void SetTransform(
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_VISUAL3D_SETTRANSFORM)
+ sizeof(MILCMD_VISUAL3D_SETTRANSFORM)
);
}
}
@@ -2168,7 +2157,7 @@ internal static class CompositionTarget
// Public imports for composition targets.
//
internal static void HwndInitialize(
- DUCE.ResourceHandle hCompositionTarget,
+ ResourceHandle hCompositionTarget,
IntPtr hWnd,
int nWidth,
int nHeight,
@@ -2178,7 +2167,7 @@ internal static void HwndInitialize(
Channel channel
)
{
- DUCE.MILCMD_HWNDTARGET_CREATE command;
+ MILCMD_HWNDTARGET_CREATE command;
command.Type = MILCMD.MilCmdHwndTargetCreate;
command.Handle = hCompositionTarget;
@@ -2222,7 +2211,7 @@ Channel channel
}
bool? enableMultiMonitorDisplayClipping =
- System.Windows.CoreCompatibilityPreferences.EnableMultiMonitorDisplayClipping;
+ CoreCompatibilityPreferences.EnableMultiMonitorDisplayClipping;
if (enableMultiMonitorDisplayClipping != null)
{
@@ -2231,7 +2220,7 @@ Channel channel
if (!enableMultiMonitorDisplayClipping.Value)
{
- command.flags |= (UInt32) MILRTInitializationFlags.MIL_RT_DISABLE_MULTIMON_DISPLAY_CLIPPING;
+ command.flags |= (UInt32)MILRTInitializationFlags.MIL_RT_DISABLE_MULTIMON_DISPLAY_CLIPPING;
}
}
@@ -2240,7 +2229,7 @@ Channel channel
command.flags |= (UInt32)MILRTInitializationFlags.MIL_RT_DISABLE_DIRTY_RECTANGLES;
}
- command.hBitmap = DUCE.ResourceHandle.Null;
+ command.hBitmap = ResourceHandle.Null;
command.stride = 0;
command.ePixelFormat = 0;
command.hSection = 0;
@@ -2254,20 +2243,20 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_HWNDTARGET_CREATE),
+ sizeof(MILCMD_HWNDTARGET_CREATE),
false /* sendInSeparateBatch */
);
}
}
internal static void ProcessDpiChanged(
- DUCE.ResourceHandle hCompositionTarget,
+ ResourceHandle hCompositionTarget,
DpiScale dpiScale,
bool afterParent,
Channel channel
)
{
- DUCE.MILCMD_HWNDTARGET_DPICHANGED command;
+ MILCMD_HWNDTARGET_DPICHANGED command;
command.Type = MILCMD.MilCmdHwndTargetDpiChanged;
command.Handle = hCompositionTarget;
@@ -2279,20 +2268,20 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_HWNDTARGET_DPICHANGED),
+ sizeof(MILCMD_HWNDTARGET_DPICHANGED),
sendInSeparateBatch: false);
}
}
internal static void PrintInitialize(
- DUCE.ResourceHandle hCompositionTarget,
+ ResourceHandle hCompositionTarget,
IntPtr pRenderTarget,
int nWidth,
int nHeight,
Channel channel
)
{
- DUCE.MILCMD_GENERICTARGET_CREATE command;
+ MILCMD_GENERICTARGET_CREATE command;
command.Type = MILCMD.MilCmdGenericTargetCreate;
command.Handle = hCompositionTarget;
@@ -2306,19 +2295,19 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_GENERICTARGET_CREATE),
+ sizeof(MILCMD_GENERICTARGET_CREATE),
false /* sendInSeparateBatch */
);
}
}
internal static void SetClearColor(
- DUCE.ResourceHandle hCompositionTarget,
+ ResourceHandle hCompositionTarget,
Color color,
Channel channel
)
{
- DUCE.MILCMD_TARGET_SETCLEARCOLOR command;
+ MILCMD_TARGET_SETCLEARCOLOR command;
command.Type = MILCMD.MilCmdTargetSetClearColor;
command.Handle = hCompositionTarget;
@@ -2331,18 +2320,18 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_TARGET_SETCLEARCOLOR)
+ sizeof(MILCMD_TARGET_SETCLEARCOLOR)
);
}
}
internal static void SetRenderingMode(
- DUCE.ResourceHandle hCompositionTarget,
+ ResourceHandle hCompositionTarget,
MILRTInitializationFlags nRenderingMode,
Channel channel
)
{
- DUCE.MILCMD_TARGET_SETFLAGS command;
+ MILCMD_TARGET_SETFLAGS command;
command.Type = MILCMD.MilCmdTargetSetFlags;
command.Handle = hCompositionTarget;
@@ -2352,19 +2341,19 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_TARGET_SETFLAGS)
+ sizeof(MILCMD_TARGET_SETFLAGS)
);
}
}
internal static void SetRoot(
- DUCE.ResourceHandle hCompositionTarget,
- DUCE.ResourceHandle hRoot,
+ ResourceHandle hCompositionTarget,
+ ResourceHandle hRoot,
Channel channel
)
{
- DUCE.MILCMD_TARGET_SETROOT command;
+ MILCMD_TARGET_SETROOT command;
command.Type = MILCMD.MilCmdTargetSetRoot;
command.Handle = hCompositionTarget;
@@ -2374,7 +2363,7 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_TARGET_SETROOT)
+ sizeof(MILCMD_TARGET_SETROOT)
);
}
}
@@ -2394,13 +2383,13 @@ internal static void UpdateWindowSettings(
Channel channel
)
{
- DUCE.MILCMD_TARGET_UPDATEWINDOWSETTINGS command;
+ MILCMD_TARGET_UPDATEWINDOWSETTINGS command;
command.Type = MILCMD.MilCmdTargetUpdateWindowSettings;
command.Handle = hCompositionTarget;
command.renderingEnabled = (uint)(renderingEnabled ? 1 : 0);
- command.disableCookie = (uint) disableCookie;
+ command.disableCookie = (uint)disableCookie;
command.windowRect = windowRect;
@@ -2420,18 +2409,18 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_TARGET_UPDATEWINDOWSETTINGS)
+ sizeof(MILCMD_TARGET_UPDATEWINDOWSETTINGS)
);
}
}
internal static void Invalidate(
- DUCE.ResourceHandle hCompositionTarget,
+ ResourceHandle hCompositionTarget,
ref NativeMethods.RECT pRect,
Channel channel
)
{
- DUCE.MILCMD_TARGET_INVALIDATE command;
+ MILCMD_TARGET_INVALIDATE command;
command.Type = MILCMD.MilCmdTargetInvalidate;
command.Handle = hCompositionTarget;
@@ -2441,7 +2430,7 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_TARGET_INVALIDATE),
+ sizeof(MILCMD_TARGET_INVALIDATE),
false /* sendInSeparateBatch */
);
}
@@ -2460,7 +2449,7 @@ internal static void NotifyPolicyChangeForNonInteractiveMode(
Channel channel
)
{
- var command = new DUCE.MILCMD_PARTITION_NOTIFYPOLICYCHANGEFORNONINTERACTIVEMODE
+ var command = new MILCMD_PARTITION_NOTIFYPOLICYCHANGEFORNONINTERACTIVEMODE
{
Type = MILCMD.MilCmdPartitionNotifyPolicyChangeForNonInteractiveMode,
ShouldRenderEvenWhenNoDisplayDevicesAreAvailable = (forceRender ? 1u : 0u)
@@ -2470,7 +2459,7 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_PARTITION_NOTIFYPOLICYCHANGEFORNONINTERACTIVEMODE),
+ sizeof(MILCMD_PARTITION_NOTIFYPOLICYCHANGEFORNONINTERACTIVEMODE),
sendInSeparateBatch: false
);
}
@@ -2481,12 +2470,12 @@ Channel channel
internal static class ETWEvent
{
internal static void RaiseEvent(
- DUCE.ResourceHandle hEtwEvent,
+ ResourceHandle hEtwEvent,
UInt32 id,
Channel channel
)
{
- DUCE.MILCMD_ETWEVENTRESOURCE command;
+ MILCMD_ETWEVENTRESOURCE command;
command.Type = MILCMD.MilCmdEtwEventResource;
command.Handle = hEtwEvent;
@@ -2496,7 +2485,7 @@ Channel channel
{
channel.SendCommand(
(byte*)&command,
- sizeof(DUCE.MILCMD_ETWEVENTRESOURCE)
+ sizeof(MILCMD_ETWEVENTRESOURCE)
);
}
}
@@ -2508,15 +2497,15 @@ Channel channel
///
internal interface IResource
{
- DUCE.ResourceHandle AddRefOnChannel(Channel channel);
+ ResourceHandle AddRefOnChannel(Channel channel);
int GetChannelCount();
- DUCE.Channel GetChannel(int index);
+ Channel GetChannel(int index);
void ReleaseOnChannel(Channel channel);
- DUCE.ResourceHandle GetHandle(Channel channel);
+ ResourceHandle GetHandle(Channel channel);
///
/// Only Vieport3DVisual and Visual3D implement this.
@@ -2524,7 +2513,7 @@ internal interface IResource
/// and the other one stored in _proxy3D. This function returns
/// the handle stored in _proxy3D.
///
- DUCE.ResourceHandle Get3DHandle(Channel channel);
+ ResourceHandle Get3DHandle(Channel channel);
///
/// Sends a command to compositor to remove the child
@@ -2532,7 +2521,7 @@ internal interface IResource
///
void RemoveChildFromParent(
IResource parent,
- DUCE.Channel channel);
+ Channel channel);
}
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_error.cs b/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_error.cs
deleted file mode 100644
index a0d54aba740..00000000000
--- a/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_error.cs
+++ /dev/null
@@ -1,172 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-//
-
-namespace MS.Internal
-{
- #region Enumeration Types
-
- internal enum WinCodecErrors
- {
- // Range 0x?8982000 - 0x?8982FFF
- WINCODEC_ERR_GENERIC_ERROR = unchecked((int) 0x80004005),
- WINCODEC_ERR_INVALIDPARAMETER = unchecked((int) 0x80000003),
- WINCODEC_ERR_OUTOFMEMORY = unchecked((int) 0x80000002),
- WINCODEC_ERR_NOTIMPLEMENTED = unchecked((int) 0x80000001),
- WINCODEC_ERR_ABORTED = unchecked((int) 0x80004004),
- WINCODEC_ERR_ACCESSDENIED = unchecked((int) 0x80070005),
- WINCODEC_ERR_VALUEOVERFLOW = unchecked((int) 0x80070216),
- WINCODEC_ERR_WRONGSTATE = unchecked((int) 0x88982f04),
- WINCODEC_ERR_VALUEOUTOFRANGE = unchecked((int) 0x88982f05),
- WINCODEC_ERR_UNKNOWNIMAGEFORMAT = unchecked((int) 0x88982f07),
- WINCODEC_ERR_UNSUPPORTEDVERSION = unchecked((int) 0x88982f0B),
- WINCODEC_ERR_NOTINITIALIZED = unchecked((int) 0x88982f0C),
- WINCODEC_ERR_ALREADYLOCKED = unchecked((int) 0x88982f0D),
- WINCODEC_ERR_PROPERTYNOTFOUND = unchecked((int) 0x88982f40),
- WINCODEC_ERR_PROPERTYNOTSUPPORTED = unchecked((int) 0x88982f41),
- WINCODEC_ERR_PROPERTYSIZE = unchecked((int) 0x88982f42),
- WINCODEC_ERR_CODECPRESENT = unchecked((int) 0x88982f43),
- WINCODEC_ERR_CODECNOTHUMBNAIL = unchecked((int) 0x88982f44),
- WINCODEC_ERR_PALETTEUNAVAILABLE = unchecked((int) 0x88982f45),
- WINCODEC_ERR_CODECTOOMANYSCANLINES = unchecked((int) 0x88982f46),
- WINCODEC_ERR_INTERNALERROR = unchecked((int) 0x88982f48),
- WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS = unchecked((int) 0x88982f49),
- WINCODEC_ERR_COMPONENTNOTFOUND = unchecked((int) 0x88982f50),
- WINCODEC_ERR_IMAGESIZEOUTOFRANGE = unchecked((int) 0x88982f51),
- WINCODEC_ERR_TOOMUCHMETADATA = unchecked((int) 0x88982f52),
- WINCODEC_ERR_BADIMAGE = unchecked((int) 0x88982f60),
- WINCODEC_ERR_BADHEADER = unchecked((int) 0x88982f61),
- WINCODEC_ERR_FRAMEMISSING = unchecked((int) 0x88982f62),
- WINCODEC_ERR_BADMETADATAHEADER = unchecked((int) 0x88982f63),
- WINCODEC_ERR_BADSTREAMDATA = unchecked((int) 0x88982f70),
- WINCODEC_ERR_STREAMWRITE = unchecked((int) 0x88982f71),
- WINCODEC_ERR_STREAMREAD = unchecked((int) 0x88982f72),
- WINCODEC_ERR_STREAMNOTAVAILABLE = unchecked((int) 0x88982f73),
- WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT = unchecked((int) 0x88982f80),
- WINCODEC_ERR_UNSUPPORTEDOPERATION = unchecked((int) 0x88982f81),
- WINCODEC_ERR_INVALIDREGISTRATION = unchecked((int) 0x88982f8A),
- WINCODEC_ERR_COMPONENTINITIALIZEFAILURE = unchecked((int) 0x88982f8B),
- WINCODEC_ERR_INSUFFICIENTBUFFER = unchecked((int) 0x88982f8C),
- WINCODEC_ERR_DUPLICATEMETADATAPRESENT = unchecked((int) 0x88982f8D),
- WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE = unchecked((int) 0x88982f8E),
- WINCODEC_ERR_UNEXPECTEDSIZE = unchecked((int) 0x88982f8F),
- WINCODEC_ERR_INVALIDQUERYREQUEST = unchecked((int) 0x88982f90),
- WINCODEC_ERR_UNEXPECTEDMETADATATYPE = unchecked((int) 0x88982f91),
- WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT = unchecked((int) 0x88982f92),
- WINCODEC_ERR_INVALIDQUERYCHARACTER = unchecked((int) 0x88982f93),
- };
-
- internal enum MILErrors
- {
- // Range 0x?8980000 - 0x?8980FFF
- WGXHR_CLIPPEDTOEMPTY = unchecked((int) 0x8980001),
- WGXHR_EMPTYFILL = unchecked((int) 0x8980002),
- WGXHR_INTERNALTEMPORARYSUCCESS = unchecked((int) 0x8980003),
- WGXHR_RESETSHAREDHANDLEMANAGER = unchecked((int) 0x8980004),
- WGXERR_GENERIC_ERROR = unchecked((int) 0x80004005),
- WGXERR_INVALIDPARAMETER = unchecked((int) 0x80000003),
- WGXERR_OUTOFMEMORY = unchecked((int) 0x80000002),
- WGXERR_NOTIMPLEMENTED = unchecked((int) 0x80000001),
- WGXERR_ABORTED = unchecked((int) 0x80004004),
- WGXERR_ACCESSDENIED = unchecked((int) 0x80070005),
- WGXERR_VALUEOVERFLOW = unchecked((int) 0x80070216),
- WGXERR_WRONGSTATE = WinCodecErrors.WINCODEC_ERR_WRONGSTATE,
- WGXERR_UNSUPPORTEDVERSION = WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDVERSION,
- WGXERR_NOTINITIALIZED = WinCodecErrors.WINCODEC_ERR_NOTINITIALIZED,
- WGXERR_UNSUPPORTEDPIXELFORMAT = WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT,
- WGXERR_UNSUPPORTED_OPERATION = WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION,
- WGXERR_PALETTEUNAVAILABLE = WinCodecErrors.WINCODEC_ERR_PALETTEUNAVAILABLE,
- WGXERR_OBJECTBUSY = unchecked((int) 0x88980001),
- WGXERR_INSUFFICIENTBUFFER = unchecked((int) 0x88980002),
- WGXERR_WIN32ERROR = unchecked((int) 0x88980003),
- WGXERR_SCANNER_FAILED = unchecked((int) 0x88980004),
- WGXERR_SCREENACCESSDENIED = unchecked((int) 0x88980005),
- WGXERR_DISPLAYSTATEINVALID = unchecked((int) 0x88980006),
- WGXERR_NONINVERTIBLEMATRIX = unchecked((int) 0x88980007),
- WGXERR_ZEROVECTOR = unchecked((int) 0x88980008),
- WGXERR_TERMINATED = unchecked((int) 0x88980009),
- WGXERR_BADNUMBER = unchecked((int) 0x8898000A),
- WGXERR_INTERNALERROR = unchecked((int) 0x88980080),
- WGXERR_DISPLAYFORMATNOTSUPPORTED = unchecked((int) 0x88980084),
- WGXERR_INVALIDCALL = unchecked((int) 0x88980085),
- WGXERR_ALREADYLOCKED = unchecked((int) 0x88980086),
- WGXERR_NOTLOCKED = unchecked((int) 0x88980087),
- WGXERR_DEVICECANNOTRENDERTEXT = unchecked((int) 0x88980088),
- WGXERR_GLYPHBITMAPMISSED = unchecked((int) 0x88980089),
- WGXERR_MALFORMEDGLYPHCACHE = unchecked((int) 0x8898008A),
- WGXERR_GENERIC_IGNORE = unchecked((int) 0x8898008B),
- WGXERR_MALFORMED_GUIDELINE_DATA = unchecked((int) 0x8898008C),
- WGXERR_NO_HARDWARE_DEVICE = unchecked((int) 0x8898008D),
- WGXERR_NEED_RECREATE_AND_PRESENT = unchecked((int) 0x8898008E),
- WGXERR_ALREADY_INITIALIZED = unchecked((int) 0x8898008F),
- WGXERR_MISMATCHED_SIZE = unchecked((int) 0x88980090),
- WGXERR_NO_REDIRECTION_SURFACE_AVAILABLE = unchecked((int) 0x88980091),
- WGXERR_REMOTING_NOT_SUPPORTED = unchecked((int) 0x88980092),
- WGXERR_QUEUED_PRESENT_NOT_SUPPORTED = unchecked((int) 0x88980093),
- WGXERR_NOT_QUEUING_PRESENTS = unchecked((int) 0x88980094),
- WGXERR_NO_REDIRECTION_SURFACE_RETRY_LATER = unchecked((int) 0x88980095),
- WGXERR_TOOMANYSHADERELEMNTS = unchecked((int) 0x88980096),
- // AVAILABLE = unchecked((int) 0x88980097),
- // AVAILABLE = unchecked((int) 0x88980098),
- WGXERR_SHADER_COMPILE_FAILED = unchecked((int) 0x88980099),
- WGXERR_MAX_TEXTURE_SIZE_EXCEEDED = unchecked((int) 0x8898009A),
- // AVAILABLE = unchecked((int) 0x8898009B),
- WGXERR_UCE_INVALIDPACKETHEADER = unchecked((int) 0x88980400),
- WGXERR_UCE_UNKNOWNPACKET = unchecked((int) 0x88980401),
- WGXERR_UCE_ILLEGALPACKET = unchecked((int) 0x88980402),
- WGXERR_UCE_MALFORMEDPACKET = unchecked((int) 0x88980403),
- WGXERR_UCE_ILLEGALHANDLE = unchecked((int) 0x88980404),
- WGXERR_UCE_HANDLELOOKUPFAILED = unchecked((int) 0x88980405),
- WGXERR_UCE_RENDERTHREADFAILURE = unchecked((int) 0x88980406),
- WGXERR_UCE_CTXSTACKFRSTTARGETNULL = unchecked((int) 0x88980407),
- WGXERR_UCE_CONNECTIONIDLOOKUPFAILED = unchecked((int) 0x88980408),
- WGXERR_UCE_BLOCKSFULL = unchecked((int) 0x88980409),
- WGXERR_UCE_MEMORYFAILURE = unchecked((int) 0x8898040A),
- WGXERR_UCE_PACKETRECORDOUTOFRANGE = unchecked((int) 0x8898040B),
- WGXERR_UCE_ILLEGALRECORDTYPE = unchecked((int) 0x8898040C),
- WGXERR_UCE_OUTOFHANDLES = unchecked((int) 0x8898040D),
- WGXERR_UCE_UNCHANGABLE_UPDATE_ATTEMPTED = unchecked((int) 0x8898040E),
- WGXERR_UCE_NO_MULTIPLE_WORKER_THREADS = unchecked((int) 0x8898040F),
- WGXERR_UCE_REMOTINGNOTSUPPORTED = unchecked((int) 0x88980410),
- WGXERR_UCE_MISSINGENDCOMMAND = unchecked((int) 0x88980411),
- WGXERR_UCE_MISSINGBEGINCOMMAND = unchecked((int) 0x88980412),
- WGXERR_UCE_CHANNELSYNCTIMEDOUT = unchecked((int) 0x88980413),
- WGXERR_UCE_CHANNELSYNCABANDONED = unchecked((int) 0x88980414),
- WGXERR_UCE_UNSUPPORTEDTRANSPORTVERSION = unchecked((int) 0x88980415),
- WGXERR_UCE_TRANSPORTUNAVAILABLE = unchecked((int) 0x88980416),
- WGXERR_UCE_FEEDBACK_UNSUPPORTED = unchecked((int) 0x88980417),
- WGXERR_UCE_COMMANDTRANSPORTDENIED = unchecked((int) 0x88980418),
- WGXERR_UCE_GRAPHICSSTREAMUNAVAILABLE = unchecked((int) 0x88980419),
- WGXERR_UCE_GRAPHICSSTREAMALREADYOPEN = unchecked((int) 0x88980420),
- WGXERR_UCE_TRANSPORTDISCONNECTED = unchecked((int) 0x88980421),
- WGXERR_UCE_TRANSPORTOVERLOADED = unchecked((int) 0x88980422),
- WGXERR_UCE_PARTITION_ZOMBIED = unchecked((int) 0x88980423),
- WGXERR_UCE_USER_SHADEREFFECT_ERROR = unchecked((int) 0x88980424),
- WGXERR_AV_NOCLOCK = unchecked((int) 0x88980500),
- WGXERR_AV_NOMEDIATYPE = unchecked((int) 0x88980501),
- WGXERR_AV_NOVIDEOMIXER = unchecked((int) 0x88980502),
- WGXERR_AV_NOVIDEOPRESENTER = unchecked((int) 0x88980503),
- WGXERR_AV_NOREADYFRAMES = unchecked((int) 0x88980504),
- WGXERR_AV_MODULENOTLOADED = unchecked((int) 0x88980505),
- WGXERR_AV_WMPFACTORYNOTREGISTERED = unchecked((int) 0x88980506),
- WGXERR_AV_INVALIDWMPVERSION = unchecked((int) 0x88980507),
- WGXERR_AV_INSUFFICIENTVIDEORESOURCES = unchecked((int) 0x88980508),
- WGXERR_AV_VIDEOACCELERATIONNOTAVAILABLE = unchecked((int) 0x88980509),
- WGXERR_AV_REQUESTEDTEXTURETOOBIG = unchecked((int) 0x8898050A),
- WGXERR_AV_SEEKFAILED = unchecked((int) 0x8898050B),
- WGXERR_AV_UNEXPECTEDWMPFAILURE = unchecked((int) 0x8898050C),
- WGXERR_AV_MEDIAPLAYERCLOSED = unchecked((int) 0x8898050D),
- WGXERR_AV_UNKNOWNHARDWAREERROR = unchecked((int) 0x8898050E),
- WGXERR_D3DI_INVALIDSURFACEUSAGE = unchecked((int) 0x88980800),
- WGXERR_D3DI_INVALIDSURFACESIZE = unchecked((int) 0x88980801),
- WGXERR_D3DI_INVALIDSURFACEPOOL = unchecked((int) 0x88980802),
- WGXERR_D3DI_INVALIDSURFACEDEVICE = unchecked((int) 0x88980803),
- WGXERR_D3DI_INVALIDANTIALIASINGSETTINGS = unchecked((int) 0x88980804)
- };
-
- #endregion
-}
-
diff --git a/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_exports.cs b/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_exports.cs
index 5c6ea9c459a..9c7c5df379e 100644
--- a/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_exports.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_exports.cs
@@ -1,11 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Runtime.InteropServices;
+using Windows.Win32.Foundation;
namespace MS.Internal
{
@@ -14,13 +14,13 @@ namespace MS.Internal
internal static class MILRenderTargetBitmap
{
[DllImport(DllImport.MilCore, EntryPoint="MILRenderTargetBitmapGetBitmap")]//CASRemoval:
- internal static extern int /*HRESULT*/
+ internal static extern HRESULT
GetBitmap(
SafeMILHandle /* IMILRenderTargetBitmap */ THIS_PTR,
out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap);
[DllImport(DllImport.MilCore, EntryPoint = "MILRenderTargetBitmapClear")]
- internal static extern int /*HRESULT*/
+ internal static extern HRESULT
Clear(
SafeMILHandle /* IMILRenderTargetBitmap */ THIS_PTR);
}
@@ -32,121 +32,121 @@ internal static extern int /*HRESULT*/
internal static class MILMedia
{
[DllImport(DllImport.MilCore, EntryPoint="MILMediaOpen")]
- internal static extern int /* HRESULT */ Open(
+ internal static extern HRESULT Open(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
[In, MarshalAs(UnmanagedType.BStr)] string /* LPOLESTR */ src
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaStop")]//CASRemoval:
- internal static extern int /* HRESULT */ Stop(
+ internal static extern HRESULT Stop(
SafeMediaHandle /* IMILMedia */ THIS_PTR
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaClose")]//CASRemoval:
- internal static extern int /*HRESULT */ Close(
+ internal static extern HRESULT Close(
SafeMediaHandle /* IMILMedia */ THIS_PTR
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaGetPosition")]//CASRemoval:
- internal static extern int /* HRESULT */ GetPosition(
+ internal static extern HRESULT GetPosition(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref long pllTime);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaSetPosition")]//CASRemoval:
- internal static extern int /* HRESULT */ SetPosition(
+ internal static extern HRESULT SetPosition(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
long llTime);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaSetVolume")]//CASRemoval:
- internal static extern int /* HRESULT */ SetVolume(
+ internal static extern HRESULT SetVolume(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
double dblVolume
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaSetBalance")]
- internal static extern int /* HRESULT */ SetBalance(
+ internal static extern HRESULT SetBalance(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
double dblBalance
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaSetIsScrubbingEnabled")]
- internal static extern int /* HRESULT */ SetIsScrubbingEnabled(
+ internal static extern HRESULT SetIsScrubbingEnabled(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
bool isScrubbingEnabled
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaIsBuffering")]//CASRemoval:
- internal static extern int /* HRESULT */ IsBuffering(
+ internal static extern HRESULT IsBuffering(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref bool pIsBuffering
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaCanPause")]//CASRemoval:
- internal static extern int /* HRESULT */ CanPause(
+ internal static extern HRESULT CanPause(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref bool pCanPause
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaGetDownloadProgress")]//CASRemoval:
- internal static extern int /* HRESULT */ GetDownloadProgress(
+ internal static extern HRESULT GetDownloadProgress(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref double pProgress
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaGetBufferingProgress")]//CASRemoval:
- internal static extern int /* HRESULT */ GetBufferingProgress(
+ internal static extern HRESULT GetBufferingProgress(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref double pProgress
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaSetRate")]//CASRemoval:
- internal static extern int /* HRESULT */ SetRate(
+ internal static extern HRESULT SetRate(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
double dblRate
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaHasVideo")]//CASRemoval:
- internal static extern int /* HRESULT */ HasVideo(
+ internal static extern HRESULT HasVideo(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref bool pfHasVideo
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaHasAudio")]//CASRemoval:
- internal static extern int /* HRESULT */ HasAudio(
+ internal static extern HRESULT HasAudio(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref bool pfHasAudio
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaGetNaturalHeight")]//CASRemoval:
- internal static extern int /* HRESULT */ GetNaturalHeight(
+ internal static extern HRESULT GetNaturalHeight(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref UInt32 puiHeight
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaGetNaturalWidth")]//CASRemoval:
- internal static extern int /* HRESULT */ GetNaturalWidth(
+ internal static extern HRESULT GetNaturalWidth(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref UInt32 puiWidth
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaGetMediaLength")]//CASRemoval:
- internal static extern int /* HRESULT */ GetMediaLength(
+ internal static extern HRESULT GetMediaLength(
SafeMediaHandle /* IMILMedia */ THIS_PTR,
ref long pllLength
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaNeedUIFrameUpdate")]
- internal static extern int /* HRESULT */ NeedUIFrameUpdate(
+ internal static extern HRESULT NeedUIFrameUpdate(
SafeMediaHandle /* IMILMedia */ THIS_PTR
);
[DllImport(DllImport.MilCore, EntryPoint="MILMediaShutdown")]//CASRemoval:
- internal static extern int /* HRESULT */ Shutdown(
+ internal static extern HRESULT Shutdown(
IntPtr /* IMILMedia */ THIS_PTR
);
[DllImport(DllImport.MilCore, EntryPoint = "MILMediaProcessExitHandler")]
- internal static extern int /*HRESULT*/ ProcessExitHandler(
+ internal static extern HRESULT ProcessExitHandler(
SafeMediaHandle /* IMILMedia */ THIS_PTR
);
}
@@ -156,7 +156,7 @@ ref long pllLength
internal static class MILSwDoubleBufferedBitmap
{
[DllImport(DllImport.MilCore, EntryPoint = "MILSwDoubleBufferedBitmapCreate")]
- internal static extern int /* HRESULT */ Create(
+ internal static extern HRESULT Create(
uint width,
uint height,
double dpiX,
@@ -179,7 +179,7 @@ ref Int32Rect dirtyRect
);
[DllImport(DllImport.MilCore, EntryPoint = "MILSwDoubleBufferedBitmapProtectBackBuffer")]
- internal static extern int /* HRESULT */ ProtectBackBuffer(
+ internal static extern HRESULT ProtectBackBuffer(
SafeMILHandle /* CSwDoubleBufferedBitmap */ THIS_PTR
);
}
@@ -192,7 +192,7 @@ ref Int32Rect dirtyRect
internal static class MILUpdateSystemParametersInfo
{
[DllImport(DllImport.MilCore, EntryPoint="MILUpdateSystemParametersInfo")]
- internal static extern int /* HRESULT */
+ internal static extern HRESULT
Update();
}
#endregion
diff --git a/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_render.cs b/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_render.cs
index 9a92a0dbb05..5edf714dd35 100644
--- a/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_render.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Common/Graphics/wgx_render.cs
@@ -1,28 +1,8 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation 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 MS.Internal
{
- #region Enumeration Types
-
- internal enum NtStatusErrors
- {
- NT_STATUS_NO_MEMORY = unchecked((int)0xC0000017)
- }
-
- internal enum MediaPlayerErrors
- {
- NS_E_WMP_LOGON_FAILURE = unchecked((int)0xC00D1196L),
- NS_E_WMP_CANNOT_FIND_FILE = unchecked((int)0xC00D1197L),
- NS_E_WMP_UNSUPPORTED_FORMAT = unchecked((int)0xC00D1199L),
- NS_E_WMP_DSHOW_UNSUPPORTED_FORMAT = unchecked((int)0xC00D119AL),
- NS_E_WMP_INVALID_ASX = unchecked((int)0xC00D119DL),
- NS_E_WMP_URLDOWNLOADFAILED = unchecked((int)0xC00D0FEAL),
- }
-
internal enum LockFlags
{
MIL_LOCK_READ = 0x00000001,
@@ -320,299 +300,6 @@ internal enum WICPaletteType
WICPaletteTypeFixedGray256 = 12
};
- internal enum MILCompoundStyle
- {
- MILCompoundStyleSingle = 0,
- MILCompoundStyleDouble = 1,
- MILCompoundStyleTriple = 2,
- MILCompoundStyleCustom = 3,
- MILCOMPOUNDSTYLE_FORCE_DWORD = 0x7FFFFFFF // MIL_FORCE_DWORD
- }
-
- internal enum MILLineJoin
- {
- MILLineJoinMiter = 0,
- MILLineJoinBevel = 1,
- MILLineJoinRound = 2,
- MILLineJoinMiterClipped = 3,
- MILLINEJOIN_FORCE_DWORD = 0x7FFFFFFF // MIL_FORCE_DWORD
- }
-
-
- internal enum MILDashStyle
- {
- MILDashStyleSolid = 0,
- MILDashStyleDash = 1,
- MILDashStyleDot = 2,
- MILDashStyleDashDot = 3,
- MILDashStyleDashDotDot = 4,
- MILDashStyleCustom = 5,
- MILDASHSTYLE_FORCE_DWORD = 0x7FFFFFFF // MIL_FORCE_DWORD
- }
-
- internal enum MILPropTypes
- {
- MILPropertyItemTypeInvalid = 0,
- MILPropertyItemTypeByte = 1,
- MILPropertyItemTypeASCII = 2,
- MILPropertyItemTypeWord = 3,
- MILPropertyItemTypeLong = 4,
- MILPropertyItemTypeRational = 5,
- MILPropertyItemTypeUndefined = 7,
- MILPropertyItemTypeSLong = 9,
- MILPropertyItemTypeSRational = 10,
-
- MILPropertyItemTypeMax = 0xFFFF,
- }
-
- internal enum MILPropIDs: uint
- {
- MILPropertyItemIdInvalid = 0x0,
- MILPropertyItemIdNewSubfileType = 0x00FE,
- MILPropertyItemIdSubfileType = 0x00FF,
- MILPropertyItemIdImageWidth = 0x0100,
- MILPropertyItemIdImageHeight = 0x0101,
- MILPropertyItemIdBitsPerSample = 0x0102,
- MILPropertyItemIdCompression = 0x0103,
- MILPropertyItemIdPhotometricInterp = 0x0106,
- MILPropertyItemIdThreshHolding = 0x0107,
- MILPropertyItemIdCellWidth = 0x0108,
- MILPropertyItemIdCellHeight = 0x0109,
- MILPropertyItemIdFillOrder = 0x010A,
- MILPropertyItemIdDocumentName = 0x010D,
- MILPropertyItemIdImageDescription = 0x010E,
- MILPropertyItemIdEquipMake = 0x010F,
- MILPropertyItemIdEquipModel = 0x0110,
- MILPropertyItemIdStripOffsets = 0x0111,
- MILPropertyItemIdOrientation = 0x0112,
- MILPropertyItemIdSamplesPerPixel = 0x0115,
- MILPropertyItemIdRowsPerStrip = 0x0116,
- MILPropertyItemIdStripBytesCount = 0x0117,
- MILPropertyItemIdMinSampleValue = 0x0118,
- MILPropertyItemIdMaxSampleValue = 0x0119,
- MILPropertyItemIdXResolution = 0x011A,
- MILPropertyItemIdYResolution = 0x011B,
- MILPropertyItemIdPlanarConfig = 0x011C,
- MILPropertyItemIdPageName = 0x011D,
- MILPropertyItemIdXPosition = 0x011E,
- MILPropertyItemIdYPosition = 0x011F,
- MILPropertyItemIdFreeOffset = 0x0120,
- MILPropertyItemIdFreeByteCounts = 0x0121,
- MILPropertyItemIdGrayResponseUnit = 0x0122,
- MILPropertyItemIdGrayResponseCurve = 0x0123,
- MILPropertyItemIdT4Option = 0x0124,
- MILPropertyItemIdT6Option = 0x0125,
- MILPropertyItemIdResolutionUnit = 0x0128,
- MILPropertyItemIdPageNumber = 0x0129,
- MILPropertyItemIdTransferFuncition = 0x012D,
- MILPropertyItemIdSoftwareUsed = 0x0131,
- MILPropertyItemIdDateTime = 0x0132,
- MILPropertyItemIdArtist = 0x013B,
- MILPropertyItemIdHostComputer = 0x013C,
- MILPropertyItemIdPredictor = 0x013D,
- MILPropertyItemIdWhitePoint = 0x013E,
- MILPropertyItemIdPrimaryChromaticities = 0x013F,
- MILPropertyItemIdColorMap = 0x0140,
- MILPropertyItemIdHalftoneHints = 0x0141,
- MILPropertyItemIdTileWidth = 0x0142,
- MILPropertyItemIdTileLength = 0x0143,
- MILPropertyItemIdTileOffset = 0x0144,
- MILPropertyItemIdTileByteCounts = 0x0145,
- MILPropertyItemIdInkSet = 0x014C,
- MILPropertyItemIdInkNames = 0x014D,
- MILPropertyItemIdNumberOfInks = 0x014E,
- MILPropertyItemIdDotRange = 0x0150,
- MILPropertyItemIdTargetPrinter = 0x0151,
- MILPropertyItemIdExtraSamples = 0x0152,
- MILPropertyItemIdSampleFormat = 0x0153,
- MILPropertyItemIdSMinSampleValue = 0x0154,
- MILPropertyItemIdSMaxSampleValue = 0x0155,
- MILPropertyItemIdTransferRange = 0x0156,
- MILPropertyItemIdScreenWidth = 0x0157,
- MILPropertyItemIdScreenHeight = 0x0158,
-
- MILPropertyItemIdJPEGProc = 0x0200,
- MILPropertyItemIdJPEGInterFormat = 0x0201,
- MILPropertyItemIdJPEGInterLength = 0x0202,
- MILPropertyItemIdJPEGRestartInterval = 0x0203,
- MILPropertyItemIdJPEGLosslessPredictors = 0x0205,
- MILPropertyItemIdJPEGPointTransforms = 0x0206,
- MILPropertyItemIdJPEGQTables = 0x0207,
- MILPropertyItemIdJPEGDCTables = 0x0208,
- MILPropertyItemIdJPEGACTables = 0x0209,
- MILPropertyItemIdYCbCrCoefficients = 0x0211,
- MILPropertyItemIdYCbCrSubsampling = 0x0212,
- MILPropertyItemIdYCbCrPositioning = 0x0213,
- MILPropertyItemIdREFBlackWhite = 0x0214,
- MILPropertyItemIdInterlaced = 0x0215,
-
- MILPropertyItemIdGamma = 0x0301,
- MILPropertyItemIdICCProfileDescriptor = 0x0302,
- MILPropertyItemIdSRGBRenderingIntent = 0x0303,
- MILPropertyItemIdICCProfile = 0x8773,
-
- MILPropertyItemIdImageTitle = 0x0320,
- MILPropertyItemIdCopyright = 0x8298,
-
- // Extra IDs (Like Adobe Image Information ids etc.)
-
- MILPropertyItemIdResolutionXUnit = 0x5001,
- MILPropertyItemIdResolutionYUnit = 0x5002,
- MILPropertyItemIdResolutionXLengthUnit = 0x5003,
- MILPropertyItemIdResolutionYLengthUnit = 0x5004,
- MILPropertyItemIdPrintFlags = 0x5005,
- MILPropertyItemIdPrintFlagsVersion = 0x5006,
- MILPropertyItemIdPrintFlagsCrop = 0x5007,
- MILPropertyItemIdPrintFlagsBleedWidth = 0x5008,
- MILPropertyItemIdPrintFlagsBleedWidthScale = 0x5009,
- MILPropertyItemIdHalftoneLPI = 0x500A,
- MILPropertyItemIdHalftoneLPIUnit = 0x500B,
- MILPropertyItemIdHalftoneDegree = 0x500C,
- MILPropertyItemIdHalftoneShape = 0x500D,
- MILPropertyItemIdHalftoneMisc = 0x500E,
- MILPropertyItemIdHalftoneScreen = 0x500F,
- MILPropertyItemIdJPEGQuality = 0x5010,
- MILPropertyItemIdGridSize = 0x5011,
- MILPropertyItemIdThumbnailFormat = 0x5012,
- MILPropertyItemIdThumbnailWidth = 0x5013,
- MILPropertyItemIdThumbnailHeight = 0x5014,
- MILPropertyItemIdThumbnailColorDepth = 0x5015,
- MILPropertyItemIdThumbnailPlanes = 0x5016,
- MILPropertyItemIdThumbnailRawBytes = 0x5017,
- MILPropertyItemIdThumbnailSize = 0x5018,
- MILPropertyItemIdThumbnailCompressedSize = 0x5019,
- MILPropertyItemIdColorTransferFunction = 0x501A,
- MILPropertyItemIdThumbnailData = 0x501B,
-
- // Thumbnail related ids
-
- MILPropertyItemIdThumbnailImageWidth = 0x5020,
- MILPropertyItemIdThumbnailImageHeight = 0x5021,
- MILPropertyItemIdThumbnailBitsPerSample = 0x5022,
- MILPropertyItemIdThumbnailCompression = 0x5023,
- MILPropertyItemIdThumbnailPhotometricInterp = 0x5024,
- MILPropertyItemIdThumbnailImageDescription = 0x5025,
- MILPropertyItemIdThumbnailEquipMake = 0x5026,
- MILPropertyItemIdThumbnailEquipModel = 0x5027,
- MILPropertyItemIdThumbnailStripOffsets = 0x5028,
- MILPropertyItemIdThumbnailOrientation = 0x5029,
- MILPropertyItemIdThumbnailSamplesPerPixel = 0x502A,
- MILPropertyItemIdThumbnailRowsPerStrip = 0x502B,
- MILPropertyItemIdThumbnailStripBytesCount = 0x502C,
- MILPropertyItemIdThumbnailResolutionX = 0x502D,
- MILPropertyItemIdThumbnailResolutionY = 0x502E,
- MILPropertyItemIdThumbnailPlanarConfig = 0x502F,
- MILPropertyItemIdThumbnailResolutionUnit = 0x5030,
- MILPropertyItemIdThumbnailTransferFunction = 0x5031,
- MILPropertyItemIdThumbnailSoftwareUsed = 0x5032,
- MILPropertyItemIdThumbnailDateTime = 0x5033,
- MILPropertyItemIdThumbnailArtist = 0x5034,
- MILPropertyItemIdThumbnailWhitePoint = 0x5035,
- MILPropertyItemIdThumbnailPrimaryChromaticities = 0x5036,
- MILPropertyItemIdThumbnailYCbCrCoefficients = 0x5037,
- MILPropertyItemIdThumbnailYCbCrSubsampling = 0x5038,
- MILPropertyItemIdThumbnailYCbCrPositioning = 0x5039,
- MILPropertyItemIdThumbnailRefBlackWhite = 0x503A,
- MILPropertyItemIdThumbnailCopyRight = 0x503B,
-
- MILPropertyItemIdLuminanceTable = 0x5090,
- MILPropertyItemIdChrominanceTable = 0x5091,
- MILPropertyItemIdFrameDelay = 0x5100,
- MILPropertyItemIdLoopCount = 0x5101,
- MILPropertyItemIdGlobalPalette = 0x5102,
- MILPropertyItemIdIndexBackground = 0x5103,
- MILPropertyItemIdIndexTransparent = 0x5104,
-
- MILPropertyItemIdPixelUnit = 0x5110,
- MILPropertyItemIdPixelPerUnitX = 0x5111,
- MILPropertyItemIdPixelPerUnitY = 0x5112,
- MILPropertyItemIdPaletteHistogram = 0x5113,
-
- // EXIF specific ids
- MILPropertyItemIdExifIFD = 0x8769,
- MILPropertyItemIdExifExposureTime = 0x829A,
- MILPropertyItemIdExifFNumber = 0x829D,
- MILPropertyItemIdExifExposureProg = 0x8822,
- MILPropertyItemIdExifSpectralSense = 0x8824,
- MILPropertyItemIdExifISOSpeed = 0x8827,
- MILPropertyItemIdExifOECF = 0x8828,
- MILPropertyItemIdExifVer = 0x9000,
- MILPropertyItemIdExifDTOrig = 0x9003,
- MILPropertyItemIdExifDTDigitized = 0x9004,
- MILPropertyItemIdExifCompConfig = 0x9101,
- MILPropertyItemIdExifCompBPP = 0x9102,
- MILPropertyItemIdExifShutterSpeed = 0x9201,
- MILPropertyItemIdExifAperture = 0x9202,
- MILPropertyItemIdExifBrightness = 0x9203,
- MILPropertyItemIdExifExposureBias = 0x9204,
- MILPropertyItemIdExifMaxAperture = 0x9205,
- MILPropertyItemIdExifSubjectDist = 0x9206,
- MILPropertyItemIdExifMeteringMode = 0x9207,
- MILPropertyItemIdExifLightSource = 0x9208,
- MILPropertyItemIdExifFlash = 0x9209,
- MILPropertyItemIdExifFocalLength = 0x920A,
- MILPropertyItemIdExifMakerNote = 0x927C,
- MILPropertyItemIdExifUserComment = 0x9286,
- MILPropertyItemIdExifDTSubsec = 0x9290,
- MILPropertyItemIdExifDTOrigSS = 0x9291,
- MILPropertyItemIdExifDTDigSS = 0x9292,
- MILPropertyItemIdExifFPXVer = 0xA000,
- MILPropertyItemIdExifColorSpace = 0xA001,
- MILPropertyItemIdExifPixXDim = 0xA002,
- MILPropertyItemIdExifPixYDim = 0xA003,
- MILPropertyItemIdExifRelatedWav = 0xA004,
- MILPropertyItemIdExifInterop = 0xA005,
- MILPropertyItemIdExifFlashEnergy = 0xA20B,
- MILPropertyItemIdExifSpatialFR = 0xA20C,
- MILPropertyItemIdExifFocalXRes = 0xA20E,
- MILPropertyItemIdExifFocalYRes = 0xA20F,
- MILPropertyItemIdExifFocalResUnit = 0xA210,
- MILPropertyItemIdExifSubjectLoc = 0xA214,
- MILPropertyItemIdExifExposureIndex = 0xA215,
- MILPropertyItemIdExifSensingMethod = 0xA217,
- MILPropertyItemIdExifFileSource = 0xA300,
- MILPropertyItemIdExifSceneType = 0xA301,
- MILPropertyItemIdExifCfaPattern = 0xA302,
-
- MILPropertyItemIdMax = 0xFFFF
- };
-
- internal enum ChildType
- {
- eCOB = 0x0,
- eCOBGROUP = 0x1,
- eChildLast = 0x2
- };
-
- enum MILResourceType
- {
- eMILResourceVideo = 0,
- eMILCOB = 1,
- eMILChain = 2,
- eMILTarget = 3,
- eMILResource = 4,
- eMILResourceLast = 5
- };
-
- enum MILAVInstructionType
- {
- eAVPlay = 0,
- eAVStop,
- eAVPause,
- eAVResume,
- eAVSetSeek,
- eAVGetVolume,
- eAVSetVolume,
- eAVGetState,
- eAVHasVideo,
- eAVHasAudio,
- eAVWidth,
- eAVHeight,
- eAVMediaLength
- };
- #endregion
-
- #region Structures
///
/// Transform options when doing a lossless JPEG image save
///
@@ -644,368 +331,4 @@ internal enum WICBitmapTransformOptions
///
WICBitmapTransformFlipVertical = 0x10
}
-
- internal enum WICComponentType
- {
- WICDecoder = 0x00000001,
- WICEncoder = 0x00000002,
- WICFormat = 0x00000004,
- WICFormatConverter = 0x00000008,
- WICMetadataReader = 0x00000010,
- WICMetadataWriter = 0x00000020
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct WICBitmapPattern
- {
- Int64 Offset;
- UInt32 Length;
- IntPtr Pattern;
- IntPtr Mask;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct MILBitmapItem
- {
- uint Size;
- IntPtr Desc;
- uint DescSize;
- IntPtr Data;
- uint DataSize;
- uint Cookie;
- };
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct BitmapTransformCaps
- {
- // Size of this structure.
-
- int nSize;
-
- // minimum number of inputs required.
-
- int cMinInputs;
-
- // maximum number of inputs that will be processed.
-
- int cMaxInputs;
-
- // Set to false requires all the inputs and the
- // output to have the same pixel format determined
- // by calling IsPixelFormatSupported() for any
- // index. Set to true allows different input/output
- // pixel formats.
-
- [MarshalAs(UnmanagedType.Bool)] bool fSupportMultiFormat;
-
- // Supports auxilliary data out.
-
- [MarshalAs(UnmanagedType.Bool)] bool fAuxiliaryData;
-
- // TRUE if the effect supports multiple output
-
- [MarshalAs(UnmanagedType.Bool)] bool fSupportMultiOutput;
-
- // TRUE if the effect can provide output band by band
-
- [MarshalAs(UnmanagedType.Bool)] bool fSupportBanding;
-
- // TRUE if the effect supports multi-resolution
-
- [MarshalAs(UnmanagedType.Bool)] bool fSupportMultiResolution;
-};
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct HWND
- {
- public int hwnd;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct MILAVInstruction
- {
- internal IntPtr m_pMedia;
- internal MILAVInstructionType m_instType;
- internal nested_u u;
-
- [StructLayout(LayoutKind.Explicit)]
- internal struct nested_u
- {
- [FieldOffset(0)] [MarshalAs(UnmanagedType.Bool)] internal bool m_fValue;
- [FieldOffset(0)] internal double m_dblValue;
- [FieldOffset(0)] internal int m_iValue;
- [FieldOffset(0)] internal long m_lValue;
- [FieldOffset(0)] internal float m_flValue;
- };
-};
-
- #endregion
-
- #region HRESULT
- ///
- /// HRESULT
- ///
- ///
- // [StructLayout(LayoutKind.Sequential)]
- internal struct HRESULT
- {
- // NTSTATUS error codes are converted to HRESULT by ORing the FACILITY_NT_BIT
- // into the status code.
- internal const int FACILITY_NT_BIT = 0x10000000;
-
- internal const int FACILITY_MASK = 0x7FFF0000;
-
- internal const int FACILITY_WINCODEC_ERROR = 0x08980000;
-
- internal const int COMPONENT_MASK = 0x0000E000;
-
- internal const int COMPONENT_WINCODEC_ERROR = 0x00002000;
-
- internal static bool IsWindowsCodecError(int hr)
- {
- return (hr & (FACILITY_MASK | COMPONENT_MASK)) == (FACILITY_WINCODEC_ERROR | COMPONENT_WINCODEC_ERROR);
- }
-
- ///
- /// If the result is not a success, then throw the appropriate exception.
- ///
- ///
- ///
- internal static Exception ConvertHRToException(int hr)
- {
- Exception exceptionForHR = Marshal.GetExceptionForHR(hr, (IntPtr)(-1));
-
- if ((hr & FACILITY_NT_BIT) == FACILITY_NT_BIT)
- {
- // Convert HRESULT to NTSTATUS code.
- switch(hr & ~FACILITY_NT_BIT)
- {
- case (int) NtStatusErrors.NT_STATUS_NO_MEMORY:
- return new OutOfMemoryException();
-
- default:
- return exceptionForHR;
- }
- }
- else
- {
- switch (hr)
- {
- case (int) NtStatusErrors.NT_STATUS_NO_MEMORY:
- return new System.OutOfMemoryException();
-
- case (int)WinCodecErrors.WINCODEC_ERR_WRONGSTATE:
- return new System.InvalidOperationException(SR.Image_WrongState, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_VALUEOUTOFRANGE:
- case (int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW:
- return new System.OverflowException(SR.Image_Overflow, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_UNKNOWNIMAGEFORMAT:
- return new System.IO.FileFormatException(null, SR.Image_UnknownFormat, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDVERSION:
- return new System.IO.FileLoadException(SR.MilErr_UnsupportedVersion, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_NOTINITIALIZED:
- return new System.InvalidOperationException(SR.WIC_NotInitialized, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_PROPERTYNOTFOUND:
- return new System.ArgumentException(SR.Image_PropertyNotFound, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_PROPERTYNOTSUPPORTED:
- return new System.NotSupportedException(SR.Image_PropertyNotSupported, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_PROPERTYSIZE:
- return new System.ArgumentException(SR.Image_PropertySize, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_CODECPRESENT:
- return new System.InvalidOperationException(SR.Image_CodecPresent, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_CODECNOTHUMBNAIL:
- return new System.NotSupportedException(SR.Image_NoThumbnail, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_PALETTEUNAVAILABLE:
- return new System.InvalidOperationException(SR.Image_NoPalette, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_CODECTOOMANYSCANLINES:
- return new System.ArgumentException(SR.Image_TooManyScanlines, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_INTERNALERROR:
- return new System.InvalidOperationException(SR.Image_InternalError, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS:
- return new System.ArgumentException(SR.Image_BadDimensions, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_COMPONENTINITIALIZEFAILURE:
- case (int)WinCodecErrors.WINCODEC_ERR_COMPONENTNOTFOUND:
- return new System.NotSupportedException(SR.Image_ComponentNotFound, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_UNEXPECTEDSIZE:
- case (int)WinCodecErrors.WINCODEC_ERR_BADIMAGE: // error decoding image file
- return new System.IO.FileFormatException(null, SR.Image_DecoderError, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_BADHEADER: // error decoding header
- return new System.IO.FileFormatException(null, SR.Image_HeaderError, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_FRAMEMISSING:
- return new System.ArgumentException(SR.Image_FrameMissing, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_BADMETADATAHEADER:
- return new System.ArgumentException(SR.Image_BadMetadataHeader, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_BADSTREAMDATA:
- return new System.ArgumentException(SR.Image_BadStreamData, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_STREAMWRITE:
- return new System.InvalidOperationException(SR.Image_StreamWrite, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT:
- return new System.NotSupportedException(SR.Image_UnsupportedPixelFormat, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION:
- return new System.NotSupportedException(SR.Image_UnsupportedOperation, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_IMAGESIZEOUTOFRANGE:
- return new System.ArgumentException(SR.Image_SizeOutOfRange, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_STREAMREAD:
- return new System.IO.IOException(SR.Image_StreamRead, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_INVALIDQUERYREQUEST:
- return new System.IO.IOException(SR.Image_InvalidQueryRequest, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_UNEXPECTEDMETADATATYPE:
- return new System.IO.FileFormatException(null, SR.Image_UnexpectedMetadataType, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT:
- return new System.IO.FileFormatException(null, SR.Image_RequestOnlyValidAtMetadataRoot, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_INVALIDQUERYCHARACTER:
- return new System.IO.IOException(SR.Image_InvalidQueryCharacter, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_DUPLICATEMETADATAPRESENT:
- return new System.IO.FileFormatException(null, SR.Image_DuplicateMetadataPresent, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE:
- return new System.IO.FileFormatException(null, SR.Image_PropertyUnexpectedType, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_TOOMUCHMETADATA:
- return new System.IO.FileFormatException(null, SR.Image_TooMuchMetadata, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_STREAMNOTAVAILABLE:
- return new System.NotSupportedException(SR.Image_StreamNotAvailable, exceptionForHR);
-
- case (int)WinCodecErrors.WINCODEC_ERR_INSUFFICIENTBUFFER:
- return new System.ArgumentException(SR.Image_InsufficientBuffer, exceptionForHR);
-
- case unchecked((int)0x80070057):
- return new System.ArgumentException(SR.Format(SR.Media_InvalidArgument, null), exceptionForHR);
-
- case unchecked((int)0x800707db):
- return new System.IO.FileFormatException(null, SR.Image_InvalidColorContext, exceptionForHR);
-
- case (int)MILErrors.WGXERR_DISPLAYSTATEINVALID:
- return new System.InvalidOperationException(SR.Image_DisplayStateInvalid, exceptionForHR);
-
- case (int)MILErrors.WGXERR_NONINVERTIBLEMATRIX:
- return new System.ArithmeticException(SR.Image_SingularMatrix, exceptionForHR);
-
- case (int)MILErrors.WGXERR_AV_INVALIDWMPVERSION:
- return new System.Windows.Media.InvalidWmpVersionException(SR.Format(SR.Media_InvalidWmpVersion, null), exceptionForHR);
-
- case (int)MILErrors.WGXERR_AV_INSUFFICIENTVIDEORESOURCES:
- return new System.NotSupportedException(SR.Format(SR.Media_InsufficientVideoResources, null), exceptionForHR);
-
- case (int)MILErrors.WGXERR_AV_VIDEOACCELERATIONNOTAVAILABLE:
- return new System.NotSupportedException(SR.Format(SR.Media_HardwareVideoAccelerationNotAvailable, null), exceptionForHR);
-
- case (int)MILErrors.WGXERR_AV_MEDIAPLAYERCLOSED:
- return new System.NotSupportedException(SR.Format(SR.Media_PlayerIsClosed, null), exceptionForHR);
-
- case (int)MediaPlayerErrors.NS_E_WMP_URLDOWNLOADFAILED:
- return new System.IO.FileNotFoundException(SR.Format(SR.Media_DownloadFailed, null), exceptionForHR);
-
- case (int)MediaPlayerErrors.NS_E_WMP_LOGON_FAILURE:
- return new System.Security.SecurityException(SR.Media_LogonFailure, exceptionForHR);
-
- case (int)MediaPlayerErrors.NS_E_WMP_CANNOT_FIND_FILE:
- return new System.IO.FileNotFoundException(SR.Media_FileNotFound, exceptionForHR);
-
- case (int)MediaPlayerErrors.NS_E_WMP_UNSUPPORTED_FORMAT:
- case (int)MediaPlayerErrors.NS_E_WMP_DSHOW_UNSUPPORTED_FORMAT:
- return new System.IO.FileFormatException(SR.Media_FileFormatNotSupported, exceptionForHR);
-
- case (int)MediaPlayerErrors.NS_E_WMP_INVALID_ASX:
- return new System.IO.FileFormatException(SR.Media_PlaylistFormatNotSupported, exceptionForHR);
-
- case (int)MILErrors.WGXERR_BADNUMBER:
- return new System.ArithmeticException(SR.Geometry_BadNumber, exceptionForHR);
-
- case (int)MILErrors.WGXERR_D3DI_INVALIDSURFACEUSAGE:
- return new System.ArgumentException(SR.D3DImage_InvalidUsage, exceptionForHR);
- case (int)MILErrors.WGXERR_D3DI_INVALIDSURFACESIZE:
- return new System.ArgumentException(SR.D3DImage_SurfaceTooBig, exceptionForHR);
- case (int)MILErrors.WGXERR_D3DI_INVALIDSURFACEPOOL:
- return new System.ArgumentException(SR.D3DImage_InvalidPool, exceptionForHR);
- case (int)MILErrors.WGXERR_D3DI_INVALIDSURFACEDEVICE:
- return new System.ArgumentException(SR.D3DImage_InvalidDevice, exceptionForHR);
- case (int)MILErrors.WGXERR_D3DI_INVALIDANTIALIASINGSETTINGS:
- return new System.ArgumentException(SR.D3DImage_AARequires9Ex, exceptionForHR);
-
- default:
- return exceptionForHR;
- }
- }
- }
-
- ///
- /// If the result is not a success, then throw the appropriate exception.
- ///
- ///
- ///
- public static void Check(int hr)
- {
- if (hr >= 0)
- {
- // The call succeeded, don't bother calling Marshal.ThrowExceptionForHr
- return;
- }
- else
- {
- throw ConvertHRToException(hr);
- }
- }
-
- ///
- /// HRESULT succeeded.
- ///
- ///
- public static bool Succeeded(int hr)
- {
- if (hr >= 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- ///
- /// HRESULT succeeded.
- ///
- ///
- public static bool Failed(int hr)
- {
- return !(HRESULT.Succeeded(hr));
- }
-
- internal const int S_OK = 0;
- internal const int E_FAIL = unchecked((int)0x80004005);
- internal const int E_OUTOFMEMORY = unchecked((int)0x8007000E);
- internal const int D3DERR_OUTOFVIDEOMEMORY = unchecked((int)0x8876017C);
- }
- #endregion
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/Win32/UnsafeNativeMethodsTablet.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/Win32/UnsafeNativeMethodsTablet.cs
index 937f03fefb2..17dfd1f032c 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/Win32/UnsafeNativeMethodsTablet.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/Win32/UnsafeNativeMethodsTablet.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -6,6 +6,7 @@
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Ink;
+using Windows.Win32.Foundation;
namespace MS.Win32.Recognizer
{
@@ -15,50 +16,48 @@ namespace MS.Win32.Recognizer
internal static class UnsafeNativeMethods
{
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int CreateRecognizer([In] ref Guid clsid, [Out] out RecognizerSafeHandle hRec);
+ internal static extern HRESULT CreateRecognizer([In] ref Guid clsid, [Out] out RecognizerSafeHandle hRec);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int DestroyRecognizer([In] IntPtr hRec);
+ internal static extern HRESULT DestroyRecognizer([In] IntPtr hRec);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int CreateContext([In] RecognizerSafeHandle hRec, [Out] out ContextSafeHandle hRecContext);
+ internal static extern HRESULT CreateContext([In] RecognizerSafeHandle hRec, [Out] out ContextSafeHandle hRecContext);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int DestroyContext([In] IntPtr hRecContext);
+ internal static extern HRESULT DestroyContext([In] IntPtr hRecContext);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int AddStroke([In] ContextSafeHandle hRecContext, [In] ref PACKET_DESCRIPTION packetDesc, [In] uint cbPackets, [In] IntPtr pByte, [In, MarshalAs(UnmanagedType.LPStruct)] NativeMethods.XFORM xForm);
+ internal static extern HRESULT AddStroke([In] ContextSafeHandle hRecContext, [In] ref PACKET_DESCRIPTION packetDesc, [In] uint cbPackets, [In] IntPtr pByte, [In, MarshalAs(UnmanagedType.LPStruct)] NativeMethods.XFORM xForm);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int SetEnabledUnicodeRanges([In] ContextSafeHandle hRecContext, [In] uint cRangs, [In] CHARACTER_RANGE[] charRanges);
+ internal static extern HRESULT SetEnabledUnicodeRanges([In] ContextSafeHandle hRecContext, [In] uint cRangs, [In] CHARACTER_RANGE[] charRanges);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int EndInkInput([In] ContextSafeHandle hRecContext);
+ internal static extern HRESULT EndInkInput([In] ContextSafeHandle hRecContext);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int Process([In] ContextSafeHandle hRecContext, [Out] out bool partialProcessing);
+ internal static extern HRESULT Process([In] ContextSafeHandle hRecContext, [Out] out bool partialProcessing);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int GetAlternateList([In] ContextSafeHandle hRecContext, [In, Out] ref RECO_RANGE recoRange, [In, Out] ref uint cAlts, [In, Out] IntPtr[] recAtls, [In] ALT_BREAKS breaks);
+ internal static extern HRESULT GetAlternateList([In] ContextSafeHandle hRecContext, [In, Out] ref RECO_RANGE recoRange, [In, Out] ref uint cAlts, [In, Out] IntPtr[] recAtls, [In] ALT_BREAKS breaks);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int DestroyAlternate([In] IntPtr hRecAtls);
+ internal static extern HRESULT DestroyAlternate([In] IntPtr hRecAtls);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
- internal static extern int GetString([In] IntPtr hRecAtls, [Out] out RECO_RANGE recoRange, [In, Out]ref uint size, [In, Out] StringBuilder recoString);
+ internal static extern HRESULT GetString([In] IntPtr hRecAtls, [Out] out RECO_RANGE recoRange, [In, Out]ref uint size, [In, Out] StringBuilder recoString);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int GetConfidenceLevel([In] IntPtr hRecAtls, [Out] out RECO_RANGE recoRange, [Out] out RecognitionConfidence confidenceLevel);
+ internal static extern HRESULT GetConfidenceLevel([In] IntPtr hRecAtls, [Out] out RECO_RANGE recoRange, [Out] out RecognitionConfidence confidenceLevel);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int ResetContext([In] ContextSafeHandle hRecContext);
+ internal static extern HRESULT ResetContext([In] ContextSafeHandle hRecContext);
[DllImport(ExternDll.Mshwgst, CallingConvention = CallingConvention.Winapi)]
- internal static extern int GetLatticePtr([In] ContextSafeHandle hRecContext, [In] ref IntPtr pRecoLattice);
+ internal static extern HRESULT GetLatticePtr([In] ContextSafeHandle hRecContext, [In] ref IntPtr pRecoLattice);
}
-
-
///
/// RecognizerSafeHandle
///
@@ -86,10 +85,10 @@ public override bool IsInvalid
}
}
- override protected bool ReleaseHandle()
+ protected override bool ReleaseHandle()
{
- Debug.Assert(handle != IntPtr.Zero);
- return (MS.Internal.HRESULT.Succeeded(MS.Win32.Recognizer.UnsafeNativeMethods.DestroyRecognizer(handle)));
+ Debug.Assert(handle != 0);
+ return UnsafeNativeMethods.DestroyRecognizer(handle).Succeeded;
}
}
@@ -120,33 +119,33 @@ public override bool IsInvalid
return IsClosed || handle == IntPtr.Zero;
}
}
-
- override protected bool ReleaseHandle()
+
+ protected override bool ReleaseHandle()
{
- //Note: It is not an error to have already called DestroyRecognizer
- //which makes _recognizerHandle.IsInvalid == true before calling
- //DestroyContext. I have removed this assert, but left it commented for
- //context.
- //Debug.Assert(_recognizerHandle != null && !_recognizerHandle.IsInvalid);
- Debug.Assert(handle != IntPtr.Zero);
- int hr = MS.Win32.Recognizer.UnsafeNativeMethods.DestroyContext(handle);
+ // Note: It is not an error to have already called DestroyRecognizer
+ // which makes _recognizerHandle.IsInvalid == true before calling
+ // DestroyContext. I have removed this assert, but left it commented for
+ // context.
+ //
+ // Debug.Assert(_recognizerHandle != null && !_recognizerHandle.IsInvalid);
+ Debug.Assert(handle != 0);
+ HRESULT result = UnsafeNativeMethods.DestroyContext(handle);
// Now, dereference the attached recognizer.
_recognizerHandle = null;
- return MS.Internal.HRESULT.Succeeded(hr);
+ return result.Succeeded;
}
-
internal void AddReferenceOnRecognizer(RecognizerSafeHandle handle)
{
- System.Diagnostics.Debug.Assert(_recognizerHandle == null);
+ Debug.Assert(_recognizerHandle == null);
_recognizerHandle = handle;
}
private RecognizerSafeHandle _recognizerHandle;
}
-
+
// The structure has been copied from public\internal\drivers\inc\tpcshrd.h
//typedef struct _PROPERTY_METRICS
// {
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs
index fb0de6bcc17..1222440ceda 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -13,6 +13,7 @@
using System.Windows.Media;
using System.Windows.Ink;
using System.Windows.Input;
+using Windows.Win32.Foundation;
#pragma warning disable 1634, 1691 // suppressing PreSharp warnings
@@ -44,20 +45,22 @@ static NativeRecognizer()
///
private NativeRecognizer()
{
- Debug.Assert(NativeRecognizer.RecognizerHandleSingleton != null);
+ Debug.Assert(RecognizerHandleSingleton != null);
- int hr = MS.Win32.Recognizer.UnsafeNativeMethods.CreateContext(NativeRecognizer.RecognizerHandleSingleton,
- out _hContext);
- if (HRESULT.Failed(hr))
+ HRESULT result = Win32.Recognizer.UnsafeNativeMethods.CreateContext(
+ RecognizerHandleSingleton,
+ out _hContext);
+
+ if (result.Failed)
{
- //don't throw a com exception here, we don't need to pass out any details
+ // Don't throw a com exception here, we don't need to pass out any details
throw new InvalidOperationException(SR.UnspecifiedGestureConstructionException);
}
// We add a reference of the recognizer to the context handle.
// The context will dereference the recognizer reference when it gets disposed.
// This trick will prevent the GC from disposing the recognizer before all contexts.
- _hContext.AddReferenceOnRecognizer(NativeRecognizer.RecognizerHandleSingleton);
+ _hContext.AddReferenceOnRecognizer(RecognizerHandleSingleton);
}
#endregion Constructors
@@ -76,7 +79,7 @@ private NativeRecognizer()
/// null if it fails
internal static NativeRecognizer CreateInstance()
{
- if (NativeRecognizer.RecognizerHandleSingleton != null)
+ if (RecognizerHandleSingleton != null)
{
return new NativeRecognizer();
}
@@ -99,8 +102,7 @@ internal ApplicationGesture[] SetEnabledGestures(IEnumerable
GetApplicationGestureArrayAndVerify(applicationGestures);
// Set enabled Gestures.
- int hr = SetEnabledGestures(_hContext, enabledGestures);
- if (HRESULT.Failed(hr))
+ if (SetEnabledGestures(_hContext, enabledGestures).Failed)
{
//don't throw a com exception here, we don't need to pass out any details
throw new InvalidOperationException(SR.UnspecifiedSetEnabledGesturesException);
@@ -136,33 +138,32 @@ internal GestureRecognitionResult[] Recognize(StrokeCollection strokes)
return recResults;
}
- int hr = 0;
+ HRESULT result = HRESULT.S_OK;
try
{
// Reset the context
- hr = MS.Win32.Recognizer.UnsafeNativeMethods.ResetContext(_hContext);
- if (HRESULT.Failed(hr))
+ result = Win32.Recognizer.UnsafeNativeMethods.ResetContext(_hContext);
+ if (result.Failed)
{
//finally block will clean up and throw
return recResults;
}
// Add strokes
- hr = AddStrokes(_hContext, strokes);
- if (HRESULT.Failed(hr))
+ result = AddStrokes(_hContext, strokes);
+ if (result.Failed)
{
//AddStrokes's finally block will clean up this finally block will throw
return recResults;
}
// recognize the ink
- bool bIncremental;
- hr = MS.Win32.Recognizer.UnsafeNativeMethods.Process(_hContext, out bIncremental);
+ result = Win32.Recognizer.UnsafeNativeMethods.Process(_hContext, out bool bIncremental);
- if (HRESULT.Succeeded(hr))
+ if (result.Succeeded)
{
- if ( s_GetAlternateListExists )
+ if (s_GetAlternateListExists)
{
recResults = InvokeGetAlternateList();
}
@@ -175,7 +176,7 @@ internal GestureRecognitionResult[] Recognize(StrokeCollection strokes)
finally
{
// Check if we should report any error.
- if ( HRESULT.Failed(hr) )
+ if (result.Failed)
{
//don't throw a com exception here, we don't need to pass out any details
throw new InvalidOperationException(SR.UnspecifiedGestureException);
@@ -324,13 +325,13 @@ private static bool LoadRecognizerDll()
if (path != null)
{
- IntPtr hModule = MS.Win32.UnsafeNativeMethods.LoadLibrary(path);
+ IntPtr hModule = UnsafeNativeMethods.LoadLibrary(path);
// Check whether GetAlternateList exists in the loaded Dll.
s_GetAlternateListExists = false;
if ( hModule != IntPtr.Zero )
{
- s_GetAlternateListExists = MS.Win32.UnsafeNativeMethods.GetProcAddressNoThrow(
+ s_GetAlternateListExists = UnsafeNativeMethods.GetProcAddressNoThrow(
new HandleRef(null, hModule), "GetAlternateList") != IntPtr.Zero ?
true : false;
}
@@ -344,7 +345,7 @@ private static bool LoadRecognizerDll()
/// Set the enabled gestures.
/// This method is called from the internal SetEnabledGestures method.
///
- private int SetEnabledGestures(MS.Win32.Recognizer.ContextSafeHandle recContext, ApplicationGesture[] enabledGestures)
+ private HRESULT SetEnabledGestures(MS.Win32.Recognizer.ContextSafeHandle recContext, ApplicationGesture[] enabledGestures)
{
Debug.Assert(recContext != null && !recContext.IsInvalid);
@@ -383,20 +384,18 @@ private int SetEnabledGestures(MS.Win32.Recognizer.ContextSafeHandle recContext,
charRanges[i].wcLow = (ushort)( enabledGestures[i] );
}
}
- int hr = MS.Win32.Recognizer.UnsafeNativeMethods.SetEnabledUnicodeRanges(recContext, cRanges, charRanges);
- return hr;
+
+ return Win32.Recognizer.UnsafeNativeMethods.SetEnabledUnicodeRanges(recContext, cRanges, charRanges);
}
///
/// Add the strokes to the recoContext.
/// The method is called from the internal Recognize method.
///
- private int AddStrokes(MS.Win32.Recognizer.ContextSafeHandle recContext, StrokeCollection strokes)
+ private HRESULT AddStrokes(MS.Win32.Recognizer.ContextSafeHandle recContext, StrokeCollection strokes)
{
Debug.Assert(recContext != null && !recContext.IsInvalid);
- int hr;
-
foreach ( Stroke stroke in strokes )
{
MS.Win32.Recognizer.PACKET_DESCRIPTION packetDescription =
@@ -409,14 +408,21 @@ private int AddStrokes(MS.Win32.Recognizer.ContextSafeHandle recContext, StrokeC
GetPacketData(stroke, out packetDescription, out countOfBytes, out packets, out xForm);
if (packets == IntPtr.Zero)
{
- return -2147483640; //E_FAIL - 0x80000008. We never raise this in an exception
+ // This isn't actually E_FAIL, it's the Macintosh version of it from the headers. Keeping for compat.
+ return (HRESULT)(-2147483640); // E_FAIL - 0x80000008. We never raise this in an exception
}
- hr = MS.Win32.Recognizer.UnsafeNativeMethods.AddStroke(recContext, ref packetDescription, (uint)countOfBytes, packets, xForm);
- if ( HRESULT.Failed(hr) )
+ HRESULT result = Win32.Recognizer.UnsafeNativeMethods.AddStroke(
+ recContext,
+ ref packetDescription,
+ (uint)countOfBytes,
+ packets,
+ xForm);
+
+ if (result.Failed)
{
// Return from here. The finally block will free the memory and report the error properly.
- return hr;
+ return result;
}
}
finally
@@ -426,7 +432,7 @@ private int AddStrokes(MS.Win32.Recognizer.ContextSafeHandle recContext, StrokeC
}
}
- return MS.Win32.Recognizer.UnsafeNativeMethods.EndInkInput(recContext);
+ return Win32.Recognizer.UnsafeNativeMethods.EndInkInput(recContext);
}
///
@@ -585,7 +591,6 @@ private void ReleaseResourcesinPacketDescription(MS.Win32.Recognizer.PACKET_DESC
private GestureRecognitionResult[] InvokeGetAlternateList()
{
GestureRecognitionResult[] recResults = Array.Empty();
- int hr = 0;
MS.Win32.Recognizer.RECO_RANGE recoRange;
recoRange.iwcBegin = 0;
@@ -595,9 +600,14 @@ private GestureRecognitionResult[] InvokeGetAlternateList()
try
{
- hr = MS.Win32.Recognizer.UnsafeNativeMethods.GetAlternateList(_hContext, ref recoRange, ref countOfAlternates, pRecoAlternates, MS.Win32.Recognizer.ALT_BREAKS.ALT_BREAKS_SAME);
+ HRESULT result = Win32.Recognizer.UnsafeNativeMethods.GetAlternateList(
+ _hContext,
+ ref recoRange,
+ ref countOfAlternates,
+ pRecoAlternates,
+ Win32.Recognizer.ALT_BREAKS.ALT_BREAKS_SAME);
- if ( HRESULT.Succeeded(hr) && countOfAlternates != 0 )
+ if (result.Succeeded && countOfAlternates != 0)
{
List resultList = new List();
@@ -607,8 +617,8 @@ private GestureRecognitionResult[] InvokeGetAlternateList()
StringBuilder recoString = new StringBuilder(1);
RecognitionConfidence confidenceLevel;
- if ( HRESULT.Failed(MS.Win32.Recognizer.UnsafeNativeMethods.GetString(pRecoAlternates[i], out recoRange, ref size, recoString))
- || HRESULT.Failed(MS.Win32.Recognizer.UnsafeNativeMethods.GetConfidenceLevel(pRecoAlternates[i], out recoRange, out confidenceLevel)) )
+ if (Win32.Recognizer.UnsafeNativeMethods.GetString(pRecoAlternates[i], out recoRange, ref size, recoString).Failed
+ || Win32.Recognizer.UnsafeNativeMethods.GetConfidenceLevel(pRecoAlternates[i], out recoRange, out confidenceLevel).Failed)
{
// Fail to retrieve the reco result, skip this one
continue;
@@ -650,15 +660,12 @@ private GestureRecognitionResult[] InvokeGetLatticePtr()
{
GestureRecognitionResult[] recResults = Array.Empty();
-// int hr = 0;
IntPtr ptr = IntPtr.Zero;
// NOTICE-2005/07/11-WAYNEZEN,
// There is no need to free the returned the structure.
// The memory will be released when ResetContext, which is invoked in the callee - Recognize, is called.
- if ( HRESULT.Succeeded(
- MS.Win32.Recognizer.UnsafeNativeMethods.GetLatticePtr(
- _hContext, ref ptr)) )
+ if (Win32.Recognizer.UnsafeNativeMethods.GetLatticePtr(_hContext, ref ptr).Succeeded)
{
unsafe
{
@@ -750,7 +757,7 @@ private static MS.Win32.Recognizer.RecognizerSafeHandle RecognizerHandleSingleto
{
if (s_isSupported && s_hRec == null)
{
- if (HRESULT.Failed(MS.Win32.Recognizer.UnsafeNativeMethods.CreateRecognizer(ref s_Gesture, out s_hRec)))
+ if (Win32.Recognizer.UnsafeNativeMethods.CreateRecognizer(ref s_Gesture, out s_hRec).Failed)
{
s_hRec = null;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/OtherAssemblyAttrs.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/OtherAssemblyAttrs.cs
index 83f94f0a9f2..d2e632e33f9 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/OtherAssemblyAttrs.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/OtherAssemblyAttrs.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -17,7 +17,7 @@
[assembly: InternalsVisibleTo(BuildInfo.PresentationFrameworkSystemDrawing)]
[assembly: InternalsVisibleTo(BuildInfo.SystemWindowsControlsRibbon)]
[assembly: InternalsVisibleTo(BuildInfo.WindowsFormsIntegration)]
-[assembly: InternalsVisibleTo($"PresentationCore.Tests, PublicKey={BuildInfo.WCP_PUBLIC_KEY_STRING}")]
+[assembly: InternalsVisibleTo($"PresentationCore.Tests, PublicKey={BuildInfo.OpenPublicKey}")]
[assembly: TypeForwardedTo(typeof(System.Windows.Markup.IUriContext))]
[assembly: TypeForwardedTo(typeof(System.Windows.Media.TextFormattingMode))]
[assembly: TypeForwardedTo(typeof(System.Windows.Input.ICommand))]
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj
index df8afb8ed48..42dfbe12663 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj
@@ -29,8 +29,6 @@
Common\System\SR.cs
-
-
@@ -336,7 +334,6 @@
-
@@ -1418,6 +1415,7 @@
+
@@ -1425,6 +1423,7 @@
+
@@ -1435,6 +1434,7 @@
+
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/ExceptionExtensions.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/ExceptionExtensions.cs
deleted file mode 100644
index 069900280e7..00000000000
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/BinaryFormat/ExceptionExtensions.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Threading;
-
-namespace System.Windows
-{
- internal static class ExceptionExtensions
- {
- ///
- /// Returns if the exception is an exception that isn't recoverable and/or a likely
- /// bug in our implementation.
- ///
- public static bool IsCriticalException(this Exception ex)
- => ex is NullReferenceException
- or StackOverflowException
- or OutOfMemoryException
- or ThreadAbortException
- or IndexOutOfRangeException
- or AccessViolationException;
- }
-}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/DragDrop.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/DragDrop.cs
index 67dd9e3e5df..e2d8995b4a4 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/DragDrop.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/DragDrop.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -19,6 +19,7 @@
using System.Windows.Interop;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
+using Windows.Win32.Foundation;
namespace System.Windows
{
@@ -627,7 +628,7 @@ public OleDragSource(DependencyObject dragSource)
///
/// Query the source to know the drag continue or not.
///
- int UnsafeNativeMethods.IOleDropSource.OleQueryContinueDrag(int escapeKey, int grfkeyState)
+ HRESULT UnsafeNativeMethods.IOleDropSource.OleQueryContinueDrag(int escapeKey, int grfkeyState)
{
bool escapePressed;
QueryContinueDragEventArgs args;
@@ -648,24 +649,24 @@ int UnsafeNativeMethods.IOleDropSource.OleQueryContinueDrag(int escapeKey, int g
// Check the drag continue result.
if (args.Action == DragAction.Continue)
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
else if (args.Action == DragAction.Drop)
{
- return NativeMethods.DRAGDROP_S_DROP;
+ return HRESULT.DRAGDROP_S_DROP;
}
else if (args.Action == DragAction.Cancel)
{
- return NativeMethods.DRAGDROP_S_CANCEL;
+ return HRESULT.DRAGDROP_S_CANCEL;
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// Give feedback from the source whether use the default cursor or not.
///
- int UnsafeNativeMethods.IOleDropSource.OleGiveFeedback(int effect)
+ HRESULT UnsafeNativeMethods.IOleDropSource.OleGiveFeedback(int effect)
{
GiveFeedbackEventArgs args;
@@ -678,10 +679,10 @@ int UnsafeNativeMethods.IOleDropSource.OleGiveFeedback(int effect)
// Check the give feedback result whether use default cursors or not.
if (args.UseDefaultCursors)
{
- return NativeMethods.DRAGDROP_S_USEDEFAULTCURSORS;
+ return HRESULT.DRAGDROP_S_USEDEFAULTCURSORS;
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
@@ -910,7 +911,7 @@ public OleDropTarget(IntPtr handle)
///
/// OleDragEnter - check the data object and notify DragEnter to the target element.
///
- int UnsafeNativeMethods.IOleDropTarget.OleDragEnter(object data, int dragDropKeyStates, long point, ref int effects)
+ HRESULT UnsafeNativeMethods.IOleDropTarget.OleDragEnter(object data, int dragDropKeyStates, long point, ref int effects)
{
DependencyObject target;
Point targetPoint;
@@ -922,7 +923,7 @@ int UnsafeNativeMethods.IOleDropTarget.OleDragEnter(object data, int dragDropKey
// Set the none effect.
effects = (int)DragDropEffects.None;
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
// Get the current target from the mouse drag point that is based on screen.
@@ -947,13 +948,13 @@ int UnsafeNativeMethods.IOleDropTarget.OleDragEnter(object data, int dragDropKey
effects = (int)DragDropEffects.None;
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// OleDragOver - get the drop effect from the target element.
///
- int UnsafeNativeMethods.IOleDropTarget.OleDragOver(int dragDropKeyStates, long point, ref int effects)
+ HRESULT UnsafeNativeMethods.IOleDropTarget.OleDragOver(int dragDropKeyStates, long point, ref int effects)
{
DependencyObject target;
Point targetPoint;
@@ -1032,13 +1033,13 @@ int UnsafeNativeMethods.IOleDropTarget.OleDragOver(int dragDropKeyStates, long p
}
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// OleDragLeave.
///
- int UnsafeNativeMethods.IOleDropTarget.OleDragLeave()
+ HRESULT UnsafeNativeMethods.IOleDropTarget.OleDragLeave()
{
if (_lastTarget != null)
{
@@ -1065,13 +1066,13 @@ int UnsafeNativeMethods.IOleDropTarget.OleDragLeave()
}
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// OleDrop - drop the object to the target element.
///
- int UnsafeNativeMethods.IOleDropTarget.OleDrop(object data, int dragDropKeyStates, long point, ref int effects)
+ HRESULT UnsafeNativeMethods.IOleDropTarget.OleDrop(object data, int dragDropKeyStates, long point, ref int effects)
{
IDataObject dataObject;
DependencyObject target;
@@ -1083,7 +1084,7 @@ int UnsafeNativeMethods.IOleDropTarget.OleDrop(object data, int dragDropKeyState
{
effects = (int)DragDropEffects.None;
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
// Reset last element and target point.
@@ -1108,7 +1109,7 @@ int UnsafeNativeMethods.IOleDropTarget.OleDrop(object data, int dragDropKeyState
effects = (int)DragDropEffects.None;
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
#endregion IOleDropTarget
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputMethod.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputMethod.cs
index 5fecd80ac86..f13d31a5e67 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputMethod.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputMethod.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -11,6 +11,7 @@
using System.Windows.Interop;
using MS.Win32;
using MS.Internal;
+using Windows.Win32.Foundation;
namespace System.Windows.Input
{
@@ -1292,7 +1293,7 @@ private static void IsInputMethodEnabled_Changed(DependencyObject d, DependencyP
IInputElement inputElement = (IInputElement)d;
if (inputElement == Keyboard.FocusedElement)
{
- InputMethod.Current.EnableOrDisableInputMethod((bool) e.NewValue);
+ Current.EnableOrDisableInputMethod((bool) e.NewValue);
}
}
@@ -1657,7 +1658,7 @@ private UnsafeNativeMethods.TF_LANGUAGEPROFILE GetCurrentKeybordTipProfile()
UnsafeNativeMethods.TF_LANGUAGEPROFILE[] tf_profiles = new UnsafeNativeMethods.TF_LANGUAGEPROFILE[1];
int fetched;
- while(enumIpp.Next(1, tf_profiles, out fetched) == NativeMethods.S_OK)
+ while(enumIpp.Next(1, tf_profiles, out fetched) == HRESULT.S_OK)
{
// Check if this profile is active.
if (tf_profiles[0].fActive == true)
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProcessorProfilesLoader.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProcessorProfilesLoader.cs
index d161dffe3b5..e80ddbcb667 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProcessorProfilesLoader.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputProcessorProfilesLoader.cs
@@ -1,73 +1,32 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-//
-//
-// Description: Creates ITfThreadMgr instances, the root object of the Text
-// Services Framework.
-//
-//
-
-// PRESHARP: In order to avoid generating warnings about unkown message numbers and unknown pragmas.
-#pragma warning disable 1634, 1691
+#nullable enable
using System.Threading;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace System.Windows.Input
{
- //------------------------------------------------------
- //
- // InputProcessorProfilesLoader class
- //
- //------------------------------------------------------
-
///
- /// Loads an instance of the Text Services Framework.
+ /// Loads an instance of the Text Services Input Processor Profiles.
///
internal static class InputProcessorProfilesLoader
{
- //------------------------------------------------------
- //
- // Constructors
- //
- //------------------------------------------------------
-
- #region Constructors
-
- #endregion Constructors
-
- //------------------------------------------------------
- //
- // Internal Properties
- //
- //------------------------------------------------------
-
- #region Internal Properties
-
///
- /// Loads an instance of the Text Services Framework.
+ /// Loads an instance of the Text Services Framework.
///
///
- /// May return null if no text services are available.
+ /// May return if no text services are available.
///
- internal static UnsafeNativeMethods.ITfInputProcessorProfiles Load()
+ internal static UnsafeNativeMethods.ITfInputProcessorProfiles? Load()
{
- UnsafeNativeMethods.ITfInputProcessorProfiles obj;
-
Debug.Assert(Thread.CurrentThread.GetApartmentState() == ApartmentState.STA, "Load called on MTA thread!");
-
-#pragma warning suppress 6523
- if (UnsafeNativeMethods.TF_CreateInputProcessorProfiles(out obj) == NativeMethods.S_OK)
- {
- return obj;
- }
- return null;
+ return UnsafeNativeMethods.TF_CreateInputProcessorProfiles(out UnsafeNativeMethods.ITfInputProcessorProfiles obj) == HRESULT.S_OK
+ ? obj
+ : null;
}
-
- #endregion Internal Properties
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/D3DImage.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/D3DImage.cs
index 46b40636527..7d15094faf7 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/D3DImage.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/D3DImage.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -14,6 +14,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using System.Threading;
+using Windows.Win32.Foundation;
namespace System.Windows.Interop
{
@@ -153,7 +154,7 @@ public void SetBackBuffer(D3DResourceType backBufferType, IntPtr backBuffer, boo
// in a null _pInteropDeviceBitmap at the end
if (backBuffer != IntPtr.Zero)
{
- HRESULT.Check(UnsafeNativeMethods.InteropDeviceBitmap.Create(
+ UnsafeNativeMethods.InteropDeviceBitmap.Create(
backBuffer,
_dpiX,
_dpiY,
@@ -163,7 +164,7 @@ public void SetBackBuffer(D3DResourceType backBufferType, IntPtr backBuffer, boo
out newBitmap,
out newPixelWidth,
out newPixelHeight
- ));
+ ).ThrowOnFailureExtended();
}
//
@@ -299,18 +300,18 @@ public void AddDirtyRect(Int32Rect dirtyRect)
throw new InvalidOperationException(SR.D3DImage_MustHaveBackBuffer);
}
- dirtyRect.ValidateForDirtyRect("dirtyRect", PixelWidth, PixelHeight);
+ dirtyRect.ValidateForDirtyRect(nameof(dirtyRect), PixelWidth, PixelHeight);
if (dirtyRect.HasArea)
{
// Unmanaged code will make sure that the rect is well-formed
- HRESULT.Check(UnsafeNativeMethods.InteropDeviceBitmap.AddDirtyRect(
- dirtyRect.X,
- dirtyRect.Y,
- dirtyRect.Width,
- dirtyRect.Height,
+ UnsafeNativeMethods.InteropDeviceBitmap.AddDirtyRect(
+ dirtyRect.X,
+ dirtyRect.Y,
+ dirtyRect.Width,
+ dirtyRect.Height,
_pInteropDeviceBitmap
- ));
-
+ ).ThrowOnFailureExtended();
+
// We're now dirty, but we won't consider it a change until Unlock
_isDirty = true;
_isChangePending = true;
@@ -400,7 +401,7 @@ public sealed override double Width
{
ReadPreamble();
- return ImageSource.PixelsToDIPs(_dpiX, (int)_pixelWidth);
+ return PixelsToDIPs(_dpiX, (int)_pixelWidth);
}
}
@@ -415,7 +416,7 @@ public sealed override double Height
{
ReadPreamble();
- return ImageSource.PixelsToDIPs(_dpiY, (int)_pixelHeight);
+ return PixelsToDIPs(_dpiY, (int)_pixelHeight);
}
}
@@ -514,24 +515,23 @@ protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
///
protected internal virtual BitmapSource CopyBackBuffer()
{
-
BitmapSource copy = null;
-
+
if (_pInteropDeviceBitmap != null)
{
BitmapSourceSafeMILHandle pIWICBitmapSource;
-
- if (HRESULT.Succeeded(UnsafeNativeMethods.InteropDeviceBitmap.GetAsSoftwareBitmap(
+
+ if (UnsafeNativeMethods.InteropDeviceBitmap.GetAsSoftwareBitmap(
_pInteropDeviceBitmap,
out pIWICBitmapSource
- )))
+ ).Succeeded)
{
// CachedBitmap will AddRef the bitmap
copy = new CachedBitmap(pIWICBitmapSource);
}
}
- return copy;
+ return copy;
}
private void CloneCommon(Freezable sourceFreezable)
@@ -826,7 +826,7 @@ internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCh
internal override DUCE.ResourceHandle AddRefOnChannelCore(DUCE.Channel channel)
{
- if (_duceResource.CreateOrAddRefOnChannel(this, channel, System.Windows.Media.Composition.DUCE.ResourceType.TYPE_D3DIMAGE))
+ if (_duceResource.CreateOrAddRefOnChannel(this, channel, DUCE.ResourceType.TYPE_D3DIMAGE))
{
AddRefOnChannelAnimations(channel);
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs
index 7e0190fada4..2c07a53a27e 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -16,9 +16,10 @@
using MS.Win32;
using MS.Internal.PresentationCore;
-using HRESULT = MS.Internal.HRESULT;
+using HRESULT = Windows.Win32.Foundation.HRESULT;
using NativeMethodsSetLastError = MS.Internal.WindowsBase.NativeMethodsSetLastError;
using PROCESS_DPI_AWARENESS = MS.Win32.NativeMethods.PROCESS_DPI_AWARENESS;
+using Windows.Win32.Foundation;
#pragma warning disable 1634, 1691 // suppressing PreSharp warnings
@@ -544,9 +545,9 @@ out processId
);
}
- int hr = VisualTarget_AttachToHwnd(hwnd);
+ HRESULT hr = VisualTarget_AttachToHwnd(hwnd);
- if (HRESULT.Failed(hr))
+ if (hr.Failed)
{
if (hr == unchecked((int)0x80070005)) // E_ACCESSDENIED
{
@@ -556,7 +557,7 @@ out processId
}
else
{
- HRESULT.Check(hr);
+ hr.ThrowOnFailureExtended();
}
}
@@ -566,15 +567,11 @@ out processId
}
[DllImport(DllImport.MilCore, EntryPoint = "MilVisualTarget_AttachToHwnd")]
- internal static extern int VisualTarget_AttachToHwnd(
- IntPtr hwnd
- );
+ internal static extern HRESULT VisualTarget_AttachToHwnd(IntPtr hwnd);
[DllImport(DllImport.MilCore, EntryPoint = "MilVisualTarget_DetachFromHwnd")]
- internal static extern int VisualTarget_DetachFromHwnd(
- IntPtr hwnd
- );
+ internal static extern HRESULT VisualTarget_DetachFromHwnd(IntPtr hwnd);
internal void InvalidateRenderMode()
{
@@ -604,7 +601,7 @@ internal void InvalidateRenderMode()
//Obtain compatibility flags set in the application
bool? enableMultiMonitorDisplayClipping =
- System.Windows.CoreCompatibilityPreferences.EnableMultiMonitorDisplayClipping;
+ CoreCompatibilityPreferences.EnableMultiMonitorDisplayClipping;
if (enableMultiMonitorDisplayClipping != null)
{
@@ -686,7 +683,7 @@ public override void Dispose()
{
RootVisual = null;
- HRESULT.Check(VisualTarget_DetachFromHwnd(_hWnd));
+ VisualTarget_DetachFromHwnd(_hWnd).ThrowOnFailureExtended();
//
// Unregister this CompositionTarget from the MediaSystem.
@@ -1524,7 +1521,7 @@ private bool OnSettingChange(Int32 firstParam)
(int)firstParam == (int)NativeMethods.SPI_SETDISPLAYTEXTCONTRASTLEVEL
)
{
- HRESULT.Check(MILUpdateSystemParametersInfo.Update());
+ MILUpdateSystemParametersInfo.Update().ThrowOnFailureExtended();
return true;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ChannelManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ChannelManager.cs
index af7338394e0..347131ae611 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ChannelManager.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ChannelManager.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -12,7 +12,7 @@
using System.Windows.Media.Composition;
using MS.Internal;
-
+using Windows.Win32.Foundation;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods.MilCoreApi;
namespace System.Windows.Media
@@ -48,16 +48,16 @@ internal void CreateChannels()
// Pass in a reference to the global mediasystem channel so that it uses
// the same partition.
_asyncChannel = new DUCE.Channel(
- System.Windows.Media.MediaSystem.ServiceChannel,
+ MediaSystem.ServiceChannel,
false, // not out of band
- System.Windows.Media.MediaSystem.Connection,
+ MediaSystem.Connection,
false // sync transport
);
_asyncOutOfBandChannel = new DUCE.Channel(
- System.Windows.Media.MediaSystem.ServiceChannel,
+ MediaSystem.ServiceChannel,
true, // out of band
- System.Windows.Media.MediaSystem.Connection,
+ MediaSystem.Connection,
false // sync transport
);
}
@@ -104,12 +104,12 @@ internal void RemoveChannels()
_asyncOutOfBandChannel.Close();
_asyncOutOfBandChannel = null;
}
-
+
RemoveSyncChannels();
if (_pSyncConnection != IntPtr.Zero)
{
- HRESULT.Check(UnsafeNativeMethods.WgxConnection_Disconnect(_pSyncConnection));
+ UnsafeNativeMethods.WgxConnection_Disconnect(_pSyncConnection).ThrowOnFailureExtended();
_pSyncConnection = IntPtr.Zero;
}
}
@@ -123,9 +123,9 @@ internal DUCE.Channel AllocateSyncChannel()
if (_pSyncConnection == IntPtr.Zero)
{
- HRESULT.Check(UnsafeNativeMethods.WgxConnection_Create(
+ UnsafeNativeMethods.WgxConnection_Create(
true, // true means synchronous transport
- out _pSyncConnection));
+ out _pSyncConnection).ThrowOnFailureExtended();
}
if (_freeSyncChannels == null)
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs
index 1132c55c573..944c90bc08b 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -16,6 +16,7 @@
using UnsafeNativeMethodsMilCoreApi = MS.Win32.PresentationCore.UnsafeNativeMethods;
using IWICCC = MS.Win32.PresentationCore.UnsafeNativeMethods.IWICColorContext;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
{
@@ -39,9 +40,9 @@ private ColorContext(SafeMILHandle colorContextHandle)
// will be invalid and we'll emulate the old failure behavior later in
// OpenProfileStream()
//
-
+
IWICCC.WICColorContextType type;
- if (HRESULT.Failed(IWICCC.GetType(_colorContextHandle, out type)))
+ if (IWICCC.GetType(_colorContextHandle, out type).Failed)
{
return;
}
@@ -50,13 +51,15 @@ private ColorContext(SafeMILHandle colorContextHandle)
{
case IWICCC.WICColorContextType.WICColorContextProfile:
uint cbProfileActual;
- int hr = IWICCC.GetProfileBytes(_colorContextHandle, 0, null, out cbProfileActual);
- if (HRESULT.Succeeded(hr) && cbProfileActual != 0)
+ HRESULT hr = IWICCC.GetProfileBytes(_colorContextHandle, 0, null, out cbProfileActual);
+ if (hr.Succeeded && cbProfileActual != 0)
{
byte[] profileData = new byte[cbProfileActual];
- if (HRESULT.Failed(IWICCC.GetProfileBytes(
- _colorContextHandle, cbProfileActual, profileData, out cbProfileActual))
- )
+ if (IWICCC.GetProfileBytes(
+ _colorContextHandle,
+ cbProfileActual,
+ profileData,
+ out cbProfileActual).Failed)
{
return;
}
@@ -68,7 +71,7 @@ private ColorContext(SafeMILHandle colorContextHandle)
case IWICCC.WICColorContextType.WICColorContextExifColorSpace:
uint colorSpace;
- if (HRESULT.Failed(IWICCC.GetExifColorSpace(_colorContextHandle, out colorSpace)))
+ if (IWICCC.GetExifColorSpace(_colorContextHandle, out colorSpace).Failed)
{
return;
}
@@ -115,16 +118,17 @@ private ColorContext(SafeMILHandle colorContextHandle)
_colorContextHandle.Dispose();
_colorContextHandle = null;
- if (HRESULT.Failed(UnsafeNativeMethodsMilCoreApi.WICCodec.CreateColorContext(
- factoryMaker.ImagingFactoryPtr, out _colorContextHandle))
- )
+ if (UnsafeNativeMethodsMilCoreApi.WICCodec.CreateColorContext(
+ factoryMaker.ImagingFactoryPtr,
+ out _colorContextHandle).Failed)
{
return;
}
- if (HRESULT.Failed(IWICCC.InitializeFromMemory(
- _colorContextHandle, sRGBProfile, (uint)sRGBProfile.Length))
- )
+ if (IWICCC.InitializeFromMemory(
+ _colorContextHandle,
+ sRGBProfile,
+ (uint)sRGBProfile.Length).Failed)
{
return;
}
@@ -335,7 +339,7 @@ internal bool IsValid
}
}
- internal delegate int GetColorContextsDelegate(ref uint numContexts, IntPtr[] colorContextPtrs);
+ internal delegate HRESULT GetColorContextsDelegate(ref uint numContexts, IntPtr[] colorContextPtrs);
///
/// Helper method that will retrieve ColorContexts from an unmanaged object (e.g. BitmapDecoder or BitmapFrameDecode)
@@ -345,12 +349,12 @@ internal static IList GetColorContextsHelper(GetColorContextsDeleg
uint numContexts = 0;
List colorContextsList = null;
- int hr = getColorContexts(ref numContexts, null);
- if (hr != (int)WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION)
+ HRESULT hr = getColorContexts(ref numContexts, null);
+ if (hr != HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION)
{
- HRESULT.Check(hr);
+ hr.ThrowOnFailureExtended();
}
-
+
if (numContexts > 0)
{
// GetColorContexts does not create new IWICColorContexts. Instead, it initializes existing
@@ -361,7 +365,9 @@ internal static IList GetColorContextsHelper(GetColorContextsDeleg
{
for (uint i = 0; i < numContexts; ++i)
{
- HRESULT.Check(UnsafeNativeMethodsMilCoreApi.WICCodec.CreateColorContext(factoryMaker.ImagingFactoryPtr, out colorContextHandles[i]));
+ UnsafeNativeMethodsMilCoreApi.WICCodec.CreateColorContext(
+ factoryMaker.ImagingFactoryPtr,
+ out colorContextHandles[i]).ThrowOnFailureExtended();
}
}
@@ -374,7 +380,7 @@ internal static IList GetColorContextsHelper(GetColorContextsDeleg
colorContextPtrs[i] = colorContextHandles[i].DangerousGetHandle();
}
- HRESULT.Check(getColorContexts(ref numContexts, colorContextPtrs));
+ getColorContexts(ref numContexts, colorContextPtrs).ThrowOnFailureExtended();
}
colorContextsList = new List((int)numContexts);
@@ -549,7 +555,11 @@ private static Uri GetStandardColorSpaceProfile()
uint bufferSize = SIZE;
StringBuilder buffer = new StringBuilder(SIZE);
- HRESULT.Check(UnsafeNativeMethodsMilCoreApi.Mscms.GetStandardColorSpaceProfile(IntPtr.Zero, dwProfileID, buffer, out bufferSize));
+ UnsafeNativeMethodsMilCoreApi.Mscms.GetStandardColorSpaceProfile(
+ IntPtr.Zero,
+ dwProfileID,
+ buffer,
+ out bufferSize).ThrowOnFailureExtended();
Uri profilePath;
string profilePathString = buffer.ToString();
@@ -567,7 +577,10 @@ private static Uri GetStandardColorSpaceProfile()
// bufferSize was modified by GetStandardColorSpaceProfile so set it again
bufferSize = SIZE;
- HRESULT.Check(UnsafeNativeMethodsMilCoreApi.Mscms.GetColorDirectory(IntPtr.Zero, buffer, out bufferSize));
+ UnsafeNativeMethodsMilCoreApi.Mscms.GetColorDirectory(
+ IntPtr.Zero,
+ buffer,
+ out bufferSize).ThrowOnFailureExtended();
profilePath = new Uri(Path.Combine(buffer.ToString(), profilePathString));
}
@@ -600,8 +613,13 @@ private void FromStream(Stream stm, string filename)
using (FactoryMaker factoryMaker = new FactoryMaker())
{
- HRESULT.Check(UnsafeNativeMethodsMilCoreApi.WICCodec.CreateColorContext(factoryMaker.ImagingFactoryPtr, out _colorContextHandle));
- HRESULT.Check(IWICCC.InitializeFromMemory(_colorContextHandle, rawBytes, (uint)numBytesRead));
+ UnsafeNativeMethodsMilCoreApi.WICCodec.CreateColorContext(
+ factoryMaker.ImagingFactoryPtr,
+ out _colorContextHandle).ThrowOnFailureExtended();
+ IWICCC.InitializeFromMemory(
+ _colorContextHandle,
+ rawBytes,
+ (uint)numBytesRead).ThrowOnFailureExtended();
}
return;
@@ -647,8 +665,8 @@ private void FromRawBytes(byte[] data, int dataLength, bool dontThrowException)
return;
}
else
- {
- HRESULT.Check(Marshal.GetHRForLastWin32Error());
+ {
+ ((HRESULT)Marshal.GetHRForLastWin32Error()).ThrowOnFailureExtended();
}
}
}
@@ -661,8 +679,8 @@ private void FromRawBytes(byte[] data, int dataLength, bool dontThrowException)
return;
}
else
- {
- HRESULT.Check(Marshal.GetHRForLastWin32Error());
+ {
+ ((HRESULT)Marshal.GetHRForLastWin32Error()).ThrowOnFailureExtended();
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContextHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContextHelper.cs
index 5d5762e92a9..f903eb89868 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContextHelper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContextHelper.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -6,6 +6,7 @@
using MS.Internal;
using MS.Win32;
using Microsoft.Win32.SafeHandles;
+using Windows.Win32.Foundation;
using UnsafeNativeMethodsMilCoreApi = MS.Win32.PresentationCore.UnsafeNativeMethods;
@@ -91,7 +92,7 @@ internal void GetColorProfileFromHandle(byte[] buffer, ref uint bufferSize)
// what we want.
if (!UnsafeNativeMethodsMilCoreApi.Mscms.GetColorProfileFromHandle(_profileHandle, buffer, ref bufferSize) && buffer != null)
{
- HRESULT.Check(Marshal.GetHRForLastWin32Error());
+ ((HRESULT)Marshal.GetHRForLastWin32Error()).ThrowOnFailureExtended();
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorTransformHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorTransformHelper.cs
index 07975f176b3..5464975a233 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorTransformHelper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorTransformHelper.cs
@@ -1,10 +1,10 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
-using MS.Internal;
using Microsoft.Win32.SafeHandles;
+using Windows.Win32.Foundation;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
@@ -98,7 +98,7 @@ internal void CreateTransform(SafeProfileHandle sourceProfile, SafeProfileHandle
if (_transformHandle == null || _transformHandle.IsInvalid)
{
- HRESULT.Check(Marshal.GetHRForLastWin32Error());
+ ((HRESULT)Marshal.GetHRForLastWin32Error()).ThrowOnFailureExtended();
}
}
@@ -111,13 +111,13 @@ internal void TranslateColors(IntPtr paInputColors, UInt32 numColors, UInt32 inp
throw new InvalidOperationException(SR.Image_ColorTransformInvalid);
}
- HRESULT.Check(UnsafeNativeMethods.Mscms.TranslateColors(
+ UnsafeNativeMethods.Mscms.TranslateColors(
_transformHandle,
paInputColors,
numColors,
inputColorType,
paOutputColors,
- outputColorType));
+ outputColorType).ThrowOnFailureExtended();
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Composition.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Composition.cs
index 9aa79767051..40b03a38a25 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Composition.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Composition.cs
@@ -1,9 +1,10 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows.Media.Media3D;
using System.Runtime.InteropServices;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Composition
{
@@ -192,12 +193,12 @@ internal static UInt32 BooleanToUInt32(Boolean v)
internal static partial class MilCoreApi
{
[DllImport(DllImport.MilCore)]
- internal static extern int MilComposition_SyncFlush(
+ internal static extern HRESULT MilComposition_SyncFlush(
IntPtr pChannel
);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_GetPointAtLengthFraction(
+ internal unsafe static extern HRESULT MilUtility_GetPointAtLengthFraction(
MilMatrix3x2D *pMatrix,
FillRule fillRule,
byte *pPathData,
@@ -207,7 +208,7 @@ internal unsafe static extern int MilUtility_GetPointAtLengthFraction(
out Point vecTangent);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_PolygonBounds(
+ internal unsafe static extern HRESULT MilUtility_PolygonBounds(
MilMatrix3x2D *pWorldMatrix,
MIL_PEN_DATA *pPenData,
double *pDashArray,
@@ -222,7 +223,7 @@ internal unsafe static extern int MilUtility_PolygonBounds(
Rect *pBounds);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_PolygonHitTest(
+ internal unsafe static extern HRESULT MilUtility_PolygonHitTest(
MilMatrix3x2D *pGeometryMatrix,
MIL_PEN_DATA *pPenData,
double *pDashArray,
@@ -236,7 +237,7 @@ internal unsafe static extern int MilUtility_PolygonHitTest(
out bool pDoesContain);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_PathGeometryHitTest(
+ internal unsafe static extern HRESULT MilUtility_PathGeometryHitTest(
MilMatrix3x2D *pMatrix,
MIL_PEN_DATA* pPenData,
double* pDashArray,
@@ -249,7 +250,7 @@ internal unsafe static extern int MilUtility_PathGeometryHitTest(
out bool pDoesContain);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_PathGeometryHitTestPathGeometry(
+ internal unsafe static extern HRESULT MilUtility_PathGeometryHitTestPathGeometry(
MilMatrix3x2D *pMatrix1,
FillRule fillRule1,
byte *pPathData1,
@@ -263,7 +264,7 @@ internal unsafe static extern int MilUtility_PathGeometryHitTestPathGeometry(
IntersectionDetail* pDetail);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_GeometryGetArea(
+ internal unsafe static extern HRESULT MilUtility_GeometryGetArea(
FillRule fillRule,
byte *pPathData,
UInt32 nSize,
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/EventProxy.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/EventProxy.cs
index 1211eea8a75..1b3288c3af3 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/EventProxy.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/EventProxy.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -8,6 +8,7 @@
using MS.Internal;
using MS.Win32;
using System.Runtime.InteropServices;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
{
@@ -47,8 +48,8 @@ internal static class EventProxyStaticPtrs
{
static EventProxyStaticPtrs()
{
- EventProxyStaticPtrs.pfnDispose = new EventProxyDescriptor.Dispose(EventProxyDescriptor.StaticDispose);
- EventProxyStaticPtrs.pfnRaiseEvent = new EventProxyDescriptor.RaiseEvent(EventProxyWrapper.RaiseEvent);
+ pfnDispose = new EventProxyDescriptor.Dispose(EventProxyDescriptor.StaticDispose);
+ pfnRaiseEvent = new EventProxyDescriptor.RaiseEvent(EventProxyWrapper.RaiseEvent);
}
internal static EventProxyDescriptor.Dispose pfnDispose;
@@ -75,9 +76,8 @@ private EventProxyWrapper(IInvokable invokable)
#region Public methods
- public int RaiseEvent(byte[] buffer, uint cb)
+ public HRESULT RaiseEvent(byte[] buffer, uint cb)
{
-#pragma warning disable 6500
try
{
ObjectDisposedException.ThrowIf(target == null, typeof(EventProxyWrapper));
@@ -90,16 +90,15 @@ public int RaiseEvent(byte[] buffer, uint cb)
{
// return E_HANDLE to notify that object is no longer alive
- return NativeMethods.E_HANDLE;
+ return HRESULT.E_HANDLE;
}
}
catch (Exception e)
{
- return Marshal.GetHRForException(e);
+ return (HRESULT)Marshal.GetHRForException(e);
}
-#pragma warning restore 6500
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
#endregion
@@ -108,13 +107,13 @@ public int RaiseEvent(byte[] buffer, uint cb)
internal static EventProxyWrapper FromEPD(ref EventProxyDescriptor epd)
{
Debug.Assert(((IntPtr)epd.m_handle) != IntPtr.Zero, "Stream is disposed.");
- System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)(epd.m_handle);
- return (EventProxyWrapper)(handle.Target);
+ GCHandle handle = epd.m_handle;
+ return (EventProxyWrapper)handle.Target;
}
internal static int RaiseEvent(ref EventProxyDescriptor pEPD, byte[] buffer, uint cb)
{
- EventProxyWrapper target = EventProxyWrapper.FromEPD(ref pEPD);
+ EventProxyWrapper target = FromEPD(ref pEPD);
if (target != null)
{
return target.RaiseEvent(buffer, cb);
@@ -141,9 +140,9 @@ internal static SafeMILHandle CreateEventProxyWrapper(IInvokable invokable)
epd.pfnDispose = EventProxyStaticPtrs.pfnDispose;
epd.pfnRaiseEvent = EventProxyStaticPtrs.pfnRaiseEvent;
- epd.m_handle = System.Runtime.InteropServices.GCHandle.Alloc(epw, System.Runtime.InteropServices.GCHandleType.Normal);
+ epd.m_handle = GCHandle.Alloc(epw, GCHandleType.Normal);
- HRESULT.Check(MILCreateEventProxy(ref epd, out eventProxy));
+ MILCreateEventProxy(ref epd, out eventProxy).ThrowOnFailureExtended();
return eventProxy;
}
@@ -151,7 +150,7 @@ internal static SafeMILHandle CreateEventProxyWrapper(IInvokable invokable)
#endregion
[DllImport(DllImport.MilCore)]
- private extern static int /* HRESULT */ MILCreateEventProxy(ref EventProxyDescriptor pEPD, out SafeMILHandle ppEventProxy);
+ private extern static HRESULT MILCreateEventProxy(ref EventProxyDescriptor pEPD, out SafeMILHandle ppEventProxy);
}
#endregion
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FactoryMaker.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FactoryMaker.cs
index 547656c256b..5d0484a6c2c 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FactoryMaker.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FactoryMaker.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -6,6 +6,7 @@
//
using MS.Internal;
+using Windows.Win32.Foundation;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
namespace System.Windows.Media
@@ -30,7 +31,9 @@ internal FactoryMaker()
// should catch it. We won't add ref counter here if this
// happens.
- HRESULT.Check(UnsafeNativeMethods.MILFactory2.CreateFactory(out s_pFactory, MS.Internal.Composition.Version.MilSdkVersion));
+ UnsafeNativeMethods.MILFactory2.CreateFactory(
+ out s_pFactory,
+ MS.Internal.Composition.Version.MilSdkVersion).ThrowOnFailureExtended();
}
s_cInstance++;
@@ -111,7 +114,9 @@ internal IntPtr ImagingFactoryPtr
{
lock (s_factoryMakerLock)
{
- HRESULT.Check(UnsafeNativeMethods.WICCodec.CreateImagingFactory(UnsafeNativeMethods.WICCodec.WINCODEC_SDK_VERSION, out s_pImagingFactory));
+ UnsafeNativeMethods.WICCodec.CreateImagingFactory(
+ UnsafeNativeMethods.WICCodec.WINCODEC_SDK_VERSION,
+ out s_pImagingFactory).ThrowOnFailureExtended();
}
}
Debug.Assert(s_pImagingFactory != IntPtr.Zero);
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Geometry.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Geometry.cs
index 1a1e8ad9597..0542192d81e 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Geometry.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Geometry.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -14,6 +14,7 @@
using System.Windows.Media.Composition;
using System.Windows.Media.Animation;
using System.Runtime.InteropServices;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
{
@@ -186,7 +187,7 @@ internal unsafe static Rect GetBoundsHelper(
fixed (double *pDashArray = dashArray)
{
- int hr = MilCoreApi.MilUtility_PolygonBounds(
+ HRESULT result = MilCoreApi.MilUtility_PolygonBounds(
&worldMatrix,
(fPenContributesToBounds) ? &penData : null,
(dashArray == null) ? null : pDashArray,
@@ -201,7 +202,7 @@ internal unsafe static Rect GetBoundsHelper(
&bounds
);
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we report that the geometry has empty bounds.
@@ -209,7 +210,7 @@ internal unsafe static Rect GetBoundsHelper(
}
else
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
@@ -286,7 +287,7 @@ public virtual double GetArea(double tolerance, ToleranceType type)
{
Debug.Assert(pbPathData != (byte*)0);
- int hr = MilCoreApi.MilUtility_GeometryGetArea(
+ HRESULT result = MilCoreApi.MilUtility_GeometryGetArea(
pathData.FillRule,
pbPathData,
pathData.Size,
@@ -295,7 +296,7 @@ public virtual double GetArea(double tolerance, ToleranceType type)
type == ToleranceType.Relative,
&area);
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we report that the geometry has 0 area.
@@ -303,7 +304,7 @@ public virtual double GetArea(double tolerance, ToleranceType type)
}
else
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
}
@@ -407,21 +408,21 @@ internal virtual bool ContainsInternal(Pen pen, Point hitPoint, double tolerance
{
Debug.Assert(pbPathData != (byte*)0);
- fixed (double * dashArrayFixed = dashArray)
+ fixed (double* dashArrayFixed = dashArray)
{
- int hr = MilCoreApi.MilUtility_PathGeometryHitTest(
- &pathData.Matrix,
- (pen == null) ? null : &penData,
- dashArrayFixed,
- pathData.FillRule,
- pbPathData,
- pathData.Size,
- tolerance,
- type == ToleranceType.Relative,
- &hitPoint,
- out contains);
-
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ HRESULT result = MilCoreApi.MilUtility_PathGeometryHitTest(
+ &pathData.Matrix,
+ (pen == null) ? null : &penData,
+ dashArrayFixed,
+ pathData.FillRule,
+ pbPathData,
+ pathData.Size,
+ tolerance,
+ type == ToleranceType.Relative,
+ &hitPoint,
+ out contains);
+
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we report that the geometry is never hittable.
@@ -429,7 +430,7 @@ internal virtual bool ContainsInternal(Pen pen, Point hitPoint, double tolerance
}
else
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
}
@@ -458,20 +459,20 @@ internal unsafe bool ContainsInternal(Pen pen, Point hitPoint, double tolerance,
fixed (double *dashArrayFixed = dashArray)
{
- int hr = MilCoreApi.MilUtility_PolygonHitTest(
- &matrix,
- (pen == null) ? null : &penData,
- dashArrayFixed,
- pPoints,
- pTypes,
- pointCount,
- typeCount,
- tolerance,
- type == ToleranceType.Relative,
- &hitPoint,
- out contains);
+ HRESULT result = MilCoreApi.MilUtility_PolygonHitTest(
+ &matrix,
+ (pen == null) ? null : &penData,
+ dashArrayFixed,
+ pPoints,
+ pTypes,
+ pointCount,
+ typeCount,
+ tolerance,
+ type == ToleranceType.Relative,
+ &hitPoint,
+ out contains);
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we report that the geometry is never hittable.
@@ -479,7 +480,7 @@ internal unsafe bool ContainsInternal(Pen pen, Point hitPoint, double tolerance,
}
else
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
@@ -612,8 +613,8 @@ public virtual PathGeometry GetFlattenedPathGeometry(double tolerance, Tolerance
FillRule fillRule = FillRule.Nonzero;
PathGeometry.FigureList list = new PathGeometry.FigureList();
-
- int hr = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryFlatten(
+
+ HRESULT result = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryFlatten(
&pathData.Matrix,
pathData.FillRule,
pbPathData,
@@ -623,7 +624,7 @@ public virtual PathGeometry GetFlattenedPathGeometry(double tolerance, Tolerance
new PathGeometry.AddFigureToListDelegate(list.AddFigureToList),
out fillRule);
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we return an empty geometry.
@@ -631,8 +632,7 @@ public virtual PathGeometry GetFlattenedPathGeometry(double tolerance, Tolerance
}
else
{
- HRESULT.Check(hr);
-
+ result.ThrowOnFailureExtended();
resultGeometry = new PathGeometry(list.Figures, fillRule, null);
}
}
@@ -709,7 +709,7 @@ public virtual PathGeometry GetWidenedPathGeometry(Pen pen, double tolerance, To
try
{
- int hr = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryWiden(
+ HRESULT result = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryWiden(
&penData,
(dashArray == null) ? null : (double*)handle.AddrOfPinnedObject(),
&pathData.Matrix,
@@ -721,7 +721,7 @@ public virtual PathGeometry GetWidenedPathGeometry(Pen pen, double tolerance, To
new PathGeometry.AddFigureToListDelegate(list.AddFigureToList),
out fillRule);
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we return an empty geometry.
@@ -729,8 +729,7 @@ public virtual PathGeometry GetWidenedPathGeometry(Pen pen, double tolerance, To
}
else
{
- HRESULT.Check(hr);
-
+ result.ThrowOnFailureExtended();
resultGeometry = new PathGeometry(list.Figures, fillRule, null);
}
}
@@ -796,11 +795,11 @@ public static PathGeometry Combine(
Transform transform)
{
return PathGeometry.InternalCombine(
- geometry1,
- geometry2,
- mode,
- transform,
- Geometry.StandardFlatteningTolerance,
+ geometry1,
+ geometry2,
+ mode,
+ transform,
+ StandardFlatteningTolerance,
ToleranceType.Absolute);
}
@@ -841,7 +840,7 @@ public virtual PathGeometry GetOutlinedPathGeometry(double tolerance, ToleranceT
FillRule fillRule = FillRule.Nonzero;
PathGeometry.FigureList list = new PathGeometry.FigureList();
- int hr = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryOutline(
+ HRESULT result = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryOutline(
&pathData.Matrix,
pathData.FillRule,
pbPathData,
@@ -851,7 +850,7 @@ public virtual PathGeometry GetOutlinedPathGeometry(double tolerance, ToleranceT
new PathGeometry.AddFigureToListDelegate(list.AddFigureToList),
out fillRule);
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we return an empty geometry.
@@ -859,8 +858,7 @@ public virtual PathGeometry GetOutlinedPathGeometry(double tolerance, ToleranceT
}
else
{
- HRESULT.Check(hr);
-
+ result.ThrowOnFailureExtended();
resultGeometry = new PathGeometry(list.Figures, fillRule, null);
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphTypeface.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphTypeface.cs
index c7eca52c219..33ef29335e8 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphTypeface.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphTypeface.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -23,6 +23,7 @@
using MS.Internal.FontFace;
using MS.Internal.PresentationCore;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
@@ -828,7 +829,7 @@ public IDictionary AdvanceWidths
get
{
CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
- return CreateGlyphIndexer(this.GetAdvanceWidth);
+ return CreateGlyphIndexer(GetAdvanceWidth);
}
}
@@ -840,7 +841,7 @@ public IDictionary AdvanceHeights
get
{
CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
- return CreateGlyphIndexer(this.GetAdvanceHeight);
+ return CreateGlyphIndexer(GetAdvanceHeight);
}
}
@@ -855,7 +856,7 @@ public IDictionary LeftSideBearings
get
{
CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
- return CreateGlyphIndexer(this.GetLeftSidebearing);
+ return CreateGlyphIndexer(GetLeftSidebearing);
}
}
@@ -870,7 +871,7 @@ public IDictionary RightSideBearings
get
{
CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
- return CreateGlyphIndexer(this.GetRightSidebearing);
+ return CreateGlyphIndexer(GetRightSidebearing);
}
}
@@ -886,7 +887,7 @@ public IDictionary TopSideBearings
get
{
CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
- return CreateGlyphIndexer(this.GetTopSidebearing);
+ return CreateGlyphIndexer(GetTopSidebearing);
}
}
@@ -902,7 +903,7 @@ public IDictionary BottomSideBearings
get
{
CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
- return CreateGlyphIndexer(this.GetBottomSidebearing);
+ return CreateGlyphIndexer(GetBottomSidebearing);
}
}
@@ -914,7 +915,7 @@ public IDictionary DistancesFromHorizontalBaselineToBlackBoxBott
get
{
CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
- return CreateGlyphIndexer(this.GetBaseline);
+ return CreateGlyphIndexer(GetBaseline);
}
}
@@ -1263,7 +1264,7 @@ internal Geometry ComputeGlyphOutline(ushort glyphIndex,
MS.Internal.Text.TextInterface.FontFace fontFaceDWrite = _font.GetFontFace();
try
{
- HRESULT.Check(UnsafeNativeMethods.MilCoreApi.MilGlyphRun_GetGlyphOutline(
+ UnsafeNativeMethods.MilCoreApi.MilGlyphRun_GetGlyphOutline(
fontFaceDWrite.DWriteFontFaceAddRef, // Released in this native code function
glyphIndex,
sideways,
@@ -1271,7 +1272,7 @@ internal Geometry ComputeGlyphOutline(ushort glyphIndex,
out pMilPathGeometry,
out size,
out fillRule
- ));
+ ).ThrowOnFailureExtended();
}
finally
{
@@ -1281,12 +1282,11 @@ out fillRule
Geometry.PathGeometryData pathGeoData = new Geometry.PathGeometryData();
byte[] data = new byte[size];
Marshal.Copy(new IntPtr(pMilPathGeometry), data, 0, checked((int)size));
-
+
// Delete the memory we allocated in native code.
- HRESULT.Check(UnsafeNativeMethods.MilCoreApi.MilGlyphRun_ReleasePathGeometryData(
- pMilPathGeometry
- ));
-
+ UnsafeNativeMethods.MilCoreApi.MilGlyphRun_ReleasePathGeometryData(
+ pMilPathGeometry).ThrowOnFailureExtended();
+
pathGeoData.SerializedData = data;
pathGeoData.FillRule = fillRule;
pathGeoData.Matrix = CompositionResourceManager.MatrixToMilMatrix3x2D(Matrix.Identity);
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapCodecInfo.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapCodecInfo.cs
index 2da17eb0970..e6964492c7f 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapCodecInfo.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapCodecInfo.cs
@@ -1,13 +1,10 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-//
-
-using MS.Internal;
using MS.Win32.PresentationCore;
using System.Text;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -48,15 +45,11 @@ public virtual Guid ContainerFormat
{
get
{
-
EnsureBuiltIn();
- Guid containerFormat;
-
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetContainerFormat(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetContainerFormat(
_codecInfoHandle,
- out containerFormat
- ));
+ out Guid containerFormat).ThrowOnFailureExtended();
return containerFormat;
}
@@ -69,125 +62,98 @@ public virtual string Author
{
get
{
-
EnsureBuiltIn();
StringBuilder author = null;
- UInt32 length = 0;
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICComponentInfo.GetAuthor(
+ UnsafeNativeMethods.WICComponentInfo.GetAuthor(
_codecInfoHandle,
0,
author,
- out length
- ));
+ out uint length).ThrowOnFailureExtended();
- Debug.Assert(length >= 0);
-
- // get the string back
+ // Get the string back
if (length > 0)
{
author = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICComponentInfo.GetAuthor(
+ UnsafeNativeMethods.WICComponentInfo.GetAuthor(
_codecInfoHandle,
length,
author,
- out length
- ));
+ out _).ThrowOnFailureExtended();
}
- if (author != null)
- return author.ToString();
- else
- return String.Empty;
+ return author?.ToString() ?? string.Empty;
}
}
///
- /// Version
+ /// Version
///
- public virtual System.Version Version
+ public virtual Version Version
{
get
{
-
EnsureBuiltIn();
StringBuilder version = null;
- UInt32 length = 0;
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICComponentInfo.GetVersion(
+ UnsafeNativeMethods.WICComponentInfo.GetVersion(
_codecInfoHandle,
0,
version,
- out length
- ));
-
- Debug.Assert(length >= 0);
+ out uint length).ThrowOnFailureExtended();
- // get the string back
if (length > 0)
{
+ // Get the string back
version = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICComponentInfo.GetVersion(
+ UnsafeNativeMethods.WICComponentInfo.GetVersion(
_codecInfoHandle,
length,
version,
- out length
- ));
+ out _).ThrowOnFailureExtended();
}
- if (version != null)
- return new Version(version.ToString());
- else
- return new Version();
+ return version is not null ? new Version(version.ToString()) : new Version();
}
}
///
- /// Spec Version
+ /// Spec Version
///
public virtual Version SpecificationVersion
{
get
{
-
EnsureBuiltIn();
StringBuilder specVersion = null;
- UInt32 length = 0;
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICComponentInfo.GetSpecVersion(
+ UnsafeNativeMethods.WICComponentInfo.GetSpecVersion(
_codecInfoHandle,
0,
specVersion,
- out length
- ));
-
- Debug.Assert(length >= 0);
+ out uint length).ThrowOnFailureExtended();
- // get the string back
+ // Get the string back
if (length > 0)
{
specVersion = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICComponentInfo.GetSpecVersion(
+ UnsafeNativeMethods.WICComponentInfo.GetSpecVersion(
_codecInfoHandle,
length,
specVersion,
- out length
- ));
+ out _).ThrowOnFailureExtended();
}
- if (specVersion != null)
- return new Version(specVersion.ToString());
- else
- return new Version();
+ return specVersion is not null ? new Version(specVersion.ToString()) : new Version();
}
}
@@ -198,39 +164,33 @@ public virtual string FriendlyName
{
get
{
-
EnsureBuiltIn();
StringBuilder friendlyName = null;
- UInt32 length = 0;
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICComponentInfo.GetFriendlyName(
+ UnsafeNativeMethods.WICComponentInfo.GetFriendlyName(
_codecInfoHandle,
0,
friendlyName,
- out length
- ));
+ out uint length).ThrowOnFailureExtended();
Debug.Assert(length >= 0);
- // get the string back
+ // Get the string back
if (length > 0)
{
friendlyName = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICComponentInfo.GetFriendlyName(
+ UnsafeNativeMethods.WICComponentInfo.GetFriendlyName(
_codecInfoHandle,
length,
friendlyName,
out length
- ));
+ ).ThrowOnFailureExtended();
}
- if (friendlyName != null)
- return friendlyName.ToString();
- else
- return String.Empty;
+ return friendlyName?.ToString() ?? string.Empty;
}
}
@@ -241,39 +201,30 @@ public virtual string DeviceManufacturer
{
get
{
-
EnsureBuiltIn();
StringBuilder deviceManufacturer = null;
- UInt32 length = 0;
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetDeviceManufacturer(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetDeviceManufacturer(
_codecInfoHandle,
0,
deviceManufacturer,
- out length
- ));
-
- Debug.Assert(length >= 0);
+ out uint length).ThrowOnFailureExtended();
- // get the string back
+ // Get the string back
if (length > 0)
{
deviceManufacturer = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetDeviceManufacturer(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetDeviceManufacturer(
_codecInfoHandle,
length,
deviceManufacturer,
- out length
- ));
+ out length).ThrowOnFailureExtended();
}
- if (deviceManufacturer != null)
- return deviceManufacturer.ToString();
- else
- return String.Empty;
+ return deviceManufacturer?.ToString() ?? string.Empty;
}
}
@@ -284,39 +235,30 @@ public virtual string DeviceModels
{
get
{
-
EnsureBuiltIn();
StringBuilder deviceModels = null;
- UInt32 length = 0;
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetDeviceModels(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetDeviceModels(
_codecInfoHandle,
0,
deviceModels,
- out length
- ));
-
- Debug.Assert(length >= 0);
+ out uint length).ThrowOnFailureExtended();
- // get the string back
+ // Get the string back
if (length > 0)
{
deviceModels = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetDeviceModels(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetDeviceModels(
_codecInfoHandle,
length,
deviceModels,
- out length
- ));
+ out _).ThrowOnFailureExtended();
}
- if (deviceModels != null)
- return deviceModels.ToString();
- else
- return String.Empty;
+ return deviceModels?.ToString() ?? string.Empty;
}
}
@@ -327,39 +269,32 @@ public virtual string MimeTypes
{
get
{
-
EnsureBuiltIn();
StringBuilder mimeTypes = null;
- UInt32 length = 0;
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetMimeTypes(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetMimeTypes(
_codecInfoHandle,
0,
mimeTypes,
- out length
- ));
+ out uint length).ThrowOnFailureExtended();
Debug.Assert(length >= 0);
- // get the string back
+ // Get the string back
if (length > 0)
{
mimeTypes = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetMimeTypes(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetMimeTypes(
_codecInfoHandle,
length,
mimeTypes,
- out length
- ));
+ out _).ThrowOnFailureExtended();
}
- if (mimeTypes != null)
- return mimeTypes.ToString();
- else
- return String.Empty;
+ return mimeTypes?.ToString() ?? string.Empty;
}
}
@@ -370,39 +305,30 @@ public virtual string FileExtensions
{
get
{
-
EnsureBuiltIn();
StringBuilder fileExtensions = null;
- UInt32 length = 0;
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetFileExtensions(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetFileExtensions(
_codecInfoHandle,
0,
fileExtensions,
- out length
- ));
+ out uint length).ThrowOnFailureExtended();
- Debug.Assert(length >= 0);
-
- // get the string back
+ // Get the string back
if (length > 0)
{
fileExtensions = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetFileExtensions(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetFileExtensions(
_codecInfoHandle,
length,
fileExtensions,
- out length
- ));
+ out _).ThrowOnFailureExtended();
}
- if (fileExtensions != null)
- return fileExtensions.ToString();
- else
- return String.Empty;
+ return fileExtensions?.ToString() ?? string.Empty;
}
}
@@ -413,15 +339,11 @@ public virtual bool SupportsAnimation
{
get
{
-
EnsureBuiltIn();
- bool supportsAnimation;
-
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.DoesSupportAnimation(
+ UnsafeNativeMethods.WICBitmapCodecInfo.DoesSupportAnimation(
_codecInfoHandle,
- out supportsAnimation
- ));
+ out bool supportsAnimation).ThrowOnFailureExtended();
return supportsAnimation;
}
@@ -434,15 +356,11 @@ public virtual bool SupportsLossless
{
get
{
-
EnsureBuiltIn();
- bool supportsLossless;
-
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.DoesSupportLossless(
+ UnsafeNativeMethods.WICBitmapCodecInfo.DoesSupportLossless(
_codecInfoHandle,
- out supportsLossless
- ));
+ out bool supportsLossless).ThrowOnFailureExtended();
return supportsLossless;
}
@@ -455,15 +373,11 @@ public virtual bool SupportsMultipleFrames
{
get
{
-
EnsureBuiltIn();
- bool supportsMultiFrame;
-
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.DoesSupportMultiframe(
+ UnsafeNativeMethods.WICBitmapCodecInfo.DoesSupportMultiframe(
_codecInfoHandle,
- out supportsMultiFrame
- ));
+ out bool supportsMultiFrame).ThrowOnFailureExtended();
return supportsMultiFrame;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapDecoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapDecoder.cs
index ca0edcb0cfb..75732cb982f 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapDecoder.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapDecoder.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -15,6 +15,7 @@
using System.Net;
using System.Net.Cache;
using System.Text;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -243,7 +244,7 @@ bool insertInDecoderCache
if (uri != null)
{
finalUri = (baseUri != null) ?
- System.Windows.Navigation.BaseUriHelper.GetResolvedUri(baseUri, uri) :
+ Navigation.BaseUriHelper.GetResolvedUri(baseUri, uri) :
uri;
if (insertInDecoderCache)
@@ -278,7 +279,7 @@ out clsId
else
{
// Create an unmanaged decoder
- decoderHandle = BitmapDecoder.SetupDecoderFromUriOrStream(
+ decoderHandle = SetupDecoderFromUriOrStream(
finalUri,
stream,
cacheOption,
@@ -524,13 +525,13 @@ public virtual BitmapPalette Palette
lock (_syncObject)
{
- int hr = UnsafeNativeMethods.WICBitmapDecoder.CopyPalette(
+ HRESULT result = UnsafeNativeMethods.WICBitmapDecoder.CopyPalette(
_decoderHandle,
- paletteHandle
- );
- if (hr != (int)WinCodecErrors.WINCODEC_ERR_PALETTEUNAVAILABLE)
+ paletteHandle);
+
+ if (result != HRESULT.WINCODEC_ERR_PALETTEUNAVAILABLE)
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
_palette = new BitmapPalette(paletteHandle);
}
}
@@ -574,13 +575,13 @@ public virtual BitmapSource Thumbnail
// Check if there is embedded thumbnail or not
lock (_syncObject)
{
- int hr = UnsafeNativeMethods.WICBitmapDecoder.GetThumbnail(
+ HRESULT result = UnsafeNativeMethods.WICBitmapDecoder.GetThumbnail(
_decoderHandle,
- out thumbnail
- );
- if (hr != (int)WinCodecErrors.WINCODEC_ERR_CODECNOTHUMBNAIL)
+ out thumbnail);
+
+ if (result != HRESULT.WINCODEC_ERR_CODECNOTHUMBNAIL)
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
@@ -589,16 +590,16 @@ out thumbnail
BitmapSourceSafeMILHandle thumbHandle = new BitmapSourceSafeMILHandle(thumbnail);
SafeMILHandle unmanagedPalette = BitmapPalette.CreateInternalPalette();
BitmapPalette palette = null;
-
- int hr = UnsafeNativeMethods.WICBitmapSource.CopyPalette(
- thumbHandle,
- unmanagedPalette
- );
- if (hr == HRESULT.S_OK)
+
+ HRESULT result = UnsafeNativeMethods.WICBitmapSource.CopyPalette(
+ thumbHandle,
+ unmanagedPalette);
+
+ if (result == HRESULT.S_OK)
{
palette = new BitmapPalette(unmanagedPalette);
}
-
+
_thumbnail = new UnmanagedBitmapWrapper(
BitmapSource.CreateCachedBitmap(
null,
@@ -634,13 +635,13 @@ public virtual BitmapMetadata Metadata
lock (_syncObject)
{
- int hr = UnsafeNativeMethods.WICBitmapDecoder.GetMetadataQueryReader(
+ HRESULT result = UnsafeNativeMethods.WICBitmapDecoder.GetMetadataQueryReader(
_decoderHandle,
- out metadata
- );
- if (hr != (int)WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION)
+ out metadata);
+
+ if (result != HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION)
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
@@ -674,10 +675,9 @@ public virtual BitmapCodecInfo CodecInfo
{
SafeMILHandle /* IWICBitmapDecoderInfo */ codecInfoHandle = new SafeMILHandle();
- HRESULT.Check(UnsafeNativeMethods.WICBitmapDecoder.GetDecoderInfo(
+ UnsafeNativeMethods.WICBitmapDecoder.GetDecoderInfo(
_decoderHandle,
- out codecInfoHandle
- ));
+ out codecInfoHandle).ThrowOnFailureExtended();
_codecInfo = new BitmapCodecInfoInternal(codecInfoHandle);
}
@@ -728,13 +728,13 @@ public virtual BitmapSource Preview
lock (_syncObject)
{
// Check if there is embedded preview or not
- int hr = UnsafeNativeMethods.WICBitmapDecoder.GetPreview(
+ HRESULT result = UnsafeNativeMethods.WICBitmapDecoder.GetPreview(
_decoderHandle,
- out preview
- );
- if (hr != (int)WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION)
+ out preview);
+
+ if (result != HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION)
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
@@ -743,27 +743,27 @@ out preview
BitmapSourceSafeMILHandle previewHandle = new BitmapSourceSafeMILHandle(preview);
SafeMILHandle unmanagedPalette = BitmapPalette.CreateInternalPalette();
BitmapPalette palette = null;
-
- int hr = UnsafeNativeMethods.WICBitmapSource.CopyPalette(
- previewHandle,
- unmanagedPalette
- );
- if (hr == HRESULT.S_OK)
+
+ HRESULT result = UnsafeNativeMethods.WICBitmapSource.CopyPalette(
+ previewHandle,
+ unmanagedPalette);
+
+ if (result == HRESULT.S_OK)
{
palette = new BitmapPalette(unmanagedPalette);
}
-
+
_preview = new UnmanagedBitmapWrapper(
BitmapSource.CreateCachedBitmap(
null,
previewHandle,
BitmapCreateOptions.PreservePixelFormat,
_cacheOption,
- palette
- ));
+ palette));
+
_preview.Freeze();
}
-
+
_isPreviewCached = true;
}
@@ -938,10 +938,10 @@ internal object SyncObject
///
/// Used as a delegate in InternalColorContexts to get the unmanaged IWICColorContexts
///
- private int GetColorContexts(ref uint numContexts, IntPtr[] colorContextPtrs)
+ private HRESULT GetColorContexts(ref uint numContexts, IntPtr[] colorContextPtrs)
{
Invariant.Assert(colorContextPtrs == null || numContexts <= colorContextPtrs.Length);
-
+
return UnsafeNativeMethods.WICBitmapDecoder.GetColorContexts(_decoderHandle, numContexts, colorContextPtrs, out numContexts);
}
@@ -982,7 +982,7 @@ internal void CheckOriginalWritable()
{
if (!_isOriginalWritable)
{
- throw new System.InvalidOperationException(SR.Image_OriginalStreamReadOnly);
+ throw new InvalidOperationException(SR.Image_OriginalStreamReadOnly);
}
}
@@ -1003,7 +1003,7 @@ out SafeFileHandle safeFilehandle
{
SafeMILHandle decoderHandle;
IntPtr decoder = IntPtr.Zero;
- System.IO.Stream bitmapStream = null;
+ Stream bitmapStream = null;
unmanagedMemoryStream = null;
safeFilehandle = null;
isOriginalWritable = false;
@@ -1030,7 +1030,7 @@ out SafeFileHandle safeFilehandle
}
}
- if ((bitmapStream == null) || (bitmapStream == System.IO.Stream.Null))
+ if ((bitmapStream == null) || (bitmapStream == Stream.Null))
{
// We didn't get a stream from the pack web request, so we have
// to try to create one ourselves.
@@ -1044,7 +1044,7 @@ out SafeFileHandle safeFilehandle
if (uri.IsFile)
{
// FileStream does a demand for us, so no need to do a demand
- bitmapStream = new System.IO.FileStream(uri.LocalPath, FileMode.Open, FileAccess.Read, FileShare.Read);
+ bitmapStream = new FileStream(uri.LocalPath, FileMode.Open, FileAccess.Read, FileShare.Read);
}
}
else // Any other zone
@@ -1075,7 +1075,7 @@ out SafeFileHandle safeFilehandle
// We don't have an absolute URI, so we don't necessarily know
// if it is a file, but we'll have to assume it is and try to
// create a stream from the original string.
- bitmapStream = new System.IO.FileStream(uri.OriginalString, FileMode.Open, FileAccess.Read, FileShare.Read);
+ bitmapStream = new FileStream(uri.OriginalString, FileMode.Open, FileAccess.Read, FileShare.Read);
#pragma warning restore 6518
}
@@ -1104,9 +1104,9 @@ out SafeFileHandle safeFilehandle
IntPtr comStream = IntPtr.Zero;
- if (stream is System.IO.FileStream)
+ if (stream is FileStream)
{
- System.IO.FileStream filestream = stream as System.IO.FileStream;
+ FileStream filestream = stream as FileStream;
try
{
if (filestream.IsAsync is false)
@@ -1142,29 +1142,27 @@ out SafeFileHandle safeFilehandle
{
using (FactoryMaker myFactory = new FactoryMaker())
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateDecoderFromFileHandle(
+ UnsafeNativeMethods.WICImagingFactory.CreateDecoderFromFileHandle(
myFactory.ImagingFactoryPtr,
safeFilehandle,
ref vendorMicrosoft,
metadataFlags,
- out decoder
- ));
+ out decoder).ThrowOnFailureExtended();
}
}
else
{
- comStream = BitmapDecoder.GetIStreamFromStream(ref stream);
+ comStream = GetIStreamFromStream(ref stream);
using (FactoryMaker myFactory = new FactoryMaker())
{
// This does an add-ref on the comStream
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateDecoderFromStream(
+ UnsafeNativeMethods.WICImagingFactory.CreateDecoderFromStream(
myFactory.ImagingFactoryPtr,
comStream,
ref vendorMicrosoft,
metadataFlags,
- out decoder
- ));
+ out decoder).ThrowOnFailureExtended();
}
}
Debug.Assert(decoder != IntPtr.Zero);
@@ -1228,7 +1226,7 @@ private static Stream ProcessUncFiles(Uri uri)
{
- return new System.IO.FileStream(uri.LocalPath, FileMode.Open, FileAccess.Read, FileShare.Read);
+ return new FileStream(uri.LocalPath, FileMode.Open, FileAccess.Read, FileShare.Read);
}
/// Returns the decoder's CLSID
@@ -1238,52 +1236,41 @@ private static Guid GetCLSIDFromDecoder(SafeMILHandle decoderHandle, out string
// Get the decoder info
SafeMILHandle decoderInfo = new SafeMILHandle();
- HRESULT.Check(UnsafeNativeMethods.WICBitmapDecoder.GetDecoderInfo(
+ UnsafeNativeMethods.WICBitmapDecoder.GetDecoderInfo(
decoderHandle,
- out decoderInfo
- ));
+ out decoderInfo).ThrowOnFailureExtended();
// Get CLSID for the decoder
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetContainerFormat(decoderInfo, out clsId));
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetContainerFormat(decoderInfo, out clsId).ThrowOnFailureExtended();
StringBuilder mimeTypes = null;
- UInt32 length = 0;
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetMimeTypes(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetMimeTypes(
decoderInfo,
0,
mimeTypes,
- out length
- ));
+ out uint length).ThrowOnFailureExtended();
- // get the string back
+ // Get the string back
if (length > 0)
{
mimeTypes = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICBitmapCodecInfo.GetMimeTypes(
+ UnsafeNativeMethods.WICBitmapCodecInfo.GetMimeTypes(
decoderInfo,
length,
mimeTypes,
- out length
- ));
+ out _).ThrowOnFailureExtended();
}
- if (mimeTypes != null)
- {
- decoderMimeTypes = mimeTypes.ToString();
- }
- else
- {
- decoderMimeTypes = String.Empty;
- }
+ decoderMimeTypes = mimeTypes?.ToString() ?? string.Empty;
return clsId;
}
/// Return a seekable stream if the current one is not seekable
- private static System.IO.Stream GetSeekableStream(System.IO.Stream bitmapStream)
+ private static Stream GetSeekableStream(Stream bitmapStream)
{
// MIL codecs require the source stream to be seekable. But if
// the source stream is an internet stream, it is not seekable.
@@ -1301,8 +1288,8 @@ private static System.IO.Stream GetSeekableStream(System.IO.Stream bitmapStream)
// hack here and pass the network stream (CConectStream)
// directly to the unmanaged code
- System.IO.MemoryStream memStream =
- new System.IO.MemoryStream();
+ MemoryStream memStream =
+ new MemoryStream();
byte[] buffer = new byte[1024];
int read;
@@ -1323,7 +1310,7 @@ private static System.IO.Stream GetSeekableStream(System.IO.Stream bitmapStream)
} while (true);
// Reset the memory stream pointer back to the begining
- memStream.Seek(0, System.IO.SeekOrigin.Begin);
+ memStream.Seek(0, SeekOrigin.Begin);
// Use the new stream
@@ -1434,7 +1421,7 @@ internal void SetupFrames(BitmapDecoder decoder, ReadOnlyCollection
{
uint numFrames = 1;
- HRESULT.Check(UnsafeNativeMethods.WICBitmapDecoder.GetFrameCount(_decoderHandle, out numFrames));
+ UnsafeNativeMethods.WICBitmapDecoder.GetFrameCount(_decoderHandle, out numFrames).ThrowOnFailureExtended();
_frames = new List((int)numFrames);
@@ -1502,7 +1489,7 @@ private void EnsureBuiltInDecoder()
///
///
///
- private static IntPtr GetIStreamFromStream(ref System.IO.Stream bitmapStream)
+ private static IntPtr GetIStreamFromStream(ref Stream bitmapStream)
{
IntPtr comStream = IntPtr.Zero;
@@ -1532,7 +1519,7 @@ private static IntPtr GetIStreamFromStream(ref System.IO.Stream bitmapStream)
if (comStream == IntPtr.Zero)
{
- throw new System.InvalidOperationException(
+ throw new InvalidOperationException(
SR.Image_CantDealWithStream);
}
@@ -1546,12 +1533,12 @@ private static IntPtr GetIStreamFromStream(ref System.IO.Stream bitmapStream)
{
// we don't need the original stream anymore
UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref comStream);
- bitmapStream = System.IO.Stream.Null;
+ bitmapStream = Stream.Null;
return memoryStream;
}
else if (!seekable)
{
- throw new System.InvalidOperationException(
+ throw new InvalidOperationException(
SR.Image_CantDealWithStream);
}
}
@@ -1559,7 +1546,7 @@ private static IntPtr GetIStreamFromStream(ref System.IO.Stream bitmapStream)
if (comStream == IntPtr.Zero)
{
- throw new System.InvalidOperationException(
+ throw new InvalidOperationException(
SR.Image_CantDealWithStream);
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapEncoder.cs
index ebfb262c206..6eae6b533db 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapEncoder.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapEncoder.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using System.Windows.Threading;
using System.Runtime.InteropServices;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
#pragma warning disable 1634, 1691 // suppressing PreSharp warnings
@@ -243,12 +244,11 @@ public virtual BitmapCodecInfo CodecInfo
// There should always be a codec info.
if (_codecInfo == null)
{
- SafeMILHandle /* IWICBitmapEncoderInfo */ codecInfoHandle = new SafeMILHandle();
+ SafeMILHandle /* IWICBitmapEncoderInfo */ codecInfoHandle = new SafeMILHandle();
- HRESULT.Check(UnsafeNativeMethods.WICBitmapEncoder.GetEncoderInfo(
+ UnsafeNativeMethods.WICBitmapEncoder.GetEncoderInfo(
_encoderHandle,
- out codecInfoHandle
- ));
+ out codecInfoHandle).ThrowOnFailureExtended();
_codecInfo = new BitmapCodecInfoInternal(codecInfoHandle);
}
@@ -349,11 +349,10 @@ public virtual void Save(System.IO.Stream stream)
comStream = StreamAsIStream.IStreamFrom(stream);
// does this addref the stream?
- HRESULT.Check(UnsafeNativeMethods.WICBitmapEncoder.Initialize(
+ UnsafeNativeMethods.WICBitmapEncoder.Initialize(
encoderHandle,
comStream,
- WICBitmapEncodeCacheOption.WICBitmapEncodeNoCache
- ));
+ WICBitmapEncodeCacheOption.WICBitmapEncodeNoCache).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.EncoderInitialized;
@@ -366,10 +365,9 @@ public virtual void Save(System.IO.Stream stream)
lock (_thumbnail.SyncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapEncoder.SetThumbnail(
+ UnsafeNativeMethods.WICBitmapEncoder.SetThumbnail(
encoderHandle,
- thumbnailBitmapSource
- ));
+ thumbnailBitmapSource).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.EncoderThumbnailSet;
@@ -381,10 +379,9 @@ public virtual void Save(System.IO.Stream stream)
{
SafeMILHandle paletteHandle = _palette.InternalPalette;
- HRESULT.Check(UnsafeNativeMethods.WICBitmapEncoder.SetPalette(
+ UnsafeNativeMethods.WICBitmapEncoder.SetPalette(
encoderHandle,
- paletteHandle
- ));
+ paletteHandle).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.EncoderPaletteSet;
@@ -407,11 +404,10 @@ public virtual void Save(System.IO.Stream stream)
lock (_metadata.SyncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICMetadataQueryWriter.SetMetadataByName(
+ UnsafeNativeMethods.WICMetadataQueryWriter.SetMetadataByName(
_metadataHandle,
"/",
- ref propVar
- ));
+ ref propVar).ThrowOnFailureExtended();
}
}
finally
@@ -425,11 +421,10 @@ ref propVar
{
SafeMILHandle frameEncodeHandle = new SafeMILHandle();
SafeMILHandle encoderOptions = new SafeMILHandle();
- HRESULT.Check(UnsafeNativeMethods.WICBitmapEncoder.CreateNewFrame(
+ UnsafeNativeMethods.WICBitmapEncoder.CreateNewFrame(
encoderHandle,
out frameEncodeHandle,
- out encoderOptions
- ));
+ out encoderOptions).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.EncoderCreatedNewFrame;
@@ -445,7 +440,7 @@ out encoderOptions
}
// Now let the encoder know we are done encoding the file.
- HRESULT.Check(UnsafeNativeMethods.WICBitmapEncoder.Commit(encoderHandle));
+ UnsafeNativeMethods.WICBitmapEncoder.Commit(encoderHandle).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.EncoderCommitted;
@@ -521,18 +516,18 @@ private void EnsureMetadata(bool createBitmapMetadata)
{
SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle = new SafeMILHandle();
- int hr = UnsafeNativeMethods.WICBitmapEncoder.GetMetadataQueryWriter(
+ HRESULT result = UnsafeNativeMethods.WICBitmapEncoder.GetMetadataQueryWriter(
_encoderHandle,
out metadataHandle
);
- if (hr == (int)WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION)
+ if (result == HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION)
{
_supportsGlobalMetadata = false;
return;
}
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
_metadataHandle = metadataHandle;
}
@@ -558,12 +553,11 @@ private void EnsureUnmanagedEncoder()
Guid vendorMicrosoft = new Guid(MILGuidData.GUID_VendorMicrosoft);
Guid containerFormat = ContainerFormat;
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateEncoder(
- myFactory.ImagingFactoryPtr,
- ref containerFormat,
- ref vendorMicrosoft,
- out encoderHandle
- ));
+ UnsafeNativeMethods.WICImagingFactory.CreateEncoder(
+ myFactory.ImagingFactoryPtr,
+ ref containerFormat,
+ ref vendorMicrosoft,
+ out encoderHandle).ThrowOnFailureExtended();
_encoderHandle = encoderHandle;
}
@@ -581,11 +575,10 @@ private void SaveFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOpt
_encodeState = EncodeState.FrameEncodeInitialized;
// Set the size
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.SetSize(
+ UnsafeNativeMethods.WICBitmapFrameEncode.SetSize(
frameEncodeHandle,
frame.PixelWidth,
- frame.PixelHeight
- ));
+ frame.PixelHeight).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.FrameEncodeSizeSet;
@@ -603,11 +596,10 @@ private void SaveFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOpt
dpiY = 96;
}
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.SetResolution(
+ UnsafeNativeMethods.WICBitmapFrameEncode.SetResolution(
frameEncodeHandle,
dpiX,
- dpiY
- ));
+ dpiY).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.FrameEncodeResolutionSet;
@@ -623,10 +615,9 @@ private void SaveFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOpt
lock (thumbnail.SyncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.SetThumbnail(
+ UnsafeNativeMethods.WICBitmapFrameEncode.SetThumbnail(
frameEncodeHandle,
- thumbnailHandle
- ));
+ thumbnailHandle).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.FrameEncodeThumbnailSet;
@@ -658,7 +649,7 @@ private void SaveFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOpt
{
IList colorContexts = frame.ColorContexts;
if (colorContexts != null && colorContexts.Count > 0)
- {
+ {
int count = colorContexts.Count;
// Marshal can't convert SafeMILHandle[] so we must
@@ -695,12 +686,11 @@ private void SaveFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOpt
// Set the pixel format and palette of the bitmap.
// This could (but hopefully won't) introduce a format converter.
- HRESULT.Check(UnsafeNativeMethods.WICCodec.WICSetEncoderFormat(
+ UnsafeNativeMethods.WICCodec.WICSetEncoderFormat(
bitmapSourceHandle,
paletteHandle,
frameEncodeHandle,
- out outSourceHandle
- ));
+ out outSourceHandle).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.FrameEncodeFormatSet;
@@ -716,10 +706,9 @@ out outSourceHandle
{
SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle = new SafeMILHandle();
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.GetMetadataQueryWriter(
+ UnsafeNativeMethods.WICBitmapFrameEncode.GetMetadataQueryWriter(
frameEncodeHandle,
- out metadataHandle
- ));
+ out metadataHandle).ThrowOnFailureExtended();
PROPVARIANT propVar = new PROPVARIANT();
@@ -729,11 +718,10 @@ out metadataHandle
lock (metadata.SyncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICMetadataQueryWriter.SetMetadataByName(
+ UnsafeNativeMethods.WICMetadataQueryWriter.SetMetadataByName(
metadataHandle,
"/",
- ref propVar
- ));
+ ref propVar).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.FrameEncodeMetadataSet;
@@ -747,18 +735,15 @@ ref propVar
}
Int32Rect r = new Int32Rect();
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.WriteSource(
+ UnsafeNativeMethods.WICBitmapFrameEncode.WriteSource(
frameEncodeHandle,
outSourceHandle,
- ref r
- ));
+ ref r).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.FrameEncodeSourceWritten;
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Commit(
- frameEncodeHandle
- ));
+ UnsafeNativeMethods.WICBitmapFrameEncode.Commit(frameEncodeHandle).ThrowOnFailureExtended();
// Helpful for debugging stress and remote dumps
_encodeState = EncodeState.FrameEncodeCommitted;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapFrameDecode.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapFrameDecode.cs
index 1527655d7a9..236d0801bd4 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapFrameDecode.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapFrameDecode.cs
@@ -1,13 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-//
-
using System.Collections.ObjectModel;
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
#pragma warning disable 1634, 1691 // Allow suppression of certain presharp messages
@@ -115,7 +113,7 @@ LateBoundBitmapDecoder decoder
byte[] pixels = new byte[4];
- BitmapSource source = BitmapSource.Create(
+ BitmapSource source = Create(
1,
1,
96,
@@ -215,11 +213,15 @@ public override BitmapDecoder Decoder
///
/// Used as a delegate in ColorContexts to get the unmanaged IWICColorContexts
///
- private int GetColorContexts(ref uint numContexts, IntPtr[] colorContextPtrs)
+ private HRESULT GetColorContexts(ref uint numContexts, IntPtr[] colorContextPtrs)
{
Invariant.Assert(colorContextPtrs == null || numContexts <= colorContextPtrs.Length);
-
- return UnsafeNativeMethods.WICBitmapFrameDecode.GetColorContexts(_frameSource, numContexts, colorContextPtrs, out numContexts);
+
+ return UnsafeNativeMethods.WICBitmapFrameDecode.GetColorContexts(
+ _frameSource,
+ numContexts,
+ colorContextPtrs,
+ out numContexts);
}
///
@@ -576,14 +578,14 @@ private void EnsureThumbnail()
lock (_syncObject)
{
// Check if there is embedded thumbnail or not
- int hr = UnsafeNativeMethods.WICBitmapFrameDecode.GetThumbnail(
+ HRESULT result = UnsafeNativeMethods.WICBitmapFrameDecode.GetThumbnail(
_frameSource,
out thumbnail
);
- if (hr != (int)WinCodecErrors.WINCODEC_ERR_CODECNOTHUMBNAIL)
+ if (result != HRESULT.WINCODEC_ERR_CODECNOTHUMBNAIL)
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
@@ -595,11 +597,9 @@ out thumbnail
SafeMILHandle unmanagedPalette = BitmapPalette.CreateInternalPalette();
BitmapPalette palette = null;
- int hr = UnsafeNativeMethods.WICBitmapSource.CopyPalette(
- thumbHandle,
- unmanagedPalette
- );
- if (hr == HRESULT.S_OK)
+ HRESULT result = UnsafeNativeMethods.WICBitmapSource.CopyPalette(thumbHandle, unmanagedPalette);
+
+ if (result == HRESULT.S_OK)
{
palette = new BitmapPalette(unmanagedPalette);
}
@@ -637,14 +637,13 @@ internal override BitmapMetadata InternalMetadata
lock (_syncObject)
{
// Check if there is embedded metadata or not
- int hr = UnsafeNativeMethods.WICBitmapFrameDecode.GetMetadataQueryReader(
+ HRESULT result = UnsafeNativeMethods.WICBitmapFrameDecode.GetMetadataQueryReader(
_frameSource,
- out metadata
- );
+ out metadata);
- if (hr != (int)WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION)
+ if (result != HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION)
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
@@ -676,7 +675,7 @@ private void EnsureSource()
{
if (_decoder == null)
{
- HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_NOTINITIALIZED);
+ HRESULT.WINCODEC_ERR_NOTINITIALIZED.ThrowOnFailureExtended();
}
//
@@ -701,11 +700,10 @@ private void EnsureSource()
Debug.Assert(_syncObject != null);
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapDecoder.GetFrame(
+ UnsafeNativeMethods.WICBitmapDecoder.GetFrame(
_decoder.InternalDecoder,
(uint)_frameNumber,
- out frameDecode
- ));
+ out frameDecode).ThrowOnFailureExtended();
_frameSource = new BitmapSourceSafeMILHandle(frameDecode);
_frameSource.CalculateSize();
@@ -765,7 +763,7 @@ public WeakBitmapFrameDecodeEventSink(BitmapFrameDecode cloned, BitmapFrameDecod
public void OnSourceDownloadCompleted(object sender, EventArgs e)
{
- BitmapFrameDecode clone = this.Target as BitmapFrameDecode;
+ BitmapFrameDecode clone = Target as BitmapFrameDecode;
if (null != clone)
{
clone.OnOriginalDownloadCompleted(_original, e);
@@ -778,7 +776,7 @@ public void OnSourceDownloadCompleted(object sender, EventArgs e)
public void OnSourceDownloadFailed(object sender, ExceptionEventArgs e)
{
- BitmapFrameDecode clone = this.Target as BitmapFrameDecode;
+ BitmapFrameDecode clone = Target as BitmapFrameDecode;
if (null != clone)
{
clone.OnOriginalDownloadFailed(e);
@@ -791,7 +789,7 @@ public void OnSourceDownloadFailed(object sender, ExceptionEventArgs e)
public void OnSourceDownloadProgress(object sender, DownloadProgressEventArgs e)
{
- BitmapFrameDecode clone = this.Target as BitmapFrameDecode;
+ BitmapFrameDecode clone = Target as BitmapFrameDecode;
if (null != clone)
{
clone.OnDownloadProgress(sender, e);
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadata.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadata.cs
index ae8f0353562..e122c457d22 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadata.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadata.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -12,7 +12,8 @@
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
-using MS.Internal.PresentationCore; // SecurityHelper
+using MS.Internal.PresentationCore;
+using Windows.Win32.Foundation; // SecurityHelper
#pragma warning disable 1634, 1691 // suppressing PreSharp warnings
@@ -34,27 +35,27 @@ public partial class BitmapMetadata : ImageMetadata, IEnumerable, IEnumerable
/// This method is part of an interface that is only called by way of WindowsCodec. It is not
/// publicly exposed or accessible in any way.
///
- public int GetReaderByIndex(
+ public HRESULT GetReaderByIndex(
UInt32 index,
out IntPtr /* IWICMetadataReader */ pIMetadataReader
)
@@ -213,7 +207,7 @@ out IntPtr /* IWICMetadataReader */ pIMetadataReader
if (index >= _metadataBlocks.Count)
{
pIMetadataReader = IntPtr.Zero;
- return (int) WinCodecErrors.WINCODEC_ERR_PROPERTYNOTFOUND;
+ return HRESULT.WINCODEC_ERR_PROPERTYNOTFOUND;
}
SafeMILHandle metadataReader = (SafeMILHandle) _metadataBlocks[(int)index];
@@ -229,7 +223,7 @@ out IntPtr /* IWICMetadataReader */ pIMetadataReader
/// This method is part of an interface that is only called by way of WindowsCodec. It is not
/// publicly exposed or accessible in any way.
///
- public int GetEnumerator(
+ public HRESULT GetEnumerator(
out IntPtr /* IEnumUnknown */ pIEnumMetadata
)
{
@@ -239,35 +233,30 @@ out IntPtr /* IEnumUnknown */ pIEnumMetadata
pIEnumMetadata = Marshal.GetComInterfaceForObject(
blockEnumerator,
- typeof(System.Windows.Media.Imaging.BitmapMetadata.IEnumUnknown));
+ typeof(IEnumUnknown));
- return MS.Win32.NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// This method is part of an interface that is only called by way of WindowsCodec. It is not
/// publicly exposed or accessible in any way.
///
- public int InitializeFromBlockReader(
+ public HRESULT InitializeFromBlockReader(
IntPtr /* IWICMetadataBlockReader */ pIBlockReader
)
{
Invariant.Assert(pIBlockReader != IntPtr.Zero);
- int hr = MS.Win32.NativeMethods.S_OK;
-
- UInt32 count = 0;
-
Guid guidVendor = new Guid(MILGuidData.GUID_VendorMicrosoft);
ArrayList metadataBlocks = new ArrayList();
- hr = UnsafeNativeMethods.WICMetadataBlockReader.GetCount(
+ HRESULT result = UnsafeNativeMethods.WICMetadataBlockReader.GetCount(
pIBlockReader,
- out count
- );
+ out uint count);
- if (HRESULT.Succeeded(hr))
+ if (result.Succeeded)
{
using (FactoryMaker factoryMaker = new FactoryMaker())
{
@@ -278,25 +267,23 @@ out count
try
{
- hr = UnsafeNativeMethods.WICMetadataBlockReader.GetReaderByIndex(
+ result = UnsafeNativeMethods.WICMetadataBlockReader.GetReaderByIndex(
pIBlockReader,
i,
- out pIMetadataReader
- );
+ out pIMetadataReader);
- if (HRESULT.Failed(hr))
+ if (result.Failed)
{
break;
}
- hr = UnsafeNativeMethods.WICComponentFactory.CreateMetadataWriterFromReader(
+ result = UnsafeNativeMethods.WICComponentFactory.CreateMetadataWriterFromReader(
factoryMaker.ImagingFactoryPtr,
pIMetadataReader,
ref guidVendor,
- out pIMetadataWriter
- );
+ out pIMetadataWriter);
- if (HRESULT.Failed(hr))
+ if (result.Failed)
{
break;
}
@@ -315,8 +302,8 @@ out pIMetadataWriter
}
if (pIMetadataWriter != IntPtr.Zero)
{
- #pragma warning suppress 6031 // Return value ignored on purpose.
- UnsafeNativeMethods.MILUnknown.Release(pIMetadataWriter);
+ // Return value ignored on purpose.
+ _ = UnsafeNativeMethods.MILUnknown.Release(pIMetadataWriter);
}
}
}
@@ -325,14 +312,14 @@ out pIMetadataWriter
_metadataBlocks = metadataBlocks;
}
- return hr;
+ return result;
}
///
/// This method is part of an interface that is only called by way of WindowsCodec. It is not
/// publicly exposed or accessible in any way.
///
- public int GetWriterByIndex(
+ public HRESULT GetWriterByIndex(
UInt32 index,
out IntPtr /* IWICMetadataWriter */ pIMetadataWriter
)
@@ -340,7 +327,7 @@ out IntPtr /* IWICMetadataWriter */ pIMetadataWriter
if (index >= _metadataBlocks.Count)
{
pIMetadataWriter = IntPtr.Zero;
- return (int) WinCodecErrors.WINCODEC_ERR_PROPERTYNOTFOUND;
+ return HRESULT.WINCODEC_ERR_PROPERTYNOTFOUND;
}
SafeMILHandle metadataWriter = (SafeMILHandle) _metadataBlocks[(int)index];
@@ -356,18 +343,18 @@ out IntPtr /* IWICMetadataWriter */ pIMetadataWriter
/// This method is part of an interface that is only called by way of WindowsCodec. It is not
/// publicly exposed or accessible in any way.
///
- public int AddWriter(
+ public HRESULT AddWriter(
IntPtr /* IWICMetadataWriter */ pIMetadataWriter
)
{
if (pIMetadataWriter == IntPtr.Zero)
{
- return (int) WinCodecErrors.WINCODEC_ERR_INVALIDPARAMETER;
+ return HRESULT.FromWin32(WIN32_ERROR.ERROR_INVALID_PARAMETER);
}
if (_fixedSize && _metadataBlocks.Count>0)
{
- return (int) WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION;
+ return HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
SafeMILHandle metadataWriter = new SafeMILHandle(pIMetadataWriter);
@@ -376,31 +363,31 @@ public int AddWriter(
_metadataBlocks.Add(metadataWriter);
- return MS.Win32.NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// This method is part of an interface that is only called by way of WindowsCodec. It is not
/// publicly exposed or accessible in any way.
///
- public int SetWriterByIndex(
+ public HRESULT SetWriterByIndex(
UInt32 index,
IntPtr /* IWICMetadataWriter */ pIMetadataWriter
)
{
if (index >= _metadataBlocks.Count)
{
- return (int) WinCodecErrors.WINCODEC_ERR_PROPERTYNOTFOUND;
+ return HRESULT.WINCODEC_ERR_PROPERTYNOTFOUND;
}
if (pIMetadataWriter == IntPtr.Zero)
{
- return (int) WinCodecErrors.WINCODEC_ERR_INVALIDPARAMETER;
+ return HRESULT.FromWin32(WIN32_ERROR.ERROR_INVALID_PARAMETER);
}
if (_fixedSize)
{
- return (int) WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION;
+ return HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
SafeMILHandle metadataWriter = new SafeMILHandle(pIMetadataWriter);
@@ -409,26 +396,24 @@ public int SetWriterByIndex(
_metadataBlocks[(int)index] = metadataWriter;
- return MS.Win32.NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
- public int RemoveWriterByIndex(
- UInt32 index
- )
+ public HRESULT RemoveWriterByIndex(uint index)
{
if (index >= _metadataBlocks.Count)
{
- return (int) WinCodecErrors.WINCODEC_ERR_PROPERTYNOTFOUND;
+ return HRESULT.WINCODEC_ERR_PROPERTYNOTFOUND;
}
if (_fixedSize)
{
- return (int) WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION;
+ return HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
_metadataBlocks.Remove(index);
- return MS.Win32.NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
internal ArrayList MetadataBlocks
@@ -453,26 +438,26 @@ internal ArrayList MetadataBlocks
// Guid: IID_IEnumUnknown
[ComImport(),
Guid("00000100-0000-0000-C000-000000000046"),
- InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
+ InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IEnumUnknown
{
[PreserveSig]
- int Next(
+ HRESULT Next(
UInt32 celt,
out IntPtr /* IUnknown ** */ rgelt,
ref UInt32 pceltFetched
);
[PreserveSig]
- int Skip(
+ HRESULT Skip(
UInt32 celt
);
[PreserveSig]
- int Reset();
+ HRESULT Reset();
[PreserveSig]
- int Clone(
+ HRESULT Clone(
ref IntPtr /* IEnumString ** */ ppEnum
);
}
@@ -501,7 +486,7 @@ BitmapMetadataBlockWriter blockWriter
/// This method is part of an interface that is only called by way of WindowsCodec. It is not
/// publicly exposed or accessible in any way.
///
- public int Next(
+ public HRESULT Next(
UInt32 celt,
out IntPtr /* IUnknown ** */ rgelt,
ref UInt32 pceltFetched
@@ -512,69 +497,65 @@ ref UInt32 pceltFetched
{
rgelt = IntPtr.Zero;
pceltFetched = 0;
- return (int) WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION;
+ return HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
if (_index >= _metadataBlocks.Count || celt == 0)
{
rgelt = IntPtr.Zero;
pceltFetched = 0;
- return MS.Win32.NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
else
{
- SafeMILHandle metadataHandle = (SafeMILHandle) _metadataBlocks[(int)_index];
+ SafeMILHandle metadataHandle = (SafeMILHandle)_metadataBlocks[(int)_index];
Guid wicMetadataReader = MILGuidData.IID_IWICMetadataReader;
- int hr = UnsafeNativeMethods.MILUnknown.QueryInterface(
+ HRESULT result = UnsafeNativeMethods.MILUnknown.QueryInterface(
metadataHandle,
ref wicMetadataReader,
out rgelt);
- if (HRESULT.Succeeded(hr))
+ if (result.Succeeded)
{
pceltFetched = 1;
_index++;
}
- return hr;
+ return result;
}
}
- public int Skip(
- UInt32 celt
- )
+ public HRESULT Skip(uint celt)
{
- UInt32 newIndex = _index + celt;
+ uint newIndex = _index + celt;
if (newIndex > _metadataBlocks.Count)
{
- _index = (uint) _metadataBlocks.Count;
- return MS.Win32.NativeMethods.S_FALSE;
+ _index = (uint)_metadataBlocks.Count;
+ return HRESULT.S_FALSE;
}
else
{
_index += celt;
- return MS.Win32.NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
}
- public int Reset()
+ public HRESULT Reset()
{
_index = 0;
- return MS.Win32.NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// This method is part of an interface that is only called by way of WindowsCodec. It is not
/// publicly exposed or accessible in any way.
///
- public int Clone(
- ref IntPtr /* IEnumUnknown ** */ ppEnum
- )
+ public HRESULT Clone(ref IntPtr /* IEnumUnknown ** */ ppEnum)
{
ppEnum = IntPtr.Zero;
- return (int) WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION;
+ return HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
private ArrayList _metadataBlocks;
@@ -583,9 +564,6 @@ ref IntPtr /* IEnumUnknown ** */ ppEnum
#region Constructors
- ///
- ///
- ///
public BitmapMetadata(String containerFormat)
{
ArgumentNullException.ThrowIfNull(containerFormat);
@@ -593,10 +571,7 @@ public BitmapMetadata(String containerFormat)
Guid guid = new Guid();
// Find the length of the string needed
- HRESULT.Check(UnsafeNativeMethods.WICCodec.WICMapShortNameToGuid(
- containerFormat,
- ref guid
- ));
+ UnsafeNativeMethods.WICCodec.WICMapShortNameToGuid(containerFormat, ref guid).ThrowOnFailureExtended();
Init(guid, false, false);
}
@@ -644,7 +619,7 @@ internal BitmapMetadata(BitmapMetadata bitmapMetadata)
///
private void Init(Guid containerFormat, bool readOnly, bool fixedSize)
{
- int hr = 0;
+ HRESULT result = HRESULT.S_OK;
IntPtr /* IWICMetadataQueryWriter */ queryWriter = IntPtr.Zero;
using (FactoryMaker factoryMaker = new FactoryMaker())
@@ -652,7 +627,7 @@ private void Init(Guid containerFormat, bool readOnly, bool fixedSize)
Guid vendorMicrosoft = new Guid(MILGuidData.GUID_VendorMicrosoft);
// If it's a metadata format, create a Query Writer to wrap it.
- hr = UnsafeNativeMethods.WICImagingFactory.CreateQueryWriter(
+ result = UnsafeNativeMethods.WICImagingFactory.CreateQueryWriter(
factoryMaker.ImagingFactoryPtr,
ref containerFormat,
ref vendorMicrosoft,
@@ -660,7 +635,7 @@ out queryWriter
);
}
- if (HRESULT.Succeeded(hr))
+ if (result.Succeeded)
{
_readOnly = readOnly;
_fixedSize = fixedSize;
@@ -692,13 +667,12 @@ private void InitializeFromBlockWriter(Guid containerFormat, bool readOnly, bool
blockWriter = Marshal.GetComInterfaceForObject(
_blockWriter,
- typeof(System.Windows.Media.Imaging.BitmapMetadata.IWICMetadataBlockWriter));
+ typeof(IWICMetadataBlockWriter));
- HRESULT.Check(UnsafeNativeMethods.WICComponentFactory.CreateQueryWriterFromBlockWriter(
+ UnsafeNativeMethods.WICComponentFactory.CreateQueryWriterFromBlockWriter(
factoryMaker.ImagingFactoryPtr,
blockWriter,
- ref queryWriter
- ));
+ ref queryWriter).ThrowOnFailureExtended();
_readOnly = readOnly;
_fixedSize = fixedSize;
@@ -741,13 +715,12 @@ private void InitializeFromBlockWriter(BitmapMetadataBlockWriter sourceBlockWrit
blockWriter = Marshal.GetComInterfaceForObject(
_blockWriter,
- typeof(System.Windows.Media.Imaging.BitmapMetadata.IWICMetadataBlockWriter));
+ typeof(IWICMetadataBlockWriter));
- HRESULT.Check(UnsafeNativeMethods.WICComponentFactory.CreateQueryWriterFromBlockWriter(
+ UnsafeNativeMethods.WICComponentFactory.CreateQueryWriterFromBlockWriter(
factoryMaker.ImagingFactoryPtr,
blockWriter,
- ref queryWriter
- ));
+ ref queryWriter).ThrowOnFailureExtended();
_readOnly = false;
_fixedSize = false;
@@ -778,7 +751,7 @@ ref queryWriter
///
private void InitializeFromMetadataWriter(SafeMILHandle metadataHandle, object syncObject)
{
- int hr;
+ HRESULT result;
IntPtr queryWriter = IntPtr.Zero;
Guid guidVendor = new Guid(MILGuidData.GUID_VendorMicrosoft);
@@ -790,7 +763,7 @@ private void InitializeFromMetadataWriter(SafeMILHandle metadataHandle, object s
{
lock (syncObject)
{
- hr = UnsafeNativeMethods.WICImagingFactory.CreateQueryWriterFromReader(
+ result = UnsafeNativeMethods.WICImagingFactory.CreateQueryWriterFromReader(
factoryMaker.ImagingFactoryPtr,
metadataHandle,
ref guidVendor,
@@ -798,7 +771,7 @@ private void InitializeFromMetadataWriter(SafeMILHandle metadataHandle, object s
}
}
- if (HRESULT.Succeeded(hr))
+ if (result.Succeeded)
{
_readOnly = false;
_fixedSize = false;
@@ -809,17 +782,17 @@ private void InitializeFromMetadataWriter(SafeMILHandle metadataHandle, object s
_syncObject = _metadataHandle;
}
- else if (!HRESULT.IsWindowsCodecError(hr))
+ else if (!result.IsWindowsCodecError())
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
finally
{
if (queryWriter != IntPtr.Zero)
{
- #pragma warning suppress 6031 // Return value ignored on purpose.
- UnsafeNativeMethods.MILUnknown.Release(queryWriter);
+ // Return value ignored on purpose.
+ _ = UnsafeNativeMethods.MILUnknown.Release(queryWriter);
}
}
}
@@ -838,7 +811,7 @@ private void InitializeFromMetadataWriter(SafeMILHandle metadataHandle, object s
}
///
- /// Implementation of Freezable.CreateInstanceCore.
+ /// Implementation of Freezable.CreateInstanceCore.
///
/// The new Freezable.
protected override Freezable CreateInstanceCore()
@@ -847,7 +820,7 @@ protected override Freezable CreateInstanceCore()
}
///
- /// Implementation of Freezable.CloneCore.
+ /// Implementation of Freezable.CloneCore.
///
protected override void CloneCore(Freezable sourceFreezable)
{
@@ -858,7 +831,7 @@ protected override void CloneCore(Freezable sourceFreezable)
}
///
- /// Implementation of Freezable.CloneCurrentValueCore.
+ /// Implementation of Freezable.CloneCurrentValueCore.
///
protected override void CloneCurrentValueCore(Freezable sourceFreezable)
{
@@ -870,7 +843,7 @@ protected override void CloneCurrentValueCore(Freezable sourceFreezable)
///
- /// Implementation of Freezable.GetAsFrozenCore.
+ /// Implementation of Freezable.GetAsFrozenCore.
///
protected override void GetAsFrozenCore(Freezable sourceFreezable)
{
@@ -882,7 +855,7 @@ protected override void GetAsFrozenCore(Freezable sourceFreezable)
///
- /// Implementation of Freezable.GetCurrentValueAsFrozenCore.
+ /// Implementation of Freezable.GetCurrentValueAsFrozenCore.
///
protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
{
@@ -894,16 +867,13 @@ protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
#endregion
- ///
- ///
- ///
public String Format
{
get
{
EnsureBitmapMetadata();
StringBuilder format = null;
- UInt32 length = 0;
+ uint length = 0;
// This calls EnsureBitmapMetadata()
Guid guid = GuidFormat;
@@ -911,26 +881,22 @@ public String Format
// Find the length of the string needed
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICCodec.WICMapGuidToShortName(
+ UnsafeNativeMethods.WICCodec.WICMapGuidToShortName(
ref guid,
0,
format,
- ref length
- ));
-
- Debug.Assert(length >= 0);
+ ref length).ThrowOnFailureExtended();
- // get the string back
+ // Get the string back
if (length > 0)
{
format = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICCodec.WICMapGuidToShortName(
+ UnsafeNativeMethods.WICCodec.WICMapGuidToShortName(
ref guid,
length,
format,
- ref length
- ));
+ ref length).ThrowOnFailureExtended();
}
}
@@ -938,41 +904,33 @@ ref length
}
}
- ///
- ///
- ///
public String Location
{
get
{
StringBuilder location = null;
- UInt32 length = 0;
EnsureBitmapMetadata();
// Find the length of the string needed
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICMetadataQueryReader.GetLocation(
+ UnsafeNativeMethods.WICMetadataQueryReader.GetLocation(
_metadataHandle,
0,
location,
- out length
- ));
+ out uint length).ThrowOnFailureExtended();
- Debug.Assert(length >= 0);
-
- // get the string back
+ // Get the string back
if (length > 0)
{
location = new StringBuilder((int)length);
- HRESULT.Check(UnsafeNativeMethods.WICMetadataQueryReader.GetLocation(
+ UnsafeNativeMethods.WICMetadataQueryReader.GetLocation(
_metadataHandle,
length,
location,
- out length
- ));
+ out length).ThrowOnFailureExtended();
}
}
@@ -982,9 +940,6 @@ out length
#region Properties
- ///
- ///
- ///
public bool IsReadOnly
{
get
@@ -995,9 +950,6 @@ public bool IsReadOnly
}
}
- ///
- ///
- ///
public bool IsFixedSize
{
get
@@ -1025,7 +977,7 @@ public void SetQuery(String query, object value)
if (_readOnly)
{
- throw new System.InvalidOperationException(SR.Image_MetadataReadOnly);
+ throw new InvalidOperationException(SR.Image_MetadataReadOnly);
}
// Store these for debugging stress failures.
@@ -1053,11 +1005,10 @@ public void SetQuery(String query, object value)
{
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICMetadataQueryWriter.SetMetadataByName(
+ UnsafeNativeMethods.WICMetadataQueryWriter.SetMetadataByName(
_metadataHandle,
query,
- ref propVar
- ));
+ ref propVar).ThrowOnFailureExtended();
}
}
}
@@ -1065,11 +1016,10 @@ ref propVar
{
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICMetadataQueryWriter.SetMetadataByName(
+ UnsafeNativeMethods.WICMetadataQueryWriter.SetMetadataByName(
_metadataHandle,
query,
- ref propVar
- ));
+ ref propVar).ThrowOnFailureExtended();
}
}
}
@@ -1081,12 +1031,9 @@ ref propVar
WritePostscript();
}
- ///
- ///
- ///
public object GetQuery(String query)
{
- int hr;
+ HRESULT result;
ArgumentNullException.ThrowIfNull(query);
@@ -1100,16 +1047,15 @@ public object GetQuery(String query)
lock (_syncObject)
{
- hr = UnsafeNativeMethods.WICMetadataQueryReader.GetMetadataByName(
+ result = UnsafeNativeMethods.WICMetadataQueryReader.GetMetadataByName(
_metadataHandle,
query,
- ref propVar
- );
+ ref propVar);
}
- if (hr != (int)WinCodecErrors.WINCODEC_ERR_PROPERTYNOTFOUND)
+ if (result != HRESULT.WINCODEC_ERR_PROPERTYNOTFOUND)
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
object objValue = propVar.ToObject(_syncObject);
@@ -1134,12 +1080,9 @@ ref propVar
return null;
}
- ///
- ///
- ///
public void RemoveQuery(String query)
{
- int hr;
+ HRESULT result;
WritePreamble();
@@ -1147,51 +1090,39 @@ public void RemoveQuery(String query)
if (_readOnly)
{
- throw new System.InvalidOperationException(SR.Image_MetadataReadOnly);
+ throw new InvalidOperationException(SR.Image_MetadataReadOnly);
}
EnsureBitmapMetadata();
lock (_syncObject)
{
- hr = UnsafeNativeMethods.WICMetadataQueryWriter.RemoveMetadataByName(
+ result = UnsafeNativeMethods.WICMetadataQueryWriter.RemoveMetadataByName(
_metadataHandle,
- query
- );
+ query);
}
- if (hr != (int)WinCodecErrors.WINCODEC_ERR_PROPERTYNOTFOUND)
+ if (result != HRESULT.WINCODEC_ERR_PROPERTYNOTFOUND)
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
- ///
- ///
- ///
IEnumerator IEnumerable.GetEnumerator()
{
EnsureBitmapMetadata();
-
return new BitmapMetadataEnumerator(_metadataHandle);
}
- ///
- ///
- ///
IEnumerator IEnumerable.GetEnumerator()
{
EnsureBitmapMetadata();
-
return new BitmapMetadataEnumerator(_metadataHandle);
}
- ///
- ///
- ///
public bool ContainsQuery(String query)
{
- int hr;
+ HRESULT result;
ArgumentNullException.ThrowIfNull(query);
@@ -1199,20 +1130,20 @@ public bool ContainsQuery(String query)
lock (_syncObject)
{
- hr = UnsafeNativeMethods.WICMetadataQueryReader.ContainsMetadataByName(
+ result = UnsafeNativeMethods.WICMetadataQueryReader.ContainsMetadataByName(
_metadataHandle,
query,
IntPtr.Zero
);
}
- if (HRESULT.IsWindowsCodecError(hr))
+ if (result.IsWindowsCodecError())
{
return false;
}
else
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
return true;
@@ -1274,14 +1205,14 @@ public int Rating
if (rating != null && rating.GetType() == typeof(ushort))
{
- return System.Convert.ToInt32(rating, CultureInfo.InvariantCulture);
+ return Convert.ToInt32(rating, CultureInfo.InvariantCulture);
}
return 0;
}
set
{
- SetQuery(policy_Rating, System.Convert.ToUInt16(value, CultureInfo.InvariantCulture));
+ SetQuery(policy_Rating, Convert.ToUInt16(value, CultureInfo.InvariantCulture));
}
}
@@ -1323,9 +1254,9 @@ public String DateTaken
get
{
object fileTime = GetQuery(policy_DateTaken);
- if (fileTime != null && fileTime.GetType() == typeof(System.Runtime.InteropServices.ComTypes.FILETIME))
+ if (fileTime != null && fileTime.GetType() == typeof(Runtime.InteropServices.ComTypes.FILETIME))
{
- System.Runtime.InteropServices.ComTypes.FILETIME time = (System.Runtime.InteropServices.ComTypes.FILETIME)fileTime;
+ Runtime.InteropServices.ComTypes.FILETIME time = (Runtime.InteropServices.ComTypes.FILETIME)fileTime;
DateTime dateTime = DateTime.FromFileTime( (((long)time.dwHighDateTime) << 32) + (uint)time.dwLowDateTime );
return dateTime.ToString();
}
@@ -1333,7 +1264,7 @@ public String DateTaken
}
set
{
- DateTime dt = System.Convert.ToDateTime(value, CultureInfo.InvariantCulture);
+ DateTime dt = Convert.ToDateTime(value, CultureInfo.InvariantCulture);
PROPVARIANT propVar= new PROPVARIANT();
propVar.varType = (ushort)VarEnum.VT_FILETIME;
@@ -1477,10 +1408,9 @@ internal Guid GuidFormat
EnsureBitmapMetadata();
- HRESULT.Check(UnsafeNativeMethods.WICMetadataQueryReader.GetContainerFormat(
+ UnsafeNativeMethods.WICMetadataQueryReader.GetContainerFormat(
_metadataHandle,
- out guid
- ));
+ out guid).ThrowOnFailureExtended();
return guid;
}
@@ -1516,7 +1446,7 @@ private void EnsureBitmapMetadata()
if (_metadataHandle == null)
{
- throw new System.InvalidOperationException(SR.Image_MetadataInitializationIncomplete);
+ throw new InvalidOperationException(SR.Image_MetadataInitializationIncomplete);
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadataEnumerator.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadataEnumerator.cs
index 345fb4831ac..df5a61265e2 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadataEnumerator.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadataEnumerator.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,8 +7,8 @@
using System.Collections;
using System.Runtime.InteropServices;
-using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -62,19 +62,19 @@ public bool MoveNext()
try
{
- int hr = UnsafeNativeMethods.EnumString.Next(
+ HRESULT result = UnsafeNativeMethods.EnumString.Next(
_enumeratorHandle,
1,
ref ppStr,
ref celtFetched);
- if (HRESULT.IsWindowsCodecError(hr))
+ if (result.IsWindowsCodecError())
{
_current = null;
return false;
}
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
if (celtFetched == 0)
{
@@ -92,19 +92,19 @@ public bool MoveNext()
{
Marshal.FreeCoTaskMem(ppStr);
ppStr = IntPtr.Zero;
- }
+ }
}
return true;
}
-
+
///
/// Sets the enumerator to its initial position, which is before the first element
/// in the collection.
///
public void Reset()
{
- HRESULT.Check(UnsafeNativeMethods.EnumString.Reset(_enumeratorHandle));
+ UnsafeNativeMethods.EnumString.Reset(_enumeratorHandle).ThrowOnFailureExtended();
_current = null;
_fStarted = false;
@@ -167,9 +167,9 @@ internal BitmapMetadataEnumerator(SafeMILHandle metadataHandle)
{
Debug.Assert(metadataHandle != null && !metadataHandle.IsInvalid);
- HRESULT.Check(UnsafeNativeMethods.WICMetadataQueryReader.GetEnumerator(
+ UnsafeNativeMethods.WICMetadataQueryReader.GetEnumerator(
metadataHandle,
- out _enumeratorHandle));
+ out _enumeratorHandle).ThrowOnFailureExtended();
_current = null;
_fStarted = false;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapPalette.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapPalette.cs
index b4e2659a081..ae345b411b3 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapPalette.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapPalette.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -6,6 +6,7 @@
using MS.Win32.PresentationCore;
using System.Windows.Threading;
using System.Runtime.InteropServices;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -72,11 +73,11 @@ public BitmapPalette(BitmapSource bitmapSource, int maxColorCount)
lock (bitmapSource.SyncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICPalette.InitializeFromBitmap(
- _palette,
- unmanagedBitmap,
- maxColorCount,
- false));
+ UnsafeNativeMethods.WICPalette.InitializeFromBitmap(
+ _palette,
+ unmanagedBitmap,
+ maxColorCount,
+ false).ThrowOnFailureExtended();
}
UpdateManaged();
@@ -117,10 +118,10 @@ internal BitmapPalette(WICPaletteType paletteType,
_palette = CreateInternalPalette();
- HRESULT.Check(UnsafeNativeMethods.WICPalette.InitializePredefined(
- _palette,
- paletteType,
- addtransparentColor));
+ UnsafeNativeMethods.WICPalette.InitializePredefined(
+ _palette,
+ paletteType,
+ addtransparentColor).ThrowOnFailureExtended();
// Fill in the Colors property.
UpdateManaged();
@@ -158,11 +159,9 @@ static internal BitmapPalette CreateFromBitmapSource(BitmapSource source)
// that likely means that the source doesn't have a palette.
lock (source.SyncObject)
{
- int hr = UnsafeNativeMethods.WICBitmapSource.CopyPalette(
- bitmapSource,
- unmanagedPalette);
+ HRESULT result = UnsafeNativeMethods.WICBitmapSource.CopyPalette(bitmapSource, unmanagedPalette);
- if (hr != HRESULT.S_OK)
+ if (result != HRESULT.S_OK)
{
return null;
}
@@ -171,8 +170,8 @@ static internal BitmapPalette CreateFromBitmapSource(BitmapSource source)
WICPaletteType paletteType;
bool hasAlpha;
- HRESULT.Check(UnsafeNativeMethods.WICPalette.GetType(unmanagedPalette, out paletteType));
- HRESULT.Check(UnsafeNativeMethods.WICPalette.HasAlpha(unmanagedPalette, out hasAlpha));
+ UnsafeNativeMethods.WICPalette.GetType(unmanagedPalette, out paletteType).ThrowOnFailureExtended();
+ UnsafeNativeMethods.WICPalette.HasAlpha(unmanagedPalette, out hasAlpha).ThrowOnFailureExtended();
if (paletteType == WICPaletteType.WICPaletteTypeCustom ||
paletteType == WICPaletteType.WICPaletteTypeOptimal)
@@ -247,9 +246,10 @@ static internal SafeMILHandle CreateInternalPalette()
using (FactoryMaker myFactory = new FactoryMaker())
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreatePalette(
- myFactory.ImagingFactoryPtr,
- out palette));
+ UnsafeNativeMethods.WICImagingFactory.CreatePalette(
+ myFactory.ImagingFactoryPtr,
+ out palette).ThrowOnFailureExtended();
+
Debug.Assert(palette != null && !palette.IsInvalid);
}
@@ -280,10 +280,10 @@ unsafe private void UpdateUnmanaged()
fixed (void* paletteColorArrayPinned = paletteColorArray)
{
- HRESULT.Check(UnsafeNativeMethods.WICPalette.InitializeCustom(
- _palette,
- (IntPtr)paletteColorArrayPinned,
- numColors));
+ UnsafeNativeMethods.WICPalette.InitializeCustom(
+ _palette,
+ (IntPtr)paletteColorArrayPinned,
+ numColors).ThrowOnFailureExtended();
}
}
@@ -296,8 +296,7 @@ private void UpdateManaged()
int numColors = 0;
int cActualColors = 0;
- HRESULT.Check(UnsafeNativeMethods.WICPalette.GetColorCount(_palette,
- out numColors));
+ UnsafeNativeMethods.WICPalette.GetColorCount(_palette, out numColors).ThrowOnFailureExtended();
List colors = new List();
@@ -310,13 +309,13 @@ private void UpdateManaged()
ImagePaletteColor[] paletteColorArray = new ImagePaletteColor[numColors];
unsafe
{
- fixed(void* paletteColorArrayPinned = paletteColorArray)
+ fixed (void* paletteColorArrayPinned = paletteColorArray)
{
- HRESULT.Check(UnsafeNativeMethods.WICPalette.GetColors(
- _palette,
- numColors,
- (IntPtr)paletteColorArrayPinned,
- out cActualColors));
+ UnsafeNativeMethods.WICPalette.GetColors(
+ _palette,
+ numColors,
+ (IntPtr)paletteColorArrayPinned,
+ out cActualColors).ThrowOnFailureExtended();
Debug.Assert(cActualColors == numColors);
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSource.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSource.cs
index 99908947ab1..9c447d1e969 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSource.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSource.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -9,6 +9,7 @@
using MS.Win32;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -235,7 +236,7 @@ public virtual Imaging.BitmapPalette Palette
// update the local palette
if (_format.Palettized)
{
- _palette = Imaging.BitmapPalette.CreateFromBitmapSource(this);
+ _palette = BitmapPalette.CreateFromBitmapSource(this);
}
}
@@ -440,7 +441,7 @@ public override ImageMetadata Metadata
///
private double GetWidthInternal()
{
- return ImageSource.PixelsToDIPs(this.DpiX, this.PixelWidth);
+ return PixelsToDIPs(DpiX, PixelWidth);
}
///
@@ -448,7 +449,7 @@ private double GetWidthInternal()
///
private double GetHeightInternal()
{
- return ImageSource.PixelsToDIPs(this.DpiY, this.PixelHeight);
+ return PixelsToDIPs(DpiY, PixelHeight);
}
///
@@ -581,10 +582,10 @@ internal BitmapSourceSafeMILHandle WicSourceHandle
{
IntPtr wicSource = IntPtr.Zero;
Guid _uuidWicBitmapSource = MILGuidData.IID_IWICBitmapSource;
- HRESULT.Check(UnsafeNativeMethods.MILUnknown.QueryInterface(
+ UnsafeNativeMethods.MILUnknown.QueryInterface(
value,
ref _uuidWicBitmapSource,
- out wicSource));
+ out wicSource).ThrowOnFailureExtended();
_wicSource = new BitmapSourceSafeMILHandle(wicSource, value);
UpdateCachedSettings();
@@ -609,15 +610,15 @@ internal virtual void UpdateCachedSettings()
{
_format = PixelFormat.GetPixelFormat(_wicSource);
- HRESULT.Check(UnsafeNativeMethods.WICBitmapSource.GetSize(
+ UnsafeNativeMethods.WICBitmapSource.GetSize(
_wicSource,
out pw,
- out ph));
+ out ph).ThrowOnFailureExtended();
- HRESULT.Check(UnsafeNativeMethods.WICBitmapSource.GetResolution(
+ UnsafeNativeMethods.WICBitmapSource.GetResolution(
_wicSource,
out _dpiX,
- out _dpiY));
+ out _dpiY).ThrowOnFailureExtended();
}
_pixelWidth = (int)pw;
@@ -644,7 +645,7 @@ unsafe internal void CriticalCopyPixels(Int32Rect sourceRect, Array pixels, int
if (offset < 0)
{
- HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW);
+ HRESULT.FromWin32(WIN32_ERROR.ERROR_ARITHMETIC_OVERFLOW).ThrowOnFailureExtended();
}
int elementSize = -1;
@@ -732,13 +733,12 @@ internal void CriticalCopyPixels(Int32Rect sourceRect, IntPtr buffer, int buffer
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapSource.CopyPixels(
+ UnsafeNativeMethods.WICBitmapSource.CopyPixels(
WicSourceHandle,
ref sourceRect,
(uint)stride,
(uint)bufferSize,
- buffer
- ));
+ buffer).ThrowOnFailureExtended();
}
}
@@ -814,13 +814,12 @@ internal virtual BitmapSourceSafeMILHandle DUCECompatiblePtr
{
fixed (void* pixelArray = &((byte[])buffer)[0])
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapSource.CopyPixels(
+ UnsafeNativeMethods.WICBitmapSource.CopyPixels(
pIWICSource,
ref sourceRect,
(uint)bufferSize,
(uint)bufferSize,
- (IntPtr)pixelArray
- ));
+ (IntPtr)pixelArray).ThrowOnFailureExtended();
}
}
}
@@ -852,18 +851,18 @@ internal virtual BitmapSourceSafeMILHandle DUCECompatiblePtr
// necessary to avoid format conversion in the UCE during render and accompanying
// sychronization locks with UI thread during bitmap access.
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFormatConverter(
+ UnsafeNativeMethods.WICImagingFactory.CreateFormatConverter(
factoryMaker.ImagingFactoryPtr,
- out pIWicConverter));
+ out pIWicConverter).ThrowOnFailureExtended();
- HRESULT.Check(UnsafeNativeMethods.WICFormatConverter.Initialize(
+ UnsafeNativeMethods.WICFormatConverter.Initialize(
pIWicConverter,
pIWICSource,
ref destFmt,
DitherType.DitherTypeNone,
new SafeMILHandle(IntPtr.Zero),
0,
- WICPaletteType.WICPaletteTypeCustom));
+ WICPaletteType.WICPaletteTypeCustom).ThrowOnFailureExtended();
pIWICSource = pIWicConverter;
@@ -874,11 +873,11 @@ internal virtual BitmapSourceSafeMILHandle DUCECompatiblePtr
try
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
- factoryMaker.ImagingFactoryPtr,
- pIWICSource,
- WICBitmapCreateCacheOptions.WICBitmapCacheOnLoad,
- out pIWICSource));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
+ factoryMaker.ImagingFactoryPtr,
+ pIWICSource,
+ WICBitmapCreateCacheOptions.WICBitmapCacheOnLoad,
+ out pIWICSource).ThrowOnFailureExtended();
}
catch (Exception e)
{
@@ -900,9 +899,9 @@ internal virtual BitmapSourceSafeMILHandle DUCECompatiblePtr
}
}
- HRESULT.Check(UnsafeNativeMethods.MilCoreApi.CreateCWICWrapperBitmap(
- pIWICSource,
- out pCWICWrapperBitmap));
+ UnsafeNativeMethods.MilCoreApi.CreateCWICWrapperBitmap(
+ pIWICSource,
+ out pCWICWrapperBitmap).ThrowOnFailureExtended();
UnsafeNativeMethods.MILUnknown.AddRef(pCWICWrapperBitmap);
_convertedDUCEPtr = new BitmapSourceSafeMILHandle(pCWICWrapperBitmap.DangerousGetHandle(), pIWICSource);
@@ -1100,7 +1099,7 @@ BitmapPalette palette
if (!IsCompatibleFormat(originalFmt))
changeFormat = true;
- destFmt = BitmapSource.GetClosestDUCEFormat(originalFmt, palette);
+ destFmt = GetClosestDUCEFormat(originalFmt, palette);
}
if (frame != null &&
@@ -1189,26 +1188,26 @@ BitmapPalette palette
{
// start up a format converter
Guid fmtDestFmt = destFmt.Guid;
- HRESULT.Check(UnsafeNativeMethods.WICCodec.WICConvertBitmapSource(
- ref fmtDestFmt,
- wicSource,
- out wicConverter));
+ UnsafeNativeMethods.WICCodec.WICConvertBitmapSource(
+ ref fmtDestFmt,
+ wicSource,
+ out wicConverter).ThrowOnFailureExtended();
// dump the converted contents into a bitmap
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
- wicFactory,
- wicConverter,
- wicCache,
- out wicConvertedSource));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
+ wicFactory,
+ wicConverter,
+ wicCache,
+ out wicConvertedSource).ThrowOnFailureExtended();
}
else
{
// Create the unmanaged resources
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
- wicFactory,
- wicSource,
- wicCache,
- out wicConvertedSource));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
+ wicFactory,
+ wicSource,
+ wicCache,
+ out wicConvertedSource).ThrowOnFailureExtended();
}
wicConvertedSource.CalculateSize();
@@ -1734,13 +1733,13 @@ int IWICBitmapSource.GetSize(out int puiWidth, out int puiHeight)
{
puiWidth = bitmapSource.PixelWidth;
puiHeight = bitmapSource.PixelHeight;
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
else
{
puiWidth = 0;
puiHeight = 0;
- return NativeMethods.E_FAIL;
+ return HRESULT.E_FAIL;
}
}
@@ -1750,12 +1749,12 @@ int IWICBitmapSource.GetPixelFormat(out Guid guidFormat)
if(_bitmapSource.TryGetTarget(out bitmapSource))
{
guidFormat = bitmapSource.Format.Guid;
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
else
{
guidFormat = Guid.Empty;
- return NativeMethods.E_FAIL;
+ return HRESULT.E_FAIL;
}
}
@@ -1766,13 +1765,13 @@ int IWICBitmapSource.GetResolution(out double pDpiX, out double pDpiY)
{
pDpiX = bitmapSource.DpiX;
pDpiY = bitmapSource.DpiY;
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
else
{
pDpiX = 0.0;
pDpiY = 0.0;
- return NativeMethods.E_FAIL;
+ return HRESULT.E_FAIL;
}
}
@@ -1784,15 +1783,18 @@ int IWICBitmapSource.GetPalette(IntPtr /* IWICPalette */ pIPalette)
BitmapPalette palette = bitmapSource.Palette;
if ((palette == null) || (palette.InternalPalette == null) || palette.InternalPalette.IsInvalid)
{
- return (int)WinCodecErrors.WINCODEC_ERR_PALETTEUNAVAILABLE;
+ return (int)HRESULT.WINCODEC_ERR_PALETTEUNAVAILABLE;
}
-
- HRESULT.Check(UnsafeNativeMethods.WICPalette.InitializeFromPalette(pIPalette, palette.InternalPalette));
- return NativeMethods.S_OK;
+
+ UnsafeNativeMethods.WICPalette.InitializeFromPalette(
+ pIPalette,
+ palette.InternalPalette).ThrowOnFailureExtended();
+
+ return HRESULT.S_OK;
}
else
{
- return NativeMethods.E_FAIL;
+ return HRESULT.E_FAIL;
}
}
@@ -1800,12 +1802,12 @@ int IWICBitmapSource.CopyPixels(IntPtr prc, int cbStride, int cbPixels, IntPtr p
{
if (cbStride < 0)
{
- return NativeMethods.E_INVALIDARG;
+ return HRESULT.E_INVALIDARG;
}
if (pvPixels == IntPtr.Zero)
{
- return NativeMethods.E_INVALIDARG;
+ return HRESULT.E_INVALIDARG;
}
BitmapSource bitmapSource;
@@ -1826,29 +1828,28 @@ int IWICBitmapSource.CopyPixels(IntPtr prc, int cbStride, int cbPixels, IntPtr p
rectHeight = rc.Height;
rectWidth = rc.Width;
-
+
if (rc.Width < 1 || rc.Height < 1)
{
- return NativeMethods.E_INVALIDARG;
+ return HRESULT.E_INVALIDARG;
}
-
+
// assuming cbStride can't be negative, but that prc.Height can
PixelFormat pfStruct = bitmapSource.Format;
-
+
if (pfStruct.Format == PixelFormatEnum.Default ||
pfStruct.Format == PixelFormatEnum.Extended)
{
- return (int)(WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT);
+ return HRESULT.WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT;
}
-
-
+
int rectRowSize = checked((rectWidth * pfStruct.InternalBitsPerPixel + 7) / 8);
-
+
if (cbPixels < checked((rectHeight - 1) * cbStride + rectRowSize))
{
- return (int)(WinCodecErrors.WINCODEC_ERR_INSUFFICIENTBUFFER);
+ return HRESULT.WINCODEC_ERR_INSUFFICIENTBUFFER;
}
-
+
// Need to marshal
int arraySize = checked(rectHeight * rectRowSize);
byte[] managedArray = new byte[arraySize];
@@ -1865,12 +1866,12 @@ int IWICBitmapSource.CopyPixels(IntPtr prc, int cbStride, int cbPixels, IntPtr p
rowPtr += cbStride;
}
}
-
- return NativeMethods.S_OK;
+
+ return HRESULT.S_OK;
}
else
{
- return NativeMethods.E_FAIL;
+ return HRESULT.E_FAIL;
}
}
}
@@ -1903,7 +1904,7 @@ public WeakBitmapSourceEventSink(BitmapSource bitmapSource)
public void OnSourceDownloadCompleted(object sender, EventArgs e)
{
- BitmapSource bitmapSource = this.Target as BitmapSource;
+ BitmapSource bitmapSource = Target as BitmapSource;
if (null != bitmapSource)
{
bitmapSource.OnSourceDownloadCompleted(bitmapSource, e);
@@ -1916,7 +1917,7 @@ public void OnSourceDownloadCompleted(object sender, EventArgs e)
public void OnSourceDownloadFailed(object sender, ExceptionEventArgs e)
{
- BitmapSource bitmapSource = this.Target as BitmapSource;
+ BitmapSource bitmapSource = Target as BitmapSource;
if (null != bitmapSource)
{
bitmapSource.OnSourceDownloadFailed(bitmapSource, e);
@@ -1929,7 +1930,7 @@ public void OnSourceDownloadFailed(object sender, ExceptionEventArgs e)
public void OnSourceDownloadProgress(object sender, DownloadProgressEventArgs e)
{
- BitmapSource bitmapSource = this.Target as BitmapSource;
+ BitmapSource bitmapSource = Target as BitmapSource;
if (null != bitmapSource)
{
bitmapSource.OnSourceDownloadProgress(bitmapSource, e);
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSourceSafeMILHandle.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSourceSafeMILHandle.cs
index 197979e32ca..805acfa0a06 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSourceSafeMILHandle.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapSourceSafeMILHandle.cs
@@ -1,25 +1,18 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-//
-//
-// Description:
-// A sub-class of SafeMILHandle that can estimate size for bitmap
-// source objects.
-
using MS.Internal;
+using Windows.Win32.Foundation;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
namespace System.Windows.Media.Imaging
{
///
- /// Constructor which computes size of the handle and delegates
- /// to baseclass safe handle.
+ /// A sub-class of SafeMILHandle that can estimate size for bitmap
+ /// source objects.
///
-
internal class BitmapSourceSafeMILHandle : SafeMILHandle
{
static BitmapSourceSafeMILHandle() { }
@@ -76,13 +69,12 @@ private static long ComputeEstimatedSize(IntPtr bitmapObject)
// calling through the right vtable on the pinvoke.
//
- int hr = UnsafeNativeMethods.MILUnknown.QueryInterface(
+ HRESULT result = UnsafeNativeMethods.MILUnknown.QueryInterface(
bitmapObject,
ref _uuidBitmap,
- out wicBitmap
- );
+ out wicBitmap);
- if (hr == HRESULT.S_OK)
+ if (result == HRESULT.S_OK)
{
Debug.Assert(wicBitmap != IntPtr.Zero);
@@ -98,17 +90,17 @@ out wicBitmap
uint pixelWidth = 0;
uint pixelHeight = 0;
- hr = UnsafeNativeMethods.WICBitmapSource.GetSize(
+ result = UnsafeNativeMethods.WICBitmapSource.GetSize(
bitmapSourceSafeHandle,
out pixelWidth,
out pixelHeight);
- if (hr == HRESULT.S_OK)
+ if (result == HRESULT.S_OK)
{
Guid guidFormat;
- hr = UnsafeNativeMethods.WICBitmapSource.GetPixelFormat(bitmapSourceSafeHandle, out guidFormat);
- if (hr == HRESULT.S_OK)
+ result = UnsafeNativeMethods.WICBitmapSource.GetPixelFormat(bitmapSourceSafeHandle, out guidFormat);
+ if (result == HRESULT.S_OK)
{
//
// Go to long space to avoid overflow and check for overflow
@@ -148,5 +140,5 @@ protected override bool ReleaseHandle()
/// Guid for IWICBitmapSource
///
private static Guid _uuidBitmap = MILGuidData.IID_IWICBitmapSource;
-}
+ }
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapVisualManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapVisualManager.cs
index 8174bcfc9a6..1dc28681290 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapVisualManager.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapVisualManager.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -6,6 +6,7 @@
using MS.Internal;
using System.Windows.Media.Composition;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -111,10 +112,10 @@ internal void Render(Visual visual, Matrix worldTransform, Rect windowClip)
Guid iidRTB = MILGuidData.IID_IMILRenderTargetBitmap;
- HRESULT.Check(UnsafeNativeMethods.MILUnknown.QueryInterface(
+ UnsafeNativeMethods.MILUnknown.QueryInterface(
renderTargetBitmap,
ref iidRTB,
- out pIRenderTargetBitmap));
+ out pIRenderTargetBitmap).ThrowOnFailureExtended();
//
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BmpBitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BmpBitmapEncoder.cs
index 4127350365b..d435dd65a84 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BmpBitmapEncoder.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BmpBitmapEncoder.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -53,10 +54,9 @@ internal override Guid ContainerFormat
///
internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
+ UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
frameEncodeHandle,
- encoderOptions
- ));
+ encoderOptions).ThrowOnFailureExtended();
}
#endregion
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/CachedBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/CachedBitmap.cs
index ed5519621ac..193a18d4ed7 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/CachedBitmap.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/CachedBitmap.cs
@@ -1,9 +1,10 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -355,11 +356,11 @@ SafeMILHandle wicSource
{
using (FactoryMaker factoryMaker = new FactoryMaker())
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
- factoryMaker.ImagingFactoryPtr,
- wicSource,
- WICBitmapCreateCacheOptions.WICBitmapCacheOnLoad,
- out bitmapSource));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
+ factoryMaker.ImagingFactoryPtr,
+ wicSource,
+ WICBitmapCreateCacheOptions.WICBitmapCacheOnLoad,
+ out bitmapSource).ThrowOnFailureExtended();
}
bitmapSource.CalculateSize();
@@ -409,28 +410,28 @@ int stride
using (FactoryMaker factoryMaker = new FactoryMaker())
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromMemory(
- factoryMaker.ImagingFactoryPtr,
- (uint)pixelWidth, (uint)pixelHeight,
- ref guidFmt,
- (uint)stride,
- (uint)bufferSize,
- buffer,
- out wicBitmap));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromMemory(
+ factoryMaker.ImagingFactoryPtr,
+ (uint)pixelWidth, (uint)pixelHeight,
+ ref guidFmt,
+ (uint)stride,
+ (uint)bufferSize,
+ buffer,
+ out wicBitmap).ThrowOnFailureExtended();
wicBitmap.CalculateSize();
}
- HRESULT.Check(UnsafeNativeMethods.WICBitmap.SetResolution(
- wicBitmap,
- dpiX,
- dpiY));
+ UnsafeNativeMethods.WICBitmap.SetResolution(
+ wicBitmap,
+ dpiX,
+ dpiY).ThrowOnFailureExtended();
if (pixelFormat.Palettized)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmap.SetPalette(
+ UnsafeNativeMethods.WICBitmap.SetPalette(
wicBitmap,
- palette.InternalPalette));
+ palette.InternalPalette).ThrowOnFailureExtended();
}
WicSourceHandle = wicBitmap;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/ColorConvertedBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/ColorConvertedBitmap.cs
index 9960e5cfdf1..4976ef18019 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/ColorConvertedBitmap.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/ColorConvertedBitmap.cs
@@ -1,10 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -89,19 +90,18 @@ internal override void FinalizeCreation()
_bitmapInit.EnsureInitializedComplete();
BitmapSourceSafeMILHandle wicConverter = null;
- HRESULT.Check(UnsafeNativeMethods.WICCodec.CreateColorTransform(
- out wicConverter));
+ UnsafeNativeMethods.WICCodec.CreateColorTransform(out wicConverter).ThrowOnFailureExtended();
lock (_syncObject)
{
Guid fmtDestFmt = DestinationFormat.Guid;
- HRESULT.Check(UnsafeNativeMethods.WICColorTransform.Initialize(
- wicConverter,
- Source.WicSourceHandle,
- SourceColorContext.ColorContextHandle,
- DestinationColorContext.ColorContextHandle,
- ref fmtDestFmt));
+ UnsafeNativeMethods.WICColorTransform.Initialize(
+ wicConverter,
+ Source.WicSourceHandle,
+ SourceColorContext.ColorContextHandle,
+ DestinationColorContext.ColorContextHandle,
+ ref fmtDestFmt).ThrowOnFailureExtended();
}
//
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/CroppedBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/CroppedBitmap.cs
index f7721e4775d..740754b7232 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/CroppedBitmap.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/CroppedBitmap.cs
@@ -1,10 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -96,16 +97,16 @@ internal override void FinalizeCreation()
{
IntPtr wicFactory = factoryMaker.ImagingFactoryPtr;
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapClipper(
- wicFactory,
- out wicClipper));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapClipper(
+ wicFactory,
+ out wicClipper).ThrowOnFailureExtended();
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapClipper.Initialize(
- wicClipper,
- source.WicSourceHandle,
- ref rect));
+ UnsafeNativeMethods.WICBitmapClipper.Initialize(
+ wicClipper,
+ source.WicSourceHandle,
+ ref rect).ThrowOnFailureExtended();
}
//
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/FormatConvertedBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/FormatConvertedBitmap.cs
index 5a4670ff811..ded8bcb244d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/FormatConvertedBitmap.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/FormatConvertedBitmap.cs
@@ -1,10 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -96,9 +97,9 @@ internal override void FinalizeCreation()
{
IntPtr wicFactory = factoryMaker.ImagingFactoryPtr;
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFormatConverter(
- wicFactory,
- out wicFormatter));
+ UnsafeNativeMethods.WICImagingFactory.CreateFormatConverter(
+ wicFactory,
+ out wicFormatter).ThrowOnFailureExtended();
SafeMILHandle internalPalette;
if (DestinationPalette != null)
@@ -110,15 +111,14 @@ internal override void FinalizeCreation()
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICFormatConverter.Initialize(
- wicFormatter,
- Source.WicSourceHandle,
- ref format,
- DitherType.DitherTypeErrorDiffusion,
- internalPalette,
- AlphaThreshold,
- WICPaletteType.WICPaletteTypeOptimal
- ));
+ UnsafeNativeMethods.WICFormatConverter.Initialize(
+ wicFormatter,
+ Source.WicSourceHandle,
+ ref format,
+ DitherType.DitherTypeErrorDiffusion,
+ internalPalette,
+ AlphaThreshold,
+ WICPaletteType.WICPaletteTypeOptimal).ThrowOnFailureExtended();
}
//
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/GifBitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/GifBitmapEncoder.cs
index 56f4ccf34e2..f1841fd6d7f 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/GifBitmapEncoder.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/GifBitmapEncoder.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -53,10 +54,9 @@ internal override Guid ContainerFormat
///
internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
+ UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
frameEncodeHandle,
- encoderOptions
- ));
+ encoderOptions).ThrowOnFailureExtended();
}
#endregion
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InplaceBitmapMetadataWriter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InplaceBitmapMetadataWriter.cs
index 157e9dd4803..6f74b790723 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InplaceBitmapMetadataWriter.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InplaceBitmapMetadataWriter.cs
@@ -1,13 +1,10 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-//
-
using MS.Internal;
using MS.Win32.PresentationCore;
-using MS.Internal.PresentationCore; // SecurityHelper
+using Windows.Win32.Foundation; // SecurityHelper
namespace System.Windows.Media.Imaging
{
@@ -16,20 +13,14 @@ namespace System.Windows.Media.Imaging
///
/// Metadata Class for BitmapImage.
///
- sealed public partial class InPlaceBitmapMetadataWriter : BitmapMetadata
+ public sealed partial class InPlaceBitmapMetadataWriter : BitmapMetadata
{
#region Constructors
- ///
- ///
- ///
private InPlaceBitmapMetadataWriter()
{
}
- ///
- ///
- ///
internal InPlaceBitmapMetadataWriter(
SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle,
SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle,
@@ -39,10 +30,7 @@ object syncObject
_fmeHandle = fmeHandle;
}
- ///
- ///
- ///
- static internal InPlaceBitmapMetadataWriter CreateFromFrameDecode(BitmapSourceSafeMILHandle frameHandle, object syncObject)
+ internal static InPlaceBitmapMetadataWriter CreateFromFrameDecode(BitmapSourceSafeMILHandle frameHandle, object syncObject)
{
Invariant.Assert(frameHandle != null);
@@ -53,24 +41,21 @@ static internal InPlaceBitmapMetadataWriter CreateFromFrameDecode(BitmapSourceSa
{
lock (syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromFrameDecode(
- factoryMaker.ImagingFactoryPtr,
- frameHandle,
- out fmeHandle));
+ UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromFrameDecode(
+ factoryMaker.ImagingFactoryPtr,
+ frameHandle,
+ out fmeHandle).ThrowOnFailureExtended();
}
}
- HRESULT.Check(UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter(
- fmeHandle,
- out metadataHandle));
+ UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter(
+ fmeHandle,
+ out metadataHandle).ThrowOnFailureExtended();
return new InPlaceBitmapMetadataWriter(fmeHandle, metadataHandle, syncObject);
}
- ///
- ///
- ///
- static internal InPlaceBitmapMetadataWriter CreateFromDecoder(SafeMILHandle decoderHandle, object syncObject)
+ internal static InPlaceBitmapMetadataWriter CreateFromDecoder(SafeMILHandle decoderHandle, object syncObject)
{
Invariant.Assert(decoderHandle != null);
@@ -81,35 +66,28 @@ static internal InPlaceBitmapMetadataWriter CreateFromDecoder(SafeMILHandle deco
{
lock (syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromDecoder(
- factoryMaker.ImagingFactoryPtr,
- decoderHandle,
- out fmeHandle));
+ UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromDecoder(
+ factoryMaker.ImagingFactoryPtr,
+ decoderHandle,
+ out fmeHandle).ThrowOnFailureExtended();
}
}
- HRESULT.Check(UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter(
- fmeHandle,
- out metadataHandle));
+ UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter(
+ fmeHandle,
+ out metadataHandle).ThrowOnFailureExtended();
return new InPlaceBitmapMetadataWriter(fmeHandle, metadataHandle, syncObject);
}
- ///
- ///
- ///
public bool TrySave()
{
- int hr;
-
Invariant.Assert(_fmeHandle != null);
lock (SyncObject)
{
- hr = UnsafeNativeMethods.WICFastMetadataEncoder.Commit(_fmeHandle);
+ return UnsafeNativeMethods.WICFastMetadataEncoder.Commit(_fmeHandle).Succeeded;
}
-
- return HRESULT.Succeeded(hr);
}
#endregion
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InteropBitmapSource.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InteropBitmapSource.cs
index 3cb22a1aa29..c4437d0e281 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InteropBitmapSource.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InteropBitmapSource.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -11,6 +11,7 @@
using System.Windows.Media;
using System.Windows.Media.Composition;
using System.Windows.Media.Imaging;
+using Windows.Win32.Foundation;
namespace System.Windows.Interop
{
@@ -30,11 +31,6 @@ private InteropBitmap() : base(true)
///
/// Construct a BitmapSource from an HBITMAP.
///
- ///
- ///
- ///
- ///
- ///
internal InteropBitmap(IntPtr hbitmap, IntPtr hpalette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions, WICBitmapAlphaChannelOption alphaOptions)
: base(true) // Use virtuals
{
@@ -42,13 +38,14 @@ internal InteropBitmap(IntPtr hbitmap, IntPtr hpalette, Int32Rect sourceRect, Bi
using (FactoryMaker myFactory = new FactoryMaker())
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromHBITMAP(
- myFactory.ImagingFactoryPtr,
- hbitmap,
- hpalette,
- alphaOptions,
- out _unmanagedSource));
- Debug.Assert (_unmanagedSource != null && !_unmanagedSource.IsInvalid);
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromHBITMAP(
+ myFactory.ImagingFactoryPtr,
+ hbitmap,
+ hpalette,
+ alphaOptions,
+ out _unmanagedSource).ThrowOnFailureExtended();
+
+ Debug.Assert(_unmanagedSource != null && !_unmanagedSource.IsInvalid);
}
_unmanagedSource.CalculateSize();
@@ -60,13 +57,10 @@ internal InteropBitmap(IntPtr hbitmap, IntPtr hpalette, Int32Rect sourceRect, Bi
FinalizeCreation();
}
-
+
///
/// Construct a BitmapSource from an HICON.
///
- ///
- ///
- ///
internal InteropBitmap(IntPtr hicon, Int32Rect sourceRect, BitmapSizeOptions sizeOptions)
: base(true) // Use virtuals
{
@@ -75,11 +69,12 @@ internal InteropBitmap(IntPtr hicon, Int32Rect sourceRect, BitmapSizeOptions siz
using (FactoryMaker myFactory = new FactoryMaker())
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromHICON(
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromHICON(
myFactory.ImagingFactoryPtr,
hicon,
- out _unmanagedSource));
- Debug.Assert (_unmanagedSource != null && !_unmanagedSource.IsInvalid);
+ out _unmanagedSource).ThrowOnFailureExtended();
+
+ Debug.Assert(_unmanagedSource != null && !_unmanagedSource.IsInvalid);
}
_unmanagedSource.CalculateSize();
@@ -95,12 +90,6 @@ internal InteropBitmap(IntPtr hicon, Int32Rect sourceRect, BitmapSizeOptions siz
///
/// Construct a BitmapSource from a memory section.
///
- ///
- ///
- ///
- ///
- ///
- ///
internal InteropBitmap(
IntPtr section,
int pixelWidth,
@@ -117,16 +106,16 @@ internal InteropBitmap(
Guid formatGuid = format.Guid;
- HRESULT.Check(UnsafeNativeMethods.WindowsCodecApi.CreateBitmapFromSection(
- (uint)pixelWidth,
- (uint)pixelHeight,
- ref formatGuid,
- section,
- (uint)stride,
- (uint)offset,
- out _unmanagedSource
- ));
- Debug.Assert (_unmanagedSource != null && !_unmanagedSource.IsInvalid);
+ UnsafeNativeMethods.WindowsCodecApi.CreateBitmapFromSection(
+ (uint)pixelWidth,
+ (uint)pixelHeight,
+ ref formatGuid,
+ section,
+ (uint)stride,
+ (uint)offset,
+ out _unmanagedSource).ThrowOnFailureExtended();
+
+ Debug.Assert(_unmanagedSource != null && !_unmanagedSource.IsInvalid);
_unmanagedSource.CalculateSize();
_sourceRect = Int32Rect.Empty;
@@ -228,11 +217,11 @@ SafeMILHandle wicSource
{
using (FactoryMaker factoryMaker = new FactoryMaker())
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
- factoryMaker.ImagingFactoryPtr,
- wicSource,
- WICBitmapCreateCacheOptions.WICBitmapCacheOnLoad,
- out bitmapSource));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFromSource(
+ factoryMaker.ImagingFactoryPtr,
+ wicSource,
+ WICBitmapCreateCacheOptions.WICBitmapCacheOnLoad,
+ out bitmapSource).ThrowOnFailureExtended();
}
bitmapSource.CalculateSize();
@@ -345,7 +334,7 @@ internal override void FinalizeCreation()
BitmapSourceSafeMILHandle wicTransformer = null;
BitmapSourceSafeMILHandle transformedSource = _unmanagedSource;
- HRESULT.Check(UnsafeNativeMethods.WICBitmap.SetResolution(_unmanagedSource, 96, 96));
+ UnsafeNativeMethods.WICBitmap.SetResolution(_unmanagedSource, 96, 96).ThrowOnFailureExtended();
using (FactoryMaker factoryMaker = new FactoryMaker())
{
@@ -353,16 +342,16 @@ internal override void FinalizeCreation()
if (!_sourceRect.IsEmpty)
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapClipper(
- wicFactory,
- out wicClipper));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapClipper(
+ wicFactory,
+ out wicClipper).ThrowOnFailureExtended();
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapClipper.Initialize(
- wicClipper,
- transformedSource,
- ref _sourceRect));
+ UnsafeNativeMethods.WICBitmapClipper.Initialize(
+ wicClipper,
+ transformedSource,
+ ref _sourceRect).ThrowOnFailureExtended();
}
transformedSource = wicClipper;
@@ -381,32 +370,32 @@ internal override void FinalizeCreation()
out width,
out height);
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapScaler(
- wicFactory,
- out wicTransformer));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapScaler(
+ wicFactory,
+ out wicTransformer).ThrowOnFailureExtended();
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapScaler.Initialize(
- wicTransformer,
- transformedSource,
- width,
- height,
- WICInterpolationMode.Fant));
+ UnsafeNativeMethods.WICBitmapScaler.Initialize(
+ wicTransformer,
+ transformedSource,
+ width,
+ height,
+ WICInterpolationMode.Fant).ThrowOnFailureExtended();
}
}
else if (_sizeOptions.Rotation != Rotation.Rotate0)
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFlipRotator(
- wicFactory,
- out wicTransformer));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFlipRotator(
+ wicFactory,
+ out wicTransformer).ThrowOnFailureExtended();
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFlipRotator.Initialize(
- wicTransformer,
- transformedSource,
- _sizeOptions.WICTransformOptions));
+ UnsafeNativeMethods.WICBitmapFlipRotator.Initialize(
+ wicTransformer,
+ transformedSource,
+ _sizeOptions.WICTransformOptions).ThrowOnFailureExtended();
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/JpegBitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/JpegBitmapEncoder.cs
index ba96c2fb7a7..3d288da0437 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/JpegBitmapEncoder.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/JpegBitmapEncoder.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -123,7 +124,7 @@ public bool FlipHorizontal
}
set
{
- if (value != this.FlipHorizontal)
+ if (value != FlipHorizontal)
{
if (value)
{
@@ -149,7 +150,7 @@ public bool FlipVertical
}
set
{
- if (value != this.FlipVertical)
+ if (value != FlipVertical)
{
if (value)
{
@@ -195,11 +196,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("BitmapTransform");
propValue.Init((byte) _transformation);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -213,13 +214,13 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
try
{
propBag.Init("ImageQuality");
- propValue.Init( ((float)_qualityLevel) / 100.0f);
+ propValue.Init(((float)_qualityLevel) / 100.0f);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -228,10 +229,9 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
}
}
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
+ UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
frameEncodeHandle,
- encoderOptions
- ));
+ encoderOptions).ThrowOnFailureExtended();
}
///
@@ -247,7 +247,7 @@ private bool Rotate90
}
set
{
- if (value != this.Rotate90)
+ if (value != Rotate90)
{
bool IsFlipH = FlipHorizontal;
bool IsFlipV = FlipVertical;
@@ -278,7 +278,7 @@ private bool Rotate180
}
set
{
- if (value != this.Rotate180)
+ if (value != Rotate180)
{
bool IsFlipH = FlipHorizontal;
bool IsFlipV = FlipVertical;
@@ -309,7 +309,7 @@ private bool Rotate270
}
set
{
- if (value != this.Rotate270)
+ if (value != Rotate270)
{
bool IsFlipH = FlipHorizontal;
bool IsFlipV = FlipVertical;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/PngBitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/PngBitmapEncoder.cs
index 3aa2b327139..e0ed6b711f9 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/PngBitmapEncoder.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/PngBitmapEncoder.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -109,11 +110,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("InterlaceOption");
propValue.Init(_interlaceOption == PngInterlaceOption.On);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -122,10 +123,9 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
}
}
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
+ UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
frameEncodeHandle,
- encoderOptions
- ));
+ encoderOptions).ThrowOnFailureExtended();
}
#endregion
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/PropVariant.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/PropVariant.cs
index 4a5ac3bcd61..2326fea8bc9 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/PropVariant.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/PropVariant.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -9,6 +9,7 @@
using MS.Win32.PresentationCore;
using System.Runtime.InteropServices;
using MS.Internal.PresentationCore;
+using Windows.Win32.Foundation;
#pragma warning disable 1634, 1691 // suppressing PreSharp warnings
@@ -420,10 +421,10 @@ internal void Init(object value)
}
Guid wicMetadataQueryReader = MILGuidData.IID_IWICMetadataQueryReader;
- HRESULT.Check(UnsafeNativeMethods.MILUnknown.QueryInterface(
+ UnsafeNativeMethods.MILUnknown.QueryInterface(
metadataHandle,
ref wicMetadataQueryReader,
- out punkTemp));
+ out punkTemp).ThrowOnFailureExtended();
varType = (ushort)VarEnum.VT_UNKNOWN;
punkVal = punkTemp;
@@ -706,9 +707,9 @@ internal object ToObject(object syncObject)
try
{
- int hr = UnsafeNativeMethods.MILUnknown.QueryInterface(punkVal, ref guidIWICQueryWriter, out queryHandle);
+ HRESULT result = UnsafeNativeMethods.MILUnknown.QueryInterface(punkVal, ref guidIWICQueryWriter, out queryHandle);
- if (hr == HRESULT.S_OK)
+ if (result == HRESULT.S_OK)
{
// It's a IWICMetadataQueryWriter interface - read and write
SafeMILHandle metadataHandle = new SafeMILHandle(queryHandle);
@@ -720,9 +721,9 @@ internal object ToObject(object syncObject)
}
else
{
- hr = UnsafeNativeMethods.MILUnknown.QueryInterface(punkVal, ref guidIWICQueryReader, out queryHandle);
+ result = UnsafeNativeMethods.MILUnknown.QueryInterface(punkVal, ref guidIWICQueryReader, out queryHandle);
- if (hr == HRESULT.S_OK)
+ if (result == HRESULT.S_OK)
{
// It's a IWICMetadataQueryReader interface - read only
SafeMILHandle metadataHandle = new SafeMILHandle(queryHandle);
@@ -733,7 +734,7 @@ internal object ToObject(object syncObject)
return new BitmapMetadata(metadataHandle, true, false, syncObject);
}
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
finally
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/RenderTargetBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/RenderTargetBitmap.cs
index cf87a573029..33381a8191d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/RenderTargetBitmap.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/RenderTargetBitmap.cs
@@ -1,10 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using MS.Internal;
using MS.Win32.PresentationCore;
using System.Windows.Media.Composition;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -104,7 +105,7 @@ private void CopyCommon(RenderTargetBitmap sourceBitmap)
using (FactoryMaker myFactory = new FactoryMaker())
{
// Create an IWICBitmap
- BitmapSourceSafeMILHandle newBitmapHandle = BitmapSource.CreateCachedBitmap(
+ BitmapSourceSafeMILHandle newBitmapHandle = CreateCachedBitmap(
null,
WicSourceHandle,
BitmapCreateOptions.PreservePixelFormat,
@@ -117,11 +118,10 @@ private void CopyCommon(RenderTargetBitmap sourceBitmap)
}
// Now create a Render target from that Bitmap
- HRESULT.Check(UnsafeNativeMethods.MILFactory2.CreateBitmapRenderTargetForBitmap(
+ UnsafeNativeMethods.MILFactory2.CreateBitmapRenderTargetForBitmap(
myFactory.FactoryPtr,
newBitmapHandle,
- out _renderTargetBitmap
- ));
+ out _renderTargetBitmap).ThrowOnFailureExtended();
}
_bitmapInit.EndInit();
@@ -190,7 +190,7 @@ public void Render(Visual visual)
///
public void Clear()
{
- HRESULT.Check(MILRenderTargetBitmap.Clear(_renderTargetBitmap));
+ MILRenderTargetBitmap.Clear(_renderTargetBitmap).ThrowOnFailureExtended();
RenderTargetContentsChanged();
}
@@ -236,7 +236,7 @@ internal override void FinalizeCreation()
using (FactoryMaker myFactory = new FactoryMaker())
{
SafeMILHandle renderTargetBitmap = null;
- HRESULT.Check(UnsafeNativeMethods.MILFactory2.CreateBitmapRenderTarget(
+ UnsafeNativeMethods.MILFactory2.CreateBitmapRenderTarget(
myFactory.FactoryPtr,
(uint)_pixelWidth,
(uint)_pixelHeight,
@@ -244,14 +244,14 @@ internal override void FinalizeCreation()
(float)_dpiX,
(float)_dpiY,
MILRTInitializationFlags.MIL_RT_INITIALIZE_DEFAULT,
- out renderTargetBitmap));
+ out renderTargetBitmap).ThrowOnFailureExtended();
Debug.Assert(renderTargetBitmap != null && !renderTargetBitmap.IsInvalid);
BitmapSourceSafeMILHandle bitmapSource = null;
- HRESULT.Check(MILRenderTargetBitmap.GetBitmap(
+ MILRenderTargetBitmap.GetBitmap(
renderTargetBitmap,
- out bitmapSource));
+ out bitmapSource).ThrowOnFailureExtended();
Debug.Assert(bitmapSource != null && !bitmapSource.IsInvalid);
lock (_syncObject)
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/TiffBitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/TiffBitmapEncoder.cs
index 8f965626de9..02aec6e8e00 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/TiffBitmapEncoder.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/TiffBitmapEncoder.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -143,13 +144,13 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
try
{
propBag.Init("TiffCompressionMethod");
- propValue.Init((byte) _compressionMethod);
+ propValue.Init((byte)_compressionMethod);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -158,10 +159,9 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
}
}
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
+ UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
frameEncodeHandle,
- encoderOptions
- ));
+ encoderOptions).ThrowOnFailureExtended();
}
#endregion
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/TransformedBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/TransformedBitmap.cs
index 0ecc22e5748..63755d9fcce 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/TransformedBitmap.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/TransformedBitmap.cs
@@ -1,10 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -176,18 +177,18 @@ internal override void FinalizeCreation()
uint width = Math.Max(1, (uint)(scaleX * _source.PixelWidth + 0.5));
uint height = Math.Max(1, (uint)(scaleY * _source.PixelHeight + 0.5));
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapScaler(
- wicFactory,
- out wicTransformer));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapScaler(
+ wicFactory,
+ out wicTransformer).ThrowOnFailureExtended();
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapScaler.Initialize(
- wicTransformer,
- _source.WicSourceHandle,
- width,
- height,
- WICInterpolationMode.Fant));
+ UnsafeNativeMethods.WICBitmapScaler.Initialize(
+ wicTransformer,
+ _source.WicSourceHandle,
+ width,
+ height,
+ WICInterpolationMode.Fant).ThrowOnFailureExtended();
}
}
@@ -208,16 +209,16 @@ internal override void FinalizeCreation()
BitmapSourceSafeMILHandle rotator = null;
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFlipRotator(
- wicFactory,
- out rotator));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFlipRotator(
+ wicFactory,
+ out rotator).ThrowOnFailureExtended();
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFlipRotator.Initialize(
- rotator,
- wicTransformer,
- options));
+ UnsafeNativeMethods.WICBitmapFlipRotator.Initialize(
+ rotator,
+ wicTransformer,
+ options).ThrowOnFailureExtended();
}
wicTransformer = rotator;
@@ -228,16 +229,16 @@ internal override void FinalizeCreation()
if (options == WICBitmapTransformOptions.WICBitmapTransformRotate0 &&
DoubleUtil.IsOne(scaleX) && DoubleUtil.IsOne(scaleY))
{
- HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFlipRotator(
- wicFactory,
- out wicTransformer));
+ UnsafeNativeMethods.WICImagingFactory.CreateBitmapFlipRotator(
+ wicFactory,
+ out wicTransformer).ThrowOnFailureExtended();
lock (_syncObject)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFlipRotator.Initialize(
- wicTransformer,
- _source.WicSourceHandle,
- WICBitmapTransformOptions.WICBitmapTransformRotate0));
+ UnsafeNativeMethods.WICBitmapFlipRotator.Initialize(
+ wicTransformer,
+ _source.WicSourceHandle,
+ WICBitmapTransformOptions.WICBitmapTransformRotate0).ThrowOnFailureExtended();
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/UnknownBitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/UnknownBitmapEncoder.cs
index 106ec00ce29..7404055f7e0 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/UnknownBitmapEncoder.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/UnknownBitmapEncoder.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -56,10 +57,9 @@ internal override Guid ContainerFormat
///
internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions)
{
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
+ UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
frameEncodeHandle,
- encoderOptions
- ));
+ encoderOptions).ThrowOnFailureExtended();
}
#endregion
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WmpBitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WmpBitmapEncoder.cs
index 2478a4b8deb..83a406a8ec4 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WmpBitmapEncoder.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WmpBitmapEncoder.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using MS.Internal;
using MS.Win32.PresentationCore;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -140,7 +141,7 @@ public bool FlipHorizontal
}
set
{
- if (value != this.FlipHorizontal)
+ if (value != FlipHorizontal)
{
if (value)
{
@@ -166,7 +167,7 @@ public bool FlipVertical
}
set
{
- if (value != this.FlipVertical)
+ if (value != FlipVertical)
{
if (value)
{
@@ -421,11 +422,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("ImageQuality");
propValue.Init((float)_imagequalitylevel);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -439,13 +440,13 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
try
{
propBag.Init("BitmapTransform");
- propValue.Init((byte) _transformation);
+ propValue.Init((byte)_transformation);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -461,11 +462,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("Lossless");
propValue.Init((bool)_lossless);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -481,11 +482,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("UseCodecOptions");
propValue.Init((bool)_usecodecoptions);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -501,11 +502,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("Quality");
propValue.Init((byte)_qualitylevel);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -521,11 +522,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("Subsampling");
propValue.Init((byte)_subsamplinglevel);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -541,11 +542,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("Overlap");
propValue.Init((byte)_overlaplevel);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -561,11 +562,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("HorizontalTileSlices");
propValue.Init((ushort)_horizontaltileslices );
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -581,11 +582,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("VerticalTileSlices");
propValue.Init((ushort)_verticaltileslices );
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -601,11 +602,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("FrequencyOrder");
propValue.Init((bool)_frequencyorder);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -621,11 +622,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("InterleavedAlpha");
propValue.Init((bool)_interleavedalpha);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -641,11 +642,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("AlphaQuality");
propValue.Init((byte)_alphaqualitylevel);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -661,11 +662,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("CompressedDomainTranscode");
propValue.Init((bool)_compresseddomaintranscode);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -681,11 +682,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("ImageDataDiscard");
propValue.Init((byte)_imagedatadiscardlevel);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -701,11 +702,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("AlphaDataDiscard");
propValue.Init((byte)_alphadatadiscardlevel);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -721,11 +722,11 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
propBag.Init("IgnoreOverlap");
propValue.Init((bool)_ignoreoverlap);
- HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write(
+ UnsafeNativeMethods.IPropertyBag2.Write(
encoderOptions,
1,
ref propBag,
- ref propValue));
+ ref propValue).ThrowOnFailureExtended();
}
finally
{
@@ -734,10 +735,9 @@ internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle
}
}
- HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
+ UnsafeNativeMethods.WICBitmapFrameEncode.Initialize(
frameEncodeHandle,
- encoderOptions
- ));
+ encoderOptions).ThrowOnFailureExtended();
}
///
@@ -753,7 +753,7 @@ private bool Rotate90
}
set
{
- if (value != this.Rotate90)
+ if (value != Rotate90)
{
bool IsFlipH = FlipHorizontal;
bool IsFlipV = FlipVertical;
@@ -784,7 +784,7 @@ private bool Rotate180
}
set
{
- if (value != this.Rotate180)
+ if (value != Rotate180)
{
bool IsFlipH = FlipHorizontal;
bool IsFlipV = FlipVertical;
@@ -815,7 +815,7 @@ private bool Rotate270
}
set
{
- if (value != this.Rotate270)
+ if (value != Rotate270)
{
bool IsFlipH = FlipHorizontal;
bool IsFlipV = FlipVertical;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs
index ab96f9e8919..4b7a49af8c0 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -8,6 +8,7 @@
using System.Runtime.InteropServices;
using System.Windows.Media.Composition;
using System.Threading;
+using Windows.Win32.Foundation;
namespace System.Windows.Media.Imaging
{
@@ -81,25 +82,25 @@ BitmapPalette palette
if (pixelWidth < 0)
{
// Backwards Compat
- HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW);
+ HRESULT.FromWin32(WIN32_ERROR.ERROR_ARITHMETIC_OVERFLOW).ThrowOnFailureExtended();
}
if (pixelWidth == 0)
{
// Backwards Compat
- HRESULT.Check(MS.Win32.NativeMethods.E_INVALIDARG);
+ HRESULT.E_INVALIDARG.ThrowOnFailureExtended();
}
if (pixelHeight < 0)
{
// Backwards Compat
- HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW);
+ HRESULT.FromWin32(WIN32_ERROR.ERROR_ARITHMETIC_OVERFLOW).ThrowOnFailureExtended();
}
if (pixelHeight == 0)
{
// Backwards Compat
- HRESULT.Check(MS.Win32.NativeMethods.E_INVALIDARG);
+ HRESULT.E_INVALIDARG.ThrowOnFailureExtended();
}
//
@@ -114,15 +115,14 @@ BitmapPalette palette
internalPalette = palette.InternalPalette;
}
- HRESULT.Check(MILSwDoubleBufferedBitmap.Create(
- (uint) pixelWidth, // safe cast
- (uint) pixelHeight, // safe cast
+ MILSwDoubleBufferedBitmap.Create(
+ (uint)pixelWidth, // safe cast
+ (uint)pixelHeight, // safe cast
dpiX,
dpiY,
ref formatGuid,
internalPalette,
- out _pDoubleBufferedBitmap
- ));
+ out _pDoubleBufferedBitmap).ThrowOnFailureExtended();
_pDoubleBufferedBitmap.UpdateEstimatedSize(
GetEstimatedSize(pixelWidth, pixelHeight, pixelFormat));
@@ -254,12 +254,11 @@ public bool TryLock(Duration timeout)
Int32Rect rect = new Int32Rect(0, 0, _pixelWidth, _pixelHeight);
- HRESULT.Check(UnsafeNativeMethods.WICBitmap.Lock(
+ UnsafeNativeMethods.WICBitmap.Lock(
WicSourceHandle,
ref rect,
LockFlags.MIL_LOCK_WRITE,
- out _pBackBufferLock
- ));
+ out _pBackBufferLock).ThrowOnFailureExtended();
// If this is the first lock operation, cache the BackBuffer and
// BackBufferStride. These two values will never change, so we
@@ -268,18 +267,18 @@ out _pBackBufferLock
{
IntPtr tempBackBufferPointer = IntPtr.Zero;
uint lockBufferSize = 0;
- HRESULT.Check(UnsafeNativeMethods.WICBitmapLock.GetDataPointer(
+ UnsafeNativeMethods.WICBitmapLock.GetDataPointer(
_pBackBufferLock,
ref lockBufferSize,
- ref tempBackBufferPointer
- ));
+ ref tempBackBufferPointer).ThrowOnFailureExtended();
+
BackBuffer = tempBackBufferPointer;
uint lockBufferStride = 0;
- HRESULT.Check(UnsafeNativeMethods.WICBitmapLock.GetStride(
+ UnsafeNativeMethods.WICBitmapLock.GetStride(
_pBackBufferLock,
- ref lockBufferStride
- ));
+ ref lockBufferStride).ThrowOnFailureExtended();
+
Invariant.Assert(lockBufferStride <= Int32.MaxValue);
_backBufferStride = (int)lockBufferStride;
}
@@ -600,7 +599,7 @@ protected override bool FreezeCore(bool isChecking)
//
// Protect the back buffer for writing
- HRESULT.Check(MILSwDoubleBufferedBitmap.ProtectBackBuffer(_pDoubleBufferedBitmap));
+ MILSwDoubleBufferedBitmap.ProtectBackBuffer(_pDoubleBufferedBitmap).ThrowOnFailureExtended();
// Get the back buffer to be used as our WicSourceHandle
AcquireBackBuffer(TimeSpan.Zero, false);
@@ -723,13 +722,13 @@ BitmapSource source
if (source.PixelWidth < 0)
{
// Backwards Compat
- HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW);
+ HRESULT.FromWin32(WIN32_ERROR.ERROR_ARITHMETIC_OVERFLOW).ThrowOnFailureExtended();
}
if (source.PixelHeight < 0)
{
// Backwards Compat
- HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW);
+ HRESULT.FromWin32(WIN32_ERROR.ERROR_ARITHMETIC_OVERFLOW).ThrowOnFailureExtended();
}
BeginInit();
@@ -744,16 +743,15 @@ BitmapSource source
{
internalPalette = source.Palette.InternalPalette;
}
-
- HRESULT.Check(MILSwDoubleBufferedBitmap.Create(
+
+ MILSwDoubleBufferedBitmap.Create(
(uint)source.PixelWidth, // safe cast
(uint)source.PixelHeight, // safe cast
source.DpiX,
source.DpiY,
ref formatGuid,
internalPalette,
- out _pDoubleBufferedBitmap
- ));
+ out _pDoubleBufferedBitmap).ThrowOnFailureExtended();
_pDoubleBufferedBitmap.UpdateEstimatedSize(
GetEstimatedSize(source.PixelWidth, source.PixelHeight, source.Format));
@@ -831,11 +829,11 @@ bool backwardsCompat
}
else if(sourceRect.Width > _pixelWidth || sourceRect.Height > _pixelHeight || destinationX > _pixelWidth - sourceRect.Width || destinationY > _pixelHeight - sourceRect.Height)
{
- HRESULT.Check(MS.Win32.NativeMethods.E_INVALIDARG);
+ HRESULT.E_INVALIDARG.ThrowOnFailureExtended();
}
else if (destinationX < 0 || destinationY < 0)
{
- HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW);
+ HRESULT.FromWin32(WIN32_ERROR.ERROR_ARITHMETIC_OVERFLOW).ThrowOnFailureExtended();
}
//
@@ -871,7 +869,7 @@ bool backwardsCompat
{
if (backwardsCompat)
{
- HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_INSUFFICIENTBUFFER);
+ HRESULT.WINCODEC_ERR_INSUFFICIENTBUFFER.ThrowOnFailureExtended();
}
else
{
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MILUtilities.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MILUtilities.cs
index a6ae8561157..287a56852cd 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MILUtilities.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MILUtilities.cs
@@ -1,14 +1,12 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-//
-
using System.Windows.Media.Media3D;
using System.Windows.Media.Composition;
using MS.Internal;
using System.Runtime.InteropServices;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
{
@@ -145,10 +143,10 @@ internal struct MilRectF
};
[DllImport(DllImport.MilCore)]
- private extern static /*HRESULT*/ int MIL3DCalcProjected2DBounds(
+ private static extern HRESULT MIL3DCalcProjected2DBounds(
ref D3DMATRIX pFullTransform3D,
ref MILRect3D pboxBounds,
- out MilRectF prcDestRect);
+ out MilRectF prcDestRect);
[DllImport(DllImport.MilCore, EntryPoint = "MilUtility_CopyPixelBuffer", PreserveSig = false)]
internal extern static unsafe void MILCopyPixelBuffer(
@@ -172,11 +170,10 @@ internal static Rect ProjectBounds(
MILRect3D originalBoxFloat = new MILRect3D(ref originalBox);
MilRectF outRect = new MilRectF();
- HRESULT.Check(
- MIL3DCalcProjected2DBounds(
- ref viewProjFloatMatrix,
- ref originalBoxFloat,
- out outRect));
+ MIL3DCalcProjected2DBounds(
+ ref viewProjFloatMatrix,
+ ref originalBoxFloat,
+ out outRect).ThrowOnFailureExtended();
if (outRect.Left == outRect.Right ||
outRect.Top == outRect.Bottom)
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs
index 00e222801f5..661bf053af4 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -11,6 +11,7 @@
using MS.Internal;
using MS.Utility;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
{
@@ -214,7 +215,7 @@ internal MediaContext(Dispatcher dispatcher)
}
// Subscribe to the OnDestroyContext event so that we can cleanup our state.
- _destroyHandler = new EventHandler(this.OnDestroyContext);
+ _destroyHandler = new EventHandler(OnDestroyContext);
Dispatcher.ShutdownFinished += _destroyHandler;
_renderMessage = new DispatcherOperationCallback(RenderMessageHandler);
@@ -271,7 +272,7 @@ internal void NotifySyncChannelMessage(DUCE.Channel channel)
// we remove the sync channels so that if the app handles the exception
// it will get a new partition on the next sync render request.
_channelManager.RemoveSyncChannels();
- NotifyPartitionIsZombie(message.HRESULTFailure.HRESULTFailureCode);
+ NotifyPartitionIsZombie((HRESULT)message.HRESULTFailure.HRESULTFailureCode);
break;
default:
@@ -315,7 +316,7 @@ internal void NotifyChannelMessage()
break;
case DUCE.MilMessage.Type.PartitionIsZombie:
- NotifyPartitionIsZombie(message.HRESULTFailure.HRESULTFailureCode);
+ NotifyPartitionIsZombie((HRESULT)message.HRESULTFailure.HRESULTFailureCode);
break;
case DUCE.MilMessage.Type.BadPixelShader:
@@ -413,23 +414,27 @@ private void NotifyBadPixelShader()
/// zombie state. This means either an unhandled batch processing,
/// rendering or presentation error and will require us to reconnect.
///
- private void NotifyPartitionIsZombie(int failureCode)
+ private static void NotifyPartitionIsZombie(HRESULT failureCode)
{
+ // We only get back these kinds of notification:
//
- // We only get back these kinds of notification:-
- // For all OOM cases, we get E_OUTOFMEMORY.
- // For all OOVM cases, we get D3DERR_OUTOFVIDEOMEMORY and
- // for all other errors we get WGXERR_UCE_RENDERTHREADFAILURE.
- //
+ // For all OOM cases, we get E_OUTOFMEMORY.
+ // For all OOVM cases, we get D3DERR_OUTOFVIDEOMEMORY and
+ // for all other errors we get WGXERR_UCE_RENDERTHREADFAILURE.
- switch (failureCode)
+ if (failureCode == HRESULT.E_OUTOFMEMORY)
+ {
+#pragma warning disable CA2201 // Do not raise reserved exception types
+ throw new OutOfMemoryException();
+ }
+ else if (failureCode == D3dErrors.D3DERR_OUTOFVIDEOMEMORY)
+ {
+ throw new OutOfMemoryException(SR.MediaContext_OutOfVideoMemory);
+#pragma warning restore CA2201
+ }
+ else
{
- case HRESULT.E_OUTOFMEMORY:
- throw new System.OutOfMemoryException();
- case HRESULT.D3DERR_OUTOFVIDEOMEMORY:
- throw new System.OutOfMemoryException(SR.MediaContext_OutOfVideoMemory);
- default:
- throw new System.InvalidOperationException(SR.MediaContext_RenderThreadError);
+ throw new InvalidOperationException(SR.MediaContext_RenderThreadError);
}
}
@@ -1508,7 +1513,7 @@ internal static void UnregisterICompositionTarget(Dispatcher dispatcher, ICompos
Debug.Assert(dispatcher != null);
Debug.Assert(iv != null);
- MediaContext.From(dispatcher).UnregisterICompositionTargetInternal(iv);
+ From(dispatcher).UnregisterICompositionTargetInternal(iv);
}
///
@@ -1823,7 +1828,7 @@ private void RenderMessageHandlerCore(
// (TimeManager gets its tick time from MediaContext's IClock implementation).
// In the case where we can't query QPC or aren't doing interlocked presents,
// this will be equal to the current time, which is a good enough approximation.
- Rendering?.Invoke(this.Dispatcher, new RenderingEventArgs(_timeManager.LastTickTime));
+ Rendering?.Invoke(Dispatcher, new RenderingEventArgs(_timeManager.LastTickTime));
// call all render callbacks again in case the Rendering event affects layout
// this will enable layout effecting changes to get triggered this frame
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContextNotificationWindow.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContextNotificationWindow.cs
index ac1e3246ac7..2e1e7be3cae 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContextNotificationWindow.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContextNotificationWindow.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -12,6 +12,8 @@
using System.Runtime.InteropServices;
using MS.Internal.Interop;
using MS.Win32;
+using Windows.Win32.Foundation;
+using HRESULT = Windows.Win32.Foundation.HRESULT;
namespace System.Windows.Media
{
@@ -73,17 +75,15 @@ internal MediaContextNotificationWindow(MediaContext ownerMediaContext)
//
ChangeWindowMessageFilter(s_dwmRedirectionEnvironmentChanged, 1 /* MSGFLT_ADD */);
- MS.Internal.HRESULT.Check(MilContent_AttachToHwnd(_hwndNotification.Handle));
+ MilContent_AttachToHwnd(_hwndNotification.Handle).ThrowOnFailureExtended();
}
public void Dispose()
{
if (!_isDisposed)
{
- //
// If DWM is not running, this call will result in NoOp.
- //
- MS.Internal.HRESULT.Check(MilContent_DetachFromHwnd(_hwndNotification.Handle));
+ MilContent_DetachFromHwnd(_hwndNotification.Handle).ThrowOnFailureExtended();
_hwndNotification.Dispose();
@@ -134,14 +134,13 @@ private IntPtr MessageFilter(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam,
if (message == WindowMessage.WM_DWMCOMPOSITIONCHANGED)
{
- //
// We need to register as MIL content to receive the Vista Magnifier messages
// (see comments in ctor).
//
// We're going to attempt to attach to DWM every time the desktop composition
// state changes to ensure that we properly handle DWM crashing/restarting/etc.
- //
- MS.Internal.HRESULT.Check(MilContent_AttachToHwnd(_hwndNotification.Handle));
+
+ MilContent_AttachToHwnd(_hwndNotification.Handle).ThrowOnFailureExtended();
}
else if (message == s_channelNotifyMessage)
{
@@ -156,14 +155,10 @@ private IntPtr MessageFilter(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam,
}
[DllImport(DllImport.MilCore)]
- private static extern int MilContent_AttachToHwnd(
- IntPtr hwnd
- );
+ private static extern HRESULT MilContent_AttachToHwnd(IntPtr hwnd);
[DllImport(DllImport.MilCore)]
- private static extern int MilContent_DetachFromHwnd(
- IntPtr hwnd
- );
+ private static extern HRESULT MilContent_DetachFromHwnd(IntPtr hwnd);
///
/// Allow lower integrity applications to send specified window messages
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs
index f7fbc3ed54e..ff8a12a4e92 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -11,6 +11,7 @@
using System.Windows.Navigation;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
+using Windows.Win32.Foundation;
#pragma warning disable 1634, 1691
@@ -102,7 +103,7 @@ internal bool IsBuffering
{
VerifyAPI();
bool isBuffering = false;
- HRESULT.Check(MILMedia.IsBuffering(_nativeMedia, ref isBuffering));
+ MILMedia.IsBuffering(_nativeMedia, ref isBuffering).ThrowOnFailureExtended();
return isBuffering;
}
}
@@ -116,7 +117,7 @@ internal bool CanPause
{
VerifyAPI();
bool canPause = false;
- HRESULT.Check(MILMedia.CanPause(_nativeMedia, ref canPause));
+ MILMedia.CanPause(_nativeMedia, ref canPause).ThrowOnFailureExtended();
return canPause;
}
}
@@ -130,7 +131,7 @@ internal double DownloadProgress
{
VerifyAPI();
double downloadProgress = 0;
- HRESULT.Check(MILMedia.GetDownloadProgress(_nativeMedia, ref downloadProgress));
+ MILMedia.GetDownloadProgress(_nativeMedia, ref downloadProgress).ThrowOnFailureExtended();
return downloadProgress;
}
}
@@ -144,7 +145,7 @@ internal double BufferingProgress
{
VerifyAPI();
double bufferingProgress = 0;
- HRESULT.Check(MILMedia.GetBufferingProgress(_nativeMedia, ref bufferingProgress));
+ MILMedia.GetBufferingProgress(_nativeMedia, ref bufferingProgress).ThrowOnFailureExtended();
return bufferingProgress;
}
}
@@ -160,7 +161,7 @@ internal Int32 NaturalVideoHeight
UInt32 height = 0;
- HRESULT.Check(MILMedia.GetNaturalHeight(_nativeMedia, ref height));
+ MILMedia.GetNaturalHeight(_nativeMedia, ref height).ThrowOnFailureExtended();
return (Int32)height;
}
}
@@ -176,7 +177,7 @@ internal Int32 NaturalVideoWidth
UInt32 width = 0;
- HRESULT.Check(MILMedia.GetNaturalWidth(_nativeMedia, ref width));
+ MILMedia.GetNaturalWidth(_nativeMedia, ref width).ThrowOnFailureExtended();
return (Int32)width;
}
}
@@ -192,7 +193,7 @@ internal bool HasAudio
bool hasAudio = true;
- HRESULT.Check(MILMedia.HasAudio(_nativeMedia, ref hasAudio));
+ MILMedia.HasAudio(_nativeMedia, ref hasAudio).ThrowOnFailureExtended();
return hasAudio;
}
}
@@ -208,7 +209,7 @@ internal bool HasVideo
bool hasVideo = false;
- HRESULT.Check(MILMedia.HasVideo(_nativeMedia, ref hasVideo));
+ MILMedia.HasVideo(_nativeMedia, ref hasVideo).ThrowOnFailureExtended();
return hasVideo;
}
}
@@ -259,9 +260,7 @@ internal double Volume
{
if (!_muted)
{
- int hr = MILMedia.SetVolume(_nativeMedia, value);
-
- HRESULT.Check(hr);
+ MILMedia.SetVolume(_nativeMedia, value).ThrowOnFailureExtended();
// value is changing
_volume = value;
@@ -305,9 +304,7 @@ internal double Balance
// is not the same. No need to do extra work.
if (!DoubleUtil.AreClose(_balance, value))
{
- int hr = MILMedia.SetBalance(_nativeMedia, value);
-
- HRESULT.Check(hr);
+ MILMedia.SetBalance(_nativeMedia, value).ThrowOnFailureExtended();
// value is changing
_balance = value;
@@ -330,7 +327,7 @@ internal bool ScrubbingEnabled
VerifyAPI();
if (value != _scrubbingEnabled)
{
- HRESULT.Check(MILMedia.SetIsScrubbingEnabled(_nativeMedia, value));
+ MILMedia.SetIsScrubbingEnabled(_nativeMedia, value).ThrowOnFailureExtended();
_scrubbingEnabled = value;
}
}
@@ -358,7 +355,7 @@ internal bool IsMuted
// Going from Unmuted -> Muted
// Set the volume to 0
- this.Volume = 0;
+ Volume = 0;
_muted = true;
// make sure cached volume is previous value
@@ -375,7 +372,7 @@ internal bool IsMuted
_volume = 0;
// set volume to old cached value, which will also update our current cached value
- this.Volume = volume;
+ Volume = volume;
}
}
}
@@ -387,7 +384,8 @@ internal Duration NaturalDuration
VerifyAPI();
long mediaLength = 0;
- HRESULT.Check(MILMedia.GetMediaLength(_nativeMedia, ref mediaLength));
+ MILMedia.GetMediaLength(_nativeMedia, ref mediaLength).ThrowOnFailureExtended();
+
if (mediaLength == 0)
{
return Duration.Automatic;
@@ -718,7 +716,7 @@ internal void Stop()
VerifyNotControlledByClock();
- HRESULT.Check(MILMedia.Close(_nativeMedia));
+ MILMedia.Close(_nativeMedia).ThrowOnFailureExtended();
//
// Once we successfully close, we don't have a clock anymore.
@@ -767,8 +765,7 @@ bool notifyUceDirectly
NeedUIFrameUpdate()
{
VerifyAPI();
-
- HRESULT.Check(MILMedia.NeedUIFrameUpdate(_nativeMedia));
+ MILMedia.NeedUIFrameUpdate(_nativeMedia).ThrowOnFailureExtended();
}
#endregion
@@ -786,12 +783,11 @@ private void CreateMedia(MediaPlayer mediaPlayer)
{
using (FactoryMaker myFactory = new FactoryMaker())
{
- HRESULT.Check(UnsafeNativeMethods.MILFactory2.CreateMediaPlayer(
- myFactory.FactoryPtr,
- unmanagedProxy,
- true,
- out _nativeMedia
- ));
+ UnsafeNativeMethods.MILFactory2.CreateMediaPlayer(
+ myFactory.FactoryPtr,
+ unmanagedProxy,
+ true,
+ out _nativeMedia).ThrowOnFailureExtended();
}
}
catch
@@ -844,7 +840,7 @@ private void OpenMedia(Uri source)
// We pass in exact same URI for which we demanded permissions so that we can be sure
// there is no discrepancy between the two.
- HRESULT.Check(MILMedia.Open(_nativeMedia, toOpen));
+ MILMedia.Open(_nativeMedia, toOpen).ThrowOnFailureExtended();
}
private Uri ResolveUri(Uri uri, Uri appBase)
@@ -885,8 +881,7 @@ private string DemandPermissions(Uri absoluteUri)
internal void SetPosition(TimeSpan value)
{
VerifyAPI();
-
- HRESULT.Check(MILMedia.SetPosition(_nativeMedia, value.Ticks));
+ MILMedia.SetPosition(_nativeMedia, value.Ticks).ThrowOnFailureExtended();
}
///
@@ -895,9 +890,8 @@ internal void SetPosition(TimeSpan value)
private TimeSpan GetPosition()
{
VerifyAPI();
-
long position = 0;
- HRESULT.Check(MILMedia.GetPosition(_nativeMedia, ref position));
+ MILMedia.GetPosition(_nativeMedia, ref position).ThrowOnFailureExtended();
return TimeSpan.FromTicks(position);
}
@@ -906,10 +900,8 @@ private double PrivateSpeedRatio
set
{
VerifyAPI();
-
ArgumentOutOfRangeException.ThrowIfEqual(value, double.NaN);
-
- HRESULT.Check(MILMedia.SetRate(_nativeMedia, value));
+ MILMedia.SetRate(_nativeMedia, value).ThrowOnFailureExtended();
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs
index 4e667e318ca..e10b7324e3c 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -10,7 +10,7 @@
using System.Windows.Media.Composition;
using System.Windows.Threading;
using MS.Internal;
-
+using Windows.Win32.Foundation;
using SafeNativeMethods = MS.Win32.PresentationCore.SafeNativeMethods;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods.MilCoreApi;
@@ -42,7 +42,7 @@ public static bool Startup(MediaContext mc)
// *** Failure here does NOT indicate a bug in MediaContext.Startup! ***
//
- HRESULT.Check(UnsafeNativeMethods.MilVersionCheck(MS.Internal.Composition.Version.MilSdkVersion));
+ UnsafeNativeMethods.MilVersionCheck(MS.Internal.Composition.Version.MilSdkVersion).ThrowOnFailureExtended();
using (CompositionEngineLock.Acquire())
{
@@ -51,9 +51,8 @@ public static bool Startup(MediaContext mc)
//Is this the first startup?
if (0 == s_refCount)
{
- HRESULT.Check(SafeNativeMethods.MilCompositionEngine_InitializePartitionManager(
- 0 // THREAD_PRIORITY_NORMAL
- ));
+ SafeNativeMethods.MilCompositionEngine_InitializePartitionManager(
+ 0).ThrowOnFailureExtended(); // THREAD_PRIORITY_NORMAL
s_forceSoftareForGraphicsStreamMagnifier =
UnsafeNativeMethods.WgxConnection_ShouldForceSoftwareForGraphicsStreamClient();
@@ -134,7 +133,7 @@ internal static void Shutdown(MediaContext mc)
DisconnectTransport();
}
- HRESULT.Check(SafeNativeMethods.MilCompositionEngine_DeinitializePartitionManager());
+ SafeNativeMethods.MilCompositionEngine_DeinitializePartitionManager().ThrowOnFailureExtended();
}
}
}
@@ -194,9 +193,9 @@ private static void ConnectTransport()
// If creation fails, fall back to a local transport.
//
- HRESULT.Check(UnsafeNativeMethods.WgxConnection_Create(
+ UnsafeNativeMethods.WgxConnection_Create(
false, // false means asynchronous transport
- out s_pConnection));
+ out s_pConnection).ThrowOnFailureExtended();
// Create service channel used by global glyph cache. This channel is
// the first channel created for the app, and by creating it with
@@ -227,7 +226,7 @@ private static void DisconnectTransport()
// Close global glyph cache channel.
s_serviceChannel.Close();
- HRESULT.Check(UnsafeNativeMethods.WgxConnection_Disconnect(s_pConnection));
+ UnsafeNativeMethods.WgxConnection_Disconnect(s_pConnection).ThrowOnFailureExtended();
// Release references to global glyph cache and service channel.
s_serviceChannel = null;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathGeometry.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathGeometry.cs
index 8e6ec842f1a..cbd06ad22a4 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathGeometry.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathGeometry.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using System.Windows.Markup;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
{
@@ -568,14 +569,14 @@ public void GetPointAtFractionLength(
{
Debug.Assert(pbPathData != (byte*)0);
- HRESULT.Check(MilCoreApi.MilUtility_GetPointAtLengthFraction(
+ MilCoreApi.MilUtility_GetPointAtLengthFraction(
&pathData.Matrix,
pathData.FillRule,
pbPathData,
pathData.Size,
progress,
out point,
- out tangent));
+ out tangent).ThrowOnFailureExtended();
}
}
}
@@ -619,7 +620,7 @@ internal static PathGeometry InternalCombine(
FillRule fillRule = FillRule.Nonzero;
FigureList list = new FigureList();
- int hr = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryCombine(
+ HRESULT result = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryCombine(
&matrix,
&data1.Matrix,
data1.FillRule,
@@ -635,7 +636,7 @@ internal static PathGeometry InternalCombine(
mode,
out fillRule);
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we return an empty geometry.
@@ -643,8 +644,7 @@ internal static PathGeometry InternalCombine(
}
else
{
- HRESULT.Check(hr);
-
+ result.ThrowOnFailureExtended();
resultGeometry = new PathGeometry(list.Figures, fillRule, null);
}
}
@@ -710,10 +710,10 @@ public override Rect Bounds
///
internal static Rect GetPathBounds(
PathGeometryData pathData,
- Pen pen,
- Matrix worldMatrix,
- double tolerance,
- ToleranceType type,
+ Pen pen,
+ Matrix worldMatrix,
+ double tolerance,
+ ToleranceType type,
bool skipHollows)
{
if (pathData.IsEmpty())
@@ -722,18 +722,18 @@ internal static Rect GetPathBounds(
}
else
{
- MilRectD bounds = PathGeometry.GetPathBoundsAsRB(
+ MilRectD bounds = GetPathBoundsAsRB(
pathData,
pen,
- worldMatrix,
- tolerance,
+ worldMatrix,
+ tolerance,
type,
skipHollows);
return bounds.AsRect;
}
}
-
+
///
/// Gets the bounds of this PathGeometry as an axis-aligned bounding box with pen and/or transform
///
@@ -771,9 +771,9 @@ internal static MilRectD GetPathBoundsAsRB(
Debug.Assert(pbPathData != (byte*)0);
- fixed (double *pDashArray = dashArray)
+ fixed (double* pDashArray = dashArray)
{
- int hr = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryBounds(
+ HRESULT result = UnsafeNativeMethods.MilCoreApi.MilUtility_PathGeometryBounds(
(pen == null) ? null : &penData,
pDashArray,
&worldMatrix3X2,
@@ -784,10 +784,9 @@ internal static MilRectD GetPathBoundsAsRB(
tolerance,
type == ToleranceType.Relative,
skipHollows,
- &bounds
- );
+ &bounds);
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we report that the geometry has empty bounds
@@ -797,7 +796,7 @@ internal static MilRectD GetPathBoundsAsRB(
}
else
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
@@ -827,11 +826,11 @@ internal static IntersectionDetail HitTestWithPathGeometry(
{
Debug.Assert(pbPathData1 != (byte*)0);
- fixed (byte *pbPathData2 = data2.SerializedData)
+ fixed (byte* pbPathData2 = data2.SerializedData)
{
Debug.Assert(pbPathData2 != (byte*)0);
- int hr = MilCoreApi.MilUtility_PathGeometryHitTestPathGeometry(
+ HRESULT result = MilCoreApi.MilUtility_PathGeometryHitTestPathGeometry(
&data1.Matrix,
data1.FillRule,
pbPathData1,
@@ -844,7 +843,7 @@ internal static IntersectionDetail HitTestWithPathGeometry(
type == ToleranceType.Relative,
&detail);
- if (hr == (int)MILErrors.WGXERR_BADNUMBER)
+ if (result == MilErrors.WGXERR_BADNUMBER)
{
// When we encounter NaNs in the renderer, we absorb the error and draw
// nothing. To be consistent, we report that the geometry is never hittable.
@@ -852,7 +851,7 @@ internal static IntersectionDetail HitTestWithPathGeometry(
}
else
{
- HRESULT.Check(hr);
+ result.ThrowOnFailureExtended();
}
}
}
@@ -952,10 +951,10 @@ internal override PathGeometryData GetPathGeometryData()
PathGeometryData data = new PathGeometryData();
data.FillRule = FillRule;
data.Matrix = CompositionResourceManager.TransformToMilMatrix3x2D(Transform);
-
+
if (IsObviouslyEmpty())
{
- return Geometry.GetEmptyPathGeometryData();
+ return GetEmptyPathGeometryData();
}
ByteStreamGeometryContext ctx = new ByteStreamGeometryContext();
@@ -989,7 +988,7 @@ private void ManualUpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
// Obtain handles for properties that implement DUCE.IResource
DUCE.ResourceHandle hTransform;
if (vTransform == null ||
- Object.ReferenceEquals(vTransform, Transform.Identity)
+ ReferenceEquals(vTransform, Transform.Identity)
)
{
hTransform = DUCE.ResourceHandle.Null;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs
index 3ad6804d24a..4fd453485ad 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -9,6 +9,7 @@
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
using System.Runtime.CompilerServices;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
{
@@ -192,7 +193,7 @@ internal PixelFormat(PixelFormatEnum format)
_flags = GetPixelFormatFlagsFromEnum(format);
_bitsPerPixel = GetBitsPerPixelFromEnum(format);
- _guidFormat = PixelFormat.GetGuidFromFormat(format);
+ _guidFormat = GetGuidFromFormat(format);
}
///
@@ -207,7 +208,7 @@ internal PixelFormat(string pixelFormatString)
ArgumentNullException.ThrowIfNull(pixelFormatString);
- string upperPixelFormatString = pixelFormatString.ToUpper(System.Globalization.CultureInfo.InvariantCulture);
+ string upperPixelFormatString = pixelFormatString.ToUpper(Globalization.CultureInfo.InvariantCulture);
switch (upperPixelFormatString)
{
@@ -328,7 +329,7 @@ internal PixelFormat(string pixelFormatString)
_flags = GetPixelFormatFlagsFromEnum(format);
_bitsPerPixel = GetBitsPerPixelFromEnum(format);
- _guidFormat = PixelFormat.GetGuidFromFormat(format);
+ _guidFormat = GetGuidFromFormat(format);
}
static private Guid GetGuidFromFormat(PixelFormatEnum format)
@@ -506,10 +507,9 @@ public IList Masks
try
{
- HRESULT.Check(UnsafeNativeMethods.WICPixelFormatInfo.GetChannelCount(
+ UnsafeNativeMethods.WICPixelFormatInfo.GetChannelCount(
pixelFormatInfo,
- out channelCount
- ));
+ out channelCount).ThrowOnFailureExtended();
Debug.Assert(channelCount >= 1);
@@ -519,8 +519,12 @@ out channelCount
{
for (uint i = 0; i < channelCount; i++)
{
- HRESULT.Check(UnsafeNativeMethods.WICPixelFormatInfo.GetChannelMask(
- pixelFormatInfo, i, 0, null, out cbBytes));
+ UnsafeNativeMethods.WICPixelFormatInfo.GetChannelMask(
+ pixelFormatInfo,
+ i,
+ 0,
+ null,
+ out cbBytes).ThrowOnFailureExtended();
Debug.Assert(cbBytes > 0);
@@ -528,8 +532,12 @@ out channelCount
fixed (byte *pbChannelMask = channelMask)
{
- HRESULT.Check(UnsafeNativeMethods.WICPixelFormatInfo.GetChannelMask(
- pixelFormatInfo, i, cbBytes, pbChannelMask, out cbBytes));
+ UnsafeNativeMethods.WICPixelFormatInfo.GetChannelMask(
+ pixelFormatInfo,
+ i,
+ cbBytes,
+ pbChannelMask,
+ out cbBytes).ThrowOnFailureExtended();
Debug.Assert(cbBytes == channelMask.Length);
}
@@ -559,24 +567,26 @@ internal IntPtr CreatePixelFormatInfo()
{
try
{
- Guid guidPixelFormat = this.Guid;
+ Guid guidPixelFormat = Guid;
- int hr = UnsafeNativeMethods.WICImagingFactory.CreateComponentInfo(
+ HRESULT result = UnsafeNativeMethods.WICImagingFactory.CreateComponentInfo(
myFactory.ImagingFactoryPtr,
ref guidPixelFormat,
out componentInfo);
- if (hr == (int)WinCodecErrors.WINCODEC_ERR_COMPONENTINITIALIZEFAILURE ||
- hr == (int)WinCodecErrors.WINCODEC_ERR_COMPONENTNOTFOUND)
+
+ if (result == HRESULT.WINCODEC_ERR_COMPONENTINITIALIZEFAILURE
+ || result == HRESULT.WINCODEC_ERR_COMPONENTNOTFOUND)
{
- throw new System.NotSupportedException(SR.Image_NoPixelFormatFound);
+ throw new NotSupportedException(SR.Image_NoPixelFormatFound);
}
- HRESULT.Check(hr);
+
+ result.ThrowOnFailureExtended();
Guid guidPixelFormatInfo = MILGuidData.IID_IWICPixelFormatInfo;
- HRESULT.Check(UnsafeNativeMethods.MILUnknown.QueryInterface(
+ UnsafeNativeMethods.MILUnknown.QueryInterface(
componentInfo,
ref guidPixelFormatInfo,
- out pixelFormatInfo));
+ out pixelFormatInfo).ThrowOnFailureExtended();
}
finally
{
@@ -603,10 +613,9 @@ internal int InternalBitsPerPixel
try
{
- HRESULT.Check(UnsafeNativeMethods.WICPixelFormatInfo.GetBitsPerPixel(
+ UnsafeNativeMethods.WICPixelFormatInfo.GetBitsPerPixel(
pixelFormatInfo,
- out bpp
- ));
+ out bpp).ThrowOnFailureExtended();
}
finally
{
@@ -619,7 +628,7 @@ out bpp
_bitsPerPixel = bpp;
}
- return (int) _bitsPerPixel;
+ return (int)_bitsPerPixel;
}
}
@@ -672,7 +681,7 @@ internal static PixelFormat GetPixelFormat (
{
Guid guidPixelFormat = WICPixelFormatGUIDs.WICPixelFormatDontCare;
- HRESULT.Check(UnsafeNativeMethods.WICBitmapSource.GetPixelFormat(bitmapSource, out guidPixelFormat));
+ UnsafeNativeMethods.WICBitmapSource.GetPixelFormat(bitmapSource, out guidPixelFormat).ThrowOnFailureExtended();
return new PixelFormat(guidPixelFormat);
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/SafeNativeMethodsMilCoreApi.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/SafeNativeMethodsMilCoreApi.cs
index 0f59f1135c5..db6cfa565fd 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/SafeNativeMethodsMilCoreApi.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/SafeNativeMethodsMilCoreApi.cs
@@ -1,48 +1,21 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
-
-//
-// ABOUT THIS FILE:
-// -- This file contains native methods which are deemed SAFE for partial trust callers
-// -- These methods DO have the SuppressUnmanagedCodeSecurity attribute which means
-// stalk walks for unmanaged
-// code will stop with the immediate caler.
-// -- Put methods in here which are needed in partial trust scenarios
-// -- If you have questions about how to use this file, email avsee
+using Windows.Win32.Foundation;
namespace MS.Win32.PresentationCore
{
internal static partial class SafeNativeMethods
{
- internal static int MilCompositionEngine_InitializePartitionManager(int nPriority)
- {
- return SafeNativeMethodsPrivate.MilCompositionEngine_InitializePartitionManager(nPriority);
- }
-
- internal static int MilCompositionEngine_DeinitializePartitionManager()
- {
- return SafeNativeMethodsPrivate.MilCompositionEngine_DeinitializePartitionManager();
- }
-
- internal static long GetNextPerfElementId()
- {
- return SafeNativeMethodsPrivate.GetNextPerfElementId();
- }
-
- private static partial class SafeNativeMethodsPrivate
- {
- [DllImport(DllImport.MilCore)]
- internal static extern int MilCompositionEngine_InitializePartitionManager(int nPriority);
+ [DllImport(DllImport.MilCore)]
+ internal static extern HRESULT MilCompositionEngine_InitializePartitionManager(int nPriority);
- [DllImport(DllImport.MilCore)]
- internal static extern int MilCompositionEngine_DeinitializePartitionManager();
+ [DllImport(DllImport.MilCore)]
+ internal static extern HRESULT MilCompositionEngine_DeinitializePartitionManager();
- [DllImport(DllImport.MilCore)]
- internal static extern long GetNextPerfElementId();
- }
+ [DllImport(DllImport.MilCore)]
+ internal static extern long GetNextPerfElementId();
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/SafeReversePInvokeHandle.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/SafeReversePInvokeHandle.cs
index 056de9ec34c..28111cf818d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/SafeReversePInvokeHandle.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/SafeReversePInvokeHandle.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -12,6 +12,7 @@
using Microsoft.Win32.SafeHandles;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
{
@@ -30,11 +31,13 @@ internal SafeReversePInvokeWrapper() : base(true)
/// Use this constructor if the handle exists at construction time.
/// SafeMILHandle owns the release of the parameter.
///
- internal SafeReversePInvokeWrapper(IntPtr delegatePtr) : base(true)
+ internal SafeReversePInvokeWrapper(IntPtr delegatePtr) : base(true)
{
// Wrap the reverse p-invoke into a reversePInvokeWrapper.
IntPtr reversePInvokeWrapper;
- HRESULT.Check(UnsafeNativeMethods.MilCoreApi.MilCreateReversePInvokeWrapper(delegatePtr, out reversePInvokeWrapper));
+ UnsafeNativeMethods.MilCoreApi.MilCreateReversePInvokeWrapper(
+ delegatePtr,
+ out reversePInvokeWrapper).ThrowOnFailureExtended();
SetHandle(reversePInvokeWrapper);
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/StreamAsIStream.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/StreamAsIStream.cs
index 62fd460f39d..d62b155dd53 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/StreamAsIStream.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/StreamAsIStream.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,7 +7,7 @@
using MS.Internal;
using MS.Win32;
using System.Runtime.InteropServices;
-
+using Windows.Win32.Foundation;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
namespace System.Windows.Media
@@ -70,24 +70,24 @@ internal static class StaticPtrs
{
static StaticPtrs()
{
- StaticPtrs.pfnDispose = new StreamDescriptor.Dispose(StreamDescriptor.StaticDispose);
+ pfnDispose = new StreamDescriptor.Dispose(StreamDescriptor.StaticDispose);
- StaticPtrs.pfnClone = new StreamDescriptor.Clone(StreamAsIStream.Clone);
- StaticPtrs.pfnCommit = new StreamDescriptor.Commit(StreamAsIStream.Commit);
- StaticPtrs.pfnCopyTo = new StreamDescriptor.CopyTo(StreamAsIStream.CopyTo);
- StaticPtrs.pfnLockRegion = new StreamDescriptor.LockRegion(StreamAsIStream.LockRegion);
- StaticPtrs.pfnRead = new StreamDescriptor.Read(StreamAsIStream.Read);
- StaticPtrs.pfnRevert = new StreamDescriptor.Revert(StreamAsIStream.Revert);
+ pfnClone = new StreamDescriptor.Clone(StreamAsIStream.Clone);
+ pfnCommit = new StreamDescriptor.Commit(StreamAsIStream.Commit);
+ pfnCopyTo = new StreamDescriptor.CopyTo(StreamAsIStream.CopyTo);
+ pfnLockRegion = new StreamDescriptor.LockRegion(StreamAsIStream.LockRegion);
+ pfnRead = new StreamDescriptor.Read(StreamAsIStream.Read);
+ pfnRevert = new StreamDescriptor.Revert(StreamAsIStream.Revert);
unsafe
{
- StaticPtrs.pfnSeek = new StreamDescriptor.Seek(StreamAsIStream.Seek);
+ pfnSeek = new StreamDescriptor.Seek(StreamAsIStream.Seek);
}
- StaticPtrs.pfnSetSize = new StreamDescriptor.SetSize(StreamAsIStream.SetSize);
- StaticPtrs.pfnStat = new StreamDescriptor.Stat(StreamAsIStream.Stat);
- StaticPtrs.pfnUnlockRegion = new StreamDescriptor.UnlockRegion(StreamAsIStream.UnlockRegion);
- StaticPtrs.pfnWrite = new StreamDescriptor.Write(StreamAsIStream.Write);
- StaticPtrs.pfnCanWrite = new StreamDescriptor.CanWrite(StreamAsIStream.CanWrite);
- StaticPtrs.pfnCanSeek = new StreamDescriptor.CanSeek(StreamAsIStream.CanSeek);
+ pfnSetSize = new StreamDescriptor.SetSize(StreamAsIStream.SetSize);
+ pfnStat = new StreamDescriptor.Stat(StreamAsIStream.Stat);
+ pfnUnlockRegion = new StreamDescriptor.UnlockRegion(StreamAsIStream.UnlockRegion);
+ pfnWrite = new StreamDescriptor.Write(StreamAsIStream.Write);
+ pfnCanWrite = new StreamDescriptor.CanWrite(StreamAsIStream.CanWrite);
+ pfnCanSeek = new StreamDescriptor.CanSeek(StreamAsIStream.CanSeek);
}
internal static StreamDescriptor.Dispose pfnDispose;
@@ -153,12 +153,10 @@ private void ActualizeVirtualPosition()
#endregion
#region StreamFunctions
- public int Clone(out IntPtr stream)
+ public HRESULT Clone(out IntPtr stream)
{
stream = IntPtr.Zero;
- #pragma warning disable 6500
-
try
{
Verify();
@@ -170,15 +168,11 @@ public int Clone(out IntPtr stream)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
public int Commit(uint grfCommitFlags)
{
- #pragma warning disable 6500
-
try
{
Verify();
@@ -193,14 +187,12 @@ public int Commit(uint grfCommitFlags)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
public int CopyTo(IntPtr /* IStream */ pstm, long cb, out long cbRead, out long cbWritten)
{
- int hr = NativeMethods.S_OK;
+ HRESULT result = HRESULT.S_OK;
uint bufsize = 4096; // one page
@@ -209,8 +201,6 @@ public int CopyTo(IntPtr /* IStream */ pstm, long cb, out long cbRead, out long
cbWritten = 0;
cbRead = 0;
- #pragma warning disable 6500
-
try
{
Verify();
@@ -226,7 +216,7 @@ public int CopyTo(IntPtr /* IStream */ pstm, long cb, out long cbRead, out long
uint read = 0;
- hr = Read(buffer.AsSpan(0, (int) toRead), out read);
+ result = Read(buffer.AsSpan(0, (int) toRead), out read);
if (read == 0)
{
@@ -235,13 +225,11 @@ public int CopyTo(IntPtr /* IStream */ pstm, long cb, out long cbRead, out long
cbRead += read;
- uint written = 0;
-
- hr = MILIStreamWrite(pstm, buffer, read, out written);
+ result = MILIStreamWrite(pstm, buffer, read, out uint written);
if (written != read)
{
- return hr;
+ return result;
}
cbWritten += read;
@@ -254,15 +242,11 @@ public int CopyTo(IntPtr /* IStream */ pstm, long cb, out long cbRead, out long
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return hr;
+ return result;
}
public int LockRegion(long libOffset, long cb, uint dwLockType)
{
- #pragma warning disable 6500
-
try
{
Verify();
@@ -274,23 +258,19 @@ public int LockRegion(long libOffset, long cb, uint dwLockType)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
- public int Read(Span buffer, out uint cbRead)
+ public HRESULT Read(Span buffer, out uint cbRead)
{
cbRead = 0;
- #pragma warning disable 6500
-
try
{
Verify();
ActualizeVirtualPosition();
- cbRead = (uint) dataStream.Read(buffer);
+ cbRead = (uint)dataStream.Read(buffer);
}
catch (Exception e)
{
@@ -299,15 +279,11 @@ public int Read(Span buffer, out uint cbRead)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
- public int Revert()
+ public HRESULT Revert()
{
- #pragma warning disable 6500
-
try
{
Verify();
@@ -319,15 +295,11 @@ public int Revert()
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
- public unsafe int Seek(long offset, uint origin, long * plibNewPostion)
+ public unsafe HRESULT Seek(long offset, uint origin, long * plibNewPostion)
{
- #pragma warning disable 6500
-
try
{
Verify();
@@ -395,19 +367,14 @@ public unsafe int Seek(long offset, uint origin, long * plibNewPostion)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
- public int SetSize(long value)
+ public HRESULT SetSize(long value)
{
- #pragma warning disable 6500
-
try
{
Verify();
-
dataStream.SetLength(value);
}
catch (Exception e)
@@ -417,18 +384,14 @@ public int SetSize(long value)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
- public int Stat(out System.Runtime.InteropServices.ComTypes.STATSTG statstg, uint grfStatFlag)
+ public HRESULT Stat(out System.Runtime.InteropServices.ComTypes.STATSTG statstg, uint grfStatFlag)
{
System.Runtime.InteropServices.ComTypes.STATSTG statstgOut = new System.Runtime.InteropServices.ComTypes.STATSTG();
statstg = statstgOut;
- #pragma warning disable 6500
-
try
{
Verify();
@@ -446,15 +409,11 @@ public int Stat(out System.Runtime.InteropServices.ComTypes.STATSTG statstg, uin
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
- public int UnlockRegion(long libOffset, long cb, uint dwLockType)
+ public HRESULT UnlockRegion(long libOffset, long cb, uint dwLockType)
{
- #pragma warning disable 6500
-
try
{
Verify();
@@ -466,24 +425,20 @@ public int UnlockRegion(long libOffset, long cb, uint dwLockType)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
public int Write(byte[] buffer, uint cb, out uint cbWritten)
{
cbWritten = 0;
- #pragma warning disable 6500
-
try
{
Verify();
ActualizeVirtualPosition();
- dataStream.Write(buffer, 0, (int) cb);
+ dataStream.Write(buffer, 0, (int)cb);
cbWritten = cb;
}
@@ -494,21 +449,16 @@ public int Write(byte[] buffer, uint cb, out uint cbWritten)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
public int CanWrite(out bool canWrite)
{
canWrite = false;
- #pragma warning disable 6500
-
try
{
Verify();
-
canWrite = dataStream.CanWrite;
}
catch (Exception e)
@@ -518,21 +468,16 @@ public int CanWrite(out bool canWrite)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
public int CanSeek(out bool canSeek)
{
canSeek = false;
- #pragma warning disable 6500
-
try
{
Verify();
-
canSeek = dataStream.CanSeek;
}
catch (Exception e)
@@ -542,16 +487,14 @@ public int CanSeek(out bool canSeek)
return SecurityHelper.GetHRForException(e);
}
- #pragma warning restore 6500
-
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
#endregion
#region Verify
private void Verify()
{
- if (this.dataStream == null)
+ if (dataStream == null)
{
throw new System.ObjectDisposedException(SR.Media_StreamClosed);
}
@@ -568,68 +511,68 @@ internal static StreamAsIStream FromSD(ref StreamDescriptor sd)
internal static int Clone(ref StreamDescriptor pSD, out IntPtr stream)
{
- return (StreamAsIStream.FromSD(ref pSD)).Clone(out stream);
+ return (FromSD(ref pSD)).Clone(out stream);
}
internal static int Commit(ref StreamDescriptor pSD, UInt32 grfCommitFlags)
{
- return (StreamAsIStream.FromSD(ref pSD)).Commit(grfCommitFlags);
+ return (FromSD(ref pSD)).Commit(grfCommitFlags);
}
internal static int CopyTo(ref StreamDescriptor pSD, IntPtr pstm, long cb, out long cbRead, out long cbWritten)
{
- return (StreamAsIStream.FromSD(ref pSD)).CopyTo(pstm, cb, out cbRead, out cbWritten);
+ return (FromSD(ref pSD)).CopyTo(pstm, cb, out cbRead, out cbWritten);
}
internal static int LockRegion(ref StreamDescriptor pSD, long libOffset, long cb, uint dwLockType)
{
- return (StreamAsIStream.FromSD(ref pSD)).LockRegion(libOffset, cb, dwLockType);
+ return (FromSD(ref pSD)).LockRegion(libOffset, cb, dwLockType);
}
internal static unsafe int Read(ref StreamDescriptor pSD, IntPtr buffer, uint cb, out uint cbRead)
{
var span = new Span(buffer.ToPointer(), (int) cb);
- return (StreamAsIStream.FromSD(ref pSD)).Read(span, out cbRead);
+ return (FromSD(ref pSD)).Read(span, out cbRead);
}
internal static int Revert(ref StreamDescriptor pSD)
{
- return (StreamAsIStream.FromSD(ref pSD)).Revert();
+ return (FromSD(ref pSD)).Revert();
}
internal unsafe static int Seek(ref StreamDescriptor pSD, long offset, uint origin, long* plibNewPostion)
{
- return (StreamAsIStream.FromSD(ref pSD)).Seek(offset, origin, plibNewPostion);
+ return (FromSD(ref pSD)).Seek(offset, origin, plibNewPostion);
}
internal static int SetSize(ref StreamDescriptor pSD, long value)
{
- return (StreamAsIStream.FromSD(ref pSD)).SetSize(value);
+ return (FromSD(ref pSD)).SetSize(value);
}
internal static int Stat(ref StreamDescriptor pSD, out System.Runtime.InteropServices.ComTypes.STATSTG statstg, uint grfStatFlag)
{
- return (StreamAsIStream.FromSD(ref pSD)).Stat(out statstg, grfStatFlag);
+ return (FromSD(ref pSD)).Stat(out statstg, grfStatFlag);
}
internal static int UnlockRegion(ref StreamDescriptor pSD, long libOffset, long cb, uint dwLockType)
{
- return (StreamAsIStream.FromSD(ref pSD)).UnlockRegion(libOffset, cb, dwLockType);
+ return (FromSD(ref pSD)).UnlockRegion(libOffset, cb, dwLockType);
}
internal static int Write(ref StreamDescriptor pSD, byte[] buffer, uint cb, out uint cbWritten)
{
- return (StreamAsIStream.FromSD(ref pSD)).Write(buffer, cb, out cbWritten);
+ return (FromSD(ref pSD)).Write(buffer, cb, out cbWritten);
}
internal static int CanWrite(ref StreamDescriptor pSD, out bool canWrite)
{
- return (StreamAsIStream.FromSD(ref pSD)).CanWrite(out canWrite);
+ return (FromSD(ref pSD)).CanWrite(out canWrite);
}
internal static int CanSeek(ref StreamDescriptor pSD, out bool canSeek)
{
- return (StreamAsIStream.FromSD(ref pSD)).CanSeek(out canSeek);
+ return FromSD(ref pSD).CanSeek(out canSeek);
}
#endregion
@@ -641,12 +584,12 @@ internal static IntPtr IStreamMemoryFrom(IntPtr comStream)
using (FactoryMaker myFactory = new FactoryMaker())
{
- if (HRESULT.Failed(UnsafeNativeMethods.WICImagingFactory.CreateStream(myFactory.ImagingFactoryPtr, out pIStream)))
+ if (UnsafeNativeMethods.WICImagingFactory.CreateStream(myFactory.ImagingFactoryPtr, out pIStream).Failed)
{
return IntPtr.Zero;
}
- if (HRESULT.Failed(UnsafeNativeMethods.WICStream.InitializeFromIStream(pIStream, comStream)))
+ if (UnsafeNativeMethods.WICStream.InitializeFromIStream(pIStream, comStream).Failed)
{
UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref pIStream);
@@ -663,12 +606,12 @@ internal static IntPtr IStreamFrom(IntPtr memoryBuffer, int bufferSize)
using (FactoryMaker myFactory = new FactoryMaker())
{
- if (HRESULT.Failed(UnsafeNativeMethods.WICImagingFactory.CreateStream(myFactory.ImagingFactoryPtr, out pIStream)))
+ if (UnsafeNativeMethods.WICImagingFactory.CreateStream(myFactory.ImagingFactoryPtr, out pIStream).Failed)
{
return IntPtr.Zero;
}
- if (HRESULT.Failed(UnsafeNativeMethods.WICStream.InitializeFromMemory(pIStream, memoryBuffer, (uint) bufferSize)))
+ if (UnsafeNativeMethods.WICStream.InitializeFromMemory(pIStream, memoryBuffer, (uint)bufferSize).Failed)
{
UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref pIStream);
@@ -708,16 +651,20 @@ internal static IntPtr IStreamFrom(System.IO.Stream stream)
sd.pfnCanWrite = StaticPtrs.pfnCanWrite;
sd.pfnCanSeek = StaticPtrs.pfnCanSeek;
- sd.m_handle = System.Runtime.InteropServices.GCHandle.Alloc(sais, System.Runtime.InteropServices.GCHandleType.Normal);
+ sd.m_handle = GCHandle.Alloc(sais, GCHandleType.Normal);
- HRESULT.Check(UnsafeNativeMethods.MilCoreApi.MILCreateStreamFromStreamDescriptor(ref sd, out pStream));
+ UnsafeNativeMethods.MilCoreApi.MILCreateStreamFromStreamDescriptor(ref sd, out pStream).ThrowOnFailureExtended();
return pStream;
}
#endregion
- [DllImport(DllImport.MilCore)]//CASRemoval:
- private extern static int /* HRESULT */ MILIStreamWrite(IntPtr pStream, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)]byte[] buffer, uint cb, out uint cbWritten);
+ [DllImport(DllImport.MilCore)]
+ private static extern HRESULT MILIStreamWrite(
+ IntPtr pStream,
+ [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] buffer,
+ uint cb,
+ out uint cbWritten);
}
#endregion
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/UnsafeNativeMethodsMilCoreApi.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/UnsafeNativeMethodsMilCoreApi.cs
index 40962845841..465573f06d7 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/UnsafeNativeMethodsMilCoreApi.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/UnsafeNativeMethodsMilCoreApi.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -17,6 +17,8 @@
using System.Windows.Media.Imaging;
using System.Windows;
+using HRESULT = Windows.Win32.Foundation.HRESULT;
+
#pragma warning disable 1634, 1691 // suppressing PreSharp warnings
namespace MS.Win32.PresentationCore
@@ -38,26 +40,26 @@ internal static class MilCoreApi
internal static extern void ExitMediaSystemLock();
[DllImport(DllImport.MilCore)]
- internal static extern int MilVersionCheck(
+ internal static extern HRESULT MilVersionCheck(
uint uiCallerMilSdkVersion
);
-
+
[DllImport(DllImport.MilCore)]
internal static extern bool WgxConnection_ShouldForceSoftwareForGraphicsStreamClient();
[DllImport(DllImport.MilCore)]
- internal static extern int WgxConnection_Create(
- bool requestSynchronousTransport,
- out IntPtr ppConnection);
+ internal static extern HRESULT WgxConnection_Create(
+ bool requestSynchronousTransport,
+ out IntPtr ppConnection);
[DllImport(DllImport.MilCore)]
- internal static extern int WgxConnection_Disconnect(IntPtr pTranspManager);
+ internal static extern HRESULT WgxConnection_Disconnect(IntPtr pTranspManager);
[DllImport(DllImport.MilCore)]
- internal extern static int /* HRESULT */ MILCreateStreamFromStreamDescriptor(ref System.Windows.Media.StreamDescriptor pSD, out IntPtr ppStream);
+ internal static extern HRESULT MILCreateStreamFromStreamDescriptor(ref System.Windows.Media.StreamDescriptor pSD, out IntPtr ppStream);
[DllImport(DllImport.MilCore)]
- unsafe internal static extern void MilUtility_GetTileBrushMapping(
+ internal static extern unsafe void MilUtility_GetTileBrushMapping(
D3DMATRIX* transform,
D3DMATRIX* relativeTransform,
Stretch stretch,
@@ -74,9 +76,9 @@ out int brushIsEmpty
);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_PathGeometryBounds(
- MIL_PEN_DATA *pPenData,
- double *pDashArray,
+ internal static extern unsafe HRESULT MilUtility_PathGeometryBounds(
+ MIL_PEN_DATA* pPenData,
+ double* pDashArray,
MilMatrix3x2D* pWorldMatrix,
FillRule fillRule,
byte* pPathData,
@@ -88,7 +90,7 @@ internal unsafe static extern int MilUtility_PathGeometryBounds(
MilRectD* pBounds);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_PathGeometryCombine(
+ internal static extern unsafe HRESULT MilUtility_PathGeometryCombine(
MilMatrix3x2D* pMatrix,
MilMatrix3x2D* pMatrix1,
FillRule fillRule1,
@@ -105,9 +107,9 @@ internal unsafe static extern int MilUtility_PathGeometryCombine(
out FillRule resultFillRule);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_PathGeometryWiden(
- MIL_PEN_DATA *pPenData,
- double *pDashArray,
+ internal static extern unsafe HRESULT MilUtility_PathGeometryWiden(
+ MIL_PEN_DATA* pPenData,
+ double* pDashArray,
MilMatrix3x2D* pMatrix,
FillRule fillRule,
byte* pPathData,
@@ -118,7 +120,7 @@ internal unsafe static extern int MilUtility_PathGeometryWiden(
out FillRule widenedFillRule);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_PathGeometryOutline(
+ internal static extern unsafe HRESULT MilUtility_PathGeometryOutline(
MilMatrix3x2D* pMatrix,
FillRule fillRule,
byte* pPathData,
@@ -129,7 +131,7 @@ internal unsafe static extern int MilUtility_PathGeometryOutline(
out FillRule outlinedFillRule);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilUtility_PathGeometryFlatten(
+ internal static extern unsafe HRESULT MilUtility_PathGeometryFlatten(
MilMatrix3x2D* pMatrix,
FillRule fillRule,
byte* pPathData,
@@ -140,7 +142,7 @@ internal unsafe static extern int MilUtility_PathGeometryFlatten(
out FillRule resultFillRule);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilGlyphCache_BeginCommandAtRenderTime(
+ internal static extern unsafe HRESULT MilGlyphCache_BeginCommandAtRenderTime(
IntPtr pMilSlaveGlyphCacheTarget,
byte* pbData,
uint cbSize,
@@ -148,29 +150,29 @@ uint cbExtra
);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilGlyphCache_AppendCommandDataAtRenderTime(
+ internal static extern unsafe HRESULT MilGlyphCache_AppendCommandDataAtRenderTime(
IntPtr pMilSlaveGlyphCacheTarget,
byte* pbData,
uint cbSize
);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilGlyphCache_EndCommandAtRenderTime(
+ internal static extern unsafe HRESULT MilGlyphCache_EndCommandAtRenderTime(
IntPtr pMilSlaveGlyphCacheTarget
);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilGlyphRun_SetGeometryAtRenderTime(
+ internal static extern unsafe HRESULT MilGlyphRun_SetGeometryAtRenderTime(
IntPtr pMilGlyphRunTarget,
byte* pCmd,
uint cbCmd
);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilGlyphRun_GetGlyphOutline(
+ internal static extern unsafe HRESULT MilGlyphRun_GetGlyphOutline(
IntPtr pFontFace,
- ushort glyphIndex,
- bool sideways,
+ ushort glyphIndex,
+ bool sideways,
double renderingEmSize,
out byte* pPathGeometryData,
out UInt32 pSize,
@@ -178,31 +180,31 @@ out FillRule pFillRule
);
[DllImport(DllImport.MilCore)]
- internal unsafe static extern int MilGlyphRun_ReleasePathGeometryData(
+ internal static extern unsafe HRESULT MilGlyphRun_ReleasePathGeometryData(
byte* pPathGeometryData
);
[DllImport(DllImport.MilCore, EntryPoint = "MilCreateReversePInvokeWrapper")]
- internal unsafe static extern /*HRESULT*/ int MilCreateReversePInvokeWrapper(
- IntPtr pFcn,
+ internal static extern unsafe HRESULT MilCreateReversePInvokeWrapper(
+ IntPtr pFcn,
out IntPtr reversePInvokeWrapper);
[DllImport(DllImport.MilCore, EntryPoint = "MilReleasePInvokePtrBlocking")]
- internal unsafe static extern void MilReleasePInvokePtrBlocking(
+ internal static extern unsafe void MilReleasePInvokePtrBlocking(
IntPtr reversePInvokeWrapper);
[DllImport(DllImport.MilCore, EntryPoint = "RenderOptions_ForceSoftwareRenderingModeForProcess")]
- internal unsafe static extern void RenderOptions_ForceSoftwareRenderingModeForProcess(
+ internal static extern unsafe void RenderOptions_ForceSoftwareRenderingModeForProcess(
bool fForce);
[DllImport(DllImport.MilCore, EntryPoint = "RenderOptions_IsSoftwareRenderingForcedForProcess")]
- internal unsafe static extern bool RenderOptions_IsSoftwareRenderingForcedForProcess();
+ internal static extern unsafe bool RenderOptions_IsSoftwareRenderingForcedForProcess();
[DllImport(DllImport.MilCore, EntryPoint = "RenderOptions_EnableHardwareAccelerationInRdp")]
- internal unsafe static extern void RenderOptions_EnableHardwareAccelerationInRdp(bool value);
+ internal static extern unsafe void RenderOptions_EnableHardwareAccelerationInRdp(bool value);
[DllImport(DllImport.MilCore, EntryPoint = "MilResource_CreateCWICWrapperBitmap")]
- internal unsafe static extern int /* HRESULT */ CreateCWICWrapperBitmap(
+ internal static extern unsafe HRESULT CreateCWICWrapperBitmap(
BitmapSourceSafeMILHandle /* IWICBitmapSource */ pIWICBitmapSource,
out BitmapSourceSafeMILHandle /* CWICWrapperBitmap as IWICBitmapSource */ pCWICWrapperBitmap);
}
@@ -210,33 +212,33 @@ internal unsafe static extern void RenderOptions_ForceSoftwareRenderingModeForPr
internal static class WICComponentInfo
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetCLSID_Proxy")]
- internal static extern int /* HRESULT */ GetCLSID(
+ internal static extern HRESULT GetCLSID(
System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR,
out Guid pclsid);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetAuthor_Proxy")]
- internal static extern int /* HRESULT */ GetAuthor(
+ internal static extern HRESULT GetAuthor(
System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR,
UInt32 cchAuthor,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAuthor,
out UInt32 pcchActual);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetVersion_Proxy")]
- internal static extern int /* HRESULT */ GetVersion(
+ internal static extern HRESULT GetVersion(
System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR,
UInt32 cchVersion,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzVersion,
out UInt32 pcchActual);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetSpecVersion_Proxy")]
- internal static extern int /* HRESULT */ GetSpecVersion(
+ internal static extern HRESULT GetSpecVersion(
System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR,
UInt32 cchSpecVersion,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzSpecVersion,
out UInt32 pcchActual);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetFriendlyName_Proxy")]
- internal static extern int /* HRESULT */ GetFriendlyName(
+ internal static extern HRESULT GetFriendlyName(
System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR,
UInt32 cchFriendlyName,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFriendlyName,
@@ -246,12 +248,12 @@ internal static class WICComponentInfo
internal static class WICBitmapCodecInfo
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetContainerFormat_Proxy")]
- internal static extern int /* HRESULT */ GetContainerFormat(
+ internal static extern HRESULT GetContainerFormat(
System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR,
out Guid pguidContainerFormat);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetDeviceManufacturer_Proxy")]
- internal static extern int /* HRESULT */ GetDeviceManufacturer(
+ internal static extern HRESULT GetDeviceManufacturer(
System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR,
UInt32 cchDeviceManufacturer,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceManufacturer,
@@ -259,7 +261,7 @@ out UInt32 pcchActual
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetDeviceModels_Proxy")]
- internal static extern int /* HRESULT */ GetDeviceModels(
+ internal static extern HRESULT GetDeviceModels(
System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR,
UInt32 cchDeviceModels,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceModels,
@@ -267,7 +269,7 @@ out UInt32 pcchActual
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetMimeTypes_Proxy")]
- internal static extern int /* HRESULT */ GetMimeTypes(
+ internal static extern HRESULT GetMimeTypes(
System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR,
UInt32 cchMimeTypes,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzMimeTypes,
@@ -275,7 +277,7 @@ out UInt32 pcchActual
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetFileExtensions_Proxy")]
- internal static extern int /* HRESULT */ GetFileExtensions(
+ internal static extern HRESULT GetFileExtensions(
System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR,
UInt32 cchFileExtensions,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFileExtensions,
@@ -283,33 +285,33 @@ out UInt32 pcchActual
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_DoesSupportAnimation_Proxy")]
- internal static extern int /* HRESULT */ DoesSupportAnimation(
+ internal static extern HRESULT DoesSupportAnimation(
System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR,
out bool pfSupportAnimation
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_DoesSupportLossless_Proxy")]
- internal static extern int /* HRESULT */ DoesSupportLossless(
+ internal static extern HRESULT DoesSupportLossless(
System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR,
out bool pfSupportLossless
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_DoesSupportMultiframe_Proxy")]
- internal static extern int /* HRESULT */ DoesSupportMultiframe(
+ internal static extern HRESULT DoesSupportMultiframe(
System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR,
out bool pfSupportMultiframe
);
-}
+ }
internal static class WICMetadataQueryReader
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetContainerFormat_Proxy")]
- internal static extern int /* HRESULT */ GetContainerFormat(
+ internal static extern HRESULT GetContainerFormat(
System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR,
out Guid pguidContainerFormat);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetLocation_Proxy")]
- internal static extern int /* HRESULT */ GetLocation(
+ internal static extern HRESULT GetLocation(
System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR,
UInt32 cchLocation,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzNamespace,
@@ -317,21 +319,21 @@ out UInt32 pcchActual
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetMetadataByName_Proxy")]
- internal static extern int /* HRESULT */ GetMetadataByName(
+ internal static extern HRESULT GetMetadataByName(
System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR,
[MarshalAs(UnmanagedType.LPWStr)] String wzName,
ref System.Windows.Media.Imaging.PROPVARIANT propValue
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetMetadataByName_Proxy")]
- internal static extern int /* HRESULT */ ContainsMetadataByName(
+ internal static extern HRESULT ContainsMetadataByName(
System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR,
[MarshalAs(UnmanagedType.LPWStr)] String wzName,
IntPtr propVar
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetEnumerator_Proxy")]
- internal static extern int /* HRESULT */ GetEnumerator(
+ internal static extern HRESULT GetEnumerator(
System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR,
out System.Windows.Media.SafeMILHandle /* IEnumString */ enumString
);
@@ -340,14 +342,14 @@ out System.Windows.Media.SafeMILHandle /* IEnumString */ enumString
internal static class WICMetadataQueryWriter
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryWriter_SetMetadataByName_Proxy")]
- internal static extern int /* HRESULT */ SetMetadataByName(
+ internal static extern HRESULT SetMetadataByName(
System.Windows.Media.SafeMILHandle /* IWICMetadataQueryWriter */ THIS_PTR,
[MarshalAs(UnmanagedType.LPWStr)] String wzName,
ref System.Windows.Media.Imaging.PROPVARIANT propValue
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryWriter_RemoveMetadataByName_Proxy")]
- internal static extern int /* HRESULT */ RemoveMetadataByName(
+ internal static extern HRESULT RemoveMetadataByName(
System.Windows.Media.SafeMILHandle /* IWICMetadataQueryWriter */ THIS_PTR,
[MarshalAs(UnmanagedType.LPWStr)] String wzName
);
@@ -356,12 +358,12 @@ ref System.Windows.Media.Imaging.PROPVARIANT propValue
internal static class WICFastMetadataEncoder
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFastMetadataEncoder_Commit_Proxy")]
- internal static extern int /* HRESULT */ Commit(
+ internal static extern HRESULT Commit(
System.Windows.Media.SafeMILHandle /* IWICFastMetadataEncoder */ THIS_PTR
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFastMetadataEncoder_GetMetadataQueryWriter_Proxy")]
- internal static extern int /* HRESULT */ GetMetadataQueryWriter(
+ internal static extern HRESULT GetMetadataQueryWriter(
System.Windows.Media.SafeMILHandle /* IWICFastMetadataEncoder */ THIS_PTR,
out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter
);
@@ -370,7 +372,7 @@ out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter
internal static class EnumString
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IEnumString_Next_WIC_Proxy")]
- internal static extern int /* HRESULT */ Next(
+ internal static extern HRESULT Next(
System.Windows.Media.SafeMILHandle /* IEnumString */ THIS_PTR,
Int32 celt,
ref IntPtr rgElt,
@@ -378,7 +380,7 @@ ref Int32 pceltFetched
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IEnumString_Reset_WIC_Proxy")]
- internal static extern int /* HRESULT */ Reset(
+ internal static extern HRESULT Reset(
System.Windows.Media.SafeMILHandle /* IEnumString */ THIS_PTR
);
}
@@ -386,7 +388,7 @@ ref Int32 pceltFetched
internal static class IPropertyBag2
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IPropertyBag2_Write_Proxy")]
- internal static extern int /* HRESULT */ Write(
+ internal static extern HRESULT Write(
System.Windows.Media.SafeMILHandle /* IPropertyBag2 */ THIS_PTR,
UInt32 cProperties,
ref System.Windows.Media.Imaging.PROPBAG2 propBag,
@@ -397,29 +399,29 @@ ref System.Windows.Media.Imaging.PROPVARIANT propValue
internal static class WICBitmapSource
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetSize_Proxy")]
- internal static extern int /* HRESULT */ GetSize(
+ internal static extern HRESULT GetSize(
System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR,
out UInt32 puiWidth,
out UInt32 puiHeight);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetPixelFormat_Proxy")]
- internal static extern int /* HRESULT */ GetPixelFormat(
+ internal static extern HRESULT GetPixelFormat(
System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR,
out Guid pPixelFormatEnum);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetResolution_Proxy")]
- internal static extern int /* HRESULT */ GetResolution(
+ internal static extern HRESULT GetResolution(
System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR,
out double pDpiX,
out double pDpiY);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_CopyPalette_Proxy")]
- internal static extern int /* HRESULT */ CopyPalette(
+ internal static extern HRESULT CopyPalette(
System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IMILPalette */ pIPalette);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_CopyPixels_Proxy")]
- internal static extern int /* HRESULT */ CopyPixels(
+ internal static extern HRESULT CopyPixels(
SafeMILHandle /* IWICBitmapSource */ THIS_PTR,
ref Int32Rect prc,
UInt32 cbStride,
@@ -430,23 +432,23 @@ internal static class WICBitmapSource
internal static class WICBitmapDecoder
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetDecoderInfo_Proxy")]
- internal static extern int /* HRESULT */ GetDecoderInfo(
+ internal static extern HRESULT GetDecoderInfo(
SafeMILHandle THIS_PTR,
out SafeMILHandle /* IWICBitmapDecoderInfo */ ppIDecoderInfo);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_CopyPalette_Proxy")]
- internal static extern int /* HRESULT */ CopyPalette(
+ internal static extern HRESULT CopyPalette(
SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR,
SafeMILHandle /* IMILPalette */ pIPalette);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetPreview_Proxy")]
- internal static extern int /* HRESULT */ GetPreview(
+ internal static extern HRESULT GetPreview(
SafeMILHandle THIS_PTR,
out IntPtr /* IWICBitmapSource */ ppIBitmapSource
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetColorContexts_Proxy")]
- internal static extern int /* HRESULT */ GetColorContexts(
+ internal static extern HRESULT GetColorContexts(
SafeMILHandle THIS_PTR,
uint count,
IntPtr[] /* IWICColorContext */ ppIColorContext,
@@ -454,25 +456,25 @@ out uint pActualCount
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetThumbnail_Proxy")]
- internal static extern int /* HRESULT */ GetThumbnail(
+ internal static extern HRESULT GetThumbnail(
SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR,
out IntPtr /* IWICBitmapSource */ ppIThumbnail
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetMetadataQueryReader_Proxy")]
- internal static extern int /* HRESULT */ GetMetadataQueryReader(
+ internal static extern HRESULT GetMetadataQueryReader(
SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR,
out IntPtr /* IWICMetadataQueryReader */ ppIQueryReader
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetFrameCount_Proxy")]
- internal static extern int /* HRESULT */ GetFrameCount(
+ internal static extern HRESULT GetFrameCount(
SafeMILHandle THIS_PTR,
out uint pFrameCount
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetFrame_Proxy")]
- internal static extern int /* HRESULT */ GetFrame(
+ internal static extern HRESULT GetFrame(
SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR,
UInt32 index,
out IntPtr /* IWICBitmapFrameDecode */ ppIFrameDecode
@@ -482,25 +484,25 @@ out IntPtr /* IWICBitmapFrameDecode */ ppIFrameDecode
internal static class WICBitmapFrameDecode
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameDecode_GetThumbnail_Proxy")]
- internal static extern int /* HRESULT */ GetThumbnail(
+ internal static extern HRESULT GetThumbnail(
SafeMILHandle /* IWICBitmapFrameDecode */ THIS_PTR,
out IntPtr /* IWICBitmap */ ppIThumbnail
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameDecode_GetMetadataQueryReader_Proxy")]
- internal static extern int /* HRESULT */ GetMetadataQueryReader(
+ internal static extern HRESULT GetMetadataQueryReader(
SafeMILHandle /* IWICBitmapFrameDecode */ THIS_PTR,
out IntPtr /* IWICMetadataQueryReader */ ppIQueryReader
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameDecode_GetColorContexts_Proxy")]
- internal static extern int /* HRESULT */ GetColorContexts(
+ internal static extern HRESULT GetColorContexts(
SafeMILHandle /* IWICBitmapFrameDecode */ THIS_PTR,
uint count,
IntPtr[] /* IWICColorContext */ ppIColorContext,
out uint pActualCount
);
-}
+ }
internal static class MILUnknown
{
@@ -518,20 +520,20 @@ internal static void ReleaseInterface(ref IntPtr ptr)
{
if (ptr != IntPtr.Zero)
{
- #pragma warning suppress 6031 // Return value ignored on purpose.
+#pragma warning suppress 6031 // Return value ignored on purpose.
UnsafeNativeMethods.MILUnknown.Release(ptr);
ptr = IntPtr.Zero;
}
}
[DllImport(DllImport.MilCore, EntryPoint = "MILQueryInterface")]
- internal static extern int /* HRESULT */ QueryInterface(
+ internal static extern HRESULT QueryInterface(
IntPtr pIUnknown,
ref Guid guid,
out IntPtr ppvObject);
[DllImport(DllImport.MilCore, EntryPoint = "MILQueryInterface")]
- internal static extern int /* HRESULT */ QueryInterface(
+ internal static extern HRESULT QueryInterface(
SafeMILHandle pIUnknown,
ref Guid guid,
out IntPtr ppvObject);
@@ -540,12 +542,12 @@ internal static void ReleaseInterface(ref IntPtr ptr)
internal static class WICStream
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICStream_InitializeFromIStream_Proxy")]
- internal static extern int /*HRESULT*/ InitializeFromIStream(
+ internal static extern HRESULT InitializeFromIStream(
IntPtr pIWICStream,
IntPtr pIStream);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICStream_InitializeFromMemory_Proxy")]
- internal static extern int /*HRESULT*/ InitializeFromMemory(
+ internal static extern HRESULT InitializeFromMemory(
IntPtr pIWICStream,
IntPtr pbBuffer,
uint cbSize);
@@ -554,7 +556,7 @@ internal static class WICStream
internal static class WindowsCodecApi
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateBitmapFromSection")]
- internal static extern int /*HRESULT*/ CreateBitmapFromSection(
+ internal static extern HRESULT CreateBitmapFromSection(
UInt32 width,
UInt32 height,
ref Guid pixelFormatGuid,
@@ -566,126 +568,126 @@ internal static class WindowsCodecApi
internal static class WICBitmapFrameEncode
{
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_Initialize_Proxy")]
- internal static extern int /* HRESULT */ Initialize(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_Initialize_Proxy")]
+ internal static extern HRESULT Initialize(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
SafeMILHandle /* IPropertyBag2* */ pIEncoderOptions);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_Commit_Proxy")]
- internal static extern int /* HRESULT */ Commit(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR);
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_Commit_Proxy")]
+ internal static extern HRESULT Commit(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_SetSize_Proxy")]
- internal static extern int /* HRESULT */ SetSize(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_SetSize_Proxy")]
+ internal static extern HRESULT SetSize(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
int width,
int height);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_SetResolution_Proxy")]
- internal static extern int /* HRESULT */ SetResolution(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
- double dpiX,
- double dpiY);
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_SetResolution_Proxy")]
+ internal static extern HRESULT SetResolution(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
+ double dpiX,
+ double dpiY);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_WriteSource_Proxy")]
- internal static extern int /* HRESULT */ WriteSource(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_WriteSource_Proxy")]
+ internal static extern HRESULT WriteSource(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
SafeMILHandle /* IWICBitmapSource* */ pIBitmapSource,
ref Int32Rect /* MILRect* */ r);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_SetThumbnail_Proxy")]
- internal static extern int /* HRESULT */ SetThumbnail(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
+ internal static extern HRESULT SetThumbnail(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICBitmapSource* */ pIThumbnail);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_GetMetadataQueryWriter_Proxy")]
- internal static extern int /* HRESULT */ GetMetadataQueryWriter(
+ internal static extern HRESULT GetMetadataQueryWriter(
SafeMILHandle /* IWICBitmapFrameEncode */ THIS_PTR,
out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_SetColorContexts_Proxy")]
- internal static extern int /* HRESULT */ SetColorContexts(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
+ internal static extern HRESULT SetColorContexts(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
uint nIndex,
IntPtr[] /* IWICColorContext */ ppIColorContext
);
-}
+ }
internal static class WICBitmapEncoder
{
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_Initialize_Proxy")]
- internal static extern int /* HRESULT */ Initialize(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapEncoder_Initialize_Proxy")]
+ internal static extern HRESULT Initialize(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
IntPtr /* IStream */ pStream,
WICBitmapEncodeCacheOption option);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_GetEncoderInfo_Proxy")]
- internal static extern int /* HRESULT */ GetEncoderInfo(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapEncoder_GetEncoderInfo_Proxy")]
+ internal static extern HRESULT GetEncoderInfo(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
out SafeMILHandle /* IWICBitmapEncoderInfo ** */ ppIEncoderInfo
);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_CreateNewFrame_Proxy")]
- internal static extern int /* HRESULT */ CreateNewFrame(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapEncoder_CreateNewFrame_Proxy")]
+ internal static extern HRESULT CreateNewFrame(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
out SafeMILHandle /* IWICBitmapFrameEncode ** */ ppIFramEncode,
out SafeMILHandle /* IPropertyBag2 ** */ ppIEncoderOptions
);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_SetThumbnail_Proxy")]
- internal static extern int /* HRESULT */ SetThumbnail(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapEncoder_SetThumbnail_Proxy")]
+ internal static extern HRESULT SetThumbnail(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICBitmapSource* */ pIThumbnail);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_SetPalette_Proxy")]
- internal static extern int /* HRESULT */ SetPalette(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapEncoder_SetPalette_Proxy")]
+ internal static extern HRESULT SetPalette(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICPalette* */ pIPalette);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapEncoder_GetMetadataQueryWriter_Proxy")]
- internal static extern int /* HRESULT */ GetMetadataQueryWriter(
+ internal static extern HRESULT GetMetadataQueryWriter(
SafeMILHandle /* IWICBitmapEncoder */ THIS_PTR,
out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter
);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_Commit_Proxy")]
- internal static extern int /* HRESULT */ Commit(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR);
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapEncoder_Commit_Proxy")]
+ internal static extern HRESULT Commit(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR);
}
internal static class WICPalette
{
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializePredefined_Proxy")]
- internal static extern int /* HRESULT */ InitializePredefined(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPalette_InitializePredefined_Proxy")]
+ internal static extern HRESULT InitializePredefined(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
WICPaletteType ePaletteType,
bool fAddTransparentColor);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializeCustom_Proxy")]
- internal static extern int /* HRESULT */ InitializeCustom(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPalette_InitializeCustom_Proxy")]
+ internal static extern HRESULT InitializeCustom(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
IntPtr /* MILColor* */ pColors,
int colorCount);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializeFromBitmap_Proxy")]
- internal static extern int /* HRESULT */ InitializeFromBitmap(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPalette_InitializeFromBitmap_Proxy")]
+ internal static extern HRESULT InitializeFromBitmap(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICBitmapSource* */ pISurface,
int colorCount,
bool fAddTransparentColor);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializeFromPalette_Proxy")]
- internal static extern int /* HRESULT */ InitializeFromPalette(IntPtr /* IWICPalette */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPalette_InitializeFromPalette_Proxy")]
+ internal static extern HRESULT InitializeFromPalette(IntPtr /* IWICPalette */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICPalette */ pIWICPalette);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_GetType_Proxy")]
- internal static extern int /* HRESULT */ GetType(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPalette_GetType_Proxy")]
+ internal static extern HRESULT GetType(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
out WICPaletteType pePaletteType);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_GetColorCount_Proxy")]
- internal static extern int /* HRESULT */ GetColorCount(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPalette_GetColorCount_Proxy")]
+ internal static extern HRESULT GetColorCount(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
out int pColorCount);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_GetColors_Proxy")]
- internal static extern int /* HRESULT */ GetColors(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPalette_GetColors_Proxy")]
+ internal static extern HRESULT GetColors(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
int colorCount,
IntPtr /* MILColor* */ pColors,
out int pcActualCount);
- [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_HasAlpha_Proxy")]
- internal static extern int /* HRESULT */ HasAlpha(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
+ [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPalette_HasAlpha_Proxy")]
+ internal static extern HRESULT HasAlpha(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR,
out bool pfHasAlpha);
}
internal static class WICImagingFactory
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateDecoderFromStream_Proxy")]
- internal static extern int /*HRESULT*/ CreateDecoderFromStream(
+ internal static extern HRESULT CreateDecoderFromStream(
IntPtr pICodecFactory,
IntPtr /* IStream */ pIStream,
ref Guid guidVendor,
@@ -693,7 +695,7 @@ internal static class WICImagingFactory
out IntPtr /* IWICBitmapDecoder */ ppIDecode);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateDecoderFromFileHandle_Proxy")]
- internal static extern int /*HRESULT*/ CreateDecoderFromFileHandle(
+ internal static extern HRESULT CreateDecoderFromFileHandle(
IntPtr pICodecFactory,
Microsoft.Win32.SafeHandles.SafeFileHandle /*ULONG_PTR*/ hFileHandle,
ref Guid guidVendor,
@@ -701,57 +703,57 @@ internal static class WICImagingFactory
out IntPtr /* IWICBitmapDecoder */ ppIDecode);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateComponentInfo_Proxy")]
- internal static extern int /*HRESULT*/ CreateComponentInfo(
+ internal static extern HRESULT CreateComponentInfo(
IntPtr pICodecFactory,
ref Guid clsidComponent,
out IntPtr /* IWICComponentInfo */ ppIComponentInfo);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreatePalette_Proxy")]
- internal static extern int /*HRESULT*/ CreatePalette(
+ internal static extern HRESULT CreatePalette(
IntPtr pICodecFactory,
out SafeMILHandle /* IWICPalette */ ppIPalette);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFormatConverter_Proxy")]
- internal static extern int /* HRESULT */ CreateFormatConverter(
+ internal static extern HRESULT CreateFormatConverter(
IntPtr pICodecFactory,
out BitmapSourceSafeMILHandle /* IWICFormatConverter */ ppFormatConverter);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapScaler_Proxy")]
- internal static extern int /* HRESULT */ CreateBitmapScaler(
+ internal static extern HRESULT CreateBitmapScaler(
IntPtr pICodecFactory,
out BitmapSourceSafeMILHandle /* IWICBitmapScaler */ ppBitmapScaler);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapClipper_Proxy")]
- internal static extern int /* HRESULT */ CreateBitmapClipper(
+ internal static extern HRESULT CreateBitmapClipper(
IntPtr pICodecFactory,
out BitmapSourceSafeMILHandle /* IWICBitmapClipper */ ppBitmapClipper);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFlipRotator_Proxy")]
- internal static extern int /* HRESULT */ CreateBitmapFlipRotator(
+ internal static extern HRESULT CreateBitmapFlipRotator(
IntPtr pICodecFactory,
out BitmapSourceSafeMILHandle /* IWICBitmapFlipRotator */ ppBitmapFlipRotator);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateStream_Proxy")]
- internal static extern int /* HRESULT */ CreateStream(
+ internal static extern HRESULT CreateStream(
IntPtr pICodecFactory,
out IntPtr /* IWICBitmapStream */ ppIStream);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateEncoder_Proxy")]
- internal static extern int /* HRESULT */ CreateEncoder(
+ internal static extern HRESULT CreateEncoder(
IntPtr pICodecFactory,
ref Guid guidContainerFormat,
ref Guid guidVendor,
out SafeMILHandle /* IUnknown** */ ppICodec);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromSource_Proxy")]
- internal static extern int /*HRESULT*/ CreateBitmapFromSource(
+ internal static extern HRESULT CreateBitmapFromSource(
IntPtr THIS_PTR,
SafeMILHandle /* IWICBitmapSource */ pIBitmapSource,
WICBitmapCreateCacheOptions options,
out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromMemory_Proxy")]
- internal static extern int /*HRESULT*/ CreateBitmapFromMemory(
+ internal static extern HRESULT CreateBitmapFromMemory(
IntPtr THIS_PTR,
UInt32 width,
UInt32 height,
@@ -762,7 +764,7 @@ internal static class WICImagingFactory
out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmap_Proxy")]
- internal static extern int /*HRESULT*/ CreateBitmap(
+ internal static extern HRESULT CreateBitmap(
IntPtr THIS_PTR,
UInt32 width,
UInt32 height,
@@ -771,7 +773,7 @@ internal static class WICImagingFactory
out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromHBITMAP_Proxy")]
- internal static extern int /*HRESULT*/ CreateBitmapFromHBITMAP(
+ internal static extern HRESULT CreateBitmapFromHBITMAP(
IntPtr THIS_PTR,
IntPtr hBitmap,
IntPtr hPalette,
@@ -779,25 +781,25 @@ internal static class WICImagingFactory
out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromHICON_Proxy")]
- internal static extern int /*HRESULT*/ CreateBitmapFromHICON(
+ internal static extern HRESULT CreateBitmapFromHICON(
IntPtr THIS_PTR,
IntPtr hIcon,
out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFastMetadataEncoderFromDecoder_Proxy")]
- internal static extern int /*HRESULT*/ CreateFastMetadataEncoderFromDecoder(
+ internal static extern HRESULT CreateFastMetadataEncoderFromDecoder(
IntPtr THIS_PTR,
SafeMILHandle /* IWICBitmapDecoder */ pIDecoder,
out SafeMILHandle /* IWICFastMetadataEncoder */ ppIFME);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFastMetadataEncoderFromFrameDecode_Proxy")]
- internal static extern int /*HRESULT*/ CreateFastMetadataEncoderFromFrameDecode(
+ internal static extern HRESULT CreateFastMetadataEncoderFromFrameDecode(
IntPtr THIS_PTR,
BitmapSourceSafeMILHandle /* IWICBitmapFrameDecode */ pIFrameDecode,
out SafeMILHandle /* IWICFastMetadataEncoder */ ppIBitmap);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateQueryWriter_Proxy")]
- internal static extern int /*HRESULT*/ CreateQueryWriter(
+ internal static extern HRESULT CreateQueryWriter(
IntPtr THIS_PTR,
ref Guid metadataFormat,
ref Guid guidVendor,
@@ -805,7 +807,7 @@ out IntPtr /* IWICMetadataQueryWriter */ queryWriter
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateQueryWriterFromReader_Proxy")]
- internal static extern int /*HRESULT*/ CreateQueryWriterFromReader(
+ internal static extern HRESULT CreateQueryWriterFromReader(
IntPtr THIS_PTR,
SafeMILHandle /* IWICMetadataQueryReader */ queryReader,
ref Guid guidVendor,
@@ -816,7 +818,7 @@ out IntPtr /* IWICMetadataQueryWriter */ queryWriter
internal static class WICComponentFactory
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentFactory_CreateMetadataWriterFromReader_Proxy")]
- internal static extern int /*HRESULT*/ CreateMetadataWriterFromReader(
+ internal static extern HRESULT CreateMetadataWriterFromReader(
IntPtr pICodecFactory,
SafeMILHandle pIMetadataReader,
ref Guid guidVendor,
@@ -824,7 +826,7 @@ out IntPtr metadataWriter
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentFactory_CreateQueryWriterFromBlockWriter_Proxy")]
- internal static extern int /*HRESULT*/ CreateQueryWriterFromBlockWriter(
+ internal static extern HRESULT CreateQueryWriterFromBlockWriter(
IntPtr pICodecFactory,
IntPtr pIBlockWriter,
ref IntPtr ppIQueryWriter
@@ -834,13 +836,13 @@ ref IntPtr ppIQueryWriter
internal static class WICMetadataBlockReader
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataBlockReader_GetCount_Proxy")]
- internal static extern int /*HRESULT*/ GetCount(
+ internal static extern HRESULT GetCount(
IntPtr pIBlockReader,
out UInt32 count
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataBlockReader_GetReaderByIndex_Proxy")]
- internal static extern int /*HRESULT*/ GetReaderByIndex(
+ internal static extern HRESULT GetReaderByIndex(
IntPtr pIBlockReader,
UInt32 index,
out SafeMILHandle /* IWICMetadataReader* */ pIMetadataReader
@@ -850,23 +852,23 @@ out SafeMILHandle /* IWICMetadataReader* */ pIMetadataReader
internal static class WICPixelFormatInfo
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPixelFormatInfo_GetBitsPerPixel_Proxy")]
- internal static extern int /*HRESULT*/ GetBitsPerPixel(
+ internal static extern HRESULT GetBitsPerPixel(
IntPtr /* IWICPixelFormatInfo */ pIPixelFormatInfo,
out UInt32 uiBitsPerPixel
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPixelFormatInfo_GetChannelCount_Proxy")]
- internal static extern int /*HRESULT*/ GetChannelCount(
+ internal static extern HRESULT GetChannelCount(
IntPtr /* IWICPixelFormatInfo */ pIPixelFormatInfo,
out UInt32 uiChannelCount
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPixelFormatInfo_GetChannelMask_Proxy")]
- internal unsafe static extern int /*HRESULT*/ GetChannelMask(
+ internal static extern unsafe HRESULT GetChannelMask(
IntPtr /* IWICPixelFormatInfo */ pIPixelFormatInfo,
UInt32 uiChannelIndex,
UInt32 cbMaskBuffer,
- byte *pbMaskBuffer,
+ byte* pbMaskBuffer,
out UInt32 cbActual
);
}
@@ -874,7 +876,7 @@ out UInt32 cbActual
internal static class WICBitmapClipper
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapClipper_Initialize_Proxy")]
- internal static extern int /* HRESULT */ Initialize(
+ internal static extern HRESULT Initialize(
System.Windows.Media.SafeMILHandle /* IWICBitmapClipper */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source,
ref Int32Rect prc);
@@ -883,7 +885,7 @@ internal static class WICBitmapClipper
internal static class WICBitmapFlipRotator
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFlipRotator_Initialize_Proxy")]
- internal static extern int /* HRESULT */ Initialize(
+ internal static extern HRESULT Initialize(
System.Windows.Media.SafeMILHandle /* IWICBitmapFlipRotator */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source,
WICBitmapTransformOptions options);
@@ -892,7 +894,7 @@ internal static class WICBitmapFlipRotator
internal static class WICBitmapScaler
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapScaler_Initialize_Proxy")]
- internal static extern int /* HRESULT */ Initialize(
+ internal static extern HRESULT Initialize(
System.Windows.Media.SafeMILHandle /* IWICBitmapScaler */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source,
uint width,
@@ -903,7 +905,7 @@ internal static class WICBitmapScaler
internal static class WICFormatConverter
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFormatConverter_Initialize_Proxy")]
- internal static extern int /* HRESULT */ Initialize(
+ internal static extern HRESULT Initialize(
System.Windows.Media.SafeMILHandle /* IWICFormatConverter */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source,
ref Guid dstFormat,
@@ -915,15 +917,15 @@ WICPaletteType paletteTranslate
}
internal static class IWICColorContext
{
- internal enum WICColorContextType : uint
+ internal enum WICColorContextType : uint
{
- WICColorContextUninitialized = 0,
- WICColorContextProfile = 1,
+ WICColorContextUninitialized = 0,
+ WICColorContextProfile = 1,
WICColorContextExifColorSpace = 2
};
-
+
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICColorContext_InitializeFromMemory_Proxy")]
- internal static extern int /* HRESULT */ InitializeFromMemory(
+ internal static extern HRESULT InitializeFromMemory(
SafeMILHandle THIS_PTR,
byte[] pbBuffer,
uint cbBufferSize
@@ -932,7 +934,7 @@ uint cbBufferSize
// We import the following functions from MilCore because WindowsCodecs does not have
// them built-in
[DllImport(DllImport.MilCore, EntryPoint = "IWICColorContext_GetProfileBytes_Proxy")]
- internal static extern int /* HRESULT */ GetProfileBytes(
+ internal static extern HRESULT GetProfileBytes(
SafeMILHandle THIS_PTR,
uint cbBuffer,
/* inout */ byte[] pbBuffer,
@@ -940,13 +942,13 @@ out uint pcbActual
);
[DllImport(DllImport.MilCore, EntryPoint = "IWICColorContext_GetType_Proxy")]
- internal static extern int /* HRESULT */ GetType(
+ internal static extern HRESULT GetType(
SafeMILHandle THIS_PTR,
out WICColorContextType pType
);
[DllImport(DllImport.MilCore, EntryPoint = "IWICColorContext_GetExifColorSpace_Proxy")]
- internal static extern int /* HRESULT */ GetExifColorSpace(
+ internal static extern HRESULT GetExifColorSpace(
SafeMILHandle THIS_PTR,
out uint pValue
);
@@ -955,7 +957,7 @@ out uint pValue
internal static class WICColorTransform
{
[DllImport(DllImport.WindowsCodecsExt, EntryPoint = "IWICColorTransform_Initialize_Proxy")]
- internal static extern int /* HRESULT */ Initialize(
+ internal static extern HRESULT Initialize(
System.Windows.Media.SafeMILHandle /* IWICColorTransform */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source,
System.Windows.Media.SafeMILHandle /* IWICColorContext */ pIContextSource,
@@ -967,20 +969,20 @@ ref Guid pixelFmtDest
internal static class WICBitmap
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmap_Lock_Proxy")]
- internal static extern int /* HRESULT */ Lock(
+ internal static extern HRESULT Lock(
System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR,
ref Int32Rect prcLock,
LockFlags flags,
out SafeMILHandle /* IWICBitmapLock* */ ppILock);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmap_SetResolution_Proxy")]
- internal static extern int /* HRESULT */ SetResolution(
+ internal static extern HRESULT SetResolution(
System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR,
double dpiX,
double dpiY);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmap_SetPalette_Proxy")]
- internal static extern int /* HRESULT */ SetPalette(
+ internal static extern HRESULT SetPalette(
System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR,
System.Windows.Media.SafeMILHandle /* IMILPalette */ pIPalette);
}
@@ -988,13 +990,13 @@ internal static class WICBitmap
internal static class WICBitmapLock
{
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapLock_GetStride_Proxy")]
- internal static extern int /* HRESULT */ GetStride(
+ internal static extern HRESULT GetStride(
SafeMILHandle /* IWICBitmapLock */ pILock,
ref uint pcbStride
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapLock_GetDataPointer_STA_Proxy")]
- internal static extern int /* HRESULT */ GetDataPointer(
+ internal static extern HRESULT GetDataPointer(
SafeMILHandle /* IWICBitmapLock */ pILock,
ref uint pcbBufferSize,
ref IntPtr ppbData
@@ -1008,52 +1010,52 @@ internal static class WICCodec
internal const int WINCODEC_SDK_VERSION = 0x0236;
[DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateImagingFactory_Proxy")]
- internal static extern int CreateImagingFactory(
+ internal static extern HRESULT CreateImagingFactory(
UInt32 SDKVersion,
out IntPtr ppICodecFactory
);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "WICConvertBitmapSource")]
- internal static extern int /* HRESULT */ WICConvertBitmapSource(
+ internal static extern HRESULT WICConvertBitmapSource(
ref Guid dstPixelFormatGuid,
SafeMILHandle /* IWICBitmapSource */ pISrc,
out BitmapSourceSafeMILHandle /* IWICBitmapSource* */ ppIDst);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "WICSetEncoderFormat_Proxy")]
- internal static extern int /* HRESULT */ WICSetEncoderFormat(
+ internal static extern HRESULT WICSetEncoderFormat(
SafeMILHandle /* IWICBitmapSource */ pSourceIn,
SafeMILHandle /* IMILPalette */ pIPalette,
SafeMILHandle /* IWICBitmapFrameEncode* */ pIFrameEncode,
out SafeMILHandle /* IWICBitmapSource** */ ppSourceOut);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "WICMapGuidToShortName")]//CASRemoval:
- internal static extern int /* HRESULT */ WICMapGuidToShortName(
+ internal static extern HRESULT WICMapGuidToShortName(
ref Guid guid,
uint cchName,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzName,
ref uint pcchActual);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "WICMapShortNameToGuid")]//CASRemoval:
- internal static extern int /* HRESULT */ WICMapShortNameToGuid(
+ internal static extern HRESULT WICMapShortNameToGuid(
[MarshalAs(UnmanagedType.LPWStr)] String wzName,
ref Guid guid);
[DllImport(DllImport.WindowsCodecsExt, EntryPoint = "WICCreateColorTransform_Proxy")]
- internal static extern int /* HRESULT */ CreateColorTransform(
+ internal static extern HRESULT CreateColorTransform(
out BitmapSourceSafeMILHandle /* IWICColorTransform */ ppWICColorTransform);
[DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateColorContext_Proxy")]
- internal static extern int /* HRESULT */ CreateColorContext(
+ internal static extern HRESULT CreateColorContext(
IntPtr pICodecFactory,
out System.Windows.Media.SafeMILHandle /* IWICColorContext */ ppColorContext);
[DllImport("ole32.dll")]
- internal static extern int /* HRESULT */ CoInitialize(
+ internal static extern HRESULT CoInitialize(
IntPtr reserved);
[DllImport("ole32.dll")]
internal static extern void CoUninitialize();
-}
+ }
internal static class Mscms
{
@@ -1064,7 +1066,7 @@ internal static class Mscms
internal static extern bool DeleteColorTransform(IntPtr /* HTRANSFORM */ hColorTransform);
[DllImport(DllImport.Mscms, EntryPoint = "TranslateColors")]
- internal static extern int /* HRESULT */ TranslateColors(ColorTransformHandle /* HTRANSFORM */ hColorTransform, IntPtr paInputColors, UInt32 nColors, UInt32 ctInput, IntPtr paOutputColors, UInt32 ctOutput);
+ internal static extern HRESULT TranslateColors(ColorTransformHandle /* HTRANSFORM */ hColorTransform, IntPtr paInputColors, UInt32 nColors, UInt32 ctInput, IntPtr paOutputColors, UInt32 ctOutput);
[DllImport(DllImport.Mscms, EntryPoint = "OpenColorProfile")]
internal static extern SafeProfileHandle /* HANDLE */ OpenColorProfile(ref MS.Win32.UnsafeNativeMethods.PROFILE pProfile, UInt32 dwDesiredAccess, UInt32 dwShareMode, UInt32 dwCreationMode);
@@ -1076,10 +1078,10 @@ internal static class Mscms
internal static extern bool GetColorProfileHeader(SafeProfileHandle /* HANDLE */ phProfile, out MS.Win32.UnsafeNativeMethods.PROFILEHEADER pHeader);
[DllImport(DllImport.Mscms, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int /* HRESULT */ GetColorDirectory(IntPtr pMachineName, StringBuilder pBuffer, out uint pdwSize);
+ internal static extern HRESULT GetColorDirectory(IntPtr pMachineName, StringBuilder pBuffer, out uint pdwSize);
[DllImport(DllImport.Mscms, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int /* HRESULT */ GetStandardColorSpaceProfile(IntPtr pMachineName, uint dwProfileID, StringBuilder pProfileName, out uint pdwSize);
+ internal static extern HRESULT GetStandardColorSpaceProfile(IntPtr pMachineName, uint dwProfileID, StringBuilder pProfileName, out uint pdwSize);
[DllImport(DllImport.Mscms, EntryPoint = "GetColorProfileFromHandle", SetLastError = true)]
internal static extern bool GetColorProfileFromHandle(SafeProfileHandle /* HANDLE */ hProfile, byte[] pBuffer, ref uint pdwSize);
@@ -1088,20 +1090,20 @@ internal static class Mscms
internal static class MILFactory2
{
[DllImport(DllImport.MilCore, EntryPoint = "MILCreateFactory")]
- internal static extern int CreateFactory(
+ internal static extern HRESULT CreateFactory(
out IntPtr ppIFactory,
UInt32 SDKVersion
);
[DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateMediaPlayer")]
- internal static extern int /*HRESULT*/ CreateMediaPlayer(
+ internal static extern HRESULT CreateMediaPlayer(
IntPtr THIS_PTR,
SafeMILHandle /* CEventProxy */ pEventProxy,
bool canOpenAllMedia,
out SafeMediaHandle /* IMILMedia */ ppMedia);
[DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateBitmapRenderTarget")]
- internal static extern int /* HRESULT */ CreateBitmapRenderTarget(
+ internal static extern HRESULT CreateBitmapRenderTarget(
IntPtr THIS_PTR,
UInt32 width,
UInt32 height,
@@ -1112,7 +1114,7 @@ UInt32 SDKVersion
out SafeMILHandle /* IMILRenderTargetBitmap */ ppIRenderTargetBitmap);
[DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateSWRenderTargetForBitmap")]
- internal static extern int /* HRESULT */ CreateBitmapRenderTargetForBitmap(
+ internal static extern HRESULT CreateBitmapRenderTargetForBitmap(
IntPtr THIS_PTR,
BitmapSourceSafeMILHandle /* IWICBitmap */ pIBitmap,
out SafeMILHandle /* IMILRenderTargetBitmap */ ppIRenderTargetBitmap);
@@ -1121,9 +1123,9 @@ UInt32 SDKVersion
internal static class InteropDeviceBitmap
{
internal delegate void FrontBufferAvailableCallback(bool lost, uint version);
-
+
[DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_Create")]
- internal static extern int Create(
+ internal static extern HRESULT Create(
IntPtr d3dResource,
double dpiX,
double dpiY,
@@ -1141,17 +1143,18 @@ SafeMILHandle pInteropDeviceBitmap
);
[DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_AddDirtyRect")]
- internal static extern int AddDirtyRect(
-
- int x,
- int y,
- int w,
+ internal static extern HRESULT AddDirtyRect(
+ int x,
+ int y,
+ int w,
int h,
SafeMILHandle pInteropDeviceBitmap
);
[DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_GetAsSoftwareBitmap")]
- internal static extern int GetAsSoftwareBitmap(SafeMILHandle pInteropDeviceBitmap, out BitmapSourceSafeMILHandle pIWICBitmapSource);
+ internal static extern HRESULT GetAsSoftwareBitmap(
+ SafeMILHandle pInteropDeviceBitmap,
+ out BitmapSourceSafeMILHandle pIWICBitmapSource);
}
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/mediaeventshelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/mediaeventshelper.cs
index 056cee85b76..97329e82671 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/mediaeventshelper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/mediaeventshelper.cs
@@ -1,14 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-//
-
using System.Text;
-using MS.Internal;
using System.Windows.Threading;
using System.IO;
+using Windows.Win32.Foundation;
namespace System.Windows.Media
{
@@ -28,28 +25,28 @@ internal class MediaEventsHelper : IInvokable
internal MediaEventsHelper(MediaPlayer mediaPlayer)
{
_mediaOpened = new DispatcherOperationCallback(OnMediaOpened);
- this.DispatcherMediaOpened += _mediaOpened;
+ DispatcherMediaOpened += _mediaOpened;
_mediaFailed = new DispatcherOperationCallback(OnMediaFailed);
- this.DispatcherMediaFailed += _mediaFailed;
+ DispatcherMediaFailed += _mediaFailed;
_mediaPrerolled = new DispatcherOperationCallback(OnMediaPrerolled);
- this.DispatcherMediaPrerolled += _mediaPrerolled;
+ DispatcherMediaPrerolled += _mediaPrerolled;
_mediaEnded = new DispatcherOperationCallback(OnMediaEnded);
- this.DispatcherMediaEnded += _mediaEnded;
+ DispatcherMediaEnded += _mediaEnded;
_bufferingStarted = new DispatcherOperationCallback(OnBufferingStarted);
- this.DispatcherBufferingStarted += _bufferingStarted;
+ DispatcherBufferingStarted += _bufferingStarted;
_bufferingEnded = new DispatcherOperationCallback(OnBufferingEnded);
- this.DispatcherBufferingEnded += _bufferingEnded;
+ DispatcherBufferingEnded += _bufferingEnded;
_scriptCommand = new DispatcherOperationCallback(OnScriptCommand);
- this.DispatcherScriptCommand += _scriptCommand;
+ DispatcherScriptCommand += _scriptCommand;
_newFrame = new DispatcherOperationCallback(OnNewFrame);
- this.DispatcherMediaNewFrame += _newFrame;
+ DispatcherMediaNewFrame += _newFrame;
SetSender(mediaPlayer);
}
@@ -231,10 +228,7 @@ internal void RaiseMediaFailed(Exception e)
///
void IInvokable.RaiseEvent(byte[] buffer, int cb)
{
- const int S_OK = 0;
-
AVEvent avEventType = AVEvent.AVMediaNone;
- int failureHr = S_OK;
int size = 0;
//
@@ -261,7 +255,7 @@ void IInvokable.RaiseEvent(byte[] buffer, int cb)
// Unpack the event and the errorHResult
//
avEventType = (AVEvent)reader.ReadUInt32();
- failureHr = (int)reader.ReadUInt32();
+ HRESULT failureHr = (HRESULT)reader.ReadUInt32();
switch(avEventType)
{
@@ -275,7 +269,7 @@ void IInvokable.RaiseEvent(byte[] buffer, int cb)
case AVEvent.AVMediaFailed:
- RaiseMediaFailed(HRESULT.ConvertHRToException(failureHr));
+ RaiseMediaFailed(failureHr.GetExtendedException());
break;
case AVEvent.AVMediaBufferingStarted:
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/safemediahandle.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/safemediahandle.cs
index 3e486c425ad..79a51fcb821 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/safemediahandle.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/safemediahandle.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -6,21 +6,17 @@
//
using MS.Internal;
-
+using Windows.Win32.Foundation;
using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods;
namespace System.Windows.Media
{
internal class SafeMediaHandle : SafeMILHandle
{
- ///
- ///
internal SafeMediaHandle()
{
}
- ///
- ///
internal SafeMediaHandle(IntPtr handle)
{
SetHandle(handle);
@@ -28,7 +24,7 @@ internal SafeMediaHandle(IntPtr handle)
protected override bool ReleaseHandle()
{
- HRESULT.Check(MILMedia.Shutdown(handle));
+ MILMedia.Shutdown(handle).ThrowOnFailureExtended();
UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref handle);
return true;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/OleServicesContext.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/OleServicesContext.cs
index 12c60ebf310..b1ccf3291af 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/OleServicesContext.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/OleServicesContext.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -12,6 +12,7 @@
using System.Windows.Input;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
+using Windows.Win32.Foundation;
namespace System.Windows
{
@@ -72,7 +73,7 @@ internal static OleServicesContext CurrentOleServicesContext
OleServicesContext oleServicesContext;
// Get the ole services context from the Thread data slot.
- oleServicesContext = (OleServicesContext)Thread.GetData(OleServicesContext._threadDataSlot);
+ oleServicesContext = (OleServicesContext)Thread.GetData(_threadDataSlot);
if (oleServicesContext == null)
{
@@ -80,7 +81,7 @@ internal static OleServicesContext CurrentOleServicesContext
oleServicesContext = new OleServicesContext();
// Save the ole services context into the UIContext data slot.
- Thread.SetData(OleServicesContext._threadDataSlot, oleServicesContext);
+ Thread.SetData(_threadDataSlot, oleServicesContext);
}
return oleServicesContext;
@@ -100,7 +101,7 @@ internal static OleServicesContext CurrentOleServicesContext
///
/// OleSetClipboard - Call OLE Interopo OleSetClipboard()
///
- internal int OleSetClipboard(IComDataObject dataObject)
+ internal HRESULT OleSetClipboard(IComDataObject dataObject)
{
if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
{
@@ -113,7 +114,7 @@ internal int OleSetClipboard(IComDataObject dataObject)
///
/// OleGetClipboard - Call OLE Interop OleGetClipboard()
///
- internal int OleGetClipboard(ref IComDataObject dataObject)
+ internal HRESULT OleGetClipboard(ref IComDataObject dataObject)
{
if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
{
@@ -126,7 +127,7 @@ internal int OleGetClipboard(ref IComDataObject dataObject)
///
/// OleFlushClipboard - Call OLE Interop OleFlushClipboard()
///
- internal int OleFlushClipboard()
+ internal HRESULT OleFlushClipboard()
{
if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
{
@@ -138,11 +139,11 @@ internal int OleFlushClipboard()
///
/// OleIsCurrentClipboard - OleIsCurrentClipboard only works for the data object
- /// used in the OleSetClipboard. This means that it can’t be called by the consumer
+ /// used in the OleSetClipboard. This means that it can’t be called by the consumer
/// of the data object to determine if the object that was on the clipboard at the
/// previous OleGetClipboard call is still on the Clipboard.
///
- internal int OleIsCurrentClipboard(IComDataObject dataObject)
+ internal HRESULT OleIsCurrentClipboard(IComDataObject dataObject)
{
if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
{
@@ -223,8 +224,6 @@ internal int OleRevokeDragDrop(HandleRef windowHandle)
///
private void SetDispatcherThread()
{
- int hr;
-
if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
{
throw new ThreadStateException(SR.OleServicesContext_ThreadMustBeSTA);
@@ -232,11 +231,11 @@ private void SetDispatcherThread()
// Initialize Ole services.
// Balanced with OleUninitialize call in OnDispatcherShutdown.
- hr = OleInitialize();
+ HRESULT result = OleInitialize();
- if (!NativeMethods.Succeeded(hr))
+ if (!result.Succeeded)
{
- throw new SystemException(SR.Format(SR.OleServicesContext_oleInitializeFailure, hr));
+ throw new SystemException(SR.Format(SR.OleServicesContext_oleInitializeFailure, result));
}
// Add Dispatcher.Shutdown event handler.
@@ -266,7 +265,7 @@ private void OnDispatcherShutdown(object sender, EventArgs args)
}
// Wrapper for UnsafeNativeMethods.OleInitialize, useful for debugging.
- private int OleInitialize()
+ private HRESULT OleInitialize()
{
#if DEBUG
_debugOleInitializeRefCount++;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/clipboard.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/clipboard.cs
index 19b90b15ea1..879ef14bb72 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/clipboard.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/clipboard.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -17,6 +17,7 @@
using System.Windows.Media.Imaging;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
+using Windows.Win32.Foundation;
namespace System.Windows
{
@@ -49,16 +50,16 @@ public static void Clear()
while (true)
{
// Clear the system clipboard by calling OleSetClipboard with null parameter.
- int hr = OleServicesContext.CurrentOleServicesContext.OleSetClipboard(null);
+ HRESULT result = OleServicesContext.CurrentOleServicesContext.OleSetClipboard(null);
- if (NativeMethods.Succeeded(hr))
+ if (result.Succeeded)
{
break;
}
if (--i == 0)
{
- Marshal.ThrowExceptionForHR(hr);
+ result.ThrowOnFailure();
}
Thread.Sleep(OleRetryDelay);
@@ -138,16 +139,16 @@ public static void Flush()
while (true)
{
- int hr = OleServicesContext.CurrentOleServicesContext.OleFlushClipboard();
+ HRESULT result = OleServicesContext.CurrentOleServicesContext.OleFlushClipboard();
- if (NativeMethods.Succeeded(hr))
+ if (result.Succeeded)
{
break;
}
if (--i == 0)
{
- SecurityHelper.ThrowExceptionForHR(hr);
+ result.ThrowOnFailure();
}
Thread.Sleep(OleRetryDelay);
@@ -358,7 +359,7 @@ public static IDataObject GetDataObject()
/// Data object from the current containing clipboard which the caller
/// previously placed on the clipboard.
///
- public static bool IsCurrent(IDataObject data)
+ public static bool IsCurrent(IDataObject data)
{
bool bReturn;
@@ -368,7 +369,7 @@ public static bool IsCurrent(IDataObject data)
if (data is IComDataObject)
{
- int hr;
+ HRESULT result;
// Retry OLE operations several times as mitigation for clipboard locking issues in TS sessions.
@@ -376,9 +377,9 @@ public static bool IsCurrent(IDataObject data)
while (true)
{
- hr = OleServicesContext.CurrentOleServicesContext.OleIsCurrentClipboard((IComDataObject)data);
+ result = OleServicesContext.CurrentOleServicesContext.OleIsCurrentClipboard((IComDataObject)data);
- if (NativeMethods.Succeeded(hr) || (--i == 0))
+ if (result.Succeeded || (--i == 0))
{
break;
}
@@ -386,13 +387,15 @@ public static bool IsCurrent(IDataObject data)
Thread.Sleep(OleRetryDelay);
}
- if (hr == NativeMethods.S_OK)
+ if (result == HRESULT.S_OK)
{
bReturn = true;
}
- else if (!NativeMethods.Succeeded(hr))
+ else if (!result.Succeeded)
{
- throw new ExternalException("OleIsCurrentClipboard()", hr);
+#pragma warning disable CA2201 // Do not raise reserved exception types
+ throw new ExternalException("OleIsCurrentClipboard()", result);
+#pragma warning restore CA2201
}
}
@@ -480,16 +483,16 @@ internal static void CriticalSetDataObject(object data, bool copy)
while (true)
{
// Clear the system clipboard by calling OleSetClipboard with null parameter.
- int hr = OleServicesContext.CurrentOleServicesContext.OleSetClipboard(dataObject);
+ HRESULT result = OleServicesContext.CurrentOleServicesContext.OleSetClipboard(dataObject);
- if (NativeMethods.Succeeded(hr))
+ if (result.Succeeded)
{
break;
}
if (--i == 0)
{
- Marshal.ThrowExceptionForHR(hr);
+ result.ThrowOnFailure();
}
Thread.Sleep(OleRetryDelay);
@@ -555,9 +558,9 @@ private static bool IsDynamicCodePolicyEnabled()
IntPtr entryPoint = UnsafeNativeMethods.GetProcAddressNoThrow(new HandleRef(null, hModule), "WldpIsDynamicCodePolicyEnabled");
if (entryPoint != IntPtr.Zero)
{
- int hResult = UnsafeNativeMethods.WldpIsDynamicCodePolicyEnabled(out isEnabled);
+ HRESULT result = UnsafeNativeMethods.WldpIsDynamicCodePolicyEnabled(out isEnabled);
- if (hResult != NativeMethods.S_OK)
+ if (result != HRESULT.S_OK)
{
isEnabled = false;
}
@@ -590,16 +593,16 @@ private static IDataObject GetDataObjectInternal()
while (true)
{
oleDataObject = null;
- int hr = OleServicesContext.CurrentOleServicesContext.OleGetClipboard(ref oleDataObject);
+ HRESULT result = OleServicesContext.CurrentOleServicesContext.OleGetClipboard(ref oleDataObject);
- if (NativeMethods.Succeeded(hr))
+ if (result.Succeeded)
{
break;
}
if (--i == 0)
{
- Marshal.ThrowExceptionForHR(hr);
+ result.ThrowOnFailure();
}
Thread.Sleep(OleRetryDelay);
@@ -659,7 +662,7 @@ private static object GetDataInternal(string format)
{
IDataObject dataObject;
- dataObject = Clipboard.GetDataObject();
+ dataObject = GetDataObject();
if (dataObject != null)
{
@@ -702,7 +705,7 @@ private static void SetDataInternal(string format, object data)
dataObject = new DataObject();
dataObject.SetData(format, data, autoConvert);
- Clipboard.SetDataObject(dataObject, /*copy*/true);
+ SetDataObject(dataObject, copy: true);
}
///
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/dataobject.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/dataobject.cs
index e5f24310b5d..ab74bd839ec 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/dataobject.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/dataobject.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -16,6 +16,7 @@
using System.Windows.Media.Imaging;
using System.Text;
using MS.Internal;
+using Windows.Win32.Foundation;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
@@ -549,7 +550,7 @@ int IComDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink pAdv
return ((OleConverter)_innerData).OleDataObject.DAdvise(ref pFormatetc, advf, pAdvSink, out pdwConnection);
}
pdwConnection = 0;
- return (NativeMethods.E_NOTIMPL);
+ return HRESULT.E_NOTIMPL;
}
///
@@ -563,8 +564,8 @@ void IComDataObject.DUnadvise(int dwConnection)
return;
}
- // Throw the exception NativeMethods.E_NOTIMPL.
- Marshal.ThrowExceptionForHR(NativeMethods.E_NOTIMPL);
+ // Throw the exception HRESULT.E_NOTIMPL.
+ HRESULT.E_NOTIMPL.ThrowOnFailure();
}
///
@@ -577,7 +578,7 @@ int IComDataObject.EnumDAdvise(out IEnumSTATDATA enumAdvise)
return ((OleConverter)_innerData).OleDataObject.EnumDAdvise(out enumAdvise);
}
enumAdvise = null;
- return (OLE_E_ADVISENOTSUPPORTED);
+ return HRESULT.OLE_E_ADVISENOTSUPPORTED;
}
//
@@ -595,7 +596,7 @@ IEnumFORMATETC IComDataObject.EnumFormatEtc(DATADIR dwDirection)
}
else
{
- throw new ExternalException(SR.Format(SR.DataObject_NotImplementedEnumFormatEtc, dwDirection), NativeMethods.E_NOTIMPL);
+ throw new ExternalException(SR.Format(SR.DataObject_NotImplementedEnumFormatEtc, dwDirection), HRESULT.E_NOTIMPL);
}
}
@@ -610,7 +611,8 @@ int IComDataObject.GetCanonicalFormatEtc(ref FORMATETC pformatetcIn, out FORMATE
if (pformatetcIn.lindex != -1)
{
- return DV_E_LINDEX;
+ // return HRESULT.DV_E_LINDEX;
+ return (HRESULT)(-2147221400);
}
if (_innerData is OleConverter)
@@ -618,7 +620,8 @@ int IComDataObject.GetCanonicalFormatEtc(ref FORMATETC pformatetcIn, out FORMATE
return ((OleConverter)_innerData).OleDataObject.GetCanonicalFormatEtc(ref pformatetcIn, out pformatetcOut);
}
- return DATA_S_SAMEFORMATETC;
+ // return HRESULT.DATA_S_SAMEFORMATETC;
+ return (HRESULT)262448;
}
///
@@ -632,9 +635,7 @@ void IComDataObject.GetData(ref FORMATETC formatetc, out STGMEDIUM medium)
return;
}
- int hr;
-
- hr = DV_E_TYMED;
+ HRESULT result = HRESULT.DV_E_TYMED;
medium = new STGMEDIUM();
@@ -649,9 +650,9 @@ void IComDataObject.GetData(ref FORMATETC formatetc, out STGMEDIUM medium)
| NativeMethods.GMEM_ZEROINIT,
(IntPtr)1);
- hr = OleGetDataUnrestricted(ref formatetc, ref medium, false /* doNotReallocate */);
+ result = OleGetDataUnrestricted(ref formatetc, ref medium, false /* doNotReallocate */);
- if (NativeMethods.Failed(hr))
+ if (result.Failed)
{
Win32GlobalFree(new HandleRef(this, medium.unionmember));
}
@@ -661,15 +662,15 @@ void IComDataObject.GetData(ref FORMATETC formatetc, out STGMEDIUM medium)
medium.tymed = TYMED.TYMED_ISTREAM;
IStream istream = null;
- hr = Win32CreateStreamOnHGlobal(IntPtr.Zero, true /*deleteOnRelease*/, ref istream);
- if ( NativeMethods.Succeeded(hr) )
+ result = Win32CreateStreamOnHGlobal(IntPtr.Zero, true /*deleteOnRelease*/, ref istream);
+ if (result.Succeeded)
{
medium.unionmember = Marshal.GetComInterfaceForObject(istream, typeof(IStream));
Marshal.ReleaseComObject(istream);
- hr = OleGetDataUnrestricted(ref formatetc, ref medium, false /* doNotReallocate */);
+ result = OleGetDataUnrestricted(ref formatetc, ref medium, false /* doNotReallocate */);
- if ( NativeMethods.Failed(hr) )
+ if (result.Failed)
{
Marshal.Release(medium.unionmember);
}
@@ -678,16 +679,15 @@ void IComDataObject.GetData(ref FORMATETC formatetc, out STGMEDIUM medium)
else
{
medium.tymed = formatetc.tymed;
- hr = OleGetDataUnrestricted(ref formatetc, ref medium, false /* doNotReallocate */);
+ result = OleGetDataUnrestricted(ref formatetc, ref medium, false /* doNotReallocate */);
}
}
// Make sure we zero out that pointer if we don't support the format.
- if (NativeMethods.Failed(hr))
+ if (result.Failed)
{
medium.unionmember = IntPtr.Zero;
-
- Marshal.ThrowExceptionForHR(hr);
+ result.ThrowOnFailure();
}
}
@@ -703,14 +703,10 @@ void IComDataObject.GetDataHere(ref FORMATETC formatetc, ref STGMEDIUM medium)
medium.tymed != TYMED.TYMED_HGLOBAL &&
medium.tymed != TYMED.TYMED_FILE)
{
- Marshal.ThrowExceptionForHR(DV_E_TYMED);
+ HRESULT.DV_E_TYMED.ThrowOnFailure();
}
- int hr = OleGetDataUnrestricted(ref formatetc, ref medium, true /* doNotReallocate */);
- if (NativeMethods.Failed(hr))
- {
- Marshal.ThrowExceptionForHR(hr);
- }
+ OleGetDataUnrestricted(ref formatetc, ref medium, doNotReallocate: true).ThrowOnFailure();
}
///
@@ -728,27 +724,27 @@ int IComDataObject.QueryGetData(ref FORMATETC formatetc)
{
if (formatetc.cfFormat == 0)
{
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
else
{
if (!GetDataPresent(DataFormats.GetDataFormat(formatetc.cfFormat).Name))
{
- return (DV_E_FORMATETC);
+ return HRESULT.DV_E_FORMATETC;
}
}
}
else
{
- return (DV_E_TYMED);
+ return HRESULT.DV_E_TYMED;
}
}
else
{
- return (DV_E_DVASPECT);
+ return HRESULT.DV_E_DVASPECT;
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
@@ -762,7 +758,7 @@ void IComDataObject.SetData(ref FORMATETC pFormatetcIn, ref STGMEDIUM pmedium, b
return;
}
- Marshal.ThrowExceptionForHR(NativeMethods.E_NOTIMPL);
+ Marshal.ThrowExceptionForHR(HRESULT.E_NOTIMPL);
}
//......................................................
@@ -982,15 +978,9 @@ internal static IntPtr Win32GlobalAlloc(int flags, IntPtr bytes)
///
/// Call Win32 UnsafeNativeMethods.CreateStreamOnHGlobal() with Win32 error checking.
///
- private static int Win32CreateStreamOnHGlobal(IntPtr hGlobal, bool fDeleteOnRelease, ref IStream istream)
+ private static HRESULT Win32CreateStreamOnHGlobal(IntPtr hGlobal, bool fDeleteOnRelease, ref IStream istream)
{
- int hr = UnsafeNativeMethods.CreateStreamOnHGlobal(hGlobal, fDeleteOnRelease, ref istream);
- if ( NativeMethods.Failed(hr) )
- {
- Marshal.ThrowExceptionForHR(hr);
- }
-
- return hr;
+ return UnsafeNativeMethods.CreateStreamOnHGlobal(hGlobal, fDeleteOnRelease, ref istream).ThrowOnFailure();
}
///
@@ -1238,13 +1228,13 @@ internal static string[] GetMappedFormats(string format)
/// Behaves like IComDataObject.GetData and IComDataObject.GetDataHere,
/// except we make no restrictions TYMED values.
///
- private int OleGetDataUnrestricted(ref FORMATETC formatetc, ref STGMEDIUM medium, bool doNotReallocate)
+ private HRESULT OleGetDataUnrestricted(ref FORMATETC formatetc, ref STGMEDIUM medium, bool doNotReallocate)
{
if (_innerData is OleConverter)
{
((OleConverter)_innerData).OleDataObject.GetDataHere(ref formatetc, ref medium);
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
return GetDataIntoOleStructs(ref formatetc, ref medium, doNotReallocate);
@@ -1407,11 +1397,9 @@ private IntPtr GetEnhancedMetafileHandle(String format, object data)
/// Populates Ole datastructes from a WinForms dataObject. This is the core
/// of WinForms to OLE conversion.
///
- private int GetDataIntoOleStructs(ref FORMATETC formatetc, ref STGMEDIUM medium, bool doNotReallocate)
+ private HRESULT GetDataIntoOleStructs(ref FORMATETC formatetc, ref STGMEDIUM medium, bool doNotReallocate)
{
- int hr;
-
- hr = DV_E_TYMED;
+ HRESULT result = HRESULT.DV_E_TYMED;
if (GetTymedUseable(formatetc.tymed) && GetTymedUseable(medium.tymed))
{
@@ -1420,7 +1408,7 @@ private int GetDataIntoOleStructs(ref FORMATETC formatetc, ref STGMEDIUM medium,
format = DataFormats.GetDataFormat(formatetc.cfFormat).Name;
// set the default result with DV_E_FORMATETC.
- hr = DV_E_FORMATETC;
+ result = HRESULT.DV_E_FORMATETC;
if (GetDataPresent(format))
{
@@ -1429,78 +1417,76 @@ private int GetDataIntoOleStructs(ref FORMATETC formatetc, ref STGMEDIUM medium,
data = GetData(format);
// set the default result with DV_E_TYMED.
- hr = DV_E_TYMED;
+ result = HRESULT.DV_E_TYMED;
if ((formatetc.tymed & TYMED.TYMED_HGLOBAL) != 0)
{
- hr = GetDataIntoOleStructsByTypeMedimHGlobal(format, data, ref medium, doNotReallocate);
+ result = GetDataIntoOleStructsByTypeMedimHGlobal(format, data, ref medium, doNotReallocate);
}
else if ( ( formatetc.tymed & TYMED.TYMED_GDI ) != 0 )
{
- hr = GetDataIntoOleStructsByTypeMediumGDI(format, data, ref medium);
+ result = GetDataIntoOleStructsByTypeMediumGDI(format, data, ref medium);
}
else if ( ( formatetc.tymed & TYMED.TYMED_ENHMF ) != 0 )
{
- hr = GetDataIntoOleStructsByTypeMediumEnhancedMetaFile(format, data, ref medium);
+ result = GetDataIntoOleStructsByTypeMediumEnhancedMetaFile(format, data, ref medium);
}
else if ( ( formatetc.tymed & TYMED.TYMED_ISTREAM ) != 0 )
{
- hr = GetDataIntoOleStructsByTypeMedimIStream(format, data, ref medium);
+ result = GetDataIntoOleStructsByTypeMedimIStream(format, data, ref medium);
}
}
}
- return hr;
+ return result;
}
///
/// Populates Ole data structes from a dataObject that is TYMED_HGLOBAL.
///
- private int GetDataIntoOleStructsByTypeMedimHGlobal(string format, object data, ref STGMEDIUM medium, bool doNotReallocate)
+ private HRESULT GetDataIntoOleStructsByTypeMedimHGlobal(string format, object data, ref STGMEDIUM medium, bool doNotReallocate)
{
- int hr;
-
- hr = NativeMethods.E_FAIL;
+ HRESULT result = HRESULT.E_FAIL;
if (data is Stream)
{
- hr = SaveStreamToHandle(medium.unionmember, (Stream)data, doNotReallocate);
+ result = SaveStreamToHandle(medium.unionmember, (Stream)data, doNotReallocate);
}
else if (IsFormatEqual(format, DataFormats.Html)
|| IsFormatEqual(format, DataFormats.Xaml))
{
// Save Html and Xaml data string as UTF8 encoding.
- hr = SaveStringToHandleAsUtf8(medium.unionmember, data.ToString(), doNotReallocate);
+ result = SaveStringToHandleAsUtf8(medium.unionmember, data.ToString(), doNotReallocate);
}
else if (IsFormatEqual(format, DataFormats.Text)
|| IsFormatEqual(format, DataFormats.Rtf)
|| IsFormatEqual(format, DataFormats.OemText)
|| IsFormatEqual(format, DataFormats.CommaSeparatedValue))
{
- hr = SaveStringToHandle(medium.unionmember, data.ToString(), false /* unicode */, doNotReallocate);
+ result = SaveStringToHandle(medium.unionmember, data.ToString(), false /* unicode */, doNotReallocate);
}
else if (IsFormatEqual(format, DataFormats.UnicodeText)||
IsFormatEqual(format, DataFormats.ApplicationTrust))
{
- hr = SaveStringToHandle(medium.unionmember, data.ToString(), true /* unicode */, doNotReallocate);
+ result = SaveStringToHandle(medium.unionmember, data.ToString(), true /* unicode */, doNotReallocate);
}
else if (IsFormatEqual(format, DataFormats.FileDrop))
{
- hr = SaveFileListToHandle(medium.unionmember, (string[])data, doNotReallocate);
+ result = SaveFileListToHandle(medium.unionmember, (string[])data, doNotReallocate);
}
else if (IsFormatEqual(format, DataFormats.FileName))
{
string[] filelist;
filelist = (string[])data;
- hr = SaveStringToHandle(medium.unionmember, filelist[0], false /* unicode */, doNotReallocate);
+ result = SaveStringToHandle(medium.unionmember, filelist[0], false /* unicode */, doNotReallocate);
}
else if (IsFormatEqual(format, DataFormats.FileNameW))
{
string[] filelist;
filelist = (string[])data;
- hr = SaveStringToHandle(medium.unionmember, filelist[0], true /* unicode */, doNotReallocate);
+ result = SaveStringToHandle(medium.unionmember, filelist[0], true /* unicode */, doNotReallocate);
}
else if (IsFormatEqual(format, DataFormats.Dib)
&& SystemDrawingHelper.IsImage(data))
@@ -1508,65 +1494,64 @@ private int GetDataIntoOleStructsByTypeMedimHGlobal(string format, object data,
// GDI+ does not properly handle saving to DIB images. Since the
// clipboard will take an HBITMAP and publish a Dib, we don't need
// to support this.
- //
- hr = DV_E_TYMED;
+ result = HRESULT.DV_E_TYMED;
}
else if (IsFormatEqual(format, typeof(BitmapSource).FullName))
{
// Save the System.Drawing.Bitmap or BitmapSource data to handle as BitmapSource
- hr = SaveSystemBitmapSourceToHandle(medium.unionmember, data, doNotReallocate);
+ result = SaveSystemBitmapSourceToHandle(medium.unionmember, data, doNotReallocate);
}
else if (IsFormatEqual(format, SystemDrawingBitmapFormat))
{
// Save the System.Drawing.Bitmap or BitmapSource data to handle as System.Drawing.Bitmap
- hr = SaveSystemDrawingBitmapToHandle(medium.unionmember, data, doNotReallocate);
+ result = SaveSystemDrawingBitmapToHandle(medium.unionmember, data, doNotReallocate);
}
else if (IsFormatEqual(format, DataFormats.EnhancedMetafile)
|| SystemDrawingHelper.IsMetafile(data))
{
// We don't need to support the enhanced metafile for TYMED.TYMED_HGLOBAL,
// since we directly support TYMED.TYMED_ENHMF.
- hr = DV_E_TYMED;
+ result = HRESULT.DV_E_TYMED;
}
#pragma warning disable SYSLIB0050
else if (IsFormatEqual(format, DataFormats.Serializable)
|| data is ISerializable
|| (data != null && data.GetType().IsSerializable))
{
- hr = SaveObjectToHandle(medium.unionmember, data, doNotReallocate);
+ result = SaveObjectToHandle(medium.unionmember, data, doNotReallocate);
}
#pragma warning restore SYSLIB0050
else
{
// Couldn't find the proper data for the current TYMED_HGLOBAL
- hr = DV_E_TYMED;
+ result = HRESULT.DV_E_TYMED;
}
- if (hr == NativeMethods.S_OK)
+ if (result == HRESULT.S_OK)
{
medium.tymed = TYMED.TYMED_HGLOBAL;
}
- return hr;
+ return result;
}
///
/// Populates Ole data structes from a dataObject that is TYMED_ISTREAM.
///
- private int GetDataIntoOleStructsByTypeMedimIStream(string format, object data, ref STGMEDIUM medium)
+ private HRESULT GetDataIntoOleStructsByTypeMedimIStream(string format, object data, ref STGMEDIUM medium)
{
IStream istream = (IStream)( Marshal.GetObjectForIUnknown(medium.unionmember) );
if ( istream == null )
{
- return NativeMethods.E_INVALIDARG;
+ return HRESULT.E_INVALIDARG;
}
- int hr = NativeMethods.E_FAIL;
+ HRESULT result = HRESULT.E_FAIL;
try
{
// If the format is ISF, we should copy the data from the managed stream to the COM IStream object.
- if ( format == System.Windows.Ink.StrokeCollection.InkSerializedFormat )
+ if (format == Ink.StrokeCollection.InkSerializedFormat)
{
Stream inkStream = data as Stream;
@@ -1579,7 +1564,7 @@ private int GetDataIntoOleStructsByTypeMedimIStream(string format, object data,
inkStream.ReadExactly(buffer);
istream.Write(buffer, NativeMethods.IntPtrToInt32(size), IntPtr.Zero);
- hr = NativeMethods.S_OK;
+ result = HRESULT.S_OK;
}
}
}
@@ -1588,22 +1573,20 @@ private int GetDataIntoOleStructsByTypeMedimIStream(string format, object data,
Marshal.ReleaseComObject(istream);
}
- if ( NativeMethods.Succeeded(hr) )
+ if (result.Succeeded)
{
medium.tymed = TYMED.TYMED_ISTREAM;
}
- return hr;
+ return result;
}
///
/// Populates Ole data structes from a dataObject that is TYMED_GDI.
///
- private int GetDataIntoOleStructsByTypeMediumGDI(string format, object data, ref STGMEDIUM medium)
+ private HRESULT GetDataIntoOleStructsByTypeMediumGDI(string format, object data, ref STGMEDIUM medium)
{
- int hr;
-
- hr = NativeMethods.E_FAIL;
+ HRESULT result = HRESULT.E_FAIL;
if (IsFormatEqual(format, DataFormats.Bitmap)
&& (SystemDrawingHelper.IsBitmap(data) || IsDataSystemBitmapSource(data)))
@@ -1618,27 +1601,25 @@ private int GetDataIntoOleStructsByTypeMediumGDI(string format, object data, ref
medium.tymed = TYMED.TYMED_GDI;
medium.unionmember = hBitmap;
- hr = NativeMethods.S_OK;
+ result = HRESULT.S_OK;
}
}
else
{
// Couldn't find the proper data for the current TYMED_GDI
- hr = DV_E_TYMED;
+ result = HRESULT.DV_E_TYMED;
}
- return hr;
+ return result;
}
///
/// Populates Ole data structes from a dataObject that is TYMED_ENHMF.
///
- private int GetDataIntoOleStructsByTypeMediumEnhancedMetaFile(string format, object data, ref STGMEDIUM medium)
+ private HRESULT GetDataIntoOleStructsByTypeMediumEnhancedMetaFile(string format, object data, ref STGMEDIUM medium)
{
IntPtr hMetafile;
- int hr;
-
- hr = NativeMethods.E_FAIL;
+ HRESULT result = HRESULT.E_FAIL;
if (IsFormatEqual(format, DataFormats.EnhancedMetafile))
{
@@ -1651,19 +1632,19 @@ private int GetDataIntoOleStructsByTypeMediumEnhancedMetaFile(string format, obj
medium.tymed = TYMED.TYMED_ENHMF;
medium.unionmember = hMetafile;
- hr = NativeMethods.S_OK;
+ result = HRESULT.S_OK;
}
}
else
{
// Couldn't find the proper data for the current TYMED_ENHMF
- hr = DV_E_TYMED;
+ result = HRESULT.DV_E_TYMED;
}
- return hr;
+ return result;
}
#pragma warning disable SYSLIB0011 // Type or member is obsolete
- private int SaveObjectToHandle(IntPtr handle, Object data, bool doNotReallocate)
+ private HRESULT SaveObjectToHandle(IntPtr handle, Object data, bool doNotReallocate)
{
Stream stream;
BinaryWriter binaryWriter;
@@ -1693,6 +1674,7 @@ private int SaveObjectToHandle(IntPtr handle, Object data, bool doNotReallocate)
formatter.Serialize(stream, data);
#pragma warning restore SYSLIB0011 // BinaryFormatter is obsolete
}
+
return SaveStreamToHandle(handle, stream, doNotReallocate);
}
}
@@ -1702,22 +1684,22 @@ private int SaveObjectToHandle(IntPtr handle, Object data, bool doNotReallocate)
///
/// Saves stream out to handle.
///
- private int SaveStreamToHandle(IntPtr handle, Stream stream, bool doNotReallocate)
+ private HRESULT SaveStreamToHandle(IntPtr handle, Stream stream, bool doNotReallocate)
{
IntPtr size;
IntPtr ptr;
if (handle == IntPtr.Zero)
{
- return (NativeMethods.E_INVALIDARG);
+ return HRESULT.E_INVALIDARG;
}
size = (IntPtr)stream.Length;
- int hr = EnsureMemoryCapacity(ref handle, NativeMethods.IntPtrToInt32(size), doNotReallocate);
- if (NativeMethods.Failed(hr))
+ HRESULT result = EnsureMemoryCapacity(ref handle, NativeMethods.IntPtrToInt32(size), doNotReallocate);
+ if (result.Failed)
{
- return hr;
+ return result;
}
ptr = Win32GlobalLock(new HandleRef(this, handle));
@@ -1736,13 +1718,13 @@ private int SaveStreamToHandle(IntPtr handle, Stream stream, bool doNotReallocat
Win32GlobalUnlock(new HandleRef(this, handle));
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// Save the System.Drawing.Bitmap or BitmapSource data to handle as BitmapSource.
///
- private int SaveSystemBitmapSourceToHandle(IntPtr handle, Object data, bool doNotReallocate)
+ private HRESULT SaveSystemBitmapSourceToHandle(IntPtr handle, Object data, bool doNotReallocate)
{
BitmapSource bitmapSource;
Stream bitmapStream;
@@ -1780,7 +1762,7 @@ private int SaveSystemBitmapSourceToHandle(IntPtr handle, Object data, bool doNo
///
/// Save the System.Drawing.Bitmap or BitmapSource data to handle as System.Drawing.Bitmap.
///
- private int SaveSystemDrawingBitmapToHandle(IntPtr handle, Object data, bool doNotReallocate)
+ private HRESULT SaveSystemDrawingBitmapToHandle(IntPtr handle, Object data, bool doNotReallocate)
{
object systemDrawingBitmap = SystemDrawingHelper.GetBitmap(data);
@@ -1792,7 +1774,7 @@ private int SaveSystemDrawingBitmapToHandle(IntPtr handle, Object data, bool doN
///
/// Saves a list of files out to the handle in HDROP format.
///
- private int SaveFileListToHandle(IntPtr handle, string[] files, bool doNotReallocate)
+ private HRESULT SaveFileListToHandle(IntPtr handle, string[] files, bool doNotReallocate)
{
IntPtr currentPtr;
Int32 baseStructSize;
@@ -1802,18 +1784,18 @@ private int SaveFileListToHandle(IntPtr handle, string[] files, bool doNotReallo
if (files == null || files.Length < 1)
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
if (handle == IntPtr.Zero)
{
- return (NativeMethods.E_INVALIDARG);
+ return HRESULT.E_INVALIDARG;
}
if (Marshal.SystemDefaultCharSize == 1)
{
Invariant.Assert(false, "Expected the system default char size to be 2 for Unicode systems.");
- return (NativeMethods.E_INVALIDARG);
+ return HRESULT.E_INVALIDARG;
}
currentPtr = IntPtr.Zero;
@@ -1829,10 +1811,10 @@ private int SaveFileListToHandle(IntPtr handle, string[] files, bool doNotReallo
// Add the extra 2bytes since it is unicode.
sizeInBytes += 2;
- int hr = EnsureMemoryCapacity(ref handle, sizeInBytes, doNotReallocate);
- if (NativeMethods.Failed(hr))
+ HRESULT result = EnsureMemoryCapacity(ref handle, sizeInBytes, doNotReallocate);
+ if (result.Failed)
{
- return hr;
+ return result;
}
basePtr = Win32GlobalLock(new HandleRef(this, handle));
@@ -1884,18 +1866,18 @@ private int SaveFileListToHandle(IntPtr handle, string[] files, bool doNotReallo
Win32GlobalUnlock(new HandleRef(this, handle));
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// Save string to handle. If unicode is set to true
/// then the string is saved as unicode, else it is saves as DBCS.
///
- private int SaveStringToHandle(IntPtr handle, string str, bool unicode, bool doNotReallocate)
+ private HRESULT SaveStringToHandle(IntPtr handle, string str, bool unicode, bool doNotReallocate)
{
if (handle == IntPtr.Zero)
{
- return (NativeMethods.E_INVALIDARG);
+ return HRESULT.E_INVALIDARG;
}
if (unicode)
@@ -1906,10 +1888,10 @@ private int SaveStringToHandle(IntPtr handle, string str, bool unicode, bool doN
byteSize = (str.Length*2 + 2);
- int hr = EnsureMemoryCapacity(ref handle, byteSize, doNotReallocate);
- if (NativeMethods.Failed(hr))
+ HRESULT result = EnsureMemoryCapacity(ref handle, byteSize, doNotReallocate);
+ if (result.Failed)
{
- return hr;
+ return result;
}
ptr = Win32GlobalLock(new HandleRef(this, handle));
@@ -1964,10 +1946,10 @@ private int SaveStringToHandle(IntPtr handle, string str, bool unicode, bool doN
}
// Ensure memory allocation and copy multi byte data with the null terminate
- int hr = EnsureMemoryCapacity(ref handle, pinvokeSize + 1, doNotReallocate);
- if (NativeMethods.Failed(hr))
+ HRESULT result = EnsureMemoryCapacity(ref handle, pinvokeSize + 1, doNotReallocate);
+ if (result.Failed)
{
- return hr;
+ return result;
}
ptr = Win32GlobalLock(new HandleRef(this, handle));
@@ -1990,14 +1972,14 @@ private int SaveStringToHandle(IntPtr handle, string str, bool unicode, bool doN
}
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
/// Save string to handle as UTF8 encoding.
/// Html and Xaml data format will be save as UTF8 encoding.
///
- private int SaveStringToHandleAsUtf8(IntPtr handle, string str, bool doNotReallocate)
+ private HRESULT SaveStringToHandleAsUtf8(IntPtr handle, string str, bool doNotReallocate)
{
IntPtr pointerUtf8;
byte[] utf8Bytes;
@@ -2006,7 +1988,7 @@ private int SaveStringToHandleAsUtf8(IntPtr handle, string str, bool doNotReallo
if (handle == IntPtr.Zero)
{
- return (NativeMethods.E_INVALIDARG);
+ return HRESULT.E_INVALIDARG;
}
// Create UTF8Encoding instance to convert the string to UFT8 from GetBytes.
@@ -2018,10 +2000,10 @@ private int SaveStringToHandleAsUtf8(IntPtr handle, string str, bool doNotReallo
// Create byte array and assign UTF8 encoding.
utf8Bytes = utf8Encoding.GetBytes(str);
- int hr = EnsureMemoryCapacity(ref handle, utf8ByteCount + 1, doNotReallocate);
- if (NativeMethods.Failed(hr))
+ HRESULT result = EnsureMemoryCapacity(ref handle, utf8ByteCount + 1, doNotReallocate);
+ if (result.Failed)
{
- return hr;
+ return result;
}
pointerUtf8 = Win32GlobalLock(new HandleRef(this, handle));
@@ -2045,7 +2027,7 @@ private int SaveStringToHandleAsUtf8(IntPtr handle, string str, bool doNotReallo
Win32GlobalUnlock(new HandleRef(this, handle));
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
@@ -2117,9 +2099,9 @@ private static bool IsFormatEqual(string format1, string format2)
/// If doNotReallocate is false, this method will always realloc the original
/// handle to fit minimumByteCount tightly.
///
- private int EnsureMemoryCapacity(ref IntPtr handle, Int32 minimumByteCount, bool doNotReallocate)
+ private HRESULT EnsureMemoryCapacity(ref IntPtr handle, Int32 minimumByteCount, bool doNotReallocate)
{
- int hr = NativeMethods.S_OK;
+ HRESULT result = HRESULT.S_OK;
if (doNotReallocate)
{
@@ -2127,7 +2109,9 @@ private int EnsureMemoryCapacity(ref IntPtr handle, Int32 minimumByteCount, bool
if (byteCount < minimumByteCount)
{
handle = IntPtr.Zero;
- hr = STG_E_MEDIUMFULL;
+
+ // HRESULT.STG_E_MEDIUMFULL; Replace when added to System.Private.Windows.Core.
+ result = (HRESULT)(-2147286928);
}
}
else
@@ -2140,11 +2124,11 @@ private int EnsureMemoryCapacity(ref IntPtr handle, Int32 minimumByteCount, bool
if (handle == IntPtr.Zero)
{
- hr = NativeMethods.E_OUTOFMEMORY;
+ result = HRESULT.E_OUTOFMEMORY;
}
}
- return hr;
+ return result;
}
///
@@ -2209,15 +2193,6 @@ private static object EnsureBitmapDataFromFormat(string format, bool autoConvert
private const string SystemBitmapSourceFormat = "System.Windows.Media.Imaging.BitmapSource";
private const string SystemDrawingImagingMetafileFormat = "System.Drawing.Imaging.Metafile";
- private const int DV_E_FORMATETC = unchecked((int)0x80040064);
- private const int DV_E_LINDEX = unchecked((int)0x80040068);
- private const int DV_E_TYMED = unchecked((int)0x80040069);
- private const int DV_E_DVASPECT = unchecked((int)0x8004006B);
- private const int OLE_E_NOTRUNNING = unchecked((int)0x80040005);
- private const int OLE_E_ADVISENOTSUPPORTED = unchecked((int)0x80040003);
- private const int DATA_S_SAMEFORMATETC = unchecked((int)0x00040130);
- private const int STG_E_MEDIUMFULL = unchecked((int)0x80030070);
-
// Const integer base size of the file drop list: "4 + 8 + 4 + 4"
private const int FILEDROPBASESIZE = 20;
@@ -2326,12 +2301,12 @@ public int Next(int celt, FORMATETC[] rgelt, int[] pceltFetched)
if (rgelt == null)
{
- return NativeMethods.E_INVALIDARG;
+ return HRESULT.E_INVALIDARG;
}
for (int i = 0; i < celt && _current < _formats.Length; i++)
{
- rgelt[i] = _formats[this._current];
+ rgelt[i] = _formats[_current];
_current++;
fetched++;
}
@@ -2341,7 +2316,7 @@ public int Next(int celt, FORMATETC[] rgelt, int[] pceltFetched)
pceltFetched[0] = fetched;
}
- return (fetched == celt) ? NativeMethods.S_OK : NativeMethods.S_FALSE;
+ return (fetched == celt) ? HRESULT.S_OK : HRESULT.S_FALSE;
}
// IEnumFORMATETC.Skip implementation.
@@ -2350,14 +2325,14 @@ public int Skip(int celt)
// Make sure we don't overflow on the skip.
_current = _current + (int)Math.Min(celt, Int32.MaxValue - _current);
- return (_current < _formats.Length) ? NativeMethods.S_OK : NativeMethods.S_FALSE;
+ return (_current < _formats.Length) ? HRESULT.S_OK : HRESULT.S_FALSE;
}
// IEnumFORMATETC.Reset implementation.
public int Reset()
{
_current = 0;
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
// IEnumFORMATETC.Clone implementation.
@@ -2494,7 +2469,7 @@ public string[] GetFormats(bool autoConvert)
{
retrieved[0] = 0;
- if (enumFORMATETC.Next(1, formatetc, retrieved) == NativeMethods.S_OK && retrieved[0] > 0)
+ if (enumFORMATETC.Next(1, formatetc, retrieved) == HRESULT.S_OK && retrieved[0] > 0)
{
string name;
@@ -2694,7 +2669,7 @@ private Object GetDataFromOleIStream(string format, DVASPECT aspect, int index)
object outData = null;
- if (NativeMethods.S_OK == QueryGetDataInner(ref formatetc))
+ if (HRESULT.S_OK == QueryGetDataInner(ref formatetc))
{
GetDataInner(ref formatetc, out medium);
try
@@ -2866,7 +2841,7 @@ private object GetDataFromOleHGLOBAL(string format, DVASPECT aspect, int index)
data = null;
- if (NativeMethods.S_OK == QueryGetDataInner(ref formatetc))
+ if (HRESULT.S_OK == QueryGetDataInner(ref formatetc))
{
GetDataInner(ref formatetc, out medium);
try
@@ -2923,7 +2898,7 @@ private Object GetDataFromOleOther(string format, DVASPECT aspect, int index)
data = null;
- if (NativeMethods.S_OK == QueryGetDataInner(ref formatetc))
+ if (HRESULT.S_OK == QueryGetDataInner(ref formatetc))
{
GetDataInner(ref formatetc, out medium);
try
@@ -3246,7 +3221,7 @@ private bool GetDataPresentInner(string format, DVASPECT aspect, int index)
hr = QueryGetDataInner(ref formatetc);
- return (hr == NativeMethods.S_OK);
+ return hr == HRESULT.S_OK;
}
private int QueryGetDataInner(ref FORMATETC formatetc)
@@ -3270,7 +3245,7 @@ private IEnumFORMATETC EnumFormatEtcInner(DATADIR dwDirection)
/// We need a separate method to avoid loading the System.Drawing assembly
/// when unnecessary.
///
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private Object GetBitmapSourceFromHbitmap(IntPtr hbitmap)
{
return Imaging.CreateBitmapSourceFromHBitmap(
@@ -3426,7 +3401,7 @@ public string[] GetFormats(bool autoConvert)
dataStoreIndex < entries.Length;
dataStoreIndex++)
{
- if (DataObject.IsFormatAndDataSerializable(cur[mappedFormatIndex], entries[dataStoreIndex].Data))
+ if (IsFormatAndDataSerializable(cur[mappedFormatIndex], entries[dataStoreIndex].Data))
{
if (serializationCheckFailedForThisFunction)
{
@@ -3461,7 +3436,7 @@ public string[] GetFormats(bool autoConvert)
public void SetData(Object data)
{
if (data is ISerializable
- && !this._data.ContainsKey(DataFormats.Serializable))
+ && !_data.ContainsKey(DataFormats.Serializable))
{
SetData(DataFormats.Serializable, data);
}
@@ -3633,7 +3608,7 @@ private void SetData(string format, Object data, bool autoConvert, DVASPECT aspe
DataStoreEntry[] datalist;
dse = new DataStoreEntry(data, autoConvert, aspect, index);
- datalist = (DataStoreEntry[])this._data[format];
+ datalist = (DataStoreEntry[])_data[format];
if (datalist == null)
{
@@ -3649,7 +3624,7 @@ private void SetData(string format, Object data, bool autoConvert, DVASPECT aspe
}
datalist[0] = dse;
- this._data[format] = datalist;
+ _data[format] = datalist;
}
private DataStoreEntry FindDataStoreEntry(string format, DVASPECT aspect, int index)
@@ -3738,10 +3713,10 @@ private class DataStoreEntry
public DataStoreEntry(Object data, bool autoConvert, DVASPECT aspect, int index)
{
- this._data = data;
- this._autoConvert = autoConvert;
- this._aspect = aspect;
- this._index = index;
+ _data = data;
+ _autoConvert = autoConvert;
+ _aspect = aspect;
+ _index = index;
}
#endregion Constructors
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Windows/Win32/Foundation/HResultExtensions.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Windows/Win32/Foundation/HResultExtensions.cs
new file mode 100644
index 00000000000..e946bf93d48
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Windows/Win32/Foundation/HResultExtensions.cs
@@ -0,0 +1,300 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+#nullable enable
+
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Windows.Media;
+using Windows.Win32.System.Diagnostics.Debug;
+
+namespace Windows.Win32.Foundation;
+
+internal static class HResultExtensions
+{
+ ///
+ /// Extended version of that special cases WIC and MIL errors.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal static void ThrowOnFailureExtended(this HRESULT result)
+ {
+ if (!result.Failed)
+ {
+ return;
+ }
+
+ // Separate method to facilitate inlining.
+ result.ThrowOnFailureExtendedPrivate();
+ }
+
+ [DoesNotReturn]
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void ThrowOnFailureExtendedPrivate(this HRESULT result) => throw result.GetExtendedException();
+
+ ///
+ /// Helper that gets gets exceptions with special casing for WIC and MIL errors. Callers should check
+ /// before calling this method.
+ ///
+ internal static Exception GetExtendedException(this HRESULT result)
+ {
+ Debug.Assert(result.Failed);
+
+ if (result.IsNtStatus() && result.ToNtStatus() == NTSTATUS.STATUS_NO_MEMORY)
+ {
+ // We historically threw this.
+#pragma warning disable CA2201 // Do not raise reserved exception types
+ return new OutOfMemoryException();
+#pragma warning restore CA2201
+ }
+
+ // Pass -1 to ignore current IErrorInfo.
+ Exception exception = Marshal.GetExceptionForHR(result, -1)
+ ?? new InvalidOperationException() { HResult = result.Value };
+
+ FACILITY_CODE facility = result.Facility;
+
+ if (facility == FACILITY_CODE.FACILITY_WIN32)
+ {
+ WIN32_ERROR error = (WIN32_ERROR)result.Code;
+
+ return error switch
+ {
+ // This is what WINCODEC_ERR_VALUEOVERFLOW is defined to.
+ WIN32_ERROR.ERROR_ARITHMETIC_OVERFLOW => new OverflowException(SR.Image_Overflow, exception),
+ // Previously checked directly as 0x80070057.
+ WIN32_ERROR.ERROR_INVALID_PARAMETER => new ArgumentException(SR.Media_InvalidArgument, exception),
+ // Previously checked directly as 0x800707db.
+ WIN32_ERROR.ERROR_INVALID_PROFILE => new FileFormatException(null, SR.Image_InvalidColorContext, exception),
+ _ => exception,
+ };
+ }
+ else if (facility == FACILITY_CODE.FACILITY_MEDIASERVER)
+ {
+ if (result == MediaPlayerErrors.NS_E_WMP_LOGON_FAILURE)
+ {
+ return new SecurityException(SR.Media_LogonFailure, exception);
+ }
+ else if (result == MediaPlayerErrors.NS_E_WMP_CANNOT_FIND_FILE)
+ {
+ return new FileNotFoundException(SR.Media_FileNotFound, exception);
+ }
+ else if (result == MediaPlayerErrors.NS_E_WMP_UNSUPPORTED_FORMAT
+ || result == MediaPlayerErrors.NS_E_WMP_DSHOW_UNSUPPORTED_FORMAT)
+ {
+ return new FileFormatException(SR.Media_FileFormatNotSupported, exception);
+ }
+ else if (result == MediaPlayerErrors.NS_E_WMP_INVALID_ASX)
+ {
+ return new FileFormatException(SR.Media_PlaylistFormatNotSupported, exception);
+ }
+ }
+ else if (facility == FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM)
+ {
+ if (result == MilErrors.WGXERR_DISPLAYSTATEINVALID)
+ {
+ return new InvalidOperationException(SR.Image_DisplayStateInvalid, exception);
+ }
+ else if (result == MilErrors.WGXERR_NONINVERTIBLEMATRIX)
+ {
+ return new ArithmeticException(SR.Image_SingularMatrix, exception);
+ }
+ else if (result == MilErrors.WGXERR_AV_INVALIDWMPVERSION)
+ {
+ return new InvalidWmpVersionException(SR.Media_InvalidWmpVersion, exception);
+ }
+ else if (result == MilErrors.WGXERR_AV_INSUFFICIENTVIDEORESOURCES)
+ {
+ return new NotSupportedException(SR.Media_InsufficientVideoResources, exception);
+ }
+ else if (result == MilErrors.WGXERR_AV_VIDEOACCELERATIONNOTAVAILABLE)
+ {
+ return new NotSupportedException(SR.Media_HardwareVideoAccelerationNotAvailable, exception);
+ }
+ else if (result == MilErrors.WGXERR_AV_MEDIAPLAYERCLOSED)
+ {
+ return new NotSupportedException(SR.Media_PlayerIsClosed, exception);
+ }
+ else if (result == MilErrors.WGXERR_BADNUMBER)
+ {
+ return new ArgumentException(SR.Geometry_BadNumber, exception);
+ }
+ else if (result == MilErrors.WGXERR_D3DI_INVALIDSURFACEUSAGE)
+ {
+ return new ArgumentException(SR.D3DImage_InvalidUsage, exception);
+ }
+ else if (result == MilErrors.WGXERR_D3DI_INVALIDSURFACESIZE)
+ {
+ return new ArgumentException(SR.D3DImage_SurfaceTooBig, exception);
+ }
+ else if (result == MilErrors.WGXERR_D3DI_INVALIDSURFACEPOOL)
+ {
+ return new ArgumentException(SR.D3DImage_InvalidPool, exception);
+ }
+ else if (result == MilErrors.WGXERR_D3DI_INVALIDSURFACEDEVICE)
+ {
+ return new ArgumentException(SR.D3DImage_InvalidDevice, exception);
+ }
+ else if (result == MilErrors.WGXERR_D3DI_INVALIDANTIALIASINGSETTINGS)
+ {
+ return new ArgumentException(SR.D3DImage_AARequires9Ex, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_WRONGSTATE)
+ {
+ return new InvalidOperationException(SR.Image_WrongState, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_VALUEOUTOFRANGE)
+ {
+ return new OverflowException(SR.Image_Overflow, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_UNKNOWNIMAGEFORMAT)
+ {
+ return new FileFormatException(null, SR.Image_UnknownFormat, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_UNSUPPORTEDVERSION)
+ {
+ return new FileLoadException(SR.MilErr_UnsupportedVersion, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_NOTINITIALIZED)
+ {
+ return new InvalidOperationException(SR.WIC_NotInitialized, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_PROPERTYNOTFOUND)
+ {
+ return new ArgumentException(SR.Image_PropertyNotFound, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_PROPERTYNOTSUPPORTED)
+ {
+ return new NotSupportedException(SR.Image_PropertyNotSupported, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_PROPERTYSIZE)
+ {
+ return new ArgumentException(SR.Image_PropertySize, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_CODECPRESENT)
+ {
+ return new InvalidOperationException(SR.Image_CodecPresent, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_CODECNOTHUMBNAIL)
+ {
+ return new NotSupportedException(SR.Image_NoThumbnail, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_PALETTEUNAVAILABLE)
+ {
+ return new InvalidOperationException(SR.Image_NoPalette, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_CODECTOOMANYSCANLINES)
+ {
+ return new ArgumentException(SR.Image_TooManyScanlines, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_INTERNALERROR)
+ {
+ return new InvalidOperationException(SR.Image_InternalError, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS)
+ {
+ return new ArgumentException(SR.Image_BadDimensions, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_COMPONENTINITIALIZEFAILURE
+ || result == HRESULT.WINCODEC_ERR_COMPONENTNOTFOUND)
+ {
+ return new NotSupportedException(SR.Image_ComponentNotFound, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_UNEXPECTEDSIZE
+ || result == HRESULT.WINCODEC_ERR_BADIMAGE)
+ {
+ return new FileFormatException(null, SR.Image_DecoderError, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_BADHEADER)
+ {
+ return new FileFormatException(null, SR.Image_HeaderError, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_FRAMEMISSING)
+ {
+ return new ArgumentException(SR.Image_FrameMissing, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_BADMETADATAHEADER)
+ {
+ return new ArgumentException(SR.Image_BadMetadataHeader, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_BADSTREAMDATA)
+ {
+ return new ArgumentException(SR.Image_BadStreamData, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_STREAMWRITE)
+ {
+ return new InvalidOperationException(SR.Image_StreamWrite, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT)
+ {
+ return new NotSupportedException(SR.Image_UnsupportedPixelFormat, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION)
+ {
+ return new NotSupportedException(SR.Image_UnsupportedOperation, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_IMAGESIZEOUTOFRANGE)
+ {
+ return new ArgumentException(SR.Image_SizeOutOfRange, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_STREAMREAD)
+ {
+ return new IOException(SR.Image_StreamRead, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_INVALIDQUERYREQUEST)
+ {
+ return new IOException(SR.Image_InvalidQueryRequest, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_UNEXPECTEDMETADATATYPE)
+ {
+ return new FileFormatException(null, SR.Image_UnexpectedMetadataType, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT)
+ {
+ return new FileFormatException(null, SR.Image_RequestOnlyValidAtMetadataRoot, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_INVALIDQUERYCHARACTER)
+ {
+ return new IOException(SR.Image_InvalidQueryCharacter, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_DUPLICATEMETADATAPRESENT)
+ {
+ return new FileFormatException(null, SR.Image_DuplicateMetadataPresent, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE)
+ {
+ return new FileFormatException(null, SR.Image_PropertyUnexpectedType, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_TOOMUCHMETADATA)
+ {
+ return new FileFormatException(null, SR.Image_TooMuchMetadata, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_STREAMNOTAVAILABLE)
+ {
+ return new NotSupportedException(SR.Image_StreamNotAvailable, exception);
+ }
+ else if (result == HRESULT.WINCODEC_ERR_INSUFFICIENTBUFFER)
+ {
+ return new ArgumentException(SR.Image_InsufficientBuffer, exception);
+ }
+ }
+
+ return exception;
+ }
+
+#pragma warning disable IDE1006 // Naming Styles
+#pragma warning disable format
+
+ // Waiting on WinForms update to get these in HRESULT.
+ internal static class MediaPlayerErrors
+ {
+ internal static readonly HRESULT NS_E_WMP_LOGON_FAILURE = new(unchecked((int)0xC00D1196L));
+ internal static readonly HRESULT NS_E_WMP_CANNOT_FIND_FILE = new(unchecked((int)0xC00D1197L));
+ internal static readonly HRESULT NS_E_WMP_UNSUPPORTED_FORMAT = new(unchecked((int)0xC00D1199L));
+ internal static readonly HRESULT NS_E_WMP_DSHOW_UNSUPPORTED_FORMAT = new(unchecked((int)0xC00D119AL));
+ internal static readonly HRESULT NS_E_WMP_INVALID_ASX = new(unchecked((int)0xC00D119DL));
+ internal static readonly HRESULT NS_E_WMP_URLDOWNLOADFAILED = new(unchecked((int)0xC00D0FEAL));
+ }
+}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs
index 47ab6841795..a548a566ae6 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -19,6 +19,7 @@
using MS.Win32;
using System.Runtime.InteropServices;
using MS.Internal.Documents.Application;
+using Windows.Win32.Foundation;
namespace MS.Internal.AppModel
{
@@ -75,9 +76,9 @@ internal static LaunchResult SafeLaunchBrowserOnlyIfPossible(Uri originatingUri,
{
LaunchResult launched = LaunchResult.NotLaunched;
- bool isKnownScheme = (Object.ReferenceEquals(destinationUri.Scheme, Uri.UriSchemeHttp)) ||
- (Object.ReferenceEquals(destinationUri.Scheme, Uri.UriSchemeHttps)) ||
- destinationUri.IsFile;
+ bool isKnownScheme = ReferenceEquals(destinationUri.Scheme, Uri.UriSchemeHttp)
+ || ReferenceEquals(destinationUri.Scheme, Uri.UriSchemeHttps)
+ || destinationUri.IsFile;
bool fIsMailTo = string.Equals(destinationUri.Scheme, Uri.UriSchemeMailto, StringComparison.OrdinalIgnoreCase);
@@ -185,8 +186,8 @@ private static LaunchResult CanNavigateToUrlWithZoneCheck(Uri originatingUri, Ur
// is this feature enabled ?
fEnabled = UnsafeNativeMethods.CoInternetIsFeatureEnabled(
- NativeMethods.FEATURE_ZONE_ELEVATION,
- NativeMethods.GET_FEATURE_FROM_PROCESS) != NativeMethods.S_FALSE;
+ NativeMethods.FEATURE_ZONE_ELEVATION,
+ NativeMethods.GET_FEATURE_FROM_PROCESS) != HRESULT.S_FALSE;
targetZone = MapUrlToZone(destinationUri);
@@ -300,10 +301,10 @@ private static LaunchResult CheckBlockNavigation(Uri originatingUri, Uri destina
if (fEnabled)
{
if (UnsafeNativeMethods.CoInternetIsFeatureZoneElevationEnabled(
- BindUriHelper.UriToString(originatingUri),
- BindUriHelper.UriToString(destinationUri),
- _secMgr,
- NativeMethods.GET_FEATURE_FROM_PROCESS) == NativeMethods.S_FALSE)
+ BindUriHelper.UriToString(originatingUri),
+ BindUriHelper.UriToString(destinationUri),
+ _secMgr,
+ NativeMethods.GET_FEATURE_FROM_PROCESS) == HRESULT.S_FALSE)
{
return LaunchResult.Launched;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/OleCmdHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/OleCmdHelper.cs
index 14b406d4af1..b98eed41108 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/OleCmdHelper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/OleCmdHelper.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -19,6 +19,9 @@
using MS.Internal.Documents; // DocumentApplicationDocumentViewer
using MS.Internal.KnownBoxes;
using MS.Win32;
+using Standard;
+
+using Windows.Win32.Foundation;
namespace MS.Internal.AppModel
{
@@ -61,7 +64,7 @@ unrecognized commands.
if (Application.Current == null || Application.IsShuttingDown == true)
{
- Marshal.ThrowExceptionForHR(NativeMethods.E_FAIL);
+ HRESULT.E_FAIL.ThrowOnFailure();
}
// Get values from mapping here else mark them as disabled ==>
@@ -71,7 +74,7 @@ unrecognized commands.
IDictionary oleCmdMappingTable = GetOleCmdMappingTable(guidCmdGroup);
if (oleCmdMappingTable == null)
{
- Marshal.ThrowExceptionForHR(OleCmdHelper.OLECMDERR_E_UNKNOWNGROUP);
+ ((HRESULT)OLECMDERR_E_UNKNOWNGROUP).ThrowOnFailure();
}
CommandWithArgument command = oleCmdMappingTable[cmdId] as CommandWithArgument;
if (command == null)
@@ -110,7 +113,7 @@ internal void ExecCommand(Guid guidCmdGroup, uint commandId, object arg)
{
if (Application.Current == null || Application.IsShuttingDown == true)
{
- Marshal.ThrowExceptionForHR(NativeMethods.E_FAIL);
+ HRESULT.E_FAIL.ThrowOnFailure();
}
int hresult = (int)Application.Current.Dispatcher.Invoke(
@@ -148,7 +151,8 @@ private object ExecCommandCallback(object arguments)
// This will always succeed because Window is IInputElement
target = (IInputElement)Application.Current.MainWindow;
}
- return command.Execute(target, arg) ? NativeMethods.S_OK : OLECMDERR_E_DISABLED;
+
+ return command.Execute(target, arg) ? HRESULT.S_OK : OLECMDERR_E_DISABLED;
}
private IDictionary GetOleCmdMappingTable(Guid guidCmdGroup)
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ProgressPage.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ProgressPage.cs
index 3be58d9322b..143553ae221 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ProgressPage.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ProgressPage.cs
@@ -1,6 +1,5 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
//
// Description:
@@ -11,9 +10,7 @@
using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.Windows.Threading;
-
-// Disambiguate MS.Internal.HRESULT...
-using HR = MS.Internal.Interop.HRESULT;
+using Windows.Win32.Foundation;
namespace MS.Internal.AppModel
{
@@ -22,17 +19,17 @@ namespace MS.Internal.AppModel
interface INativeProgressPage
{
[PreserveSig]
- HR Show();
+ HRESULT Show();
[PreserveSig]
- HR Hide();
+ HRESULT Hide();
[PreserveSig]
- HR ShowProgressMessage(string message);
+ HRESULT ShowProgressMessage(string message);
[PreserveSig]
- HR SetApplicationName(string appName);
+ HRESULT SetApplicationName(string appName);
[PreserveSig]
- HR SetPublisherName(string publisherName);
+ HRESULT SetPublisherName(string publisherName);
[PreserveSig]
- HR OnDownloadProgress(ulong bytesDownloaded, ulong bytesTotal);
+ HRESULT OnDownloadProgress(ulong bytesDownloaded, ulong bytesTotal);
};
///
@@ -54,13 +51,13 @@ internal NativeProgressPageProxy(INativeProgressPage npp)
public void ShowProgressMessage(string message)
{
// Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up.
- HR hr = _npp.ShowProgressMessage(message);
+ _ = _npp.ShowProgressMessage(message);
}
public Uri DeploymentPath
{
set { }
- get { throw new System.NotImplementedException(); }
+ get { throw new NotImplementedException(); }
}
///
@@ -70,14 +67,14 @@ public Uri DeploymentPath
public DispatcherOperationCallback StopCallback
{
set { }
- get { throw new System.NotImplementedException(); }
+ get { throw new NotImplementedException(); }
}
///
/// The native progress page sends a Refresh request to its host object, which then calls
/// IBrowserHostServices.ExecCommand(OLECMDID_REFRESH).
///
- public System.Windows.Threading.DispatcherOperationCallback RefreshCallback
+ public DispatcherOperationCallback RefreshCallback
{
set { }
get { return null; }
@@ -88,10 +85,10 @@ public string ApplicationName
set
{
// Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up.
- HR hr = _npp.SetApplicationName(value);
+ _ = _npp.SetApplicationName(value);
}
- get { throw new System.NotImplementedException(); }
+ get { throw new NotImplementedException(); }
}
///
@@ -105,7 +102,7 @@ public string PublisherName
set
{
// Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up.
- HR hr = _npp.SetPublisherName(value);
+ _ = _npp.SetPublisherName(value);
}
get { throw new System.NotImplementedException(); }
@@ -117,7 +114,7 @@ public string PublisherName
public void UpdateProgress(long bytesDownloaded, long bytesTotal)
{
// Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up.
- HR hr = _npp.OnDownloadProgress((ulong)bytesDownloaded, (ulong)bytesTotal);
+ _ = _npp.OnDownloadProgress((ulong)bytesDownloaded, (ulong)bytesTotal);
}
INativeProgressPage _npp;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs
index 01987ea9e74..b7ce88c0a69 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -7,6 +7,7 @@
using System.Text;
using MS.Win32;
using MS.Internal.Interop;
+using Windows.Win32.Foundation;
// Some COM interfaces and Win32 structures are already declared in the framework.
// Interesting ones to remember in System.Runtime.InteropServices.ComTypes are:
@@ -16,11 +17,6 @@
namespace MS.Internal.AppModel
{
- // There are THREE definitions of HRESULT. Two in ErrorCodes, and one in wgx_render.cs.
- // wgx_render.cs wins if we don't put this inside of the namespace.
- using Win32Error = MS.Internal.Interop.Win32Error;
- using HRESULT = MS.Internal.Interop.HRESULT;
-
#region Structs
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
@@ -964,17 +960,18 @@ public static IShellItem2 GetShellItemForPath(string path)
Guid iidShellItem2 = new Guid(IID.ShellItem2);
object unk;
- HRESULT hr = NativeMethods2.SHCreateItemFromParsingName(path, null, ref iidShellItem2, out unk);
+ HRESULT result = NativeMethods2.SHCreateItemFromParsingName(path, null, ref iidShellItem2, out unk);
// Silently absorb errors such as ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND.
// Let others pass through
- if (hr == (HRESULT)Win32Error.ERROR_FILE_NOT_FOUND || hr == (HRESULT)Win32Error.ERROR_PATH_NOT_FOUND)
+ if (result == HRESULT.FromWin32(WIN32_ERROR.ERROR_FILE_NOT_FOUND)
+ || result == HRESULT.FromWin32(WIN32_ERROR.ERROR_PATH_NOT_FOUND))
{
- hr = HRESULT.S_OK;
+ result = HRESULT.S_OK;
unk = null;
}
- hr.ThrowIfFailed();
+ result.ThrowOnFailureUnwrapWin32();
return (IShellItem2)unk;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXContainer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXContainer.cs
index 395c152e716..40f32c568af 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXContainer.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXContainer.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -11,6 +11,7 @@
using System.Windows.Interop;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.Controls
{
@@ -25,7 +26,7 @@ internal class ActiveXContainer : UnsafeNativeMethods.IOleContainer, UnsafeNativ
internal ActiveXContainer(ActiveXHost host)
{
- this._host = host;
+ _host = host;
Invariant.Assert(_host != null);
}
@@ -50,7 +51,7 @@ int UnsafeNativeMethods.IOleContainer.ParseDisplayName(Object pbc, string pszDis
if (ppmkOut != null)
ppmkOut[0] = null;
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleContainer.EnumObjects(int grfFlags, out UnsafeNativeMethods.IEnumUnknown ppenum)
@@ -73,16 +74,16 @@ int UnsafeNativeMethods.IOleContainer.EnumObjects(int grfFlags, out UnsafeNative
Object[] temp = new Object[1];
temp[0] = ax;
ppenum = new EnumUnknown(temp);
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
ppenum = new EnumUnknown(null);
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleContainer.LockContainer(bool fLock)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
#endregion IOleContainer
@@ -100,22 +101,22 @@ IntPtr UnsafeNativeMethods.IOleInPlaceFrame.GetWindow()
int UnsafeNativeMethods.IOleInPlaceFrame.ContextSensitiveHelp(int fEnterMode)
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceFrame.GetBorder(NativeMethods.COMRECT lprectBorder)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleInPlaceFrame.RequestBorderSpace(NativeMethods.COMRECT pborderwidths)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleInPlaceFrame.SetBorderSpace(NativeMethods.COMRECT pborderwidths)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleInPlaceFrame.SetActiveObject(UnsafeNativeMethods.IOleInPlaceActiveObject pActiveObject, string pszObjName)
@@ -152,37 +153,37 @@ int UnsafeNativeMethods.IOleInPlaceFrame.SetActiveObject(UnsafeNativeMethods.IOl
}
*/
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceFrame.InsertMenus(IntPtr hmenuShared, NativeMethods.tagOleMenuGroupWidths lpMenuWidths)
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceFrame.SetMenu(IntPtr hmenuShared, IntPtr holemenu, IntPtr hwndActiveObject)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleInPlaceFrame.RemoveMenus(IntPtr hmenuShared)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleInPlaceFrame.SetStatusText(string pszStatusText)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleInPlaceFrame.EnableModeless(bool fEnable)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleInPlaceFrame.TranslateAccelerator(ref MSG lpmsg, short wID)
{
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
#endregion IOleInPlaceFrame
@@ -214,7 +215,7 @@ internal void OnUIDeactivate(ActiveXHost site)
#if DEBUG
if (_siteUIActive != null) {
//TODO: Debug.Assert(_siteUIActive == site, "deactivating when not active...");
- Debug.Assert(this.ActiveXHost == site, "deactivating when not active...");
+ Debug.Assert(ActiveXHost == site, "deactivating when not active...");
}
#endif // DEBUG
@@ -227,7 +228,7 @@ internal void OnUIDeactivate(ActiveXHost site)
internal void OnInPlaceDeactivate(ActiveXHost site)
{
//TODO: Clear the focus here too?
- if (this.ActiveXHost == site)
+ if (ActiveXHost == site)
{
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXSite.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXSite.cs
index 1b3f7d9e187..39dec9f7d1d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXSite.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXSite.cs
@@ -1,12 +1,12 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.Controls
{
@@ -44,18 +44,18 @@ internal ActiveXSite(ActiveXHost host)
#region IOleControlSite
int UnsafeNativeMethods.IOleControlSite.OnControlInfoChanged()
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleControlSite.LockInPlaceActive(int fLock)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleControlSite.GetExtendedControl(out object ppDisp)
{
ppDisp = null;
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleControlSite.TransformCoords(ref NativeMethods.POINT pPtlHimetric, ref NativeMethods.POINTF pPtfContainer, int dwFlags)
@@ -74,7 +74,7 @@ int UnsafeNativeMethods.IOleControlSite.TransformCoords(ref NativeMethods.POINT
}
else
{
- return NativeMethods.E_INVALIDARG;
+ return HRESULT.E_INVALIDARG;
}
}
else if ((dwFlags & NativeMethods.XFORMCOORDS_CONTAINERTOHIMETRIC) != 0)
@@ -91,15 +91,15 @@ int UnsafeNativeMethods.IOleControlSite.TransformCoords(ref NativeMethods.POINT
}
else
{
- return NativeMethods.E_INVALIDARG;
+ return HRESULT.E_INVALIDARG;
}
}
else
{
- return NativeMethods.E_INVALIDARG;
+ return HRESULT.E_INVALIDARG;
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
@@ -117,7 +117,7 @@ int UnsafeNativeMethods.IOleControlSite.TranslateAccelerator(ref MSG pMsg, int g
try {
bool f = ((Control)this.Host).PreProcessMessage(ref msg);
- return f ? NativeMethods.S_OK : NativeMethods.S_FALSE;
+ return f ? HRESULT.S_OK : HRESULT.S_FALSE;
}
finally {
this.Host.SetAxHostState(AxHostHelper.siteProcessedInputKey, false);
@@ -126,17 +126,17 @@ int UnsafeNativeMethods.IOleControlSite.TranslateAccelerator(ref MSG pMsg, int g
// This is called by IOleInPlaceActiveObject::TranslateAccelerator.
// returning S_FALSE means we don't process the messages. Let the webbrowser control handle it.
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
int UnsafeNativeMethods.IOleControlSite.OnFocus(int fGotFocus)
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleControlSite.ShowPropertyFrame()
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
#endregion IOleControlSite
@@ -148,52 +148,52 @@ int UnsafeNativeMethods.IOleControlSite.ShowPropertyFrame()
int UnsafeNativeMethods.IOleClientSite.SaveObject()
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleClientSite.GetMoniker(int dwAssign, int dwWhichMoniker, out Object moniker)
{
moniker = null;
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleClientSite.GetContainer(out UnsafeNativeMethods.IOleContainer container)
{
- container = this.Host.Container;
- return NativeMethods.S_OK;
+ container = Host.Container;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleClientSite.ShowObject()
{
if (HostState >= ActiveXHelper.ActiveXState.InPlaceActive)
{
IntPtr hwnd;
- if (NativeMethods.Succeeded(this.Host.ActiveXInPlaceObject.GetWindow(out hwnd)))
+ if (Host.ActiveXInPlaceObject.GetWindow(out hwnd).Succeeded)
{
- if (this.Host.ControlHandle.Handle != hwnd)
+ if (Host.ControlHandle.Handle != hwnd)
{
if (hwnd != IntPtr.Zero)
{
- this.Host.AttachWindow(hwnd);
- this.OnActiveXRectChange(this.Host.Bounds);
+ Host.AttachWindow(hwnd);
+ OnActiveXRectChange(Host.Bounds);
}
}
}
- else if (this.Host.ActiveXInPlaceObject is UnsafeNativeMethods.IOleInPlaceObjectWindowless)
+ else if (Host.ActiveXInPlaceObject is UnsafeNativeMethods.IOleInPlaceObjectWindowless)
{
throw new InvalidOperationException(SR.AxWindowlessControl);
}
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleClientSite.OnShowWindow(int fShow)
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleClientSite.RequestNewObjectLayout()
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
#endregion IOleClientSite
@@ -207,7 +207,7 @@ IntPtr UnsafeNativeMethods.IOleInPlaceSite.GetWindow()
{
try
{
- return this.Host.ParentHandle.Handle;
+ return Host.ParentHandle.Handle;
}
catch (Exception t)
{
@@ -218,12 +218,12 @@ IntPtr UnsafeNativeMethods.IOleInPlaceSite.GetWindow()
int UnsafeNativeMethods.IOleInPlaceSite.ContextSensitiveHelp(int fEnterMode)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IOleInPlaceSite.CanInPlaceActivate()
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceSite.OnInPlaceActivate()
@@ -231,55 +231,55 @@ int UnsafeNativeMethods.IOleInPlaceSite.OnInPlaceActivate()
HostState = ActiveXHelper.ActiveXState.InPlaceActive;
if (!HostBounds.IsEmpty)
{
- this.OnActiveXRectChange(HostBounds);
+ OnActiveXRectChange(HostBounds);
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceSite.OnUIActivate()
{
HostState = ActiveXHelper.ActiveXState.UIActive;
- this.Host.Container.OnUIActivate(this.Host);
- return NativeMethods.S_OK;
+ Host.Container.OnUIActivate(Host);
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceSite.GetWindowContext(out UnsafeNativeMethods.IOleInPlaceFrame ppFrame, out UnsafeNativeMethods.IOleInPlaceUIWindow ppDoc,
NativeMethods.COMRECT lprcPosRect, NativeMethods.COMRECT lprcClipRect, NativeMethods.OLEINPLACEFRAMEINFO lpFrameInfo)
{
ppDoc = null;
- ppFrame = this.Host.Container;
+ ppFrame = Host.Container;
- lprcPosRect.left = (int)this.Host.Bounds.left;
- lprcPosRect.top = (int)this.Host.Bounds.top;
- lprcPosRect.right = (int)this.Host.Bounds.right;
- lprcPosRect.bottom = (int)this.Host.Bounds.bottom;
+ lprcPosRect.left = (int)Host.Bounds.left;
+ lprcPosRect.top = (int)Host.Bounds.top;
+ lprcPosRect.right = (int)Host.Bounds.right;
+ lprcPosRect.bottom = (int)Host.Bounds.bottom;
- lprcClipRect = this.Host.Bounds;
+ lprcClipRect = Host.Bounds;
if (lpFrameInfo != null)
{
lpFrameInfo.cb = (uint)Marshal.SizeOf(typeof(NativeMethods.OLEINPLACEFRAMEINFO));
lpFrameInfo.fMDIApp = false;
lpFrameInfo.hAccel = IntPtr.Zero;
lpFrameInfo.cAccelEntries = 0;
- lpFrameInfo.hwndFrame = this.Host.ParentHandle.Handle;
+ lpFrameInfo.hwndFrame = Host.ParentHandle.Handle;
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceSite.Scroll(NativeMethods.SIZE scrollExtant)
{
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
int UnsafeNativeMethods.IOleInPlaceSite.OnUIDeactivate(int fUndoable)
{
- this.Host.Container.OnUIDeactivate(this.Host);
+ Host.Container.OnUIDeactivate(Host);
if (HostState > ActiveXHelper.ActiveXState.InPlaceActive)
{
HostState = ActiveXHelper.ActiveXState.InPlaceActive;
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceSite.OnInPlaceDeactivate()
@@ -289,24 +289,24 @@ int UnsafeNativeMethods.IOleInPlaceSite.OnInPlaceDeactivate()
((UnsafeNativeMethods.IOleInPlaceSite)this).OnUIDeactivate(0);
}
- this.Host.Container.OnInPlaceDeactivate(this.Host);
+ Host.Container.OnInPlaceDeactivate(Host);
HostState = ActiveXHelper.ActiveXState.Running;
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceSite.DiscardUndoState()
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IOleInPlaceSite.DeactivateAndUndo()
{
- return this.Host.ActiveXInPlaceObject.UIDeactivate();
+ return Host.ActiveXInPlaceObject.UIDeactivate();
}
int UnsafeNativeMethods.IOleInPlaceSite.OnPosRectChange(NativeMethods.COMRECT lprcPosRect)
{
- return this.OnActiveXRectChange(lprcPosRect);
+ return OnActiveXRectChange(lprcPosRect);
}
#endregion IOleInPlaceSite
@@ -316,11 +316,11 @@ ActiveXHelper.ActiveXState HostState
{
get
{
- return this.Host.ActiveXState;
+ return Host.ActiveXState;
}
set
{
- this.Host.ActiveXState = value;
+ Host.ActiveXState = value;
}
}
@@ -328,7 +328,7 @@ internal NativeMethods.COMRECT HostBounds
{
get
{
- return this.Host.Bounds;
+ return Host.Bounds;
}
}
@@ -365,7 +365,7 @@ void UnsafeNativeMethods.IPropertyNotifySink.OnChanged(int dispid)
int UnsafeNativeMethods.IPropertyNotifySink.OnRequestEdit(int dispid)
{
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
#endregion IPropertyNotifySink
@@ -433,7 +433,7 @@ internal void StartEvents()
if (_connectionPoint != null)
return;
- Object nativeObject = this.Host.ActiveXInstance;
+ Object nativeObject = Host.ActiveXInstance;
if (nativeObject != null)
{
try
@@ -461,16 +461,16 @@ internal void StopEvents()
internal int OnActiveXRectChange(NativeMethods.COMRECT lprcPosRect)
{
- if (this.Host.ActiveXInPlaceObject != null)
+ if (Host.ActiveXInPlaceObject != null)
{
- this.Host.ActiveXInPlaceObject.SetObjectRects(
+ Host.ActiveXInPlaceObject.SetObjectRects(
lprcPosRect,
lprcPosRect); //Same clip rect
- this.Host.Bounds = lprcPosRect;
+ Host.Bounds = lprcPosRect;
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
#endregion Internal Methods
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ConnectionPointCookie.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ConnectionPointCookie.cs
index f9998b07633..e0258e47f09 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ConnectionPointCookie.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ConnectionPointCookie.cs
@@ -1,10 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
using System.Windows;
using MS.Win32;
+using Windows.Win32.Foundation;
// Since we disable PreSharp warnings in this file, PreSharp warning is unknown to C# compiler.
// We first need to disable warnings about unknown message numbers and unknown pragmas.
@@ -30,7 +31,7 @@ internal ConnectionPointCookie(object source, object sink, Type eventInterface)
try
{
Guid tmp = eventInterface.GUID;
- if (cpc.FindConnectionPoint(ref tmp, out connectionPoint) != NativeMethods.S_OK)
+ if (cpc.FindConnectionPoint(ref tmp, out connectionPoint) != HRESULT.S_OK)
{
connectionPoint = null;
}
@@ -58,7 +59,7 @@ internal ConnectionPointCookie(object source, object sink, Type eventInterface)
else
{
int hr = connectionPoint.Advise(sink, ref cookie);
- if (hr != NativeMethods.S_OK)
+ if (hr != HRESULT.S_OK)
{
cookie = 0;
Marshal.FinalReleaseComObject(connectionPoint);
@@ -122,7 +123,7 @@ internal void Disconnect()
try
{
- System.Runtime.InteropServices.Marshal.FinalReleaseComObject(connectionPoint);
+ Marshal.FinalReleaseComObject(connectionPoint);
}
catch (Exception ex)
{
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/EnumUnknown.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/EnumUnknown.cs
index da041e9ca32..d947a52b50c 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/EnumUnknown.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/EnumUnknown.cs
@@ -1,21 +1,18 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-// Description: Helper object implementing IEnumUnknown for enumerating controls
-//
-// Source copied from AxContainer.cs
-//
using System.Runtime.InteropServices;
-
using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.Controls
{
#region class EnumUnknown
+ ///
+ /// Helper object implementing IEnumUnknown for enumerating controls.
+ /// Source copied from AxContainer.cs
+ ///
internal class EnumUnknown : UnsafeNativeMethods.IEnumUnknown
{
private Object[] arr;
@@ -25,8 +22,8 @@ internal class EnumUnknown : UnsafeNativeMethods.IEnumUnknown
internal EnumUnknown(Object[] arr)
{
this.arr = arr;
- this.loc = 0;
- this.size = (arr == null) ? 0 : arr.Length;
+ loc = 0;
+ size = (arr == null) ? 0 : arr.Length;
}
private EnumUnknown(Object[] arr, int loc)
@@ -42,21 +39,21 @@ unsafe int UnsafeNativeMethods.IEnumUnknown.Next(int celt, IntPtr rgelt, IntPtr
if (celt < 0)
{
- return NativeMethods.E_INVALIDARG;
+ return HRESULT.E_INVALIDARG;
}
int fetched = 0;
- if (this.loc >= this.size)
+ if (loc >= size)
{
fetched = 0;
}
else
{
- for (; this.loc < this.size && fetched < celt; ++(this.loc))
+ for (; loc < size && fetched < celt; ++(loc))
{
- if (this.arr[this.loc] != null)
+ if (arr[loc] != null)
{
- Marshal.WriteIntPtr(rgelt, Marshal.GetIUnknownForObject(this.arr[this.loc]));
+ Marshal.WriteIntPtr(rgelt, Marshal.GetIUnknownForObject(arr[loc]));
rgelt = (IntPtr)((long)rgelt + (long)sizeof(IntPtr));
++fetched;
}
@@ -68,29 +65,29 @@ unsafe int UnsafeNativeMethods.IEnumUnknown.Next(int celt, IntPtr rgelt, IntPtr
if (fetched != celt)
{
- return (NativeMethods.S_FALSE);
+ return (HRESULT.S_FALSE);
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IEnumUnknown.Skip(int celt)
{
- this.loc += celt;
- if (this.loc >= this.size)
+ loc += celt;
+ if (loc >= size)
{
- return (NativeMethods.S_FALSE);
+ return (HRESULT.S_FALSE);
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
void UnsafeNativeMethods.IEnumUnknown.Reset()
{
- this.loc = 0;
+ loc = 0;
}
void UnsafeNativeMethods.IEnumUnknown.Clone(out UnsafeNativeMethods.IEnumUnknown ppenum)
{
- ppenum = new EnumUnknown(this.arr, this.loc);
+ ppenum = new EnumUnknown(arr, loc);
}
}
#endregion class EnumUnknown
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/WebBrowserSite.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/WebBrowserSite.cs
index 37e365d1550..fc3313db239 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/WebBrowserSite.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/WebBrowserSite.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -17,6 +17,7 @@
using System.Windows.Input;
using System.Windows.Threading;
using System.Threading;
+using Windows.Win32.Foundation;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
@@ -65,7 +66,7 @@ int UnsafeNativeMethods.IDocHostUIHandler.ShowContextMenu(int dwID, ref NativeMe
// i.e., execute the shortcut key. Returning S_OK will cancel the context menu
//
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
int UnsafeNativeMethods.IDocHostUIHandler.GetHostInfo(NativeMethods.DOCHOSTUIINFO info)
@@ -89,13 +90,13 @@ int UnsafeNativeMethods.IDocHostUIHandler.GetHostInfo(NativeMethods.DOCHOSTUIINF
NativeMethods.DOCHOSTUIFLAG.ENABLE_REDIRECT_NOTIFICATION |
NativeMethods.DOCHOSTUIFLAG.NO3DOUTERBORDER);
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
int UnsafeNativeMethods.IDocHostUIHandler.EnableModeless(bool fEnable)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
@@ -103,36 +104,36 @@ int UnsafeNativeMethods.IDocHostUIHandler.ShowUI(int dwID, UnsafeNativeMethods.I
NativeMethods.IOleCommandTarget commandTarget, UnsafeNativeMethods.IOleInPlaceFrame frame,
UnsafeNativeMethods.IOleInPlaceUIWindow doc)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.HideUI()
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.UpdateUI()
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.OnDocWindowActivate(bool fActivate)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.OnFrameWindowActivate(bool fActivate)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.ResizeBorder(NativeMethods.COMRECT rect, UnsafeNativeMethods.IOleInPlaceUIWindow doc, bool fFrameWindow)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.GetOptionKeyPath(string[] pbstrKey, int dw)
{
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.GetDropTarget(UnsafeNativeMethods.IOleDropTarget pDropTarget, out UnsafeNativeMethods.IOleDropTarget ppDropTarget)
@@ -141,7 +142,7 @@ int UnsafeNativeMethods.IDocHostUIHandler.GetDropTarget(UnsafeNativeMethods.IOle
// Set to null no matter what we return, to prevent the marshaller
// from behaving erroneously if the pointer points to random stuff.
ppDropTarget = null;
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
///
@@ -152,7 +153,7 @@ int UnsafeNativeMethods.IDocHostUIHandler.GetExternal(out object ppDispatch)
{
WebBrowser wb = (WebBrowser)Host;
ppDispatch = wb.HostingAdaptor.ObjectForScripting;
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
@@ -173,13 +174,13 @@ int UnsafeNativeMethods.IDocHostUIHandler.TranslateAccelerator(ref System.Window
if (msg.message != WindowMessage.WM_CHAR
&& Enum.IsDefined(typeof(Shortcut), (Shortcut)keyCode)) {
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
*/
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
int UnsafeNativeMethods.IDocHostUIHandler.TranslateUrl(int dwTranslate, string strUrlIn, out string pstrUrlOut)
@@ -188,7 +189,7 @@ int UnsafeNativeMethods.IDocHostUIHandler.TranslateUrl(int dwTranslate, string s
// Set to null no matter what we return, to prevent the marshaller
// from behaving erroneously if the pointer points to random stuff.
pstrUrlOut = null;
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.FilterDataObject(IComDataObject pDO, out IComDataObject ppDORet)
@@ -197,7 +198,7 @@ int UnsafeNativeMethods.IDocHostUIHandler.FilterDataObject(IComDataObject pDO, o
// Set to null no matter what we return, to prevent the marshaller
// from behaving erroneously if the pointer points to random stuff.
ppDORet = null;
- return NativeMethods.E_NOTIMPL;
+ return HRESULT.E_NOTIMPL;
}
#endregion
@@ -214,9 +215,9 @@ int UnsafeNativeMethods.IOleControlSite.TranslateAccelerator(ref MSG msg, int gr
// For the WebOCHostedInBrowserProcess case, we need to switch to the right thread.
Host.Dispatcher.Invoke(
DispatcherPriority.Send, new SendOrPostCallback(MoveFocusCallback), direction);
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
private void MoveFocusCallback(object direction)
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/DataStreams.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/DataStreams.cs
index 93de5d6ac3c..c836135964c 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/DataStreams.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/DataStreams.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -105,7 +105,7 @@ private ArrayList SaveSubStreams(UIElement element)
// These properties should not be journaled.
// There should be a better way to do this, maybe FrameworkPropertyMetadata.CausesNavigation?
// Or maybe the Source property should be on INavigatorHost
- if (object.ReferenceEquals(localValueEntry.Property, Frame.SourceProperty))
+ if (ReferenceEquals(localValueEntry.Property, Frame.SourceProperty))
continue;
if (subStreams == null)
@@ -132,10 +132,10 @@ private ArrayList SaveSubStreams(UIElement element)
Debug.Fail($"Unexpected exception writing binary formatted data. {ex.Message}");
}
- if(!success)
+ if (!success)
{
#pragma warning disable SYSLIB0011 // BinaryFormatter is obsolete
- this.Formatter.Serialize(byteStream, currentValue);
+ Formatter.Serialize(byteStream, currentValue);
#pragma warning restore SYSLIB0011 // BinaryFormatter is obsolete
}
@@ -171,7 +171,7 @@ private void SaveState(object node)
if (persistId != 0)
{
- ArrayList subStreams = this.SaveSubStreams(element);
+ ArrayList subStreams = SaveSubStreams(element);
if (subStreams != null)
{
//
@@ -266,7 +266,7 @@ private void LoadSubStreams(UIElement element, ArrayList subStreams)
{
dataStream.Position = 0;
#pragma warning disable SYSLIB0011 // BinaryFormatter is obsolete
- newValue = this.Formatter.Deserialize(dataStream);
+ newValue = Formatter.Deserialize(dataStream);
#pragma warning restore SYSLIB0011 // BinaryFormatter is obsolete
}
@@ -291,10 +291,10 @@ private void LoadState(object node)
// Due to bug 1282529, PersistId can be null. Only XAML/BAML-loaded elements have it.
if (persistId != 0)
{
- if (this.HasSubStreams(persistId))
+ if (HasSubStreams(persistId))
{
// Get the properties to restore
- ArrayList properties = this.GetSubStreams(persistId);
+ ArrayList properties = GetSubStreams(persistId);
LoadSubStreams(element, properties);
}
@@ -366,14 +366,14 @@ internal void Save(Object root)
{
_subStreams.Clear();
}
- WalkLogicalTree(root, new NodeOperation(this.SaveState));
+ WalkLogicalTree(root, new NodeOperation(SaveState));
}
internal void Load(Object root)
{
- if (this.HasAnyData)
+ if (HasAnyData)
{
- WalkLogicalTree(root, new NodeOperation(this.LoadState));
+ WalkLogicalTree(root, new NodeOperation(LoadState));
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XmlGlyphRunInfo.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XmlGlyphRunInfo.cs
index 74d0caa241f..32f0ca7dc85 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XmlGlyphRunInfo.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XmlGlyphRunInfo.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -57,8 +57,8 @@ internal XmlGlyphRunInfo(XmlNode glyphsNode)
/// The point is given in page coordinates.
/// double.NaN can be returned in either coordinate when the input glyph run is invalid.
///
- internal override Windows.Point StartPosition
- {
+ internal override Point StartPosition
+ {
get
{
throw new NotSupportedException(SR.XmlGlyphRunInfoIsNonGraphic);
@@ -73,8 +73,8 @@ internal override Windows.Point StartPosition
/// The point is given in page coordinates.
/// double.NaN can be returned in either coordinate when the input glyph run is invalid.
///
- internal override Windows.Point EndPosition
- {
+ internal override Point EndPosition
+ {
get
{
throw new NotSupportedException(SR.XmlGlyphRunInfoIsNonGraphic);
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XpsFilter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XpsFilter.cs
index f45de9fd061..59a48291de7 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XpsFilter.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XpsFilter.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -20,6 +20,8 @@
using MS.Win32;
using MS.Internal.Interop; // For STAT_CHUNK, etc.
+using Windows.Win32.Foundation;
+
namespace MS.Internal.IO.Packaging
{
#region XpsFilter
@@ -53,14 +55,14 @@ IFILTER_FLAGS IFilter.Init(
if (_filter == null)
{
throw new COMException(SR.FileToFilterNotLoaded,
- (int)NativeMethods.E_FAIL);
+ (int)HRESULT.E_FAIL);
}
if (cAttributes > 0 && aAttributes == null)
{
// Attributes count and array do not match.
throw new COMException(SR.FilterInitInvalidAttributes,
- (int)NativeMethods.E_INVALIDARG);
+ (int)HRESULT.E_INVALIDARG);
}
return _filter.Init(grfFlags, cAttributes, aAttributes);
@@ -316,11 +318,11 @@ int IPersistFile.GetCurFile(out string ppszFileName)
if (_filter == null || _xpsFileName == null)
{
ppszFileName = $"*.{PackagingUtilities.ContainerFileExtension}";
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
ppszFileName = _xpsFileName;
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
///
@@ -336,7 +338,7 @@ int IPersistFile.GetCurFile(out string ppszFileName)
[PreserveSig]
int IPersistFile.IsDirty()
{
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
///
@@ -503,7 +505,7 @@ void IPersistStream.GetClassID(out Guid pClassID)
[PreserveSig]
int IPersistStream.IsDirty()
{
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
///
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/UnsafeNativeMethods.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/UnsafeNativeMethods.cs
index c38f611dc7d..c038f967972 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/UnsafeNativeMethods.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/UnsafeNativeMethods.cs
@@ -1,8 +1,8 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
+using Windows.Win32.Foundation;
using MS.Internal.PresentationFramework;
@@ -11,13 +11,7 @@ namespace MS.Internal.Printing
internal static class UnsafeNativeMethods
{
[DllImport("comdlg32.dll", CharSet = CharSet.Auto)]
- internal
- static
- extern
- Int32
- PrintDlgEx(
- IntPtr pdex
- );
+ internal static extern HRESULT PrintDlgEx(IntPtr pdex);
[DllImport("kernel32.dll")]
internal
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/Win32PrintDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/Win32PrintDialog.cs
index 5fc0e52d1a2..0d59d1f97ff 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/Win32PrintDialog.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Printing/Win32PrintDialog.cs
@@ -1,14 +1,14 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#if !DONOTREFPRINTINGASMMETA
-
using System.Printing.Interop;
using System.Printing;
using System.Runtime.InteropServices;
using System.Windows.Controls;
+using Windows.Win32.Foundation;
namespace MS.Internal.Printing
{
@@ -67,7 +67,7 @@ internal partial class Win32PrintDialog
try
{
- if (this._printQueue == null || this._printTicket == null)
+ if (_printQueue == null || _printTicket == null)
{
// Normally printDlgEx.SyncToStruct() probes the printer if both the print queue and print
// ticket are not null.
@@ -88,8 +88,7 @@ internal partial class Win32PrintDialog
//
// Display the Win32 print dialog
//
- Int32 hr = UnsafeNativeMethods.PrintDlgEx(printDlgEx.UnmanagedPrintDlgEx);
- if (hr == MS.Win32.NativeMethods.S_OK)
+ if (UnsafeNativeMethods.PrintDlgEx(printDlgEx.UnmanagedPrintDlgEx) == HRESULT.S_OK)
{
result = printDlgEx.SyncFromStruct();
}
@@ -118,12 +117,12 @@ internal partial class Win32PrintDialog
if (owner == IntPtr.Zero)
{
- owner = MS.Win32.UnsafeNativeMethods.GetActiveWindow();
+ owner = Win32.UnsafeNativeMethods.GetActiveWindow();
}
- if(0 != MS.Win32.UnsafeNativeMethods.MessageBox(new HandleRef(null, owner), message, caption, type))
+ if (0 != Win32.UnsafeNativeMethods.MessageBox(new HandleRef(null, owner), message, caption, type))
{
- result = NativeMethods.PD_RESULT_CANCEL;
+ result = NativeMethods.PD_RESULT_CANCEL;
}
}
else
@@ -284,7 +283,7 @@ private void ProbeForPrintingSupport()
// We could avoid the exception if we had access to
// MS.Internal.Printing.Configuration.NativeMethods.BindPTProviderThunk
- string printerName = (this._printQueue != null) ? this._printQueue.FullName : string.Empty;
+ string printerName = (_printQueue != null) ? _printQueue.FullName : string.Empty;
try
{
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs
index f3e3c76357f..fcbbe8ab174 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -9,10 +9,7 @@
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
-
-// There are THREE definitions of HRESULT. Two in ErrorCodes, and one in wgx_render.cs.
-// wgx_render.cs wins if we don't explicitly define it here.
-using HRESULT = MS.Internal.Interop.HRESULT;
+using Windows.Win32.Foundation;
namespace Microsoft.Win32
{
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj
index 5b90421c0a6..90b49d883ba 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj
@@ -1313,7 +1313,6 @@
-
@@ -1371,6 +1370,7 @@
+
@@ -1387,6 +1387,7 @@
+
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdropManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdropManager.cs
index 81157e76b02..02924cdf00e 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdropManager.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdropManager.cs
@@ -1,8 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
using System.Windows.Interop;
using System.Windows.Media;
using MS.Internal;
using Standard;
-using HRESULT = Standard.HRESULT;
+using Windows.Win32.Foundation;
// ReSharper disable once CheckNamespace
namespace System.Windows.Appearance;
@@ -71,11 +74,11 @@ private static bool ApplyBackdrop(IntPtr hwnd, WindowBackdropType backdropType)
var backdropPvAttribute = backdropType switch
{
- WindowBackdropType.Auto => Standard.DWMSBT.DWMSBT_TABBEDWINDOW,
- WindowBackdropType.TabbedWindow => Standard.DWMSBT.DWMSBT_TABBEDWINDOW,
- WindowBackdropType.MainWindow => Standard.DWMSBT.DWMSBT_MAINWINDOW,
- WindowBackdropType.TransientWindow => Standard.DWMSBT.DWMSBT_TRANSIENTWINDOW,
- _ => Standard.DWMSBT.DWMSBT_NONE
+ WindowBackdropType.Auto => DWMSBT.DWMSBT_TABBEDWINDOW,
+ WindowBackdropType.TabbedWindow => DWMSBT.DWMSBT_TABBEDWINDOW,
+ WindowBackdropType.MainWindow => DWMSBT.DWMSBT_MAINWINDOW,
+ WindowBackdropType.TransientWindow => DWMSBT.DWMSBT_TRANSIENTWINDOW,
+ _ => DWMSBT.DWMSBT_NONE
};
var dwmResult = NativeMethods.DwmSetWindowAttributeSystemBackdropType(hwnd, backdropPvAttribute);
@@ -86,7 +89,7 @@ private static bool RemoveBackdrop(IntPtr hwnd)
{
UpdateGlassFrame(hwnd, WindowBackdropType.None);
- var backdropPvAttribute = Standard.DWMSBT.DWMSBT_NONE;
+ var backdropPvAttribute = DWMSBT.DWMSBT_NONE;
var dwmResult = NativeMethods.DwmSetWindowAttributeSystemBackdropType(hwnd, backdropPvAttribute);
return dwmResult == HRESULT.S_OK;
}
@@ -128,8 +131,7 @@ private static bool UpdateGlassFrame(IntPtr hwnd, WindowBackdropType backdropTyp
margins = new MARGINS { cxLeftWidth = -1, cxRightWidth = -1, cyTopHeight = -1, cyBottomHeight = -1 };
}
- var dwmApiResult = NativeMethods.DwmExtendFrameIntoClientArea(hwnd, ref margins);
- return new HRESULT((uint)dwmApiResult) == HRESULT.S_OK;
+ return NativeMethods.DwmExtendFrameIntoClientArea(hwnd, ref margins) == HRESULT.S_OK;
}
#endregion
@@ -143,4 +145,4 @@ private static bool UpdateGlassFrame(IntPtr hwnd, WindowBackdropType backdropTyp
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs
index df7fd9c875f..932d5c085ef 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -23,6 +23,7 @@
using MS.Internal.KnownBoxes;
using MS.Internal.Interop;
using MS.Win32;
+using Windows.Win32.Foundation;
using CommonDependencyProperty = MS.Internal.PresentationFramework.CommonDependencyPropertyAttribute;
@@ -264,9 +265,9 @@ private void UpdatePlacementTargetRegistration(UIElement oldValue, UIElement new
// This causes Popup and its descedents to miss some change notifications.
// Thus a Popup that isnt connected to the tree in any way should be
// designated standalone and thus IsSelfInheritanceParent = true.
- if (!this.IsSelfInheritanceParent)
+ if (!IsSelfInheritanceParent)
{
- this.SetIsSelfInheritanceParent();
+ SetIsSelfInheritanceParent();
}
// Invalidate relevant properties for this subtree
@@ -1215,7 +1216,7 @@ private static void OnLostMouseCapture(object sender, MouseEventArgs e)
//
// Note we do not reestablish capture if we are losing capture
// ourselves.
- bool reestablishCapture = e.OriginalSource != root && Mouse.Captured == null && MS.Win32.SafeNativeMethods.GetCapture() == IntPtr.Zero;
+ bool reestablishCapture = e.OriginalSource != root && Mouse.Captured == null && SafeNativeMethods.GetCapture() == IntPtr.Zero;
if(reestablishCapture)
{
@@ -1287,7 +1288,7 @@ void IAddChild.AddChild(Object value)
throw new ArgumentException(SR.Format(SR.UnexpectedParameterType, value.GetType(), typeof(UIElement)), "value");
}
- this.Child = element;
+ Child = element;
}
///
@@ -1324,7 +1325,7 @@ internal override bool BlockReverseInheritance()
// In the case that the Popup has a TemplatedParent we don't want
// to block reverse inheritance because the Popup is considered
// part of that tree.
- return this.TemplatedParent == null;
+ return TemplatedParent == null;
}
///
@@ -1395,7 +1396,7 @@ protected override bool IsUnchanged
{
get
{
- return Object.ReferenceEquals(Content, _popup.Child);
+ return ReferenceEquals(Content, _popup.Child);
}
}
@@ -2667,9 +2668,9 @@ private Rect GetScreenBounds(Rect boundingBox, Point p)
SafeNativeMethods.GetMonitorInfo(new HandleRef(null, monitor), monitorInfo);
//If this is a pop up for a menu or ToolTip then respect the work area if opening in the work area.
- if (((this.Child is MenuBase)
- || (this.Child is ToolTip)
- || (this.TemplatedParent is MenuItem))
+ if (((Child is MenuBase)
+ || (Child is ToolTip)
+ || (TemplatedParent is MenuItem))
&& ((p.X >= monitorInfo.rcWork.left)
&& (p.X <= monitorInfo.rcWork.right)
&& (p.Y >= monitorInfo.rcWork.top)
@@ -2979,7 +2980,7 @@ internal bool IsChildPopup
internal Point ClientToScreen(Visual rootVisual, Point clientPoint)
{
// Get the HwndSource of the target element.
- HwndSource targetWindow = PopupSecurityHelper.GetPresentationSource(rootVisual) as HwndSource;
+ HwndSource targetWindow = GetPresentationSource(rootVisual) as HwndSource;
if (targetWindow != null)
{
@@ -3023,7 +3024,7 @@ internal NativeMethods.POINT GetMouseCursorPos(Visual targetVisual)
HwndSource hwndSource = null;
if (targetVisual != null)
{
- hwndSource = PopupSecurityHelper.GetPresentationSource(targetVisual) as HwndSource;
+ hwndSource = GetPresentationSource(targetVisual) as HwndSource;
}
IInputElement relativeTarget = targetVisual as IInputElement;
@@ -3118,7 +3119,7 @@ internal static Matrix GetTransformToDevice(Visual targetVisual)
HwndSource hwndSource = null;
if (targetVisual != null)
{
- hwndSource = PopupSecurityHelper.GetPresentationSource(targetVisual) as HwndSource;
+ hwndSource = GetPresentationSource(targetVisual) as HwndSource;
}
if (hwndSource != null)
@@ -3151,7 +3152,7 @@ internal void SetWindowRootVisual(Visual v)
internal static bool IsVisualPresentationSourceNull(Visual visual)
{
- return (PopupSecurityHelper.GetPresentationSource(visual) == null);
+ return (GetPresentationSource(visual) == null);
}
internal void ShowWindow()
@@ -3301,13 +3302,13 @@ internal void BuildWindow(int x, int y, Visual placementTarget,
}
// get visual's PresentationSource
- HwndSource hwndSource = PopupSecurityHelper.GetPresentationSource(mainTreeVisual) as HwndSource;
+ HwndSource hwndSource = GetPresentationSource(mainTreeVisual) as HwndSource;
// get parent handle
IntPtr parent = IntPtr.Zero;
if (hwndSource != null)
{
- parent = PopupSecurityHelper.GetHandle(hwndSource);
+ parent = GetHandle(hwndSource);
}
int classStyle = 0;
@@ -3438,13 +3439,11 @@ internal void ForceMsaaToUiaBridge(PopupRoot popupRoot)
if (lResult != IntPtr.Zero)
{
IAccessible acc = null;
- int hr = NativeMethods.S_FALSE;
Guid iid = new Guid(MS.Internal.AppModel.IID.Accessible);
- hr = UnsafeNativeMethods.ObjectFromLresult(lResult, ref iid, IntPtr.Zero, ref acc);
- if (hr == NativeMethods.S_OK && acc != null)
+ HRESULT result = UnsafeNativeMethods.ObjectFromLresult(lResult, ref iid, IntPtr.Zero, ref acc);
+ if (result == HRESULT.S_OK && acc != null)
{
// Release IAccessible(acc) object, just trusting the GC
- ;
}
}
}
@@ -3530,8 +3529,8 @@ internal static bool IsPerMonitorDpiScalingActive
var target = popup?.GetTarget() as UIElement;
if (target != null)
{
- var rootVisual = Popup.GetRootVisual(target);
- var targetToClientTransform = Popup.TransformToClient(target, rootVisual);
+ var rootVisual = GetRootVisual(target);
+ var targetToClientTransform = TransformToClient(target, rootVisual);
Point ptPlacementTargetOrigin;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs
index 5ebd5e587cb..1b37d8b94ab 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -20,8 +20,7 @@
using MS.Internal.Controls;
using MS.Internal.Telemetry.PresentationFramework;
using System.Diagnostics.CodeAnalysis;
-
-using HRESULT = MS.Internal.Interop.HRESULT;
+using Windows.Win32.Foundation;
using PackUriHelper = MS.Internal.IO.Packaging.PackUriHelper;
/* Overview of Keyboard Input Routing for the WebOC
@@ -288,7 +287,7 @@ public object InvokeScript(string scriptName, params object[] args)
int[] dispids = new int[] { NativeMethods.DISPID_UNKNOWN };
HRESULT hr = scriptObjectEx.GetIDsOfNames(ref guid, names, 1, Thread.CurrentThread.CurrentCulture.LCID, dispids);
- hr.ThrowIfFailed();
+ hr.ThrowOnFailureUnwrapWin32();
if (args != null)
{
@@ -321,7 +320,7 @@ public object InvokeScript(string scriptName, params object[] args)
out retVal,
new NativeMethods.EXCEPINFO(),
null);
- hr.ThrowIfFailed();
+ hr.ThrowOnFailureUnwrapWin32();
}
finally
{
@@ -545,7 +544,7 @@ internal override object CreateActiveXObject(Guid clsid)
internal override void AttachInterfaces(object nativeActiveXObject)
{
//cache the interface
- this._axIWebBrowser2 = (UnsafeNativeMethods.IWebBrowser2)nativeActiveXObject;
+ _axIWebBrowser2 = (UnsafeNativeMethods.IWebBrowser2)nativeActiveXObject;
//
//Initializations
@@ -922,7 +921,7 @@ private void DoNavigate(Uri source, ref object targetFrameName, ref object postD
///
private void SyncUIActiveState()
{
- if (ActiveXState != ActiveXHelper.ActiveXState.UIActive && this.HasFocusWithinCore())
+ if (ActiveXState != ActiveXHelper.ActiveXState.UIActive && HasFocusWithinCore())
{
Invariant.Assert(ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive);
ActiveXState = ActiveXHelper.ActiveXState.UIActive;
@@ -955,12 +954,12 @@ protected override bool TabIntoCore(TraversalRequest request)
Invariant.Assert(ActiveXState >= ActiveXHelper.ActiveXState.InPlaceActive, "Should be at least InPlaceActive when tabbed into");
bool activated = DoVerb(NativeMethods.OLEIVERB_UIACTIVATE);
-
+
if (activated)
{
- this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
+ ActiveXState = ActiveXHelper.ActiveXState.UIActive;
}
-
+
return activated;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/InputScopeAttribute.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/InputScopeAttribute.cs
index 60b57d8af88..1687e5b145f 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/InputScopeAttribute.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/InputScopeAttribute.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -10,6 +10,7 @@
using System.Runtime.InteropServices;
using System.Windows.Input;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace System.Windows.Documents
@@ -58,7 +59,7 @@ public void GetInputScopes(out IntPtr ppinputscopes, out int count)
}
catch (OutOfMemoryException)
{
- throw new COMException(SR.InputScopeAttribute_E_OUTOFMEMORY, NativeMethods.E_OUTOFMEMORY);
+ throw new COMException(SR.InputScopeAttribute_E_OUTOFMEMORY, HRESULT.E_OUTOFMEMORY);
}
for (int i = 0; i < count; i++)
@@ -86,7 +87,7 @@ public int GetPhrase(out IntPtr ppbstrPhrases, out int count)
}
catch (OutOfMemoryException)
{
- throw new COMException(SR.InputScopeAttribute_E_OUTOFMEMORY, NativeMethods.E_OUTOFMEMORY);
+ throw new COMException(SR.InputScopeAttribute_E_OUTOFMEMORY, HRESULT.E_OUTOFMEMORY);
}
int offset = 0;
@@ -105,14 +106,14 @@ public int GetPhrase(out IntPtr ppbstrPhrases, out int count)
Marshal.FreeBSTR(Marshal.ReadIntPtr(ppbstrPhrases, offset));
offset += IntPtr.Size;
}
- throw new COMException(SR.InputScopeAttribute_E_OUTOFMEMORY, NativeMethods.E_OUTOFMEMORY);
+ throw new COMException(SR.InputScopeAttribute_E_OUTOFMEMORY, HRESULT.E_OUTOFMEMORY);
}
Marshal.WriteIntPtr(ppbstrPhrases , offset, pbstr);
offset += IntPtr.Size;
}
- return count > 0 ? NativeMethods.S_OK : NativeMethods.S_FALSE;
+ return count > 0 ? HRESULT.S_OK : HRESULT.S_FALSE;
}
// A method of ITfInputScope.
@@ -124,7 +125,7 @@ public int GetRegularExpression(out string desc)
{
desc = _inputScope.RegularExpression;
}
- return desc != null ? NativeMethods.S_OK : NativeMethods.S_FALSE;
+ return desc != null ? HRESULT.S_OK : HRESULT.S_FALSE;
}
// A method of ITfInputScope.
@@ -136,14 +137,14 @@ public int GetSRGC(out string desc)
{
desc = _inputScope.SrgsMarkup;
}
- return desc != null ? NativeMethods.S_OK : NativeMethods.S_FALSE;
+ return desc != null ? HRESULT.S_OK : HRESULT.S_FALSE;
}
// A method of ITfInputScope.
public int GetXML(out string desc)
{
desc = null;
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
#endregion Internal Methods
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/NLGSpellerInterop.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/NLGSpellerInterop.cs
index cb62e4448b2..293aa390de0 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/NLGSpellerInterop.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/NLGSpellerInterop.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -8,6 +8,7 @@
using System.Globalization;
using System.Windows.Controls;
using MS.Internal.PresentationFramework;
+using Windows.Win32.Foundation;
//
// Description: Custom COM marshalling code and interfaces for interaction
@@ -220,7 +221,7 @@ internal override int EnumTextSegments(char[] text, int count,
result = EnumVariantNext(sentenceEnumerator, variant, fetched);
- if ((result != NativeMethods.S_OK) || (fetched[0] == 0))
+ if ((result != HRESULT.S_OK) || (fetched[0] == 0))
{
break;
}
@@ -594,7 +595,7 @@ private void EnumerateSuggestions()
variant.Clear();
result = EnumVariantNext(variantEnumerator, variant, fetched);
- if ((result != NativeMethods.S_OK) || (fetched[0] == 0))
+ if ((result != HRESULT.S_OK) || (fetched[0] == 0))
{
break;
}
@@ -963,7 +964,7 @@ private ILexicon AddLexicon(string lexiconFilePath)
{
hasDemand = true;
- lexicon = NLGSpellerInterop.CreateLexicon();
+ lexicon = CreateLexicon();
lexicon.ReadFrom(lexiconFilePath);
_textChunk.get_Context(out textContext);
textContext.AddLexicon(lexicon);
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextEditorDragDrop.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextEditorDragDrop.cs
index e3b4a7b30e1..48f21d1df1c 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextEditorDragDrop.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextEditorDragDrop.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -11,6 +11,7 @@
using System.Windows.Data; // BindingExpression
using System.Windows.Media;
using MS.Win32;
+using Windows.Win32.Foundation;
//
// Description: A Component of TextEditor class supposrtinng Drag-and-drop
@@ -118,13 +119,13 @@ internal bool SourceOnMouseLeftButtonDown(Point mouseDownPoint)
internal void DoMouseLeftButtonUp(MouseButtonEventArgs e)
{
if (_dragStarted)
- {
+ {
// We get to this state when drag gesture ends within the selection,
// so we only need to set selection into mouse-releasing point.
- if (this.TextView.IsValid)
+ if (TextView.IsValid)
{
Point mouseDownPoint = e.GetPosition(_textEditor.TextView.RenderScope);
- ITextPointer cursorPosition = this.TextView.GetTextPositionFromPoint(mouseDownPoint, /*snapToText:*/true);
+ ITextPointer cursorPosition = TextView.GetTextPositionFromPoint(mouseDownPoint, /*snapToText:*/true);
if (cursorPosition != null)
{
_textEditor.Selection.SetSelectionByMouse(cursorPosition, mouseDownPoint);
@@ -228,7 +229,7 @@ private void SourceDoDragDrop(ITextSelection selection, IDataObject dataObject)
// if something unexpected happened during the drag and drop operation,
// e.g. the application receiving the drop failed. In this case we should
// not fail, we should catch the exception and act as if the drop wasn't allowed.
- catch (COMException ex) when(ex.HResult == NativeMethods.E_UNEXPECTED)
+ catch (COMException ex) when(ex.HResult == HRESULT.E_UNEXPECTED)
{
}
@@ -407,7 +408,7 @@ internal void TargetOnDragOver(DragEventArgs e)
if (dragPosition != null)
{
// Get the caret position to show the dropable point.
- Rect caretRectangle = this.TextView.GetRectangleFromTextPosition(dragPosition);
+ Rect caretRectangle = TextView.GetRectangleFromTextPosition(dragPosition);
// NOTE: We DO NOT use GetCurrentValue because springload formatting should NOT be involved for drop caret.
object fontStylePropertyValue = dragPosition.GetValue(TextElement.FontStyleProperty);
@@ -445,7 +446,7 @@ private ITextPointer GetDropPosition(Visual target, Point point)
transform.TryTransform(point, out point);
}
- ITextPointer dropPosition = this.TextView.GetTextPositionFromPoint(point, /*snapToText:*/true);
+ ITextPointer dropPosition = TextView.GetTextPositionFromPoint(point, /*snapToText:*/true);
// For rich text content we adjust drop position to word boundary
if (dropPosition != null)
@@ -455,7 +456,7 @@ private ITextPointer GetDropPosition(Visual target, Point point)
if (_textEditor.AcceptsRichContent)
{
- TextSegment lineRange = TextEditorSelection.GetNormalizedLineRange(this.TextView, dropPosition);
+ TextSegment lineRange = TextEditorSelection.GetNormalizedLineRange(TextView, dropPosition);
if (!lineRange.IsNull &&
// The drop position must be before of end of line
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextServicesDisplayAttributePropertyRanges.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextServicesDisplayAttributePropertyRanges.cs
index 0f33d489085..1ca76b174dc 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextServicesDisplayAttributePropertyRanges.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextServicesDisplayAttributePropertyRanges.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -6,6 +6,7 @@
using System.Runtime.InteropServices;
using System.Collections;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace System.Windows.Documents
{
@@ -116,12 +117,12 @@ internal override void OnEndEdit(UnsafeNativeMethods.ITfContext context,
displayAttributeGuid = Guid;
context.GetProperty(ref displayAttributeGuid, out displayAttributeProperty);
// Get a range enumerator for the property.
- if (displayAttributeProperty.EnumRanges(ecReadOnly, out attributeRangeEnumerator, null) == NativeMethods.S_OK)
+ if (displayAttributeProperty.EnumRanges(ecReadOnly, out attributeRangeEnumerator, null) == HRESULT.S_OK)
{
attributeRanges = new UnsafeNativeMethods.ITfRange[1];
// Walk each range.
- while (attributeRangeEnumerator.Next(1, attributeRanges, out fetched) == NativeMethods.S_OK)
+ while (attributeRangeEnumerator.Next(1, attributeRanges, out fetched) == HRESULT.S_OK)
{
// Get a DisplayAttribute for this range.
guidAtom = GetInt32Value(ecReadOnly, displayAttributeProperty, attributeRanges[0]);
@@ -144,8 +145,8 @@ internal override void OnEndEdit(UnsafeNativeMethods.ITfContext context,
if (_compositionAdorner == null)
{
- _compositionAdorner = new CompositionAdorner(this.TextStore.TextView);
- _compositionAdorner.Initialize(this.TextStore.TextView);
+ _compositionAdorner = new CompositionAdorner(TextStore.TextView);
+ _compositionAdorner.Initialize(TextStore.TextView);
}
#if UNUSED_IME_HIGHLIGHT_LAYER
@@ -171,7 +172,7 @@ internal override void OnEndEdit(UnsafeNativeMethods.ITfContext context,
if (_compositionAdorner != null)
{
// Update the layout to get the acurated rectangle from calling GetRectangleFromTextPosition
- this.TextStore.RenderScope.UpdateLayout();
+ TextStore.RenderScope.UpdateLayout();
// Invalidate the composition adorner to render the composition attribute ranges.
_compositionAdorner.InvalidateAdorner();
@@ -225,7 +226,7 @@ private static TextServicesDisplayAttribute GetDisplayAttribute(Int32 guidatom)
// Use category manager to convert guidatom to GUID.
//
UnsafeNativeMethods.ITfCategoryMgr catmgr;
- if (UnsafeNativeMethods.TF_CreateCategoryMgr(out catmgr) != NativeMethods.S_OK)
+ if (UnsafeNativeMethods.TF_CreateCategoryMgr(out catmgr) != HRESULT.S_OK)
return null;
if (catmgr == null)
@@ -245,7 +246,7 @@ private static TextServicesDisplayAttribute GetDisplayAttribute(Int32 guidatom)
UnsafeNativeMethods.ITfDisplayAttributeMgr dam;
UnsafeNativeMethods.ITfDisplayAttributeInfo dai;
UnsafeNativeMethods.TF_DISPLAYATTRIBUTE tfattr;
- if (UnsafeNativeMethods.TF_CreateDisplayAttributeMgr(out dam) != NativeMethods.S_OK)
+ if (UnsafeNativeMethods.TF_CreateDisplayAttributeMgr(out dam) != HRESULT.S_OK)
return null;
if (dam == null)
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs
index 0e8e7b0257c..d84f5b87785 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -20,6 +20,7 @@
using System.Windows.Interop;
using MS.Internal.Documents;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace System.Windows.Documents
{
@@ -328,9 +329,9 @@ public void GetSelection(int index, int count, UnsafeNativeMethods.TS_SELECTION_
if (count > 0 && (index == 0 || index == UnsafeNativeMethods.TS_DEFAULT_SELECTION))
{
- selection[0].start = this.TextSelection.Start.CharOffset;
- selection[0].end = this.TextSelection.End.CharOffset;
- selection[0].style.ase = (this.TextSelection.MovingPosition.CompareTo(this.TextSelection.Start) == 0) ? UnsafeNativeMethods.TsActiveSelEnd.TS_AE_START : UnsafeNativeMethods.TsActiveSelEnd.TS_AE_END;
+ selection[0].start = TextSelection.Start.CharOffset;
+ selection[0].end = TextSelection.End.CharOffset;
+ selection[0].style.ase = (TextSelection.MovingPosition.CompareTo(TextSelection.Start) == 0) ? UnsafeNativeMethods.TsActiveSelEnd.TS_AE_START : UnsafeNativeMethods.TsActiveSelEnd.TS_AE_END;
selection[0].style.interimChar = _interimSelection;
fetched = 1;
@@ -364,15 +365,15 @@ public void SetSelection(int count, UnsafeNativeMethods.TS_SELECTION_ACP[] selec
{
// Setting a caret. Make sure we set Backward direction to
// keep the caret tight with the composition text.
- this.TextSelection.SetCaretToPosition(start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
+ TextSelection.SetCaretToPosition(start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
}
else if (selection[0].style.ase == UnsafeNativeMethods.TsActiveSelEnd.TS_AE_START)
{
- this.TextSelection.Select(end, start);
+ TextSelection.Select(end, start);
}
else
{
- this.TextSelection.Select(start, end);
+ TextSelection.Select(start, end);
}
// Update the selection style of InterimSelection.
@@ -382,7 +383,7 @@ public void SetSelection(int count, UnsafeNativeMethods.TS_SELECTION_ACP[] selec
if (previousInterimSelection != _interimSelection)
{
// Call TextSelection to start/stop the block caret.
- this.TextSelection.OnInterimSelectionChanged(_interimSelection);
+ TextSelection.OnInterimSelectionChanged(_interimSelection);
}
}
}
@@ -470,7 +471,7 @@ public void GetText(int startIndex, int endIndex, char[] text, int cchReq, out i
// See msdn's ITextStoreACP documentation for a full description.
public void SetText(UnsafeNativeMethods.SetTextFlags flags, int startIndex, int endIndex, char[] text, int cch, out UnsafeNativeMethods.TS_TEXTCHANGE change)
{
- if (this.IsReadOnly)
+ if (IsReadOnly)
{
throw new COMException(SR.TextStore_TS_E_READONLY, UnsafeNativeMethods.TS_E_READONLY);
}
@@ -493,7 +494,7 @@ public void SetText(UnsafeNativeMethods.SetTextFlags flags, int startIndex, int
if (start == null)
{
- throw new COMException(SR.TextStore_CompositionRejected, NativeMethods.E_FAIL);
+ throw new COMException(SR.TextStore_CompositionRejected, HRESULT.E_FAIL);
}
if (start.CompareTo(end) > 0)
@@ -504,7 +505,7 @@ public void SetText(UnsafeNativeMethods.SetTextFlags flags, int startIndex, int
string filteredText = FilterCompositionString(new string(text), start.GetOffsetToPosition(end)); // does NOT filter MaxLength.
if (filteredText == null)
{
- throw new COMException(SR.TextStore_CompositionRejected, NativeMethods.E_FAIL);
+ throw new COMException(SR.TextStore_CompositionRejected, HRESULT.E_FAIL);
}
// Openes a composition undo unit for the composition undo.
@@ -515,7 +516,7 @@ public void SetText(UnsafeNativeMethods.SetTextFlags flags, int startIndex, int
{
ITextRange range = new TextRange(start, end, true /* ignoreTextUnitBoundaries */);
- this.TextEditor.SetText(range, filteredText, InputLanguageManager.Current.CurrentInputLanguage);
+ TextEditor.SetText(range, filteredText, InputLanguageManager.Current.CurrentInputLanguage);
change.start = startIndex;
change.oldEnd = endIndex;
@@ -624,7 +625,7 @@ public void InsertEmbedded(UnsafeNativeMethods.InsertEmbeddedFlags flags, int st
data = obj as IComDataObject;
if (data == null)
{
- throw new COMException(SR.TextStore_BadObject, NativeMethods.E_INVALIDARG);
+ throw new COMException(SR.TextStore_BadObject, HRESULT.E_INVALIDARG);
}
container = (TextContainer)this.TextContainer;
@@ -671,7 +672,7 @@ public void InsertTextAtSelection(UnsafeNativeMethods.InsertAtSelectionFlags fla
// We need to refactor the code to change that.
//
- ITextRange range = new TextRange(this.TextSelection.AnchorPosition, this.TextSelection.MovingPosition);
+ ITextRange range = new TextRange(TextSelection.AnchorPosition, TextSelection.MovingPosition);
range.ApplyTypingHeuristics(false /* overType */);
ITextPointer start;
@@ -705,13 +706,13 @@ public void InsertTextAtSelection(UnsafeNativeMethods.InsertAtSelectionFlags fla
string filteredText = FilterCompositionString(new string(text), range.Start.GetOffsetToPosition(range.End)); // does NOT filter MaxLength.
if (filteredText == null)
{
- throw new COMException(SR.TextStore_CompositionRejected, NativeMethods.E_FAIL);
+ throw new COMException(SR.TextStore_CompositionRejected, HRESULT.E_FAIL);
}
// We still need to call ApplyTypingHeuristics, even though
// we already did the work above, because it might need
// to spring load formatting.
- this.TextSelection.ApplyTypingHeuristics(false /* overType */);
+ TextSelection.ApplyTypingHeuristics(false /* overType */);
//Invariant.Assert(this.TextSelection.Start.CompareTo(range.Start) == 0 && this.TextSelection.End.CompareTo(range.End) == 0);
// We cannot make this Assertion because TextRange will normalize
@@ -739,10 +740,10 @@ public void InsertTextAtSelection(UnsafeNativeMethods.InsertAtSelectionFlags fla
// Avoid calling Select when the selection doesn't need a
// final reposition to preserve any spring loaded formatting
// from ApplyTypingHeuristics.
- if (start.CompareTo(this.TextSelection.Start) != 0 ||
- end.CompareTo(this.TextSelection.End) != 0)
+ if (start.CompareTo(TextSelection.Start) != 0 ||
+ end.CompareTo(TextSelection.End) != 0)
{
- this.TextSelection.Select(start, end);
+ TextSelection.Select(start, end);
}
if (!_isComposing && _previousCompositionStartOffset == -1)
@@ -753,11 +754,11 @@ public void InsertTextAtSelection(UnsafeNativeMethods.InsertAtSelectionFlags fla
// to remember where the composition started, from the
// point of view of the application listening to events
// we will raise in the future.
- _previousCompositionStartOffset = this.TextSelection.Start.Offset;
- _previousCompositionEndOffset = this.TextSelection.End.Offset;
+ _previousCompositionStartOffset = TextSelection.Start.Offset;
+ _previousCompositionEndOffset = TextSelection.End.Offset;
}
- this.TextEditor.SetSelectedText(filteredText, InputLanguageManager.Current.CurrentInputLanguage);
+ TextEditor.SetSelectedText(filteredText, InputLanguageManager.Current.CurrentInputLanguage);
change.start = startNavigator.CharOffset;
change.newEnd = endNavigator.CharOffset;
@@ -821,7 +822,7 @@ public void InsertEmbeddedAtSelection(UnsafeNativeMethods.InsertAtSelectionFlags
data = obj as IComDataObject;
if (data == null)
{
- throw new COMException(SR.TextStore_BadObject, NativeMethods.E_INVALIDARG);
+ throw new COMException(SR.TextStore_BadObject, HRESULT.E_INVALIDARG);
}
// Do the insert.
@@ -852,9 +853,9 @@ public int RequestSupportedAttrs(UnsafeNativeMethods.AttributeFlags flags, int c
count, filterAttributes);
if (_preparedattributes.Count == 0)
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
// See msdn's ITextStoreACP documentation for a full description.
@@ -872,9 +873,9 @@ public int RequestAttrsAtPosition(int index, int count, Guid[] filterAttributes,
count, filterAttributes);
if (_preparedattributes.Count == 0)
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
@@ -915,7 +916,7 @@ public void RetrieveRequestedAttrs(int count, UnsafeNativeMethods.TS_ATTRVAL[] a
// See msdn's ITextStoreACP documentation for a full description.
public void GetEnd(out int end)
{
- end = this.TextContainer.IMECharCount;
+ end = TextContainer.IMECharCount;
}
// See msdn's ITextStoreACP documentation for a full description.
@@ -1037,7 +1038,7 @@ void UnsafeNativeMethods.ITextStoreACP.GetTextExt(int viewCookie, int startIndex
"text changed - bail");
}
- _netCharCount = this.TextContainer.IMECharCount;
+ _netCharCount = TextContainer.IMECharCount;
throw new COMException(SR.TextStore_TS_E_NOLAYOUT, UnsafeNativeMethods.TS_E_NOLAYOUT);
}
@@ -1050,7 +1051,7 @@ void UnsafeNativeMethods.ITextStoreACP.GetTextExt(int viewCookie, int startIndex
startPointer = CreatePointerAtCharOffset(startIndex, LogicalDirection.Forward);
startPointer.MoveToInsertionPosition(LogicalDirection.Forward);
- if (!this.TextView.IsValid)
+ if (!TextView.IsValid)
{
// We can not get the visual. Return TS_R_NOLAYOUT to the caller.
throw new COMException(SR.TextStore_TS_E_NOLAYOUT, UnsafeNativeMethods.TS_E_NOLAYOUT);
@@ -1073,7 +1074,7 @@ void UnsafeNativeMethods.ITextStoreACP.GetTextExt(int viewCookie, int startIndex
do
{
// Compute the textSegment bounds line by line.
- TextSegment lineRange = this.TextView.GetLineRange(navigator);
+ TextSegment lineRange = TextView.GetLineRange(navigator);
ITextPointer end;
Rect lineRect;
@@ -1250,13 +1251,13 @@ public void OnStartComposition(UnsafeNativeMethods.ITfCompositionView view, out
}
else
{
- if (this.TextEditor.AcceptsRichContent && start.CompareTo(end) != 0)
+ if (TextEditor.AcceptsRichContent && start.CompareTo(end) != 0)
{
TextElement startElement = (TextElement)((TextPointer)start).Parent;
TextElement endElement = (TextElement)((TextPointer)end).Parent;
TextElement commonAncestor = TextElement.GetCommonAncestor(startElement, endElement);
- int originalIMECharCount = this.TextContainer.IMECharCount;
+ int originalIMECharCount = TextContainer.IMECharCount;
TextRange range = new TextRange(start, end);
string unmergedText = range.Text;
@@ -1266,7 +1267,7 @@ public void OnStartComposition(UnsafeNativeMethods.ITfCompositionView view, out
// serialized text for the range can include extra characters for things like
// ListItems, which could cause us to increase the number of characters visible
// to the IME in the document.
- this.TextEditor.MarkCultureProperty(range, InputLanguageManager.Current.CurrentInputLanguage);
+ TextEditor.MarkCultureProperty(range, InputLanguageManager.Current.CurrentInputLanguage);
}
else if (commonAncestor is Paragraph || commonAncestor is Span)
{
@@ -1282,19 +1283,19 @@ public void OnStartComposition(UnsafeNativeMethods.ITfCompositionView view, out
// Force any merges now by replacing the content with a single
// Run, before we start caching character offsets.
- this.TextEditor.SetText(range, unmergedText, InputLanguageManager.Current.CurrentInputLanguage);
+ TextEditor.SetText(range, unmergedText, InputLanguageManager.Current.CurrentInputLanguage);
}
// It is crucial that from the point of view of the IME the document
// has not changed. That means the plain text of the content we just
// replaced must not have changed.
Invariant.Assert(range.Text == unmergedText);
- Invariant.Assert(originalIMECharCount == this.TextContainer.IMECharCount);
+ Invariant.Assert(originalIMECharCount == TextContainer.IMECharCount);
}
}
// Add the composition message into the composition message list.
// This composition message list will be handled all together after we release the lock.
- this.CompositionEventList.Add(new CompositionEventRecord(CompositionStage.StartComposition, startOffsetBefore, endOffsetBefore, _lastCompositionText));
+ CompositionEventList.Add(new CompositionEventRecord(CompositionStage.StartComposition, startOffsetBefore, endOffsetBefore, _lastCompositionText));
_previousCompositionStartOffset = start.Offset;
_previousCompositionEndOffset = end.Offset;
@@ -1321,7 +1322,7 @@ public void OnUpdateComposition(UnsafeNativeMethods.ITfCompositionView view, Uns
}
// If UiScope has a ToolTip and it is open, any keyboard/mouse activity should close the tooltip.
- this.TextEditor.CloseToolTip();
+ TextEditor.CloseToolTip();
Invariant.Assert(_isComposing);
Invariant.Assert(_previousCompositionStartOffset != -1);
@@ -1348,7 +1349,7 @@ public void OnUpdateComposition(UnsafeNativeMethods.ITfCompositionView view, Uns
{
// Add internal shift record to process it later when we raise events in RaiseCompositionEvents.
CompositionEventRecord record = new CompositionEventRecord(CompositionStage.UpdateComposition, _previousCompositionStartOffset, _previousCompositionEndOffset, compositionText, true);
- this.CompositionEventList.Add(record);
+ CompositionEventList.Add(record);
_previousCompositionStartOffset = newStart.Offset;
_previousCompositionEndOffset = newEnd.Offset;
@@ -1361,13 +1362,13 @@ public void OnUpdateComposition(UnsafeNativeMethods.ITfCompositionView view, Uns
// This composition message list will be handled all together after release the lock.
CompositionEventRecord record = new CompositionEventRecord(CompositionStage.UpdateComposition, _previousCompositionStartOffset, _previousCompositionEndOffset, compositionText);
- CompositionEventRecord previousRecord = (this.CompositionEventList.Count == 0) ? null : this.CompositionEventList[this.CompositionEventList.Count - 1];
+ CompositionEventRecord previousRecord = (CompositionEventList.Count == 0) ? null : CompositionEventList[CompositionEventList.Count - 1];
if (_lastCompositionText == null ||
!string.Equals(compositionText, _lastCompositionText, StringComparison.Ordinal))
{
// Add the new update event.
- this.CompositionEventList.Add(record);
+ CompositionEventList.Add(record);
}
_previousCompositionStartOffset = oldStart.Offset;
@@ -1406,7 +1407,7 @@ public void OnEndComposition(UnsafeNativeMethods.ITfCompositionView view)
{
// Add the composition message into the composition message list.
// This composition message list will be handled all together after release the lock.
- this.CompositionEventList.Add(new CompositionEventRecord(CompositionStage.EndComposition, start.Offset, end.Offset, TextRangeBase.GetTextInternal(start, end)));
+ CompositionEventList.Add(new CompositionEventRecord(CompositionStage.EndComposition, start.Offset, end.Offset, TextRangeBase.GetTextInternal(start, end)));
// Composition event is completed, so new composition undo unit will be opened.
CompositionParentUndoUnit unit = PeekCompositionParentUndoUnit();
@@ -1509,10 +1510,10 @@ public void OnTransitoryExtensionUpdated(UnsafeNativeMethods.ITfContext context,
string filteredText = FilterCompositionString(result, TextSelection.Start.GetOffsetToPosition(TextSelection.End)); // does NOT filter MaxLength.
if (filteredText == null)
{
- throw new COMException(SR.TextStore_CompositionRejected, NativeMethods.E_FAIL);
+ throw new COMException(SR.TextStore_CompositionRejected, HRESULT.E_FAIL);
}
- this.TextEditor.SetText(TextSelection, filteredText, InputLanguageManager.Current.CurrentInputLanguage);
+ TextEditor.SetText(TextSelection, filteredText, InputLanguageManager.Current.CurrentInputLanguage);
TextSelection.Select(TextSelection.End, TextSelection.End);
}
}
@@ -1561,13 +1562,13 @@ public int AdviceMouseSink(UnsafeNativeMethods.ITfRangeACP range, UnsafeNativeMe
UiScope.PreviewMouseRightButtonUp += new MouseButtonEventHandler(OnMouseButtonEvent);
UiScope.PreviewMouseMove += new MouseEventHandler(OnMouseEvent);
}
- return NativeMethods.S_OK;
+ return HRESULT.S_OK;
}
// existing mouse sink is unadviced.
public int UnadviceMouseSink(int dwCookie)
{
- int ret = NativeMethods.E_INVALIDARG;
+ int ret = HRESULT.E_INVALIDARG;
int i;
for (i = 0; i < _mouseSinks.Count; i++)
{
@@ -1595,7 +1596,7 @@ public int UnadviceMouseSink(int dwCookie)
{
mSink.Dispose();
}
- ret = NativeMethods.S_OK;
+ ret = HRESULT.S_OK;
break;
}
}
@@ -1616,14 +1617,14 @@ public int UnadviceMouseSink(int dwCookie)
// Called by the TextEditor when the document should go live.
internal void OnAttach()
{
- _netCharCount = this.TextContainer.IMECharCount;
+ _netCharCount = TextContainer.IMECharCount;
// keep _textservicesHost because we may not be in Dispatcher when GC Finalizer calls OnDetach().
_textservicesHost = TextServicesHost.Current;
_textservicesHost.RegisterTextStore(this);
- this.TextContainer.Change += new TextContainerChangeEventHandler(OnTextContainerChange);
+ TextContainer.Change += new TextContainerChangeEventHandler(OnTextContainerChange);
_textservicesproperty = new TextServicesProperty(this);
@@ -1637,9 +1638,9 @@ internal void OnAttach()
internal void OnDetach(bool finalizer)
{
// TextEditor could be GCed before.
- if (this.IsTextEditorValid)
+ if (IsTextEditorValid)
{
- this.TextContainer.Change -= new TextContainerChangeEventHandler(OnTextContainerChange);
+ TextContainer.Change -= new TextContainerChangeEventHandler(OnTextContainerChange);
}
// Relase the naitive resources. Unregister ThreadFocusSink and EditSink and release DocumentManager.
@@ -1888,7 +1889,7 @@ internal void CompleteComposition()
{
if (_isComposing)
{
- FrameworkTextComposition.CompleteCurrentComposition(this.DocumentManager);
+ FrameworkTextComposition.CompleteCurrentComposition(DocumentManager);
}
_previousCompositionStartOffset = -1;
@@ -1903,14 +1904,14 @@ internal ITextPointer CreatePointerAtCharOffset(int charOffset, LogicalDirection
{
ValidateCharOffset(charOffset);
- ITextPointer pointer = this.TextContainer.CreatePointerAtCharOffset(charOffset, direction);
+ ITextPointer pointer = TextContainer.CreatePointerAtCharOffset(charOffset, direction);
if (pointer == null)
{
// A null pointer means that the ITextContainer has no character offsets.
// This happens in an empty TextBox, or in a mal-formed RichTextBox.
// In either case, use the selection start.
- pointer = this.TextSelection.Start.CreatePointer(direction);
+ pointer = TextSelection.Start.CreatePointer(direction);
}
return pointer;
@@ -1957,7 +1958,7 @@ internal void UpdateCompositionText(FrameworkTextComposition composition)
// If we're here it means composition is being finalized
//
range = new TextRange(composition._ResultStart, composition._ResultEnd, true /* ignoreTextUnitBoundaries */);
- text = this.TextEditor._FilterText(composition.Text, range);
+ text = TextEditor._FilterText(composition.Text, range);
if (text.Length != composition.Text.Length)
{
@@ -1967,7 +1968,7 @@ internal void UpdateCompositionText(FrameworkTextComposition composition)
else
{
range = new TextRange(composition._CompositionStart, composition._CompositionEnd, true /* ignoreTextUnitBoundaries */);
- text = this.TextEditor._FilterText(composition.CompositionText, range, /*filterMaxLength:*/false);
+ text = TextEditor._FilterText(composition.CompositionText, range, /*filterMaxLength:*/false);
// A change in length should not happen other than for MaxLength filtering during finalization since we cover those
// cases and reject input if necessary when the IME edits the document in the first place.
@@ -1996,19 +1997,19 @@ internal void UpdateCompositionText(FrameworkTextComposition composition)
compositionUndoUnit.IsLastCompositionUnit = true;
}
- this.TextSelection.BeginChange();
+ TextSelection.BeginChange();
try
{
- this.TextEditor.SetText(range, text, InputLanguageManager.Current.CurrentInputLanguage);
+ TextEditor.SetText(range, text, InputLanguageManager.Current.CurrentInputLanguage);
// shouldn't we record the selection position from the original event instead?
if (_interimSelection)
{
- this.TextSelection.Select(range.Start, range.End);
+ TextSelection.Select(range.Start, range.End);
}
else
{
- this.TextSelection.SetCaretToPosition(range.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
+ TextSelection.SetCaretToPosition(range.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
}
compositionUndoUnit.RecordRedoSelectionState(range.End, range.End);
@@ -2026,7 +2027,7 @@ internal void UpdateCompositionText(FrameworkTextComposition composition)
}
// PUBLIC EVENT:
- this.TextSelection.EndChange();
+ TextSelection.EndChange();
if (IsTracing)
{
@@ -2074,24 +2075,24 @@ internal UIElement RenderScope
{
get
{
- if (this.TextEditor == null)
+ if (TextEditor == null)
return null;
- if (this.TextEditor.TextView == null)
+ if (TextEditor.TextView == null)
return null;
- return this.TextEditor.TextView.RenderScope;
+ return TextEditor.TextView.RenderScope;
}
}
internal FrameworkElement UiScope
{
- get { return this.TextEditor.UiScope; }
+ get { return TextEditor.UiScope; }
}
internal ITextContainer TextContainer
{
- get { return this.TextEditor.TextContainer; }
+ get { return TextEditor.TextContainer; }
}
internal ITextView TextView
@@ -2191,7 +2192,7 @@ private void OnTextContainerChange(object sender, TextContainerChangeEventArgs a
IMECompositionTracer.Trace(this, IMECompositionTraceOp.BOnTextContainerChange);
}
- Invariant.Assert(sender == this.TextContainer);
+ Invariant.Assert(sender == TextContainer);
#if ENABLE_INK_EMBEDDING
// Record the offset of the first symbol in the document
@@ -2312,12 +2313,12 @@ private int GrantLockWorker(UnsafeNativeMethods.LockFlags flags)
int hrSession;
- TextEditor textEditor = this.TextEditor;
+ TextEditor textEditor = TextEditor;
if (textEditor == null)
{
// The app shutdown before we got an async callback.
- hrSession = NativeMethods.E_FAIL;
+ hrSession = HRESULT.E_FAIL;
}
else
{
@@ -2613,7 +2614,7 @@ private void GetVisualInfo(out PresentationSource source, out IWin32Window win32
throw new COMException(SR.TextStore_TS_E_NOLAYOUT, UnsafeNativeMethods.TS_E_NOLAYOUT);
}
- view = this.TextView;
+ view = TextView;
}
// Transforms mil measure unit points to screen pixels.
@@ -2664,7 +2665,7 @@ private void InsertEmbeddedAtPosition(TextPointer position, IComDataObject data,
if (stgmedium.unionmember == IntPtr.Zero)
{
- throw new COMException(SR.TextStore_BadObjectData, NativeMethods.E_INVALIDARG);
+ throw new COMException(SR.TextStore_BadObjectData, HRESULT.E_INVALIDARG);
}
IntPtr hbitmap = SystemDrawingHelper.ConvertMetafileToHBitmap(stgmedium.unionmember);
@@ -2917,7 +2918,7 @@ private void GetCompositionPositions(out ITextPointer start, out ITextPointer en
if (_isComposing)
{
- UnsafeNativeMethods.ITfCompositionView view = FrameworkTextComposition.GetCurrentCompositionView(this.DocumentManager);
+ UnsafeNativeMethods.ITfCompositionView view = FrameworkTextComposition.GetCurrentCompositionView(DocumentManager);
if (view != null)
{
@@ -3111,7 +3112,7 @@ private CompositionParentUndoUnit OpenCompositionUndoUnit()
// and add it to the undo stack.
private CompositionParentUndoUnit OpenCompositionUndoUnit(ITextPointer compositionStart, ITextPointer compositionEnd)
{
- UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent);
+ UndoManager undoManager = UndoManager.GetUndoManager(TextContainer.Parent);
if (undoManager == null || !undoManager.IsEnabled)
{
@@ -3138,16 +3139,16 @@ private CompositionParentUndoUnit OpenCompositionUndoUnit(ITextPointer compositi
GetCompositionPositions(out compositionStart, out compositionEnd);
}
- if (compositionStart != null && compositionStart.CompareTo(this.TextSelection.Start) > 0)
+ if (compositionStart != null && compositionStart.CompareTo(TextSelection.Start) > 0)
{
start = compositionStart;
}
else
{
- start = this.TextSelection.Start;
+ start = TextSelection.Start;
}
- CompositionParentUndoUnit unit = new CompositionParentUndoUnit(this.TextSelection, start, start, _nextUndoUnitIsFirstCompositionUnit);
+ CompositionParentUndoUnit unit = new CompositionParentUndoUnit(TextSelection, start, start, _nextUndoUnitIsFirstCompositionUnit);
_nextUndoUnitIsFirstCompositionUnit = false;
// Add the given composition undo unit to the undo manager and making it
@@ -3272,7 +3273,7 @@ private void RemoveContent(ITextPointer startPosition, ITextPointer endPosition,
// filter MaxLength.
private string FilterCompositionString(string text, int charsToReplaceCount)
{
- string newText = this.TextEditor._FilterText(text, charsToReplaceCount, /*filterMaxLength:*/false);
+ string newText = TextEditor._FilterText(text, charsToReplaceCount, /*filterMaxLength:*/false);
// if the length has been changed, there is no way to recover and we finalize the composition string.
if (newText.Length != text.Length)
@@ -3330,7 +3331,7 @@ private void ValidateChange(UnsafeNativeMethods.TS_TEXTCHANGE change)
// in sync with the actual TextContainer.
private void VerifyTextStoreConsistency()
{
- if (_netCharCount != this.TextContainer.IMECharCount)
+ if (_netCharCount != TextContainer.IMECharCount)
{
Invariant.Assert(false, "TextContainer/TextStore have inconsistent char counts!");
}
@@ -3341,9 +3342,9 @@ private void VerifyTextStoreConsistency()
// too large for the document.
private void ValidateCharOffset(int offset)
{
- if (offset < 0 || offset > this.TextContainer.IMECharCount)
+ if (offset < 0 || offset > TextContainer.IMECharCount)
{
- throw new ArgumentException(SR.Format(SR.TextStore_BadIMECharOffset, offset, this.TextContainer.IMECharCount));
+ throw new ArgumentException(SR.Format(SR.TextStore_BadIMECharOffset, offset, TextContainer.IMECharCount));
}
}
@@ -3437,7 +3438,7 @@ private static void GetAdjustedSelection(ITextPointer startIn, ITextPointer endI
// If we have non-canonical format, give up.
if (start == null || start.IsAtRowEnd || TextPointerBase.IsInBlockUIContainer(start))
{
- throw new COMException(SR.TextStore_CompositionRejected, NativeMethods.E_FAIL);
+ throw new COMException(SR.TextStore_CompositionRejected, HRESULT.E_FAIL);
}
startOut = start;
@@ -3507,7 +3508,7 @@ private void GetNormalizedRange(int startCharOffset, int endCharOffset, out ITex
// then restore state forward incrementally with each public event.
private void HandleCompositionEvents(int previousUndoCount)
{
- if (this.CompositionEventList.Count == 0 ||
+ if (CompositionEventList.Count == 0 ||
_compositionEventState != CompositionEventState.NotRaisingEvents)
{
// No work to do.
@@ -3534,10 +3535,10 @@ private void HandleCompositionEvents(int previousUndoCount)
try
{
// Remember our original selection positions.
- int imeSelectionAnchorOffset = this.TextSelection.AnchorPosition.Offset;
- int imeSelectionMovingOffset = this.TextSelection.MovingPosition.Offset;
+ int imeSelectionAnchorOffset = TextSelection.AnchorPosition.Offset;
+ int imeSelectionMovingOffset = TextSelection.MovingPosition.Offset;
- UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent);
+ UndoManager undoManager = UndoManager.GetUndoManager(TextContainer.Parent);
//
// Undo the last set of IME changes, saving the current state
@@ -3568,7 +3569,7 @@ private void HandleCompositionEvents(int previousUndoCount)
finally
{
// Clear the composition message list
- this.CompositionEventList.Clear();
+ CompositionEventList.Clear();
// Reset the rasising composition events flag
_compositionEventState = CompositionEventState.NotRaisingEvents;
@@ -3586,10 +3587,10 @@ private void HandleCompositionEvents(int previousUndoCount)
// Open the text parent undo unit
private TextParentUndoUnit OpenTextParentUndoUnit()
{
- UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent);
+ UndoManager undoManager = UndoManager.GetUndoManager(TextContainer.Parent);
// Create the text parent undo unit
- TextParentUndoUnit textParentUndoUnit = new TextParentUndoUnit(this.TextSelection, this.TextSelection.Start, this.TextSelection.Start);
+ TextParentUndoUnit textParentUndoUnit = new TextParentUndoUnit(TextSelection, TextSelection.Start, TextSelection.Start);
// Open the text parent undo unit
undoManager.Open(textParentUndoUnit);
@@ -3602,7 +3603,7 @@ private void CloseTextParentUndoUnit(TextParentUndoUnit textParentUndoUnit, Undo
{
if (textParentUndoUnit != null)
{
- UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent);
+ UndoManager undoManager = UndoManager.GetUndoManager(TextContainer.Parent);
// Close the text parent undo unit
undoManager.Close(textParentUndoUnit, undoCloseAction);
@@ -3624,16 +3625,16 @@ private void RaiseCompositionEvents(out int appSelectionAnchorOffset, out int ap
appSelectionAnchorOffset = -1;
appSelectionMovingOffset = -1;
- UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent);
+ UndoManager undoManager = UndoManager.GetUndoManager(TextContainer.Parent);
// Raise the each composition events
- for (int i = 0; i < this.CompositionEventList.Count; i++)
+ for (int i = 0; i < CompositionEventList.Count; i++)
{
- CompositionEventRecord record = this.CompositionEventList[i];
- FrameworkTextComposition composition = CreateComposition(this.TextEditor, this);
+ CompositionEventRecord record = CompositionEventList[i];
+ FrameworkTextComposition composition = CreateComposition(TextEditor, this);
- ITextPointer start = this.TextContainer.CreatePointerAtOffset(record.StartOffsetBefore, LogicalDirection.Backward);
- ITextPointer end = this.TextContainer.CreatePointerAtOffset(record.EndOffsetBefore, LogicalDirection.Forward);
+ ITextPointer start = TextContainer.CreatePointerAtOffset(record.StartOffsetBefore, LogicalDirection.Backward);
+ ITextPointer end = TextContainer.CreatePointerAtOffset(record.EndOffsetBefore, LogicalDirection.Forward);
bool handled = false;
_handledByTextStoreListener = false;
@@ -3774,8 +3775,8 @@ private void RaiseCompositionEvents(out int appSelectionAnchorOffset, out int ap
if (_compositionModifiedByEventListener)
{
// Stop rasing the composition by application's text change or handled events
- appSelectionAnchorOffset = this.TextSelection.AnchorPosition.Offset;
- appSelectionMovingOffset = this.TextSelection.MovingPosition.Offset;
+ appSelectionAnchorOffset = TextSelection.AnchorPosition.Offset;
+ appSelectionMovingOffset = TextSelection.MovingPosition.Offset;
break;
}
@@ -3801,8 +3802,8 @@ private void RaiseCompositionEvents(out int appSelectionAnchorOffset, out int ap
if (_compositionModifiedByEventListener)
{
// Stop rasing the composition by application's text change or handled events
- appSelectionAnchorOffset = this.TextSelection.AnchorPosition.Offset;
- appSelectionMovingOffset = this.TextSelection.MovingPosition.Offset;
+ appSelectionAnchorOffset = TextSelection.AnchorPosition.Offset;
+ appSelectionMovingOffset = TextSelection.MovingPosition.Offset;
break;
}
}
@@ -3818,12 +3819,12 @@ private bool IsMaxLengthExceeded(string textData, int charsToReplaceCount)
{
// We only filter text for plain text content
- if (!this.TextEditor.AcceptsRichContent && this.TextEditor.MaxLength > 0)
+ if (!TextEditor.AcceptsRichContent && TextEditor.MaxLength > 0)
{
- ITextContainer textContainer = this.TextContainer;
+ ITextContainer textContainer = TextContainer;
int currentLength = textContainer.SymbolCount - charsToReplaceCount;
- int extraCharsAllowed = Math.Max(0, this.TextEditor.MaxLength - currentLength);
+ int extraCharsAllowed = Math.Max(0, TextEditor.MaxLength - currentLength);
// Does textData length exceed allowed char length?
if (textData.Length > extraCharsAllowed)
@@ -3868,7 +3869,7 @@ private void SetFinalDocumentState(UndoManager undoManager, Stack imeChangeStack
IMECompositionTracer.Trace(this, IMECompositionTraceOp.BSetFinalDocumentState);
}
- this.TextSelection.BeginChangeNoUndo();
+ TextSelection.BeginChangeNoUndo();
// make sure this method decreases the IME reentrancy count,
// even if an exception bypasses the normal codepath
@@ -3893,7 +3894,7 @@ private void SetFinalDocumentState(UndoManager undoManager, Stack imeChangeStack
RedoQuietly(imeChangeCount);
// At this point the document should be exactly where the IME left it.
- Invariant.Assert(_netCharCount == this.TextContainer.IMECharCount);
+ Invariant.Assert(_netCharCount == TextContainer.IMECharCount);
// we are done replaying IME changes, IME lock requests can be granted again
--_replayingIMEChangeReentrancyCount;
@@ -3947,14 +3948,14 @@ private void SetFinalDocumentState(UndoManager undoManager, Stack imeChangeStack
RedoQuietly(appChangeCount);
// The IME should have received the app change events from preceeding RedoQuietly.
- Invariant.Assert(_netCharCount == this.TextContainer.IMECharCount);
+ Invariant.Assert(_netCharCount == TextContainer.IMECharCount);
// we can't rely on Redo fixing up the selection.
// If the app only modified the selection appChangeCount == 0.
- ITextPointer anchor = this.TextContainer.CreatePointerAtOffset(appSelectionAnchorOffset, LogicalDirection.Forward);
- ITextPointer moving = this.TextContainer.CreatePointerAtOffset(appSelectionMovingOffset, LogicalDirection.Forward);
+ ITextPointer anchor = TextContainer.CreatePointerAtOffset(appSelectionAnchorOffset, LogicalDirection.Forward);
+ ITextPointer moving = TextContainer.CreatePointerAtOffset(appSelectionMovingOffset, LogicalDirection.Forward);
- this.TextSelection.Select(anchor, moving);
+ TextSelection.Select(anchor, moving);
//
// We may have a filtering related composition undo unit on the top
@@ -3972,10 +3973,10 @@ private void SetFinalDocumentState(UndoManager undoManager, Stack imeChangeStack
else
{
// Restore the selection.
- ITextPointer anchor = this.TextContainer.CreatePointerAtOffset(imeSelectionAnchorOffset, LogicalDirection.Backward);
- ITextPointer moving = this.TextContainer.CreatePointerAtOffset(imeSelectionMovingOffset, LogicalDirection.Backward);
+ ITextPointer anchor = TextContainer.CreatePointerAtOffset(imeSelectionAnchorOffset, LogicalDirection.Backward);
+ ITextPointer moving = TextContainer.CreatePointerAtOffset(imeSelectionMovingOffset, LogicalDirection.Backward);
- this.TextSelection.Select(anchor, moving);
+ TextSelection.Select(anchor, moving);
// Since we just had a composition accepted, we need to merge all
// of its individual units now.
@@ -3985,7 +3986,7 @@ private void SetFinalDocumentState(UndoManager undoManager, Stack imeChangeStack
finally
{
_replayingIMEChangeReentrancyCount += deltaReplayingIMEChangeReentrancyCount;
- this.TextSelection.EndChange(false /* disableScroll */, true /* skipEvents */);
+ TextSelection.EndChange(false /* disableScroll */, true /* skipEvents */);
}
if (IsTracing)
@@ -4004,16 +4005,16 @@ private void UndoQuietly(int count)
IMECompositionTracer.Trace(this, IMECompositionTraceOp.BUndoQuietly, count);
}
- UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent);
+ UndoManager undoManager = UndoManager.GetUndoManager(TextContainer.Parent);
- this.TextSelection.BeginChangeNoUndo();
+ TextSelection.BeginChangeNoUndo();
try
{
undoManager.Undo(count);
}
finally
{
- this.TextSelection.EndChange(false /* disableScroll */, true /* skipEvents */);
+ TextSelection.EndChange(false /* disableScroll */, true /* skipEvents */);
}
if (IsTracing)
@@ -4033,16 +4034,16 @@ private void RedoQuietly(int count)
IMECompositionTracer.Trace(this, IMECompositionTraceOp.BRedoQuietly, count);
}
- UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent);
+ UndoManager undoManager = UndoManager.GetUndoManager(TextContainer.Parent);
- this.TextSelection.BeginChangeNoUndo();
+ TextSelection.BeginChangeNoUndo();
try
{
undoManager.Redo(count);
}
finally
{
- this.TextSelection.EndChange(false /* disableScroll */, true /* skipEvents */);
+ TextSelection.EndChange(false /* disableScroll */, true /* skipEvents */);
}
if (IsTracing)
@@ -4056,7 +4057,7 @@ private void RedoQuietly(int count)
// single undo units.
private void MergeCompositionUndoUnits()
{
- UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent);
+ UndoManager undoManager = UndoManager.GetUndoManager(TextContainer.Parent);
if (undoManager == null || !undoManager.IsEnabled)
{
@@ -4102,7 +4103,7 @@ private void MergeCompositionUndoUnits()
// if any. Does not actually pop the unit.
private CompositionParentUndoUnit PeekCompositionParentUndoUnit()
{
- UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent);
+ UndoManager undoManager = UndoManager.GetUndoManager(TextContainer.Parent);
if (undoManager == null || !undoManager.IsEnabled)
return null;
@@ -4132,14 +4133,14 @@ private TextEditor TextEditor
private ITextSelection TextSelection
{
- get { return this.TextEditor.Selection; }
+ get { return TextEditor.Selection; }
}
private bool IsReadOnly
{
get
{
- return ((bool)this.UiScope.GetValue(TextEditor.IsReadOnlyProperty) || TextEditor.IsReadOnly);
+ return ((bool)UiScope.GetValue(TextEditor.IsReadOnlyProperty) || TextEditor.IsReadOnly);
}
}
@@ -4237,7 +4238,7 @@ internal TextEditor TextEditor
{
try
{
- return (TextEditor)this.Target;
+ return (TextEditor)Target;
}
catch (InvalidOperationException)
{
@@ -4361,15 +4362,15 @@ internal void MergeCompositionUnit(CompositionParentUndoUnit unit)
{
object[] units = unit.CopyUnits();
- Invariant.Assert(this.Locked); // If this fails, then the Locked = true below is invalid.
- this.Locked = false;
+ Invariant.Assert(Locked); // If this fails, then the Locked = true below is invalid.
+ Locked = false;
for (int i = units.Length - 1; i >= 0; i--)
{
Add((IUndoUnit)units[i]);
}
- this.Locked = true;
+ Locked = true;
MergeRedoSelectionState(unit);
@@ -4402,7 +4403,7 @@ internal bool IsLastCompositionUnit
// Returns a shallow copy of this units children.
private object[] CopyUnits()
{
- return this.Units.ToArray();
+ return Units.ToArray();
}
private readonly bool _isFirstCompositionUnit;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs
index c66b388311c..5b33abac41f 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -31,6 +31,7 @@
using MS.Internal;
using MS.Internal.Controls;
using MS.Win32;
+using Windows.Win32.Foundation;
// Since we disable PreSharp warnings in this file, PreSharp warning is unknown to C# compiler.
// We first need to disable warnings about unknown message numbers and unknown pragmas.
@@ -65,8 +66,8 @@ static ActiveXHost()
{
// We use this map to lookup which invalidator method to call
// when the Avalon parent's properties change.
- invalidatorMap[UIElement.VisibilityProperty] = new PropertyInvalidator(OnVisibilityInvalidated);
- invalidatorMap[FrameworkElement.IsEnabledProperty] = new PropertyInvalidator(OnIsEnabledInvalidated);
+ invalidatorMap[VisibilityProperty] = new PropertyInvalidator(OnVisibilityInvalidated);
+ invalidatorMap[IsEnabledProperty] = new PropertyInvalidator(OnIsEnabledInvalidated);
// register for access keys
EventManager.RegisterClassHandler(typeof(ActiveXHost), AccessKeyManager.AccessKeyPressedEvent, new AccessKeyPressedEventHandler(OnAccessKeyPressed));
@@ -140,7 +141,7 @@ protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
///
protected override HandleRef BuildWindowCore(HandleRef hwndParent)
{
- this.ParentHandle = hwndParent;
+ ParentHandle = hwndParent;
//BuildWindowCore should only be called if visible. Bug 1236445 tracks this.
TransitionUpTo(ActiveXHelper.ActiveXState.InPlaceActive);
@@ -180,7 +181,7 @@ protected override void OnWindowPositionChanged(Rect bounds)
//SetExtent only sets height and width, can call it for perf if X, Y haven't changed
//We need to call SetObjectRects instead, which updates X, Y, width and height
//OnActiveXRectChange calls SetObjectRects
- this.ActiveXSite.OnActiveXRectChange(_bounds);
+ ActiveXSite.OnActiveXRectChange(_bounds);
}
///
@@ -395,108 +396,108 @@ internal void SetAxHostState(int mask, bool value)
internal void TransitionUpTo(ActiveXHelper.ActiveXState state)
{
- if (!this.GetAxHostState(ActiveXHelper.inTransition))
+ if (!GetAxHostState(ActiveXHelper.inTransition))
{
- this.SetAxHostState(ActiveXHelper.inTransition, true);
+ SetAxHostState(ActiveXHelper.inTransition, true);
try
{
ActiveXHelper.ActiveXState oldState;
- while (state > this.ActiveXState)
+ while (state > ActiveXState)
{
- oldState = this.ActiveXState;
+ oldState = ActiveXState;
- switch (this.ActiveXState)
+ switch (ActiveXState)
{
case ActiveXHelper.ActiveXState.Passive:
TransitionFromPassiveToLoaded();
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Failed transition");
- this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Failed transition");
+ ActiveXState = ActiveXHelper.ActiveXState.Loaded;
break;
case ActiveXHelper.ActiveXState.Loaded:
TransitionFromLoadedToRunning();
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Failed transition");
- this.ActiveXState = ActiveXHelper.ActiveXState.Running;
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Running, "Failed transition");
+ ActiveXState = ActiveXHelper.ActiveXState.Running;
break;
case ActiveXHelper.ActiveXState.Running:
TransitionFromRunningToInPlaceActive();
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Failed transition");
- this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Failed transition");
+ ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
break;
case ActiveXHelper.ActiveXState.InPlaceActive:
TransitionFromInPlaceActiveToUIActive();
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.UIActive, "Failed transition");
- this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.UIActive, "Failed transition");
+ ActiveXState = ActiveXHelper.ActiveXState.UIActive;
break;
default:
Debug.Fail("bad state");
- this.ActiveXState = this.ActiveXState + 1; // To exit the loop
+ ActiveXState = ActiveXState + 1; // To exit the loop
break;
}
- OnActiveXStateChange((int)oldState, (int)this.ActiveXState);
+ OnActiveXStateChange((int)oldState, (int)ActiveXState);
}
}
finally
{
- this.SetAxHostState(ActiveXHelper.inTransition, false);
+ SetAxHostState(ActiveXHelper.inTransition, false);
}
}
}
internal void TransitionDownTo(ActiveXHelper.ActiveXState state)
{
- if (!this.GetAxHostState(ActiveXHelper.inTransition))
+ if (!GetAxHostState(ActiveXHelper.inTransition))
{
- this.SetAxHostState(ActiveXHelper.inTransition, true);
+ SetAxHostState(ActiveXHelper.inTransition, true);
try
{
ActiveXHelper.ActiveXState oldState;
- while (state < this.ActiveXState)
+ while (state < ActiveXState)
{
- oldState = this.ActiveXState;
+ oldState = ActiveXState;
- switch (this.ActiveXState)
+ switch (ActiveXState)
{
case ActiveXHelper.ActiveXState.Open:
Debug.Fail("how did we ever get into the open state?");
- this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
+ ActiveXState = ActiveXHelper.ActiveXState.UIActive;
break;
case ActiveXHelper.ActiveXState.UIActive:
TransitionFromUIActiveToInPlaceActive();
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Failed transition");
- this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Failed transition");
+ ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
break;
case ActiveXHelper.ActiveXState.InPlaceActive:
TransitionFromInPlaceActiveToRunning();
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Failed transition");
- this.ActiveXState = ActiveXHelper.ActiveXState.Running;
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Running, "Failed transition");
+ ActiveXState = ActiveXHelper.ActiveXState.Running;
break;
case ActiveXHelper.ActiveXState.Running:
TransitionFromRunningToLoaded();
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Failed transition");
- this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Failed transition");
+ ActiveXState = ActiveXHelper.ActiveXState.Loaded;
break;
case ActiveXHelper.ActiveXState.Loaded:
TransitionFromLoadedToPassive();
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Passive, "Failed transition");
- this.ActiveXState = ActiveXHelper.ActiveXState.Passive;
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Passive, "Failed transition");
+ ActiveXState = ActiveXHelper.ActiveXState.Passive;
break;
default:
Debug.Fail("bad state");
- this.ActiveXState = this.ActiveXState - 1; // To exit the loop
+ ActiveXState = ActiveXState - 1; // To exit the loop
break;
}
- OnActiveXStateChange((int)oldState, (int)this.ActiveXState);
+ OnActiveXStateChange((int)oldState, (int)ActiveXState);
}
}
finally
{
- this.SetAxHostState(ActiveXHelper.inTransition, false);
+ SetAxHostState(ActiveXHelper.inTransition, false);
}
}
}
@@ -505,13 +506,13 @@ internal bool DoVerb(int verb)
{
int hr = _axOleObject.DoVerb(verb,
IntPtr.Zero,
- this.ActiveXSite,
+ ActiveXSite,
0,
- this.ParentHandle.Handle,
+ ParentHandle.Handle,
_bounds);
- Debug.Assert(hr == NativeMethods.S_OK, $"DoVerb call failed for verb 0x{verb:X}");
- return hr == NativeMethods.S_OK;
+ Debug.Assert(hr == HRESULT.S_OK, $"DoVerb call failed for verb 0x{verb:X}");
+ return hr == HRESULT.S_OK;
}
internal void AttachWindow(IntPtr hwnd)
@@ -525,36 +526,36 @@ internal void AttachWindow(IntPtr hwnd)
_axWindow = new HandleRef(this, hwnd);
- if (this.ParentHandle.Handle != IntPtr.Zero)
+ if (ParentHandle.Handle != IntPtr.Zero)
{
- UnsafeNativeMethods.SetParent(_axWindow, this.ParentHandle);
+ UnsafeNativeMethods.SetParent(_axWindow, ParentHandle);
}
}
private void StartEvents()
{
- if (!this.GetAxHostState(ActiveXHelper.sinkAttached))
+ if (!GetAxHostState(ActiveXHelper.sinkAttached))
{
- this.SetAxHostState(ActiveXHelper.sinkAttached, true);
+ SetAxHostState(ActiveXHelper.sinkAttached, true);
CreateSink();
}
- this.ActiveXSite.StartEvents();
+ ActiveXSite.StartEvents();
}
private void StopEvents()
{
- if (this.GetAxHostState(ActiveXHelper.sinkAttached))
+ if (GetAxHostState(ActiveXHelper.sinkAttached))
{
- this.SetAxHostState(ActiveXHelper.sinkAttached, false);
+ SetAxHostState(ActiveXHelper.sinkAttached, false);
DetachSink();
}
- this.ActiveXSite.StopEvents();
+ ActiveXSite.StopEvents();
}
private void TransitionFromPassiveToLoaded()
{
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Passive, "Wrong start state to transition from");
- if (this.ActiveXState == ActiveXHelper.ActiveXState.Passive)
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Passive, "Wrong start state to transition from");
+ if (ActiveXState == ActiveXHelper.ActiveXState.Passive)
{
//
// First, create the ActiveX control
@@ -565,19 +566,19 @@ private void TransitionFromPassiveToLoaded()
//
// We are now Loaded!
- this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
+ ActiveXState = ActiveXHelper.ActiveXState.Loaded;
//
// Lets give them a chance to cast the ActiveX object
// to the appropriate interfaces.
- this.AttachInterfacesInternal();
+ AttachInterfacesInternal();
}
}
private void TransitionFromLoadedToPassive()
{
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Wrong start state to transition from");
- if (this.ActiveXState == ActiveXHelper.ActiveXState.Loaded)
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Wrong start state to transition from");
+ if (ActiveXState == ActiveXHelper.ActiveXState.Loaded)
{
//
// Need to make sure that we don't handle any PropertyChanged
@@ -591,7 +592,7 @@ private void TransitionFromLoadedToPassive()
{
//
// Lets first get the cached interface pointers of _axInstance released.
- this.DetachInterfacesInternal();
+ DetachInterfacesInternal();
Marshal.FinalReleaseComObject(_axInstance);
_axInstance = null;
@@ -604,39 +605,39 @@ private void TransitionFromLoadedToPassive()
//
// We are now Passive!
- this.ActiveXState = ActiveXHelper.ActiveXState.Passive;
+ ActiveXState = ActiveXHelper.ActiveXState.Passive;
}
}
private void TransitionFromLoadedToRunning()
{
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Wrong start state to transition from");
- if (this.ActiveXState == ActiveXHelper.ActiveXState.Loaded)
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Wrong start state to transition from");
+ if (ActiveXState == ActiveXHelper.ActiveXState.Loaded)
{
//
// See if the ActiveX control returns OLEMISC_SETCLIENTSITEFIRST
int bits = 0;
- int hr = _axOleObject.GetMiscStatus(NativeMethods.DVASPECT_CONTENT, out bits);
- if (NativeMethods.Succeeded(hr) && ((bits & NativeMethods.OLEMISC_SETCLIENTSITEFIRST) != 0))
+ HRESULT result = _axOleObject.GetMiscStatus(NativeMethods.DVASPECT_CONTENT, out bits);
+ if (result.Succeeded && ((bits & NativeMethods.OLEMISC_SETCLIENTSITEFIRST) != 0))
{
//
// Simply setting the site to the ActiveX control should activate it.
// And this will take us to the Running state.
- _axOleObject.SetClientSite(this.ActiveXSite);
+ _axOleObject.SetClientSite(ActiveXSite);
}
StartEvents();
//
// We are now Running!
- this.ActiveXState = ActiveXHelper.ActiveXState.Running;
+ ActiveXState = ActiveXHelper.ActiveXState.Running;
}
}
private void TransitionFromRunningToLoaded()
{
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Wrong start state to transition from");
- if (this.ActiveXState == ActiveXHelper.ActiveXState.Running)
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Running, "Wrong start state to transition from");
+ if (ActiveXState == ActiveXHelper.ActiveXState.Running)
{
StopEvents();
@@ -646,14 +647,14 @@ private void TransitionFromRunningToLoaded()
//
// We are now Loaded!
- this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
+ ActiveXState = ActiveXHelper.ActiveXState.Loaded;
}
}
private void TransitionFromRunningToInPlaceActive()
{
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Wrong start state to transition from");
- if (this.ActiveXState == ActiveXHelper.ActiveXState.Running)
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.Running, "Wrong start state to transition from");
+ if (ActiveXState == ActiveXHelper.ActiveXState.Running)
{
try
{
@@ -673,14 +674,14 @@ private void TransitionFromRunningToInPlaceActive()
//
// We are now InPlaceActive!
- this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
+ ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
}
}
private void TransitionFromInPlaceActiveToRunning()
{
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Wrong start state to transition from");
- if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Wrong start state to transition from");
+ if (ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
{
//
// InPlaceDeactivate.
@@ -688,34 +689,33 @@ private void TransitionFromInPlaceActiveToRunning()
//
// We are now Running!
- this.ActiveXState = ActiveXHelper.ActiveXState.Running;
+ ActiveXState = ActiveXHelper.ActiveXState.Running;
}
}
private void TransitionFromInPlaceActiveToUIActive()
{
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Wrong start state to transition from");
- if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Wrong start state to transition from");
+ if (ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
{
DoVerb(NativeMethods.OLEIVERB_UIACTIVATE);
//
// We are now UIActive!
- this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
+ ActiveXState = ActiveXHelper.ActiveXState.UIActive;
}
}
private void TransitionFromUIActiveToInPlaceActive()
{
- Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.UIActive, "Wrong start state to transition from");
- if (this.ActiveXState == ActiveXHelper.ActiveXState.UIActive)
+ Debug.Assert(ActiveXState == ActiveXHelper.ActiveXState.UIActive, "Wrong start state to transition from");
+ if (ActiveXState == ActiveXHelper.ActiveXState.UIActive)
{
- int hr = _axOleInPlaceObject.UIDeactivate();
- Debug.Assert(NativeMethods.Succeeded(hr), "Failed in IOleInPlaceObject.UiDeactivate");
+ HRESULT result = _axOleInPlaceObject.UIDeactivate();
+ Debug.Assert(result.Succeeded, "Failed in IOleInPlaceObject.UiDeactivate");
- //
// We are now InPlaceActive!
- this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
+ ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
}
}
@@ -837,7 +837,7 @@ private void OnInitialized(object sender, EventArgs e)
// AccessKeyManager.Register(k.ToString(), this);
//}
- this.Initialized -= new EventHandler(this.OnInitialized);
+ Initialized -= new EventHandler(OnInitialized);
//Cannot inplace activate yet, since BuildWindowCore is not called yet
//and we need that for getting the parent handle to pass on to the control.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpList.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpList.cs
index 3822e12022a..fe96eab7adf 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpList.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpList.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -12,8 +12,7 @@
using MS.Internal.AppModel;
using MS.Internal.Interop;
using MS.Win32;
-
-using HRESULT = MS.Internal.Interop.HRESULT;
+using Windows.Win32.Foundation;
namespace System.Windows.Shell
{
@@ -411,7 +410,8 @@ private static string _RuntimeId
hr = HRESULT.S_OK;
appId = null;
}
- hr.ThrowIfFailed();
+
+ hr.ThrowOnFailureUnwrapWin32();
return appId;
}
}
@@ -482,7 +482,7 @@ private void ApplyList()
// if they really care. We'll happily add too many items with the hope that if the user changes the setting
// items will be recovered from the overflow.
uint slotsVisible;
- Guid removedIid = new Guid(IID.ObjectArray);
+ Guid removedIid = new Guid(MS.Internal.AppModel.IID.ObjectArray);
var objectsRemoved = (IObjectArray)destinationList.BeginList(out slotsVisible, ref removedIid);
// Keep track of the items that were previously removed by the user.
@@ -765,7 +765,7 @@ private static List<_ShellObjectPair> GenerateJumpItems(IObjectArray shellObject
var retList = new List<_ShellObjectPair>();
- Guid unknownIid = new Guid(IID.Unknown);
+ Guid unknownIid = new Guid(MS.Internal.AppModel.IID.Unknown);
uint count = shellObjects.GetCount();
for (uint i = 0; i < count; ++i)
{
@@ -831,7 +831,7 @@ private static void AddCategory(ICustomDestinationList cdl, string category, Lis
{
// If the list contained items that could not be added because this object isn't a handler
// then drop all ShellItems and retry without them.
- if (isHeterogenous && hr == HRESULT.DESTS_E_NO_MATCHING_ASSOC_HANDLER)
+ if (isHeterogenous && hr == (HRESULT)unchecked((int)0x80040F03)) // HRESULT.DESTS_E_NO_MATCHING_ASSOC_HANDLER
{
if (TraceShell.IsEnabled)
{
@@ -860,7 +860,7 @@ private static void AddCategory(ICustomDestinationList cdl, string category, Lis
}
else
{
- Debug.Assert(HRESULT.DESTS_E_NO_MATCHING_ASSOC_HANDLER != hr);
+ Debug.Assert(hr != (HRESULT)unchecked((int)0x80040F03)); // HRESULT.DESTS_E_NO_MATCHING_ASSOC_HANDLER
// If we failed for some other reason, just reject everything.
foreach (var item in jumpItems)
{
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/ErrorCodes.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/ErrorCodes.cs
deleted file mode 100644
index b72e0e80252..00000000000
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/ErrorCodes.cs
+++ /dev/null
@@ -1,466 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-namespace Standard
-{
- ///
- /// Wrapper for common Win32 status codes.
- ///
- [StructLayout(LayoutKind.Explicit)]
- internal struct Win32Error
- {
- [FieldOffset(0)]
- private readonly int _value;
-
- // NOTE: These public static field declarations are automatically
- // picked up by (HRESULT's) ToString through reflection.
-
- /// The operation completed successfully.
- public static readonly Win32Error ERROR_SUCCESS = new Win32Error(0);
- /// Incorrect function.
- public static readonly Win32Error ERROR_INVALID_FUNCTION = new Win32Error(1);
- /// The system cannot find the file specified.
- public static readonly Win32Error ERROR_FILE_NOT_FOUND = new Win32Error(2);
- /// The system cannot find the path specified.
- public static readonly Win32Error ERROR_PATH_NOT_FOUND = new Win32Error(3);
- /// The system cannot open the file.
- public static readonly Win32Error ERROR_TOO_MANY_OPEN_FILES = new Win32Error(4);
- /// Access is denied.
- public static readonly Win32Error ERROR_ACCESS_DENIED = new Win32Error(5);
- /// The handle is invalid.
- public static readonly Win32Error ERROR_INVALID_HANDLE = new Win32Error(6);
- /// Not enough storage is available to complete this operation.
- public static readonly Win32Error ERROR_OUTOFMEMORY = new Win32Error(14);
- /// There are no more files.
- public static readonly Win32Error ERROR_NO_MORE_FILES = new Win32Error(18);
- /// The process cannot access the file because it is being used by another process.
- public static readonly Win32Error ERROR_SHARING_VIOLATION = new Win32Error(32);
- /// The parameter is incorrect.
- public static readonly Win32Error ERROR_INVALID_PARAMETER = new Win32Error(87);
- /// The data area passed to a system call is too small.
- public static readonly Win32Error ERROR_INSUFFICIENT_BUFFER = new Win32Error(122);
- /// Cannot nest calls to LoadModule.
- public static readonly Win32Error ERROR_NESTING_NOT_ALLOWED = new Win32Error(215);
- /// Illegal operation attempted on a registry key that has been marked for deletion.
- public static readonly Win32Error ERROR_KEY_DELETED = new Win32Error(1018);
- /// Element not found.
- public static readonly Win32Error ERROR_NOT_FOUND = new Win32Error(1168);
- /// There was no match for the specified key in the index.
- public static readonly Win32Error ERROR_NO_MATCH = new Win32Error(1169);
- /// An invalid device was specified.
- public static readonly Win32Error ERROR_BAD_DEVICE = new Win32Error(1200);
- /// The operation was canceled by the user.
- public static readonly Win32Error ERROR_CANCELLED = new Win32Error(1223);
- /// The window class was already registered.
- public static readonly Win32Error ERROR_CLASS_ALREADY_EXISTS = new Win32Error(1410);
- /// The specified datatype is invalid.
- public static readonly Win32Error ERROR_INVALID_DATATYPE = new Win32Error(1804);
- /// Invalid window handle.
- public static readonly Win32Error ERROR_INVALID_WINDOW_HANDLE = new Win32Error(1400);
- /// This operation returned because the timeout period expired.
- public static readonly Win32Error ERROR_TIMEOUT = new Win32Error(1460);
-
- ///
- /// Create a new Win32 error.
- ///
- /// The integer value of the error.
- public Win32Error(int i)
- {
- _value = i;
- }
-
- /// Performs HRESULT_FROM_WIN32 conversion.
- /// The Win32 error being converted to an HRESULT.
- /// The equivilent HRESULT value.
- public static explicit operator HRESULT(Win32Error error)
- {
- // #define __HRESULT_FROM_WIN32(x)
- // ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000)))
- if (error._value <= 0)
- {
- return new HRESULT((uint)error._value);
- }
- return HRESULT.Make(true, Facility.Win32, error._value & 0x0000FFFF);
- }
-
- // Method version of the cast operation
- /// Performs HRESULT_FROM_WIN32 conversion.
- /// The Win32 error being converted to an HRESULT.
- /// The equivilent HRESULT value.
- public HRESULT ToHRESULT()
- {
- return (HRESULT)this;
- }
-
- /// Performs the equivalent of Win32's GetLastError()
- /// A Win32Error instance with the result of the native GetLastError
- public static Win32Error GetLastError()
- {
- return new Win32Error(Marshal.GetLastWin32Error());
- }
-
- public override bool Equals(object obj)
- {
- try
- {
- return ((Win32Error)obj)._value == _value;
- }
- catch (InvalidCastException)
- {
- return false;
- }
- }
-
- public override int GetHashCode()
- {
- return _value.GetHashCode();
- }
-
- ///
- /// Compare two Win32 error codes for equality.
- ///
- /// The first error code to compare.
- /// The second error code to compare.
- /// Whether the two error codes are the same.
- public static bool operator ==(Win32Error errLeft, Win32Error errRight)
- {
- return errLeft._value == errRight._value;
- }
-
- ///
- /// Compare two Win32 error codes for inequality.
- ///
- /// The first error code to compare.
- /// The second error code to compare.
- /// Whether the two error codes are not the same.
- public static bool operator !=(Win32Error errLeft, Win32Error errRight)
- {
- return !(errLeft == errRight);
- }
- }
-
- internal enum Facility
- {
- /// FACILITY_NULL
- Null = 0,
- /// FACILITY_RPC
- Rpc = 1,
- /// FACILITY_DISPATCH
- Dispatch = 2,
- /// FACILITY_STORAGE
- Storage = 3,
- /// FACILITY_ITF
- Itf = 4,
- /// FACILITY_WIN32
- Win32 = 7,
- /// FACILITY_WINDOWS
- Windows = 8,
- /// FACILITY_CONTROL
- Control = 10,
- /// MSDN doced facility code for ESE errors.
- Ese = 0xE5E,
- /// FACILITY_WINCODEC (WIC)
- WinCodec = 0x898,
- }
-
- /// Wrapper for HRESULT status codes.
- [StructLayout(LayoutKind.Explicit)]
- internal struct HRESULT
- {
- [FieldOffset(0)]
- private readonly uint _value;
-
- // NOTE: These public static field declarations are automatically
- // picked up by ToString through reflection.
- /// S_OK
- public static readonly HRESULT S_OK = new HRESULT(0x00000000);
- /// S_FALSE
- public static readonly HRESULT S_FALSE = new HRESULT(0x00000001);
- /// E_PENDING
- public static readonly HRESULT E_PENDING = new HRESULT(0x8000000A);
- /// E_NOTIMPL
- public static readonly HRESULT E_NOTIMPL = new HRESULT(0x80004001);
- /// E_NOINTERFACE
- public static readonly HRESULT E_NOINTERFACE = new HRESULT(0x80004002);
- /// E_POINTER
- public static readonly HRESULT E_POINTER = new HRESULT(0x80004003);
- /// E_ABORT
- public static readonly HRESULT E_ABORT = new HRESULT(0x80004004);
- /// E_FAIL
- public static readonly HRESULT E_FAIL = new HRESULT(0x80004005);
- /// E_UNEXPECTED
- public static readonly HRESULT E_UNEXPECTED = new HRESULT(0x8000FFFF);
- /// STG_E_INVALIDFUNCTION
- public static readonly HRESULT STG_E_INVALIDFUNCTION = new HRESULT(0x80030001);
- /// REGDB_E_CLASSNOTREG
- public static readonly HRESULT REGDB_E_CLASSNOTREG = new HRESULT(0x80040154);
-
- /// DESTS_E_NO_MATCHING_ASSOC_HANDLER. Win7 internal error code for Jump Lists.
- /// There is no Assoc Handler for the given item registered by the specified application.
- public static readonly HRESULT DESTS_E_NO_MATCHING_ASSOC_HANDLER = new HRESULT(0x80040F03);
- /// DESTS_E_NORECDOCS. Win7 internal error code for Jump Lists.
- /// The given item is excluded from the recent docs folder by the NoRecDocs bit on its registration.
- public static readonly HRESULT DESTS_E_NORECDOCS = new HRESULT(0x80040F04);
- /// DESTS_E_NOTALLCLEARED. Win7 internal error code for Jump Lists.
- /// Not all of the items were successfully cleared
- public static readonly HRESULT DESTS_E_NOTALLCLEARED = new HRESULT(0x80040F05);
-
- /// E_ACCESSDENIED
- /// Win32Error ERROR_ACCESS_DENIED.
- public static readonly HRESULT E_ACCESSDENIED = new HRESULT(0x80070005);
- /// E_OUTOFMEMORY
- /// Win32Error ERROR_OUTOFMEMORY.
- public static readonly HRESULT E_OUTOFMEMORY = new HRESULT(0x8007000E);
- /// E_INVALIDARG
- /// Win32Error ERROR_INVALID_PARAMETER.
- public static readonly HRESULT E_INVALIDARG = new HRESULT(0x80070057);
- /// INTSAFE_E_ARITHMETIC_OVERFLOW
- public static readonly HRESULT INTSAFE_E_ARITHMETIC_OVERFLOW = new HRESULT(0x80070216);
- /// COR_E_OBJECTDISPOSED
- public static readonly HRESULT COR_E_OBJECTDISPOSED = new HRESULT(0x80131622);
- /// WC_E_GREATERTHAN
- public static readonly HRESULT WC_E_GREATERTHAN = new HRESULT(0xC00CEE23);
- /// WC_E_SYNTAX
- public static readonly HRESULT WC_E_SYNTAX = new HRESULT(0xC00CEE2D);
-
- ///
- /// Create an HRESULT from an integer value.
- ///
- ///
- public HRESULT(uint i)
- {
- _value = i;
- }
-
- public static HRESULT Make(bool severe, Facility facility, int code)
- {
- //#define MAKE_HRESULT(sev,fac,code) \
- // ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
-
- // Severity has 1 bit reserved.
- // bitness is enforced by the boolean parameter.
-
- // Facility has 11 bits reserved (different than SCODES, which have 4 bits reserved)
- // MSDN documentation incorrectly uses 12 bits for the ESE facility (e5e), so go ahead and let that one slide.
- // And WIC also ignores it the documented size...
- Assert.Implies((int)facility != (int)((int)facility & 0x1FF), facility == Facility.Ese || facility == Facility.WinCodec);
- // Code has 4 bits reserved.
- Assert.AreEqual(code, code & 0xFFFF);
-
- return new HRESULT((uint)((severe ? (1 << 31) : 0) | ((int)facility << 16) | code));
- }
-
- ///
- /// retrieve HRESULT_FACILITY
- ///
- public Facility Facility
- {
- get
- {
- return GetFacility((int)_value);
- }
- }
-
- public static Facility GetFacility(int errorCode)
- {
- // #define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
- return (Facility)((errorCode >> 16) & 0x1fff);
- }
-
- ///
- /// retrieve HRESULT_CODE
- ///
- public int Code
- {
- get
- {
- return GetCode((int)_value);
- }
- }
-
- public static int GetCode(int error)
- {
- // #define HRESULT_CODE(hr) ((hr) & 0xFFFF)
- return (int)(error & 0xFFFF);
- }
-
- #region Object class override members
-
- ///
- /// Get a string representation of this HRESULT.
- ///
- ///
- public override string ToString()
- {
- // Use reflection to try to name this HRESULT.
- // This is expensive, but if someone's ever printing HRESULT strings then
- // I think it's a fair guess that they're not in a performance critical area
- // (e.g. printing exception strings).
- // This is less error prone than trying to keep the list in the function.
- // To properly add an HRESULT's name to the ToString table, just add the HRESULT
- // like all the others above.
- //
- // CONSIDER: This data is static. It could be cached
- // after first usage for fast lookup since the keys are unique.
- //
- foreach (FieldInfo publicStaticField in typeof(HRESULT).GetFields(BindingFlags.Static | BindingFlags.Public))
- {
- if (publicStaticField.FieldType == typeof(HRESULT))
- {
- var hr = (HRESULT)publicStaticField.GetValue(null);
- if (hr == this)
- {
- return publicStaticField.Name;
- }
- }
- }
-
- // Try Win32 error codes also
- if (Facility == Facility.Win32)
- {
- foreach (FieldInfo publicStaticField in typeof(Win32Error).GetFields(BindingFlags.Static | BindingFlags.Public))
- {
- if (publicStaticField.FieldType == typeof(Win32Error))
- {
- var error = (Win32Error)publicStaticField.GetValue(null);
- if ((HRESULT)error == this)
- {
- return $"HRESULT_FROM_WIN32({publicStaticField.Name})";
- }
- }
- }
- }
-
- // If there's no good name for this HRESULT,
- // return the string as readable hex (0x########) format.
- return string.Create(CultureInfo.InvariantCulture, $"0x{_value:X8}");
- }
-
- public override bool Equals(object obj)
- {
- try
- {
- return ((HRESULT)obj)._value == _value;
- }
- catch (InvalidCastException)
- {
- return false;
- }
- }
-
- public override int GetHashCode()
- {
- return _value.GetHashCode();
- }
-
- #endregion
-
- public static bool operator ==(HRESULT hrLeft, HRESULT hrRight)
- {
- return hrLeft._value == hrRight._value;
- }
-
- public static bool operator !=(HRESULT hrLeft, HRESULT hrRight)
- {
- return !(hrLeft == hrRight);
- }
-
- public bool Succeeded
- {
- get { return (int)_value >= 0; }
- }
-
- public bool Failed
- {
- get { return (int)_value < 0; }
- }
-
- public void ThrowIfFailed()
- {
- ThrowIfFailed(null);
- }
-
- [SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification="Only recreating Exceptions that were already raised.")]
- public void ThrowIfFailed(string message)
- {
- if (Failed)
- {
- if (string.IsNullOrEmpty(message))
- {
- message = ToString();
- }
-#if DEBUG
- else
- {
- message += $" ({ToString()})";
- }
-#endif
- // Wow. Reflection in a throw call. Later on this may turn out to have been a bad idea.
- // If you're throwing an exception I assume it's OK for me to take some time to give it back.
- // I want to convert the HRESULT to a more appropriate exception type than COMException.
- // Marshal.ThrowExceptionForHR does this for me, but the general call uses GetErrorInfo
- // if it's set, and then ignores the HRESULT that I've provided. This makes it so this
- // call works the first time but you get burned on the second. To avoid this, I use
- // the overload that explicitly ignores the IErrorInfo.
- // In addition, the function doesn't allow me to set the Message unless I go through
- // the process of implementing an IErrorInfo and then use that. There's no stock
- // implementations of IErrorInfo available and I don't think it's worth the maintenance
- // overhead of doing it, nor would it have significant value over this approach.
- Exception e = MS.Internal.PresentationFramework.SecurityHelper.GetExceptionForHR((int)_value);
- Assert.IsNotNull(e);
- // ArgumentNullException doesn't have the right constructor parameters,
- // (nor does Win32Exception...)
- // but E_POINTER gets mapped to NullReferenceException,
- // so I don't think it will ever matter.
- Assert.IsFalse(e is ArgumentNullException);
-
- // If we're not getting anything better than a COMException from Marshal,
- // then at least check the facility and attempt to do better ourselves.
- if (e.GetType() == typeof(COMException))
- {
- switch (Facility)
- {
- case Facility.Win32:
- e = CreateWin32Exception(Code, message);
- break;
- default:
- e = new COMException(message, (int)_value);
- break;
- }
- }
- else
- {
- ConstructorInfo cons = e.GetType().GetConstructor(new[] { typeof(string) });
- if (null != cons)
- {
- e = cons.Invoke(new object[] { message }) as Exception;
- Assert.IsNotNull(e);
- }
- }
- throw e;
- }
- }
-
- ///
- /// Convert the result of Win32 GetLastError() into a raised exception.
- ///
- public static void ThrowLastError()
- {
- ((HRESULT)Win32Error.GetLastError()).ThrowIfFailed();
- // Only expecting to call this when we're expecting a failed GetLastError()
- Assert.Fail();
- }
-
- private static Exception CreateWin32Exception(int code, string message)
- {
- return new Win32Exception(code, message);
- }
- }
-}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/NativeMethods.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/NativeMethods.cs
index 39e54e1e89f..d55e2927c00 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/NativeMethods.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/NativeMethods.cs
@@ -1,8 +1,5 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
@@ -11,6 +8,7 @@
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using Microsoft.Win32.SafeHandles;
+using Windows.Win32.Foundation;
// Some COM interfaces and Win32 structures are already declared in the framework.
// Interesting ones to remember in System.Runtime.InteropServices.ComTypes are:
@@ -1454,7 +1452,7 @@ public static SafeDC CreateCompatibleDC(SafeDC hdc)
dc = NativeMethods.CreateCompatibleDC(hPtr);
if (dc == null)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
}
finally
@@ -1491,8 +1489,8 @@ public static SafeDC GetDC(IntPtr hwnd)
if (dc.IsInvalid)
{
- // GetDC does not set the last error...
- HRESULT.E_FAIL.ThrowIfFailed();
+ // GetDC does not set the last error.
+ HRESULT.E_FAIL.ThrowOnFailureUnwrapWin32();
}
return dc;
@@ -1532,7 +1530,7 @@ private SafeGdiplusStartupToken() : base(true) { }
protected override bool ReleaseHandle()
{
- Status s = NativeMethods.GdiplusShutdown(this.handle);
+ Status s = NativeMethods.GdiplusShutdown(handle);
return s == Status.Ok;
}
@@ -1600,7 +1598,7 @@ protected override bool ReleaseHandle()
{
try
{
- if (!this.IsInvalid)
+ if (!IsInvalid)
{
int dwCookie = handle.ToInt32();
handle = IntPtr.Zero;
@@ -2287,7 +2285,7 @@ public static RECT AdjustWindowRectEx(RECT lpRect, WS dwStyle, bool bMenu, WS_EX
// Native version modifies the parameter in place.
if (!_AdjustWindowRectEx(ref lpRect, dwStyle, bMenu, dwExStyle))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return lpRect;
@@ -2325,7 +2323,7 @@ public static HRESULT ChangeWindowMessageFilterEx(IntPtr hwnd, WM message, MSGFL
ret = _ChangeWindowMessageFilter(message, action);
if (!ret)
{
- return (HRESULT)Win32Error.GetLastError();
+ return HRESULT.FromWin32((WIN32_ERROR)Marshal.GetLastPInvokeError());
}
return HRESULT.S_OK;
}
@@ -2334,7 +2332,7 @@ public static HRESULT ChangeWindowMessageFilterEx(IntPtr hwnd, WM message, MSGFL
ret = _ChangeWindowMessageFilterEx(hwnd, message, action, ref filterstruct);
if (!ret)
{
- return (HRESULT)Win32Error.GetLastError();
+ return HRESULT.FromWin32((WIN32_ERROR)Marshal.GetLastPInvokeError());
}
filterInfo = filterstruct.ExtStatus;
@@ -2398,7 +2396,7 @@ public static SafeHBITMAP CreateDIBSection(SafeDC hdc, ref BITMAPINFO bitmapInfo
if (hBitmap.IsInvalid)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return hBitmap;
@@ -2478,7 +2476,7 @@ public static IntPtr CreateWindowEx(
IntPtr ret = _CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
if (IntPtr.Zero == ret)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return ret;
@@ -2507,7 +2505,7 @@ public static IntPtr CreateWindowEx(
public static extern int DwmGetWindowAttribute(IntPtr hWnd, DWMWA dwAttributeToGet, ref int pvAttributeValue, int cbAttribute);
[DllImport("dwmapi.dll", PreserveSig = false)]
- public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS pMarInset);
+ public static extern HRESULT DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS pMarInset);
[DllImport("dwmapi.dll", EntryPoint = "DwmIsCompositionEnabled", PreserveSig = false)]
[return: MarshalAs(UnmanagedType.Bool)]
@@ -2640,7 +2638,7 @@ public static RECT GetClientRect(IntPtr hwnd)
RECT rc;
if (!_GetClientRect(hwnd, out rc))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return rc;
}
@@ -2662,10 +2660,13 @@ public static void GetCurrentThemeName(out string themeFileName, out string colo
var sizeBuilder = new StringBuilder((int)Win32Value.MAX_PATH);
// This will throw if the theme service is not active (e.g. not UxTheme!IsThemeActive).
- _GetCurrentThemeName(fileNameBuilder, fileNameBuilder.Capacity,
- colorBuilder, colorBuilder.Capacity,
- sizeBuilder, sizeBuilder.Capacity)
- .ThrowIfFailed();
+ _GetCurrentThemeName(
+ fileNameBuilder,
+ fileNameBuilder.Capacity,
+ colorBuilder,
+ colorBuilder.Capacity,
+ sizeBuilder,
+ sizeBuilder.Capacity).ThrowOnFailureUnwrapWin32();
themeFileName = fileNameBuilder.ToString();
color = colorBuilder.ToString();
@@ -2690,7 +2691,7 @@ public static string GetModuleFileName(IntPtr hModule)
int size = _GetModuleFileName(hModule, buffer, buffer.Capacity);
if (size == 0)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
// GetModuleFileName returns nSize when it's truncated but does NOT set the last error.
@@ -2714,7 +2715,7 @@ public static IntPtr GetModuleHandle(string lpModuleName)
IntPtr retPtr = _GetModuleHandle(lpModuleName);
if (retPtr == IntPtr.Zero)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return retPtr;
}
@@ -2741,7 +2742,7 @@ public static IntPtr GetStockObject(StockObject fnObject)
IntPtr retPtr = _GetStockObject(fnObject);
if (retPtr == IntPtr.Zero)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return retPtr;
}
@@ -2816,7 +2817,7 @@ public static RECT GetWindowRect(IntPtr hwnd)
RECT rc;
if (!_GetWindowRect(hwnd, out rc))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return rc;
}
@@ -2875,7 +2876,7 @@ public static short RegisterClassEx(ref WNDCLASSEX lpwcx)
short ret = _RegisterClassEx(ref lpwcx);
if (ret == 0)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return ret;
@@ -2889,7 +2890,7 @@ public static WM RegisterWindowMessage(string lpString)
uint iRet = _RegisterWindowMessage(lpString);
if (iRet == 0)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return (WM)iRet;
}
@@ -2903,7 +2904,7 @@ public static IntPtr SetActiveWindow(IntPtr hwnd)
IntPtr ret = _SetActiveWindow(hwnd);
if (ret == IntPtr.Zero)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return ret;
@@ -2978,7 +2979,7 @@ public static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int
}
[DllImport("shell32.dll", SetLastError = false)]
- public static extern Win32Error SHFileOperation(ref SHFILEOPSTRUCT lpFileOp);
+ public static extern WIN32_ERROR SHFileOperation(ref SHFILEOPSTRUCT lpFileOp);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
@@ -3002,7 +3003,7 @@ public static void SystemParametersInfo(SPI uiAction, int uiParam, string pvPara
{
if (!_SystemParametersInfo_String(uiAction, uiParam, pvParam, fWinIni))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
}
@@ -3014,7 +3015,7 @@ public static NONCLIENTMETRICS SystemParameterInfo_GetNONCLIENTMETRICS()
if (!_SystemParametersInfo_NONCLIENTMETRICS(SPI.GETNONCLIENTMETRICS, metrics.cbSize, ref metrics, SPIF.None))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return metrics;
@@ -3026,7 +3027,7 @@ public static HIGHCONTRAST SystemParameterInfo_GetHIGHCONTRAST()
if (!_SystemParametersInfo_HIGHCONTRAST(SPI.GETHIGHCONTRAST, hc.cbSize, ref hc, SPIF.None))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return hc;
@@ -3045,7 +3046,7 @@ public static IntPtr SelectObject(SafeDC hdc, IntPtr hgdiobj)
IntPtr ret = _SelectObject(hdc, hgdiobj);
if (ret == IntPtr.Zero)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return ret;
}
@@ -3058,7 +3059,7 @@ public static IntPtr SelectObject(SafeDC hdc, SafeHBITMAP hgdiobj)
IntPtr ret = _SelectObjectSafeHBITMAP(hdc, hgdiobj);
if (ret == IntPtr.Zero)
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
return ret;
}
@@ -3082,7 +3083,7 @@ public static void UnregisterClass(short atom, IntPtr hinstance)
{
if (!_UnregisterClassAtom(new IntPtr(atom), hinstance))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
}
@@ -3090,7 +3091,7 @@ public static void UnregisterClass(string lpClassName, IntPtr hInstance)
{
if (!_UnregisterClassName(lpClassName, hInstance))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
}
@@ -3133,7 +3134,7 @@ public static void UpdateLayeredWindow(
{
if (!_UpdateLayeredWindow(hwnd, hdcDst, ref pptDst, ref psize, hdcSrc, ref pptSrc, crKey, ref pblend, dwFlags))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
}
@@ -3145,7 +3146,7 @@ public static void UpdateLayeredWindow(
{
if (!_UpdateLayeredWindowIntPtr(hwnd, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, crKey, ref pblend, dwFlags))
{
- HRESULT.ThrowLastError();
+ throw new Win32Exception();
}
}
@@ -3186,12 +3187,13 @@ public static void SHAddToRecentDocs(IShellLinkW shellLink)
var dti = new DWM_TIMING_INFO { cbSize = Marshal.SizeOf(typeof(DWM_TIMING_INFO)) };
HRESULT hr = _DwmGetCompositionTimingInfo(hwnd, ref dti);
- if (hr == HRESULT.E_PENDING)
+ if (hr.Value == (-2147483638) /* HRESULT.E_PENDING */)
{
// The system isn't yet ready to respond. Return null rather than throw.
return null;
}
- hr.ThrowIfFailed();
+
+ hr.ThrowOnFailureUnwrapWin32();
return dti;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/ShellProvider.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/ShellProvider.cs
index 2cd2c598680..c491b1f2b56 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/ShellProvider.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/ShellProvider.cs
@@ -1,13 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using MS.Internal.Interop;
+using Windows.Win32.Foundation;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs
index ad3c6198892..ed8017b0186 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -23,8 +23,7 @@
using BuildInfo = MS.Internal.PresentationFramework.BuildInfo;
using SNM = Standard.NativeMethods;
-using HRESULT = MS.Internal.Interop.HRESULT;
-using Win32Error = MS.Internal.Interop.Win32Error;
+using Windows.Win32.Foundation;
//In order to avoid generating warnings about unknown message numbers and
//unknown pragmas when compiling your C# source code with the actual C# compiler,
@@ -84,15 +83,15 @@ static Window()
WM_APPLYTASKBARITEMINFO = UnsafeNativeMethods.RegisterWindowMessage("WPF_ApplyTaskbarItemInfo");
EventManager.RegisterClassHandler(typeof(Window),
- UIElement.ManipulationCompletedEvent,
+ ManipulationCompletedEvent,
new EventHandler(OnStaticManipulationCompleted),
/*handledEventsToo*/ true);
EventManager.RegisterClassHandler(typeof(Window),
- UIElement.ManipulationInertiaStartingEvent,
+ ManipulationInertiaStartingEvent,
new EventHandler(OnStaticManipulationInertiaStarting),
/*handledEventsToo*/ true);
- Window.DpiChangedEvent = EventManager.RegisterRoutedEvent("DpiChanged", RoutingStrategy.Bubble,
+ DpiChangedEvent = EventManager.RegisterRoutedEvent("DpiChanged", RoutingStrategy.Bubble,
typeof (System.Windows.DpiChangedEventHandler), typeof (Window));
}
@@ -515,7 +514,7 @@ protected internal override IEnumerator LogicalChildren
{
// Don't use UIElementCollection because we don't have a reference to content's visual parent;
// window has style and user can change it.
- return new SingleChildEnumerator(this.Content);
+ return new SingleChildEnumerator(Content);
}
}
@@ -536,7 +535,7 @@ public static Window GetWindow(DependencyObject dependencyObject)
// Normally this value is set to the root Window element, all the element
// inside the window view will get this value through property inheritance mechanism.
- return dependencyObject.GetValue(Window.IWindowServiceProperty) as Window;
+ return dependencyObject.GetValue(IWindowServiceProperty) as Window;
}
#endregion static public method
@@ -683,7 +682,7 @@ private void HandleTaskbarListError(HRESULT hr)
// Even if some of the taskbar methods get this error it doesn't mean that all of them will.
// They aren't all implemented with SendMessageTimeout, and unfortunately the ITaskbarList3 API inconsistently
// exposes that implementation detail.
- if (hr == (HRESULT)Win32Error.ERROR_TIMEOUT)
+ if (hr == HRESULT.FromWin32(WIN32_ERROR.ERROR_TIMEOUT))
{
// Explorer appears to be busy. Post back to the Window to try again.
if (TraceShell.IsEnabled)
@@ -695,7 +694,7 @@ private void HandleTaskbarListError(HRESULT hr)
// Explorer being non-responsive should be a transient issue. Post back to apply the full TaskbarItemInfo.
_taskbarRetryTimer.Start();
}
- else if (hr == (HRESULT)Win32Error.ERROR_INVALID_WINDOW_HANDLE || hr == HRESULT.E_NOTIMPL)
+ else if (hr == HRESULT.FromWin32(WIN32_ERROR.ERROR_INVALID_WINDOW_HANDLE) || hr == HRESULT.E_NOTIMPL)
{
// We'll get this when Explorer's not running. This means there's no Shell to integrate with.
if (TraceShell.IsEnabled)
@@ -722,7 +721,7 @@ private void HandleTaskbarListError(HRESULT hr)
private void OnTaskbarItemInfoSubPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
{
// Don't propagate changes from other TaskbarItemInfos.
- if (sender != this.TaskbarItemInfo)
+ if (sender != TaskbarItemInfo)
{
// Since this and the TaskbarItemInfo should share affinity for the same thread
// this really shouldn't happen...
@@ -1644,8 +1643,8 @@ public event EventHandler SourceInitialized
///
public event DpiChangedEventHandler DpiChanged
{
- add { AddHandler(Window.DpiChangedEvent, value); }
- remove { RemoveHandler(Window.DpiChangedEvent, value); }
+ add { AddHandler(DpiChangedEvent, value); }
+ remove { RemoveHandler(DpiChangedEvent, value); }
}
///
@@ -1765,7 +1764,7 @@ protected override AutomationPeer OnCreateAutomationPeer()
///
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
{
- RaiseEvent(new DpiChangedEventArgs(oldDpi, newDpi, Window.DpiChangedEvent, this));
+ RaiseEvent(new DpiChangedEventArgs(oldDpi, newDpi, DpiChangedEvent, this));
}
///
@@ -1870,9 +1869,9 @@ protected override Size ArrangeOverride(Size arrangeBounds)
return arrangeBounds;
}
- if (this.VisualChildrenCount > 0)
+ if (VisualChildrenCount > 0)
{
- UIElement child = this.GetVisualChild(0) as UIElement;
+ UIElement child = GetVisualChild(0) as UIElement;
if (child != null)
{
// Find out the size of the window frame x.
@@ -1946,7 +1945,7 @@ protected override void OnContentChanged(object oldContent, object newContent)
// Thus we don't want to hook up another event handler
if (_postContentRenderedFromLoadedHandler == false)
{
- this.Loaded += new RoutedEventHandler(LoadedHandler);
+ Loaded += new RoutedEventHandler(LoadedHandler);
_postContentRenderedFromLoadedHandler = true;
}
}
@@ -2674,10 +2673,10 @@ internal virtual void CorrectStyleForBorderlessWindowCase()
internal virtual void GetRequestedDimensions(ref double requestedLeft, ref double requestedTop, ref double requestedWidth, ref double requestedHeight)
{
- requestedTop = this.Top;
- requestedLeft = this.Left;
- requestedWidth = this.Width;
- requestedHeight = this.Height;
+ requestedTop = Top;
+ requestedLeft = Left;
+ requestedWidth = Width;
+ requestedHeight = Height;
}
internal virtual void SetupInitialState(double requestedTop, double requestedLeft, double requestedWidth, double requestedHeight)
@@ -2928,7 +2927,7 @@ internal void SetRootVisualAndUpdateSTC()
double yDeviceUnits = rc.top;
// inputs to CalculateWindowLocation must be in DEVICE units
- Point newSizeDeviceUnits = LogicalToDeviceUnits(new Point(this.ActualWidth, this.ActualHeight));
+ Point newSizeDeviceUnits = LogicalToDeviceUnits(new Point(ActualWidth, ActualHeight));
if (CalculateWindowLocation(ref xDeviceUnits, ref yDeviceUnits, new Size(newSizeDeviceUnits.X, newSizeDeviceUnits.Y)))
{
if (WindowState == WindowState.Normal)
@@ -3406,9 +3405,9 @@ private Size MeasureOverrideHelper(Size constraint)
return new Size(0,0);
}
- if (this.VisualChildrenCount > 0)
+ if (VisualChildrenCount > 0)
{
- UIElement child = this.GetVisualChild(0) as UIElement;
+ UIElement child = GetVisualChild(0) as UIElement;
if (child != null) // UIElement children
{
// Find out the size of the window frame x.
@@ -3481,7 +3480,7 @@ internal virtual WindowMinMax GetWindowMinMax()
//
// Get the final Min/Max Width
//
- mm.minWidth = Math.Max(this.MinWidth, minSizeLogicalUnits.X);
+ mm.minWidth = Math.Max(MinWidth, minSizeLogicalUnits.X);
// Min's precedence is higher than Max; If Min is greater than Max, use Min.
if (MinWidth > MaxWidth)
@@ -3503,12 +3502,12 @@ internal virtual WindowMinMax GetWindowMinMax()
//
// Get the final Min/Max Height
//
- mm.minHeight = Math.Max(this.MinHeight, minSizeLogicalUnits.Y);
+ mm.minHeight = Math.Max(MinHeight, minSizeLogicalUnits.Y);
// Min's precedence is higher than Max; If Min is greater than Max, use Min.
if (MinHeight > MaxHeight)
{
- mm.maxHeight = Math.Min(this.MinHeight, maxSizeLogicalUnits.Y);
+ mm.maxHeight = Math.Min(MinHeight, maxSizeLogicalUnits.Y);
}
else
{
@@ -3531,7 +3530,7 @@ private void LoadedHandler(object sender, RoutedEventArgs e)
{
PostContentRendered();
_postContentRenderedFromLoadedHandler = false;
- this.Loaded -= new RoutedEventHandler(LoadedHandler);
+ Loaded -= new RoutedEventHandler(LoadedHandler);
}
}
@@ -4535,7 +4534,7 @@ private void UpdateWindowListsOnClose()
Owner.OwnedWindowsInternal.Remove(this);
}
- if (this.IsInsideApp)
+ if (IsInsideApp)
{
if (Application.Current.Dispatcher.Thread == Dispatcher.CurrentDispatcher.Thread)
{
@@ -4662,8 +4661,8 @@ private bool WmSizeChanged(IntPtr wParam)
try
{
_updateHwndSize = false;
- SetValue(FrameworkElement.WidthProperty, ptLogicalUnits.X);
- SetValue(FrameworkElement.HeightProperty, ptLogicalUnits.Y);
+ SetValue(WidthProperty, ptLogicalUnits.X);
+ SetValue(HeightProperty, ptLogicalUnits.Y);
}
finally
{
@@ -5005,7 +5004,7 @@ internal virtual bool HandleWmNcHitTestMsg(IntPtr lParam, ref IntPtr refInt)
// x,y should be not be less than zero
// x,y should not be greater than RenderSize.Width and RenderSize.Height
- GeneralTransform transfromFromWindow = this.TransformToDescendant(_resizeGripControl);
+ GeneralTransform transfromFromWindow = TransformToDescendant(_resizeGripControl);
Point mousePositionWRTResizeGripControl = ptLogicalUnits;
if (transfromFromWindow == null || transfromFromWindow.TryTransform(ptLogicalUnits, out mousePositionWRTResizeGripControl) == false)
{
@@ -5993,7 +5992,7 @@ private void UpdateHwndRestoreBounds(double newValue, BoundsSpecified specifiedR
// of the window's visibility.
// SetWindowPlacement with SW_SHOWMAXIMIZED and SW_SHOWMINIMIZED will cause a hidden window to show.
// To workaround this issue, we check whether the current window is hidden and set showCmd to SW_HIDE if it is.
- if (!this._isVisible)
+ if (!_isVisible)
{
wp.showCmd = NativeMethods.SW_HIDE;
}
@@ -6840,11 +6839,11 @@ private HRESULT UpdateTaskbarThumbButtons()
private void CreateRtl()
{
- if ( this.FlowDirection == FlowDirection.LeftToRight )
+ if ( FlowDirection == FlowDirection.LeftToRight )
{
_StyleEx &= ~NativeMethods.WS_EX_LAYOUTRTL;
}
- else if ( this.FlowDirection == FlowDirection.RightToLeft )
+ else if ( FlowDirection == FlowDirection.RightToLeft )
{
_StyleEx |= NativeMethods.WS_EX_LAYOUTRTL;
}
@@ -6906,7 +6905,7 @@ private void ClearRootVisual()
private NativeMethods.POINT GetPointRelativeToWindow( int x, int y )
{
- return _swh.GetPointRelativeToWindow( x, y, this.FlowDirection);
+ return _swh.GetPointRelativeToWindow( x, y, FlowDirection);
}
// If you're in the middle of changing the window's _style or _styleEx and call this function,
@@ -7216,7 +7215,7 @@ private WindowCollection OwnedWindowsInternal
///
private System.Windows.Application App
{
- get {return System.Windows.Application.Current;}
+ get {return Application.Current;}
}
///
@@ -7913,7 +7912,7 @@ private bool MonitorEnumProc(IntPtr hMonitor, IntPtr hdcMonitor, ref NativeMetho
NativeMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI,
out dpiX, out dpiY);
- if (hr == NativeMethods.S_OK)
+ if (hr == HRESULT.S_OK)
{
double dpiScaleX = dpiX * 1.0d / 96.0d;
double dpiScaleY = dpiY * 1.0d / 96.0d;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/NativeDirectoryServicesQueryAPIs.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/NativeDirectoryServicesQueryAPIs.cs
index d946e970ceb..a4534586f79 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/NativeDirectoryServicesQueryAPIs.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/NativeDirectoryServicesQueryAPIs.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -9,6 +9,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
+using Windows.Win32.Foundation;
namespace MS.Internal.Documents
{
@@ -36,12 +37,12 @@ internal static class UnsafeNativeMethods
/// https://docs.microsoft.com/en-us/windows/desktop/api/cmnquery/nf-cmnquery-icommonquery-openquerywindow
///
[Guid("ab50dec0-6f1d-11d0-a1c4-00aa00c16e65")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface ICommonQuery
{
[PreserveSig]
- UInt32 OpenQueryWindow(
+ HRESULT OpenQueryWindow(
[In] IntPtr hwndParent,
[In] ref OpenQueryWindowParams pQueryWnd,
[Out] out IDataObject ppDataObj
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/PeoplePickerWrapper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/PeoplePickerWrapper.cs
index 0c9f646f53e..fc6227f7053 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/PeoplePickerWrapper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/PeoplePickerWrapper.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -13,6 +13,7 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Windows.TrustUI;
+using Windows.Win32.Foundation;
namespace MS.Internal.Documents
{
@@ -143,7 +144,7 @@ private IDataObject OpenQueryWindow(IntPtr hWndParent)
IntPtr queryInitParamsPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(queryInitParams));
//Now try to invoke the OpenQueryWindow method
- uint hresult = UnsafeNativeMethods.E_FAIL;
+ HRESULT hresult = HRESULT.E_FAIL;
IDataObject data = null;
try
@@ -179,10 +180,11 @@ private IDataObject OpenQueryWindow(IntPtr hWndParent)
//Invoke the OpenQueryWindow method on the ICommonQuery object,
//which will invoke the dialog and return any entered data in the
//"data" field.
- //OpenQueryWindow will not return until the dialog is closed.
- hresult = commonQueryInstance.OpenQueryWindow(hWndParent,
- ref openQueryWindowParams,
- out data);
+ //OpenQueryWindow will not return until the dialog is closed.
+ hresult = commonQueryInstance.OpenQueryWindow(
+ hWndParent,
+ ref openQueryWindowParams,
+ out data);
}
finally
{
@@ -191,13 +193,13 @@ private IDataObject OpenQueryWindow(IntPtr hWndParent)
Marshal.FreeCoTaskMem(queryInitParamsPtr);
commonQueryInstance = null;
}
-
- if (hresult == UnsafeNativeMethods.S_OK)
+
+ if (hresult == HRESULT.S_OK)
{
//The user pressed "OK," so we can return the selected data
return data;
}
- else if (hresult == UnsafeNativeMethods.S_FALSE)
+ else if (hresult == HRESULT.S_FALSE)
{
//The user canceled out, so we just return null.
return null;
@@ -332,16 +334,16 @@ internal DsObjectNamesWrapper(System.IO.MemoryStream dataStream)
///
/// Finalizer for DsObjectNamesWrapper, ensures that unmanaged resources are properly
- /// cleaned up.
+ /// cleaned up.
///
~DsObjectNamesWrapper()
{
- this.Dispose();
+ Dispose();
}
///
/// The number of names in the DsObjectNames struct this class is wrapping.
- ///
+ ///
internal uint Count
{
get
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs
index 98618c5151e..0a15a5908b7 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -16,6 +16,7 @@
#if !PBTCOMPILER
using MS.Win32;
using System.IO.Packaging;
+using Windows.Win32.Foundation;
#endif
#if PRESENTATION_CORE
@@ -73,43 +74,46 @@ internal static Uri GetBaseDirectory(AppDomain domain)
return( appBase );
}
- internal static int MapUrlToZoneWrapper(Uri uri)
- {
- int targetZone = NativeMethods.URLZONE_LOCAL_MACHINE ; // fail securely this is the most priveleged zone
- int hr = NativeMethods.S_OK ;
- object curSecMgr = null;
- hr = UnsafeNativeMethods.CoInternetCreateSecurityManager(
- null,
- out curSecMgr ,
- 0 );
- if ( NativeMethods.Failed( hr ))
- throw new Win32Exception( hr ) ;
-
- UnsafeNativeMethods.IInternetSecurityManager pSec = (UnsafeNativeMethods.IInternetSecurityManager) curSecMgr;
-
- string uriString = BindUriHelper.UriToString( uri ) ;
- //
- // special case the condition if file is on local machine or UNC to ensure that content with mark of the web
- // does not yield with an internet zone result
- //
- if (uri.IsFile)
- {
- pSec.MapUrlToZone( uriString, out targetZone, MS.Win32.NativeMethods.MUTZ_NOSAVEDFILECHECK );
- }
- else
- {
- pSec.MapUrlToZone( uriString, out targetZone, 0 );
- }
- //
- // This is the condition for Invalid zone
- //
- if (targetZone < 0)
- {
- throw new SecurityException( SR.Invalid_URI );
- }
- pSec = null;
- curSecMgr = null;
- return targetZone;
+ internal static int MapUrlToZoneWrapper(Uri uri)
+ {
+ int targetZone = NativeMethods.URLZONE_LOCAL_MACHINE ; // fail securely this is the most priveleged zone
+
+ HRESULT result = UnsafeNativeMethods.CoInternetCreateSecurityManager(
+ null,
+ out object curSecMgr,
+ 0);
+
+ if (result.Failed)
+ {
+ // This isn't technically right, keeping for compat.
+ throw new Win32Exception(result);
+ }
+
+ UnsafeNativeMethods.IInternetSecurityManager pSec = (UnsafeNativeMethods.IInternetSecurityManager) curSecMgr;
+
+ string uriString = BindUriHelper.UriToString( uri ) ;
+ //
+ // special case the condition if file is on local machine or UNC to ensure that content with mark of the web
+ // does not yield with an internet zone result
+ //
+ if (uri.IsFile)
+ {
+ pSec.MapUrlToZone( uriString, out targetZone, NativeMethods.MUTZ_NOSAVEDFILECHECK);
+ }
+ else
+ {
+ pSec.MapUrlToZone( uriString, out targetZone, 0 );
+ }
+ //
+ // This is the condition for Invalid zone
+ //
+ if (targetZone < 0)
+ {
+ throw new SecurityException( SR.Invalid_URI );
+ }
+ pSec = null;
+ curSecMgr = null;
+ return targetZone;
}
#endif
@@ -140,21 +144,21 @@ internal static void ThrowExceptionForHR(int hr)
{
Marshal.ThrowExceptionForHR(hr, new IntPtr(-1));
}
-
- internal static int GetHRForException(Exception exception)
+
+ internal static HRESULT GetHRForException(Exception exception)
{
ArgumentNullException.ThrowIfNull(exception);
// GetHRForException fills a per thread IErrorInfo object with data from the exception
// The exception may contain security sensitive data like full file paths that we do not
// want to leak into an IErrorInfo
- int hr = Marshal.GetHRForException(exception);
+ HRESULT result = (HRESULT)Marshal.GetHRForException(exception);
// Call GetHRForException a second time with a security safe exception object
// to make sure the per thread IErrorInfo is cleared of security sensitive data
Marshal.GetHRForException(new Exception());
- return hr;
+ return result;
}
#endif
@@ -165,44 +169,38 @@ internal static int GetHRForException(Exception exception)
/// A helper method to do the necessary work to display a standard MessageBox. This method performs
/// and necessary elevations to make the dialog work as well.
///
- internal
- static
- void
- ShowMessageBoxHelper(
- System.Windows.Window parent,
+ internal static void ShowMessageBoxHelper(
+ Window parent,
string text,
string title,
- System.Windows.MessageBoxButton buttons,
- System.Windows.MessageBoxImage image
+ MessageBoxButton buttons,
+ MessageBoxImage image
)
{
// if we have a known parent window set, let's use it when alerting the user.
if (parent != null)
{
- System.Windows.MessageBox.Show(parent, text, title, buttons, image);
+ MessageBox.Show(parent, text, title, buttons, image);
}
else
{
- System.Windows.MessageBox.Show(text, title, buttons, image);
+ MessageBox.Show(text, title, buttons, image);
}
}
///
/// A helper method to do the necessary work to display a standard MessageBox. This method performs
/// and necessary elevations to make the dialog work as well.
///
- internal
- static
- void
- ShowMessageBoxHelper(
+ internal static void ShowMessageBoxHelper(
IntPtr parentHwnd,
string text,
string title,
- System.Windows.MessageBoxButton buttons,
- System.Windows.MessageBoxImage image
+ MessageBoxButton buttons,
+ MessageBoxImage image
)
{
// NOTE: the last param must always be MessageBoxOptions.None for this to be considered TreatAsSafe
- System.Windows.MessageBox.ShowCore(parentHwnd, text, title, buttons, image, MessageBoxResult.None, MessageBoxOptions.None);
+ MessageBox.ShowCore(parentHwnd, text, title, buttons, image, MessageBoxResult.None, MessageBoxOptions.None);
}
#endif
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/TextServicesLoader.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/TextServicesLoader.cs
index fa5180a2c0e..4cab13541e7 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/TextServicesLoader.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/TextServicesLoader.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -15,6 +15,7 @@
using System.Threading;
using Microsoft.Win32;
using MS.Win32;
+using Windows.Win32.Foundation;
#if WINDOWS_BASE
#elif PRESENTATION_CORE
@@ -103,7 +104,7 @@ internal static UnsafeNativeMethods.ITfThreadMgr Load()
// loaded (no TIPs to run), you can check that in msctf.dll's NoTipsInstalled
// which lives in nt\windows\advcore\ctf\lib\immxutil.cpp. If that's the
// problem, ServicesInstalled is out of sync with Cicero's thinking.
- if (UnsafeNativeMethods.TF_CreateThreadMgr(out threadManager) == NativeMethods.S_OK)
+ if (UnsafeNativeMethods.TF_CreateThreadMgr(out threadManager) == HRESULT.S_OK)
{
return threadManager;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HandleCollector.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HandleCollector.cs
index 5c6a94642f7..c99362bc442 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HandleCollector.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HandleCollector.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -24,11 +24,6 @@ internal static IntPtr Add(IntPtr handle, int type) {
return handle;
}
- internal static SafeHandle Add(SafeHandle handle, int type) {
- handleTypes[type - 1].Add();
- return handle;
- }
-
internal static void Add(int type) {
handleTypes[type - 1].Add();
}
@@ -36,15 +31,18 @@ internal static void Add(int type) {
///
/// Registers a new type of handle with the handle collector.
///
- internal static int RegisterType(string typeName, int expense, int initialThreshold) {
+ internal static int RegisterType(string typeName, int expense, int initialThreshold)
+ {
lock (handleMutex)
{
if (handleTypeCount == 0 || handleTypeCount == handleTypes.Length)
{
HandleType[] newTypes = new HandleType[handleTypeCount + 10];
- if (handleTypes != null) {
+ if (handleTypes != null)
+ {
Array.Copy(handleTypes, 0, newTypes, 0, handleTypeCount);
}
+
handleTypes = newTypes;
}
@@ -63,11 +61,6 @@ internal static IntPtr Remove(IntPtr handle, int type) {
return handle ;
}
- internal static SafeHandle Remove(SafeHandle handle, int type) {
- handleTypes[type - 1].Remove();
- return handle ;
- }
-
internal static void Remove(int type) {
handleTypes[type - 1].Remove();
}
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs
index 96ce2a431e2..1d3ec811d6b 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs
@@ -1,28 +1,24 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
#pragma warning disable 649 // Disable CS0649: "field is never assigned to"
using System.Runtime.InteropServices;
using System;
using System.Text;
+using Windows.Win32;
+
#if !DRT && !UIAUTOMATIONTYPES
using MS.Internal.Interop;
using MS.Utility;
#endif
+
// The SecurityHelper class differs between assemblies and could not actually be
// shared, so it is duplicated across namespaces to prevent name collision.
#if WINDOWS_BASE
using MS.Internal.WindowsBase;
-#elif PRESENTATION_CORE
- using MS.Internal.PresentationCore;
-#elif PRESENTATIONFRAMEWORK
- using MS.Internal.PresentationFramework;
#elif UIAUTOMATIONTYPES
- using MS.Internal.UIAutomationTypes;
-#elif DRT
- using MS.Internal.Drt;
+using MS.Internal.UIAutomationTypes;
#else
#error Attempt to use a class (duplicated across multiple namespaces) from an unknown assembly.
#endif
@@ -42,32 +38,32 @@ public class XFORM {
public XFORM()
{
- this.eM11 = this.eM22 = 1; // identity matrix.
+ eM11 = eM22 = 1; // identity matrix.
}
public XFORM( float em11, float em12, float em21, float em22, float edx, float edy )
{
- this.eM11 = em11;
- this.eM12 = em12;
- this.eM21 = em21;
- this.eM22 = em22;
- this.eDx = edx;
- this.eDy = edy;
+ eM11 = em11;
+ eM12 = em12;
+ eM21 = em21;
+ eM22 = em22;
+ eDx = edx;
+ eDy = edy;
}
public XFORM( float[] elements )
{
- this.eM11 = elements[0];
- this.eM12 = elements[1];
- this.eM21 = elements[2];
- this.eM22 = elements[3];
- this.eDx = elements[4];
- this.eDy = elements[5];
+ eM11 = elements[0];
+ eM12 = elements[1];
+ eM21 = elements[2];
+ eM22 = elements[3];
+ eDx = elements[4];
+ eDy = elements[5];
}
public override string ToString()
{
- return String.Format(System.Globalization.CultureInfo.CurrentCulture,"[{0}, {1}, {2}, {3}, {4}, {5}]", this.eM11, this.eM12, this.eM21, this.eM22, this.eDx, this.eDy );
+ return String.Format(System.Globalization.CultureInfo.CurrentCulture,"[{0}, {1}, {2}, {3}, {4}, {5}]", eM11, eM12, eM21, eM22, eDx, eDy );
}
public override bool Equals( object obj )
@@ -79,33 +75,23 @@ public override bool Equals( object obj )
return false;
}
- return this.eM11 == xform.eM11 &&
- this.eM12 == xform.eM12 &&
- this.eM21 == xform.eM21 &&
- this.eM22 == xform.eM22 &&
- this.eDx == xform.eDx &&
- this.eDy == xform.eDy;
+ return eM11 == xform.eM11 &&
+ eM12 == xform.eM12 &&
+ eM21 == xform.eM21 &&
+ eM22 == xform.eM22 &&
+ eDx == xform.eDx &&
+ eDy == xform.eDy;
}
public override int GetHashCode()
{
- return this.ToString().GetHashCode();
+ return ToString().GetHashCode();
}
}
#endif
- public static IntPtr InvalidIntPtr = (IntPtr)(-1);
- public static IntPtr LPSTR_TEXTCALLBACK = (IntPtr)(-1);
public static HandleRef NullHandleRef = new HandleRef(null, IntPtr.Zero);
- public const int ERROR = 0;
-
- public const int BITMAPINFO_MAX_COLORSIZE = 256;
-
- public const int
- PAGE_READWRITE = 0x04,
- FILE_MAP_READ = 0x0004;
-
public const int APPCOMMAND_BROWSER_BACKWARD = 1;
public const int APPCOMMAND_BROWSER_FORWARD = 2;
public const int APPCOMMAND_BROWSER_REFRESH = 3;
@@ -167,10 +153,6 @@ public const int
public const int BITSPIXEL = 12;
public const int
- cmb4 = 0x0473,
- CS_DBLCLKS = 0x0008,
- CS_DROPSHADOW = 0x00020000,
- CS_SAVEBITS = 0x0800,
CF_TEXT = 1,
CF_BITMAP = 2,
CF_METAFILEPICT = 3,
@@ -187,260 +169,18 @@ public const int
CF_ENHMETAFILE = 14,
CF_HDROP = 15,
CF_LOCALE = 16,
- CLSCTX_INPROC_SERVER = 0x1,
- CLSCTX_LOCAL_SERVER = 0x4,
- CW_USEDEFAULT = (unchecked((int)0x80000000)),
- CWP_SKIPINVISIBLE = 0x0001,
- COLOR_WINDOW = 5,
- CB_ERR = (-1),
- CBN_SELCHANGE = 1,
- CBN_DBLCLK = 2,
- CBN_EDITCHANGE = 5,
- CBN_EDITUPDATE = 6,
- CBN_DROPDOWN = 7,
- CBN_CLOSEUP = 8,
- CBN_SELENDOK = 9,
- CBS_SIMPLE = 0x0001,
- CBS_DROPDOWN = 0x0002,
- CBS_DROPDOWNLIST = 0x0003,
- CBS_OWNERDRAWFIXED = 0x0010,
- CBS_OWNERDRAWVARIABLE = 0x0020,
- CBS_AUTOHSCROLL = 0x0040,
- CBS_HASSTRINGS = 0x0200,
- CBS_NOINTEGRALHEIGHT = 0x0400,
- CB_GETEDITSEL = 0x0140,
- CB_LIMITTEXT = 0x0141,
- CB_SETEDITSEL = 0x0142,
- CB_ADDSTRING = 0x0143,
- CB_DELETESTRING = 0x0144,
- CB_GETCURSEL = 0x0147,
- CB_GETLBTEXT = 0x0148,
- CB_GETLBTEXTLEN = 0x0149,
- CB_INSERTSTRING = 0x014A,
- CB_RESETCONTENT = 0x014B,
- CB_FINDSTRING = 0x014C,
- CB_SETCURSEL = 0x014E,
- CB_SHOWDROPDOWN = 0x014F,
- CB_GETITEMDATA = 0x0150,
- CB_SETITEMHEIGHT = 0x0153,
- CB_GETITEMHEIGHT = 0x0154,
- CB_GETDROPPEDSTATE = 0x0157,
- CB_FINDSTRINGEXACT = 0x0158,
- CB_SETDROPPEDWIDTH = 0x0160,
- CDRF_DODEFAULT = 0x00000000,
- CDRF_NEWFONT = 0x00000002,
- CDRF_SKIPDEFAULT = 0x00000004,
- CDRF_NOTIFYPOSTPAINT = 0x00000010,
- CDRF_NOTIFYITEMDRAW = 0x00000020,
- CDRF_NOTIFYSUBITEMDRAW = CDRF_NOTIFYITEMDRAW,
- CDDS_PREPAINT = 0x00000001,
- CDDS_POSTPAINT = 0x00000002,
- CDDS_ITEM = 0x00010000,
- CDDS_SUBITEM = 0x00020000,
- CDDS_ITEMPREPAINT = (0x00010000|0x00000001),
- CDDS_ITEMPOSTPAINT = (0x00010000|0x00000002),
- CDIS_SELECTED = 0x0001,
- CDIS_GRAYED = 0x0002,
- CDIS_DISABLED = 0x0004,
- CDIS_CHECKED = 0x0008,
- CDIS_FOCUS = 0x0010,
- CDIS_DEFAULT = 0x0020,
- CDIS_HOT = 0x0040,
- CDIS_MARKED = 0x0080,
- CDIS_INDETERMINATE = 0x0100,
- CDIS_SHOWKEYBOARDCUES = 0x0200,
- CLR_NONE = unchecked((int)0xFFFFFFFF),
- CLR_DEFAULT = unchecked((int)0xFF000000),
- CCM_SETVERSION = (0x2000+0x7),
- CCM_GETVERSION = (0x2000+0x8),
- CCS_NORESIZE = 0x00000004,
- CCS_NOPARENTALIGN = 0x00000008,
- CCS_NODIVIDER = 0x00000040,
- CBEM_INSERTITEMA = (0x0400+1),
- CBEM_GETITEMA = (0x0400+4),
- CBEM_SETITEMA = (0x0400+5),
- CBEM_INSERTITEMW = (0x0400+11),
- CBEM_SETITEMW = (0x0400+12),
- CBEM_GETITEMW = (0x0400+13),
- CBEN_ENDEDITA = ((0-800)-5),
- CBEN_ENDEDITW = ((0-800)-6),
- CONNECT_E_NOCONNECTION = unchecked((int)0x80040200),
- CONNECT_E_CANNOTCONNECT = unchecked((int)0x80040202),
- CTRLINFO_EATS_RETURN = 1,
- CTRLINFO_EATS_ESCAPE = 2,
- CSIDL_DESKTOP = 0x0000, //
- CSIDL_INTERNET = 0x0001, // Internet Explorer (icon on desktop)
- CSIDL_PROGRAMS = 0x0002, // Start Menu\Programs
- CSIDL_PERSONAL = 0x0005, // My Documents
- CSIDL_FAVORITES = 0x0006, // \Favorites
- CSIDL_STARTUP = 0x0007, // Start Menu\Programs\Startup
- CSIDL_RECENT = 0x0008, // \Recent
- CSIDL_SENDTO = 0x0009, // \SendTo
- CSIDL_STARTMENU = 0x000b, // \Start Menu
- CSIDL_DESKTOPDIRECTORY = 0x0010, // \Desktop
- CSIDL_TEMPLATES = 0x0015,
- CSIDL_APPDATA = 0x001a, // \Application Data
- CSIDL_LOCAL_APPDATA = 0x001c, // \Local Settings\Applicaiton Data (non roaming)
- CSIDL_INTERNET_CACHE = 0x0020,
- CSIDL_COOKIES = 0x0021,
- CSIDL_HISTORY = 0x0022,
- CSIDL_COMMON_APPDATA = 0x0023, // All Users\Application Data
- CSIDL_SYSTEM = 0x0025, // GetSystemDirectory()
- CSIDL_PROGRAM_FILES = 0x0026, // C:\Program Files
- CSIDL_PROGRAM_FILES_COMMON = 0x002b; // C:\Program Files\Common
-
- public const int DUPLICATE = 0x06,
- DISPID_VALUE = 0,
+ CW_USEDEFAULT = (unchecked((int)0x80000000));
+
+ public const int
DISPID_UNKNOWN = (-1),
- DISPID_PROPERTYPUT = (-3),
DISPATCH_METHOD = 0x1,
- DISPATCH_PROPERTYGET = 0x2,
- DISPATCH_PROPERTYPUT = 0x4,
- DISPATCH_PROPERTYPUTREF = 0x8,
- DV_E_DVASPECT = unchecked((int)0x8004006B),
DEFAULT_GUI_FONT = 17,
DIB_RGB_COLORS = 0,
- DRAGDROP_E_NOTREGISTERED = unchecked((int)0x80040100),
- DRAGDROP_E_ALREADYREGISTERED = unchecked((int)0x80040101),
- DUPLICATE_SAME_ACCESS = 0x00000002,
- DFC_CAPTION = 1,
- DFC_MENU = 2,
- DFC_SCROLL = 3,
- DFC_BUTTON = 4,
- DFCS_CAPTIONCLOSE = 0x0000,
- DFCS_CAPTIONMIN = 0x0001,
- DFCS_CAPTIONMAX = 0x0002,
- DFCS_CAPTIONRESTORE = 0x0003,
- DFCS_CAPTIONHELP = 0x0004,
- DFCS_MENUARROW = 0x0000,
- DFCS_MENUCHECK = 0x0001,
- DFCS_MENUBULLET = 0x0002,
- DFCS_SCROLLUP = 0x0000,
- DFCS_SCROLLDOWN = 0x0001,
- DFCS_SCROLLLEFT = 0x0002,
- DFCS_SCROLLRIGHT = 0x0003,
- DFCS_SCROLLCOMBOBOX = 0x0005,
- DFCS_BUTTONCHECK = 0x0000,
- DFCS_BUTTONRADIO = 0x0004,
- DFCS_BUTTON3STATE = 0x0008,
- DFCS_BUTTONPUSH = 0x0010,
- DFCS_INACTIVE = 0x0100,
- DFCS_PUSHED = 0x0200,
- DFCS_CHECKED = 0x0400,
- DFCS_FLAT = 0x4000,
- DT_LEFT = 0x00000000,
- DT_RIGHT = 0x00000002,
- DT_VCENTER = 0x00000004,
- DT_SINGLELINE = 0x00000020,
- DT_NOCLIP = 0x00000100,
- DT_CALCRECT = 0x00000400,
- DT_NOPREFIX = 0x00000800,
- DT_EDITCONTROL = 0x00002000,
- DT_EXPANDTABS = 0x00000040,
- DT_END_ELLIPSIS = 0x00008000,
- DT_RTLREADING = 0x00020000,
- DT_WORDBREAK = 0x00000010,
- DCX_WINDOW = 0x00000001,
- DCX_CACHE = 0x00000002,
- DCX_LOCKWINDOWUPDATE = 0x00000400,
- DI_NORMAL = 0x0003,
- DLGC_WANTARROWS = 0x0001,
- DLGC_WANTTAB = 0x0002,
- DLGC_WANTALLKEYS = 0x0004,
- DLGC_WANTCHARS = 0x0080,
- DTM_GETSYSTEMTIME = (0x1000+1),
- DTM_SETSYSTEMTIME = (0x1000+2),
- DTM_SETRANGE = (0x1000+4),
- DTM_SETFORMATA = (0x1000+5),
- DTM_SETFORMATW = (0x1000+50),
- DTM_SETMCCOLOR = (0x1000+6),
- DTM_SETMCFONT = (0x1000+9),
- DTS_UPDOWN = 0x0001,
- DTS_SHOWNONE = 0x0002,
- DTS_LONGDATEFORMAT = 0x0004,
- DTS_TIMEFORMAT = 0x0009,
- DTS_RIGHTALIGN = 0x0020,
- DTN_DATETIMECHANGE = ((0-760)+1),
- DTN_USERSTRINGA = ((0-760)+2),
- DTN_USERSTRINGW = ((0-760)+15),
- DTN_WMKEYDOWNA = ((0-760)+3),
- DTN_WMKEYDOWNW = ((0-760)+16),
- DTN_FORMATA = ((0-760)+4),
- DTN_FORMATW = ((0-760)+17),
- DTN_FORMATQUERYA = ((0-760)+5),
- DTN_FORMATQUERYW = ((0-760)+18),
- DTN_DROPDOWN = ((0-760)+6),
- DTN_CLOSEUP = ((0-760)+7),
- DVASPECT_CONTENT = 1,
- DVASPECT_TRANSPARENT = 32,
- DVASPECT_OPAQUE = 16;
-
- public const int E_NOTIMPL = unchecked((int)0x80004001),
- E_OUTOFMEMORY = unchecked((int)0x8007000E),
- E_INVALIDARG = unchecked((int)0x80070057),
- E_NOINTERFACE = unchecked((int)0x80004002),
- E_FAIL = unchecked((int)0x80004005),
- E_ABORT = unchecked((int)0x80004004),
- E_ACCESSDENIED = unchecked((int)0x80070005),
- E_UNEXPECTED = unchecked((int)0x8000FFFF),
- INET_E_DEFAULT_ACTION = unchecked((int)0x800C0011),
- ETO_OPAQUE = 0x0002,
- ETO_CLIPPED = 0x0004,
- EMR_POLYTEXTOUTA = 96,
- EMR_POLYTEXTOUTW = 97,
- EDGE_RAISED = (0x0001|0x0004),
- EDGE_SUNKEN = (0x0002|0x0008),
- EDGE_ETCHED = (0x0002|0x0004),
- EDGE_BUMP = (0x0001|0x0008),
- ES_LEFT = 0x0000,
- ES_CENTER = 0x0001,
- ES_RIGHT = 0x0002,
- ES_MULTILINE = 0x0004,
- ES_UPPERCASE = 0x0008,
- ES_LOWERCASE = 0x0010,
- ES_AUTOVSCROLL = 0x0040,
- ES_AUTOHSCROLL = 0x0080,
- ES_NOHIDESEL = 0x0100,
- ES_READONLY = 0x0800,
- ES_PASSWORD = 0x0020,
- EN_CHANGE = 0x0300,
- EN_UPDATE = 0x0400,
- EN_HSCROLL = 0x0601,
- EN_VSCROLL = 0x0602,
- EN_ALIGN_LTR_EC = 0x0700,
- EN_ALIGN_RTL_EC = 0x0701,
- EC_LEFTMARGIN = 0x0001,
- EC_RIGHTMARGIN = 0x0002,
- EM_GETSEL = 0x00B0,
- EM_SETSEL = 0x00B1,
- EM_SCROLL = 0x00B5,
- EM_SCROLLCARET = 0x00B7,
- EM_GETMODIFY = 0x00B8,
- EM_SETMODIFY = 0x00B9,
- EM_GETLINECOUNT = 0x00BA,
- EM_REPLACESEL = 0x00C2,
- EM_GETLINE = 0x00C4,
- EM_LIMITTEXT = 0x00C5,
- EM_CANUNDO = 0x00C6,
- EM_UNDO = 0x00C7,
- EM_SETPASSWORDCHAR = 0x00CC,
- EM_GETPASSWORDCHAR = 0x00D2,
- EM_EMPTYUNDOBUFFER = 0x00CD,
- EM_SETREADONLY = 0x00CF,
- EM_SETMARGINS = 0x00D3,
- EM_POSFROMCHAR = 0x00D6,
- EM_CHARFROMPOS = 0x00D7,
- EM_LINEFROMCHAR = 0x00C9,
- EM_LINEINDEX = 0x00BB;
-
- public const int FNERR_SUBCLASSFAILURE = 0x3001,
- FNERR_INVALIDFILENAME = 0x3002,
- FNERR_BUFFERTOOSMALL = 0x3003;
+ DVASPECT_CONTENT = 1;
public const int GMEM_MOVEABLE = 0x0002,
GMEM_ZEROINIT = 0x0040,
GMEM_DDESHARE = 0x2000,
- GCL_WNDPROC = (-24),
GWL_WNDPROC = (-4),
GWL_HWNDPARENT = (-8),
GWL_STYLE = (-16),
@@ -452,21 +192,11 @@ public const int
GW_HWNDPREV = 3,
GW_OWNER = 4,
GW_CHILD = 5,
- GMR_VISIBLE = 0,
- GMR_DAYSTATE = 1,
- GDI_ERROR = (unchecked((int)0xFFFFFFFF)),
- GDTR_MIN = 0x0001,
- GDTR_MAX = 0x0002,
- GDT_VALID = 0,
- GDT_NONE = 1,
GA_PARENT = 1,
- GA_ROOT = 2;
+ GA_ROOT = 2;
// ImmGetCompostionString index.
public const int
- GCS_COMPREADSTR = 0x0001,
- GCS_COMPREADATTR = 0x0002,
- GCS_COMPREADCLAUSE = 0x0004,
GCS_COMPSTR = 0x0008,
GCS_COMPATTR = 0x0010,
GCS_COMPCLAUSE = 0x0020,
@@ -489,12 +219,7 @@ public const int
NI_COMPOSITIONSTR = 0x0015,
// wParam of report message WM_IME_NOTIFY
- IMN_CLOSESTATUSWINDOW = 0x0001,
- IMN_OPENSTATUSWINDOW = 0x0002,
- IMN_CHANGECANDIDATE = 0x0003,
- IMN_CLOSECANDIDATE = 0x0004,
IMN_OPENCANDIDATE = 0x0005,
- IMN_SETCONVERSIONMODE = 0x0006,
IMN_SETSENTENCEMODE = 0x0007,
IMN_SETOPENSTATUS = 0x0008,
IMN_SETCANDIDATEPOS = 0x0009,
@@ -534,7 +259,6 @@ public const int
IME_CMODE_EUDC = 0x0200,
IME_CMODE_SYMBOL = 0x0400,
IME_CMODE_FIXED = 0x0800,
- IME_CMODE_RESERVED = unchecked((int)0xF0000000),
// bit field for sentence mode
IME_SMODE_NONE = 0x0000,
@@ -620,46 +344,11 @@ public struct REGISTERWORD
}
public const int
- HC_ACTION = 0,
- HC_GETNEXT = 1,
- HC_SKIP = 2,
- HTNOWHERE = 0,
HTCLIENT = 1,
- HTBOTTOM = 15,
- HTTRANSPARENT = (-1),
HTBOTTOMLEFT = 16,
HTBOTTOMRIGHT = 17,
- HELPINFO_WINDOW = 0x0001,
- HCF_HIGHCONTRASTON = 0x00000001,
- HDI_ORDER = 0x0080,
- HDI_WIDTH = 0x0001,
- HDM_GETITEMCOUNT = (0x1200+0),
- HDM_INSERTITEMA = (0x1200+1),
- HDM_INSERTITEMW = (0x1200+10),
- HDM_GETITEMA = (0x1200+3),
- HDM_GETITEMW = (0x1200+11),
- HDM_SETITEMA = (0x1200+4),
- HDM_SETITEMW = (0x1200+12),
- HDN_ITEMCHANGINGA = ((0-300)-0),
- HDN_ITEMCHANGINGW = ((0-300)-20),
- HDN_ITEMCHANGEDA = ((0-300)-1),
- HDN_ITEMCHANGEDW = ((0-300)-21),
- HDN_ITEMCLICKA = ((0-300)-2),
- HDN_ITEMCLICKW = ((0-300)-22),
- HDN_ITEMDBLCLICKA = ((0-300)-3),
- HDN_ITEMDBLCLICKW = ((0-300)-23),
- HDN_DIVIDERDBLCLICKA = ((0-300)-5),
- HDN_DIVIDERDBLCLICKW = ((0-300)-25),
- HDN_BEGINTDRAG = ((0-300)-10),
- HDN_BEGINTRACKA = ((0-300)-6),
- HDN_BEGINTRACKW = ((0-300)-26),
- HDN_ENDDRAG = ((0-300)-11),
- HDN_ENDTRACKA = ((0-300)-7),
- HDN_ENDTRACKW = ((0-300)-27),
- HDN_TRACKA = ((0-300)-8),
- HDN_TRACKW = ((0-300)-28),
- HDN_GETDISPINFOA = ((0-300)-9),
- HDN_GETDISPINFOW = ((0-300)-29);
+ HCF_HIGHCONTRASTON = 0x00000001;
+
// HOVER_DEFAULT = Do not use this value ever! It crashes entire servers.
public static HandleRef HWND_TOP = new HandleRef(null, (IntPtr)0);
@@ -669,7 +358,7 @@ public const int
// NOTE: NativeMethodsOther.cs defines the following
//public static IntPtr HWND_MESSAGE = new IntPtr(-3);
- public const int INPLACE_E_NOTOOLSPACE = unchecked((int)0x800401A1),
+ public const int
ICON_SMALL = 0,
ICON_BIG = 1,
IDC_ARROW = 32512,
@@ -685,36 +374,7 @@ public const int
IDC_NO = 32648,
IDC_APPSTARTING = 32650,
IDC_HELP = 32651,
- IMAGE_ICON = 1,
- IMAGE_CURSOR = 2,
- ICC_LISTVIEW_CLASSES = 0x00000001,
- ICC_TREEVIEW_CLASSES = 0x00000002,
- ICC_BAR_CLASSES = 0x00000004,
- ICC_TAB_CLASSES = 0x00000008,
- ICC_PROGRESS_CLASS = 0x00000020,
- ICC_DATE_CLASSES = 0x00000100,
- ILC_MASK = 0x0001,
- ILC_COLOR = 0x0000,
- ILC_COLOR4 = 0x0004,
- ILC_COLOR8 = 0x0008,
- ILC_COLOR16 = 0x0010,
- ILC_COLOR24 = 0x0018,
- ILC_COLOR32 = 0x0020,
- ILC_MIRROR = 0x00002000,
- ILD_NORMAL = 0x0000,
- ILD_TRANSPARENT = 0x0001,
- ILD_MASK = 0x0010,
- ILD_ROP = 0x0040,
-
- // ImageList
- //
- ILP_NORMAL = 0,
- ILP_DOWNLEVEL = 1,
- ILS_NORMAL = 0x0,
- ILS_GLOW = 0x1,
- ILS_SHADOW = 0x2,
- ILS_SATURATE = 0x4,
- ILS_ALPHA = 0x8;
+ IMAGE_CURSOR = 2;
public const int CSC_NAVIGATEFORWARD = 0x00000001,
CSC_NAVIGATEBACK = 0x00000002;
@@ -722,118 +382,17 @@ public const int
public const int STG_E_CANTSAVE = unchecked((int)0x80030103);
public const int LOGPIXELSX = 88,
- LOGPIXELSY = 90,
- LB_ERR = (-1),
- LB_ERRSPACE = (-2),
- LBN_SELCHANGE = 1,
- LBN_DBLCLK = 2,
- LB_ADDSTRING = 0x0180,
- LB_INSERTSTRING = 0x0181,
- LB_DELETESTRING = 0x0182,
- LB_RESETCONTENT = 0x0184,
- LB_SETSEL = 0x0185,
- LB_SETCURSEL = 0x0186,
- LB_GETSEL = 0x0187,
- LB_GETCARETINDEX = 0x019F,
- LB_GETCURSEL = 0x0188,
- LB_GETTEXT = 0x0189,
- LB_GETTEXTLEN = 0x018A,
- LB_GETTOPINDEX = 0x018E,
- LB_FINDSTRING = 0x018F,
- LB_GETSELCOUNT = 0x0190,
- LB_GETSELITEMS = 0x0191,
- LB_SETTABSTOPS = 0x0192,
- LB_SETHORIZONTALEXTENT = 0x0194,
- LB_SETCOLUMNWIDTH = 0x0195,
- LB_SETTOPINDEX = 0x0197,
- LB_GETITEMRECT = 0x0198,
- LB_SETITEMHEIGHT = 0x01A0,
- LB_GETITEMHEIGHT = 0x01A1,
- LB_FINDSTRINGEXACT = 0x01A2,
- LB_ITEMFROMPOINT = 0x01A9,
- LB_SETLOCALE = 0x01A5;
+ LOGPIXELSY = 90;
public const int LWA_ALPHA = 0x00000002;
public const int MEMBERID_NIL = (-1),
MAX_PATH = 260,
- MA_ACTIVATE = 0x0001,
- MA_ACTIVATEANDEAT = 0x0002,
MA_NOACTIVATE = 0x0003,
- MA_NOACTIVATEANDEAT = 0x0004,
- MM_TEXT = 1,
- MM_ANISOTROPIC = 8,
MK_LBUTTON = 0x0001,
MK_RBUTTON = 0x0002,
MK_SHIFT = 0x0004,
- MK_CONTROL = 0x0008,
- MK_MBUTTON = 0x0010,
- MNC_EXECUTE = 2,
- MNC_SELECT = 3,
- MIIM_STATE = 0x00000001,
- MIIM_ID = 0x00000002,
- MIIM_SUBMENU = 0x00000004,
- MIIM_TYPE = 0x00000010,
- MIIM_DATA = 0x00000020,
- MIIM_STRING = 0x00000040,
- MIIM_BITMAP = 0x00000080,
- MIIM_FTYPE = 0x00000100,
- MB_OK = 0x00000000,
- MF_BYCOMMAND = 0x00000000,
- MF_BYPOSITION = 0x00000400,
- MF_ENABLED = 0x00000000,
- MF_GRAYED = 0x00000001,
- MF_POPUP = 0x00000010,
- MF_SYSMENU = 0x00002000,
- MFS_DISABLED = 0x00000003,
- MFT_MENUBREAK = 0x00000040,
- MFT_SEPARATOR = 0x00000800,
- MFT_RIGHTORDER = 0x00002000,
- MFT_RIGHTJUSTIFY = 0x00004000,
- MDIS_ALLCHILDSTYLES = 0x0001,
- MDITILE_VERTICAL = 0x0000,
- MDITILE_HORIZONTAL = 0x0001,
- MDITILE_SKIPDISABLED = 0x0002,
- MCM_SETMAXSELCOUNT = (0x1000+4),
- MCM_SETSELRANGE = (0x1000+6),
- MCM_GETMONTHRANGE = (0x1000+7),
- MCM_GETMINREQRECT = (0x1000+9),
- MCM_SETCOLOR = (0x1000+10),
- MCM_SETTODAY = (0x1000+12),
- MCM_GETTODAY = (0x1000+13),
- MCM_HITTEST = (0x1000+14),
- MCM_SETFIRSTDAYOFWEEK = (0x1000+15),
- MCM_SETRANGE = (0x1000+18),
- MCM_SETMONTHDELTA = (0x1000+20),
- MCM_GETMAXTODAYWIDTH = (0x1000+21),
- MCHT_TITLE = 0x00010000,
- MCHT_CALENDAR = 0x00020000,
- MCHT_TODAYLINK = 0x00030000,
- MCHT_TITLEBK = (0x00010000),
- MCHT_TITLEMONTH = (0x00010000|0x0001),
- MCHT_TITLEYEAR = (0x00010000|0x0002),
- MCHT_TITLEBTNNEXT = (0x00010000|0x01000000|0x0003),
- MCHT_TITLEBTNPREV = (0x00010000|0x02000000|0x0003),
- MCHT_CALENDARBK = (0x00020000),
- MCHT_CALENDARDATE = (0x00020000|0x0001),
- MCHT_CALENDARDATENEXT = ((0x00020000|0x0001)|0x01000000),
- MCHT_CALENDARDATEPREV = ((0x00020000|0x0001)|0x02000000),
- MCHT_CALENDARDAY = (0x00020000|0x0002),
- MCHT_CALENDARWEEKNUM = (0x00020000|0x0003),
- MCSC_TEXT = 1,
- MCSC_TITLEBK = 2,
- MCSC_TITLETEXT = 3,
- MCSC_MONTHBK = 4,
- MCSC_TRAILINGTEXT = 5,
- MCN_SELCHANGE = ((0-750)+1),
- MCN_GETDAYSTATE = ((0-750)+3),
- MCN_SELECT = ((0-750)+4),
- MCS_DAYSTATE = 0x0001,
- MCS_MULTISELECT = 0x0002,
- MCS_WEEKNUMBERS = 0x0004,
- MCS_NOTODAYCIRCLE = 0x0008,
- MCS_NOTODAY = 0x0010,
- MSAA_MENU_SIG = (unchecked((int) 0xAA0DF00D));
+ MK_CONTROL = 0x0008;
//ActiveX related defines
public const int
@@ -859,72 +418,7 @@ public const int
XFORMCOORDS_HIMETRICTOCONTAINER = 0x4,
XFORMCOORDS_CONTAINERTOHIMETRIC = 0x8;
- public const int OFN_READONLY = 0x00000001,
- OFN_OVERWRITEPROMPT = 0x00000002,
- OFN_HIDEREADONLY = 0x00000004,
- OFN_NOCHANGEDIR = 0x00000008,
- //OFN_SHOWHELP = 0x00000010,
- OFN_ENABLEHOOK = 0x00000020,
- OFN_NOVALIDATE = 0x00000100,
- OFN_ALLOWMULTISELECT = 0x00000200,
- OFN_PATHMUSTEXIST = 0x00000800,
- OFN_FILEMUSTEXIST = 0x00001000,
- OFN_CREATEPROMPT = 0x00002000,
- OFN_EXPLORER = 0x00080000,
- OFN_NODEREFERENCELINKS = 0x00100000,
- OFN_ENABLESIZING = 0x00800000,
- OFN_USESHELLITEM = 0x01000000;
-
- public const int PDERR_SETUPFAILURE = 0x1001,
- PDERR_PARSEFAILURE = 0x1002,
- PDERR_RETDEFFAILURE = 0x1003,
- PDERR_LOADDRVFAILURE = 0x1004,
- PDERR_GETDEVMODEFAIL = 0x1005,
- PDERR_INITFAILURE = 0x1006,
- PDERR_NODEVICES = 0x1007,
- PDERR_NODEFAULTPRN = 0x1008,
- PDERR_DNDMMISMATCH = 0x1009,
- PDERR_CREATEICFAILURE = 0x100A,
- PDERR_PRINTERNOTFOUND = 0x100B,
- PDERR_DEFAULTDIFFERENT = 0x100C,
- PD_ALLPAGES = 0x00000000,
- PD_SELECTION = 0x00000001,
- PD_PAGENUMS = 0x00000002,
- PD_NOSELECTION = 0x00000004,
- PD_NOPAGENUMS = 0x00000008,
- PD_COLLATE = 0x00000010,
- PD_PRINTTOFILE = 0x00000020,
- PD_PRINTSETUP = 0x00000040,
- PD_NOWARNING = 0x00000080,
- PD_RETURNDC = 0x00000100,
- PD_RETURNIC = 0x00000200,
- PD_RETURNDEFAULT = 0x00000400,
- PD_SHOWHELP = 0x00000800,
- PD_ENABLEPRINTHOOK = 0x00001000,
- PD_ENABLESETUPHOOK = 0x00002000,
- PD_ENABLEPRINTTEMPLATE = 0x00004000,
- PD_ENABLESETUPTEMPLATE = 0x00008000,
- PD_ENABLEPRINTTEMPLATEHANDLE = 0x00010000,
- PD_ENABLESETUPTEMPLATEHANDLE = 0x00020000,
- PD_USEDEVMODECOPIES = 0x00040000,
- PD_USEDEVMODECOPIESANDCOLLATE = 0x00040000,
- PD_DISABLEPRINTTOFILE = 0x00080000,
- PD_HIDEPRINTTOFILE = 0x00100000,
- PD_NONETWORKBUTTON = 0x00200000,
- PD_CURRENTPAGE = 0x00400000,
- PD_NOCURRENTPAGE = 0x00800000,
- PD_EXCLUSIONFLAGS = 0x01000000,
- PD_USELARGETEMPLATE = 0x10000000,
- PSD_MINMARGINS = 0x00000001,
- PSD_MARGINS = 0x00000002,
- PSD_INHUNDREDTHSOFMILLIMETERS = 0x00000008,
- PSD_DISABLEMARGINS = 0x00000010,
- PSD_DISABLEPRINTER = 0x00000020,
- PSD_DISABLEORIENTATION = 0x00000100,
- PSD_DISABLEPAPER = 0x00000200,
- PSD_SHOWHELP = 0x00000800,
- PSD_ENABLEPAGESETUPHOOK = 0x00002000,
- PSD_NONETWORKBUTTON = 0x00200000,
+ public const int
PS_SOLID = 0,
PS_DOT = 2,
PLANES = 14,
@@ -936,16 +430,6 @@ public const int
PM_NOREMOVE = 0x0000,
PM_REMOVE = 0x0001,
PM_NOYIELD = 0x0002,
- PBM_SETRANGE = (0x0400+1),
- PBM_SETPOS = (0x0400+2),
- PBM_SETSTEP = (0x0400+4),
- PBM_SETRANGE32 = (0x0400+6),
- PBM_SETBARCOLOR = (0x0400+9),
- PBM_SETBKCOLOR = (0x2000 +1),
- PSM_SETTITLEA = (0x0400+111),
- PSM_SETTITLEW = (0x0400+120),
- PSM_SETFINISHTEXTA = (0x0400+115),
- PSM_SETFINISHTEXTW = (0x0400+121),
PATCOPY = 0x00F00021,
PATINVERT = 0x005A0049;
@@ -966,8 +450,7 @@ public const int
public const int RDW_INVALIDATE = 0x0001;
public const int RDW_ALLCHILDREN = 0x0080;
- public const int stc4 = 0x0443,
- SHGFP_TYPE_CURRENT = 0,
+ public const int
STGM_READ = 0x00000000,
STGM_WRITE = 0x00000001,
STGM_READWRITE = 0x00000002,
@@ -983,29 +466,7 @@ public const int
STGTY_PROPERTY = 4,
STARTF_USESHOWWINDOW = 0x00000001,
- SB_HORZ = 0,
- SB_VERT = 1,
- SB_CTL = 2,
- SB_LINEUP = 0,
- SB_LINELEFT = 0,
- SB_LINEDOWN = 1,
- SB_LINERIGHT = 1,
- SB_PAGEUP = 2,
- SB_PAGELEFT = 2,
- SB_PAGEDOWN = 3,
- SB_PAGERIGHT = 3,
- SB_THUMBPOSITION = 4,
- SB_THUMBTRACK = 5,
- SB_LEFT = 6,
- SB_RIGHT = 7,
- SB_ENDSCROLL = 8,
- SB_TOP = 6,
- SB_BOTTOM = 7,
SIZE_MAXIMIZED = 2,
- ESB_ENABLE_BOTH = 0x0000,
- ESB_DISABLE_BOTH =0x0003,
- SORT_DEFAULT =0x0,
- SUBLANG_DEFAULT = 0x01,
SW_HIDE = 0,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
@@ -1026,35 +487,14 @@ public const int
SWP_HIDEWINDOW = 0x0080,
SWP_DRAWFRAME = 0x0020;
- public const int MB_ICONHAND = 0x000010,
- MB_ICONQUESTION = 0x000020,
- MB_ICONEXCLAMATION = 0x000030,
- MB_ICONASTERISK = 0x000040;
-
- public const int SW_SCROLLCHILDREN = 0x0001,
- SW_INVALIDATE = 0x0002,
- SW_ERASE = 0x0004,
- SW_SMOOTHSCROLL = 0x0010,
+ public const int
SC_SIZE = 0xF000,
SC_MINIMIZE = 0xF020,
SC_MAXIMIZE = 0xF030,
SC_CLOSE = 0xF060,
SC_KEYMENU = 0xF100,
SC_RESTORE = 0xF120,
- SC_MOVE = 0xF010,
- SS_LEFT = 0x00000000,
- SS_CENTER = 0x00000001,
- SS_RIGHT = 0x00000002,
- SS_OWNERDRAW = 0x0000000D,
- SS_NOPREFIX = 0x00000080,
- SS_SUNKEN = 0x00001000,
- SBS_HORZ = 0x0000,
- SBS_VERT = 0x0001,
- SIF_RANGE = 0x0001,
- SIF_PAGE = 0x0002,
- SIF_POS = 0x0004,
- SIF_TRACKPOS = 0x0010,
- SIF_ALL = (0x0001|0x0002|0x0004|0x0010),
+ SC_MOVE = 0xF010,
SPI_GETFONTSMOOTHING = 0x004A,
SPI_GETDROPSHADOW = 0x1024,
SPI_GETFLATMENU = 0x1022,
@@ -1098,29 +538,6 @@ public const int
SPI_GETDEFAULTINPUTLANG = 89,
SPI_GETSNAPTODEFBUTTON = 95,
SPI_GETWHEELSCROLLLINES = 104,
- SBARS_SIZEGRIP = 0x0100,
- SB_SETTEXTA = (0x0400+1),
- SB_SETTEXTW = (0x0400+11),
- SB_GETTEXTA = (0x0400+2),
- SB_GETTEXTW = (0x0400+13),
- SB_GETTEXTLENGTHA = (0x0400+3),
- SB_GETTEXTLENGTHW = (0x0400+12),
- SB_SETPARTS = (0x0400+4),
- SB_SIMPLE = (0x0400+9),
- SB_GETRECT = (0x0400+10),
- SB_SETICON = (0x0400+15),
- SB_SETTIPTEXTA = (0x0400+16),
- SB_SETTIPTEXTW = (0x0400+17),
- SB_GETTIPTEXTA = (0x0400+18),
- SB_GETTIPTEXTW = (0x0400+19),
- SBT_OWNERDRAW = 0x1000,
- SBT_NOBORDERS = 0x0100,
- SBT_POPOUT = 0x0200,
- SBT_RTLREADING = 0x0400,
- SRCCOPY = 0x00CC0020,
- SRCAND = 0x008800C6, /* dest = source AND dest */
- SRCPAINT = 0x00EE0086, /* dest = source OR dest */
- NOTSRCCOPY = 0x00330008, /* dest = (NOT source) */
STATFLAG_DEFAULT = 0x0,
STATFLAG_NONAME = 0x1,
STATFLAG_NOOPEN = 0x2,
@@ -1132,323 +549,19 @@ public const int
STREAM_SEEK_CUR = 0x1,
STREAM_SEEK_END = 0x2;
- public const int S_OK = 0x00000000;
- public const int S_FALSE = 0x00000001;
-
- public static bool Succeeded(int hr) {
- return(hr >= 0);
- }
-
- public static bool Failed(int hr) {
- return(hr < 0);
- }
-
- public const int TRANSPARENT = 1,
- OPAQUE = 2,
- TME_HOVER = 0x00000001,
- TME_LEAVE = 0x00000002,
- TPM_LEFTBUTTON = 0x0000,
- TPM_RIGHTBUTTON = 0x0002,
- TPM_LEFTALIGN = 0x0000,
- TPM_RIGHTALIGN = 0x0008,
- TPM_VERTICAL = 0x0040,
- TV_FIRST = 0x1100,
- TBSTATE_CHECKED = 0x01,
- TBSTATE_ENABLED = 0x04,
- TBSTATE_HIDDEN = 0x08,
- TBSTATE_INDETERMINATE = 0x10,
- TBSTYLE_BUTTON = 0x00,
- TBSTYLE_SEP = 0x01,
- TBSTYLE_CHECK = 0x02,
- TBSTYLE_DROPDOWN = 0x08,
- TBSTYLE_TOOLTIPS = 0x0100,
- TBSTYLE_FLAT = 0x0800,
- TBSTYLE_LIST = 0x1000,
- TBSTYLE_EX_DRAWDDARROWS = 0x00000001,
- TB_ENABLEBUTTON = (0x0400+1),
- TB_ISBUTTONCHECKED = (0x0400+10),
- TB_ISBUTTONINDETERMINATE = (0x0400+13),
- TB_ADDBUTTONSA = (0x0400+20),
- TB_ADDBUTTONSW = (0x0400+68),
- TB_INSERTBUTTONA = (0x0400+21),
- TB_INSERTBUTTONW = (0x0400+67),
- TB_DELETEBUTTON = (0x0400+22),
- TB_GETBUTTON = (0x0400+23),
- TB_SAVERESTOREA = (0x0400+26),
- TB_SAVERESTOREW = (0x0400+76),
- TB_ADDSTRINGA = (0x0400+28),
- TB_ADDSTRINGW = (0x0400+77),
- TB_BUTTONSTRUCTSIZE = (0x0400+30),
- TB_SETBUTTONSIZE = (0x0400+31),
- TB_AUTOSIZE = (0x0400+33),
- TB_GETROWS = (0x0400+40),
- TB_GETBUTTONTEXTA = (0x0400+45),
- TB_GETBUTTONTEXTW = (0x0400+75),
- TB_SETIMAGELIST = (0x0400+48),
- TB_GETRECT = (0x0400+51),
- TB_GETBUTTONSIZE = (0x0400+58),
- TB_GETBUTTONINFOW = (0x0400+63),
- TB_SETBUTTONINFOW = (0x0400+64),
- TB_GETBUTTONINFOA = (0x0400+65),
- TB_SETBUTTONINFOA = (0x0400+66),
- TB_MAPACCELERATORA = (0x0400+78),
- TB_SETEXTENDEDSTYLE = (0x0400+84),
- TB_MAPACCELERATORW = (0x0400+90),
- TB_GETTOOLTIPS = (0x0400 + 35),
- TB_SETTOOLTIPS = (0x0400 + 36),
- TBIF_IMAGE = 0x00000001,
- TBIF_TEXT = 0x00000002,
- TBIF_STATE = 0x00000004,
- TBIF_STYLE = 0x00000008,
- TBIF_COMMAND = 0x00000020,
- TBIF_SIZE = 0x00000040,
- TBN_GETBUTTONINFOA = ((0-700)-0),
- TBN_GETBUTTONINFOW = ((0-700)-20),
- TBN_QUERYINSERT = ((0-700)-6),
- TBN_DROPDOWN = ((0-700)-10),
- TBN_HOTITEMCHANGE = ((0-700)-13),
- TBN_GETDISPINFOA = ((0-700)-16),
- TBN_GETDISPINFOW = ((0-700)-17),
- TBN_GETINFOTIPA = ((0-700)-18),
- TBN_GETINFOTIPW = ((0-700)-19),
- TTS_ALWAYSTIP = 0x01,
- TTS_NOPREFIX =0x02,
- TTS_NOANIMATE =0x10,
- TTS_NOFADE =0x20,
- TTS_BALLOON =0x40,
- //TTI_NONE =0,
- //TTI_INFO =1,
- TTI_WARNING =2,
- //TTI_ERROR =3,
- TTF_IDISHWND = 0x0001,
- TTF_RTLREADING = 0x0004,
- TTF_TRACK = 0x0020,
- TTF_CENTERTIP = 0x0002,
- TTF_SUBCLASS = 0x0010,
- TTF_TRANSPARENT = 0x0100,
- TTF_ABSOLUTE = 0x0080,
- TTDT_AUTOMATIC = 0,
- TTDT_RESHOW = 1,
- TTDT_AUTOPOP = 2,
- TTDT_INITIAL = 3,
- TTM_TRACKACTIVATE = (0x0400+17),
- TTM_TRACKPOSITION = (0x0400+18),
- TTM_ACTIVATE = (0x0400+1),
- TTM_POP = (0x0400 + 28),
- TTM_ADJUSTRECT = (0x400 + 31),
- TTM_SETDELAYTIME = (0x0400+3),
-#if !DRT && !UIAUTOMATIONTYPES
- TTM_SETTITLEA =((int)WindowMessage.WM_USER + 32), // wParam = TTI_*, lParam = char* szTitle
- TTM_SETTITLEW =((int)WindowMessage.WM_USER + 33), // wParam = TTI_*, lParam = wchar* szTitle
-#endif
- TTM_ADDTOOLA = (0x0400+4),
- TTM_ADDTOOLW = (0x0400+50),
- TTM_DELTOOLA = (0x0400+5),
- TTM_DELTOOLW = (0x0400+51),
- TTM_NEWTOOLRECTA = (0x0400+6),
- TTM_NEWTOOLRECTW = (0x0400+52),
- TTM_RELAYEVENT = (0x0400+7),
- TTM_GETTIPBKCOLOR = (0x0400+22),
- TTM_SETTIPBKCOLOR = (0x0400 + 19),
- TTM_SETTIPTEXTCOLOR = (0x0400 + 20),
- TTM_GETTIPTEXTCOLOR = (0x0400+23),
- TTM_GETTOOLINFOA = (0x0400+8),
- TTM_GETTOOLINFOW = (0x0400+53),
- TTM_SETTOOLINFOA = (0x0400+9),
- TTM_SETTOOLINFOW = (0x0400+54),
- TTM_HITTESTA = (0x0400+10),
- TTM_HITTESTW = (0x0400+55),
- TTM_GETTEXTA = (0x0400+11),
- TTM_GETTEXTW = (0x0400+56),
- TTM_UPDATE = (0x0400+29),
- TTM_UPDATETIPTEXTA = (0x0400+12),
- TTM_UPDATETIPTEXTW = (0x0400+57),
- TTM_ENUMTOOLSA = (0x0400+14),
- TTM_ENUMTOOLSW = (0x0400+58),
- TTM_GETCURRENTTOOLA = (0x0400+15),
- TTM_GETCURRENTTOOLW = (0x0400+59),
- TTM_WINDOWFROMPOINT = (0x0400+16),
- TTM_GETDELAYTIME = (0x0400+21),
- TTM_SETMAXTIPWIDTH = (0x0400+24),
- TTN_GETDISPINFOA = ((0-520)-0),
- TTN_GETDISPINFOW = ((0-520)-10),
- TTN_SHOW = ((0-520)-1),
- TTN_POP = ((0-520)-2),
- TTN_NEEDTEXTA = ((0-520)-0),
- TTN_NEEDTEXTW = ((0-520)-10),
- TBS_AUTOTICKS = 0x0001,
- TBS_VERT = 0x0002,
- TBS_TOP = 0x0004,
- TBS_BOTTOM = 0x0000,
- TBS_BOTH = 0x0008,
- TBS_NOTICKS = 0x0010,
- TBM_GETPOS = (0x0400),
- TBM_SETTIC = (0x0400+4),
- TBM_SETPOS = (0x0400+5),
- TBM_SETRANGE = (0x0400+6),
- TBM_SETRANGEMIN = (0x0400+7),
- TBM_SETRANGEMAX = (0x0400+8),
- TBM_SETTICFREQ = (0x0400+20),
- TBM_SETPAGESIZE = (0x0400+21),
- TBM_SETLINESIZE = (0x0400+23),
- TB_LINEUP = 0,
- TB_LINEDOWN = 1,
- TB_PAGEUP = 2,
- TB_PAGEDOWN = 3,
- TB_THUMBPOSITION = 4,
- TB_THUMBTRACK = 5,
- TB_TOP = 6,
- TB_BOTTOM = 7,
- TB_ENDTRACK = 8,
- TVS_HASBUTTONS = 0x0001,
- TVS_HASLINES = 0x0002,
- TVS_LINESATROOT = 0x0004,
- TVS_EDITLABELS = 0x0008,
- TVS_SHOWSELALWAYS = 0x0020,
- TVS_RTLREADING = 0x0040,
- TVS_CHECKBOXES = 0x0100,
- TVS_TRACKSELECT = 0x0200,
- TVS_FULLROWSELECT = 0x1000,
- TVS_NONEVENHEIGHT = 0x4000,
- TVS_INFOTIP = 0x0800,
- TVS_NOTOOLTIPS = 0x0080,
- TVIF_TEXT = 0x0001,
- TVIF_IMAGE = 0x0002,
- TVIF_PARAM = 0x0004,
- TVIF_STATE = 0x0008,
- TVIF_HANDLE = 0x0010,
- TVIF_SELECTEDIMAGE = 0x0020,
- TVIS_SELECTED = 0x0002,
- TVIS_EXPANDED = 0x0020,
- TVIS_EXPANDEDONCE = 0x0040,
- TVIS_STATEIMAGEMASK = 0xF000,
- TVI_ROOT = (unchecked((int)0xFFFF0000)),
- TVI_FIRST = (unchecked((int)0xFFFF0001)),
- TVM_INSERTITEMA = (0x1100+0),
- TVM_INSERTITEMW = (0x1100+50),
- TVM_DELETEITEM = (0x1100+1),
- TVM_EXPAND = (0x1100+2),
- TVE_COLLAPSE = 0x0001,
- TVE_EXPAND = 0x0002,
- TVM_GETITEMRECT = (0x1100+4),
- TVM_GETINDENT = (0x1100+6),
- TVM_SETINDENT = (0x1100+7),
- TVM_SETIMAGELIST = (0x1100+9),
- TVM_GETNEXTITEM = (0x1100+10),
- TVGN_NEXT = 0x0001,
- TVGN_PREVIOUS = 0x0002,
- TVGN_FIRSTVISIBLE = 0x0005,
- TVGN_NEXTVISIBLE = 0x0006,
- TVGN_PREVIOUSVISIBLE = 0x0007,
- TVGN_CARET = 0x0009,
- TVM_SELECTITEM = (0x1100+11),
- TVM_GETITEMA = (0x1100+12),
- TVM_GETITEMW = (0x1100+62),
- TVM_SETITEMA = (0x1100+13),
- TVM_SETITEMW = (0x1100+63),
- TVM_EDITLABELA = (0x1100+14),
- TVM_EDITLABELW = (0x1100+65),
- TVM_GETEDITCONTROL = (0x1100+15),
- TVM_GETVISIBLECOUNT = (0x1100+16),
- TVM_HITTEST = (0x1100+17),
- TVM_ENSUREVISIBLE = (0x1100+20),
- TVM_ENDEDITLABELNOW = (0x1100+22),
- TVM_GETISEARCHSTRINGA = (0x1100+23),
- TVM_GETISEARCHSTRINGW = (0x1100+64),
- TVM_SETITEMHEIGHT = (0x1100+27),
- TVM_GETITEMHEIGHT = (0x1100+28),
- TVN_SELCHANGINGA = ((0-400)-1),
- TVN_SELCHANGINGW = ((0-400)-50),
- TVN_GETINFOTIPA = ((0-400)-13),
- TVN_GETINFOTIPW = ((0-400)-14),
- TVN_SELCHANGEDA = ((0-400)-2),
- TVN_SELCHANGEDW = ((0-400)-51),
- TVC_UNKNOWN = 0x0000,
- TVC_BYMOUSE = 0x0001,
- TVC_BYKEYBOARD = 0x0002,
- TVN_GETDISPINFOA = ((0-400)-3),
- TVN_GETDISPINFOW = ((0-400)-52),
- TVN_SETDISPINFOA = ((0-400)-4),
- TVN_SETDISPINFOW = ((0-400)-53),
- TVN_ITEMEXPANDINGA = ((0-400)-5),
- TVN_ITEMEXPANDINGW = ((0-400)-54),
- TVN_ITEMEXPANDEDA = ((0-400)-6),
- TVN_ITEMEXPANDEDW = ((0-400)-55),
- TVN_BEGINDRAGA = ((0-400)-7),
- TVN_BEGINDRAGW = ((0-400)-56),
- TVN_BEGINRDRAGA = ((0-400)-8),
- TVN_BEGINRDRAGW = ((0-400)-57),
- TVN_BEGINLABELEDITA = ((0-400)-10),
- TVN_BEGINLABELEDITW = ((0-400)-59),
- TVN_ENDLABELEDITA = ((0-400)-11),
- TVN_ENDLABELEDITW = ((0-400)-60),
- TCS_BOTTOM = 0x0002,
- TCS_RIGHT = 0x0002,
- TCS_FLATBUTTONS = 0x0008,
- TCS_HOTTRACK = 0x0040,
- TCS_VERTICAL = 0x0080,
- TCS_TABS = 0x0000,
- TCS_BUTTONS = 0x0100,
- TCS_MULTILINE = 0x0200,
- TCS_RIGHTJUSTIFY = 0x0000,
- TCS_FIXEDWIDTH = 0x0400,
- TCS_RAGGEDRIGHT = 0x0800,
- TCS_OWNERDRAWFIXED = 0x2000,
- TCS_TOOLTIPS = 0x4000,
- TCM_SETIMAGELIST = (0x1300+3),
- TCIF_TEXT = 0x0001,
- TCIF_IMAGE = 0x0002,
- TCM_GETITEMA = (0x1300+5),
- TCM_GETITEMW = (0x1300+60),
- TCM_SETITEMA = (0x1300+6),
- TCM_SETITEMW = (0x1300+61),
- TCM_INSERTITEMA = (0x1300+7),
- TCM_INSERTITEMW = (0x1300+62),
- TCM_DELETEITEM = (0x1300+8),
- TCM_DELETEALLITEMS = (0x1300+9),
- TCM_GETITEMRECT = (0x1300+10),
- TCM_GETCURSEL = (0x1300+11),
- TCM_SETCURSEL = (0x1300+12),
- TCM_ADJUSTRECT = (0x1300+40),
- TCM_SETITEMSIZE = (0x1300+41),
- TCM_SETPADDING = (0x1300+43),
- TCM_GETROWCOUNT = (0x1300+44),
- TCM_GETTOOLTIPS = (0x1300+45),
- TCM_SETTOOLTIPS = (0x1300+46),
- TCN_SELCHANGE = ((0-550)-1),
- TCN_SELCHANGING = ((0-550)-2),
- TBSTYLE_WRAPPABLE = 0x0200,
- TVM_SETBKCOLOR = (TV_FIRST + 29),
- TVM_SETTEXTCOLOR = (TV_FIRST + 30),
- TYMED_NULL = 0,
- TVM_GETLINECOLOR = (TV_FIRST + 41),
- TVM_SETLINECOLOR = (TV_FIRST + 40),
- TVM_SETTOOLTIPS = (TV_FIRST + 24),
- TVSIL_STATE = 2,
- TVM_SORTCHILDRENCB = (TV_FIRST + 21);
-
- public const int
- UIS_SET = 1,
- UIS_CLEAR = 2,
- UIS_INITIALIZE = 3,
- UISF_HIDEFOCUS = 0x1,
- UISF_HIDEACCEL = 0x2,
- UISF_ACTIVE = 0x4;
+ public const int TME_LEAVE = 0x00000002;
public const int VK_TAB = 0x09;
public const int VK_SHIFT = 0x10;
public const int VK_CONTROL = 0x11;
public const int VK_MENU = 0x12;
- public const int WH_JOURNALPLAYBACK = 1,
- WH_GETMESSAGE = 3,
- WH_MOUSE = 7,
- WSF_VISIBLE = 0x0001,
+ public const int
WA_INACTIVE = 0,
WA_ACTIVE = 1,
WA_CLICKACTIVE = 2;
- public const int WHEEL_DELTA = 120,
+ public const int
#if !DRT && !UIAUTOMATIONTYPES
WM_REFLECT = (int)WindowMessage.WM_USER + 0x1C00,
WM_CHOOSEFONT_GETLOGFONT = (int)WindowMessage.WM_USER +1,
@@ -1497,20 +610,15 @@ public const int
public const int WHITE_BRUSH = 0x00000000;
public const int NULL_BRUSH = 5;
- public const int XBUTTON1 = 0x0001;
- public const int XBUTTON2 = 0x0002;
-
public static int SignedHIWORD(int n)
{
int i = (int)(short)((n >> 16) & 0xffff);
-
return i;
}
public static int SignedLOWORD(int n)
{
int i = (int)(short)(n & 0xFFFF);
-
return i;
}
@@ -1560,14 +668,6 @@ public override string ToString() {
public delegate IntPtr WndProc(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam);
- [StructLayout(LayoutKind.Sequential)]
- public struct MARGINS {
- public int cxLeftWidth;
- public int cxRightWidth;
- public int cyTopHeight;
- public int cyBottomHeight;
- }
-
[StructLayout(LayoutKind.Sequential)]
public class NONCLIENTMETRICS {
public int cbSize = SizeOf();
@@ -1682,28 +782,8 @@ public class BITMAP {
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public class LOGFONT {
- public LOGFONT() {
- }
- public LOGFONT( LOGFONT lf )
- {
- ArgumentNullException.ThrowIfNull(lf);
-
- this.lfHeight = lf.lfHeight;
- this.lfWidth = lf.lfWidth;
- this.lfEscapement = lf.lfEscapement;
- this.lfOrientation = lf.lfOrientation;
- this.lfWeight = lf.lfWeight;
- this.lfItalic = lf.lfItalic;
- this.lfUnderline = lf.lfUnderline;
- this.lfStrikeOut = lf.lfStrikeOut;
- this.lfCharSet = lf.lfCharSet;
- this.lfOutPrecision = lf.lfOutPrecision;
- this.lfClipPrecision = lf.lfClipPrecision;
- this.lfQuality = lf.lfQuality;
- this.lfPitchAndFamily = lf.lfPitchAndFamily;
- this.lfFaceName = lf.lfFaceName;
- }
+ public class LOGFONT
+ {
public int lfHeight;
public int lfWidth;
public int lfEscapement;
@@ -1718,94 +798,11 @@ public LOGFONT( LOGFONT lf )
public byte lfQuality;
public byte lfPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
- public string lfFaceName;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
- public class MENUITEMINFO_T
- {
- public int cbSize = SizeOf();
- public int fMask = 0;
- public int fType = 0;
- public int fState = 0;
- public int wID = 0;
- public IntPtr hSubMenu = IntPtr.Zero;
- public IntPtr hbmpChecked = IntPtr.Zero;
- public IntPtr hbmpUnchecked = IntPtr.Zero;
- public int dwItemData = 0;
- public string dwTypeData = null;
- public int cch = 0;
-
- private static int SizeOf()
- {
- return Marshal.SizeOf(typeof(MENUITEMINFO_T));
- }
+ public string lfFaceName;
}
public delegate bool EnumThreadWindowsCallback(IntPtr hWnd, IntPtr lParam);
- [StructLayout(LayoutKind.Sequential)]
- internal class OFNOTIFY
- {
- // hdr was a by-value NMHDR structure
- internal IntPtr hdr_hwndFrom;
- internal IntPtr hdr_idFrom;
- internal int hdr_code;
-
- internal IntPtr lpOFN;
- internal IntPtr pszFile;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public class OPENFILENAME_I
- {
- public int lStructSize = SizeOf(); //ndirect.DllLib.sizeOf(this);
- public IntPtr hwndOwner;
- public IntPtr hInstance;
- public string lpstrFilter; // use embedded nulls to separate filters
- public IntPtr lpstrCustomFilter;
- public int nMaxCustFilter;
- public int nFilterIndex;
- public IntPtr lpstrFile;
- public int nMaxFile = NativeMethods.MAX_PATH;
- public IntPtr lpstrFileTitle;
- public int nMaxFileTitle = NativeMethods.MAX_PATH;
- public string lpstrInitialDir;
- public string lpstrTitle;
- public int Flags;
- public short nFileOffset;
- public short nFileExtension;
- public string lpstrDefExt;
- public IntPtr lCustData;
- public WndProc lpfnHook;
- public string lpTemplateName;
- public IntPtr pvReserved;
- public int dwReserved;
- public int FlagsEx;
-
- private static int SizeOf()
- {
- return Marshal.SizeOf(typeof(OPENFILENAME_I));
- }
- }
-
- // constants related to the OPENFILENAME structure and file open/save dialogs
- public const int CDN_FIRST = unchecked((int)(0U-601U));
-
- public const int CDN_INITDONE = (CDN_FIRST - 0x0000);
- public const int CDN_SELCHANGE = (CDN_FIRST - 0x0001);
- public const int CDN_SHAREVIOLATION = (CDN_FIRST - 0x0003);
- public const int CDN_FILEOK = (CDN_FIRST - 0x0005);
-
-#if !DRT && !UIAUTOMATIONTYPES
- public const int CDM_FIRST = (int)WindowMessage.WM_USER + 100;
-
- public const int CDM_GETSPEC = (CDM_FIRST + 0x0000);
- public const int CDM_GETFILEPATH = (CDM_FIRST + 0x0001);
-#endif
-
- public const int DWL_MSGRESULT = 0;
-
[StructLayout(LayoutKind.Sequential)]
public struct STYLESTRUCT {
public int styleOld;
@@ -1869,17 +866,17 @@ public class COMRECT {
public COMRECT(int x, int y, int right, int bottom)
{
- this.left = x;
- this.top = y;
+ left = x;
+ top = y;
this.right = right;
this.bottom = bottom;
}
public COMRECT(RECT rect) {
- this.left = rect.left;
- this.top = rect.top;
- this.bottom = rect.bottom;
- this.right = rect.right;
+ left = rect.left;
+ top = rect.top;
+ bottom = rect.bottom;
+ right = rect.right;
}
public void CopyTo(COMRECT destRect) {
@@ -1905,22 +902,22 @@ public sealed class tagOleMenuGroupWidths {
[StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/]
public struct POINTF
{
- public float x;
- public float y;
+ public float x;
+ public float y;
}
[StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/]
public sealed class OLEINPLACEFRAMEINFO
{
- [MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cb)*/]
- public uint cb;
+ [MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cb)*/]
+ public uint cb;
- public bool fMDIApp;
- public IntPtr hwndFrame;
- public IntPtr hAccel;
+ public bool fMDIApp;
+ public IntPtr hwndFrame;
+ public IntPtr hAccel;
- [MarshalAs(UnmanagedType.U4)/*leftover(offset=16, cAccelEntries)*/]
- public uint cAccelEntries;
+ [MarshalAs(UnmanagedType.U4)/*leftover(offset=16, cAccelEntries)*/]
+ public uint cAccelEntries;
}
[StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/]
@@ -1948,26 +945,6 @@ public sealed class tagLOGPALETTE
public ushort palNumEntries = 0;
}
- [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/]
- public sealed class tagCONTROLINFO
- {
- [MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cb)*/]
- public uint cb = (uint)SizeOf();
-
- public IntPtr hAccel;
-
- [MarshalAs(UnmanagedType.U2)/*leftover(offset=8, cAccel)*/]
- public ushort cAccel;
-
- [MarshalAs(UnmanagedType.U4)/*leftover(offset=10, dwFlags)*/]
- public uint dwFlags;
-
- private static int SizeOf()
- {
- return Marshal.SizeOf(typeof(tagCONTROLINFO));
- }
- }
-
[StructLayout(LayoutKind.Sequential)]
public sealed class VARIANT {
[MarshalAs(UnmanagedType.I2)]
@@ -1990,16 +967,16 @@ public bool Byref{
}
public void Clear() {
- if ((this.vt == (int)tagVT.VT_UNKNOWN || this.vt == (int)tagVT.VT_DISPATCH) && this.data1 != IntPtr.Zero) {
- Marshal.Release(this.data1);
+ if ((vt == (int)tagVT.VT_UNKNOWN || vt == (int)tagVT.VT_DISPATCH) && data1 != IntPtr.Zero) {
+ Marshal.Release(data1);
}
- if (this.vt == (int)tagVT.VT_BSTR && this.data1 != IntPtr.Zero) {
- SysFreeString(this.data1);
+ if (vt == (int)tagVT.VT_BSTR && data1 != IntPtr.Zero) {
+ SysFreeString(data1);
}
- this.data1 = this.data2 = IntPtr.Zero;
- this.vt = (int)tagVT.VT_EMPTY;
+ data1 = data2 = IntPtr.Zero;
+ vt = (int)tagVT.VT_EMPTY;
}
~VARIANT() {
@@ -2039,7 +1016,7 @@ public object ToObject() {
IntPtr val = data1;
long longVal;
- int vtType = (int)(this.vt & (short)tagVT.VT_TYPEMASK);
+ int vtType = (int)(vt & (short)tagVT.VT_TYPEMASK);
switch (vtType) {
case (int)tagVT.VT_EMPTY:
@@ -2433,30 +1410,13 @@ internal override void PutString(string s)
}
}
- public static class CommonHandles {
- static CommonHandles() {
- }
-
- ///
- /// Handle type for accelerator tables.
- ///
- public static readonly int Accelerator = HandleCollector.RegisterType("Accelerator", 80, 50);
-
+ public static class CommonHandles
+ {
///
/// handle type for cursors.
///
public static readonly int Cursor = HandleCollector.RegisterType("Cursor", 20, 500);
- ///
- /// Handle type for enhanced metafiles.
- ///
- public static readonly int EMF = HandleCollector.RegisterType("EnhancedMetaFile", 20, 500);
-
- ///
- /// Handle type for file find handles.
- ///
- public static readonly int Find = HandleCollector.RegisterType("Find", 0, 1000);
-
///
/// Handle type for GDI objects.
///
@@ -2477,16 +1437,6 @@ static CommonHandles() {
/// Handle type for kernel objects.
///
public static readonly int Kernel = HandleCollector.RegisterType("Kernel", 0, 1000);
-
- ///
- /// Handle type for files.
- ///
- public static readonly int Menu = HandleCollector.RegisterType("Menu", 30, 1000);
-
- ///
- /// Handle type for windows.
- ///
- public static readonly int Window = HandleCollector.RegisterType("Window", 5, 1000);
}
public const int PBT_APMPOWERSTATUSCHANGE = 0x000A;
@@ -2502,15 +1452,14 @@ public struct SYSTEM_POWER_STATUS {
}
// WinEvent
- public const int EVENT_SYSTEM_MOVESIZESTART = 0x000A;
- public const int EVENT_SYSTEM_MOVESIZEEND = 0x000B;
+ public const int EVENT_SYSTEM_MOVESIZEEND = 0x000B;
public const int EVENT_OBJECT_STATECHANGE = 0x800A;
public const int EVENT_OBJECT_FOCUS = 0x8005;
- public const int OBJID_CLIENT = unchecked(unchecked((int)0xFFFFFFFC));
- public const int WINEVENT_OUTOFCONTEXT = 0x0000;
+ public const int OBJID_CLIENT = unchecked(unchecked((int)0xFFFFFFFC));
+ public const int WINEVENT_OUTOFCONTEXT = 0x0000;
// the delegate passed to USER for receiving a WinEvent
- internal delegate void WinEventProcDef (int winEventHook, int eventId, IntPtr hwnd, int idObject, int idChild, int eventThread, int eventTime);
+ internal delegate void WinEventProcDef(int winEventHook, int eventId, IntPtr hwnd, int idObject, int idChild, int eventThread, int eventTime);
#region WebBrowser Related Definitions
///
@@ -2578,8 +1527,8 @@ public struct RID_DEVICE_INFO
public RID_DEVICE_INFO_HID hid;
}
- public const uint RIDI_DEVICEINFO = 0x2000000b;
- public const uint RIM_TYPEHID = 2;
+ public const uint RIDI_DEVICEINFO = 0x2000000b;
+ public const uint RIM_TYPEHID = 2;
public const ushort HID_USAGE_PAGE_DIGITIZER = 0x0D;
public const ushort HID_USAGE_DIGITIZER_DIGITIZER = 1;
public const ushort HID_USAGE_DIGITIZER_PEN = 2;
@@ -2596,9 +1545,7 @@ public struct BLENDFUNCTION
}
public const int AC_SRC_OVER = 0x00000000;
- public const int ULW_COLORKEY = 0x00000001;
public const int ULW_ALPHA = 0x00000002;
- public const int ULW_OPAQUE = 0x00000004;
///
/// Contains values that indicate the type of session information to retrieve
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsOther.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsOther.cs
index 36439b4a808..2dec5df3806 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsOther.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsOther.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -231,7 +231,7 @@ private BitmapHandle() : this(true)
{
}
- private BitmapHandle(bool ownsHandle) : base(ownsHandle, NativeMethods.CommonHandles.GDI)
+ private BitmapHandle(bool ownsHandle) : base(ownsHandle, CommonHandles.GDI)
{
}
@@ -256,7 +256,7 @@ internal static BitmapHandle CreateFromHandle(IntPtr hbitmap, bool ownsHandle=tr
internal sealed class IconHandle : WpfSafeHandle
{
- private IconHandle() : base(true, NativeMethods.CommonHandles.Icon)
+ private IconHandle() : base(true, CommonHandles.Icon)
{
}
@@ -281,7 +281,7 @@ internal IntPtr CriticalGetHandle()
internal sealed class CursorHandle : WpfSafeHandle
{
- private CursorHandle() : base(true, NativeMethods.CommonHandles.Cursor)
+ private CursorHandle() : base(true, CommonHandles.Cursor)
{
}
@@ -336,35 +336,6 @@ public static int IntPtrToInt32(IntPtr intPtr)
public static IntPtr HWND_MESSAGE = new IntPtr(-3);
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- public class WNDCLASSEX_I
- {
- public int cbSize = 0;
-
- public int style = 0;
-
- public IntPtr lpfnWndProc = IntPtr.Zero;
-
- public int cbClsExtra = 0;
-
- public int cbWndExtra = 0;
-
- public IntPtr hInstance = IntPtr.Zero;
-
- public IntPtr hIcon = IntPtr.Zero;
-
- public IntPtr hCursor = IntPtr.Zero;
-
- public IntPtr hbrBackground = IntPtr.Zero;
-
- public IntPtr lpszMenuName = IntPtr.Zero;
-
- public IntPtr lpszClassName = IntPtr.Zero;
-
- public IntPtr hIconSm = IntPtr.Zero;
- }
-
// NOTE: this replaces the RECT struct in NativeMethodsCLR.cs because it adds an extra method IsEmpty
[StructLayout(LayoutKind.Sequential)]
public struct RECT
@@ -546,57 +517,49 @@ private static int SizeOf()
}
}
- internal sealed class SafeLocalMemHandle : SafeHandleZeroOrMinusOneIsInvalid
- {
- public SafeLocalMemHandle() : base(true)
- {
- }
+ internal sealed class SafeLocalMemHandle : SafeHandleZeroOrMinusOneIsInvalid
+ {
+ public SafeLocalMemHandle() : base(true)
+ {
+ }
- public SafeLocalMemHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle)
- {
- base.SetHandle(existingHandle);
- }
+ public SafeLocalMemHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle)
+ {
+ base.SetHandle(existingHandle);
+ }
- protected override bool ReleaseHandle()
- {
- return (LocalFree(base.handle) == IntPtr.Zero);
- }
+ protected override bool ReleaseHandle()
+ {
+ return (LocalFree(base.handle) == IntPtr.Zero);
+ }
[DllImport("kernel32.dll")]
- private static extern IntPtr LocalFree(IntPtr hMem);
- }
-
-
- internal const uint DELETE = 0x00010000, READ_CONTROL = 0x00020000, WRITE_DAC = 0x00040000, WRITE_OWNER = 0x00080000, SYNCHRONIZE = 0x00100000, STANDARD_RIGHTS_REQUIRED = 0x000F0000, STANDARD_RIGHTS_READ = READ_CONTROL, STANDARD_RIGHTS_WRITE = READ_CONTROL, STANDARD_RIGHTS_EXECUTE = READ_CONTROL, STANDARD_RIGHTS_ALL = 0x001F0000, SPECIFIC_RIGHTS_ALL = 0x0000FFFF, ACCESS_SYSTEM_SECURITY = 0x01000000, MAXIMUM_ALLOWED = 0x02000000, GENERIC_READ = 0x80000000, GENERIC_WRITE = 0x40000000, GENERIC_EXECUTE = 0x20000000, GENERIC_ALL = 0x10000000;
-
- internal const uint FILE_READ_DATA = 0x0001, // file & pipe
- FILE_LIST_DIRECTORY = 0x0001, // directory
- FILE_WRITE_DATA = 0x0002, // file & pipe
- FILE_ADD_FILE = 0x0002, // directory
- FILE_APPEND_DATA = 0x0004, // file
- FILE_ADD_SUBDIRECTORY = 0x0004, // directory
- FILE_CREATE_PIPE_INSTANCE = 0x0004, // named pipe
- FILE_READ_EA = 0x0008, // file & directory
- FILE_WRITE_EA = 0x0010, // file & directory
- FILE_EXECUTE = 0x0020, // file
- FILE_TRAVERSE = 0x0020, // directory
- FILE_DELETE_CHILD = 0x0040, // directory
- FILE_READ_ATTRIBUTES = 0x0080, // all
- FILE_WRITE_ATTRIBUTES = 0x0100; // all
-
- internal const uint FILE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF, FILE_GENERIC_READ = STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE, FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE, FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE;
+ private static extern IntPtr LocalFree(IntPtr hMem);
+ }
- internal const uint FILE_SHARE_READ = 0x00000001, FILE_SHARE_WRITE = 0x00000002, FILE_SHARE_DELETE = 0x00000004;
- internal const int ERROR_ALREADY_EXISTS = 183;
+ internal const uint DELETE = 0x00010000,
+ READ_CONTROL = 0x00020000,
+ WRITE_DAC = 0x00040000,
+ WRITE_OWNER = 0x00080000,
+ SYNCHRONIZE = 0x00100000,
+ STANDARD_RIGHTS_REQUIRED = 0x000F0000,
+ STANDARD_RIGHTS_READ = READ_CONTROL,
+ STANDARD_RIGHTS_WRITE = READ_CONTROL,
+ STANDARD_RIGHTS_EXECUTE = READ_CONTROL,
+ STANDARD_RIGHTS_ALL = 0x001F0000,
+ SPECIFIC_RIGHTS_ALL = 0x0000FFFF,
+ ACCESS_SYSTEM_SECURITY = 0x01000000,
+ MAXIMUM_ALLOWED = 0x02000000,
+ GENERIC_READ = 0x80000000,
+ GENERIC_WRITE = 0x40000000,
+ GENERIC_EXECUTE = 0x20000000,
+ GENERIC_ALL = 0x10000000;
+
+ internal const uint FILE_SHARE_READ = 0x00000001;
internal const int OPEN_EXISTING = 3;
- internal const int PAGE_READONLY = 0x02;
-
- internal const int SECTION_MAP_READ = 0x0004;
-
- internal const int FILE_ATTRIBUTE_NORMAL = 0x00000080;
internal const int FILE_ATTRIBUTE_TEMPORARY = 0x00000100;
internal const int FILE_FLAG_DELETE_ON_CLOSE = 0x04000000;
@@ -938,9 +901,6 @@ public class WNDCLASSEX_D
// from Framework
internal const int ENDSESSION_LOGOFF = (unchecked((int)0x80000000));
- internal const int
- ERROR_SUCCESS = 0;
-
public const int LOCALE_FONTSIGNATURE = 0x00000058;
public const int
@@ -1001,73 +961,14 @@ public const int
SPI_SETBORDER = 0x0006,
SPI_SETNONCLIENTMETRICS = 0x002A;
- public const int LANG_KOREAN = 0x12;
-
-#if NEVER
- public static int PRIMARYLANGID(int lgid)
- {
- return ((ushort)(lgid) & 0x3ff);
- }
-#endif
-
public const int
- MB_YESNO = 0x00000004,
- MB_SYSTEMMODAL = 0x00001000,
- IDYES = 6;
-
- public const int PM_QS_INPUT = unchecked(QS_INPUT << 16);
- public const int PM_QS_PAINT = unchecked(QS_PAINT << 16);
-
-
- public const int
- SW_PARENTCLOSING = 1,
- SW_PARENTOPENING = 3,
- SC_MOUSEMOVE = SC_MOVE + 0x02,
- SPI_SETKEYBOARDSPEED = 0x000B;
-
- internal const int TYMED_HGLOBAL = 1;
- internal const int TYMED_FILE = 2;
- internal const int TYMED_ISTREAM = 4;
- internal const int TYMED_ISTORAGE = 8;
- internal const int TYMED_GDI = 16;
- internal const int TYMED_MFPICT = 32;
- internal const int TYMED_ENHMF = 64;
-
+ SW_PARENTCLOSING = 1,
+ SW_PARENTOPENING = 3,
+ SC_MOUSEMOVE = SC_MOVE + 0x02,
+ SPI_SETKEYBOARDSPEED = 0x000B;
public const int WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
- public const int KEYEVENTF_EXTENDEDKEY = 0x0001;
- public const int KEYEVENTF_KEYUP = 0x0002;
- public const int KEYEVENTF_UNICODE = 0x0004;
- public const int KEYEVENTF_SCANCODE = 0x0008;
-
- public const int MOUSEEVENTF_MOVE = 0x0001;
- public const int MOUSEEVENTF_LEFTDOWN = 0x0002;
- public const int MOUSEEVENTF_LEFTUP = 0x0004;
- public const int MOUSEEVENTF_RIGHTDOWN = 0x0008;
- public const int MOUSEEVENTF_RIGHTUP = 0x0010;
- public const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
- public const int MOUSEEVENTF_MIDDLEUP = 0x0040;
- public const int MOUSEEVENTF_XDOWN = 0x0080;
- public const int MOUSEEVENTF_XUP = 0x0100;
- public const int MOUSEEVENTF_WHEEL = 0x00800;
- public const int MOUSEEVENTF_VIRTUALDESK = 0x04000;
- public const int MOUSEEVENTF_ABSOLUTE = 0x08000;
- public const int MOUSEEVENTF_ACTUAL = 0x10000;
-
- public const int GWL_HINSTANCE = -6;
- public const int GWL_USERDATA = -21;
- public const int GCL_MENUNAME = -8;
- public const int GCL_HBRBACKGROUND = -10;
- public const int GCL_HCURSOR = -12;
- public const int GCL_HICON = -14;
- public const int GCL_HMODULE = -16;
- public const int GCL_CBWNDEXTRA = -18;
- public const int GCL_CBCLSEXTRA = -20;
- public const int GCL_STYLE = -26;
- public const int GCW_ATOM = -32;
- public const int GCL_HICONSM = -34;
-
public const int MONITOR_DEFAULTTONULL = 0x00000000;
public const int MONITOR_DEFAULTTOPRIMARY = 0x00000001;
public const int MONITOR_DEFAULTTONEAREST = 0x00000002;
@@ -1085,27 +986,6 @@ private static int SizeOf()
}
}
-
-
- [StructLayout(LayoutKind.Sequential)]
- public sealed class STATDATA
- {
- [MarshalAs(UnmanagedType.U4)]
- public int advf = 0;
- [MarshalAs(UnmanagedType.U4)]
- public int dwConnection = 0;
- }
-
- public enum WINDOWTHEMEATTRIBUTETYPE
- {
- WTA_NONCLIENT = 1
- };
-
- public const uint WTNCA_NODRAWCAPTION = 0x00000001; // don't draw the window caption
- public const uint WTNCA_NODRAWICON = 0x00000002; // don't draw the system icon
- public const uint WTNCA_NOSYSMENU = 0x00000004; // don't expose the system menu icon functionality
- public const uint WTNCA_VALIDBITS = (WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU);
-
#if WCP_SYSTEM_THEMES_ENABLED
[StructLayout(LayoutKind.Sequential)]
public class WTA_OPTIONS
@@ -1115,10 +995,6 @@ public class WTA_OPTIONS
};
#endif // WCP_SYSTEM_THEMES_ENABLED
-
- internal const int NO_ERROR = 0;
-
-
///////////////////////////
// Used by BASE
@@ -1161,16 +1037,8 @@ public class WTA_OPTIONS
[StructLayout(LayoutKind.Sequential)]
public struct HWND
{
- ///
- ///
- ///
public IntPtr h;
- ///
- ///
- ///
- ///
- ///
public static HWND Cast(IntPtr h)
{
HWND hTemp = new HWND();
@@ -1183,53 +1051,27 @@ public HandleRef MakeHandleRef(object wrapper)
return new HandleRef(wrapper,h);
}
- ///
- ///
- ///
- ///
- ///
public static implicit operator IntPtr(HWND h)
{
return h.h;
}
- ///
- ///
- ///
- ///
- ///
- ///
public static bool operator ==(HWND hl, HWND hr)
{
return (hl.h == hr.h);
}
- ///
- ///
- ///
- ///
- ///
- ///
public static bool operator !=(HWND hl, HWND hr)
{
return (hl.h != hr.h);
}
- ///
- ///
- ///
- ///
- ///
override public bool Equals(object oCompare)
{
HWND hr = Cast((HWND)oCompare);
return (h == hr.h);
}
- ///
- ///
- ///
- ///
public override int GetHashCode()
{
return (int)h;
@@ -1241,40 +1083,7 @@ public override int GetHashCode()
///
public struct HDC
{
- ///
- ///
- ///
public IntPtr h;
-
- ///
- ///
- ///
- ///
- ///
- public static HDC Cast(IntPtr h)
- {
- HDC hTemp = new HDC();
- hTemp.h = h;
- return hTemp;
- }
-
- public HandleRef MakeHandleRef( object wrapper)
- {
- return new HandleRef(wrapper, h);
- }
-
- ///
- ///
- ///
- public static HDC NULL
- {
- get
- {
- HDC hTemp = new HDC();
- hTemp.h = IntPtr.Zero;
- return hTemp;
- }
- }
}
public const int DRAGDROP_S_DROP = 0x00040100;
@@ -1284,110 +1093,6 @@ public static HDC NULL
public const int TME_CANCEL = (unchecked((int)0x80000000));
public const int IDC_HAND = 32649;
- ///
- /// End document printing
- ///
- /// Printer DC
- /// More than 0 if succeeds, zero or less if fails
- [DllImport("gdi32.dll")]
- public static extern Int32 EndDoc(HDC hdc);
-
- public const int DM_ORIENTATION = 0x00000001;
- public const int DM_PAPERSIZE = 0x00000002;
- public const int DM_PAPERLENGTH = 0x00000004;
- public const int DM_PAPERWIDTH = 0x00000008;
- public const int DM_PRINTQUALITY = 0x00000400;
- public const int DM_YRESOLUTION = 0x00002000;
-
- ///
- /// Escape description for ExtEscape
- ///
- [StructLayout(LayoutKind.Sequential)]
- public unsafe struct PrinterEscape
- {
- public Int32 cbInput;
- public UInt32 cbOutput;
- public UInt32 opcode;
- public Int32 cbSize;
-
- public void* buffer;
- }
-
- ///
- /// Send Escape to DC (printer)
- ///
- /// Printer DC
- /// Escape code
- /// # bytes in lpvInData
- /// Input data
- /// size of lpvOutData in bytes
- /// Structure to receive data
- /// 0 if escape not implemented, negative if error, otherwise succeeds
- [DllImport("gdi32.dll")]
- public static unsafe extern Int32 ExtEscape(HDC hdc, Int32 nEscape, Int32 cbInput, PrinterEscape* lpvInData, Int32 cbOutput, [Out] void* lpvOutData);
-
- public const int MM_ISOTROPIC = 7;
-
-
- public const int DM_OUT_BUFFER = 2;
-
-
- ///
- /// Document info for printing
- ///
- [StructLayout(LayoutKind.Sequential)]
- public unsafe struct DocInfo
- {// (*)indicates must be specfied
- internal Int32 cbSize; // (*)size of this structure (20)
- internal String lpszName; // (*)Name of document
- internal String lpszOutput; // Name of output file (null)
- internal String lpszDatatype; // Type of data ("raw" or "emf") can be null
- internal Int32 fwType; // Flags about print job (0)
- }
-
- ///
- /// Start document printing
- ///
- /// Printer DC
- /// Document information
- /// More than zero if succeeded
- [DllImport("gdi32.dll")]
- public unsafe static extern Int32 StartDoc(HDC hdc, ref DocInfo docInfo);
-
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- [DllImport("winspool.drv", BestFitMapping = false, ThrowOnUnmappableChar = true)]
- public unsafe static extern Int32 OpenPrinterA(String printerName, IntPtr* phPrinter, void* pDefaults);
-
- ///
- ///
- ///
- ///
- ///
- [DllImport("winspool.drv")]//CASRemoval:
- public static extern Int32 ClosePrinter(IntPtr hPrinter);
-
- ///
- /// End document page
- ///
- /// Printer DC
- /// More than 0 if succeeds, zero or less if fails
- [DllImport("gdi32.dll")]//CASRemoval:
- public static extern Int32 EndPage(HDC hdc);
-
- ///
- /// Start document page
- ///
- /// Printer DC
- /// More than 0 if succeeds, zero or less if fails
- [DllImport("gdi32.dll")]//CASRemoval:
- public static extern Int32 StartPage(HDC hdc);
-
/// Win32 constants
public const int E_HANDLE = unchecked((int)0x80070006);
@@ -1508,7 +1213,7 @@ internal struct InternetCacheConfigInfo
public const int WTS_REMOTE_DISCONNECT = 0x4;
public const int WTS_SESSION_LOCK = 0x7;
public const int WTS_SESSION_UNLOCK = 0x8;
-
+
public const uint NOTIFY_FOR_THIS_SESSION = 0;
public const int PBT_APMSUSPEND = 0x0004;
@@ -1526,8 +1231,6 @@ public struct POWERBROADCAST_SETTING {
public static readonly Guid GUID_MONITOR_POWER_ON = new Guid(0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA);
-
-
public const uint PROFILE_READ = 1;
//
@@ -1542,7 +1245,7 @@ public enum ProfileType : uint
public enum COLORTYPE : uint
{
- COLOR_GRAY = 1,
+ COLOR_GRAY = 1,
COLOR_RGB,
COLOR_XYZ,
COLOR_Yxy,
@@ -1560,7 +1263,7 @@ public enum COLORTYPE : uint
};
public enum ColorSpace : uint
- {
+ {
SPACE_XYZ = 0x58595A20, // = 'XYZ '
SPACE_Lab = 0x4C616220, // = 'Lab '
SPACE_Luv = 0x4C757620, // = 'Luv '
@@ -1592,10 +1295,5 @@ public enum ColorSpace : uint
SPACE_F_CHANNEL = 0x46434C52, // = 'FCLR'
SPACE_sRGB = 0x73524742 // = 'sRGB'
};
-
- //
- //
- //
}
}
-
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsSetLastError.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsSetLastError.cs
index 378430190b4..901c41e2f3d 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsSetLastError.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsSetLastError.cs
@@ -1,10 +1,10 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
-using System.Text;
using System.Runtime.InteropServices;
+using System.Text;
using MS.Win32;
// Description: P/Invokes for methods that need to call SetLastError(0)
@@ -21,8 +21,6 @@ namespace MS.Internal.UIAutomationClientSideProviders
namespace MS.Internal.WinFormsIntegration
#elif UIAUTOMATIONTYPES
namespace MS.Internal.UIAutomationTypes
-#elif DRT
-namespace MS.Internal.Drt
#else
#error Class is being used from an unknown assembly.
#endif
@@ -33,7 +31,7 @@ internal static class NativeMethodsSetLastError
#if WINDOWSFORMSINTEGRATION // WinFormsIntegration
- [DllImport(PresentationNativeDll, EntryPoint="EnableWindowWrapper", SetLastError = true, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(PresentationNativeDll, EntryPoint="EnableWindowWrapper", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool EnableWindow(IntPtr hWnd, bool enable);
#elif UIAUTOMATIONCLIENT || UIAUTOMATIONCLIENTSIDEPROVIDERS // UIAutomation
@@ -93,7 +91,7 @@ internal static class NativeMethodsSetLastError
#endif
#else // Base/Core/FW + DRT
- [DllImport(PresentationNativeDll, EntryPoint="EnableWindowWrapper", SetLastError = true, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(PresentationNativeDll, EntryPoint="EnableWindowWrapper", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool EnableWindow(HandleRef hWnd, bool enable);
[DllImport(PresentationNativeDll, EntryPoint="GetAncestorWrapper", CharSet = CharSet.Auto)]
@@ -105,9 +103,6 @@ internal static class NativeMethodsSetLastError
[DllImport(PresentationNativeDll, EntryPoint="GetParentWrapper", SetLastError = true)]
public static extern IntPtr GetParent(HandleRef hWnd);
- [DllImport(PresentationNativeDll, EntryPoint="GetWindowWrapper", ExactSpelling = true, SetLastError = true)]
- public static extern IntPtr GetWindow(IntPtr hWnd, int uCmd);
-
[DllImport(PresentationNativeDll, EntryPoint="GetWindowLongWrapper", CharSet=CharSet.Auto, SetLastError=true)]
public static extern Int32 GetWindowLong(HandleRef hWnd, int nIndex );
@@ -129,7 +124,7 @@ internal static class NativeMethodsSetLastError
[DllImport(PresentationNativeDll, EntryPoint = "GetWindowTextWrapper", CharSet=CharSet.Auto, BestFitMapping = false, SetLastError = true)]
public static extern int GetWindowText(HandleRef hWnd, [Out] StringBuilder lpString, int nMaxCount);
- [DllImport(PresentationNativeDll, EntryPoint = "GetWindowTextLengthWrapper", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
+ [DllImport(PresentationNativeDll, EntryPoint = "GetWindowTextLengthWrapper", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int GetWindowTextLength(HandleRef hWnd);
[DllImport(PresentationNativeDll, EntryPoint="MapWindowPointsWrapper", SetLastError = true, ExactSpelling=true, CharSet=CharSet.Auto)]
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsCLR.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsCLR.cs
index 02796299c16..74bc8356fa1 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsCLR.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsCLR.cs
@@ -1,10 +1,11 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using System.Runtime.InteropServices;
using MS.Utility;
+using Windows.Win32.Foundation;
namespace MS.Win32
{
@@ -119,7 +120,7 @@ internal static void GetClientRect(HandleRef hWnd, [In, Out] ref NativeMethods.R
internal static NativeMethods.RECT GetClientRect(HandleRef hWnd)
{
var clientRect = default(NativeMethods.RECT);
- SafeNativeMethods.GetClientRect(hWnd, ref clientRect);
+ GetClientRect(hWnd, ref clientRect);
return clientRect;
}
@@ -368,13 +369,7 @@ public static bool IsCurrentSessionConnectStateWTSActive(int? SessionId = null,
internal static NativeMethods.PROCESS_DPI_AWARENESS GetProcessDpiAwareness(HandleRef hProcess)
{
var ptrProcessDpiAwareness = IntPtr.Zero;
- var hr = (int)SafeNativeMethodsPrivate.GetProcessDpiAwareness(hProcess, out ptrProcessDpiAwareness);
-
- if(hr != NativeMethods.S_OK)
- {
- Marshal.ThrowExceptionForHR(hr);
- }
-
+ SafeNativeMethodsPrivate.GetProcessDpiAwareness(hProcess, out ptrProcessDpiAwareness).ThrowOnFailure();
return (NativeMethods.PROCESS_DPI_AWARENESS)NativeMethods.IntPtrToInt32(ptrProcessDpiAwareness);
}
@@ -591,19 +586,19 @@ private partial class SafeNativeMethodsPrivate
[return:MarshalAs(UnmanagedType.Bool)]
public static extern bool ProcessIdToSessionId([In]int dwProcessId, [Out]out int pSessionId);
- [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern int GetCurrentThreadId();
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern IntPtr GetCapture();
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool IsWindowVisible(HandleRef hWnd);
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern int GetMessagePos();
- [DllImport(ExternDll.User32, EntryPoint = "ReleaseCapture", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
+ [DllImport(ExternDll.User32, EntryPoint = "ReleaseCapture", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool IntReleaseCapture();
[DllImport(ExternDll.User32, EntryPoint = "GetWindowRect", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
@@ -612,7 +607,7 @@ private partial class SafeNativeMethodsPrivate
[DllImport(ExternDll.User32, EntryPoint = "GetClientRect", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool IntGetClientRect(HandleRef hWnd, [In, Out] ref NativeMethods.RECT rect);
- [DllImport(ExternDll.User32, EntryPoint = "AdjustWindowRectEx", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
+ [DllImport(ExternDll.User32, EntryPoint = "AdjustWindowRectEx", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool IntAdjustWindowRectEx(ref NativeMethods.RECT lpRect, int dwStyle, bool bMenu, int dwExStyle);
[DllImport(ExternDll.User32, ExactSpelling=true)]
@@ -627,28 +622,28 @@ private partial class SafeNativeMethodsPrivate
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr GetKeyboardLayout(int dwLayout);
- [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling=true, CharSet= CharSet.Auto)]
public static extern IntPtr SetTimer(HandleRef hWnd, int nIDEvent, int uElapse, NativeMethods.TimerProc lpTimerFunc);
- [DllImport(ExternDll.User32, EntryPoint="SetTimer", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, EntryPoint="SetTimer", CharSet = CharSet.Auto)]
public static extern IntPtr TrySetTimer(HandleRef hWnd, int nIDEvent, int uElapse, NativeMethods.TimerProc lpTimerFunc);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet= CharSet.Auto)]
public static extern bool KillTimer(HandleRef hwnd, int idEvent);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet= CharSet.Auto)]
public static extern bool IsWindowUnicode(HandleRef hWnd);
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetDoubleClickTime();
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool IsWindowEnabled(HandleRef hWnd);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet= CharSet.Auto)]
public static extern IntPtr GetCursor();
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern int ShowCursor(bool show);
[DllImport(ExternDll.User32, EntryPoint = "GetMonitorInfo", CharSet = CharSet.Auto, SetLastError = true)]
@@ -673,13 +668,13 @@ private partial class SafeNativeMethodsPrivate
[DllImport(ExternDll.User32, ExactSpelling=true, SetLastError=true)]
public static extern bool TrackMouseEvent(NativeMethods.TRACKMOUSEEVENT tme);
- [DllImport(ExternDll.User32, CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
+ [DllImport(ExternDll.User32, CharSet= CharSet.Auto, SetLastError = true)]
public static extern NativeMethods.CursorHandle LoadCursor(HandleRef hInst, IntPtr iconId);
#endif
#if BASE_NATIVEMETHODS || CORE_NATIVEMETHODS || FRAMEWORK_NATIVEMETHODS
- [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet= CharSet.Auto)]
public static extern int GetTickCount();
#endif
@@ -737,7 +732,7 @@ public static extern bool WTSQuerySessionInformation(
/// - This function is supported on Windows 8.1 onwards.
///
[DllImport(ExternDll.Shcore, CallingConvention = CallingConvention.Winapi)]
- internal static extern uint GetProcessDpiAwareness([In] HandleRef hProcess, out IntPtr awareness);
+ internal static extern HRESULT GetProcessDpiAwareness([In] HandleRef hProcess, out IntPtr awareness);
///
/// Calculates the required size of the window rectangle, based on the desired size of the
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsOther.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsOther.cs
index bf956da9f38..9829bedaec1 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsOther.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsOther.cs
@@ -1,6 +1,5 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using System.Runtime.InteropServices;
@@ -9,9 +8,6 @@ namespace MS.Win32
{
internal partial class SafeNativeMethods
{
- //////////////////////////////
- // from Framework
-
[Flags]
internal enum PlaySoundFlags
{
@@ -29,28 +25,9 @@ internal enum PlaySoundFlags
SND_RESOURCE = 0x00040000, /* name is resource name or atom */
}
- internal static bool InSendMessage()
- {
- return SafeNativeMethodsPrivate.InSendMessage();
- }
-
-
-#if never
- public static int GetQueueStatus(uint flags)
- {
- return SafeNativeMethodsPrivate.GetQueueStatus(flags);
- }
-
- internal static int GetInputState()
- {
- return SafeNativeMethodsPrivate.GetInputState();
- }
-#endif
-
public static bool IsUxThemeActive() { return SafeNativeMethodsPrivate.IsThemeActive() != 0; }
-
- public static bool SetCaretPos(int x, int y)
+ public static bool SetCaretPos(int x, int y)
{
// To be consistent with our other PInvoke wrappers
// we should "throw" a Win32Exception on error here.
@@ -59,9 +36,8 @@ public static bool SetCaretPos(int x, int y)
return SafeNativeMethodsPrivate.SetCaretPos(x,y);
}
-
- public static bool DestroyCaret()
+ public static bool DestroyCaret()
{
// To be consistent with our other PInvoke wrappers
// we should "throw" a Win32Exception on error here.
@@ -114,10 +90,10 @@ public static bool GetStringTypeEx(uint locale, uint infoType, char[] sourceStri
return win32Return;
}
-
- public static int GetSysColor(int nIndex)
+
+ public static int GetSysColor(int nIndex)
{
- return SafeNativeMethodsPrivate.GetSysColor(nIndex);
+ return SafeNativeMethodsPrivate.GetSysColor(nIndex);
}
public static bool IsClipboardFormatAvailable(int format)
@@ -125,29 +101,15 @@ public static bool IsClipboardFormatAvailable(int format)
return SafeNativeMethodsPrivate.IsClipboardFormatAvailable(format);
}
-#if never
- [DllImport(ExternDll.User32, EntryPoint = "DestroyIcon", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
- private static extern bool IntDestroyIcon(NativeMethods.IconHandle hIcon);
- internal static void DestroyIcon(NativeMethods.IconHandle hIcon)
- {
- if (IntDestroyIcon(hIcon) == false)
- {
- throw new Win32Exception();
- }
- }
-#endif
- /////////////////////////////
// Used by BASE and FRAMEWORK
#if FRAMEWORK_NATIVEMETHODS || BASE_NATIVEMETHODS
-
-
- public static bool IsDebuggerPresent() { return SafeNativeMethodsPrivate.IsDebuggerPresent(); }
+ public static bool IsDebuggerPresent() { return SafeNativeMethodsPrivate.IsDebuggerPresent(); }
#endif
+
#if BASE_NATIVEMETHODS
- /////////////////////
- // used by BASE
+ // Used by BASE
public static void QueryPerformanceCounter(out long lpPerformanceCount)
{
@@ -158,7 +120,7 @@ public static void QueryPerformanceCounter(out long lpPerformanceCount)
}
public static void QueryPerformanceFrequency(out long lpFrequency)
- {
+ {
if (!SafeNativeMethodsPrivate.QueryPerformanceFrequency(out lpFrequency))
{
throw new Win32Exception(Marshal.GetLastWin32Error());
@@ -171,26 +133,17 @@ internal static int GetMessageTime()
}
#endif // BASE_NATIVEMETHODS
-
internal static Int32 GetWindowStyle(HandleRef hWnd, bool exStyle)
{
int nIndex = exStyle ? NativeMethods.GWL_EXSTYLE : NativeMethods.GWL_STYLE;
return UnsafeNativeMethods.GetWindowLong(hWnd, nIndex);
}
+
private static partial class SafeNativeMethodsPrivate
{
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
- internal static extern bool InSendMessage();
-
-// [DllImport(ExternDll.User32, ExactSpelling = true)]
-// public static extern int GetQueueStatus(uint flags);
-
-// [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
-// internal static extern int GetInputState();
-
[DllImport(ExternDll.Uxtheme, CharSet = CharSet.Unicode)]
public static extern int IsThemeActive();
-
+
[DllImport(ExternDll.User32, SetLastError=true, CharSet=CharSet.Auto)]
public static extern bool SetCaretPos(int x, int y);
@@ -205,29 +158,27 @@ private static partial class SafeNativeMethodsPrivate
public static extern bool GetStringTypeEx(uint locale, uint infoType, char[] sourceString, int count,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] UInt16[] charTypes);
- [DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
public static extern int GetSysColor(int nIndex);
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool IsClipboardFormatAvailable(int format);
#if FRAMEWORK_NATIVEMETHODS || BASE_NATIVEMETHODS
-
[DllImport("kernel32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
- internal static extern bool IsDebuggerPresent();
+ internal static extern bool IsDebuggerPresent();
#endif
+
#if BASE_NATIVEMETHODS
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern bool QueryPerformanceCounter(out long lpPerformanceCount);
-
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern bool QueryPerformanceFrequency(out long lpFrequency);
-
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
- internal static extern int GetMessageTime();
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern bool QueryPerformanceCounter(out long lpPerformanceCount);
+
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern bool QueryPerformanceFrequency(out long lpFrequency);
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ internal static extern int GetMessageTime();
#endif
}
+ }
}
-}
-
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs
index de69465b110..19f30eae0d6 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -9,66 +9,52 @@
using System.Text;
using System.Diagnostics;
using System.ComponentModel;
-#if !DRT && !UIAUTOMATIONTYPES
+#if !UIAUTOMATIONTYPES
using MS.Internal.Interop;
using MS.Utility;
#endif
-// DRTs cannot access MS.Internal
-#if !DRT && !UIAUTOMATIONTYPES
-using HR = MS.Internal.Interop.HRESULT;
-#endif
-
-//The SecurityHelper class differs between assemblies and could not actually be
-// shared, so it is duplicated across namespaces to prevent name collision.
#if WINDOWS_BASE
using MS.Internal.WindowsBase;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
-
-#elif PRESENTATION_CORE
- using MS.Internal.PresentationCore;
-#elif PRESENTATIONFRAMEWORK
- using MS.Internal.PresentationFramework;
+using Windows.Win32.Foundation;
#elif UIAUTOMATIONTYPES
- using MS.Internal.UIAutomationTypes;
+using MS.Internal.UIAutomationTypes;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
-
-#elif DRT
- using MS.Internal.Drt;
#else
#error Attempt to use a class (duplicated across multiple namespaces) from an unknown assembly.
#endif
+using HRESULT = Windows.Win32.Foundation.HRESULT;
+
namespace MS.Win32
{
internal partial class UnsafeNativeMethods {
#if BASE_NATIVEMETHODS
[DllImport(ExternDll.Ole32, ExactSpelling = true, CharSet = CharSet.Auto)]
- public static extern int OleGetClipboard(ref IComDataObject data);
+ public static extern HRESULT OleGetClipboard(ref IComDataObject data);
[DllImport(ExternDll.Ole32, ExactSpelling=true, CharSet=CharSet.Auto)]
- public static extern int OleSetClipboard(IComDataObject pDataObj);
+ public static extern HRESULT OleSetClipboard(IComDataObject pDataObj);
[DllImport(ExternDll.Ole32, ExactSpelling=true, CharSet=CharSet.Auto)]
- public static extern int OleFlushClipboard();
+ public static extern HRESULT OleFlushClipboard();
#endif
+
[DllImport(ExternDll.Uxtheme, CharSet = CharSet.Auto, BestFitMapping = false)]
public static extern int GetCurrentThemeName(StringBuilder pszThemeFileName, int dwMaxNameChars, StringBuilder pszColorBuff, int dwMaxColorChars, StringBuilder pszSizeBuff, int cchMaxSizeChars);
- [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
- public static extern IntPtr GetCurrentThread();
-
#if !DRT && !UIAUTOMATIONTYPES
- [DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto, BestFitMapping = false)]
+ [DllImport(ExternDll.User32, CharSet = CharSet.Auto, BestFitMapping = false)]
public static extern WindowMessage RegisterWindowMessage(string msg);
#endif
- [DllImport(ExternDll.User32, EntryPoint = "SetWindowPos", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
+ [DllImport(ExternDll.User32, EntryPoint = "SetWindowPos", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool SetWindowPos(HandleRef hWnd, HandleRef hWndInsertAfter, int x, int y, int cx, int cy, int flags);
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr GetWindow(HandleRef hWnd, int uCmd);
- [DllImport(ExternDll.Shcore, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
+ [DllImport(ExternDll.Shcore, CharSet = CharSet.Auto, SetLastError = true)]
public static extern uint GetDpiForMonitor(HandleRef hMonitor, NativeMethods.MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
[DllImport(ExternDll.User32, EntryPoint = "IsProcessDPIAware", CharSet = CharSet.Auto, SetLastError = true)]
@@ -80,10 +66,10 @@ internal partial class UnsafeNativeMethods {
[DllImport(ExternDll.User32, EntryPoint = "EnableNonClientDpiScaling", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool EnableNonClientDpiScaling(HandleRef hWnd);
- [DllImport(ExternDll.User32, SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, BestFitMapping = false)]
+ [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
public static extern int GetClassName(HandleRef hwnd, StringBuilder lpClassName, int nMaxCount);
- [DllImport(ExternDll.User32, SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, BestFitMapping = false)]
+ [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
public static extern int MessageBox(HandleRef hWnd, string text, string caption, int type);
[DllImport(ExternDll.Uxtheme, CharSet = CharSet.Auto, BestFitMapping = false, EntryPoint = "SetWindowTheme")]
@@ -102,10 +88,10 @@ internal partial class UnsafeNativeMethods {
[DllImport(ExternDll.User32, EntryPoint = "FillRect", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int CriticalFillRect(IntPtr hdc, ref NativeMethods.RECT rcFill, IntPtr brush);
- [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern int GetBitmapBits(HandleRef hbmp, int cbBuffer, byte[] lpvBits);
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool ShowWindow(HandleRef hWnd, int nCmdShow);
public static void DeleteObject(HandleRef hObject)
@@ -118,48 +104,28 @@ public static void DeleteObject(HandleRef hObject)
}
}
- public static bool DeleteObjectNoThrow(HandleRef hObject)
- {
- HandleCollector.Remove((IntPtr)hObject, NativeMethods.CommonHandles.GDI);
-
- bool result = IntDeleteObject(hObject);
- int error = Marshal.GetLastWin32Error();
-
- if(!result)
- {
- Debug.WriteLine("DeleteObject failed. Error = " + error);
- }
-
- return result;
- }
-
-
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling = true, EntryPoint="DeleteObject", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling = true, EntryPoint="DeleteObject", CharSet=CharSet.Auto)]
public static extern bool IntDeleteObject(HandleRef hObject);
-
[DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern IntPtr SelectObject(HandleRef hdc, IntPtr obj);
- [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
- public static extern IntPtr SelectObject(HandleRef hdc, NativeMethods.BitmapHandle obj);
-
[DllImport(ExternDll.Gdi32, EntryPoint="SelectObject", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern IntPtr CriticalSelectObject(HandleRef hdc, IntPtr obj);
- [DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto, BestFitMapping = false, SetLastError = true)]
+ [DllImport(ExternDll.User32, CharSet = CharSet.Auto, BestFitMapping = false, SetLastError = true)]
public static extern int GetClipboardFormatName(int format, StringBuilder lpString, int cchMax);
- [DllImport(ExternDll.User32, SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, BestFitMapping = false)]
+ [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
public static extern int RegisterClipboardFormat(string format);
- [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool BitBlt(HandleRef hDC, int x, int y, int nWidth, int nHeight,
HandleRef hSrcDC, int xSrc, int ySrc, int dwRop);
- [DllImport(ExternDll.User32, EntryPoint="PrintWindow", SetLastError = true, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, EntryPoint="PrintWindow", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool CriticalPrintWindow(HandleRef hWnd, HandleRef hDC, int flags);
- [DllImport(ExternDll.User32, EntryPoint="RedrawWindow", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, EntryPoint="RedrawWindow", ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool CriticalRedrawWindow(HandleRef hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, int flags);
[DllImport(ExternDll.Shell32, CharSet=CharSet.Auto, BestFitMapping = false)]
@@ -213,6 +179,7 @@ internal enum ShellExecuteFlags
public const int MB_COMPOSITE = 0x00000002;
public const int MB_USEGLYPHCHARS = 0x00000004;
public const int MB_ERR_INVALID_CHARS = 0x00000008;
+
[DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=CharSet.Unicode, SetLastError=true)]
public static extern int MultiByteToWideChar(int CodePage, int dwFlags, byte[] lpMultiByteStr, int cchMultiByte, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpWideCharStr, int cchWideChar);
[DllImport(ExternDll.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
@@ -225,23 +192,6 @@ internal enum ShellExecuteFlags
[DllImport(ExternDll.Kernel32, ExactSpelling=true, EntryPoint="RtlMoveMemory")]
public static extern void CopyMemory(IntPtr pdst, byte[] psrc, int cb);
-#if BASE_NATIVEMETHODS
- [DllImport(ExternDll.User32, EntryPoint="GetKeyboardState", CharSet=CharSet.Auto, SetLastError=true)]
- private static extern int IntGetKeyboardState(byte [] keystate);
- public static void GetKeyboardState(byte [] keystate)
- {
- if(IntGetKeyboardState(keystate) == 0)
- {
- throw new Win32Exception();
- }
- }
-#endif
-
-#if DRT_NATIVEMETHODS
- [DllImport(ExternDll.User32, ExactSpelling=true, EntryPoint="keybd_event", CharSet=CharSet.Auto)]
- public static extern void Keybd_event(byte vk, byte scan, int flags, IntPtr extrainfo);
-#endif
-
#if !DRT && !UIAUTOMATIONTYPES
[DllImport(ExternDll.Kernel32, EntryPoint = "GetModuleFileName", CharSet=CharSet.Unicode, SetLastError = true)]
private static extern int IntGetModuleFileName(HandleRef hModule, StringBuilder buffer, int length);
@@ -288,36 +238,20 @@ internal static string GetModuleFileName(HandleRef hModule)
public static extern IntPtr DispatchMessage([In] ref System.Windows.Interop.MSG msg);
#endif
-#if BASE_NATIVEMETHODS
- [DllImport(ExternDll.User32, CharSet=CharSet.Auto, EntryPoint="PostThreadMessage", SetLastError=true)]
- private static extern int IntPostThreadMessage(int id, int msg, IntPtr wparam, IntPtr lparam);
- public static void PostThreadMessage(int id, int msg, IntPtr wparam, IntPtr lparam)
- {
- if(IntPostThreadMessage(id, msg, wparam, lparam) == 0)
- {
- throw new Win32Exception();
- }
- }
-#endif
-
[DllImport("oleacc.dll")]
- internal static extern int ObjectFromLresult(IntPtr lResult, ref Guid iid, IntPtr wParam, [In, Out] ref IAccessible ppvObject);
+ internal static extern HRESULT ObjectFromLresult(IntPtr lResult, ref Guid iid, IntPtr wParam, [In, Out] ref IAccessible ppvObject);
[DllImport("user32.dll")]
internal static extern bool IsWinEventHookInstalled(int winevent);
[DllImport(ExternDll.Ole32, EntryPoint="OleInitialize")]
- private static extern int IntOleInitialize(IntPtr val);
+ private static extern HRESULT IntOleInitialize(IntPtr val);
- public static int OleInitialize()
+ public static HRESULT OleInitialize()
{
return IntOleInitialize(IntPtr.Zero);
}
- [DllImport(ExternDll.Ole32)]
- public static extern int CoRegisterPSClsid(ref Guid riid, ref Guid rclsid);
-
-
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public extern static bool EnumThreadWindows(int dwThreadId, NativeMethods.EnumThreadWindowsCallback lpfn, HandleRef lParam);
@@ -343,7 +277,7 @@ public static bool CloseHandleNoThrow(HandleRef handle)
}
[DllImport(ExternDll.Ole32, ExactSpelling = true, CharSet = CharSet.Auto)]
- public static extern int CreateStreamOnHGlobal(IntPtr hGlobal, bool fDeleteOnRelease, ref System.Runtime.InteropServices.ComTypes.IStream istream);
+ public static extern HRESULT CreateStreamOnHGlobal(IntPtr hGlobal, bool fDeleteOnRelease, ref System.Runtime.InteropServices.ComTypes.IStream istream);
#if BASE_NATIVEMETHODS
[DllImport(ExternDll.Gdi32, SetLastError=true, EntryPoint="CreateCompatibleDC", CharSet=CharSet.Auto)]
@@ -367,16 +301,7 @@ public static IntPtr CreateCompatibleDC(HandleRef hDC)
[DllImport(ExternDll.Kernel32, EntryPoint="UnmapViewOfFile", CharSet=CharSet.Auto, SetLastError=true)]
private static extern bool IntUnmapViewOfFile(HandleRef pvBaseAddress);
- /*
- public static void UnmapViewOfFile(HandleRef pvBaseAddress)
- {
- HandleCollector.Remove((IntPtr)pvBaseAddress, NativeMethods.CommonHandles.Kernel);
- if(IntUnmapViewOfFile(pvBaseAddress) == 0)
- {
- throw new Win32Exception();
- }
- }
- */
+
public static bool UnmapViewOfFileNoThrow(HandleRef pvBaseAddress)
{
HandleCollector.Remove((IntPtr)pvBaseAddress, NativeMethods.CommonHandles.Kernel);
@@ -384,7 +309,7 @@ public static bool UnmapViewOfFileNoThrow(HandleRef pvBaseAddress)
bool result = IntUnmapViewOfFile(pvBaseAddress);
int error = Marshal.GetLastWin32Error();
- if(!result)
+ if (!result)
{
Debug.WriteLine("UnmapViewOfFile failed. Error = " + error);
}
@@ -447,7 +372,7 @@ internal static bool TryGetCursorPos(ref NativeMethods.POINT pt)
// a secure screen saver may be running.
if (returnValue == false)
{
- System.Diagnostics.Debug.WriteLine("GetCursorPos failed!");
+ Debug.WriteLine("GetCursorPos failed!");
pt.x = 0;
pt.y = 0;
@@ -456,25 +381,22 @@ internal static bool TryGetCursorPos(ref NativeMethods.POINT pt)
}
#if BASE_NATIVEMETHODS || CORE_NATIVEMETHODS || FRAMEWORK_NATIVEMETHODS
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetWindowThreadProcessId(HandleRef hWnd, out int lpdwProcessId);
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern short GetKeyState(int keyCode);
- [DllImport(ExternDll.Ole32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto, PreserveSig = false)]
+ [DllImport(ExternDll.Ole32, ExactSpelling = true, CharSet = CharSet.Auto, PreserveSig = false)]
public static extern void DoDragDrop(IComDataObject dataObject, UnsafeNativeMethods.IOleDropSource dropSource, int allowedEffects, int[] finalEffect);
[DllImport(ExternDll.Ole32, ExactSpelling=true, CharSet=CharSet.Auto)]
internal static extern void ReleaseStgMedium(ref STGMEDIUM medium);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool InvalidateRect(HandleRef hWnd, IntPtr rect, bool erase);
-
-
#endif
-
internal static int GetWindowText(HandleRef hWnd, [Out] StringBuilder lpString, int nMaxCount)
{
int returnValue = NativeMethodsSetLastError.GetWindowText(hWnd, lpString, nMaxCount);
@@ -558,10 +480,6 @@ internal static int GetWindowTextLength(HandleRef hWnd)
[DllImport(ExternDll.Imm32, CharSet = CharSet.Auto)]
public static extern int ImmGetCompositionString(HandleRef hIMC, int dwIndex, byte[] lpBuf, int dwBufLen);
- // ImmGetCompositionString for clause information
- [DllImport(ExternDll.Imm32, CharSet = CharSet.Auto)]
- public static extern int ImmGetCompositionString(HandleRef hIMC, int dwIndex, int[] lpBuf, int dwBufLen);
-
// ImmGetCompositionString for query information
[DllImport(ExternDll.Imm32, CharSet = CharSet.Auto)]
public static extern int ImmGetCompositionString(HandleRef hIMC, int dwIndex, IntPtr lpBuf, int dwBufLen);
@@ -635,24 +553,12 @@ internal static IntPtr GetParent(HandleRef hWnd)
[DllImport(ExternDll.User32, SetLastError = true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool IsChild(HandleRef hWndParent, HandleRef hwnd);
-
- //*****************
- //
- // if you're thinking of enabling either of the functions below.
- // you should first take a look at SafeSecurityHelper.TransformGlobalRectToLocal & TransformLocalRectToScreen
- // they likely do what you typically use the function for - and it's safe to use.
- // if you use the function below - you will get exceptions in partial trust.
- // anyquestions - email avsee.
- //
- //******************
-
-
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr SetParent(HandleRef hWnd, HandleRef hWndParent);
-
[DllImport(ExternDll.Kernel32, EntryPoint = "GetModuleHandle", CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true, SetLastError = true)]
private static extern IntPtr IntGetModuleHandle(string modName);
+
internal static IntPtr GetModuleHandle(string modName)
{
IntPtr retVal = IntGetModuleHandle(modName);
@@ -670,9 +576,6 @@ internal static IntPtr GetModuleHandle(string modName)
public static extern IntPtr CallWindowProc(IntPtr wndProc, IntPtr hWnd, int msg,
IntPtr wParam, IntPtr lParam);
- [DllImport(ExternDll.User32, CharSet = CharSet.Unicode, EntryPoint = "DefWindowProcW")]
- public static extern IntPtr DefWindowProc(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam);
-
[DllImport(ExternDll.Kernel32, SetLastError=true, EntryPoint="GetProcAddress", CharSet=CharSet.Ansi, BestFitMapping=false)]
public static extern IntPtr IntGetProcAddress(HandleRef hModule, string lpProcName);
@@ -687,12 +590,12 @@ public static IntPtr GetProcAddress(HandleRef hModule, string lpProcName)
return result;
}
- // GetProcAddress Note : The lpProcName parameter can identify the DLL function by specifying an ordinal value associated
- // with the function in the EXPORTS statement. GetProcAddress verifies that the specified ordinal is in
- // the range 1 through the highest ordinal value exported in the .def file. The function then uses the
- // ordinal as an index to read the function's address from a function table. If the .def file does not number
- // the functions consecutively from 1 to N (where N is the number of exported functions), an error can
- // occur where GetProcAddress returns an invalid, non-NULL address, even though there is no function with the specified ordinal.
+ // GetProcAddress Note : The lpProcName parameter can identify the DLL function by specifying an ordinal value associated
+ // with the function in the EXPORTS statement. GetProcAddress verifies that the specified ordinal is in
+ // the range 1 through the highest ordinal value exported in the .def file. The function then uses the
+ // ordinal as an index to read the function's address from a function table. If the .def file does not number
+ // the functions consecutively from 1 to N (where N is the number of exported functions), an error can
+ // occur where GetProcAddress returns an invalid, non-NULL address, even though there is no function with the specified ordinal.
[DllImport(ExternDll.Kernel32, EntryPoint="GetProcAddress", CharSet=CharSet.Ansi, BestFitMapping=false)]
public static extern IntPtr GetProcAddressNoThrow(HandleRef hModule, string lpProcName);
@@ -1019,21 +922,6 @@ public static int ReleaseDC(HandleRef hWnd, HandleRef hDC) {
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool SetForegroundWindow(HandleRef hWnd);
- // Begin API Additions to support common dialog controls
- [DllImport(ExternDll.Comdlg32, SetLastError = true, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
- internal static extern int CommDlgExtendedError();
-
- [DllImport(ExternDll.Comdlg32, SetLastError = true, CharSet = CharSet.Unicode)]
- internal static extern bool GetOpenFileName([In, Out] NativeMethods.OPENFILENAME_I ofn);
-
- [DllImport(ExternDll.Comdlg32, SetLastError = true, CharSet = CharSet.Unicode)]
- internal static extern bool GetSaveFileName([In, Out] NativeMethods.OPENFILENAME_I ofn);
- // End Common Dialog API Additions
-
- [return:MarshalAs(UnmanagedType.Bool)]
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto, SetLastError=true)]
- public static extern bool SetLayeredWindowAttributes(HandleRef hwnd, int crKey, byte bAlpha, int dwFlags);
-
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
public static extern unsafe bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, NativeMethods.POINT* pptDst, NativeMethods.POINT* pSizeDst, IntPtr hdcSrc, NativeMethods.POINT* pptSrc, int crKey, ref NativeMethods.BLENDFUNCTION pBlend, int dwFlags);
@@ -1056,7 +944,7 @@ public static bool DestroyCursor(IntPtr hCurs) {
return IntDestroyCursor(hCurs);
}
- [DllImport(ExternDll.User32, EntryPoint="DestroyIcon", CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true)]
+ [DllImport(ExternDll.User32, EntryPoint="DestroyIcon", CharSet=CharSet.Auto, SetLastError=true)]
private static extern bool IntDestroyIcon(IntPtr hIcon);
public static bool DestroyIcon(IntPtr hIcon)
@@ -1077,7 +965,7 @@ public static bool DestroyIcon(IntPtr hIcon)
return result;
}
- [DllImport(ExternDll.Gdi32, EntryPoint="DeleteObject", CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true)]
+ [DllImport(ExternDll.Gdi32, EntryPoint="DeleteObject", CharSet=CharSet.Auto, SetLastError=true)]
private static extern bool IntDeleteObject(IntPtr hObject);
public static bool DeleteObject(IntPtr hObject)
@@ -1136,23 +1024,6 @@ internal static NativeMethods.BitmapHandle CreateBitmap(int width, int height, i
return hBitmap;
}
- [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto, EntryPoint = "DestroyIcon")]
- private static extern bool PrivateDestroyIcon(HandleRef handle);
- internal static bool DestroyIcon(HandleRef handle)
- {
- HandleCollector.Remove((IntPtr)handle, NativeMethods.CommonHandles.Icon);
-
- bool result = PrivateDestroyIcon(handle);
- int error = Marshal.GetLastWin32Error();
-
- if ( !result )
- {
- Debug.WriteLine("DestroyIcon failed. Error = " + error);
- }
-
- return result;
- }
-
[DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto, EntryPoint = "CreateIconIndirect")]
private static extern NativeMethods.IconHandle PrivateCreateIconIndirect([In, MarshalAs(UnmanagedType.LPStruct)]NativeMethods.ICONINFO iconInfo);
internal static NativeMethods.IconHandle CreateIconIndirect([In, MarshalAs(UnmanagedType.LPStruct)]NativeMethods.ICONINFO iconInfo)
@@ -1264,50 +1135,17 @@ public static void DestroyWindow(HandleRef hWnd)
throw new Win32Exception();
}
}
+
[DllImport(ExternDll.User32)]
internal static extern IntPtr SetWinEventHook(int eventMin, int eventMax, IntPtr hmodWinEventProc, NativeMethods.WinEventProcDef WinEventReentrancyFilter, uint idProcess, uint idThread, int dwFlags);
[DllImport(ExternDll.User32)]
internal static extern bool UnhookWinEvent(IntPtr winEventHook);
- public delegate bool EnumChildrenCallback(IntPtr hwnd, IntPtr lParam);
-
- public static void EnumChildWindows(HandleRef hwndParent, EnumChildrenCallback lpEnumFunc, HandleRef lParam)
- {
- // http://msdn.microsoft.com/en-us/library/ms633494(VS.85).aspx
- // Return value is not used
- IntEnumChildWindows(hwndParent, lpEnumFunc, lParam);
- }
-
- [DllImport(ExternDll.User32, EntryPoint = "EnumChildWindows", ExactSpelling = true)]
- private static extern bool IntEnumChildWindows(HandleRef hwndParent, EnumChildrenCallback lpEnumFunc, HandleRef lParam);
-
- [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern int GetWindowRgn(HandleRef hWnd, HandleRef hRgn);
-
- [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern bool PtInRegion(HandleRef hRgn, int X, int Y);
-
- [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
- public static extern IntPtr CreateRectRgn(int x1, int y1, int x2, int y2);
-
- // for GetUserNameEx
- public enum EXTENDED_NAME_FORMAT {
- NameUnknown = 0,
- NameFullyQualifiedDN = 1,
- NameSamCompatible = 2,
- NameDisplay = 3,
- NameUniqueId = 6,
- NameCanonical = 7,
- NameUserPrincipal = 8,
- NameCanonicalEx = 9,
- NameServicePrincipal = 10
- }
-
[ComImport(), Guid("00000122-0000-0000-C000-000000000046"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleDropTarget {
[PreserveSig]
- int OleDragEnter(
+ HRESULT OleDragEnter(
[In, MarshalAs(UnmanagedType.Interface)]
object pDataObj,
[In, MarshalAs(UnmanagedType.U4)]
@@ -1318,7 +1156,7 @@ int OleDragEnter(
ref int pdwEffect);
[PreserveSig]
- int OleDragOver(
+ HRESULT OleDragOver(
[In, MarshalAs(UnmanagedType.U4)]
int grfKeyState,
[In, MarshalAs(UnmanagedType.U8)]
@@ -1327,10 +1165,10 @@ int OleDragOver(
ref int pdwEffect);
[PreserveSig]
- int OleDragLeave();
+ HRESULT OleDragLeave();
[PreserveSig]
- int OleDrop(
+ HRESULT OleDrop(
[In, MarshalAs(UnmanagedType.Interface)]
object pDataObj,
[In, MarshalAs(UnmanagedType.U4)]
@@ -1344,13 +1182,13 @@ int OleDrop(
[ComImport(), Guid("00000121-0000-0000-C000-000000000046"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleDropSource {
[PreserveSig]
- int OleQueryContinueDrag(
+ HRESULT OleQueryContinueDrag(
int fEscapePressed,
[In, MarshalAs(UnmanagedType.U4)]
int grfKeyState);
[PreserveSig]
- int OleGiveFeedback(
+ HRESULT OleGiveFeedback(
[In, MarshalAs(UnmanagedType.U4)]
int dwEffect);
}
@@ -1724,33 +1562,25 @@ void ContextSensitiveHelp(
}
[ComImport(),
- Guid("00000113-0000-0000-C000-000000000046"),
- InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- public interface IOleInPlaceObject {
- [PreserveSig]
- int GetWindow( [Out]out IntPtr hwnd );
-
-
- void ContextSensitiveHelp(
-
- int fEnterMode);
-
-
- void InPlaceDeactivate();
-
+ Guid("00000113-0000-0000-C000-000000000046"),
+ InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IOleInPlaceObject
+ {
+ [PreserveSig]
+ HRESULT GetWindow(out IntPtr hwnd);
- [PreserveSig]
- int UIDeactivate();
+ void ContextSensitiveHelp(int fEnterMode);
+ void InPlaceDeactivate();
+ [PreserveSig]
+ HRESULT UIDeactivate();
- void SetObjectRects(
- [In]
- NativeMethods.COMRECT lprcPosRect,
- [In]
- NativeMethods.COMRECT lprcClipRect);
+ void SetObjectRects(
+ [In] NativeMethods.COMRECT lprcPosRect,
+ [In] NativeMethods.COMRECT lprcClipRect);
- void ReactivateAndUndo();
-}
+ void ReactivateAndUndo();
+ }
[ComImport(),
Guid("00000112-0000-0000-C000-000000000046"),
@@ -1870,11 +1700,8 @@ int Unadvise(
[PreserveSig]
int EnumAdvise(out IEnumSTATDATA e);
- [PreserveSig]
- int GetMiscStatus(
- [In, MarshalAs(UnmanagedType.U4)]
- int dwAspect,
- out int misc);
+ [PreserveSig]
+ HRESULT GetMiscStatus(int dwAspect, out int misc);
[PreserveSig]
int SetColorScheme(
@@ -2020,32 +1847,7 @@ int OnWindowMessage(
[PreserveSig]
int GetDropTarget(
[Out, MarshalAs(UnmanagedType.Interface)] object ppDropTarget);
-};
-
- [ComImport(),
- Guid("B196B288-BAB4-101A-B69C-00AA00341D07"),
- InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- public interface IOleControl {
- [PreserveSig]
- int GetControlInfo(
- [Out]
- NativeMethods.tagCONTROLINFO pCI);
-
- [PreserveSig]
- int OnMnemonic(
- [In]
- ref System.Windows.Interop.MSG pMsg);
-
- [PreserveSig]
- int OnAmbientPropertyChange(
-
- int dispID);
-
- [PreserveSig]
- int FreezeEvents(
-
- int bFreeze);
-}
+ };
[ComImport(),
Guid("B196B286-BAB4-101A-B69C-00AA00341D07"),
@@ -2238,7 +2040,7 @@ ITypeInfo GetTypeInfo(
int lcid);
[PreserveSig]
- HR GetIDsOfNames(
+ HRESULT GetIDsOfNames(
[In]
ref Guid riid,
[In, MarshalAs(UnmanagedType.LPArray)]
@@ -2252,7 +2054,7 @@ HR GetIDsOfNames(
[PreserveSig]
- HR Invoke(
+ HRESULT Invoke(
int dispIdMember,
[In]
@@ -2287,7 +2089,7 @@ public interface IDispatchEx : IDispatch {
int lcid);
[PreserveSig]
- new HR GetIDsOfNames(
+ new HRESULT GetIDsOfNames(
[In]
ref Guid riid,
[In, MarshalAs(UnmanagedType.LPArray)]
@@ -2301,7 +2103,7 @@ public interface IDispatchEx : IDispatch {
[PreserveSig]
- new HR Invoke(
+ new HRESULT Invoke(
int dispIdMember,
[In]
ref Guid riid,
@@ -2321,13 +2123,13 @@ public interface IDispatchEx : IDispatch {
#endregion
[PreserveSig]
- HR GetDispID(
+ HRESULT GetDispID(
string name,
int nameProperties,
[Out] out int dispId);
[PreserveSig]
- HR InvokeEx(
+ HRESULT InvokeEx(
int dispId,
[MarshalAs(UnmanagedType.U4)] int lcid,
[MarshalAs(UnmanagedType.U4)] int flags,
@@ -2908,29 +2710,26 @@ public unsafe static IntPtr ArrayToVARIANTVector(object[] args)
/// The length of the Variant vector to be cleared.
public unsafe static void FreeVARIANTVector(IntPtr mem, int len)
{
- int hr = NativeMethods.S_OK;
+ HRESULT result = HRESULT.S_OK;
byte* a = (byte*)(void*)mem;
for (int i = 0; i < len; ++i)
{
- int hrcurrent = NativeMethods.S_OK;
+ HRESULT currentResult = HRESULT.S_OK;
checked
{
- hrcurrent = UnsafeNativeMethods.VariantClear((IntPtr)(a + VariantSize * i));
+ currentResult = VariantClear((IntPtr)(a + VariantSize * i));
}
// save the first error and throw after we finish all VariantClear.
- if (NativeMethods.Succeeded(hr) && NativeMethods.Failed(hrcurrent))
+ if (result.Succeeded && currentResult.Failed)
{
- hr = hrcurrent;
+ result = currentResult;
}
}
- Marshal.FreeCoTaskMem(mem);
- if (NativeMethods.Failed(hr))
- {
- Marshal.ThrowExceptionForHR(hr);
- }
+ Marshal.FreeCoTaskMem(mem);
+ result.ThrowOnFailure();
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -2944,8 +2743,8 @@ private struct FindSizeOfVariant
private static readonly int VariantSize;
}
- [DllImport(ExternDll.Oleaut32, PreserveSig=true)]
- private static extern int VariantClear(IntPtr pObject);
+ [DllImport(ExternDll.Oleaut32, PreserveSig = true)]
+ private static extern HRESULT VariantClear(IntPtr pObject);
[ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IPersistStreamInit
@@ -2974,44 +2773,7 @@ void GetSizeMax(
void InitNew();
}
- [Flags]
- internal enum BrowserNavConstants : uint
- {
- OpenInNewWindow = 0x00000001,
- NoHistory = 0x00000002,
- NoReadFromCache = 0x00000004,
- NoWriteToCache = 0x00000008,
- AllowAutosearch = 0x00000010,
- BrowserBar = 0x00000020,
- Hyperlink = 0x00000040,
- EnforceRestricted = 0x00000080,
- NewWindowsManaged = 0x00000100,
- UntrustedForDownload = 0x00000200,
- TrustedForActiveX = 0x00000400,
- OpenInNewTab = 0x00000800,
- OpenInBackgroundTab = 0x00001000,
- KeepWordWheelText = 0x00002000
- }
-#if never
- //
- // Used to control the webbrowser security
- [ComVisible(true), ComImport(), Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b"),
- InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown), CLSCompliant(false)]
- public interface IInternetSecurityManager {
- [PreserveSig] int SetSecuritySite();
- [PreserveSig] int GetSecuritySite();
- [PreserveSig] int MapUrlToZone();
- [PreserveSig] int GetSecurityId();
- [PreserveSig] int ProcessUrlAction(string url, int action,
- [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] byte[] policy,
- int cbPolicy, ref byte context, int cbContext,
- int flags, int reserved);
- [PreserveSig] int QueryCustomPolicy();
- [PreserveSig] int SetZoneMapping();
- [PreserveSig] int GetZoneMappings();
- }
-#endif
- #endregion WebBrowser Related Definitions
+ #endregion WebBrowser Related Definitions
[DllImport(ExternDll.User32, SetLastError=true, CharSet=CharSet.Auto)]
public static extern uint GetRawInputDeviceList(
@@ -3026,19 +2788,6 @@ public static extern uint GetRawInputDeviceInfo(
[In] ref NativeMethods.RID_DEVICE_INFO ridInfo,
ref uint sizeInBytes);
- ///
- /// Retrieves a handle to the menu assigned to the specified window.
- ///
- /// A handle to the window whose menu handle is to be retrieved.
- /// The return value is a handle to the menu. If the specified window has no menu, the return value is NULL.
- /// If the window is a child window, the return value is undefined.
- ///
- /// GetMenu does not work on floating menu bars. Floating menu bars are custom controls that mimic
- /// standard menus; they are not menus. To get the handle on a floating menu bar, use the Active Accessibility APIs.
- ///
- [DllImport(ExternDll.User32, CallingConvention = CallingConvention.Winapi)]
- internal extern static IntPtr GetMenu([In] HandleRef hWnd);
-
#if !DRT && !UIAUTOMATIONTYPES
///
@@ -3060,20 +2809,6 @@ public static extern uint GetRawInputDeviceInfo(
[DllImport(ExternDll.User32, CallingConvention = CallingConvention.Winapi)]
internal static extern DpiAwarenessContextHandle SetThreadDpiAwarenessContext(DpiAwarenessContextHandle dpiContext);
- ///
- /// Gets the DPI_AWARENESS_CONTEXT for the current thread.
- ///
- /// The current DPI_AWARENESS_CONTEXT for the thread.
- ///
- /// This method will return the latest DPI_AWARENESS_CONTEXT sent to SetThreadDpiAwarenessContext.
- /// If SetThreadDpiAwarenessContext was never called for this thread, then the return value will equal
- /// the default DPI_AWARENESS_CONTEXT for the process.
- ///
- /// Minimum supported client: Windows 10, version 1607 (RS1)
- ///
- [DllImport(ExternDll.User32, CallingConvention = CallingConvention.Winapi)]
- internal static extern DpiAwarenessContextHandle GetThreadDpiAwarenessContext();
-
#endif
///
@@ -3149,6 +2884,6 @@ internal static extern bool EnumDisplayMonitors(
/// On success, returns true if the Device Guard policy enforces .NET Dynamic Code policy; otherwise, returns false.
/// This method returns S_OK if successful or a failure code otherwise.
[DllImport(ExternDll.Wldp, CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
- internal static extern int WldpIsDynamicCodePolicyEnabled([Out] out bool enabled);
+ internal static extern HRESULT WldpIsDynamicCodePolicyEnabled([Out] out bool enabled);
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsEventTrace.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsEventTrace.cs
index 8499fd7c85b..f202dbbb162 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsEventTrace.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsEventTrace.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -97,7 +97,6 @@ internal static unsafe class ClassicEtw
internal struct TRACE_GUID_REGISTRATION
{
internal unsafe Guid* Guid;
-
internal unsafe void* RegHandle;
}
@@ -143,9 +142,6 @@ internal enum WMIDPREQUESTCODE
[DllImport("Advapi32.dll")]
internal static extern byte GetTraceEnableLevel(ulong traceHandle);
- [DllImport("Advapi32.dll")]
- internal static extern long GetTraceLoggerHandle(WNODE_HEADER* data);
-
#region TraceEvent()
// Structures for TraceEvent API.
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsOther.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsOther.cs
index 103d6736ea3..255b910961e 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsOther.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsOther.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -8,7 +8,8 @@
using Microsoft.Win32.SafeHandles;
using MS.Internal;
using MS.Internal.Interop;
-
+using Windows.Win32.Foundation;
+using HRESULT = Windows.Win32.Foundation.HRESULT;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
namespace MS.Win32
@@ -29,7 +30,7 @@ internal static uint GetTempFileName(string tmpPath, string prefix, uint uniqueI
return result;
}
- [DllImport(ExternDll.Shell32, CharSet = System.Runtime.InteropServices.CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
+ [DllImport(ExternDll.Shell32, CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
internal static extern int ExtractIconEx(
string szExeFileName,
int nIconIndex,
@@ -37,9 +38,6 @@ internal static extern int ExtractIconEx(
out NativeMethods.IconHandle phiconSmall,
int nIcons);
- [DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError=true)]
- internal static extern NativeMethods.IconHandle CreateIcon(IntPtr hInstance, int nWidth, int nHeight, byte cPlanes, byte cBitsPixel, byte[] lpbANDbits, byte[] lpbXORbits);
-
[DllImport(ExternDll.User32, SetLastError = true)]
public static extern bool CreateCaret(HandleRef hwnd, NativeMethods.BitmapHandle hbitmap, int width, int height);
@@ -49,56 +47,33 @@ internal static extern int ExtractIconEx(
[DllImport(ExternDll.User32, SetLastError = true)]
public static extern bool HideCaret(HandleRef hwnd);
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool ShowWindowAsync(HandleRef hWnd, int nCmdShow);
- [DllImport(ExternDll.User32, EntryPoint="LoadImage", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
- internal static extern NativeMethods.IconHandle LoadImageIcon(IntPtr hinst, string stName, int nType, int cxDesired, int cyDesired, int nFlags);
-
- [DllImport(ExternDll.User32, EntryPoint="LoadImage", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
+ [DllImport(ExternDll.User32, EntryPoint="LoadImage", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
internal static extern NativeMethods.CursorHandle LoadImageCursor(IntPtr hinst, string stName, int nType, int cxDesired, int cyDesired, int nFlags);
- // uncomment this if you plan to use LoadImage to load anything other than Icons/Cursors.
- /*
- [DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
- internal static extern SafeHandle LoadImage(
- IntPtr hinst, string stName, int nType, int cxDesired, int cyDesired, int nFlags);
- */
- /*
- [DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
- internal static extern NativeMethods.IconHandle LoadImage(
- IntPtr hinst, string stName, int nType, int cxDesired, int cyDesired, int nFlags);
- */
-
- [DllImport( ExternDll.Urlmon, ExactSpelling=true)]
- internal static extern int CoInternetIsFeatureEnabled( int featureEntry , int dwFlags );
-
- [DllImport( ExternDll.Urlmon, ExactSpelling=true)]
- internal static extern int CoInternetSetFeatureEnabled( int featureEntry , int dwFlags, bool fEnable );
-
- [DllImport( ExternDll.Urlmon, ExactSpelling=true)]
- internal static extern int CoInternetIsFeatureZoneElevationEnabled(
- [MarshalAs(UnmanagedType.LPWStr)] string szFromURL,
- [MarshalAs(UnmanagedType.LPWStr)] string szToURL,
- UnsafeNativeMethods.IInternetSecurityManager secMgr,
- int dwFlags
- );
-
- [DllImport(ExternDll.PresentationHostDll, EntryPoint = "ProcessUnhandledException")]
- internal static extern void ProcessUnhandledException_DLL([MarshalAs(UnmanagedType.BStr)] string errMsg);
+ [DllImport(ExternDll.Urlmon, ExactSpelling = true)]
+ internal static extern HRESULT CoInternetIsFeatureEnabled(int featureEntry, int dwFlags);
- [DllImport(ExternDll.Kernel32, CharSet=CharSet.Unicode)]
- internal static extern bool GetVersionEx([In, Out] NativeMethods.OSVERSIONINFOEX ver);
- [DllImport( ExternDll.Urlmon, ExactSpelling=true)]
- internal static extern int CoInternetCreateSecurityManager(
- [MarshalAs(UnmanagedType.Interface)] object pIServiceProvider,
- [MarshalAs(UnmanagedType.Interface)] out object ppISecurityManager ,
- int dwReserved ) ;
+ [DllImport(ExternDll.Urlmon, ExactSpelling = true)]
+ internal static extern HRESULT CoInternetSetFeatureEnabled(int featureEntry, int dwFlags, bool fEnable);
+ [DllImport(ExternDll.Urlmon, ExactSpelling = true)]
+ internal static extern HRESULT CoInternetIsFeatureZoneElevationEnabled(
+ [MarshalAs(UnmanagedType.LPWStr)] string szFromURL,
+ [MarshalAs(UnmanagedType.LPWStr)] string szToURL,
+ UnsafeNativeMethods.IInternetSecurityManager secMgr,
+ int dwFlags);
+ [DllImport(ExternDll.Urlmon, ExactSpelling = true)]
+ internal static extern HRESULT CoInternetCreateSecurityManager(
+ [MarshalAs(UnmanagedType.Interface)] object pIServiceProvider,
+ [MarshalAs(UnmanagedType.Interface)] out object ppISecurityManager,
+ int dwReserved);
- [ComImport, ComVisible(false), Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b"), System.Runtime.InteropServices.InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [ComImport, ComVisible(false), Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IInternetSecurityManager
{
void SetSecuritySite( NativeMethods.IInternetSecurityMgrSite pSite);
@@ -140,28 +115,17 @@ unsafe void QueryCustomPolicy(
unsafe void GetZoneMappings( /* [in] */ int dwZone, /* [out] */ /*IEnumString*/ void **ppenumString, /* [in] */ int dwFlags);
}
- ///
- ///
- ///
- ///
- ///
- [DllImport(ExternDll.Kernel32, SetLastError = true)]
- internal static extern IntPtr LocalFree(IntPtr hMem);
-
#if BASE_NATIVEMETHODS
[DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
- internal unsafe static extern SafeFileHandle CreateFile(
- string lpFileName,
- uint dwDesiredAccess,
- uint dwShareMode,
- [In] NativeMethods.SECURITY_ATTRIBUTES lpSecurityAttributes,
- int dwCreationDisposition,
- int dwFlagsAndAttributes,
- IntPtr hTemplateFile);
-#endif
-
+ internal static extern unsafe SafeFileHandle CreateFile(
+ string lpFileName,
+ uint dwDesiredAccess,
+ uint dwShareMode,
+ [In] NativeMethods.SECURITY_ATTRIBUTES lpSecurityAttributes,
+ int dwCreationDisposition,
+ int dwFlagsAndAttributes,
+ IntPtr hTemplateFile);
-#if BASE_NATIVEMETHODS
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
internal static extern IntPtr GetMessageExtraInfo();
@@ -178,7 +142,7 @@ internal unsafe static extern SafeFileHandle CreateFile(
internal static int WaitForMultipleObjectsEx(int nCount, IntPtr[] pHandles, bool bWaitAll, int dwMilliseconds, bool bAlertable)
{
int result = IntWaitForMultipleObjectsEx(nCount, pHandles, bWaitAll, dwMilliseconds, bAlertable);
- if(result == UnsafeNativeMethods.WAIT_FAILED)
+ if(result == WAIT_FAILED)
{
throw new Win32Exception();
}
@@ -239,7 +203,7 @@ internal static void UnregisterClass(IntPtr atomString /*lpClassName*/ , IntPtr
// Note that processes at or below SECURITY_MANDATORY_LOW_RID are not allowed to change the message filter.
// If those processes call this function, it will fail and generate the extended error code, ERROR_ACCESS_DENIED.
- internal static MS.Internal.Interop.HRESULT ChangeWindowMessageFilterEx(IntPtr hwnd, WindowMessage message, MSGFLT action, out MSGFLTINFO extStatus)
+ internal static HRESULT ChangeWindowMessageFilterEx(IntPtr hwnd, WindowMessage message, MSGFLT action, out MSGFLTINFO extStatus)
{
extStatus = MSGFLTINFO.NONE;
@@ -247,7 +211,7 @@ internal static MS.Internal.Interop.HRESULT ChangeWindowMessageFilterEx(IntPtr h
// If we're not on either, then this message filter isolation doesn't exist.
if (!Utilities.IsOSVistaOrNewer)
{
- return MS.Internal.Interop.HRESULT.S_FALSE;
+ return HRESULT.S_FALSE;
}
// If we're on Vista rather than Win7 then we can't use the Ex version of this function.
@@ -258,42 +222,43 @@ internal static MS.Internal.Interop.HRESULT ChangeWindowMessageFilterEx(IntPtr h
// Note that the Win7 MSGFLT_ALLOW/DISALLOW enum values map to the Vista MSGFLT_ADD/REMOVE
if (!IntChangeWindowMessageFilter(message, action))
{
- return (MS.Internal.Interop.HRESULT)Win32Error.GetLastError();
+ return (HRESULT)Marshal.GetHRForLastWin32Error();
}
- return MS.Internal.Interop.HRESULT.S_OK;
+
+ return HRESULT.S_OK;
}
var filterstruct = new CHANGEFILTERSTRUCT { cbSize = (uint)Marshal.SizeOf(typeof(CHANGEFILTERSTRUCT)) };
if (!IntChangeWindowMessageFilterEx(hwnd, message, action, ref filterstruct))
{
- return (MS.Internal.Interop.HRESULT)Win32Error.GetLastError();
+ return (HRESULT)Marshal.GetHRForLastWin32Error();
}
extStatus = filterstruct.ExtStatus;
- return MS.Internal.Interop.HRESULT.S_OK;
+ return HRESULT.S_OK;
}
- [DllImport(ExternDll.Urlmon, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
- private static extern MS.Internal.Interop.HRESULT ObtainUserAgentString(int dwOption, StringBuilder userAgent, ref int length);
+ [DllImport(ExternDll.Urlmon, ExactSpelling = true, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
+ private static extern HRESULT ObtainUserAgentString(int dwOption, StringBuilder userAgent, ref int length);
internal static string ObtainUserAgentString()
{
- int length = MS.Win32.NativeMethods.MAX_PATH;
+ int length = NativeMethods.MAX_PATH;
StringBuilder userAgentBuffer = new StringBuilder(length);
- MS.Internal.Interop.HRESULT hr = ObtainUserAgentString(0 /*reserved. must be 0*/, userAgentBuffer, ref length);
+ HRESULT result = ObtainUserAgentString(0 /*reserved. must be 0*/, userAgentBuffer, ref length);
// Installing .NET 4.0 adds two parts to the user agent string, i.e.
// .NET4.0C and .NET4.0E, potentially causing the user agent string to overflow its
// documented maximum length of MAX_PATH. Turns out ObtainUserAgentString can return
// a longer string if asked to do so. Therefore we grow the string dynamically when
// needed, accommodating for this failure condition.
- if (hr == MS.Internal.Interop.HRESULT.E_OUTOFMEMORY)
+ if (result == HRESULT.E_OUTOFMEMORY)
{
userAgentBuffer = new StringBuilder(length);
- hr = ObtainUserAgentString(0 /*reserved. must be 0*/, userAgentBuffer, ref length);
+ result = ObtainUserAgentString(0 /*reserved. must be 0*/, userAgentBuffer, ref length);
}
- hr.ThrowIfFailed();
+ result.ThrowOnFailureUnwrapWin32();
return userAgentBuffer.ToString();
}
@@ -315,22 +280,11 @@ internal static string ObtainUserAgentString()
[DllImport(ExternDll.User32,EntryPoint="UnregisterPowerSettingNotification")]
unsafe internal static extern IntPtr UnregisterPowerSettingNotification(IntPtr hPowerNotify);
-/*
- //
- // SendMessage taking a SafeHandle for wParam. Needed by some Win32 messages. e.g. WM_PRINT
- //
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
- internal static extern IntPtr SendMessage(HandleRef hWnd, WindowMessage msg, SafeHandle wParam, IntPtr lParam);
-*/
-
// private DllImport - that takes an IconHandle.
[DllImport(ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
internal static extern IntPtr SendMessage( HandleRef hWnd, WindowMessage msg, IntPtr wParam, NativeMethods.IconHandle iconHandle );
#endif
- [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = CharSet.Auto)]
- internal static extern void SetLastError(int dwErrorCode);
-
#if BASE_NATIVEMETHODS || CORE_NATIVEMETHODS || FRAMEWORK_NATIVEMETHODS
///
/// Win32 GetLayeredWindowAttributes.
@@ -343,6 +297,7 @@ internal static string ObtainUserAgentString()
[DllImport("user32.dll")]
public static extern bool GetLayeredWindowAttributes(
HandleRef hwnd, IntPtr pcrKey, IntPtr pbAlpha, IntPtr pdwFlags);
+
internal sealed class SafeFileMappingHandle : SafeHandleZeroOrMinusOneIsInvalid
{
internal SafeFileMappingHandle(IntPtr handle) : base(false)
@@ -367,6 +322,7 @@ protected override bool ReleaseHandle()
return CloseHandleNoThrow(new HandleRef(null, handle));
}
}
+
internal sealed class SafeViewOfFileHandle : SafeHandleZeroOrMinusOneIsInvalid
{
internal SafeViewOfFileHandle() : base(true) { }
@@ -382,7 +338,7 @@ internal unsafe void* Memory
override protected bool ReleaseHandle()
{
- return UnsafeNativeMethods.UnmapViewOfFileNoThrow(new HandleRef(null, handle));
+ return UnmapViewOfFileNoThrow(new HandleRef(null, handle));
}
}
@@ -589,19 +545,6 @@ internal static extern bool InternetGetCookieEx([In]string Url, [In]string cooki
[DllImport(ExternDll.Kernel32, ExactSpelling = true, SetLastError = true)]
internal static extern int FindNLSString(int locale, uint flags, [MarshalAs(UnmanagedType.LPWStr)]string sourceString, int sourceCount, [MarshalAs(UnmanagedType.LPWStr)]string findString, int findCount, out int found);
-
- //[DllImport(ExternDll.Psapi, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- //public static extern int GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder buffer, int length);
-
- //
- // OpenProcess
- //
- public const int PROCESS_VM_READ = 0x0010;
- public const int PROCESS_QUERY_INFORMATION = 0x0400;
-
- //[DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- //public static extern IntPtr OpenProcess(int dwDesiredAccess, bool fInherit, int dwProcessId);
-
[DllImport(ExternDll.User32, EntryPoint = "SetWindowText", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false)]
private static extern bool IntSetWindowText(HandleRef hWnd, string text);
@@ -612,8 +555,8 @@ internal static void SetWindowText(HandleRef hWnd, string text)
throw new Win32Exception();
}
}
- [DllImport(ExternDll.User32, EntryPoint = "GetIconInfo", CharSet = CharSet.Auto, SetLastError = true)]
+ [DllImport(ExternDll.User32, EntryPoint = "GetIconInfo", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool GetIconInfoImpl(HandleRef hIcon, [Out] ICONINFO_IMPL piconinfo);
[StructLayout(LayoutKind.Sequential)]
@@ -665,17 +608,6 @@ internal static void GetIconInfo(HandleRef hIcon, out NativeMethods.ICONINFO pic
}
}
-#if never
-
- [DllImport(ExternDll.User32,
-#if WIN64
- EntryPoint="GetClassLongPtr",
-#endif
- CharSet = CharSet.Auto, SetLastError = true)
- ]
- internal static extern UInt32 GetClassLong(IntPtr hwnd, int nIndex);
-#endif
-
[DllImport(ExternDll.User32, EntryPoint = "GetWindowPlacement", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool IntGetWindowPlacement(HandleRef hWnd, ref NativeMethods.WINDOWPLACEMENT placement);
@@ -701,13 +633,6 @@ internal static void SetWindowPlacement(HandleRef hWnd, [In] ref NativeMethods.W
}
}
- //[DllImport("secur32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
- //internal static extern bool GetUserNameExW(
- // [In] EXTENDED_NAME_FORMAT nameFormat,
- // [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpNameBuffer,
- // [In, Out] ref ulong nSize);
-
-
[DllImport(ExternDll.User32, CharSet = CharSet.Auto, BestFitMapping = false)]
internal static extern bool SystemParametersInfo(int nAction, int nParam, [In, Out] NativeMethods.ANIMATIONINFO anim, int nUpdate);
@@ -805,24 +730,9 @@ public static extern bool EndPanningFeedback(
HandleRef hwnd,
bool fAnimateBack);
- ///
- ///
- ///
- [DllImport(ExternDll.Kernel32, CharSet = CharSet.Auto, SetLastError = true)]
- public static extern bool SetEvent(IntPtr hEvent);
-
[DllImport(ExternDll.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern int SetEvent([In] SafeWaitHandle hHandle);
- [DllImport(ExternDll.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
- public static extern int WaitForSingleObject([In] SafeWaitHandle hHandle, [In] int dwMilliseconds);
-
-
- //[DllImport(ExternDll.Kernel32, SetLastError = true)]
- //internal static extern int GetFileSize(SafeFileHandle hFile, ref int lpFileSizeHigh);
-
-
- //////////////////////////////////////
// Needed by BASE
#if BASE_NATIVEMETHODS
@@ -836,19 +746,6 @@ internal static extern int GetMouseMovePointsEx(
uint resolution
);
- [StructLayout(LayoutKind.Explicit)]
- internal unsafe struct ULARGE_INTEGER
- {
- [FieldOffset(0)]
- internal uint LowPart;
-
- [FieldOffset(4)]
- internal uint HighPart;
-
- [FieldOffset(0)]
- internal ulong QuadPart;
- }
-
[StructLayout(LayoutKind.Explicit)]
internal unsafe struct LARGE_INTEGER
{
@@ -872,13 +769,9 @@ ref LARGE_INTEGER lpFileSize
/// Win32 constants
internal static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
- /// Win32 constants
- internal const int PAGE_NOACCESS = 0x01;
/// Win32 constants
internal const int PAGE_READONLY = 0x02;
/// Win32 constants
- internal const int PAGE_READWRITE = 0x04;
- /// Win32 constants
internal const int PAGE_WRITECOPY = 0x08;
/// Win32 constants
internal const int PAGE_EXECUTE = 0x10;
@@ -915,10 +808,6 @@ ref LARGE_INTEGER lpFileSize
/// Win32 constants
internal const int MEM_WRITE_WATCH = 0x200000;
/// Win32 constants
- internal const int MEM_PHYSICAL = 0x400000;
- /// Win32 constants
- internal const int MEM_4MB_PAGES = unchecked((int)0x80000000);
- /// Win32 constants
internal const int SEC_FILE = 0x800000;
/// Win32 constants
internal const int SEC_IMAGE = 0x1000000;
@@ -965,44 +854,6 @@ ref LARGE_INTEGER lpFileSize
/// Win32 constants
internal const int FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS;
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- [DllImport(ExternDll.Advapi32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
- internal static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(
- string stringSecurityDescriptor, // security descriptor string
- int stringSDRevision, // revision level
- ref IntPtr securityDescriptor, // SD
- IntPtr securityDescriptorSize // SD size
- );
-
- /// Win32 constants
- internal const int SDDL_REVISION_1 = 1;
- /// Win32 constants
- internal const int SDDL_REVISION = SDDL_REVISION_1;
-
-
- [DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
- internal static extern SafeFileMappingHandle OpenFileMapping(
- int dwDesiredAccess,
- bool bInheritHandle,
- string lpName
- );
-
- [DllImport(ExternDll.Kernel32, SetLastError = true)]
- internal static extern IntPtr VirtualAlloc(
- IntPtr lpAddress,
- UIntPtr dwSize,
- int flAllocationType,
- int flProtect
- );
-
-
//
// RIT WM_MOUSEQUERY structure for DWM WM_MOUSEQUERY (see HwndMouseInputSource.cs)
//
@@ -1018,44 +869,14 @@ internal unsafe struct MOUSEQUERY
}
[DllImport(ExternDll.Ole32, ExactSpelling = true, CharSet = CharSet.Auto)]
- public static extern int OleIsCurrentClipboard(IComDataObject pDataObj);
+ public static extern HRESULT OleIsCurrentClipboard(IComDataObject pDataObj);
[DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = CharSet.Auto)]
internal static extern int GetOEMCP();
-#if never
- [DllImport("user32.dll", CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
- internal static extern int ToUnicode(int nVirtKey, int nScanCode, byte[] keystate, StringBuilder text, int cch, int flags);
-#endif
-
// WinEvent fired when new Avalon UI is created
public const int EventObjectUIFragmentCreate = 0x6FFFFFFF;
-
- //////////////////////////////////
- // Needed by FontCache
-
- [DllImport("ntdll.dll")]
- internal static extern int RtlNtStatusToDosError(int Status);
-
- internal static bool NtSuccess(int err)
- {
- return err >= STATUS_SUCCESS;
- }
-
- internal static void NtCheck(int err)
- {
- if (!NtSuccess(err))
- {
- int win32error = RtlNtStatusToDosError(err);
- throw new System.ComponentModel.Win32Exception(win32error);
- }
- }
-
- internal const int STATUS_SUCCESS = 0;
- internal const int STATUS_TIMEOUT = 0x00000102;
- internal const int STATUS_BUFFER_TOO_SMALL = unchecked((int)0xC0000023);
-
#endif // BASE_NATIVEMETHODS
//
@@ -1156,55 +977,5 @@ public unsafe struct PROFILE
[DllImport(ExternDll.User32)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsIconic(IntPtr hWnd);
-
- public enum HookType : int
- {
- WH_JOURNALRECORD = 0,
- WH_JOURNALPLAYBACK = 1,
- WH_KEYBOARD = 2,
- WH_GETMESSAGE = 3,
- WH_CALLWNDPROC = 4,
- WH_CBT = 5,
- WH_SYSMSGFILTER = 6,
- WH_MOUSE = 7,
- WH_HARDWARE = 8,
- WH_DEBUG = 9,
- WH_SHELL = 10,
- WH_FOREGROUNDIDLE = 11,
- WH_CALLWNDPROCRET = 12,
- WH_KEYBOARD_LL = 13,
- WH_MOUSE_LL = 14,
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct MOUSEHOOKSTRUCT
- {
- public NativeMethods.POINT pt;
- public IntPtr hwnd;
- public uint wHitTestCode;
- public IntPtr dwExtraInfo;
- }
-
- public delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
-
- public static HandleRef SetWindowsHookEx(HookType idHook, HookProc lpfn, IntPtr hMod, int dwThreadId)
- {
- IntPtr result = IntSetWindowsHookEx(idHook, lpfn, hMod, dwThreadId);
- if (result == IntPtr.Zero)
- {
- throw new Win32Exception();
- }
-
- return new HandleRef(lpfn, result);
- }
-
- [DllImport(ExternDll.User32, EntryPoint = "SetWindowsHookExW", SetLastError = true)]
- private static extern IntPtr IntSetWindowsHookEx(HookType idHook, HookProc lpfn, IntPtr hMod, int dwThreadId);
-
- [DllImport(ExternDll.User32, SetLastError = true)]
- public static extern bool UnhookWindowsHookEx(HandleRef hhk);
-
- [DllImport(ExternDll.User32, SetLastError = true)]
- public static extern IntPtr CallNextHookEx(HandleRef hhk, int nCode, IntPtr wParam, IntPtr lParam);
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsTextServices.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsTextServices.cs
index 7b333c760a1..10285fdaf5d 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsTextServices.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsTextServices.cs
@@ -1,734 +1,274 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
+using Windows.Win32.Foundation;
namespace MS.Win32
{
- internal partial class UnsafeNativeMethods {
- //------------------------------------------------------
- //
- // public Methods
- //
- //------------------------------------------------------
-
- #region public Methods
-
+ internal partial class UnsafeNativeMethods
+ {
[DllImport("msctf.dll")]
- internal static extern int TF_CreateThreadMgr(out ITfThreadMgr threadManager);
+ internal static extern HRESULT TF_CreateThreadMgr(out ITfThreadMgr threadManager);
- ///
[DllImport("msctf.dll")]
- public static extern int TF_CreateInputProcessorProfiles(out ITfInputProcessorProfiles profiles);
-
- ///
+ public static extern HRESULT TF_CreateInputProcessorProfiles(out ITfInputProcessorProfiles profiles);
[DllImport("msctf.dll")]
- public static extern int TF_CreateDisplayAttributeMgr(out ITfDisplayAttributeMgr dam);
+ public static extern HRESULT TF_CreateDisplayAttributeMgr(out ITfDisplayAttributeMgr dam);
- ///
[DllImport("msctf.dll")]
- public static extern int TF_CreateCategoryMgr(out ITfCategoryMgr catmgr);
-
- #endregion public Methods
-
- //------------------------------------------------------
- //
- // Constants
- //
- //------------------------------------------------------
-
- #region Constants
+ public static extern HRESULT TF_CreateCategoryMgr(out ITfCategoryMgr catmgr);
- ///
public const int TF_CLIENTID_NULL = 0;
- ///
- public const char TS_CHAR_EMBEDDED = (char)0xfffc; // unicode 2.1 object replacement character
-
- ///
- public const char TS_CHAR_REGION = (char)0x0000; // region boundary
-
- ///
- public const char TS_CHAR_REPLACEMENT = (char)0xfffd; // hidden text placeholder char, Unicode replacement character
-
- ///
+ public const char TS_CHAR_EMBEDDED = (char)0xfffc; // unicode 2.1 object replacement character
+ public const char TS_CHAR_REGION = (char)0x0000; // region boundary
+ public const char TS_CHAR_REPLACEMENT = (char)0xfffd; // hidden text placeholder char, Unicode replacement character
public const int TS_DEFAULT_SELECTION = -1;
-
- ///
- public const int TS_S_ASYNC = 0x00040300;
-
- ///
+ public const int TS_S_ASYNC = 0x00040300;
public const int TS_E_NOSELECTION = unchecked((int)0x80040205);
-
- ///
public const int TS_E_NOLAYOUT = unchecked((int)0x80040206);
-
- ///
public const int TS_E_INVALIDPOINT = unchecked((int)0x80040207);
-
- ///
public const int TS_E_SYNCHRONOUS = unchecked((int)0x80040208);
-
- ///
public const int TS_E_READONLY = unchecked((int)0x80040209);
-
- ///
public const int TS_E_FORMAT = unchecked((int)0x8004020a);
-
- ///
public const int TF_INVALID_COOKIE = -1;
+ public const int TF_DICTATION_ON = 0x00000001;
+ public const int TF_COMMANDING_ON = 0x00000008;
- ///
- public const int TF_DICTATION_ON = 0x00000001;
-
- ///
- public const int TF_COMMANDING_ON = 0x00000008;
-
- ///
public static readonly Guid IID_ITextStoreACPSink = new Guid(0x22d44c94, 0xa419, 0x4542, 0xa2, 0x72, 0xae, 0x26, 0x09, 0x3e, 0xce, 0xcf);
-
- ///
public static readonly Guid IID_ITfThreadFocusSink = new Guid(0xc0f1db0c, 0x3a20, 0x405c, 0xa3, 0x03, 0x96, 0xb6, 0x01, 0x0a, 0x88, 0x5f);
-
- ///
public static readonly Guid IID_ITfTextEditSink = new Guid(0x8127d409, 0xccd3, 0x4683, 0x96, 0x7a, 0xb4, 0x3d, 0x5b, 0x48, 0x2b, 0xf7);
-
- ///
public static readonly Guid IID_ITfLanguageProfileNotifySink = new Guid(0x43c9fe15, 0xf494, 0x4c17, 0x9d, 0xe2, 0xb8, 0xa4, 0xac, 0x35, 0x0a, 0xa8);
-
- ///
public static readonly Guid IID_ITfCompartmentEventSink = new Guid(0x743abd5f, 0xf26d, 0x48df, 0x8c, 0xc5, 0x23, 0x84, 0x92, 0x41, 0x9b, 0x64);
-
- ///
public static readonly Guid IID_ITfTransitoryExtensionSink = new Guid(0xa615096f, 0x1c57, 0x4813, 0x8a, 0x15, 0x55, 0xee, 0x6e, 0x5a, 0x83, 0x9c);
-
- ///
public static readonly Guid GUID_TFCAT_TIP_KEYBOARD = new Guid(0x34745c63, 0xb2f0, 0x4784, 0x8b, 0x67, 0x5e, 0x12, 0xc8, 0x70, 0x1a, 0x31);
-/*
- ///
- public static readonly Guid GUID_TFCAT_TIP_SPEECH = new Guid("b5a73cd1-8355-426b-a161-259808f26b14");
-
- ///
- public static readonly Guid GUID_TFCAT_TIP_HANDWRITING = new Guid("246ecb87-c2f2-4abe-905b-c8b38add2c43");
-*/
-
-
- ///
public static readonly Guid GUID_PROP_ATTRIBUTE = new Guid(0x34b45670, 0x7526, 0x11d2, 0xa1, 0x47, 0x00, 0x10, 0x5a, 0x27, 0x99, 0xb5);
-
- ///
- public static readonly Guid GUID_PROP_LANGID = new Guid(0x3280ce20, 0x8032, 0x11d2, 0xb6, 0x03, 0x00, 0x10, 0x5a, 0x27, 0x99, 0xb5);
-
- ///
+ public static readonly Guid GUID_PROP_LANGID = new Guid(0x3280ce20, 0x8032, 0x11d2, 0xb6, 0x03, 0x00, 0x10, 0x5a, 0x27, 0x99, 0xb5);
public static readonly Guid GUID_PROP_READING = new Guid(0x5463f7c0, 0x8e31, 0x11d2, 0xbf, 0x46, 0x00, 0x10, 0x5a, 0x27, 0x99, 0xb5);
-
-
- ///
public static readonly Guid GUID_PROP_INPUTSCOPE = new Guid(0x1713dd5a, 0x68e7, 0x4a5b, 0x9a, 0xf6, 0x59, 0x2a, 0x59, 0x5c, 0x77, 0x8d);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_KEYBOARD_DISABLED = new Guid( 0x71a5b253, 0x1951, 0x466b, 0x9f, 0xbc, 0x9c, 0x88, 0x08, 0xfa, 0x84, 0xf2);
-
- ///
- public static Guid GUID_COMPARTMENT_KEYBOARD_OPENCLOSE = new Guid( 0x58273aad, 0x01bb, 0x4164, 0x95, 0xc6, 0x75, 0x5b, 0xa0, 0xb5, 0x16, 0x2d);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_HANDWRITING_OPENCLOSE = new Guid( 0xf9ae2c6b, 0x1866, 0x4361, 0xaf, 0x72, 0x7a, 0xa3, 0x09, 0x48, 0x89, 0x0e);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_SPEECH_DISABLED = new Guid( 0x56c5c607, 0x0703, 0x4e59, 0x8e, 0x52, 0xcb, 0xc8, 0x4e, 0x8b, 0xbe, 0x35);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_SPEECH_OPENCLOSE = new Guid( 0x544d6a63, 0xe2e8, 0x4752, 0xbb, 0xd1, 0x00, 0x09, 0x60, 0xbc, 0xa0, 0x83);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_SPEECH_GLOBALSTATE = new Guid( 0x2a54fe8e, 0x0d08, 0x460c, 0xa7, 0x5d, 0x87, 0x03, 0x5f, 0xf4, 0x36, 0xc5);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_KEYBOARD_INPUTMODE_CONVERSION = new Guid( 0xccf05dd8, 0x4a87, 0x11d7, 0xa6, 0xe2, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_KEYBOARD_INPUTMODE_SENTENCE = new Guid( 0xccf05dd9, 0x4a87, 0x11d7, 0xa6, 0xe2, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_TRANSITORYEXTENSION = new Guid( 0x8be347f5, 0xc7a0, 0x11d7, 0xb4, 0x08, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_TRANSITORYEXTENSION_DOCUMENTMANAGER = new Guid( 0x8be347f7, 0xc7a0, 0x11d7, 0xb4, 0x08, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
-
- ///
- public static readonly Guid GUID_COMPARTMENT_TRANSITORYEXTENSION_PARENT = new Guid( 0x8be347f8, 0xc7a0, 0x11d7, 0xb4, 0x08, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
-
- ///
+ public static readonly Guid GUID_COMPARTMENT_KEYBOARD_DISABLED = new Guid(0x71a5b253, 0x1951, 0x466b, 0x9f, 0xbc, 0x9c, 0x88, 0x08, 0xfa, 0x84, 0xf2);
+ public static Guid GUID_COMPARTMENT_KEYBOARD_OPENCLOSE = new Guid(0x58273aad, 0x01bb, 0x4164, 0x95, 0xc6, 0x75, 0x5b, 0xa0, 0xb5, 0x16, 0x2d);
+ public static readonly Guid GUID_COMPARTMENT_HANDWRITING_OPENCLOSE = new Guid(0xf9ae2c6b, 0x1866, 0x4361, 0xaf, 0x72, 0x7a, 0xa3, 0x09, 0x48, 0x89, 0x0e);
+ public static readonly Guid GUID_COMPARTMENT_SPEECH_DISABLED = new Guid(0x56c5c607, 0x0703, 0x4e59, 0x8e, 0x52, 0xcb, 0xc8, 0x4e, 0x8b, 0xbe, 0x35);
+ public static readonly Guid GUID_COMPARTMENT_SPEECH_OPENCLOSE = new Guid(0x544d6a63, 0xe2e8, 0x4752, 0xbb, 0xd1, 0x00, 0x09, 0x60, 0xbc, 0xa0, 0x83);
+ public static readonly Guid GUID_COMPARTMENT_SPEECH_GLOBALSTATE = new Guid(0x2a54fe8e, 0x0d08, 0x460c, 0xa7, 0x5d, 0x87, 0x03, 0x5f, 0xf4, 0x36, 0xc5);
+ public static readonly Guid GUID_COMPARTMENT_KEYBOARD_INPUTMODE_CONVERSION = new Guid(0xccf05dd8, 0x4a87, 0x11d7, 0xa6, 0xe2, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
+ public static readonly Guid GUID_COMPARTMENT_KEYBOARD_INPUTMODE_SENTENCE = new Guid(0xccf05dd9, 0x4a87, 0x11d7, 0xa6, 0xe2, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
+ public static readonly Guid GUID_COMPARTMENT_TRANSITORYEXTENSION = new Guid(0x8be347f5, 0xc7a0, 0x11d7, 0xb4, 0x08, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
+ public static readonly Guid GUID_COMPARTMENT_TRANSITORYEXTENSION_DOCUMENTMANAGER = new Guid(0x8be347f7, 0xc7a0, 0x11d7, 0xb4, 0x08, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
+ public static readonly Guid GUID_COMPARTMENT_TRANSITORYEXTENSION_PARENT = new Guid(0x8be347f8, 0xc7a0, 0x11d7, 0xb4, 0x08, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c);
public static readonly Guid Clsid_SpeechTip = new Guid(0xdcbd6fa8, 0x032f, 0x11d3, 0xb5, 0xb1, 0x00, 0xc0, 0x4f, 0xc3, 0x24, 0xa1);
-
- ///
- public static readonly Guid Guid_Null = new Guid(0,0,0,0,0,0,0,0,0,0,0);
-
- ///
+ public static readonly Guid Guid_Null = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
public static readonly Guid IID_ITfFnCustomSpeechCommand = new Guid(0xfca6c349, 0xa12f, 0x43a3, 0x8d, 0xd6, 0x5a, 0x5a, 0x42, 0x82, 0x57, 0x7b);
-
- ///
public static readonly Guid IID_ITfFnReconversion = new Guid("4cea93c0-0a58-11d3-8df0-00105a2799b5");
-
- ///
public static readonly Guid IID_ITfFnConfigure = new Guid(0x88f567c6, 0x1757, 0x49f8, 0xa1, 0xb2, 0x89, 0x23, 0x4c, 0x1e, 0xef, 0xf9);
-
- ///
public static readonly Guid IID_ITfFnConfigureRegisterWord = new Guid(0xbb95808a, 0x6d8f, 0x4bca, 0x84, 0x00, 0x53, 0x90, 0xb5, 0x86, 0xae, 0xdf);
-
-/*
-
- ///
- public static readonly Guid TSATTRID_OTHERS = new Guid(0xb3c32af9,0x57d0,0x46a9,0xbc,0xa8,0xda,0xc2,0x38,0xa1,0x30,0x57);
-
-*/
-
-/*
- ///
- public static readonly Guid TSATTRID_Font = new Guid(0x573ea825,0x749b,0x4f8a,0x9c,0xfd,0x21,0xc3,0x60,0x5c,0xa8,0x28);
-*/
- ///
- public static readonly Guid TSATTRID_Font_FaceName = new Guid(0xb536aeb6,0x053b,0x4eb8,0xb6,0x5a,0x50,0xda,0x1e,0x81,0xe7,0x2e);
- ///
- public static readonly Guid TSATTRID_Font_SizePts = new Guid(0xc8493302,0xa5e9,0x456d,0xaf,0x04,0x80,0x05,0xe4,0x13,0x0f,0x03);
-/*
- ///
- public static readonly Guid TSATTRID_Font_Style = new Guid(0x68b2a77f,0x6b0e,0x4f28,0x81,0x77,0x57,0x1c,0x2f,0x3a,0x42,0xb1);
- ///
- public static readonly Guid TSATTRID_Font_Style_Bold = new Guid(0x48813a43,0x8a20,0x4940,0x8e,0x58,0x97,0x82,0x3f,0x7b,0x26,0x8a);
- ///
- public static readonly Guid TSATTRID_Font_Style_Italic = new Guid(0x8740682a,0xa765,0x48e1,0xac,0xfc,0xd2,0x22,0x22,0xb2,0xf8,0x10);
- ///
- public static readonly Guid TSATTRID_Font_Style_SmallCaps = new Guid(0xfacb6bc6,0x9100,0x4cc6,0xb9,0x69,0x11,0xee,0xa4,0x5a,0x86,0xb4);
- ///
- public static readonly Guid TSATTRID_Font_Style_Capitalize = new Guid(0x7d85a3ba, 0xb4fd, 0x43b3, 0xbe, 0xfc, 0x6b, 0x98, 0x5c, 0x84, 0x31, 0x41);
- ///
- public static readonly Guid TSATTRID_Font_Style_Uppercase = new Guid(0x33a300e8, 0xe340, 0x4937, 0xb6, 0x97, 0x8f, 0x23, 0x40, 0x45, 0xcd, 0x9a);
- ///
- public static readonly Guid TSATTRID_Font_Style_Lowercase = new Guid(0x76d8ccb5, 0xca7b, 0x4498, 0x8e, 0xe9, 0xd5, 0xc4, 0xf6, 0xf7, 0x4c, 0x60);
- ///
- public static readonly Guid TSATTRID_Font_Style_Animation = new Guid(0xdcf73d22, 0xe029, 0x47b7, 0xbb, 0x36, 0xf2, 0x63, 0xa3, 0xd0, 0x04, 0xcc);
- ///
- public static readonly Guid TSATTRID_Font_Style_Animation_LasVegasLights = new Guid(0xf40423d5, 0xf87, 0x4f8f, 0xba, 0xda, 0xe6, 0xd6, 0xc, 0x25, 0xe1, 0x52);
- ///
- public static readonly Guid TSATTRID_Font_Style_Animation_BlinkingBackground = new Guid(0x86e5b104, 0x0104, 0x4b10, 0xb5, 0x85, 0x00, 0xf2, 0x52, 0x75, 0x22, 0xb5);
- ///
- public static readonly Guid TSATTRID_Font_Style_Animation_SparkleText = new Guid(0x533aad20, 0x962c, 0x4e9f, 0x8c, 0x09, 0xb4, 0x2e, 0xa4, 0x74, 0x97, 0x11);
- ///
- public static readonly Guid TSATTRID_Font_Style_Animation_MarchingBlackAnts = new Guid(0x7644e067, 0xf186, 0x4902, 0xbf, 0xc6, 0xec, 0x81, 0x5a, 0xa2, 0x0e, 0x9d);
- ///
- public static readonly Guid TSATTRID_Font_Style_Animation_MarchingRedAnts = new Guid(0x78368dad, 0x50fb, 0x4c6f, 0x84, 0x0b, 0xd4, 0x86, 0xbb, 0x6c, 0xf7, 0x81);
- ///
- public static readonly Guid TSATTRID_Font_Style_Animation_Shimmer = new Guid(0x2ce31b58, 0x5293, 0x4c36, 0x88, 0x09, 0xbf, 0x8b, 0xb5, 0x1a, 0x27, 0xb3);
- ///
- public static readonly Guid TSATTRID_Font_Style_Animation_WipeDown = new Guid(0x5872e874, 0x367b, 0x4803, 0xb1, 0x60, 0xc9, 0x0f, 0xf6, 0x25, 0x69, 0xd0);
- ///
- public static readonly Guid TSATTRID_Font_Style_Animation_WipeRight = new Guid(0xb855cbe3, 0x3d2c, 0x4600, 0xb1, 0xe9, 0xe1, 0xc9, 0xce, 0x02, 0xf8, 0x42);
- ///
- public static readonly Guid TSATTRID_Font_Style_Emboss = new Guid(0xbd8ed742, 0x349e, 0x4e37, 0x82, 0xfb, 0x43, 0x79, 0x79, 0xcb, 0x53, 0xa7);
- ///
- public static readonly Guid TSATTRID_Font_Style_Engrave = new Guid(0x9c3371de, 0x8332, 0x4897, 0xbe, 0x5d, 0x89, 0x23, 0x32, 0x23, 0x17, 0x9a);
- ///
- public static readonly Guid TSATTRID_Font_Style_Hidden = new Guid(0xb1e28770, 0x881c, 0x475f, 0x86, 0x3f, 0x88, 0x7a, 0x64, 0x7b, 0x10, 0x90);
- ///
- public static readonly Guid TSATTRID_Font_Style_Kerning = new Guid(0xcc26e1b4, 0x2f9a, 0x47c8, 0x8b, 0xff, 0xbf, 0x1e, 0xb7, 0xcc, 0xe0, 0xdd);
- ///
- public static readonly Guid TSATTRID_Font_Style_Outlined = new Guid(0x10e6db31, 0xdb0d, 0x4ac6, 0xa7, 0xf5, 0x9c, 0x9c, 0xff, 0x6f, 0x2a, 0xb4);
- ///
- public static readonly Guid TSATTRID_Font_Style_Position = new Guid(0x15cd26ab, 0xf2fb, 0x4062, 0xb5, 0xa6, 0x9a, 0x49, 0xe1, 0xa5, 0xcc, 0x0b);
- ///
- public static readonly Guid TSATTRID_Font_Style_Protected = new Guid(0x1c557cb2, 0x14cf, 0x4554, 0xa5, 0x74, 0xec, 0xb2, 0xf7, 0xe7, 0xef, 0xd4);
- ///
- public static readonly Guid TSATTRID_Font_Style_Shadow = new Guid(0x5f686d2f, 0xc6cd, 0x4c56, 0x8a, 0x1a, 0x99, 0x4a, 0x4b, 0x97, 0x66, 0xbe);
- ///
- public static readonly Guid TSATTRID_Font_Style_Spacing = new Guid(0x98c1200d, 0x8f06, 0x409a, 0x8e, 0x49, 0x6a, 0x55, 0x4b, 0xf7, 0xc1, 0x53);
- ///
- public static readonly Guid TSATTRID_Font_Style_Weight = new Guid(0x12f3189c, 0x8bb0, 0x461b, 0xb1, 0xfa, 0xea, 0xf9, 0x07, 0x04, 0x7f, 0xe0);
-*/
- ///
+ public static readonly Guid TSATTRID_Font_FaceName = new Guid(0xb536aeb6, 0x053b, 0x4eb8, 0xb6, 0x5a, 0x50, 0xda, 0x1e, 0x81, 0xe7, 0x2e);
+ public static readonly Guid TSATTRID_Font_SizePts = new Guid(0xc8493302, 0xa5e9, 0x456d, 0xaf, 0x04, 0x80, 0x05, 0xe4, 0x13, 0x0f, 0x03);
public static readonly Guid TSATTRID_Font_Style_Height = new Guid(0x7e937477, 0x12e6, 0x458b, 0x92, 0x6a, 0x1f, 0xa4, 0x4e, 0xe8, 0xf3, 0x91);
-/*
- ///
- public static readonly Guid TSATTRID_Font_Style_Underline = new Guid(0xc3c9c9f3,0x7902,0x444b,0x9a,0x7b,0x48,0xe7,0x0f,0x4b,0x50,0xf7);
- ///
- public static readonly Guid TSATTRID_Font_Style_Underline_Single = new Guid(0x1b6720e5,0x0f73,0x4951,0xa6,0xb3,0x6f,0x19,0xe4,0x3c,0x94,0x61);
- ///
- public static readonly Guid TSATTRID_Font_Style_Underline_Double = new Guid(0x74d24aa6, 0x1db3, 0x4c69, 0xa1, 0x76, 0x31, 0x12, 0x0e, 0x75, 0x86, 0xd5);
- ///
- public static readonly Guid TSATTRID_Font_Style_Strikethrough = new Guid(0x0c562193,0x2d08,0x4668,0x96,0x01,0xce,0xd4,0x13,0x09,0xd7,0xaf);
- ///
- public static readonly Guid TSATTRID_Font_Style_Strikethrough_Single = new Guid(0x75d736b6,0x3c8f,0x4b97,0xab,0x78,0x18,0x77,0xcb,0x99,0x0d,0x31);
- ///
- public static readonly Guid TSATTRID_Font_Style_Strikethrough_Double = new Guid(0x62489b31, 0xa3e7, 0x4f94, 0xac, 0x43, 0xeb, 0xaf, 0x8f, 0xcc, 0x7a, 0x9f);
- ///
- public static readonly Guid TSATTRID_Font_Style_Overline = new Guid(0xe3989f4a,0x992b,0x4301,0x8c,0xe1,0xa5,0xb7,0xc6,0xd1,0xf3,0xc8);
- ///
- public static readonly Guid TSATTRID_Font_Style_Overline_Single = new Guid(0x8440d94c,0x51ce,0x47b2,0x8d,0x4c,0x15,0x75,0x1e,0x5f,0x72,0x1b);
- ///
- public static readonly Guid TSATTRID_Font_Style_Overline_Double = new Guid(0xdc46063a, 0xe115, 0x46e3, 0xbc, 0xd8, 0xca, 0x67, 0x72, 0xaa, 0x95, 0xb4);
- ///
- public static readonly Guid TSATTRID_Font_Style_Blink = new Guid(0xbfb2c036, 0x7acf, 0x4532, 0xb7, 0x20, 0xb4, 0x16, 0xdd, 0x77, 0x65, 0xa8);
- ///
- public static readonly Guid TSATTRID_Font_Style_Subscript = new Guid(0x5774fb84,0x389b,0x43bc,0xa7,0x4b,0x15,0x68,0x34,0x7c,0xf0,0xf4);
- ///
- public static readonly Guid TSATTRID_Font_Style_Superscript = new Guid(0x2ea4993c,0x563c,0x49aa,0x93,0x72,0x0b,0xef,0x09,0xa9,0x25,0x5b);
- ///
- public static readonly Guid TSATTRID_Font_Style_Color = new Guid(0x857a7a37,0xb8af,0x4e9a,0x81,0xb4,0xac,0xf7,0x00,0xc8,0x41,0x1b);
- ///
- public static readonly Guid TSATTRID_Font_Style_BackgroundColor = new Guid(0xb50eaa4e, 0x3091, 0x4468, 0x81, 0xdb, 0xd7, 0x9e, 0xa1, 0x90, 0xc7, 0xc7);
-
- ///
- public static readonly Guid TSATTRID_Text = new Guid(0x7edb8e68, 0x81f9, 0x449d, 0xa1, 0x5a, 0x87, 0xa8, 0x38, 0x8f, 0xaa, 0xc0);
-*/
- ///
- public static readonly Guid TSATTRID_Text_VerticalWriting = new Guid(0x6bba8195,0x046f,0x4ea9,0xb3,0x11,0x97,0xfd,0x66,0xc4,0x27,0x4b);
-/*
- ///
- public static readonly Guid TSATTRID_Text_RightToLeft = new Guid(0xca666e71,0x1b08,0x453d,0xbf,0xdd,0x28,0xe0,0x8c,0x8a,0xaf,0x7a);
-*/
- ///
- public static readonly Guid TSATTRID_Text_Orientation = new Guid(0x6bab707f,0x8785,0x4c39,0x8b,0x52,0x96,0xf8,0x78,0x30,0x3f,0xfb);
-/*
- ///
- public static readonly Guid TSATTRID_Text_Language = new Guid(0xd8c04ef1,0x5753,0x4c25,0x88,0x87,0x85,0x44,0x3f,0xe5,0xf8,0x19);
-*/
- ///
- public static readonly Guid TSATTRID_Text_ReadOnly = new Guid(0x85836617,0xde32,0x4afd,0xa5,0x0f,0xa2,0xdb,0x11,0x0e,0x6e,0x4d);
-/*
- ///
- public static readonly Guid TSATTRID_Text_EmbeddedObject = new Guid(0x7edb8e68, 0x81f9, 0x449d, 0xa1, 0x5a, 0x87, 0xa8, 0x38, 0x8f, 0xaa, 0xc0);
- ///
- public static readonly Guid TSATTRID_Text_Alignment = new Guid(0x139941e6, 0x1767, 0x456d, 0x93, 0x8e, 0x35, 0xba, 0x56, 0x8b, 0x5c, 0xd4);
- ///
- public static readonly Guid TSATTRID_Text_Alignment_Left = new Guid(0x16ae95d3, 0x6361, 0x43a2, 0x84, 0x95, 0xd0, 0x0f, 0x39, 0x7f, 0x16, 0x93);
- ///
- public static readonly Guid TSATTRID_Text_Alignment_Right = new Guid(0xb36f0f98, 0x1b9e, 0x4360, 0x86, 0x16, 0x03, 0xfb, 0x08, 0xa7, 0x84, 0x56);
- ///
- public static readonly Guid TSATTRID_Text_Alignment_Center = new Guid(0xa4a95c16, 0x53bf, 0x4d55, 0x8b, 0x87, 0x4b, 0xdd, 0x8d, 0x42, 0x75, 0xfc);
- ///
- public static readonly Guid TSATTRID_Text_Alignment_Justify = new Guid(0xed350740, 0xa0f7, 0x42d3, 0x8e, 0xa8, 0xf8, 0x1b, 0x64, 0x88, 0xfa, 0xf0);
- ///
- public static readonly Guid TSATTRID_Text_Link = new Guid(0x47cd9051, 0x3722, 0x4cd8, 0xb7, 0xc8, 0x4e, 0x17, 0xca, 0x17, 0x59, 0xf5);
- ///
- public static readonly Guid TSATTRID_Text_Hyphenation = new Guid(0xdadf4525, 0x618e, 0x49eb, 0xb1, 0xa8, 0x3b, 0x68, 0xbd, 0x76, 0x48, 0xe3);
- ///
- public static readonly Guid TSATTRID_Text_Para = new Guid(0x5edc5822, 0x99dc, 0x4dd6, 0xae, 0xc3, 0xb6, 0x2b, 0xaa, 0x5b, 0x2e, 0x7c);
- ///
- public static readonly Guid TSATTRID_Text_Para_FirstLineIndent = new Guid(0x07c97a13, 0x7472, 0x4dd8, 0x90, 0xa9, 0x91, 0xe3, 0xd7, 0xe4, 0xf2, 0x9c);
- ///
- public static readonly Guid TSATTRID_Text_Para_LeftIndent = new Guid(0xfb2848e9, 0x7471, 0x41c9, 0xb6, 0xb3, 0x8a, 0x14, 0x50, 0xe0, 0x18, 0x97);
- ///
- public static readonly Guid TSATTRID_Text_Para_RightIndent = new Guid(0x2c7f26f9, 0xa5e2, 0x48da, 0xb9, 0x8a, 0x52, 0x0c, 0xb1, 0x65, 0x13, 0xbf);
- ///
- public static readonly Guid TSATTRID_Text_Para_SpaceAfter = new Guid(0x7b0a3f55, 0x22dc, 0x425f, 0xa4, 0x11, 0x93, 0xda, 0x1d, 0x8f, 0x9b, 0xaa);
- ///
- public static readonly Guid TSATTRID_Text_Para_SpaceBefore = new Guid(0x8df98589, 0x194a, 0x4601, 0xb2, 0x51, 0x98, 0x65, 0xa3, 0xe9, 0x06, 0xdd);
- ///
- public static readonly Guid TSATTRID_Text_Para_LineSpacing = new Guid(0x699b380d, 0x7f8c, 0x46d6, 0xa7, 0x3b, 0xdf, 0xe3, 0xd1, 0x53, 0x8d, 0xf3);
- ///
- public static readonly Guid TSATTRID_Text_Para_LineSpacing_Single = new Guid(0xed350740, 0xa0f7, 0x42d3, 0x8e, 0xa8, 0xf8, 0x1b, 0x64, 0x88, 0xfa, 0xf0);
- ///
- public static readonly Guid TSATTRID_Text_Para_LineSpacing_OnePtFive = new Guid(0x0428a021, 0x0397, 0x4b57, 0x9a, 0x17, 0x07, 0x95, 0x99, 0x4c, 0xd3, 0xc5);
- ///
- public static readonly Guid TSATTRID_Text_Para_LineSpacing_Double = new Guid(0x82fb1805, 0xa6c4, 0x4231, 0xac, 0x12, 0x62, 0x60, 0xaf, 0x2a, 0xba, 0x28);
- ///
- public static readonly Guid TSATTRID_Text_Para_LineSpacing_AtLeast = new Guid(0xadfedf31, 0x2d44, 0x4434, 0xa5, 0xff, 0x7f, 0x4c, 0x49, 0x90, 0xa9, 0x05);
- ///
- public static readonly Guid TSATTRID_Text_Para_LineSpacing_Exactly = new Guid(0x3d45ad40, 0x23de, 0x48d7, 0xa6, 0xb3, 0x76, 0x54, 0x20, 0xc6, 0x20, 0xcc);
- ///
- public static readonly Guid TSATTRID_Text_Para_LineSpacing_Multiple = new Guid(0x910f1e3c, 0xd6d0, 0x4f65, 0x8a, 0x3c, 0x42, 0xb4, 0xb3, 0x18, 0x68, 0xc5);
-
- ///
- public static readonly Guid TSATTRID_List = new Guid(0x436d673b, 0x26f1, 0x4aee, 0x9e, 0x65, 0x8f, 0x83, 0xa4, 0xed, 0x48, 0x84);
- ///
- public static readonly Guid TSATTRID_List_LevelIndel = new Guid(0x7f7cc899, 0x311f, 0x487b, 0xad, 0x5d, 0xe2, 0xa4, 0x59, 0xe1, 0x2d, 0x42);
- ///
- public static readonly Guid TSATTRID_List_Type = new Guid(0xae3e665e, 0x4bce, 0x49e3, 0xa0, 0xfe, 0x2d, 0xb4, 0x7d, 0x3a, 0x17, 0xae);
- ///
- public static readonly Guid TSATTRID_List_Type_Bullet = new Guid(0xbccd77c5, 0x4c4d, 0x4ce2, 0xb1, 0x02, 0x55, 0x9f, 0x3b, 0x2b, 0xfc, 0xea);
- ///
- public static readonly Guid TSATTRID_List_Type_Arabic = new Guid(0x1338c5d6, 0x98a3, 0x4fa3, 0x9b, 0xd1, 0x7a, 0x60, 0xee, 0xf8, 0xe9, 0xe0);
- ///
- public static readonly Guid TSATTRID_List_Type_LowerLetter = new Guid(0x96372285, 0xf3cf, 0x491e, 0xa9, 0x25, 0x38, 0x32, 0x34, 0x7f, 0xd2, 0x37);
- ///
- public static readonly Guid TSATTRID_List_Type_UpperLetter = new Guid(0x7987b7cd, 0xce52, 0x428b, 0x9b, 0x95, 0xa3, 0x57, 0xf6, 0xf1, 0x0c, 0x45);
- ///
- public static readonly Guid TSATTRID_List_Type_LowerRoman = new Guid(0x90466262, 0x3980, 0x4b8e, 0x93, 0x68, 0x91, 0x8b, 0xd1, 0x21, 0x8a, 0x41);
- ///
- public static readonly Guid TSATTRID_List_Type_UpperRoman = new Guid(0x0f6ab552, 0x4a80, 0x467f, 0xb2, 0xf1, 0x12, 0x7e, 0x2a, 0xa3, 0xba, 0x9e);
-
- ///
- public static readonly Guid TSATTRID_App = new Guid(0xa80f77df,0x4237,0x40e5,0x84,0x9c,0xb5,0xfa,0x51,0xc1,0x3a,0xc7);
- ///
- public static readonly Guid TSATTRID_App_IncorrectSpelling = new Guid(0xf42de43c,0xef12,0x430d,0x94,0x4c,0x9a,0x08,0x97,0x0a,0x25,0xd2);
- ///
- public static readonly Guid TSATTRID_App_IncorrectGrammar = new Guid(0xbd54e398,0xad03,0x4b74,0xb6,0xb3,0x5e,0xdb,0x19,0x99,0x63,0x88);
-*/
+ public static readonly Guid TSATTRID_Text_VerticalWriting = new Guid(0x6bba8195, 0x046f, 0x4ea9, 0xb3, 0x11, 0x97, 0xfd, 0x66, 0xc4, 0x27, 0x4b);
+ public static readonly Guid TSATTRID_Text_Orientation = new Guid(0x6bab707f, 0x8785, 0x4c39, 0x8b, 0x52, 0x96, 0xf8, 0x78, 0x30, 0x3f, 0xfb);
+ public static readonly Guid TSATTRID_Text_ReadOnly = new Guid(0x85836617, 0xde32, 0x4afd, 0xa5, 0x0f, 0xa2, 0xdb, 0x11, 0x0e, 0x6e, 0x4d);
public static readonly Guid GUID_SYSTEM_FUNCTIONPROVIDER = new Guid("9a698bb0-0f21-11d3-8df1-00105a2799b5");
- #endregion Constants
-
- //------------------------------------------------------
- //
- // Enums
- //
- //------------------------------------------------------
-
- #region Enums
-
- ///
[Flags]
public enum PopFlags
{
- ///
TF_POPF_ALL = 0x0001,
}
- ///
[Flags]
public enum CreateContextFlags
{
// TF_PLAINTEXTTSI is undocumented
}
- ///
- public enum TsGravity
- {
- ///
- TS_GR_BACKWARD = 0,
- ///
- TS_GR_FORWARD = 1,
- };
-
- ///
- public enum TsShiftDir
- {
- ///
- TS_SD_BACKWARD = 0,
- ///
- TS_SD_FORWARD = 1,
- };
-
- ///
[Flags]
public enum SetTextFlags
{
- ///
- TS_ST_CORRECTION = 0x1,
+ TS_ST_CORRECTION = 0x1,
}
- ///
[Flags]
public enum InsertEmbeddedFlags
{
- ///
- TS_IE_CORRECTION = 0x1,
+ TS_IE_CORRECTION = 0x1,
}
- ///
[Flags]
public enum InsertAtSelectionFlags
{
- ///
- TS_IAS_NOQUERY = 0x1,
- ///
- TS_IAS_QUERYONLY = 0x2,
+ TS_IAS_NOQUERY = 0x1,
+ TS_IAS_QUERYONLY = 0x2,
}
- ///
[Flags]
public enum AdviseFlags
{
- ///
- TS_AS_TEXT_CHANGE = 0x01,
- ///
- TS_AS_SEL_CHANGE = 0x02,
- ///
- TS_AS_LAYOUT_CHANGE = 0x04,
- ///
- TS_AS_ATTR_CHANGE = 0x08,
- ///
- TS_AS_STATUS_CHANGE = 0x10,
+ TS_AS_TEXT_CHANGE = 0x01,
+ TS_AS_SEL_CHANGE = 0x02,
+ TS_AS_LAYOUT_CHANGE = 0x04,
+ TS_AS_ATTR_CHANGE = 0x08,
+ TS_AS_STATUS_CHANGE = 0x10,
}
- ///
[Flags]
public enum LockFlags
{
- ///
- TS_LF_SYNC = 0x1,
- ///
- TS_LF_READ = 0x2,
- ///
- TS_LF_WRITE = 0x4,
- ///
- TS_LF_READWRITE = 0x6,
+ TS_LF_SYNC = 0x1,
+ TS_LF_READ = 0x2,
+ TS_LF_WRITE = 0x4,
+ TS_LF_READWRITE = 0x6,
}
- ///
[Flags]
public enum DynamicStatusFlags
{
- ///
- TS_SD_READONLY = 0x001,
- ///
- TS_SD_LOADING = 0x002,
+ TS_SD_READONLY = 0x001,
+ TS_SD_LOADING = 0x002,
}
- ///
[Flags]
public enum StaticStatusFlags
{
- ///
- TS_SS_DISJOINTSEL = 0x001,
- ///
- TS_SS_REGIONS = 0x002,
- ///
- TS_SS_TRANSITORY = 0x004,
- ///
- TS_SS_NOHIDDENTEXT = 0x008,
+ TS_SS_DISJOINTSEL = 0x001,
+ TS_SS_REGIONS = 0x002,
+ TS_SS_TRANSITORY = 0x004,
+ TS_SS_NOHIDDENTEXT = 0x008,
}
- ///
[Flags]
public enum AttributeFlags
{
- ///
- TS_ATTR_FIND_BACKWARDS = 0x0001,
- ///
- TS_ATTR_FIND_WANT_OFFSET = 0x0002,
- ///
- TS_ATTR_FIND_UPDATESTART = 0x0004,
- ///
- TS_ATTR_FIND_WANT_VALUE = 0x0008,
- ///
- TS_ATTR_FIND_WANT_END = 0x0010,
- ///
- TS_ATTR_FIND_HIDDEN = 0x0020,
- }
-
- ///
+ TS_ATTR_FIND_BACKWARDS = 0x0001,
+ TS_ATTR_FIND_WANT_OFFSET = 0x0002,
+ TS_ATTR_FIND_UPDATESTART = 0x0004,
+ TS_ATTR_FIND_WANT_VALUE = 0x0008,
+ TS_ATTR_FIND_WANT_END = 0x0010,
+ TS_ATTR_FIND_HIDDEN = 0x0020,
+ }
+
[Flags]
public enum GetPositionFromPointFlags
{
- ///
GXFPF_ROUND_NEAREST = 0x1,
- ///
- GXFPF_NEAREST = 0x2,
+ GXFPF_NEAREST = 0x2,
}
- ///
public enum TsActiveSelEnd
{
- ///
TS_AE_NONE = 0,
- ///
TS_AE_START = 1,
- ///
TS_AE_END = 2,
}
- ///
public enum TsRunType
{
- ///
TS_RT_PLAIN = 0,
- ///
TS_RT_HIDDEN = 1,
- ///
TS_RT_OPAQUE = 2,
}
- ///
[Flags]
public enum OnTextChangeFlags
{
- ///
- TS_TC_CORRECTION = 0x1,
+ TS_TC_CORRECTION = 0x1,
}
- ///
public enum TsLayoutCode
- {
- ///
+ {
TS_LC_CREATE = 0,
- ///
TS_LC_CHANGE = 1,
- ///
TS_LC_DESTROY = 2
}
- ///
public enum TfGravity
{
- ///
TF_GR_BACKWARD = 0,
- ///
TF_GR_FORWARD = 1,
};
- ///
public enum TfShiftDir
{
- ///
TF_SD_BACKWARD = 0,
- ///
TF_SD_FORWARD = 1,
};
- ///
public enum TfAnchor
{
- ///
TF_ANCHOR_START = 0,
- ///
TF_ANCHOR_END = 1,
}
- ///
public enum TF_DA_COLORTYPE
{
- ///
- TF_CT_NONE = 0,
- ///
+ TF_CT_NONE = 0,
TF_CT_SYSCOLOR = 1,
- ///
TF_CT_COLORREF = 2
}
- ///
public enum TF_DA_LINESTYLE
{
- ///
- TF_LS_NONE = 0,
- ///
- TF_LS_SOLID = 1,
- ///
- TF_LS_DOT = 2,
- ///
- TF_LS_DASH = 3,
- ///
+ TF_LS_NONE = 0,
+ TF_LS_SOLID = 1,
+ TF_LS_DOT = 2,
+ TF_LS_DASH = 3,
TF_LS_SQUIGGLE = 4
}
-
- ///
+
public enum TF_DA_ATTR_INFO
{
- ///
- TF_ATTR_INPUT = 0,
- ///
- TF_ATTR_TARGET_CONVERTED = 1,
- ///
- TF_ATTR_CONVERTED = 2,
- ///
- TF_ATTR_TARGET_NOTCONVERTED = 3,
- ///
- TF_ATTR_INPUT_ERROR = 4,
- ///
- TF_ATTR_FIXEDCONVERTED = 5,
- ///
- TF_ATTR_OTHER = -1
- }
-
- ///
- [Flags]
- public enum GetRenderingMarkupFlags
- {
- ///
- TF_GRM_INCLUDE_PROPERTY = 1
+ TF_ATTR_INPUT = 0,
+ TF_ATTR_TARGET_CONVERTED = 1,
+ TF_ATTR_CONVERTED = 2,
+ TF_ATTR_TARGET_NOTCONVERTED = 3,
+ TF_ATTR_INPUT_ERROR = 4,
+ TF_ATTR_FIXEDCONVERTED = 5,
+ TF_ATTR_OTHER = -1
}
- ///
[Flags]
- public enum FindRenderingMarkupFlags
+ public enum ConversionModeFlags
{
- ///
- TF_FRM_INCLUDE_PROPERTY = 0x1,
- ///
- TF_FRM_BACKWARD = 0x2,
- ///
- TF_FRM_NO_CONTAINED = 0x4,
- ///
- TF_FRM_NO_RANGE = 0x8
+ TF_CONVERSIONMODE_ALPHANUMERIC = 0x0000,
+ TF_CONVERSIONMODE_NATIVE = 0x0001,
+ TF_CONVERSIONMODE_KATAKANA = 0x0002,
+ TF_CONVERSIONMODE_FULLSHAPE = 0x0008,
+ TF_CONVERSIONMODE_ROMAN = 0x0010,
+ TF_CONVERSIONMODE_CHARCODE = 0x0020,
+ TF_CONVERSIONMODE_NOCONVERSION = 0x0100,
+ TF_CONVERSIONMODE_EUDC = 0x0200,
+ TF_CONVERSIONMODE_SYMBOL = 0x0400,
+ TF_CONVERSIONMODE_FIXED = 0x0800,
}
- ///
- [Flags]
- public enum ConversionModeFlags
- {
- ///
- TF_CONVERSIONMODE_ALPHANUMERIC = 0x0000,
- ///
- TF_CONVERSIONMODE_NATIVE = 0x0001,
- ///
- TF_CONVERSIONMODE_KATAKANA = 0x0002,
- ///
- TF_CONVERSIONMODE_FULLSHAPE = 0x0008,
- ///
- TF_CONVERSIONMODE_ROMAN = 0x0010,
- ///
- TF_CONVERSIONMODE_CHARCODE = 0x0020,
- ///
- TF_CONVERSIONMODE_NOCONVERSION = 0x0100,
- ///
- TF_CONVERSIONMODE_EUDC = 0x0200,
- ///
- TF_CONVERSIONMODE_SYMBOL = 0x0400,
- ///
- TF_CONVERSIONMODE_FIXED = 0x0800,
- }
-
- ///
[Flags]
public enum SentenceModeFlags
{
- ///
- TF_SENTENCEMODE_NONE = 0x0000,
- ///
- TF_SENTENCEMODE_PLAURALCLAUSE = 0x0001,
- ///
- TF_SENTENCEMODE_SINGLECONVERT = 0x0002,
- ///
- TF_SENTENCEMODE_AUTOMATIC = 0x0004,
- ///
- TF_SENTENCEMODE_PHRASEPREDICT = 0x0008,
- ///
- TF_SENTENCEMODE_CONVERSATION = 0x0010,
+ TF_SENTENCEMODE_NONE = 0x0000,
+ TF_SENTENCEMODE_PLAURALCLAUSE = 0x0001,
+ TF_SENTENCEMODE_SINGLECONVERT = 0x0002,
+ TF_SENTENCEMODE_AUTOMATIC = 0x0004,
+ TF_SENTENCEMODE_PHRASEPREDICT = 0x0008,
+ TF_SENTENCEMODE_CONVERSATION = 0x0010,
}
- ///
- public enum TfCandidateResult
+ public enum TfCandidateResult
{
CAND_FINALIZED = 0x0,
- CAND_SELECTED = 0x1,
- CAND_CANCELED = 0x2,
+ CAND_SELECTED = 0x1,
+ CAND_CANCELED = 0x2,
}
- #endregion Enums
-
- //------------------------------------------------------
- //
- // Structs
- //
- //------------------------------------------------------
- #region Structs
-
- ///
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
- ///
- ///
- ///
public int x;
- ///
- ///
- ///
public int y;
public POINT(int x, int y)
@@ -738,161 +278,99 @@ public POINT(int x, int y)
}
}
- ///
[StructLayout(LayoutKind.Sequential)]
- public struct RECT
+ public struct RECT
{
- ///
public int left;
- ///
public int top;
- ///
public int right;
- ///
public int bottom;
-
-/*
- ///
- public static RECT FromXYWH(int x, int y, int width, int height)
- {
- return new RECT(x, y, x + width, y + height);
- }
-
- ///
- public bool IsEmpty
- {
- get
- {
- return left >= right || top >= bottom;
- }
- }
-*/
}
- ///
[StructLayout(LayoutKind.Sequential)]
public struct TS_STATUS
{
- ///
public DynamicStatusFlags dynamicFlags;
- ///
public StaticStatusFlags staticFlags;
}
- ///
[StructLayout(LayoutKind.Sequential)]
public struct TS_SELECTIONSTYLE
{
- ///
public TsActiveSelEnd ase;
- ///
- [MarshalAs(UnmanagedType.Bool)]
+ [MarshalAs(UnmanagedType.Bool)]
public bool interimChar;
}
- ///
[StructLayout(LayoutKind.Sequential)]
public struct TS_SELECTION_ACP
{
- ///
public int start;
- ///
public int end;
- ///
public TS_SELECTIONSTYLE style;
}
- ///
[StructLayout(LayoutKind.Sequential)]
public struct TS_RUNINFO
{
- ///
public int count;
- ///
public TsRunType type;
}
- ///
[StructLayout(LayoutKind.Sequential)]
public struct TS_TEXTCHANGE
{
- ///
public int start;
- ///
public int oldEnd;
- ///
public int newEnd;
}
- ///
[StructLayout(LayoutKind.Sequential)]
public struct TS_ATTRVAL
{
- ///
public Guid attributeId;
-
- ///
public Int32 overlappedId;
// Let val's offset 0x18. Though default pack is 8...
- ///
- public Int32 reserved;
+ public Int32 reserved;
- ///
[MarshalAs(UnmanagedType.Struct)]
public NativeMethods.VARIANT val;
}
- ///
[StructLayout(LayoutKind.Sequential)]
public struct TF_PRESERVEDKEY
{
- ///
public int vKey;
- ///
public int modifiers;
}
- ///
[StructLayout(LayoutKind.Sequential)]
public struct TF_DA_COLOR
{
- ///
public TF_DA_COLORTYPE type;
- ///
public Int32 indexOrColorRef; // TF_CT_SYSCOLOR/TF_CT_COLORREF union
}
-
- ///
+
[StructLayout(LayoutKind.Sequential)]
public struct TF_DISPLAYATTRIBUTE
{
- ///
- public TF_DA_COLOR crText;
- ///
- public TF_DA_COLOR crBk;
- ///
+ public TF_DA_COLOR crText;
+ public TF_DA_COLOR crBk;
public TF_DA_LINESTYLE lsStyle;
- ///
[MarshalAs(UnmanagedType.Bool)]
- public bool fBoldLine;
- ///
- public TF_DA_COLOR crLine;
- ///
- public TF_DA_ATTR_INFO bAttr;
+ public bool fBoldLine;
+ public TF_DA_COLOR crLine;
+ public TF_DA_ATTR_INFO bAttr;
}
- ///
[StructLayout(LayoutKind.Sequential)]
public struct TF_RENDERINGMARKUP
{
- ///
public ITfRange range;
- ///
public TF_DISPLAYATTRIBUTE tfDisplayAttr;
}
- ///
[StructLayout(LayoutKind.Sequential)]
internal struct TF_LANGUAGEPROFILE
{
@@ -904,15 +382,6 @@ internal struct TF_LANGUAGEPROFILE
internal Guid guidProfile; // profile description
}
-
- #endregion Structs
-
- //------------------------------------------------------
- //
- // Interfaces
- //
- //------------------------------------------------------
-
#region Interfaces
[ComImport]
@@ -926,7 +395,6 @@ internal interface ITfMessagePump
// [in] UINT wMsgFilterMax,
// [in] UINT wRemoveMsg,
// [out] BOOL *pfResult);
- ///
void PeekMessageA(ref System.Windows.Interop.MSG msg,
IntPtr hwnd,
int msgFilterMin,
@@ -939,7 +407,6 @@ void PeekMessageA(ref System.Windows.Interop.MSG msg,
// [in] UINT wMsgFilterMin,
// [in] UINT wMsgFilterMax,
// [out] BOOL *pfResult);
- ///
void GetMessageA(ref System.Windows.Interop.MSG msg,
IntPtr hwnd,
int msgFilterMin,
@@ -952,7 +419,6 @@ void GetMessageA(ref System.Windows.Interop.MSG msg,
// [in] UINT wMsgFilterMax,
// [in] UINT wRemoveMsg,
// [out] BOOL *pfResult);
- ///
void PeekMessageW(ref System.Windows.Interop.MSG msg,
IntPtr hwnd,
int msgFilterMin,
@@ -965,7 +431,6 @@ void PeekMessageW(ref System.Windows.Interop.MSG msg,
// [in] UINT wMsgFilterMin,
// [in] UINT wMsgFilterMax,
// [out] BOOL *pfResult);
- ///
void GetMessageW(ref System.Windows.Interop.MSG msg,
IntPtr hwnd,
int msgFilterMin,
@@ -973,59 +438,49 @@ void GetMessageW(ref System.Windows.Interop.MSG msg,
out int result);
};
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("e2449660-9542-11d2-bf46-00105a2799b5")]
public interface ITfProperty /* : ITfReadOnlyProperty */
{
- ///
//HRESULT GetType([out] GUID *pguid);
void GetType(out Guid type);
- ///
//HRESULT EnumRanges([in] TfEditCookie ec,
// [out] IEnumTfRanges **ppEnum,
// [in] ITfRange *pTargetRange);
[PreserveSig]
int EnumRanges(int editcookie, out IEnumTfRanges ranges, ITfRange targetRange);
- ///
//HRESULT GetValue([in] TfEditCookie ec,
// [in] ITfRange *pRange,
// [out] VARIANT *pvarValue);
void GetValue(int editCookie, ITfRange range, out object value);
- ///
//HRESULT GetContext([out] ITfContext **ppContext);
void GetContext(out ITfContext context);
- ///
//HRESULT FindRange([in] TfEditCookie ec,
// [in] ITfRange *pRange,
// [out] ITfRange **ppRange,
// [in] TfAnchor aPos);
void FindRange(int editCookie, ITfRange inRange, out ITfRange outRange, TfAnchor position);
- ///
//HRESULT SetValueStore([in] TfEditCookie ec,
// [in] ITfRange *pRange,
// [in] ITfPropertyStore *pPropStore);
void stub_SetValueStore();
- ///
//HRESULT SetValue([in] TfEditCookie ec,
// [in] ITfRange *pRange,
// [in] const VARIANT *pvarValue);
void SetValue(int editCookie, ITfRange range, object value);
- ///
//HRESULT Clear([in] TfEditCookie ec,
// [in] ITfRange *pRange);
void Clear(int editCookie, ITfRange range);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("aa80e7fd-2021-11d2-93e0-0060b067b86e")]
@@ -1037,14 +492,14 @@ public interface ITfContext
//const DWORD TF_ES_READWRITE = 0x6;
//const DWORD TF_ES_ASYNC = 0x8;
- ///
+
//HRESULT RequestEditSession([in] TfClientId tid,
// [in] ITfEditSession *pes,
// [in] DWORD dwFlags,
// [out] HRESULT *phrSession);
int stub_RequestEditSession();
- ///
+
//HRESULT InWriteSession([in] TfClientId tid,
// [out] BOOL *pfWriteSession);
void InWriteSession(int clientId, [MarshalAs(UnmanagedType.Bool)] out bool inWriteSession);
@@ -1065,7 +520,7 @@ public interface ITfContext
//const ULONG TF_DEFAULT_SELECTION = TS_DEFAULT_SELECTION;
- ///
+
//HRESULT GetSelection([in] TfEditCookie ec,
// [in] ULONG ulIndex,
// [in] ULONG ulCount,
@@ -1073,7 +528,7 @@ public interface ITfContext
// [out] ULONG *pcFetched);
void stub_GetSelection();
- ///
+
//HRESULT SetSelection([in] TfEditCookie ec,
// [in] ULONG ulCount,
// [in, size_is(ulCount)] const TF_SELECTION *pSelection);
@@ -1081,10 +536,10 @@ public interface ITfContext
//HRESULT GetStart([in] TfEditCookie ec,
// [out] ITfRange **ppStart);
- ///
+
void GetStart(int ec, out ITfRange range);
- ///
+
//HRESULT GetEnd([in] TfEditCookie ec,
// [out] ITfRange **ppEnd);
void stub_GetEnd();
@@ -1099,15 +554,15 @@ public interface ITfContext
//typedef [uuid(bc7d979a-846a-444d-afef-0a9bfa82b961)] TS_STATUS TF_STATUS;
- ///
+
//HRESULT GetActiveView([out] ITfContextView **ppView);
void stub_GetActiveView();
- ///
+
//HRESULT EnumViews([out] IEnumTfContextViews **ppEnum);
void stub_EnumViews();
-
- ///
+
+
//HRESULT GetStatus([out] TF_STATUS *pdcs);
void stub_GetStatus();
@@ -1115,12 +570,12 @@ public interface ITfContext
// [out] ITfProperty **ppProp);
void GetProperty(ref Guid guid, out ITfProperty property);
- ///
+
//HRESULT GetAppProperty([in] REFGUID guidProp,
// [out] ITfReadOnlyProperty **ppProp);
void stub_GetAppProperty();
- ///
+
//HRESULT TrackProperties([in, size_is(cProp)] const GUID **prgProp,
// [in] ULONG cProp,
// [in, size_is(cAppProp)] const GUID **prgAppProp,
@@ -1128,28 +583,26 @@ public interface ITfContext
// [out] ITfReadOnlyProperty **ppProperty);
void stub_TrackProperties();
- ///
+
//HRESULT EnumProperties([out] IEnumTfProperties **ppEnum);
void stub_EnumProperties();
- ///
+
//HRESULT GetDocumentMgr([out] ITfDocumentMgr **ppDm);
void stub_GetDocumentMgr();
- ///
+
//HRESULT CreateRangeBackup([in] TfEditCookie ec,
// [in] ITfRange *pRange,
// [out] ITfRangeBackup **ppBackup);
void stub_CreateRangeBackup();
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("aa80e7f4-2021-11d2-93e0-0060b067b86e")]
public interface ITfDocumentMgr
{
- //
//HRESULT CreateContext([in] TfClientId tidOwner,
// [in] DWORD dwFlags,
// [in, unique] IUnknown *punk,
@@ -1157,28 +610,22 @@ public interface ITfDocumentMgr
// [out] TfEditCookie *pecTextStore);
void CreateContext(int clientId, CreateContextFlags flags, [MarshalAs(UnmanagedType.Interface)] object obj, out ITfContext context, out int editCookie);
- //
//HRESULT Push([in] ITfContext *pic);
void Push(ITfContext context);
- //
//HRESULT Pop([in] DWORD dwFlags);
void Pop(PopFlags flags);
- ///
//HRESULT GetTop([out] ITfContext **ppic);
void GetTop(out ITfContext context);
//HRESULT GetBase([out] ITfContext **ppic);
- ///
void GetBase(out ITfContext context);
- ///
//HRESULT EnumContexts([out] IEnumTfContexts **ppEnum);
void EnumContexts([MarshalAs(UnmanagedType.Interface)] out /*IEnumTfContexts*/ object enumContexts);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("aa80e808-2021-11d2-93e0-0060b067b86e")]
@@ -1186,123 +633,93 @@ public interface IEnumTfDocumentMgrs
{
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("101d6610-0990-11d3-8df0-00105a2799b5")]
public interface ITfFunctionProvider
{
- ///
+
//HRESULT GetType([out] GUID *pguid);
void GetType(out Guid guid);
- ///
+
//HRESULT GetDescription([out] BSTR *pbstrDesc);
void GetDescription([MarshalAs(UnmanagedType.BStr)] out string desc);
// HRESULT GetFunction([in] REFGUID rguid,
// [in] REFIID riid,
// [out, iid_is(riid)] IUnknown **ppunk);
- ///
+
[PreserveSig]
int GetFunction(ref Guid guid, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out object obj);
}
- ///
- [ComImport]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- [Guid("db593490-098f-11d3-8df0-00105a2799b5")]
- public interface ITfFunction
- {
- ///
- //HRESULT GetDisplayName([out] BSTR *pbstrName);
- void GetDisplayName([MarshalAs(UnmanagedType.BStr)] out string funcName );
- }
-
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("581f317e-fd9d-443f-b972-ed00467c5d40")]
public interface ITfCandidateString
{
// HRESULT GetString([out] BSTR *pbstr);
- ///
- void GetString([MarshalAs(UnmanagedType.BStr)] out string funcName );
+ void GetString([MarshalAs(UnmanagedType.BStr)] out string funcName);
- ///
// HRESULT GetIndex([out] ULONG *pnIndex);
- void GetIndex(out int nIndex );
+ void GetIndex(out int nIndex);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("a3ad50fb-9bdb-49e3-a843-6c76520fbf5d")]
public interface ITfCandidateList
{
- ///
// HRESULT EnumCandidates([out] IEnumTfCandidates **ppEnum);
void EnumCandidates(out object enumCand);
// HRESULT GetCandidate([in] ULONG nIndex,
// [out] ITfCandidateString **ppCand);
- ///
void GetCandidate(int nIndex, out ITfCandidateString candstring);
// HRESULT GetCandidateNum([out] ULONG *pnCnt);
- ///
void GetCandidateNum(out int nCount);
-
// HRESULT SetResult([in] ULONG nIndex,
// [in] TfCandidateResult imcr);
- ///
void SetResult(int nIndex, TfCandidateResult result);
}
-
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("4cea93c0-0a58-11d3-8df0-00105a2799b5")]
public interface ITfFnReconversion
{
- ///
// HRESULT GetDisplayName([out] BSTR *pbstrName);
- void GetDisplayName([MarshalAs(UnmanagedType.BStr)] out string funcName );
+ void GetDisplayName([MarshalAs(UnmanagedType.BStr)] out string funcName);
// HRESULT QueryRange([in] ITfRange *pRange,
// [in, out, unique] ITfRange **ppNewRange,
// [out] BOOL *pfConvertable);
- ///
[PreserveSig]
- int QueryRange(ITfRange range,
- out ITfRange newRange,
+ int QueryRange(ITfRange range,
+ out ITfRange newRange,
[MarshalAs(UnmanagedType.Bool)] out bool isConvertable);
// HRESULT GetReconversion([in] ITfRange *pRange,
// [out] ITfCandidateList **ppCandList);
- ///
[PreserveSig]
int GetReconversion(ITfRange range, out ITfCandidateList candList);
- ///
/// HRESULT Reconvert([in] ITfRange *pRange);
[PreserveSig]
int Reconvert(ITfRange range);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("88f567c6-1757-49f8-a1b2-89234c1eeff9")]
public interface ITfFnConfigure
{
- ///
// HRESULT GetDisplayName([out] BSTR *pbstrName);
- void GetDisplayName([MarshalAs(UnmanagedType.BStr)] out string funcName );
+ void GetDisplayName([MarshalAs(UnmanagedType.BStr)] out string funcName);
- ///
// HRESULT Show([in] HWND hwndParent,
// [in] LANGID langid,
// [in] REFGUID rguidProfile);
@@ -1310,99 +727,25 @@ public interface ITfFnConfigure
int Show(IntPtr hwndParent, short langid, ref Guid guidProfile);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("bb95808a-6d8f-4bca-8400-5390b586aedf")]
public interface ITfFnConfigureRegisterWord
{
- ///
// HRESULT GetDisplayName([out] BSTR *pbstrName);
- void GetDisplayName([MarshalAs(UnmanagedType.BStr)] out string funcName );
+ void GetDisplayName([MarshalAs(UnmanagedType.BStr)] out string funcName);
- ///
// HRESULT Show([in] HWND hwndParent,
// [in] LANGID langid,
// [in] REFGUID rguidProfile,
// [in, unique] BSTR bstrRegistered);
[PreserveSig]
- int Show(IntPtr hwndParent,
- short langid,
+ int Show(IntPtr hwndParent,
+ short langid,
ref Guid guidProfile,
- [MarshalAs(UnmanagedType.BStr)] string bstrRegistered );
+ [MarshalAs(UnmanagedType.BStr)] string bstrRegistered);
}
-
- #region SpeechCommands
-
-#if UNUSED
- ///
- //
- // Speech command provider and related interfaces
- //
- [ComImport]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- [Guid("8c5dac4f-083c-4b85-a4c9-71746048adca")]
- public interface IEnumSpeechCommands
- {
- ///
- //HRESULT Clone([out] IEnumSpeechCommands **ppEnum);
- void Clone([MarshalAs(UnmanagedType.Interface)] out object obj);
-
- ///
- //HRESULT Next([in] ULONG ulCount,
- // [out, size_is(ulCount), length_is(*pcFetched)] WCHAR **pSpCmds,
- // [out] ULONG *pcFetched);
- [PreserveSig]
- int Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] string [] spCmds, out int fetched);
-
- ///
- //HRESULT Reset();
- void Reset();
-
- ///
- //HRESULT Skip(ULONG ulCount);
- [PreserveSig]
- int Skip(int count);
- }
-
- ///
- [ComImport]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- [Guid("38e09d4c-586d-435a-b592-c8a86691dec6")]
- public interface ISpeechCommandProvider
- {
- ///
- //HRESULT EnumSpeechCommands([in] LANGID langid, [out] IEnumSpeechCommands **ppEnum);
- void EnumSpeechCommands(short langid, [MarshalAs(UnmanagedType.Interface)] out object obj);
-
- ///
- //HRESULT ProcessCommand([in, size_is(cch)] const WCHAR *pszCommand,
- // [in] ULONG cch,
- // [in] LANGID langid);
- void ProcessCommand([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] char []command, int cch, short langid);
- }
-
- ///
- [ComImport]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- [Guid("fca6c349-a12f-43a3-8dd6-5a5a4282577b")]
- public interface ITfFnCustomSpeechCommand
- {
- ///
- // ITfFunction method
- void GetDisplayName([MarshalAs(UnmanagedType.BStr)] out string funcName );
-
- ///
- //HRESULT SetSpeechCommandProvider([in] ISpeechCommandProvider *pspcmdProvider);
- void SetSpeechCommandProvider([MarshalAs(UnmanagedType.Interface)] object obj /*ISpeechCommandProvider spcmdProvider*/);
- }
-
-#endif // UNUSED
-
- #endregion SpeechCommands
-
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("e4b24db0-0990-11d3-8df0-00105a2799b5")]
@@ -1410,34 +753,28 @@ public interface IEnumTfFunctionProviders
{
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("bb08f7a9-607a-4384-8623-056892b64371")]
public interface ITfCompartment
{
- //
//HRESULT SetValue([in] TfClientId tid,
// [in] const VARIANT *pvarValue);
[PreserveSig]
int SetValue(int tid, ref object varValue);
-
- ///
+
void GetValue(out object varValue);
}
-
- ///
+
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("743abd5f-f26d-48df-8cc5-238492419b64")]
public interface ITfCompartmentEventSink
{
- ///
//HRESULT OnChange([in] REFGUID rguid);
void OnChange(ref Guid rguid);
}
-
- ///
+
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("7dcf57ac-18ad-438b-824d-979bffb74b7c")]
@@ -1448,97 +785,79 @@ public interface ITfCompartmentMgr
// [out] ITfCompartment **ppcomp);
void GetCompartment(ref Guid guid, out ITfCompartment comp);
- ///
//HRESULT ClearCompartment([in] TfClientId tid,
// [in] REFGUID rguid);
void ClearCompartment(int tid, Guid guid);
- ///
//HRESULT EnumCompartments([out] IEnumGUID **ppEnum);
void EnumCompartments(out object /*IEnumGUID*/ enumGuid);
}
- ///
+
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("aa80e801-2021-11d2-93e0-0060b067b86e")]
internal interface ITfThreadMgr
{
- //
//HRESULT Activate([out] TfClientId *ptid);
void Activate(out int clientId);
- //
//HRESULT Deactivate();
void Deactivate();
- //
//HRESULT CreateDocumentMgr([out] ITfDocumentMgr **ppdim);
void CreateDocumentMgr(out ITfDocumentMgr docMgr);
- ///
//HRESULT EnumDocumentMgrs([out] IEnumTfDocumentMgrs **ppEnum);
void EnumDocumentMgrs(out IEnumTfDocumentMgrs enumDocMgrs);
- ///
//HRESULT GetFocus([out] ITfDocumentMgr **ppdimFocus);
void GetFocus(out ITfDocumentMgr docMgr);
- //
//HRESULT SetFocus([in] ITfDocumentMgr *pdimFocus);
void SetFocus(ITfDocumentMgr docMgr);
- ///
//HRESULT AssociateFocus([in] HWND hwnd,
// [in, unique] ITfDocumentMgr *pdimNew,
// [out] ITfDocumentMgr **ppdimPrev);
void AssociateFocus(IntPtr hwnd, ITfDocumentMgr newDocMgr, out ITfDocumentMgr prevDocMgr);
- ///
//HRESULT IsThreadFocus([out] BOOL *pfThreadFocus);
void IsThreadFocus([MarshalAs(UnmanagedType.Bool)] out bool isFocus);
//HRESULT GetFunctionProvider([in] REFCLSID clsid,
// [out] ITfFunctionProvider **ppFuncProv);
- ///
[PreserveSig]
int GetFunctionProvider(ref Guid classId, out ITfFunctionProvider funcProvider);
- ///
//HRESULT EnumFunctionProviders([out] IEnumTfFunctionProviders **ppEnum);
void EnumFunctionProviders(out IEnumTfFunctionProviders enumProviders);
//HRESULT GetGlobalCompartment([out] ITfCompartmentMgr **ppCompMgr);
- ///
void GetGlobalCompartment(out ITfCompartmentMgr compartmentMgr);
}
- ///
+
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("28888fe3-c2a0-483a-a3ea-8cb1ce51ff3d")]
public interface ITextStoreACP
{
- ///
//HRESULT AdviseSink([in] REFIID riid,
// [in, iid_is(riid)] IUnknown *punk,
// [in] DWORD dwMask);
void AdviseSink(ref Guid riid, [MarshalAs(UnmanagedType.Interface)] object obj, AdviseFlags flags);
- ///
//HRESULT UnadviseSink([in] IUnknown *punk);
void UnadviseSink([MarshalAs(UnmanagedType.Interface)] object obj);
-
- ///
+
//HRESULT RequestLock([in] DWORD dwLockFlags,
// [out] HRESULT *phrSession);
void RequestLock(LockFlags flags, out int hrSession);
- ///
//HRESULT GetStatus([out] TS_STATUS *pdcs);
void GetStatus(out TS_STATUS status);
- ///
//HRESULT QueryInsert([in] LONG acpTestStart,
// [in] LONG acpTestEnd,
// [in] ULONG cch,
@@ -1546,19 +865,16 @@ public interface ITextStoreACP
// [out] LONG *pacpResultEnd);
void QueryInsert(int start, int end, int cch, out int startResult, out int endResult);
- ///
//HRESULT GetSelection([in] ULONG ulIndex,
// [in] ULONG ulCount,
// [out, size_is(ulCount), length_is(*pcFetched)] TS_SELECTION_ACP *pSelection,
// [out] ULONG *pcFetched);
- void GetSelection(int index, int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] TS_SELECTION_ACP []selection, out int fetched);
+ void GetSelection(int index, int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] TS_SELECTION_ACP[] selection, out int fetched);
- ///
//HRESULT SetSelection([in] ULONG ulCount,
// [in, size_is(ulCount)] const TS_SELECTION_ACP *pSelection);
- void SetSelection(int count, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] TS_SELECTION_ACP []selection);
+ void SetSelection(int count, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] TS_SELECTION_ACP[] selection);
- ///
//HRESULT GetText([in] LONG acpStart,
// [in] LONG acpEnd,
// [out, size_is(cchPlainReq), length_is(*pcchPlainRet)] WCHAR *pchPlain,
@@ -1569,13 +885,12 @@ public interface ITextStoreACP
// [out] ULONG *pcRunInfoRet,
// [out] LONG *pacpNext);
void GetText(int start, int end,
- [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] char []text,
- int cchReq, out int charsCopied,
- [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=6)] TS_RUNINFO []runInfo,
+ [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] char[] text,
+ int cchReq, out int charsCopied,
+ [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] TS_RUNINFO[] runInfo,
int cRunInfoReq, out int cRunInfoRcv,
out int nextCp);
- ///
//HRESULT SetText([in] DWORD dwFlags,
// [in] LONG acpStart,
// [in] LONG acpEnd,
@@ -1583,29 +898,25 @@ void GetText(int start, int end,
// [in] ULONG cch,
// [out] TS_TEXTCHANGE *pChange);
void SetText(SetTextFlags flags, int start, int end,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=4)] char []text,
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] char[] text,
int cch, out TS_TEXTCHANGE change);
- ///
//HRESULT GetFormattedText([in] LONG acpStart,
// [in] LONG acpEnd,
// [out] IDataObject **ppDataObject);
void GetFormattedText(int start, int end, [MarshalAs(UnmanagedType.Interface)] out object obj);
- ///
//HRESULT GetEmbedded([in] LONG acpPos,
// [in] REFGUID rguidService,
// [in] REFIID riid,
// [out, iid_is(riid)] IUnknown **ppunk);
void GetEmbedded(int position, ref Guid guidService, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out object obj);
- ///
//HRESULT QueryInsertEmbedded([in] const GUID *pguidService,
// [in] const FORMATETC *pFormatEtc,
// [out] BOOL *pfInsertable);
void QueryInsertEmbedded(ref Guid guidService, IntPtr /*ref Win32.FORMATETC*/ formatEtc, [MarshalAs(UnmanagedType.Bool)] out bool insertable);
- ///
//HRESULT InsertEmbedded([in] DWORD dwFlags,
// [in] LONG acpStart,
// [in] LONG acpEnd,
@@ -1613,7 +924,6 @@ void SetText(SetTextFlags flags, int start, int end,
// [out] TS_TEXTCHANGE *pChange);
void InsertEmbedded(InsertEmbeddedFlags flags, int start, int end, [MarshalAs(UnmanagedType.Interface)] object obj, out TS_TEXTCHANGE change);
- ///
//HRESULT InsertTextAtSelection([in] DWORD dwFlags,
// [in, size_is(cch)] const WCHAR *pchText,
// [in] ULONG cch,
@@ -1621,11 +931,10 @@ void SetText(SetTextFlags flags, int start, int end,
// [out] LONG *pacpEnd,
// [out] TS_TEXTCHANGE *pChange);
void InsertTextAtSelection(InsertAtSelectionFlags flags,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] char []text,
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] char[] text,
int cch,
out int start, out int end, out TS_TEXTCHANGE change);
- ///
//HRESULT InsertEmbeddedAtSelection([in] DWORD dwFlags,
// [in] IDataObject *pDataObject,
// [out] LONG *pacpStart,
@@ -1634,34 +943,30 @@ void InsertTextAtSelection(InsertAtSelectionFlags flags,
void InsertEmbeddedAtSelection(InsertAtSelectionFlags flags, [MarshalAs(UnmanagedType.Interface)] object obj,
out int start, out int end, out TS_TEXTCHANGE change);
- ///
//HRESULT RequestSupportedAttrs([in] DWORD dwFlags,
// [in] ULONG cFilterAttrs,
// [in, size_is(cFilterAttrs), unique] const TS_ATTRID *paFilterAttrs);
[PreserveSig]
int RequestSupportedAttrs(AttributeFlags flags, int count,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] Guid []filterAttributes);
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Guid[] filterAttributes);
- ///
//HRESULT RequestAttrsAtPosition([in] LONG acpPos,
// [in] ULONG cFilterAttrs,
// [in, size_is(cFilterAttrs), unique] const TS_ATTRID *paFilterAttrs,
// [in] DWORD dwFlags);
[PreserveSig]
int RequestAttrsAtPosition(int position, int count,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] Guid []filterAttributes,
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Guid[] filterAttributes,
AttributeFlags flags);
- ///
//HRESULT RequestAttrsTransitioningAtPosition([in] LONG acpPos,
// [in] ULONG cFilterAttrs,
// [in, size_is(cFilterAttrs), unique] const TS_ATTRID *paFilterAttrs,
// [in] DWORD dwFlags);
void RequestAttrsTransitioningAtPosition(int position, int count,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] Guid []filterAttributes,
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Guid[] filterAttributes,
AttributeFlags flags);
- ///
//HRESULT FindNextAttrTransition([in] LONG acpStart,
// [in] LONG acpHalt,
// [in] ULONG cFilterAttrs,
@@ -1671,32 +976,27 @@ void RequestAttrsTransitioningAtPosition(int position, int count,
// [out] BOOL *pfFound,
// [out] LONG *plFoundOffset);
void FindNextAttrTransition(int start, int halt, int count,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] Guid []filterAttributes,
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Guid[] filterAttributes,
AttributeFlags flags, out int acpNext, [MarshalAs(UnmanagedType.Bool)] out bool found, out int foundOffset);
- ///
//HRESULT RetrieveRequestedAttrs([in] ULONG ulCount,
// [out, size_is(ulCount), length_is(*pcFetched)] TS_ATTRVAL *paAttrVals,
// [out] ULONG *pcFetched);
void RetrieveRequestedAttrs(int count,
- [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] TS_ATTRVAL []attributeVals,
+ [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] TS_ATTRVAL[] attributeVals,
out int countFetched);
- ///
//HRESULT GetEnd([out] LONG *pacp);
void GetEnd(out int end);
- ///
//HRESULT GetActiveView([out] TsViewCookie *pvcView);
void GetActiveView(out int viewCookie);
- ///
//HRESULT GetACPFromPoint([in] TsViewCookie vcView,
// [in] const POINT *ptScreen,
// [in] DWORD dwFlags, [out] LONG *pacp);
void GetACPFromPoint(int viewCookie, ref POINT point, GetPositionFromPointFlags flags, out int position);
- ///
//HRESULT GetTextExt([in] TsViewCookie vcView,
// [in] LONG acpStart,
// [in] LONG acpEnd,
@@ -1704,345 +1004,279 @@ void RetrieveRequestedAttrs(int count,
// [out] BOOL *pfClipped);
void GetTextExt(int viewCookie, int start, int end, out RECT rect, [MarshalAs(UnmanagedType.Bool)] out bool clipped);
- ///
//HRESULT GetScreenExt([in] TsViewCookie vcView,
// [out] RECT *prc);
void GetScreenExt(int viewCookie, out RECT rect);
- ///
//HRESULT GetWnd([in] TsViewCookie vcView,
// [out] HWND *phwnd);
void GetWnd(int viewCookie, out IntPtr hwnd);
};
- ///
+
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("22d44c94-a419-4542-a272-ae26093ececf")]
public interface ITextStoreACPSink
{
- ///
+
//HRESULT OnTextChange([in] DWORD dwFlags,
// [in] const TS_TEXTCHANGE *pChange);
void OnTextChange(OnTextChangeFlags flags, ref TS_TEXTCHANGE change);
- ///
//HRESULT OnSelectionChange();
void OnSelectionChange();
- ///
//HRESULT OnLayoutChange([in] TsLayoutCode lcode, [in] TsViewCookie vcView);
void OnLayoutChange(TsLayoutCode lcode, int viewCookie);
- ///
//HRESULT OnStatusChange([in] DWORD dwFlags);
void OnStatusChange(DynamicStatusFlags flags);
- ///
//HRESULT OnAttrsChange([in] LONG acpStart,
// [in] LONG acpEnd,
// [in] ULONG cAttrs,
// [in, size_is(cAttrs)] const TS_ATTRID *paAttrs);
void OnAttrsChange(int start, int end, int count, Guid[] attributes);
- ///
//HRESULT OnLockGranted([in] DWORD dwLockFlags);
[PreserveSig]
int OnLockGranted(LockFlags flags);
- ///
//HRESULT OnStartEditTransaction();
void OnStartEditTransaction();
- ///
//HRESULT OnEndEditTransaction();
void OnEndEditTransaction();
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("c0f1db0c-3a20-405c-a303-96b6010a885f")]
public interface ITfThreadFocusSink
{
- ///
//HRESULT OnSetThreadFocus();
void OnSetThreadFocus();
- ///
//HRESULT OnKillThreadFocus();
void OnKillThreadFocus();
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("4ea48a35-60ae-446f-8fd6-e6a8d82459f7")]
public interface ITfSource
{
- //
//HRESULT AdviseSink([in] REFIID riid,
// [in, iid_is(riid)] IUnknown *punk,
// [out] DWORD *pdwCookie);
void AdviseSink(ref Guid riid, [MarshalAs(UnmanagedType.Interface)] object obj, out int cookie);
//HRESULT UnadviseSink([in] DWORD dwCookie);
- ///
void UnadviseSink(int cookie);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("aa80e7f0-2021-11d2-93e0-0060b067b86e")]
public interface ITfKeystrokeMgr
{
- ///
//HRESULT AdviseKeyEventSink([in] TfClientId tid,
// [in] ITfKeyEventSink *pSink,
// [in] BOOL fForeground);
void AdviseKeyEventSink(int clientId, [MarshalAs(UnmanagedType.Interface)] object obj/*ITfKeyEventSink sink*/, [MarshalAs(UnmanagedType.Bool)] bool fForeground);
- ///
//HRESULT UnadviseKeyEventSink([in] TfClientId tid);
void UnadviseKeyEventSink(int clientId);
- ///
//HRESULT GetForeground([out] CLSID *pclsid);
void GetForeground(out Guid clsid);
- //
//HRESULT TestKeyDown([in] WPARAM wParam,
// [in] LPARAM lParam,
// [out] BOOL *pfEaten);
// int should be ok here, bit fields are well defined for this call as 32 bit, no pointers
void TestKeyDown(int wParam, int lParam, [MarshalAs(UnmanagedType.Bool)] out bool eaten);
- //
//HRESULT TestKeyUp([in] WPARAM wParam,
// [in] LPARAM lParam,
// [out] BOOL *pfEaten);
// int should be ok here, bit fields are well defined for this call as 32 bit, no pointers
void TestKeyUp(int wParam, int lParam, [MarshalAs(UnmanagedType.Bool)] out bool eaten);
- //
//HRESULT KeyDown([in] WPARAM wParam,
// [in] LPARAM lParam,
// [out] BOOL *pfEaten);
// int should be ok here, bit fields are well defined for this call as 32 bit, no pointers
void KeyDown(int wParam, int lParam, [MarshalAs(UnmanagedType.Bool)] out bool eaten);
- //
//HRESULT KeyUp([in] WPARAM wParam,
// [in] LPARAM lParam,
// [out] BOOL *pfEaten);
// int should be ok here, bit fields are well defined for this call as 32 bit, no pointers
void KeyUp(int wParam, int lParam, [MarshalAs(UnmanagedType.Bool)] out bool eaten);
- ///
//HRESULT GetPreservedKey([in] ITfContext *pic,
// [in] const TF_PRESERVEDKEY *pprekey,
// [out] GUID *pguid);
void GetPreservedKey(ITfContext context, ref TF_PRESERVEDKEY key, out Guid guid);
- ///
//HRESULT IsPreservedKey([in] REFGUID rguid,
// [in] const TF_PRESERVEDKEY *pprekey,
// [out] BOOL *pfRegistered);
void IsPreservedKey(ref Guid guid, ref TF_PRESERVEDKEY key, [MarshalAs(UnmanagedType.Bool)] out bool registered);
- ///
//HRESULT PreserveKey([in] TfClientId tid,
// [in] REFGUID rguid,
// [in] const TF_PRESERVEDKEY *prekey,
// [in, size_is(cchDesc)] const WCHAR *pchDesc,
// [in] ULONG cchDesc);
void PreserveKey(int clientId, ref Guid guid, ref TF_PRESERVEDKEY key,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=4)] char []desc, int descCount);
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] char[] desc, int descCount);
- ///
//HRESULT UnpreserveKey([in] REFGUID rguid,
// [in] const TF_PRESERVEDKEY *pprekey);
void UnpreserveKey(ref Guid guid, ref TF_PRESERVEDKEY key);
- ///
//HRESULT SetPreservedKeyDescription([in] REFGUID rguid,
// [in, size_is(cchDesc)] const WCHAR *pchDesc,
// [in] ULONG cchDesc);
void SetPreservedKeyDescription(ref Guid guid,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] char []desc, int descCount);
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] char[] desc, int descCount);
- ///
//HRESULT GetPreservedKeyDescription([in] REFGUID rguid,
// [out] BSTR *pbstrDesc);
void GetPreservedKeyDescription(ref Guid guid, [MarshalAs(UnmanagedType.BStr)] out string desc);
- ///
//HRESULT SimulatePreservedKey([in] ITfContext *pic,
// [in] REFGUID rguid,
// [out] BOOL *pfEaten);
void SimulatePreservedKey(ITfContext context, ref Guid guid, [MarshalAs(UnmanagedType.Bool)] out bool eaten);
};
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("aa80e7ff-2021-11d2-93e0-0060b067b86e")]
public interface ITfRange
{
- //const DWORD TF_HF_OBJECT = 1; // halt shift for TF_CHAR_EMBEDDED
- //const DWORD TF_TF_MOVESTART = 1; // update start anchor
- //const DWORD TF_TF_IGNOREEND = 2; // ignore the end anchor
- //const DWORD TF_ST_CORRECTION = 1; // the replacement is a transform of existing content (correction), not new content
- //const DWORD TF_IE_CORRECTION = 1;
-
- //typedef [uuid(49930d51-7d93-448c-a48c-fea5dac192b1)] struct TF_HALTCOND
- //{
- // ITfRange *pHaltRange; // halt shift if anchor encountered
- // TfAnchor aHaltPos; // ignored if pHaltRange == NULL
- // DWORD dwFlags; // TF_HF_*
- //} TF_HALTCOND;
-
//HRESULT GetText([in] TfEditCookie ec,
// [in] DWORD dwFlags,
// [out, size_is(cchMax), length_is(*pcch)] WCHAR *pchText,
// [in] ULONG cchMax,
// [out] ULONG *pcch);
- ///
void GetText(int ec, /*GetTextFlags*/int flags,
- [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] char []text,
+ [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] char[] text,
int countMax, out int count);
//HRESULT SetText([in] TfEditCookie ec,
// [in] DWORD dwFlags,
// [in, size_is(cch), unique] const WCHAR *pchText,
// [in] LONG cch);
- ///
void SetText(int ec, /*SetTextFlags*/ int flags,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] char []text,
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] char[] text,
int count);
//HRESULT GetFormattedText([in] TfEditCookie ec,
// [out] IDataObject **ppDataObject);
- ///
void GetFormattedText(int ec, [MarshalAs(UnmanagedType.Interface)] out object data);
//HRESULT GetEmbedded([in] TfEditCookie ec,
// [in] REFGUID rguidService,
// [in] REFIID riid,
// [out, iid_is(riid)] IUnknown **ppunk);
- ///
void GetEmbedded(int ec, ref Guid guidService, ref Guid iid, [MarshalAs(UnmanagedType.Interface)] out object obj);
//HRESULT InsertEmbedded([in] TfEditCookie ec,
// [in] DWORD dwFlags,
// [in] IDataObject *pDataObject);
- ///
void InsertEmbedded(int ec, int flags, [MarshalAs(UnmanagedType.Interface)] object data);
//HRESULT ShiftStart([in] TfEditCookie ec,
// [in] LONG cchReq,
// [out] LONG *pcch,
// [in, unique] const TF_HALTCOND *pHalt);
- ///
void ShiftStart(int ec, int count, out int result, IntPtr pHalt);
//HRESULT ShiftEnd([in] TfEditCookie ec,
// [in] LONG cchReq,
// [out] LONG *pcch,
// [in, unique] const TF_HALTCOND *pHalt);
- ///
void ShiftEnd(int ec, int count, out int result, IntPtr pHalt);
//HRESULT ShiftStartToRange([in] TfEditCookie ec,
// [in] ITfRange *pRange,
// [in] TfAnchor aPos);
- ///
void ShiftStartToRange(int ec, ITfRange range, TfAnchor position);
//HRESULT ShiftEndToRange([in] TfEditCookie ec,
// [in] ITfRange *pRange,
// [in] TfAnchor aPos);
- ///
void ShiftEndToRange(int ec, ITfRange range, TfAnchor position);
//HRESULT ShiftStartRegion([in] TfEditCookie ec,
// [in] TfShiftDir dir,
// [out] BOOL *pfNoRegion);
- ///
void ShiftStartRegion(int ec, TfShiftDir dir, [MarshalAs(UnmanagedType.Bool)] out bool noRegion);
//HRESULT ShiftEndRegion([in] TfEditCookie ec,
// [in] TfShiftDir dir,
// [out] BOOL *pfNoRegion);
- ///
void ShiftEndRegion(int ec, TfShiftDir dir, [MarshalAs(UnmanagedType.Bool)] out bool noRegion);
//HRESULT IsEmpty([in] TfEditCookie ec,
// [out] BOOL *pfEmpty);
- ///
void IsEmpty(int ec, [MarshalAs(UnmanagedType.Bool)] out bool empty);
//HRESULT Collapse([in] TfEditCookie ec,
// [in] TfAnchor aPos);
- ///
void Collapse(int ec, TfAnchor position);
//HRESULT IsEqualStart([in] TfEditCookie ec,
// [in] ITfRange *pWith,
// [in] TfAnchor aPos,
// [out] BOOL *pfEqual);
- ///
void IsEqualStart(int ec, ITfRange with, TfAnchor position, [MarshalAs(UnmanagedType.Bool)] out bool equal);
//HRESULT IsEqualEnd([in] TfEditCookie ec,
// [in] ITfRange *pWith,
// [in] TfAnchor aPos,
// [out] BOOL *pfEqual);
- ///
void IsEqualEnd(int ec, ITfRange with, TfAnchor position, [MarshalAs(UnmanagedType.Bool)] out bool equal);
//HRESULT CompareStart([in] TfEditCookie ec,
// [in] ITfRange *pWith,
// [in] TfAnchor aPos,
// [out] LONG *plResult);
- ///
void CompareStart(int ec, ITfRange with, TfAnchor position, out int result);
//HRESULT CompareEnd([in] TfEditCookie ec,
// [in] ITfRange *pWith,
// [in] TfAnchor aPos,
// [out] LONG *plResult);
- ///
void CompareEnd(int ec, ITfRange with, TfAnchor position, out int result);
//HRESULT AdjustForInsert([in] TfEditCookie ec,
// [in] ULONG cchInsert,
// [out] BOOL *pfInsertOk);
- ///
void AdjustForInsert(int ec, int count, [MarshalAs(UnmanagedType.Bool)] out bool insertOk);
//HRESULT GetGravity([out] TfGravity *pgStart,
// [out] TfGravity *pgEnd);
- ///
void GetGravity(out TfGravity start, out TfGravity end);
//HRESULT SetGravity([in] TfEditCookie ec,
// [in] TfGravity gStart,
// [in] TfGravity gEnd);
- ///
void SetGravity(int ec, TfGravity start, TfGravity end);
//HRESULT Clone([out] ITfRange **ppClone);
- ///
void Clone(out ITfRange clone);
//HRESULT GetContext([out] ITfContext **ppContext);
- ///
void GetContext(out ITfContext context);
};
- ///
+
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("057a6296-029b-4154-b79a-0d461d4ea94c")]
@@ -2053,210 +1287,176 @@ public interface ITfRangeACP /*: ITfRange*/ // derivation isn't working, calls t
// [out, size_is(cchMax), length_is(*pcch)] WCHAR *pchText,
// [in] ULONG cchMax,
// [out] ULONG *pcch);
- ///
void GetText(int ec, /*GetTextFlags*/int flags,
- [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] char []text,
+ [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] char[] text,
int countMax, out int count);
//HRESULT SetText([in] TfEditCookie ec,
// [in] DWORD dwFlags,
// [in, size_is(cch), unique] const WCHAR *pchText,
// [in] LONG cch);
- ///
void SetText(int ec, /*SetTextFlags*/ int flags,
- [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] char []text,
+ [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] char[] text,
int count);
//HRESULT GetFormattedText([in] TfEditCookie ec,
// [out] IDataObject **ppDataObject);
- ///
void GetFormattedText(int ec, [MarshalAs(UnmanagedType.Interface)] out object data);
//HRESULT GetEmbedded([in] TfEditCookie ec,
// [in] REFGUID rguidService,
// [in] REFIID riid,
// [out, iid_is(riid)] IUnknown **ppunk);
- ///
void GetEmbedded(int ec, ref Guid guidService, ref Guid iid, [MarshalAs(UnmanagedType.Interface)] out object obj);
//HRESULT InsertEmbedded([in] TfEditCookie ec,
// [in] DWORD dwFlags,
// [in] IDataObject *pDataObject);
- ///
void InsertEmbedded(int ec, int flags, [MarshalAs(UnmanagedType.Interface)] object data);
//HRESULT ShiftStart([in] TfEditCookie ec,
// [in] LONG cchReq,
// [out] LONG *pcch,
// [in, unique] const TF_HALTCOND *pHalt);
- ///
void ShiftStart(int ec, int count, out int result, IntPtr pHalt);
//HRESULT ShiftEnd([in] TfEditCookie ec,
// [in] LONG cchReq,
// [out] LONG *pcch,
// [in, unique] const TF_HALTCOND *pHalt);
- ///
void ShiftEnd(int ec, int count, out int result, IntPtr pHalt);
//HRESULT ShiftStartToRange([in] TfEditCookie ec,
// [in] ITfRange *pRange,
// [in] TfAnchor aPos);
- ///
void ShiftStartToRange(int ec, ITfRange range, TfAnchor position);
//HRESULT ShiftEndToRange([in] TfEditCookie ec,
// [in] ITfRange *pRange,
// [in] TfAnchor aPos);
- ///
void ShiftEndToRange(int ec, ITfRange range, TfAnchor position);
//HRESULT ShiftStartRegion([in] TfEditCookie ec,
// [in] TfShiftDir dir,
// [out] BOOL *pfNoRegion);
- ///
void ShiftStartRegion(int ec, TfShiftDir dir, [MarshalAs(UnmanagedType.Bool)] out bool noRegion);
//HRESULT ShiftEndRegion([in] TfEditCookie ec,
// [in] TfShiftDir dir,
// [out] BOOL *pfNoRegion);
- ///
void ShiftEndRegion(int ec, TfShiftDir dir, [MarshalAs(UnmanagedType.Bool)] out bool noRegion);
//HRESULT IsEmpty([in] TfEditCookie ec,
// [out] BOOL *pfEmpty);
- ///
void IsEmpty(int ec, [MarshalAs(UnmanagedType.Bool)] out bool empty);
//HRESULT Collapse([in] TfEditCookie ec,
// [in] TfAnchor aPos);
- ///
void Collapse(int ec, TfAnchor position);
//HRESULT IsEqualStart([in] TfEditCookie ec,
// [in] ITfRange *pWith,
// [in] TfAnchor aPos,
// [out] BOOL *pfEqual);
- ///
void IsEqualStart(int ec, ITfRange with, TfAnchor position, [MarshalAs(UnmanagedType.Bool)] out bool equal);
//HRESULT IsEqualEnd([in] TfEditCookie ec,
// [in] ITfRange *pWith,
// [in] TfAnchor aPos,
// [out] BOOL *pfEqual);
- ///
void IsEqualEnd(int ec, ITfRange with, TfAnchor position, [MarshalAs(UnmanagedType.Bool)] out bool equal);
//HRESULT CompareStart([in] TfEditCookie ec,
// [in] ITfRange *pWith,
// [in] TfAnchor aPos,
// [out] LONG *plResult);
- ///
void CompareStart(int ec, ITfRange with, TfAnchor position, out int result);
//HRESULT CompareEnd([in] TfEditCookie ec,
// [in] ITfRange *pWith,
// [in] TfAnchor aPos,
// [out] LONG *plResult);
- ///
void CompareEnd(int ec, ITfRange with, TfAnchor position, out int result);
//HRESULT AdjustForInsert([in] TfEditCookie ec,
// [in] ULONG cchInsert,
// [out] BOOL *pfInsertOk);
- ///
void AdjustForInsert(int ec, int count, [MarshalAs(UnmanagedType.Bool)] out bool insertOk);
//HRESULT GetGravity([out] TfGravity *pgStart,
// [out] TfGravity *pgEnd);
- ///
void GetGravity(out TfGravity start, out TfGravity end);
//HRESULT SetGravity([in] TfEditCookie ec,
// [in] TfGravity gStart,
// [in] TfGravity gEnd);
- ///
void SetGravity(int ec, TfGravity start, TfGravity end);
//HRESULT Clone([out] ITfRange **ppClone);
- ///
void Clone(out ITfRange clone);
//HRESULT GetContext([out] ITfContext **ppContext);
- ///
void GetContext(out ITfContext context);
//HRESULT GetExtent([out] LONG *pacpAnchor,
// [out] LONG *pcch);
- ///
void GetExtent(out int start, out int count);
//HRESULT SetExtent([in] LONG acpAnchor,
// [in] LONG cch);
- ///
void SetExtent(int start, int count);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("D7540241-F9A1-4364-BEFC-DBCD2C4395B7")]
public interface ITfCompositionView
{
//HRESULT GetOwnerClsid([out] CLSID *pclsid);
- ///
void GetOwnerClsid(out Guid clsid);
//HRESULT GetRange([out] ITfRange **ppRange);
- ///
void GetRange(out ITfRange range);
};
- ///
+
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("5F20AA40-B57A-4F34-96AB-3576F377CC79")]
public interface ITfContextOwnerCompositionSink
{
- ///
//HRESULT OnStartComposition([in] ITfCompositionView *pComposition,
// [out] BOOL *pfOk);
void OnStartComposition(ITfCompositionView view, [MarshalAs(UnmanagedType.Bool)] out bool ok);
- ///
//HRESULT OnUpdateComposition([in] ITfCompositionView *pComposition,
// [in] ITfRange *pRangeNew);
void OnUpdateComposition(ITfCompositionView view, ITfRange rangeNew);
- ///
//HRESULT OnEndComposition([in] ITfCompositionView *pComposition);
void OnEndComposition(ITfCompositionView view);
};
- ///
+
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("D40C8AAE-AC92-4FC7-9A11-0EE0E23AA39B")]
public interface ITfContextComposition
{
- ///
//HRESULT StartComposition([in] TfEditCookie ecWrite,
// [in] ITfRange *pCompositionRange,
// [in] ITfCompositionSink *pSink,
// [out] ITfComposition **ppComposition);
void StartComposition(int ecWrite, ITfRange range, [MarshalAs(UnmanagedType.Interface)] object /*ITfCompositionSink */sink, [MarshalAs(UnmanagedType.Interface)] out object /*ITfComposition */composition);
- ///
//HRESULT EnumCompositions([out] IEnumITfCompositionView **ppEnum);
void EnumCompositions([MarshalAs(UnmanagedType.Interface)] out IEnumITfCompositionView enumView);
- ///
//HRESULT FindComposition([in] TfEditCookie ecRead,
// [in] ITfRange *pTestRange,
// [out] IEnumITfCompositionView **ppEnum);
void FindComposition(int ecRead, ITfRange testRange, [MarshalAs(UnmanagedType.Interface)] out object /*IEnumITfCompositionView*/ enumView);
- ///
//HRESULT TakeOwnership([in] TfEditCookie ecWrite,
// [in] ITfCompositionView *pComposition,
// [in] ITfCompositionSink *pSink,
@@ -2265,30 +1465,25 @@ void TakeOwnership(int ecWrite, ITfCompositionView view, [MarshalAs(UnmanagedTyp
[MarshalAs(UnmanagedType.Interface)] out object /*ITfComposition*/ composition);
};
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("86462810-593B-4916-9764-19C08E9CE110")]
public interface ITfContextOwnerCompositionServices /*: ITfContextComposition*/
{
- ///
//HRESULT StartComposition([in] TfEditCookie ecWrite,
// [in] ITfRange *pCompositionRange,
// [in] ITfCompositionSink *pSink,
// [out] ITfComposition **ppComposition);
void StartComposition(int ecWrite, ITfRange range, [MarshalAs(UnmanagedType.Interface)] object /*ITfCompositionSink */sink, [MarshalAs(UnmanagedType.Interface)] out object /*ITfComposition */composition);
- ///
//HRESULT EnumCompositions([out] IEnumITfCompositionView **ppEnum);
void EnumCompositions([MarshalAs(UnmanagedType.Interface)] out object /*IEnumITfCompositionView*/ enumView);
- ///
//HRESULT FindComposition([in] TfEditCookie ecRead,
// [in] ITfRange *pTestRange,
// [out] IEnumITfCompositionView **ppEnum);
void FindComposition(int ecRead, ITfRange testRange, [MarshalAs(UnmanagedType.Interface)] out object /*IEnumITfCompositionView*/ enumView);
- ///
//HRESULT TakeOwnership([in] TfEditCookie ecWrite,
// [in] ITfCompositionView *pComposition,
// [in] ITfCompositionSink *pSink,
@@ -2296,80 +1491,63 @@ public interface ITfContextOwnerCompositionServices /*: ITfContextComposition*/
void TakeOwnership(int ecWrite, ITfCompositionView view, [MarshalAs(UnmanagedType.Interface)] object /*ITfCompositionSink */ sink,
[MarshalAs(UnmanagedType.Interface)] out object /*ITfComposition*/ composition);
- ///
//HRESULT TerminateComposition([in] ITfCompositionView *pComposition);
[PreserveSig]
int TerminateComposition(ITfCompositionView view);
};
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("5EFD22BA-7838-46CB-88E2-CADB14124F8F")]
internal interface IEnumITfCompositionView
{
- ///
//HRESULT Clone([out] IEnumTfRanges **ppEnum);
void Clone(out IEnumTfRanges ranges);
- ///
//HRESULT Next([in] ULONG ulCount,
// [out, size_is(ulCount), length_is(*pcFetched)] ITfRange **ppRange,
// [out] ULONG *pcFetched);
[PreserveSig]
- unsafe int Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] ITfCompositionView []compositionview, out int fetched);
+ unsafe int Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ITfCompositionView[] compositionview, out int fetched);
- ///
//HRESULT Reset();
void Reset();
- ///
//HRESULT Skip(ULONG ulCount);
[PreserveSig]
int Skip(int count);
}
- ///
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("f99d3f40-8e32-11d2-bf46-00105a2799b5")]
public interface IEnumTfRanges
{
//HRESULT Clone([out] IEnumTfRanges **ppEnum);
- ///
void Clone(out IEnumTfRanges ranges);
//HRESULT Next([in] ULONG ulCount,
// [out, size_is(ulCount), length_is(*pcFetched)] ITfRange **ppRange,
// [out] ULONG *pcFetched);
- ///
[PreserveSig]
- unsafe int Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] ITfRange []ranges, out int fetched);
+ unsafe int Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ITfRange[] ranges, out int fetched);
//HRESULT Reset();
- ///
void Reset();
//HRESULT Skip(ULONG ulCount);
- ///
[PreserveSig]
int Skip(int count);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("42d4d099-7c1a-4a89-b836-6c6f22160df0")]
public interface ITfEditRecord
{
- //const DWORD TF_GTP_INCL_TEXT = 0x1;
-
- ///
//HRESULT GetSelectionStatus([out] BOOL *pfChanged);
void GetSelectionStatus([MarshalAs(UnmanagedType.Bool)] out bool selectionChanged);
- ///
//HRESULT GetTextAndPropertyUpdates([in] DWORD dwFlags,
// [in, size_is(cProperties)] const GUID **prgProperties,
// [in] ULONG cProperties,
@@ -2378,89 +1556,52 @@ public interface ITfEditRecord
//
// Use "ref IntPtr" Temporarily.
// See the comment in InputMethodProperty.GetPropertyUpdate().
- //
unsafe void GetTextAndPropertyUpdates(int flags,
/*[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)]*/ /*Guid ** */ ref IntPtr properties,
int count,
out IEnumTfRanges ranges);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("8127d409-ccd3-4683-967a-b43d5b482bf7")]
public interface ITfTextEditSink
{
- ///
//HRESULT OnEndEdit([in] ITfContext *pic, [in] TfEditCookie ecReadOnly, [in] ITfEditRecord *pEditRecord);
void OnEndEdit(ITfContext context, int ecReadOnly, ITfEditRecord editRecord);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("8c03d21b-95a7-4ba0-ae1b-7fce12a72930")]
public interface IEnumTfRenderingMarkup
{
- ///
//HRESULT Clone([out] IEnumTfRenderingMarkup **ppClone);
void Clone(out IEnumTfRenderingMarkup clone);
- ///
//HRESULT Next([in] ULONG ulCount,
// [out, size_is(ulCount), length_is(*pcFetched)] TF_RENDERINGMARKUP *rgMarkup,
// [out] ULONG *pcFetched);
[PreserveSig]
- int Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] TF_RENDERINGMARKUP []markup, out int fetched);
+ int Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] TF_RENDERINGMARKUP[] markup, out int fetched);
- ///
//HRESULT Reset();
void Reset();
- ///
//HRESULT Skip([in] ULONG ulCount);
[PreserveSig]
int Skip(int count);
}
- ///
- [ComImport]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- [Guid("a305b1c0-c776-4523-bda0-7c5a2e0fef10")]
- public interface ITfContextRenderingMarkup
- {
- ///
- //HRESULT GetRenderingMarkup([in] TfEditCookie ec,
- // [in] DWORD dwFlags,
- // [in] ITfRange *pRangeCover,
- // [out] IEnumTfRenderingMarkup **ppEnum);
- void GetRenderingMarkup(int editCookie, GetRenderingMarkupFlags flags, ITfRange range, out IEnumTfRenderingMarkup enumMarkup);
-
- ///
- //HRESULT FindNextRenderingMarkup([in] TfEditCookie ec,
- // [in] DWORD dwFlags,
- // [in] ITfRange *pRangeQuery,
- // [in] TfAnchor tfAnchorQuery,
- // [out] ITfRange **ppRangeFound,
- // [out] TF_RENDERINGMARKUP *ptfRenderingMarkup);
- void FindNextRenderingMarkup(int editCookie, FindRenderingMarkupFlags flags,
- ITfRange queryRange, TfAnchor queryAnchor,
- out ITfRange foundRange, out TF_RENDERINGMARKUP foundMarkup);
- }
-
- ///
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("1F02B6C5-7842-4EE6-8A0B-9A24183A95CA")]
public interface ITfInputProcessorProfiles
{
// HRESULT Register([in] REFCLSID rclsid);
- ///
void stub_Register();
// HRESULT Unregister([in] REFCLSID rclsid);
- ///
void stub_Unregister();
// HRESULT AddLanguageProfile([in] REFCLSID rclsid,
@@ -2471,71 +1612,59 @@ public interface ITfInputProcessorProfiles
// [in, size_is(cchFile)] const WCHAR *pchIconFile,
// [in] ULONG cchFile,
// [in] ULONG uIconIndex);
- ///
void stub_AddLanguageProfile();
// HRESULT RemoveLanguageProfile([in] REFCLSID rclsid,
// [in] LANGID langid,
// [in] REFGUID guidProfile);
- ///
void stub_RemoveLanguageProfile();
// HRESULT EnumInputProcessorInfo([out] IEnumGUID **ppEnum);
- ///
void stub_EnumInputProcessorInfo();
// HRESULT GetDefaultLanguageProfile([in] LANGID langid,
// [in] REFGUID catid,
// [out] CLSID *pclsid,
// [out] GUID *pguidProfile);
- ///
void stub_GetDefaultLanguageProfile();
// HRESULT SetDefaultLanguageProfile([in] LANGID langid,
// [in] REFCLSID rclsid,
// [in] REFGUID guidProfiles);
- ///
void stub_SetDefaultLanguageProfile();
// HRESULT ActivateLanguageProfile([in] REFCLSID rclsid,
// [in] LANGID langid,
// [in] REFGUID guidProfiles);
- ///
void ActivateLanguageProfile(ref Guid clsid, short langid, ref Guid guidProfile);
// HRESULT GetActiveLanguageProfile([in] REFCLSID rclsid,
// [out] LANGID *plangid,
// [out] GUID *pguidProfile);
- ///
[PreserveSig]
int GetActiveLanguageProfile(ref Guid clsid, out short langid, out Guid profile);
-
+
// HRESULT GetLanguageProfileDescription([in] REFCLSID rclsid,
// [in] LANGID langid,
// [in] REFGUID guidProfile,
// [out] BSTR *pbstrProfile);
- ///
void stub_GetLanguageProfileDescription();
// HRESULT GetCurrentLanguage([out] LANGID *plangid);
- ///
void GetCurrentLanguage(out short langid);
// HRESULT ChangeCurrentLanguage([in] LANGID langid);
- ///
[PreserveSig]
int ChangeCurrentLanguage(short langid);
-
+
// HRESULT GetLanguageList([out] LANGID **ppLangId,
// [out] ULONG *pulCount);
- ///
[PreserveSig]
int GetLanguageList(out IntPtr langids, out int count);
-
+
// HRESULT EnumLanguageProfiles([in] LANGID langid,
// [out] IEnumTfLanguageProfiles **ppEnum);
- ///
void EnumLanguageProfiles(short langid, out IEnumTfLanguageProfiles enumIPP);
@@ -2543,123 +1672,100 @@ public interface ITfInputProcessorProfiles
// [in] LANGID langid,
// [in] REFGUID guidProfile,
// [in] BOOL fEnable);
- ///
void stub_EnableLanguageProfile();
// HRESULT IsEnabledLanguageProfile([in] REFCLSID rclsid,
// [in] LANGID langid,
// [in] REFGUID guidProfile,
// [out] BOOL *pfEnable);
- ///
void stub_IsEnabledLanguageProfile();
// HRESULT EnableLanguageProfileByDefault([in] REFCLSID rclsid,
// [in] LANGID langid,
// [in] REFGUID guidProfile,
// [in] BOOL fEnable);
- ///
void stub_EnableLanguageProfileByDefault();
// HRESULT SubstituteKeyboardLayout([in] REFCLSID rclsid,
// [in] LANGID langid,
// [in] REFGUID guidProfile,
// [in] HKL hKL);
- ///
void stub_SubstituteKeyboardLayout();
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("3d61bf11-ac5f-42c8-a4cb-931bcc28c744")]
internal interface IEnumTfLanguageProfiles
{
- ///
// HRESULT Clone([out] IEnumTfLanguageProfiles **ppEnum);
void Clone(out IEnumTfLanguageProfiles enumIPP);
- ///
// HRESULT Next([in] ULONG ulCount,
// [out, size_is(ulCount), length_is(*pcFetch)] TF_LANGUAGEPROFILE *pProfile,
// [out] ULONG *pcFetch);
[PreserveSig]
- int Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] TF_LANGUAGEPROFILE []profiles, out int fetched);
+ int Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] TF_LANGUAGEPROFILE[] profiles, out int fetched);
- ///
// HRESULT Reset();
void Reset();
- ///
// HRESULT Skip([in] ULONG ulCount);
void Skip(int count);
}
- ///
+
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("43c9fe15-f494-4c17-9de2-b8a4ac350aa8")]
public interface ITfLanguageProfileNotifySink
{
- ///
// HRESULT OnLanguageChange([in] LANGID langid,
// [out] BOOL *pfAccept);
void OnLanguageChange(short langid, [MarshalAs(UnmanagedType.Bool)] out bool bAccept);
- ///
// HRESULT OnLanguageChanged();
void OnLanguageChanged();
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("8ded7393-5db1-475c-9e71-a39111b0ff67")]
public interface ITfDisplayAttributeMgr
{
// HRESULT OnUpdateInfo();
- //
- ///
void OnUpdateInfo();
// HRESULT EnumDisplayAttributeInfo([out] IEnumTfDisplayAttributeInfo **ppEnum);
- ///
void stub_EnumDisplayAttributeInfo();
// HRESULT GetDisplayAttributeInfo([in] REFGUID guid,
// [out] ITfDisplayAttributeInfo **ppInfo,
// [out] CLSID *pclsidOwner);
- ///
void GetDisplayAttributeInfo(ref Guid guid, out ITfDisplayAttributeInfo info, out Guid clsid);
-}
+ }
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("70528852-2f26-4aea-8c96-215150578932")]
public interface ITfDisplayAttributeInfo
{
// HRESULT GetGUID([out] GUID *pguid);
- ///
void stub_GetGUID();
// HRESULT GetDescription([out] BSTR *pbstrDesc);
- ///
void stub_GetDescription();
// HRESULT GetAttributeInfo([out] TF_DISPLAYATTRIBUTE *pda);
- ///
void GetAttributeInfo(out TF_DISPLAYATTRIBUTE attr);
// HRESULT SetAttributeInfo([in] const TF_DISPLAYATTRIBUTE *pda);
- ///
void stub_SetAttributeInfo();
// HRESULT Reset();
- ///
void stub_Reset();
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("c3acefb5-f69d-4905-938f-fcadcf4be830")]
@@ -2668,170 +1774,104 @@ public interface ITfCategoryMgr
// HRESULT RegisterCategory([in] REFCLSID rclsid,
// [in] REFGUID rcatid,
// [in] REFGUID rguid);
- ///
void stub_RegisterCategory();
// HRESULT UnregisterCategory([in] REFCLSID rclsid,
// [in] REFGUID rcatid,
// [in] REFGUID rguid);
- ///
void stub_UnregisterCategory();
// HRESULT EnumCategoriesInItem([in] REFGUID rguid,
// [out] IEnumGUID **ppEnum);
- ///
void stub_EnumCategoriesInItem();
// HRESULT EnumItemsInCategory([in] REFGUID rcatid,
// [out] IEnumGUID **ppEnum);
- ///
void stub_EnumItemsInCategory();
// HRESULT FindClosestCategory([in] REFGUID rguid,
// [out] GUID *pcatid,
// [in, size_is(ulCount)] const GUID **ppcatidList,
// [in] ULONG ulCount);
- ///
void stub_FindClosestCategory();
// HRESULT RegisterGUIDDescription([in] REFCLSID rclsid,
// [in] REFGUID rguid,
// [in, size_is(cch)] const WCHAR *pchDesc,
// [in] ULONG cch);
- ///
void stub_RegisterGUIDDescription();
// HRESULT UnregisterGUIDDescription([in] REFCLSID rclsid,
// [in] REFGUID rguid);
- ///
void stub_UnregisterGUIDDescription();
// HRESULT GetGUIDDescription([in] REFGUID rguid,
// [out] BSTR *pbstrDesc);
- ///
void stub_GetGUIDDescription();
// HRESULT RegisterGUIDDWORD([in] REFCLSID rclsid,
// [in] REFGUID rguid,
// [in] DWORD dw);
- ///
void stub_RegisterGUIDDWORD();
// HRESULT UnregisterGUIDDWORD([in] REFCLSID rclsid,
// [in] REFGUID rguid);
- ///
void stub_UnregisterGUIDDWORD();
// HRESULT GetGUIDDWORD([in] REFGUID rguid,
// [out] DWORD *pdw);
- ///
void stub_GetGUIDDWORD();
// HRESULT RegisterGUID([in] REFGUID rguid,
// [out] TfGuidAtom *pguidatom);
- ///
void stub_RegisterGUID();
// HRESULT GetGUID([in] TfGuidAtom guidatom,
// [out] GUID *pguid);
- ///
[PreserveSig]
int GetGUID(Int32 guidatom, out Guid guid);
// HRESULT IsEqualTfGuidAtom([in] TfGuidAtom guidatom,
// [in] REFGUID rguid,
// [out] BOOL *pfEqual);
- ///
void stub_IsEqualTfGuidAtom();
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("aa80e80c-2021-11d2-93e0-0060b067b86e")]
public interface ITfContextOwner
{
- ///
// HRESULT GetACPFromPoint([in] const POINT *ptScreen,
// [in] DWORD dwFlags,
// [out] LONG *pacp);
void GetACPFromPoint(ref POINT point, GetPositionFromPointFlags flags, out int position);
- ///
// HRESULT GetTextExt([in] LONG acpStart,
// [in] LONG acpEnd,
// [out] RECT *prc,
// [out] BOOL *pfClipped);
void GetTextExt(int start, int end, out RECT rect, [MarshalAs(UnmanagedType.Bool)] out bool clipped);
- ///
// HRESULT GetScreenExt([out] RECT *prc);
void GetScreenExt(out RECT rect);
- ///
// HRESULT GetStatus([out] TF_STATUS *pdcs);
void GetStatus(out TS_STATUS status);
- ///
// HRESULT GetWnd([out] HWND *phwnd);
void GetWnd(out IntPtr hwnd);
- ///
// HRESULT GetAttribute([in] REFGUID rguidAttribute, [out] VARIANT *pvarValue);
void GetValue(ref Guid guidAttribute, out object varValue);
}
-
- ///
- [ComImport]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- [Guid("b23eb630-3e1c-11d3-a745-0050040ab407")]
- public interface ITfContextOwnerServices
- {
- ///
- // HRESULT OnLayoutChange();
- void stub_OnLayoutChange();
-
- ///
- // HRESULT OnStatusChange([in] DWORD dwFlags);
- void stub_OnStatusChange();
-
- ///
- // HRESULT OnAttributeChange([in] REFGUID rguidAttribute);
- void stub_OnAttributeChange();
-
- ///
- // HRESULT Serialize([in] ITfProperty *pProp,
- // [in] ITfRange *pRange,
- // [out] TF_PERSISTENT_PROPERTY_HEADER_ACP *pHdr,
- // [in] IStream *pStream);
- void stub_Serialize();
-
- ///
- // HRESULT Unserialize([in] ITfProperty *pProp,
- // [in] const TF_PERSISTENT_PROPERTY_HEADER_ACP *pHdr,
- // [in] IStream *pStream,
- // [in] ITfPersistentPropertyLoaderACP *pLoader);
- void stub_Unserialize();
-
- ///
- // HRESULT ForceLoadProperty([in] ITfProperty *pProp);
- void stub_ForceLoadProperty();
-
- ///
- // HRESULT CreateRange([in] LONG acpStart,
- // [in] LONG acpEnd,
- // [out] ITfRangeACP **ppRange);
- void CreateRange(Int32 acpStart, Int32 acpEnd, out ITfRangeACP range);
- }
-
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("a615096f-1c57-4813-8a15-55ee6e5a839c")]
public interface ITfTransitoryExtensionSink
{
- ///
+
// HRESULT OnTransitoryExtensionUpdated([in] ITfContext *pic,
// [in] TfEditCookie ecReadOnly,
// [in] ITfRange *pResultRange,
@@ -2840,60 +1880,49 @@ public interface ITfTransitoryExtensionSink
void OnTransitoryExtensionUpdated(ITfContext context, int ecReadOnly, ITfRange rangeResult, ITfRange rangeComposition, [MarshalAs(UnmanagedType.Bool)] out bool fDeleteResultRange);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("fde1eaee-6924-4cdf-91e7-da38cff5559d")]
public interface ITfInputScope
{
- ///
// HRESULT GetInputScopes([out] InputScope **pprgInputScopes,
// [out] UINT *pcCount);
void GetInputScopes(out IntPtr ppinputscopes, out int count);
- ///
// HRESULT GetPhrase([out] BSTR **ppbstrPhrases,
// [out] UINT *pcCount);
[PreserveSig]
int GetPhrase(out IntPtr ppbstrPhrases, out int count);
-
- ///
+
// HRESULT GetRegularExpression([out] BSTR *pbstrRegExp);
[PreserveSig]
int GetRegularExpression([Out, MarshalAs(UnmanagedType.BStr)] out string desc);
- ///
// HRESULT GetSRGS([out] BSTR *pbstrSRGS);
[PreserveSig]
int GetSRGC([Out, MarshalAs(UnmanagedType.BStr)] out string desc);
- ///
// HRESULT GetXML([out] BSTR *pbstrXML);
[PreserveSig]
int GetXML([Out, MarshalAs(UnmanagedType.BStr)] out string desc);
}
-
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("3bdd78e2-c16e-47fd-b883-ce6facc1a208")]
public interface ITfMouseTrackerACP
{
- ///
// HRESULT AdviseMouseSink([in] ITfRangeACP *range,
// [in] ITfMouseSink *pSink,
// [out] DWORD *pdwCookie);
[PreserveSig]
int AdviceMouseSink(ITfRangeACP range, ITfMouseSink sink, out int dwCookie);
- ///
// HRESULT UnadviseMouseSink([in] DWORD dwCookie);
[PreserveSig]
int UnadviceMouseSink(int dwCookie);
}
- ///
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("a1adaaa2-3a24-449d-ac96-5183e7f5c217")]
@@ -2903,7 +1932,7 @@ public interface ITfMouseSink
// [in] ULONG uQuadrant,
// [in] DWORD dwBtnStatus,
// [out] BOOL *pfEaten);
- ///
+
[PreserveSig]
int OnMouseEvent(int edge, int quadrant, int btnStatus, [MarshalAs(UnmanagedType.Bool)] out bool eaten);
}
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs b/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs
index 0e2505fbb3e..85e35e9025a 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs
@@ -35,6 +35,11 @@ internal static class BuildInfo
// ECMA PublicKeyToken
internal const string DEVDIV_PUBLIC_KEY_TOKEN = "b77a5c561934e089";
+ ///
+ /// The open key. The token is cc7b13ffcd2ddd51.
+ ///
+ public const string OpenPublicKey = "00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb";
+
// Constants to prevent hardcoding in InternalsVisibleTo attribute
internal const string DirectWriteForwarder = $"DirectWriteForwarder, PublicKey={WCP_PUBLIC_KEY_STRING}";
internal const string PresentationCore = $"PresentationCore, PublicKey={WCP_PUBLIC_KEY_STRING}";
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/AssemblyInfo.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/AssemblyInfo.cs
index 09ee8d39c8f..6b60d7486ca 100644
--- a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/AssemblyInfo.cs
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/AssemblyInfo.cs
@@ -22,3 +22,6 @@
[assembly: InternalsVisibleTo($"UIAutomationTypes, PublicKey={PublicKeys.MicrosoftShared}")]
[assembly: InternalsVisibleTo($"WindowsBase, PublicKey={PublicKeys.MicrosoftShared}")]
[assembly: InternalsVisibleTo($"WindowsFormsIntegration, PublicKey={PublicKeys.MicrosoftShared}")]
+
+[assembly: InternalsVisibleTo($"System.Windows.Primitives.Tests, PublicKey={PublicKeys.Open}")]
+[assembly: InternalsVisibleTo($"PresentationCore.Tests, PublicKey={PublicKeys.Open}")]
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/GlobalUsings.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/GlobalUsings.cs
new file mode 100644
index 00000000000..896c292cf1f
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/GlobalUsings.cs
@@ -0,0 +1,6 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+global using System;
+global using System.Diagnostics;
+global using System.Diagnostics.CodeAnalysis;
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/SR.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/SR.cs
new file mode 100644
index 00000000000..12945915c55
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/SR.cs
@@ -0,0 +1,20 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Globalization;
+using System.Runtime.CompilerServices;
+
+namespace System.Windows.Primitives.Resources;
+
+internal static partial class SR
+{
+ // The rest of this class is auto-generated. Normally, the following should also be generated, but it
+ // currently isn't. This may be related to building with the .NET Framework msbuild.
+
+ [AllowNull]
+ internal static CultureInfo Culture { get; set; }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal static string? GetResourceString(string resourceKey, string? defaultValue = null) =>
+ ResourceManager.GetString(resourceKey, Culture);
+}
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/SR.resx b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/SR.resx
new file mode 100644
index 00000000000..bf2ec77b805
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/SR.resx
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+ Back buffer's device is not valid.
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+ Back buffer's size is too large.
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+ The image has corrupted metadata header.
+
+
+ The stream is corrupted.
+
+
+ Codec added more than once.
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+ The system display state is not valid.
+
+
+ Duplicate copies of metadata present.
+
+
+ The image is missing a frame.
+
+
+ The image cannot be decoded. The image header might be corrupted.
+
+
+ Buffer size is not sufficient.
+
+
+ An error occurred.
+
+
+ Bitmap color context is not valid.
+
+
+ Character is not valid in metadata query request.
+
+
+ Metadata query request is not valid.
+
+
+ Windows Media Player version 10 or later is required.
+
+
+ The specified image does not contain a palette.
+
+
+ Bitmap does not contain thumbnail.
+
+
+ The image data generated an overflow during processing.
+
+
+ Property cannot be found.
+
+
+ This codec does not support the specified property.
+
+
+ Property is corrupted.
+
+
+ Unexpected property type or value.
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+ Cannot invert singular matrix.
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+ Metadata stream is not available for this operation.
+
+
+ Cannot read from the stream.
+
+
+ Cannot write to the stream.
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+ Unexpected type of metadata.
+
+
+ The image format is unrecognized.
+
+
+ Operation not supported.
+
+
+ Pixel format not supported.
+
+
+ Operation caused an invalid state.
+
+
+ Media file download failed.
+
+
+ Installed codecs do not support the media file format.
+
+
+ Cannot find the media file.
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+ Value does not fall within the expected range.
+
+
+ Access was denied on the media file.
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+ Unrecognized playlist file format.
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+ Object must be initialized before operation can be performed.
+
+
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.cs.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.cs.xlf
new file mode 100644
index 00000000000..d986f8c4487
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.cs.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.de.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.de.xlf
new file mode 100644
index 00000000000..930bf6b7594
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.de.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.es.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.es.xlf
new file mode 100644
index 00000000000..d571e845f2f
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.es.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.fr.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.fr.xlf
new file mode 100644
index 00000000000..95db89ca733
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.fr.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.it.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.it.xlf
new file mode 100644
index 00000000000..46809340772
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.it.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.ja.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.ja.xlf
new file mode 100644
index 00000000000..1d303e6ccde
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.ja.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.ko.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.ko.xlf
new file mode 100644
index 00000000000..f5261a66b19
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.ko.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.pl.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.pl.xlf
new file mode 100644
index 00000000000..9a209be7e00
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.pl.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.pt-BR.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.pt-BR.xlf
new file mode 100644
index 00000000000..6904e618174
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.pt-BR.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.ru.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.ru.xlf
new file mode 100644
index 00000000000..d4134f860e4
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.ru.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.tr.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.tr.xlf
new file mode 100644
index 00000000000..165aa900974
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.tr.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.zh-Hans.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.zh-Hans.xlf
new file mode 100644
index 00000000000..b6916fe7dcd
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.zh-Hans.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.zh-Hant.xlf b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.zh-Hant.xlf
new file mode 100644
index 00000000000..473e3e0e823
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Resources/xlf/SR.zh-Hant.xlf
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ An antialiased back buffer requires a IDirect3DDevice9Ex device.
+
+
+
+
+ Back buffer's device is not valid.
+
+
+
+
+ Back buffer's pool does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's usage does not meet the requirements for the resource type.
+
+
+
+
+ Back buffer's size is too large.
+
+
+
+
+ Arithmetic error found while trying to perform this operation.
+
+
+
+
+ The bitmap specified does not have the correct dimensions.
+
+
+
+
+
+ The stream is corrupted.
+
+
+
+
+ Codec added more than once.
+
+
+
+
+ No imaging component suitable to complete this operation was found.
+
+
+
+
+ The image decoder cannot decode the image. The image might be corrupted.
+
+
+
+
+ The system display state is not valid.
+
+
+
+
+ Duplicate copies of metadata present.
+
+
+
+
+ The image is missing a frame.
+
+
+
+
+
+ Buffer size is not sufficient.
+
+
+
+
+ An error occurred.
+
+
+
+
+ Bitmap color context is not valid.
+
+
+
+
+ Character is not valid in metadata query request.
+
+
+
+
+ Metadata query request is not valid.
+
+
+
+
+ The specified image does not contain a palette.
+
+
+
+
+ Bitmap does not contain thumbnail.
+
+
+
+
+ The image data generated an overflow during processing.
+
+
+
+
+ Property cannot be found.
+
+
+
+
+ This codec does not support the specified property.
+
+
+
+
+ Property is corrupted.
+
+
+
+
+ Unexpected property type or value.
+
+
+
+
+ The metadata query is valid only at the root of the metadata hierarchy.
+
+
+
+
+ Cannot invert singular matrix.
+
+
+
+
+ The image dimensions are out of the range supported by this codec.
+
+
+
+
+ Metadata stream is not available for this operation.
+
+
+
+
+ Cannot read from the stream.
+
+
+
+
+ Cannot write to the stream.
+
+
+
+
+ The bitmap has too many scanlines for the specified encoder.
+
+
+
+
+ Commit unsuccessful because too much metadata changed.
+
+
+
+
+ Unexpected type of metadata.
+
+
+
+
+ The image format is unrecognized.
+
+
+
+
+ Operation not supported.
+
+
+
+
+ Pixel format not supported.
+
+
+
+
+ Operation caused an invalid state.
+
+
+
+
+ Media file download failed.
+
+
+
+
+ Installed codecs do not support the media file format.
+
+
+
+
+ Cannot find the media file.
+
+
+
+
+ Display driver must support video acceleration for video or audio playback.
+
+
+
+
+ There are insufficient video resources available for video or audio playback.
+
+
+
+
+ Value does not fall within the expected range.
+
+
+
+
+ Windows Media Player version 10 or later is required.
+
+
+
+
+ Access was denied on the media file.
+
+
+
+
+ No operations are valid on a closed media player except open and close.
+
+
+
+
+ Unrecognized playlist file format.
+
+
+
+
+ Mismatched versions of PresentationCore.dll, Milcore.dll, WindowsCodecs.dll, or D3d9.dll. Check that these DLLs come from the same source.
+
+
+
+
+ Object must be initialized before operation can be performed.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/System.Windows.Primitives.csproj b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/System.Windows.Primitives.csproj
index b84ce21ef1b..dd9cbdbb13d 100644
--- a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/System.Windows.Primitives.csproj
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/System.Windows.Primitives.csproj
@@ -1,4 +1,4 @@
-
+
System.Windows.Primitives
@@ -22,6 +22,16 @@
true
+
+
+ System.Windows.Primitives.Resources.SR
+
+ System.Windows.Primitives.Resources.SR
+ true
+
+
+
+
@@ -29,6 +39,7 @@
+
false
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Windows/Win32/Foundation/D3dErrors.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Windows/Win32/Foundation/D3dErrors.cs
new file mode 100644
index 00000000000..ba20033ff0a
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Windows/Win32/Foundation/D3dErrors.cs
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using Windows.Win32.System.Diagnostics.Debug;
+
+namespace Windows.Win32.Foundation;
+
+#pragma warning disable IDE1006 // Naming Styles
+#pragma warning disable format
+
+internal static class D3dErrors
+{
+ // DirectX 9 specific defines aren't exposed in the Windows metadata (too old).
+ // Manually defining all of the codes that actually get used in the WPF codebase.
+
+ // https://learn.microsoft.com/windows/win32/direct3d9/d3derr
+
+ // Copied from d3d9.h
+
+ private const int _FACD3D = 0x876;
+
+ internal const FACILITY_CODE FacilityCode = (FACILITY_CODE)_FACD3D;
+
+ // MAKE_HRESULT definition:
+ //
+ // ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
+ private const int ErrorCode = unchecked((int)(((ulong)1 << 31) | ((ulong)(_FACD3D) << 16)));
+
+ internal static readonly HRESULT D3DERR_DEVICEHUNG = (HRESULT)(ErrorCode | 2164);
+ internal static readonly HRESULT D3DERR_DEVICELOST = (HRESULT)(ErrorCode | 2152);
+ internal static readonly HRESULT D3DERR_DEVICEREMOVED = (HRESULT)(ErrorCode | 2160);
+ internal static readonly HRESULT D3DERR_DRIVERINTERNALERROR = (HRESULT)(ErrorCode | 2087);
+ internal static readonly HRESULT D3DERR_INVALIDCALL = (HRESULT)(ErrorCode | 2156);
+ internal static readonly HRESULT D3DERR_NOTAVAILABLE = (HRESULT)(ErrorCode | 2154);
+ internal static readonly HRESULT D3DERR_OUTOFVIDEOMEMORY = (HRESULT)(ErrorCode | 380);
+ internal static readonly HRESULT D3DERR_WRONGTEXTUREFORMAT = (HRESULT)(ErrorCode | 2072);
+}
+
+#pragma warning restore IDE1006 // Naming Styles
+#pragma warning restore format
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Windows/Win32/Foundation/MilErrors.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Windows/Win32/Foundation/MilErrors.cs
new file mode 100644
index 00000000000..2f4bc2f2afb
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Windows/Win32/Foundation/MilErrors.cs
@@ -0,0 +1,201 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using Windows.Win32.System.Diagnostics.Debug;
+
+namespace Windows.Win32.Foundation;
+
+#pragma warning disable IDE1006 // Naming Styles
+#pragma warning disable format
+
+///
+/// MIL error codes. Note that these codes use the same facility code as WIC.
+///
+internal static class MilErrors
+{
+ // Copied from wgx_err.h
+
+ private const int FACILITY_WGX = (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM;
+
+ // MAKE_HRESULT definition:
+ //
+ // ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
+ private const int SuccessCode = (int)(((ulong)0 << 31) | ((ulong)(FACILITY_WGX) << 16));
+ private const int ErrorCode = unchecked((int)(((ulong)1 << 31) | ((ulong)(FACILITY_WGX) << 16)));
+
+
+ internal static readonly HRESULT WGXHR_CLIPPEDTOEMPTY = (HRESULT)(SuccessCode | 1);
+ internal static readonly HRESULT WGXHR_EMPTYFILL = (HRESULT)(SuccessCode | 2);
+ internal static readonly HRESULT WGXHR_INTERNALTEMPORARYSUCCESS = (HRESULT)(SuccessCode | 3);
+ internal static readonly HRESULT WGXHR_RESETSHAREDHANDLEMANAGER = (HRESULT)(SuccessCode | 4);
+
+
+ // Unique MIL error codes // Value: 0x8898xxxx -200330nnnn
+ internal static readonly HRESULT WGXERR_OBJECTBUSY = (HRESULT)(ErrorCode | 0x001); // 4447
+ internal static readonly HRESULT WGXERR_INSUFFICIENTBUFFER = (HRESULT)(ErrorCode | 0x002); // 4446
+ internal static readonly HRESULT WGXERR_WIN32ERROR = (HRESULT)(ErrorCode | 0x003); // 4445
+ internal static readonly HRESULT WGXERR_SCANNER_FAILED = (HRESULT)(ErrorCode | 0x004); // 4444
+ internal static readonly HRESULT WGXERR_SCREENACCESSDENIED = (HRESULT)(ErrorCode | 0x005); // 4443
+ internal static readonly HRESULT WGXERR_DISPLAYSTATEINVALID = (HRESULT)(ErrorCode | 0x006); // 4442
+ internal static readonly HRESULT WGXERR_NONINVERTIBLEMATRIX = (HRESULT)(ErrorCode | 0x007); // 4441
+ internal static readonly HRESULT WGXERR_ZEROVECTOR = (HRESULT)(ErrorCode | 0x008); // 4440
+ internal static readonly HRESULT WGXERR_TERMINATED = (HRESULT)(ErrorCode | 0x009); // 4439
+ internal static readonly HRESULT WGXERR_BADNUMBER = (HRESULT)(ErrorCode | 0x00A); // 4438
+ internal static readonly HRESULT WGXERR_UNSUPPORTEDTEXTURESIZE = (HRESULT)(ErrorCode | 0x00B); // 4437
+
+ // An internal error (MIL bug) occurred. On checked builds, we would assert.
+ internal static readonly HRESULT WGXERR_INTERNALERROR = (HRESULT)(ErrorCode | 0x080); // 4320
+
+ // This is a presentation error that is recoverable. The caller needs
+ // to reattempt present.
+ // Known cause for this is another process calling PrintWindow on our hwnd
+ // when we call UpdateLayeredWindow.
+ internal static readonly HRESULT WGXERR_NEED_REATTEMPT_PRESENT = (HRESULT)(ErrorCode | 0x083); // 4317
+
+ // The display format we need to render is not supported by the
+ // hardware device.
+ internal static readonly HRESULT WGXERR_DISPLAYFORMATNOTSUPPORTED = (HRESULT)(ErrorCode | 0x084); // 4316
+
+ // A call to this method is invalid.
+ internal static readonly HRESULT WGXERR_INVALIDCALL = (HRESULT)(ErrorCode | 0x085); // 4315
+
+ // Lock attempted on an already locked object.
+ internal static readonly HRESULT WGXERR_ALREADYLOCKED = (HRESULT)(ErrorCode | 0x086); // 4314
+
+ // Unlock attempted on an unlocked object.
+ internal static readonly HRESULT WGXERR_NOTLOCKED = (HRESULT)(ErrorCode | 0x087); // 4313
+
+ // No algorithm avaliable to render text with this device
+ internal static readonly HRESULT WGXERR_DEVICECANNOTRENDERTEXT = (HRESULT)(ErrorCode | 0x088); // 4312
+
+ // Some glyph bitmaps, required for glyph run rendering, are not
+ // contained in glyph cache.
+ internal static readonly HRESULT WGXERR_GLYPHBITMAPMISSED = (HRESULT)(ErrorCode | 0x089); // 4311
+
+ // Some glyph bitmaps in glyph cache are unexpectedly big.
+ internal static readonly HRESULT WGXERR_MALFORMEDGLYPHCACHE = (HRESULT)(ErrorCode | 0x08A); // 4310
+
+ // Marker error for known Win32 errors that are currently being ignored
+ // by the compositor. This is to avoid returning S_OK when an error has occurred,
+ // but still unwind the stack in the correct location
+ internal static readonly HRESULT WGXERR_GENERIC_IGNORE = (HRESULT)(ErrorCode | 0x08B); // 4309
+
+ // Guideline coordinates are not sorted properly or contain NaNs.
+ internal static readonly HRESULT WGXERR_MALFORMED_GUIDELINE_DATA = (HRESULT)(ErrorCode | 0x08C); // 4308
+
+ // No HW rendering device is available for this operation
+ internal static readonly HRESULT WGXERR_NO_HARDWARE_DEVICE = (HRESULT)(ErrorCode | 0x08D); // 4307
+
+ // There has been a presentation error that may be recoverable. The caller
+ // needs to recreate, rerender the entire frame, and reattempt present.
+ // There are two known case for this:
+ // 1) D3D Driver Internal error - should be investigated by DXG/IHV
+ // 2) D3D E_FAIL
+ // a) Unknown root cause - should be investigated by DXG
+ // b) When resizing too quickly for DWM and D3D stay in sync
+ internal static readonly HRESULT WGXERR_NEED_RECREATE_AND_PRESENT = (HRESULT)(ErrorCode | 0x08E); // 4306
+
+ // The object has already been initialized
+ internal static readonly HRESULT WGXERR_ALREADY_INITIALIZED = (HRESULT)(ErrorCode | 0x08F); // 4305
+
+ // The size of the object does not match the expected size
+ internal static readonly HRESULT WGXERR_MISMATCHED_SIZE = (HRESULT)(ErrorCode | 0x090); // 4304
+
+ // No Redirection surface avaiable
+ internal static readonly HRESULT WGXERR_NO_REDIRECTION_SURFACE_AVAILABLE = (HRESULT)(ErrorCode | 0x091); //4303
+
+ // Remoting of this content is not supported
+ internal static readonly HRESULT WGXERR_REMOTING_NOT_SUPPORTED = (HRESULT)(ErrorCode | 0x092); // 4302
+
+ // Queued Presents are not being used
+ internal static readonly HRESULT WGXERR_QUEUED_PRESENT_NOT_SUPPORTED = (HRESULT)(ErrorCode | 0x093); // 4301
+
+ // Queued Presents are not being used
+ internal static readonly HRESULT WGXERR_NOT_QUEUING_PRESENTS = (HRESULT)(ErrorCode | 0x094); // 4300
+
+ // No redirection surface was available retry the call
+ internal static readonly HRESULT WGXERR_NO_REDIRECTION_SURFACE_RETRY_LATER = (HRESULT)(ErrorCode | 0x095); // 4299
+
+ // Shader construction failed because it was too complex
+ internal static readonly HRESULT WGXERR_TOOMANYSHADERELEMNTS = (HRESULT)(ErrorCode | 0x096); // 4298
+
+ // AVAILABLE = (HRESULT)(ErrorCode | 0x097) // 4297
+ // AVAILABLE = (HRESULT)(ErrorCode | 0x098) // 4296
+
+ // Shader compilation failed
+ internal static readonly HRESULT WGXERR_SHADER_COMPILE_FAILED = (HRESULT)(ErrorCode | 0x099); // 4295
+
+ // Requested DX redirection surface size exceeded maximum texture size
+ internal static readonly HRESULT WGXERR_MAX_TEXTURE_SIZE_EXCEEDED = (HRESULT)(ErrorCode | 0x09A); // 4294
+
+ // AVAILABLE = (HRESULT)(ErrorCode | 0x09B) // 4293
+
+ // Caps don't meet min WPF requirement for hw rendering
+ internal static readonly HRESULT WGXERR_INSUFFICIENT_GPU_CAPS = (HRESULT)(ErrorCode | 0x09C); // 4292
+
+ // Composition engine errors
+
+
+ internal static readonly HRESULT WGXERR_UCE_INVALIDPACKETHEADER = (HRESULT)(ErrorCode | 0x400); // 3424
+ internal static readonly HRESULT WGXERR_UCE_UNKNOWNPACKET = (HRESULT)(ErrorCode | 0x401); // 3423
+ internal static readonly HRESULT WGXERR_UCE_ILLEGALPACKET = (HRESULT)(ErrorCode | 0x402); // 3422
+ internal static readonly HRESULT WGXERR_UCE_MALFORMEDPACKET = (HRESULT)(ErrorCode | 0x403); // 3421
+ internal static readonly HRESULT WGXERR_UCE_ILLEGALHANDLE = (HRESULT)(ErrorCode | 0x404); // 3420
+ internal static readonly HRESULT WGXERR_UCE_HANDLELOOKUPFAILED = (HRESULT)(ErrorCode | 0x405); // 3419
+ internal static readonly HRESULT WGXERR_UCE_RENDERTHREADFAILURE = (HRESULT)(ErrorCode | 0x406); // 3418
+ internal static readonly HRESULT WGXERR_UCE_CTXSTACKFRSTTARGETNULL = (HRESULT)(ErrorCode | 0x407); // 3417
+ internal static readonly HRESULT WGXERR_UCE_CONNECTIONIDLOOKUPFAILED = (HRESULT)(ErrorCode | 0x408); // 3416
+ internal static readonly HRESULT WGXERR_UCE_BLOCKSFULL = (HRESULT)(ErrorCode | 0x409); // 3415
+ internal static readonly HRESULT WGXERR_UCE_MEMORYFAILURE = (HRESULT)(ErrorCode | 0x40A); // 3414
+ internal static readonly HRESULT WGXERR_UCE_PACKETRECORDOUTOFRANGE = (HRESULT)(ErrorCode | 0x40B); // 3413
+ internal static readonly HRESULT WGXERR_UCE_ILLEGALRECORDTYPE = (HRESULT)(ErrorCode | 0x40C); // 3412
+ internal static readonly HRESULT WGXERR_UCE_OUTOFHANDLES = (HRESULT)(ErrorCode | 0x40D); // 3411
+ internal static readonly HRESULT WGXERR_UCE_UNCHANGABLE_UPDATE_ATTEMPTED = (HRESULT)(ErrorCode | 0x40E); // 3410
+ internal static readonly HRESULT WGXERR_UCE_NO_MULTIPLE_WORKER_THREADS = (HRESULT)(ErrorCode | 0x40F); // 3409
+ internal static readonly HRESULT WGXERR_UCE_REMOTINGNOTSUPPORTED = (HRESULT)(ErrorCode | 0x410); // 3408
+ internal static readonly HRESULT WGXERR_UCE_MISSINGENDCOMMAND = (HRESULT)(ErrorCode | 0x411); // 3407
+ internal static readonly HRESULT WGXERR_UCE_MISSINGBEGINCOMMAND = (HRESULT)(ErrorCode | 0x412); // 3406
+ internal static readonly HRESULT WGXERR_UCE_CHANNELSYNCTIMEDOUT = (HRESULT)(ErrorCode | 0x413); // 3405
+ internal static readonly HRESULT WGXERR_UCE_CHANNELSYNCABANDONED = (HRESULT)(ErrorCode | 0x414); // 3404
+ internal static readonly HRESULT WGXERR_UCE_UNSUPPORTEDTRANSPORTVERSION = (HRESULT)(ErrorCode | 0x415); // 3403
+ internal static readonly HRESULT WGXERR_UCE_TRANSPORTUNAVAILABLE = (HRESULT)(ErrorCode | 0x416); // 3402
+ internal static readonly HRESULT WGXERR_UCE_FEEDBACK_UNSUPPORTED = (HRESULT)(ErrorCode | 0x417); // 3401
+ internal static readonly HRESULT WGXERR_UCE_COMMANDTRANSPORTDENIED = (HRESULT)(ErrorCode | 0x418); // 3400
+ internal static readonly HRESULT WGXERR_UCE_GRAPHICSSTREAMUNAVAILABLE = (HRESULT)(ErrorCode | 0x419); // 3399
+ internal static readonly HRESULT WGXERR_UCE_GRAPHICSSTREAMALREADYOPEN = (HRESULT)(ErrorCode | 0x420); // 3398
+ internal static readonly HRESULT WGXERR_UCE_TRANSPORTDISCONNECTED = (HRESULT)(ErrorCode | 0x421); // 3397
+ internal static readonly HRESULT WGXERR_UCE_TRANSPORTOVERLOADED = (HRESULT)(ErrorCode | 0x422); // 3396
+ internal static readonly HRESULT WGXERR_UCE_PARTITION_ZOMBIED = (HRESULT)(ErrorCode | 0x423); // 3395
+
+
+
+ // MIL AV Specific errors
+
+ internal static readonly HRESULT WGXERR_AV_NOCLOCK = (HRESULT)(ErrorCode | 0x500);
+ internal static readonly HRESULT WGXERR_AV_NOMEDIATYPE = (HRESULT)(ErrorCode | 0x501);
+ internal static readonly HRESULT WGXERR_AV_NOVIDEOMIXER = (HRESULT)(ErrorCode | 0x502);
+ internal static readonly HRESULT WGXERR_AV_NOVIDEOPRESENTER = (HRESULT)(ErrorCode | 0x503);
+ internal static readonly HRESULT WGXERR_AV_NOREADYFRAMES = (HRESULT)(ErrorCode | 0x504);
+ internal static readonly HRESULT WGXERR_AV_MODULENOTLOADED = (HRESULT)(ErrorCode | 0x505);
+ internal static readonly HRESULT WGXERR_AV_WMPFACTORYNOTREGISTERED = (HRESULT)(ErrorCode | 0x506);
+ internal static readonly HRESULT WGXERR_AV_INVALIDWMPVERSION = (HRESULT)(ErrorCode | 0x507);
+ internal static readonly HRESULT WGXERR_AV_INSUFFICIENTVIDEORESOURCES = (HRESULT)(ErrorCode | 0x508);
+ internal static readonly HRESULT WGXERR_AV_VIDEOACCELERATIONNOTAVAILABLE = (HRESULT)(ErrorCode | 0x509);
+ internal static readonly HRESULT WGXERR_AV_REQUESTEDTEXTURETOOBIG = (HRESULT)(ErrorCode | 0x50A);
+ internal static readonly HRESULT WGXERR_AV_SEEKFAILED = (HRESULT)(ErrorCode | 0x50B);
+ internal static readonly HRESULT WGXERR_AV_UNEXPECTEDWMPFAILURE = (HRESULT)(ErrorCode | 0x50C);
+ internal static readonly HRESULT WGXERR_AV_MEDIAPLAYERCLOSED = (HRESULT)(ErrorCode | 0x50D);
+ internal static readonly HRESULT WGXERR_AV_UNKNOWNHARDWAREERROR = (HRESULT)(ErrorCode | 0x50E);
+
+ // Unused 0x60E - 0x61b
+
+ // D3DImage specific errors
+ internal static readonly HRESULT WGXERR_D3DI_INVALIDSURFACEUSAGE = (HRESULT)(ErrorCode | 0x800);
+ internal static readonly HRESULT WGXERR_D3DI_INVALIDSURFACESIZE = (HRESULT)(ErrorCode | 0x801);
+ internal static readonly HRESULT WGXERR_D3DI_INVALIDSURFACEPOOL = (HRESULT)(ErrorCode | 0x802);
+ internal static readonly HRESULT WGXERR_D3DI_INVALIDSURFACEDEVICE = (HRESULT)(ErrorCode | 0x803);
+ internal static readonly HRESULT WGXERR_D3DI_INVALIDANTIALIASINGSETTINGS = (HRESULT)(ErrorCode | 0x804);
+}
+
+#pragma warning restore IDE1006 // Naming Styles
+#pragma warning restore format
diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Windows/Win32/Foundation/PrimitivesHResultExtensions.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Windows/Win32/Foundation/PrimitivesHResultExtensions.cs
new file mode 100644
index 00000000000..45d7db65f06
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/Windows/Win32/Foundation/PrimitivesHResultExtensions.cs
@@ -0,0 +1,85 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using Windows.Win32.System.Diagnostics.Debug;
+
+namespace Windows.Win32.Foundation;
+
+internal static class PrimitivesHResultExtensions
+{
+ // Can't find these defined or documented anywhere
+ private const int COMPONENT_MASK = 0b_11100000_00000000;
+ private const int COMPONENT_WINCODEC_ERROR = 0b_00100000_00000000;
+
+ ///
+ /// if the HRESULT represents a Windows Imaging Component (WIC) error.
+ ///
+ internal static bool IsWindowsCodecError(this HRESULT result) =>
+ result.Facility == FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ && ((result.Value & COMPONENT_MASK) == COMPONENT_WINCODEC_ERROR);
+
+ ///
+ /// if the represents an code.
+ ///
+ internal static bool IsNtStatus(this HRESULT result) =>
+ (result.Value & (int)FACILITY_CODE.FACILITY_NT_BIT) == (int)FACILITY_CODE.FACILITY_NT_BIT;
+
+ ///
+ /// Extracts the code. Check before calling this method.
+ ///
+ internal static NTSTATUS ToNtStatus(this HRESULT result)
+ {
+ Debug.Assert(result.IsNtStatus());
+ return new NTSTATUS(result.Value & ~(int)FACILITY_CODE.FACILITY_NT_BIT);
+ }
+
+ ///
+ /// Throws an exception if the represents a failure. If the error would normally result
+ /// in a and the result is a Win32 error, a is thrown
+ /// instead.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal static HRESULT ThrowOnFailureUnwrapWin32(this HRESULT result)
+ {
+ if (result.Failed)
+ {
+ Throw(result);
+ }
+
+ return result;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static void Throw(HRESULT result)
+ {
+ throw result.GetExceptionUnwrapWin32()
+ ?? new InvalidOperationException() { HResult = result };
+ }
+ }
+
+ ///
+ /// Gets an exception if the represents a failure. If the error would normally result
+ /// in a and the result is a Win32 error, a is thrown
+ /// instead.
+ ///
+ ///
+ /// The exception, or if the result is a success code.
+ ///
+ internal static Exception? GetExceptionUnwrapWin32(this HRESULT result)
+ {
+ if (result.Succeeded)
+ {
+ return null;
+ }
+
+ // Pasing in -1 prevents thread IErrorInfo from trumping what we're trying to raise.
+ Exception? e = Marshal.GetExceptionForHR(result, -1);
+ Debug.Assert(e is not null);
+
+ return e is COMException && result.Facility == FACILITY_CODE.FACILITY_WIN32
+ ? new Win32Exception(result.Code)
+ : e;
+ }
+}
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/FocusTracker.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/FocusTracker.cs
index 4e538718bc4..6d520fdbef8 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/FocusTracker.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/FocusTracker.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -172,7 +172,7 @@ private AutomationElement GetFocusedElementFromWinEvent(IntPtr hwnd, int idObjec
// use that instead. This is here to get the subset link in the listview but could be usefull
// for listview subitems as well.
IRawElementProviderSimple realFocus = fragment.GetFocus();
- if(realFocus != null && !Object.ReferenceEquals(realFocus, provider))
+ if(realFocus != null && !ReferenceEquals(realFocus, provider))
{
provider = realFocus;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Accessible.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Accessible.cs
index 84284eb9995..09a15f36c42 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Accessible.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Accessible.cs
@@ -1,11 +1,8 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
// Description: Wraps some of IAccessible to support getting basic properties
// and default action
-//
-
// PRESHARP: In order to avoid generating warnings about unkown message numbers and unknown pragmas.
#pragma warning disable 1634, 1691
@@ -18,6 +15,8 @@
using Accessibility;
using System.Runtime.InteropServices;
using MS.Win32;
+using Windows.Win32.Foundation;
+using Windows.Win32.System.Diagnostics.Debug;
namespace MS.Internal.AutomationProxies
{
@@ -172,7 +171,7 @@ internal static Accessible CreateNativeFromEvent(IntPtr hwnd, int idObject, int
// unwrap the pointer that was returned
IAccessible acc = null;
- int hr = NativeMethods.S_FALSE;
+ int hr = HRESULT.S_FALSE;
try
{
@@ -212,14 +211,14 @@ internal static Accessible CreateNativeFromEvent(IntPtr hwnd, int idObject, int
// !Marshal.IsComObject()) - that only protects us from managed IAccessibles we get back directly; we could
// still hit the above issue if we get back a remote unmanaged impl that then returns a maanged impl via
// navigation (Media Center does this). So we now use AOFW all the time.
- if(hr == NativeMethods.S_OK && acc != null)
+ if(hr == HRESULT.S_OK && acc != null)
{
object obj = null;
hr = UnsafeNativeMethods.AccessibleObjectFromWindow(hwnd, idObject, ref UnsafeNativeMethods.IID_IUnknown, ref obj);
acc = obj as IAccessible;
}
- if (hr != NativeMethods.S_OK || acc == null)
+ if (hr != HRESULT.S_OK || acc == null)
{
return null;
}
@@ -312,7 +311,7 @@ internal Accessible LastChild
{
get
{
- return _idChild == NativeMethods.CHILD_SELF ? GetChildAt(_acc, null, Accessible.GetChildCount(_acc) - 1) : null;
+ return _idChild == NativeMethods.CHILD_SELF ? GetChildAt(_acc, null, GetChildCount(_acc) - 1) : null;
}
}
@@ -335,7 +334,7 @@ internal Accessible NextSibling(Accessible parent)
}
Accessible rval = null;
- if (_accessibleChildrenIndex + 1 < Accessible.GetChildCount(parent._acc))
+ if (_accessibleChildrenIndex + 1 < GetChildCount(parent._acc))
{
rval = GetChildAt(parent._acc, children, _accessibleChildrenIndex + 1);
}
@@ -436,7 +435,7 @@ internal bool IsAvailableToUser
// We're not dealing with menus [in this version of NativeMsaaProxy] so won't worry about them
// here. To "clean up" the tree we'll skip over IAccessibles that have the above states.
// May revisit per user feedback.
- if (Accessible.HasState(state, AccessibleState.Invisible) && !Accessible.HasState(state, AccessibleState.Offscreen))
+ if (HasState(state, AccessibleState.Invisible) && !HasState(state, AccessibleState.Offscreen))
return false;
return true;
@@ -563,8 +562,8 @@ internal Rect Location
internal static Accessible GetFullAccessibleChildByIndex(Accessible accParent, int index)
{
- int childCount = 0;
- object[] accChildren = Accessible.GetAccessibleChildren(accParent.IAccessible, out childCount);
+ int childCount = 0;
+ object[] accChildren = GetAccessibleChildren(accParent.IAccessible, out childCount);
if (accChildren != null && 0 <= index && index < accChildren.Length)
{
@@ -572,12 +571,12 @@ internal static Accessible GetFullAccessibleChildByIndex(Accessible accParent, i
IAccessible accChild = child as IAccessible;
if (accChild != null)
{
- return Accessible.Wrap(accChild);
+ return Wrap(accChild);
}
else if (child is int)
{
int idChild = (int)child;
- return Accessible.Wrap(accParent.IAccessible, idChild);
+ return Wrap(accParent.IAccessible, idChild);
}
}
@@ -861,7 +860,7 @@ internal IntPtr Window
try
{
int result = UnsafeNativeMethods.WindowFromAccessibleObject(_acc, ref _hwnd);
- if ( result != NativeMethods.S_OK)
+ if ( result != HRESULT.S_OK)
{
_hwnd = IntPtr.Zero;
}
@@ -900,12 +899,12 @@ internal static int AccessibleObjectFromWindow(IntPtr hwnd, int idObject, ref Ac
accObject = obj as IAccessible;
- if (hr != NativeMethods.S_OK || accObject == null)
+ if (hr != HRESULT.S_OK || accObject == null)
{
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
- acc = Accessible.Wrap(accObject);
+ acc = Wrap(accObject);
return hr;
}
catch (Exception e)
@@ -915,7 +914,7 @@ internal static int AccessibleObjectFromWindow(IntPtr hwnd, int idObject, ref Ac
throw;
}
- return NativeMethods.S_FALSE;
+ return HRESULT.S_FALSE;
}
}
@@ -937,9 +936,9 @@ internal static object[] GetAccessibleChildren(IAccessible accessibleObject, out
aChildren = new object[childCount];
// Get the raw children because accNavigate doesn't work
- if (UnsafeNativeMethods.AccessibleChildren(accessibleObject, 0, childCount, aChildren, out childrenReturned) == NativeMethods.E_INVALIDARG)
+ if (UnsafeNativeMethods.AccessibleChildren(accessibleObject, 0, childCount, aChildren, out childrenReturned) == HRESULT.E_INVALIDARG)
{
- System.Diagnostics.Debug.Assert(false, "Call to AccessibleChildren() returned E_INVALIDARG.");
+ Debug.Assert(false, "Call to AccessibleChildren() returned E_INVALIDARG.");
throw new ElementNotAvailableException();
}
}
@@ -1306,7 +1305,7 @@ internal static NativeMethods.Win32Rect GetLocation(IAccessible acc, int idChild
rect.bottom += rect.top; // convert height to bottom
return rect;
}
-
+
// converts the exception into a more appropriate one and throws it,
// or returns false indicating the caller should assume a default result
// or returns true indicating the caller should rethrow the exception.
@@ -1349,45 +1348,72 @@ private static bool HandleIAccessibleException(Exception e)
// holding pointers to them, like when Trident navigates to a new page.
int errorCode = comException.ErrorCode;
+ HRESULT result = (HRESULT)errorCode;
+ if (result.Facility == FACILITY_CODE.FACILITY_WIN32)
+ {
+ switch ((WIN32_ERROR)result.Code)
+ {
+ case WIN32_ERROR.ERROR_OUTOFMEMORY:
+ // Some OLEACC proxies produce out-of-memory for non-critical reasons:
+ // notably, the treeview proxy will raise this if the target HWND no longer exists,
+ // GetWindowThreadProcessID fails and it therefore won't be able to allocate shared
+ // memory in the target process, so it incorrectly assumes OOM.
+ throw new ElementNotAvailableException(e);
+ case WIN32_ERROR.ERROR_ACCESS_DENIED:
+ // This is returned when you call get_accValue to get the value of a password control.
+ throw new UnauthorizedAccessException();
+ };
+ }
+
+ if (result == HRESULT.E_FAIL || result == HRESULT.E_NOTIMPL)
+ {
+ // An unknown or generic error occurred; treat as a not-impl. (Other methods on the object
+ // may still work, so don't treat as ElementNotAvailable.)
+ throw new ArgumentException(SR.InvalidParameter);
+ }
+ else if (result == HRESULT.E_INVALIDARG)
+ {
+ // One or more arguments were invalid. This error occurs when the caller attempts to identify
+ // a child object using an identifier that the server does not recognize. This error also results
+ // when a client attempts to identify a child object within an object that has no children.
+ throw new ArgumentException(SR.InvalidParameter);
+ }
+ else if (result == HRESULT.DISP_E_MEMBERNOTFOUND)
+ {
+ // The object does not support the requested property or action. For example,
+ // a push button returns this value if you request its Value property, since
+ // it does not have a Value property.
+ return false;
+ }
+
+ // All of these can be updated to use defines from System.Private.Windows.Core when available.
+ // See inline comments for more.
switch (errorCode)
{
+ // 2 HRESULT defines pending System.Private.Windows.Core update (FACILITY_RPC)
case NativeMethods.RPC_E_SERVERFAULT: // The server threw an exception.
case NativeMethods.RPC_E_DISCONNECTED: // The object invoked has disconnected from its clients.
+
+ // WIN32_ERROR wrapped RPC_STATUS.RPC_S_SERVER_UNAVAILABLE
case NativeMethods.RPC_E_UNAVAILABLE: // The server has disappeared
+
+ // HRESULT define pending System.Private.Windows.Core update
case NativeMethods.DISP_E_BADINDEX: // Index out of Range (Usually means Children have disappeared)
+
+ // WIN32_ERROR wrapped RPC_STATUS.RPC_S_UNKNOWN_IF
case NativeMethods.E_INTERFACEUNKNOWN: // The interface is unknown, usually because things have changed.
+
+ // Not a publicly defined HRESULT. FACILITY_CONTROL facility codes are VB specific errors.
+ // Ultimately this comes from Visual Basic VB_E_NOTOBJECT or "Object required".
+ // It is thrown by VBA when an object has been collected or a VARIANT is not an IDispatch
+ // or IUnkown object.
+ //
+ // https://learn.microsoft.com/office/vba/language/reference/user-interface-help/object-required-error-424
case NativeMethods.E_UNKNOWNWORDERROR: // An unknown Error code thrown by Word being closed while a search is running
- case NativeMethods.RPC_E_SYS_CALL_FAILED: // System call failed during RPC.
- throw new ElementNotAvailableException(e);
- case NativeMethods.E_FAIL:
- // An unknown or generic error occurred; treat as a not-impl. (Other methods on the object
- // may still work, so don't treat as ElementNotAvailable.)
- case NativeMethods.E_MEMBERNOTFOUND:
- // The object does not support the requested property or action. For example,
- // a push button returns this value if you request its Value property, since
- // it does not have a Value property.
- case NativeMethods.E_NOTIMPL:
- // just return on E_NOTIMPL errors
- return false;
-
- case NativeMethods.E_OUTOFMEMORY:
- // Some OLEACC proxies produce out-of-memory for non-critical reasons:
- // notably, the treeview proxy will raise this if the target HWND no longer exists,
- // GetWindowThreadProcessID fails and it therefore won't be able to allocate shared
- // memory in the target process, so it incorrectly assumes OOM.
+ // 2 HRESULT defines pending System.Private.Windows.Core update (FACILITY_RPC)
+ case NativeMethods.RPC_E_SYS_CALL_FAILED: // System call failed during RPC.
throw new ElementNotAvailableException(e);
-
- case NativeMethods.E_INVALIDARG:
- // One or more arguments were invalid. This error occurs when the caller attempts to identify
- // a child object using an identifier that the server does not recognize. This error also results
- // when a client attempts to identify a child object within an object that has no children.
- throw new ArgumentException(SR.InvalidParameter);
-
- case NativeMethods.E_ACCESSDENIED:
- // This is returned when you call get_accValue to get the value of a password control.
- throw new UnauthorizedAccessException();
-
case NativeMethods.E_UNEXPECTED:
// An IAccessible server has been released unexpectedly but still has pending events.
// If the current execution context is inside one of these event handlers it must be
@@ -1396,7 +1422,7 @@ private static bool HandleIAccessibleException(Exception e)
default:
// we want to know when we get an exception we haven't seen before
- Debug.Assert(false, string.Format(CultureInfo.CurrentCulture, "MsaaNativeProvider: IAccessible threw a COMException: {0}", e.Message));
+ Debug.Fail($"MsaaNativeProvider: IAccessible threw a COMException: {e.Message}");
break;
}
}
@@ -1442,7 +1468,7 @@ static IAccessible WashPartialTrustWinformsAccessible(IAccessible old)
int childCount;
- object[] rawChildren = Accessible.GetAccessibleChildren(accParent, out childCount);
+ object[] rawChildren = GetAccessibleChildren(accParent, out childCount);
for (int i = 0; i < childCount; i++)
{
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/ProxySimple.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/ProxySimple.cs
index 5c9371593d7..31b8e71a0ee 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/ProxySimple.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/ProxySimple.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -37,6 +37,7 @@
using Accessibility;
using System.Windows;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.AutomationProxies
{
@@ -152,7 +153,7 @@ internal int[] MakeRuntimeId()
int[] id = new int[idLen];
// Base runtime id is the number indicating Win32Provider + hwnd
- id[0] = ProxySimple.Win32ProviderRuntimeIdBase;
+ id[0] = Win32ProviderRuntimeIdBase;
id[1] = _hwnd.ToInt32();
// Append part id to make this unique
@@ -642,7 +643,7 @@ internal virtual IAccessible AccessibleObject
{
Accessible acc = null;
// We need to go search for it
- _IAccessible = Accessible.AccessibleObjectFromWindow(_hwnd, NativeMethods.OBJID_CLIENT, ref acc) == NativeMethods.S_OK ? acc.IAccessible : null;
+ _IAccessible = Accessible.AccessibleObjectFromWindow(_hwnd, NativeMethods.OBJID_CLIENT, ref acc) == HRESULT.S_OK ? acc.IAccessible : null;
}
return _IAccessible;
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/SafeThemeHandle.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/SafeThemeHandle.cs
index cfd44a69144..330a1bd0277 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/SafeThemeHandle.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/SafeThemeHandle.cs
@@ -1,12 +1,10 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation 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.CompilerServices;
using Microsoft.Win32.SafeHandles;
-using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.AutomationProxies
{
@@ -28,7 +26,7 @@ protected override bool ReleaseHandle()
{
// MustRun methods may only call other MustRun methods,
// must not allocate along paths that must succeed, etc.
- return !IsInvalid ? CloseThemeData(handle) == (IntPtr)NativeMethods.S_OK : true;
+ return !IsInvalid ? CloseThemeData(handle) == (IntPtr)HRESULT.S_OK : true;
}
[DllImport("UxTheme.dll", CharSet = CharSet.Auto)/**/]
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WinFormsSpinner.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WinFormsSpinner.cs
index 9afd74b2cb5..39996f0f60c 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WinFormsSpinner.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WinFormsSpinner.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -11,6 +11,7 @@
using System.Windows.Automation.Provider;
using System.Windows;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.AutomationProxies
{
@@ -178,7 +179,7 @@ internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
// Use IAccessible implementation to confirm the spinner & children
Accessible acc = null;
- if (Accessible.AccessibleObjectFromWindow(hwndSpin, NativeMethods.OBJID_CLIENT, ref acc) != NativeMethods.S_OK || acc == null)
+ if (Accessible.AccessibleObjectFromWindow(hwndSpin, NativeMethods.OBJID_CLIENT, ref acc) != HRESULT.S_OK || acc == null)
{
return null;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsButton.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsButton.cs
index 51976c9c4c3..233dc30c296 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsButton.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsButton.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -8,6 +8,7 @@
using System.Windows.Automation;
using System.Windows.Automation.Provider;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.AutomationProxies
{
@@ -319,7 +320,7 @@ IRawElementProviderSimple[] ISelectionProvider.GetSelection()
IntPtr hwndRadioButton = GetSelection();
if (hwndRadioButton == IntPtr.Zero ||
- Accessible.AccessibleObjectFromWindow(hwndRadioButton, NativeMethods.OBJID_CLIENT, ref accRadioButton) != NativeMethods.S_OK ||
+ Accessible.AccessibleObjectFromWindow(hwndRadioButton, NativeMethods.OBJID_CLIENT, ref accRadioButton) != HRESULT.S_OK ||
accRadioButton == null)
{
// framework will handle this one correctly
@@ -394,7 +395,7 @@ IRawElementProviderSimple ISelectionItemProvider.SelectionContainer
if (hwndParent != IntPtr.Zero && WindowsFormsHelper.IsWindowsFormsControl(hwndParent))
{
Accessible accParent = null;
- if (Accessible.AccessibleObjectFromWindow(hwndParent, NativeMethods.OBJID_CLIENT, ref accParent) != NativeMethods.S_OK || accParent == null)
+ if (Accessible.AccessibleObjectFromWindow(hwndParent, NativeMethods.OBJID_CLIENT, ref accParent) != HRESULT.S_OK || accParent == null)
{
return null;
}
@@ -680,7 +681,7 @@ unsafe private bool FindRadioButtonChild(IntPtr hwnd, void* lParam)
}
Accessible acc = null;
- if (Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) == NativeMethods.S_OK &&
+ if (Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) == HRESULT.S_OK &&
acc != null &&
acc.Role == AccessibleRole.RadioButton)
{
@@ -720,7 +721,7 @@ private unsafe bool FindSelectedRadioButtonChild(IntPtr hwnd, void* lParam)
}
Accessible acc = null;
- if (Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) == NativeMethods.S_OK &&
+ if (Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) == HRESULT.S_OK &&
acc != null &&
acc.Role == AccessibleRole.RadioButton &&
acc.HasState(AccessibleState.Checked))
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsFormsHelpers.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsFormsHelpers.cs
index edf275b38e5..cde5fcd74cc 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsFormsHelpers.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsFormsHelpers.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -11,6 +11,7 @@
using System;
using System.Windows.Automation.Provider;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.AutomationProxies
{
@@ -28,7 +29,7 @@ internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild, int i
// return a Native IAccessble and not a OleAcc implementaion. Winforms does provide a Native IAccessible.
Accessible acc = null;
- if (Accessible.AccessibleObjectFromWindow(hwnd, idObject, ref acc) != NativeMethods.S_OK || acc == null)
+ if (Accessible.AccessibleObjectFromWindow(hwnd, idObject, ref acc) != HRESULT.S_OK || acc == null)
{
return null;
}
@@ -74,7 +75,7 @@ internal static IRawElementProviderSimple CreateButton(IntPtr hwnd)
// return a Native IAccessble and not a OleAcc implementaion. Winforms does provide a Native IAccessible.
Accessible acc = null;
- if (Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) != NativeMethods.S_OK || acc == null)
+ if (Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) != HRESULT.S_OK || acc == null)
{
return null;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsRichEdit.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsRichEdit.cs
index 2c121b48c32..eeaaf7a5d47 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsRichEdit.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsRichEdit.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -12,6 +12,7 @@
using System.Windows.Automation.Provider;
using Accessibility;
using MS.Win32;
+using Windows.Win32.Foundation;
using NativeMethodsSetLastError = MS.Internal.UIAutomationClientSideProviders.NativeMethodsSetLastError;
namespace MS.Internal.AutomationProxies
@@ -481,7 +482,11 @@ private void EnsureTextDocument()
{
object obj = null;
- if (UnsafeNativeMethods.AccessibleObjectFromWindow(WindowHandle, NativeMethods.OBJID_NATIVEOM, ref UnsafeNativeMethods.IID_IDispatch, ref obj) != NativeMethods.S_OK)
+ if (UnsafeNativeMethods.AccessibleObjectFromWindow(
+ WindowHandle,
+ NativeMethods.OBJID_NATIVEOM,
+ ref UnsafeNativeMethods.IID_IDispatch,
+ ref obj) != HRESULT.S_OK)
{
throw new System.NotImplementedException(SR.NoITextDocumentFromRichEdit);
}
@@ -532,7 +537,7 @@ private string GetValue()
{
sbText.Append(text.Substring(start, embeddedObjectOffset - start));
range.SetRange(embeddedObjectOffset, end);
- if (range.GetEmbeddedObject(out embeddedObject) == NativeMethods.S_OK && embeddedObject != null)
+ if (range.GetEmbeddedObject(out embeddedObject) == HRESULT.S_OK && embeddedObject != null)
{
GetEmbeddedObjectText(embeddedObject, sbText);
}
@@ -580,7 +585,7 @@ private void GetEmbeddedObjectText(object embeddedObject, StringBuilder sbText)
// Didn't get IAccessible (or didn't get a name from it).
// Try the IDataObject technique instead...
- int hr = NativeMethods.S_FALSE;
+ int hr = HRESULT.S_FALSE;
IDataObject dataObject = null;
IOleObject oleObject = embeddedObject as IOleObject;
if (oleObject != null)
@@ -590,7 +595,7 @@ private void GetEmbeddedObjectText(object embeddedObject, StringBuilder sbText)
}
// If that didn't work, try the embeddedObject as a IDataObject instead...
- if (hr != NativeMethods.S_OK)
+ if (hr != HRESULT.S_OK)
{
dataObject = embeddedObject as IDataObject;
}
@@ -618,7 +623,7 @@ private void GetEmbeddedObjectText(object embeddedObject, StringBuilder sbText)
hr = dataObject.GetData(ref fetc, ref med);
- if (hr != NativeMethods.S_OK || med.hGlobal == IntPtr.Zero)
+ if (hr != HRESULT.S_OK || med.hGlobal == IntPtr.Zero)
{
// If we didn't get Unicode, try for ANSI instead...
fGotUnicode = false;
@@ -628,7 +633,7 @@ private void GetEmbeddedObjectText(object embeddedObject, StringBuilder sbText)
}
// Did we get anything?
- if (hr != NativeMethods.S_OK || med.hGlobal == IntPtr.Zero)
+ if (hr != HRESULT.S_OK || med.hGlobal == IntPtr.Zero)
{
return;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatic.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatic.cs
index e90bca4368b..cdd697ad99e 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatic.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatic.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -8,6 +8,7 @@
using System.Windows.Automation;
using System.Windows.Automation.Provider;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.AutomationProxies
{
@@ -172,7 +173,7 @@ private static bool IsLinkLabel(IntPtr hwnd)
// could be a label or a linklabel
// we differentiate based on whether the item has children or not
Accessible acc = null;
- return Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) == NativeMethods.S_OK && acc != null && acc.ChildCount > 0;
+ return Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) == HRESULT.S_OK && acc != null && acc.ChildCount > 0;
}
private static StaticType GetStaticTypeFromStyle(int style)
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs
index a98ccd35d31..3682c1db64f 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs
@@ -1,6 +1,5 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
// Description: Windows Status Proxy
@@ -10,6 +9,7 @@
using System.Windows;
using System.Globalization;
using MS.Win32;
+using Windows.Win32.Foundation;
namespace MS.Internal.AutomationProxies
{
@@ -562,7 +562,7 @@ static internal Rect GetBoundingRectangle (IntPtr hwnd, int item)
else
{
Accessible acc = null;
- if (Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) != NativeMethods.S_OK || acc == null)
+ if (Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc) != HRESULT.S_OK || acc == null)
{
return Rect.Empty;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs
index 2e2a9886647..1273226e9d3 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -9,6 +9,7 @@
using System.Windows.Automation;
using System.Windows.Automation.Provider;
using MS.Win32;
+using Windows.Win32.Foundation;
using NativeMethodsSetLastError = MS.Internal.UIAutomationClientSideProviders.NativeMethodsSetLastError;
namespace MS.Internal.AutomationProxies
@@ -308,7 +309,7 @@ internal static bool IsWinformUpdown (IntPtr hwnd)
int hr = Accessible.AccessibleObjectFromWindow(hwnd, NativeMethods.OBJID_CLIENT, ref acc);
// Verify the role
- return hr == NativeMethods.S_OK && acc != null ? acc.Role == AccessibleRole.SpinButton : false;
+ return hr == HRESULT.S_OK && acc != null ? acc.Role == AccessibleRole.SpinButton : false;
}
#endregion
@@ -577,7 +578,7 @@ static internal Rect GetBoundingRectangle(IntPtr hwnd, WindowsUpDown.SpinItem it
switch (item)
{
- case WindowsUpDown.SpinItem.DownArrow:
+ case SpinItem.DownArrow:
if (fHorz)
{
int width = (updownRect.right - updownRect.left);
@@ -591,7 +592,7 @@ static internal Rect GetBoundingRectangle(IntPtr hwnd, WindowsUpDown.SpinItem it
// Don't need to normalize, GetWindowRect returns screen coordinates.
return updownRect.ToRect(false);
- case WindowsUpDown.SpinItem.UpArrow:
+ case SpinItem.UpArrow:
if (fHorz)
{
int width = (updownRect.right - updownRect.left);
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Win32/NativeMethods.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Win32/NativeMethods.cs
index baf3c151c61..dd11ab77cb1 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Win32/NativeMethods.cs
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Win32/NativeMethods.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -1183,10 +1183,10 @@ internal Win32Rect (int left, int top, int right, int bottom)
internal Win32Rect (Rect rc)
{
- this.left = (int)rc.Left;
- this.top = (int)rc.Top;
- this.right = (int)rc.Right;
- this.bottom = (int)rc.Bottom;
+ left = (int)rc.Left;
+ top = (int)rc.Top;
+ right = (int)rc.Right;
+ bottom = (int)rc.Bottom;
}
internal bool IsEmpty
@@ -1231,9 +1231,9 @@ internal void Normalize(bool isRtoL)
// Invert the left and right values for right-to-left windows
if (isRtoL)
{
- int temp = this.left;
- this.left = this.right;
- this.right = temp;
+ int temp = left;
+ left = right;
+ right = temp;
}
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj
index 42827702f21..d81c32706bd 100644
--- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj
+++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj
@@ -85,9 +85,11 @@
false
+
+
diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Interop/ErrorCodes.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Interop/ErrorCodes.cs
deleted file mode 100644
index a0f56983a74..00000000000
--- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Interop/ErrorCodes.cs
+++ /dev/null
@@ -1,456 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.ComponentModel;
-using System.Globalization;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-namespace MS.Internal.Interop
-{
- ///
- /// Wrapper for common Win32 status codes.
- ///
- [StructLayout(LayoutKind.Explicit)]
- internal struct Win32Error
- {
- [FieldOffset(0)]
- private readonly int _value;
-
- // NOTE: These public static field declarations are automatically
- // picked up by (HRESULT's) ToString through reflection.
-
- /// The operation completed successfully.
- public static readonly Win32Error ERROR_SUCCESS = new Win32Error(0);
- /// Incorrect function.
- public static readonly Win32Error ERROR_INVALID_FUNCTION = new Win32Error(1);
- /// The system cannot find the file specified.
- public static readonly Win32Error ERROR_FILE_NOT_FOUND = new Win32Error(2);
- /// The system cannot find the path specified.
- public static readonly Win32Error ERROR_PATH_NOT_FOUND = new Win32Error(3);
- /// The system cannot open the file.
- public static readonly Win32Error ERROR_TOO_MANY_OPEN_FILES = new Win32Error(4);
- /// Access is denied.
- public static readonly Win32Error ERROR_ACCESS_DENIED = new Win32Error(5);
- /// The handle is invalid.
- public static readonly Win32Error ERROR_INVALID_HANDLE = new Win32Error(6);
- /// Not enough storage is available to complete this operation.
- public static readonly Win32Error ERROR_OUTOFMEMORY = new Win32Error(14);
- /// There are no more files.
- public static readonly Win32Error ERROR_NO_MORE_FILES = new Win32Error(18);
- /// The process cannot access the file because it is being used by another process.
- public static readonly Win32Error ERROR_SHARING_VIOLATION = new Win32Error(32);
- /// The parameter is incorrect.
- public static readonly Win32Error ERROR_INVALID_PARAMETER = new Win32Error(87);
- /// The data area passed to a system call is too small.
- public static readonly Win32Error ERROR_INSUFFICIENT_BUFFER = new Win32Error(122);
- /// Cannot nest calls to LoadModule.
- public static readonly Win32Error ERROR_NESTING_NOT_ALLOWED = new Win32Error(215);
- /// Illegal operation attempted on a registry key that has been marked for deletion.
- public static readonly Win32Error ERROR_KEY_DELETED = new Win32Error(1018);
- /// There was no match for the specified key in the index.
- public static readonly Win32Error ERROR_NO_MATCH = new Win32Error(1169);
- /// An invalid device was specified.
- public static readonly Win32Error ERROR_BAD_DEVICE = new Win32Error(1200);
- /// The operation was canceled by the user.
- public static readonly Win32Error ERROR_CANCELLED = new Win32Error(1223);
- /// Invalid window handle.
- public static readonly Win32Error ERROR_INVALID_WINDOW_HANDLE = new Win32Error(1400);
- /// This operation returned because the timeout period expired.
- public static readonly Win32Error ERROR_TIMEOUT = new Win32Error(1460);
- /// The specified datatype is invalid.
- public static readonly Win32Error ERROR_INVALID_DATATYPE = new Win32Error(1804);
-
- ///
- /// Create a new Win32 error.
- ///
- /// The integer value of the error.
- public Win32Error(int i)
- {
- _value = i;
- }
-
- /// Performs HRESULT_FROM_WIN32 conversion.
- /// The Win32 error being converted to an HRESULT.
- /// The equivilent HRESULT value.
- public static explicit operator HRESULT(Win32Error error)
- {
- // #define __HRESULT_FROM_WIN32(x)
- // ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000)))
- if (error._value <= 0)
- {
- return new HRESULT((uint)error._value);
- }
- return HRESULT.Make(true, Facility.Win32, error._value & 0x0000FFFF);
- }
-
- // Method version of the cast operator.
- /// Performs HRESULT_FROM_WIN32 conversion.
- /// The Win32 error being converted to an HRESULT.
- /// The equivilent HRESULT value.
- public HRESULT ToHRESULT()
- {
- return (HRESULT)this;
- }
-
- /// Performs the equivalent of Win32's GetLastError()
- /// A Win32Error instance with the result of the native GetLastError
- public static Win32Error GetLastError()
- {
- return new Win32Error(Marshal.GetLastWin32Error());
- }
-
- public override bool Equals(object obj)
- {
- try
- {
- return ((Win32Error)obj)._value == _value;
- }
- catch (InvalidCastException)
- {
- return false;
- }
- }
-
- public override int GetHashCode()
- {
- return _value.GetHashCode();
- }
-
- ///
- /// Compare two Win32 error codes for equality.
- ///
- /// The first error code to compare.
- /// The second error code to compare.
- /// Whether the two error codes are the same.
- public static bool operator ==(Win32Error errLeft, Win32Error errRight)
- {
- return errLeft._value == errRight._value;
- }
-
- ///
- /// Compare two Win32 error codes for inequality.
- ///
- /// The first error code to compare.
- /// The second error code to compare.
- /// Whether the two error codes are not the same.
- public static bool operator !=(Win32Error errLeft, Win32Error errRight)
- {
- return !(errLeft == errRight);
- }
- }
-
- internal enum Facility
- {
- /// FACILITY_NULL
- Null = 0,
- /// FACILITY_RPC
- Rpc = 1,
- /// FACILITY_DISPATCH
- Dispatch = 2,
- /// FACILITY_STORAGE
- Storage = 3,
- /// FACILITY_ITF
- Itf = 4,
- /// FACILITY_WIN32
- Win32 = 7,
- /// FACILITY_WINDOWS
- Windows = 8,
- /// FACILITY_CONTROL
- Control = 10,
- /// MSDN doced facility code for ESE errors.
- Ese = 0xE5E,
- }
-
- /// Wrapper for HRESULT status codes.
- [StructLayout(LayoutKind.Explicit)]
- internal struct HRESULT
- {
- [FieldOffset(0)]
- private readonly uint _value;
-
- // NOTE: These public static field declarations are automatically
- // picked up by ToString through reflection.
- /// S_OK
- public static readonly HRESULT S_OK = new HRESULT(0x00000000);
- /// S_FALSE
- public static readonly HRESULT S_FALSE = new HRESULT(0x00000001);
- /// E_NOTIMPL
- public static readonly HRESULT E_NOTIMPL = new HRESULT(0x80004001);
- /// E_NOINTERFACE
- public static readonly HRESULT E_NOINTERFACE = new HRESULT(0x80004002);
- /// E_POINTER
- public static readonly HRESULT E_POINTER = new HRESULT(0x80004003);
- /// E_ABORT
- public static readonly HRESULT E_ABORT = new HRESULT(0x80004004);
- /// E_FAIL
- public static readonly HRESULT E_FAIL = new HRESULT(0x80004005);
- /// E_UNEXPECTED
- public static readonly HRESULT E_UNEXPECTED = new HRESULT(0x8000FFFF);
- /// DISP_E_MEMBERNOTFOUND
- public static readonly HRESULT DISP_E_MEMBERNOTFOUND = new HRESULT(0x80020003);
- /// DISP_E_TYPEMISMATCH
- public static readonly HRESULT DISP_E_TYPEMISMATCH = new HRESULT(0x80020005);
- /// DISP_E_UNKNOWNNAME
- public static readonly HRESULT DISP_E_UNKNOWNNAME = new HRESULT(0x80020006);
- /// DISP_E_EXCEPTION
- public static readonly HRESULT DISP_E_EXCEPTION = new HRESULT(0x80020009);
- /// DISP_E_OVERFLOW
- public static readonly HRESULT DISP_E_OVERFLOW = new HRESULT(0x8002000A);
- /// DISP_E_BADINDEX
- public static readonly HRESULT DISP_E_BADINDEX = new HRESULT(0x8002000B);
- /// DISP_E_BADPARAMCOUNT
- public static readonly HRESULT DISP_E_BADPARAMCOUNT = new HRESULT(0x8002000E);
- /// DISP_E_PARAMNOTOPTIONAL
- public static readonly HRESULT DISP_E_PARAMNOTOPTIONAL = new HRESULT(0x8002000F);
- /// SCRIPT_E_REPORTED
- public static readonly HRESULT SCRIPT_E_REPORTED = new HRESULT(0x80020101);
- /// STG_E_INVALIDFUNCTION
- public static readonly HRESULT STG_E_INVALIDFUNCTION = new HRESULT(0x80030001);
- /// DESTS_E_NO_MATCHING_ASSOC_HANDLER.
- ///
- /// Win7 error code for Jump Lists. There is no associated handler for the given item registered by the specified application.
- ///
- public static readonly HRESULT DESTS_E_NO_MATCHING_ASSOC_HANDLER = new HRESULT(0x80040F03);
- /// E_ACCESSDENIED
- public static readonly HRESULT E_ACCESSDENIED = new HRESULT(0x80070005);
- /// E_OUTOFMEMORY
- public static readonly HRESULT E_OUTOFMEMORY = new HRESULT(0x8007000E);
- /// E_INVALIDARG
- public static readonly HRESULT E_INVALIDARG = new HRESULT(0x80070057);
- /// COR_E_OBJECTDISPOSED
- public static readonly HRESULT COR_E_OBJECTDISPOSED = new HRESULT(0x80131622);
- /// WC_E_GREATERTHAN
- public static readonly HRESULT WC_E_GREATERTHAN = new HRESULT(0xC00CEE23);
- /// WC_E_SYNTAX
- public static readonly HRESULT WC_E_SYNTAX = new HRESULT(0xC00CEE2D);
-
- ///
- /// Create an HRESULT from an integer value.
- ///
- ///
- public HRESULT(uint i)
- {
- _value = i;
- }
-
- public static HRESULT Make(bool severe, Facility facility, int code)
- {
- //#define MAKE_HRESULT(sev,fac,code) \
- // ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
- return new HRESULT((uint)((severe ? (1 << 31) : 0) | ((int)facility << 16) | code));
- }
-
- ///
- /// retrieve HRESULT_FACILITY
- ///
- public Facility Facility
- {
- get
- {
- return GetFacility((int)_value);
- }
- }
-
- public static Facility GetFacility(int errorCode)
- {
- // #define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
- return (Facility)((errorCode >> 16) & 0x1fff);
- }
-
- ///
- /// retrieve HRESULT_CODE
- ///
- public int Code
- {
- get
- {
- return GetCode((int)_value);
- }
- }
-
- public static int GetCode(int error)
- {
- // #define HRESULT_CODE(hr) ((hr) & 0xFFFF)
- return (int)(error & 0xFFFF);
- }
-
- #region Object class override members
-
- ///
- /// Get a string representation of this HRESULT.
- ///
- ///
- public override string ToString()
- {
- // Use reflection to try to name this HRESULT.
- // This is expensive, but if someone's ever printing HRESULT strings then
- // I think it's a fair guess that they're not in a performance critical area
- // (e.g. printing exception strings).
- // This is less error prone than trying to keep the list in the function.
- // To properly add an HRESULT's name to the ToString table, just add the HRESULT
- // like all the others above.
- //
- // CONSIDER: This data is static. It could be cached
- // after first usage for fast lookup since the keys are unique.
- //
- foreach (FieldInfo publicStaticField in typeof(HRESULT).GetFields(BindingFlags.Static | BindingFlags.Public))
- {
- if (publicStaticField.FieldType == typeof(HRESULT))
- {
- var hr = (HRESULT)publicStaticField.GetValue(null);
- if (hr == this)
- {
- return publicStaticField.Name;
- }
- }
- }
-
- // Try Win32 error codes also
- if (Facility == Facility.Win32)
- {
- foreach (FieldInfo publicStaticField in typeof(Win32Error).GetFields(BindingFlags.Static | BindingFlags.Public))
- {
- if (publicStaticField.FieldType == typeof(Win32Error))
- {
- var error = (Win32Error)publicStaticField.GetValue(null);
- if ((HRESULT)error == this)
- {
- return "HRESULT_FROM_WIN32(" + publicStaticField.Name + ")";
- }
- }
- }
- }
-
- // If there's no good name for this HRESULT,
- // return the string as readable hex (0x########) format.
- return string.Format(CultureInfo.InvariantCulture, "0x{0:X8}", _value);
- }
-
- public override bool Equals(object obj)
- {
- try
- {
- return ((HRESULT)obj)._value == _value;
- }
- catch (InvalidCastException)
- {
- return false;
- }
- }
-
- public override int GetHashCode()
- {
- return _value.GetHashCode();
- }
-
- #endregion
-
- public static bool operator ==(HRESULT hrLeft, HRESULT hrRight)
- {
- return hrLeft._value == hrRight._value;
- }
-
- public static bool operator !=(HRESULT hrLeft, HRESULT hrRight)
- {
- return !(hrLeft == hrRight);
- }
-
- public bool Succeeded
- {
- get { return (int)_value >= 0; }
- }
-
- public bool Failed
- {
- get { return (int)_value < 0; }
- }
-
- public void ThrowIfFailed()
- {
- ThrowIfFailed(null);
- }
-
- public void ThrowIfFailed(string message)
- {
- Exception e = GetException(message);
-
- if (e != null)
- {
- throw e;
- }
- }
-
- public Exception GetException()
- {
- return GetException(null);
- }
-
- public Exception GetException(string message)
- {
- if (!Failed)
- {
- return null;
- }
-
- // If you're throwing an exception I assume it's OK for me to take some time to give it back.
- // I want to convert the HRESULT to a more appropriate exception type than COMException.
- // Marshal.ThrowExceptionForHR does this for me, but the general call uses GetErrorInfo
- // if it's set, and then ignores the HRESULT that I've provided. This makes it so this
- // call works the first time but you get burned on the second. To avoid this, I use
- // the overload that explicitly ignores the IErrorInfo.
- // In addition, the function doesn't allow me to set the Message unless I go through
- // the process of implementing an IErrorInfo and then use that. There's no stock
- // implementations of IErrorInfo available and I don't think it's worth the maintenance
- // overhead of doing it, nor would it have significant value over this approach.
- Exception e = Marshal.GetExceptionForHR((int)_value, new IntPtr(-1));
- Debug.Assert(e != null);
- // ArgumentNullException doesn't have the right constructor parameters,
- // (nor does Win32Exception...)
- // but E_POINTER gets mapped to NullReferenceException,
- // so I don't think it will ever matter.
- Debug.Assert(!(e is ArgumentNullException));
-
- // If we're not getting anything better than a COMException from Marshal,
- // then at least check the facility and attempt to do better ourselves.
- if (e.GetType() == typeof(COMException))
- {
- switch (Facility)
- {
- case Facility.Win32:
- // Win32Exception generates default messages based on the error type.
- // Don't override this behavior if the caller didn't explicitly
- // specify something more appropriate.
- if (string.IsNullOrEmpty(message))
- {
- e = new Win32Exception(Code);
- }
- else
- {
- e = new Win32Exception(Code, message);
- }
- break;
- default:
- e = new COMException(message ?? e.Message, (int)_value);
- break;
- }
- }
- else
- {
- // Replace the message if we have something better.
- if (!string.IsNullOrEmpty(message))
- {
- ConstructorInfo cons = e.GetType().GetConstructor(new[] { typeof(string) });
- if (null != cons)
- {
- e = cons.Invoke(new object[] { message }) as Exception;
- Debug.Assert(e != null);
- }
- }
- }
-
- return e;
- }
- }
-}
diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj b/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj
index 9910284e9b2..954d63e0d06 100644
--- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj
+++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj
@@ -97,7 +97,6 @@
-
diff --git a/src/Microsoft.DotNet.Wpf/src/WpfGfx/include/wgx_error.cs b/src/Microsoft.DotNet.Wpf/src/WpfGfx/include/wgx_error.cs
deleted file mode 100644
index 34591bae8fa..00000000000
--- a/src/Microsoft.DotNet.Wpf/src/WpfGfx/include/wgx_error.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-//------------------------------------------------------------------------------
-//
-
-//
-//------------------------------------------------------------------------------
-
-namespace MS.Internal
-{
- #region Enumeration Types
-
- internal enum WinCodecErrors
- {
- // Range 0x?8982000 - 0x?8982FFF
- WINCODEC_ERR_GENERIC_ERROR = unchecked((int) 0x80004005),
- WINCODEC_ERR_INVALIDPARAMETER = unchecked((int) 0x80000003),
- WINCODEC_ERR_OUTOFMEMORY = unchecked((int) 0x80000002),
- WINCODEC_ERR_NOTIMPLEMENTED = unchecked((int) 0x80000001),
- WINCODEC_ERR_ABORTED = unchecked((int) 0x80004004),
- WINCODEC_ERR_ACCESSDENIED = unchecked((int) 0x80070005),
- WINCODEC_ERR_VALUEOVERFLOW = unchecked((int) 0x80070216),
- WINCODEC_ERR_WRONGSTATE = unchecked((int) 0x88982f04),
- WINCODEC_ERR_VALUEOUTOFRANGE = unchecked((int) 0x88982f05),
- WINCODEC_ERR_UNKNOWNIMAGEFORMAT = unchecked((int) 0x88982f07),
- WINCODEC_ERR_UNSUPPORTEDVERSION = unchecked((int) 0x88982f0B),
- WINCODEC_ERR_NOTINITIALIZED = unchecked((int) 0x88982f0C),
- WINCODEC_ERR_ALREADYLOCKED = unchecked((int) 0x88982f0D),
- WINCODEC_ERR_PROPERTYNOTFOUND = unchecked((int) 0x88982f40),
- WINCODEC_ERR_PROPERTYNOTSUPPORTED = unchecked((int) 0x88982f41),
- WINCODEC_ERR_PROPERTYSIZE = unchecked((int) 0x88982f42),
- WINCODEC_ERR_CODECPRESENT = unchecked((int) 0x88982f43),
- WINCODEC_ERR_CODECNOTHUMBNAIL = unchecked((int) 0x88982f44),
- WINCODEC_ERR_PALETTEUNAVAILABLE = unchecked((int) 0x88982f45),
- WINCODEC_ERR_CODECTOOMANYSCANLINES = unchecked((int) 0x88982f46),
- WINCODEC_ERR_INTERNALERROR = unchecked((int) 0x88982f48),
- WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS = unchecked((int) 0x88982f49),
- WINCODEC_ERR_COMPONENTNOTFOUND = unchecked((int) 0x88982f50),
- WINCODEC_ERR_IMAGESIZEOUTOFRANGE = unchecked((int) 0x88982f51),
- WINCODEC_ERR_TOOMUCHMETADATA = unchecked((int) 0x88982f52),
- WINCODEC_ERR_BADIMAGE = unchecked((int) 0x88982f60),
- WINCODEC_ERR_BADHEADER = unchecked((int) 0x88982f61),
- WINCODEC_ERR_FRAMEMISSING = unchecked((int) 0x88982f62),
- WINCODEC_ERR_BADMETADATAHEADER = unchecked((int) 0x88982f63),
- WINCODEC_ERR_BADSTREAMDATA = unchecked((int) 0x88982f70),
- WINCODEC_ERR_STREAMWRITE = unchecked((int) 0x88982f71),
- WINCODEC_ERR_STREAMREAD = unchecked((int) 0x88982f72),
- WINCODEC_ERR_STREAMNOTAVAILABLE = unchecked((int) 0x88982f73),
- WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT = unchecked((int) 0x88982f80),
- WINCODEC_ERR_UNSUPPORTEDOPERATION = unchecked((int) 0x88982f81),
- WINCODEC_ERR_INVALIDREGISTRATION = unchecked((int) 0x88982f8A),
- WINCODEC_ERR_COMPONENTINITIALIZEFAILURE = unchecked((int) 0x88982f8B),
- WINCODEC_ERR_INSUFFICIENTBUFFER = unchecked((int) 0x88982f8C),
- WINCODEC_ERR_DUPLICATEMETADATAPRESENT = unchecked((int) 0x88982f8D),
- WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE = unchecked((int) 0x88982f8E),
- WINCODEC_ERR_UNEXPECTEDSIZE = unchecked((int) 0x88982f8F),
- WINCODEC_ERR_INVALIDQUERYREQUEST = unchecked((int) 0x88982f90),
- WINCODEC_ERR_UNEXPECTEDMETADATATYPE = unchecked((int) 0x88982f91),
- WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT = unchecked((int) 0x88982f92),
- WINCODEC_ERR_INVALIDQUERYCHARACTER = unchecked((int) 0x88982f93),
- };
-
- internal enum MILErrors
- {
- // Range 0x?8980000 - 0x?8980FFF
- WGXHR_CLIPPEDTOEMPTY = unchecked((int) 0x8980001),
- WGXHR_EMPTYFILL = unchecked((int) 0x8980002),
- WGXHR_INTERNALTEMPORARYSUCCESS = unchecked((int) 0x8980003),
- WGXHR_RESETSHAREDHANDLEMANAGER = unchecked((int) 0x8980004),
- WGXERR_GENERIC_ERROR = unchecked((int) 0x80004005),
- WGXERR_INVALIDPARAMETER = unchecked((int) 0x80000003),
- WGXERR_OUTOFMEMORY = unchecked((int) 0x80000002),
- WGXERR_NOTIMPLEMENTED = unchecked((int) 0x80000001),
- WGXERR_ABORTED = unchecked((int) 0x80004004),
- WGXERR_ACCESSDENIED = unchecked((int) 0x80070005),
- WGXERR_VALUEOVERFLOW = unchecked((int) 0x80070216),
- WGXERR_WRONGSTATE = WinCodecErrors.WINCODEC_ERR_WRONGSTATE,
- WGXERR_UNSUPPORTEDVERSION = WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDVERSION,
- WGXERR_NOTINITIALIZED = WinCodecErrors.WINCODEC_ERR_NOTINITIALIZED,
- WGXERR_UNSUPPORTEDPIXELFORMAT = WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT,
- WGXERR_UNSUPPORTED_OPERATION = WinCodecErrors.WINCODEC_ERR_UNSUPPORTEDOPERATION,
- WGXERR_PALETTEUNAVAILABLE = WinCodecErrors.WINCODEC_ERR_PALETTEUNAVAILABLE,
- WGXERR_OBJECTBUSY = unchecked((int) 0x88980001),
- WGXERR_INSUFFICIENTBUFFER = unchecked((int) 0x88980002),
- WGXERR_WIN32ERROR = unchecked((int) 0x88980003),
- WGXERR_SCANNER_FAILED = unchecked((int) 0x88980004),
- WGXERR_SCREENACCESSDENIED = unchecked((int) 0x88980005),
- WGXERR_DISPLAYSTATEINVALID = unchecked((int) 0x88980006),
- WGXERR_NONINVERTIBLEMATRIX = unchecked((int) 0x88980007),
- WGXERR_ZEROVECTOR = unchecked((int) 0x88980008),
- WGXERR_TERMINATED = unchecked((int) 0x88980009),
- WGXERR_BADNUMBER = unchecked((int) 0x8898000A),
- WGXERR_INTERNALERROR = unchecked((int) 0x88980080),
- WGXERR_DISPLAYFORMATNOTSUPPORTED = unchecked((int) 0x88980084),
- WGXERR_INVALIDCALL = unchecked((int) 0x88980085),
- WGXERR_ALREADYLOCKED = unchecked((int) 0x88980086),
- WGXERR_NOTLOCKED = unchecked((int) 0x88980087),
- WGXERR_DEVICECANNOTRENDERTEXT = unchecked((int) 0x88980088),
- WGXERR_GLYPHBITMAPMISSED = unchecked((int) 0x88980089),
- WGXERR_MALFORMEDGLYPHCACHE = unchecked((int) 0x8898008A),
- WGXERR_GENERIC_IGNORE = unchecked((int) 0x8898008B),
- WGXERR_MALFORMED_GUIDELINE_DATA = unchecked((int) 0x8898008C),
- WGXERR_NO_HARDWARE_DEVICE = unchecked((int) 0x8898008D),
- WGXERR_NEED_RECREATE_AND_PRESENT = unchecked((int) 0x8898008E),
- WGXERR_ALREADY_INITIALIZED = unchecked((int) 0x8898008F),
- WGXERR_MISMATCHED_SIZE = unchecked((int) 0x88980090),
- WGXERR_NO_REDIRECTION_SURFACE_AVAILABLE = unchecked((int) 0x88980091),
- WGXERR_REMOTING_NOT_SUPPORTED = unchecked((int) 0x88980092),
- WGXERR_QUEUED_PRESENT_NOT_SUPPORTED = unchecked((int) 0x88980093),
- WGXERR_NOT_QUEUING_PRESENTS = unchecked((int) 0x88980094),
- WGXERR_NO_REDIRECTION_SURFACE_RETRY_LATER = unchecked((int) 0x88980095),
- WGXERR_TOOMANYSHADERELEMNTS = unchecked((int) 0x88980096),
- // AVAILABLE = unchecked((int) 0x88980097),
- // AVAILABLE = unchecked((int) 0x88980098),
- WGXERR_SHADER_COMPILE_FAILED = unchecked((int) 0x88980099),
- WGXERR_MAX_TEXTURE_SIZE_EXCEEDED = unchecked((int) 0x8898009A),
- // AVAILABLE = unchecked((int) 0x8898009B),
- WGXERR_UCE_INVALIDPACKETHEADER = unchecked((int) 0x88980400),
- WGXERR_UCE_UNKNOWNPACKET = unchecked((int) 0x88980401),
- WGXERR_UCE_ILLEGALPACKET = unchecked((int) 0x88980402),
- WGXERR_UCE_MALFORMEDPACKET = unchecked((int) 0x88980403),
- WGXERR_UCE_ILLEGALHANDLE = unchecked((int) 0x88980404),
- WGXERR_UCE_HANDLELOOKUPFAILED = unchecked((int) 0x88980405),
- WGXERR_UCE_RENDERTHREADFAILURE = unchecked((int) 0x88980406),
- WGXERR_UCE_CTXSTACKFRSTTARGETNULL = unchecked((int) 0x88980407),
- WGXERR_UCE_CONNECTIONIDLOOKUPFAILED = unchecked((int) 0x88980408),
- WGXERR_UCE_BLOCKSFULL = unchecked((int) 0x88980409),
- WGXERR_UCE_MEMORYFAILURE = unchecked((int) 0x8898040A),
- WGXERR_UCE_PACKETRECORDOUTOFRANGE = unchecked((int) 0x8898040B),
- WGXERR_UCE_ILLEGALRECORDTYPE = unchecked((int) 0x8898040C),
- WGXERR_UCE_OUTOFHANDLES = unchecked((int) 0x8898040D),
- WGXERR_UCE_UNCHANGABLE_UPDATE_ATTEMPTED = unchecked((int) 0x8898040E),
- WGXERR_UCE_NO_MULTIPLE_WORKER_THREADS = unchecked((int) 0x8898040F),
- WGXERR_UCE_REMOTINGNOTSUPPORTED = unchecked((int) 0x88980410),
- WGXERR_UCE_MISSINGENDCOMMAND = unchecked((int) 0x88980411),
- WGXERR_UCE_MISSINGBEGINCOMMAND = unchecked((int) 0x88980412),
- WGXERR_UCE_CHANNELSYNCTIMEDOUT = unchecked((int) 0x88980413),
- WGXERR_UCE_CHANNELSYNCABANDONED = unchecked((int) 0x88980414),
- WGXERR_UCE_UNSUPPORTEDTRANSPORTVERSION = unchecked((int) 0x88980415),
- WGXERR_UCE_TRANSPORTUNAVAILABLE = unchecked((int) 0x88980416),
- WGXERR_UCE_FEEDBACK_UNSUPPORTED = unchecked((int) 0x88980417),
- WGXERR_UCE_COMMANDTRANSPORTDENIED = unchecked((int) 0x88980418),
- WGXERR_UCE_GRAPHICSSTREAMUNAVAILABLE = unchecked((int) 0x88980419),
- WGXERR_UCE_GRAPHICSSTREAMALREADYOPEN = unchecked((int) 0x88980420),
- WGXERR_UCE_TRANSPORTDISCONNECTED = unchecked((int) 0x88980421),
- WGXERR_UCE_TRANSPORTOVERLOADED = unchecked((int) 0x88980422),
- WGXERR_UCE_PARTITION_ZOMBIED = unchecked((int) 0x88980423),
- WGXERR_UCE_USER_SHADEREFFECT_ERROR = unchecked((int) 0x88980424),
- WGXERR_AV_NOCLOCK = unchecked((int) 0x88980500),
- WGXERR_AV_NOMEDIATYPE = unchecked((int) 0x88980501),
- WGXERR_AV_NOVIDEOMIXER = unchecked((int) 0x88980502),
- WGXERR_AV_NOVIDEOPRESENTER = unchecked((int) 0x88980503),
- WGXERR_AV_NOREADYFRAMES = unchecked((int) 0x88980504),
- WGXERR_AV_MODULENOTLOADED = unchecked((int) 0x88980505),
- WGXERR_AV_WMPFACTORYNOTREGISTERED = unchecked((int) 0x88980506),
- WGXERR_AV_INVALIDWMPVERSION = unchecked((int) 0x88980507),
- WGXERR_AV_INSUFFICIENTVIDEORESOURCES = unchecked((int) 0x88980508),
- WGXERR_AV_VIDEOACCELERATIONNOTAVAILABLE = unchecked((int) 0x88980509),
- WGXERR_AV_REQUESTEDTEXTURETOOBIG = unchecked((int) 0x8898050A),
- WGXERR_AV_SEEKFAILED = unchecked((int) 0x8898050B),
- WGXERR_AV_UNEXPECTEDWMPFAILURE = unchecked((int) 0x8898050C),
- WGXERR_AV_MEDIAPLAYERCLOSED = unchecked((int) 0x8898050D),
- WGXERR_AV_UNKNOWNHARDWAREERROR = unchecked((int) 0x8898050E),
- WGXERR_D3DI_INVALIDSURFACEUSAGE = unchecked((int) 0x88980800),
- WGXERR_D3DI_INVALIDSURFACESIZE = unchecked((int) 0x88980801),
- WGXERR_D3DI_INVALIDSURFACEPOOL = unchecked((int) 0x88980802),
- WGXERR_D3DI_INVALIDSURFACEDEVICE = unchecked((int) 0x88980803),
- WGXERR_D3DI_INVALIDANTIALIASINGSETTINGS = unchecked((int) 0x88980804)
- };
-
- #endregion
-}
-
-
diff --git a/src/Microsoft.DotNet.Wpf/tests/Directory.Build.props b/src/Microsoft.DotNet.Wpf/tests/Directory.Build.props
index 797955552c5..31cfb0cd4a3 100644
--- a/src/Microsoft.DotNet.Wpf/tests/Directory.Build.props
+++ b/src/Microsoft.DotNet.Wpf/tests/Directory.Build.props
@@ -5,5 +5,6 @@
false
true
true
+ Open
diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/PresentationCore.Tests.csproj b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/PresentationCore.Tests.csproj
index 22b66899765..f5eaaae2319 100644
--- a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/PresentationCore.Tests.csproj
+++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/PresentationCore.Tests.csproj
@@ -19,9 +19,11 @@
+
+
@@ -32,4 +34,8 @@
+
+
+
+
diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/Windows/Win32/Foundation/HResultTests.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/Windows/Win32/Foundation/HResultTests.cs
new file mode 100644
index 00000000000..f3e662411df
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/Windows/Win32/Foundation/HResultTests.cs
@@ -0,0 +1,27 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Windows.Media;
+using static Windows.Win32.Foundation.HResultExtensions;
+
+namespace Windows.Win32.Foundation;
+
+public class HResultTests
+{
+ [Theory]
+ [MemberData(nameof(HResultTestData))]
+ public void HResult_GetExtendedException(int result, Type expectedType)
+ {
+ Exception? e = ((HRESULT)result).GetExtendedException();
+ e.Should().BeOfType(expectedType);
+ }
+
+ public static TheoryData HResultTestData => new()
+ {
+ { HRESULT.FromWin32(WIN32_ERROR.ERROR_ARITHMETIC_OVERFLOW), typeof(OverflowException) },
+ { HRESULT.FromWin32(WIN32_ERROR.ERROR_INVALID_PARAMETER), typeof(ArgumentException) },
+ { MilErrors.WGXERR_AV_INVALIDWMPVERSION, typeof(InvalidWmpVersionException) },
+ { MediaPlayerErrors.NS_E_WMP_CANNOT_FIND_FILE, typeof(FileNotFoundException) },
+ { HRESULT.WINCODEC_ERR_UNSUPPORTEDVERSION, typeof(FileLoadException) }
+ };
+}
diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/GlobalUsings.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/GlobalUsings.cs
new file mode 100644
index 00000000000..836fe4797a2
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/GlobalUsings.cs
@@ -0,0 +1,6 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+global using System;
+global using Xunit;
+global using FluentAssertions;
diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/System.Windows.Primitives.Tests.csproj b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/System.Windows.Primitives.Tests.csproj
new file mode 100644
index 00000000000..da928c407b1
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/System.Windows.Primitives.Tests.csproj
@@ -0,0 +1,25 @@
+
+
+ true
+ enable
+ x64;x86;arm64
+
+ $(TargetFramework)-windows
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/Windows/Win32/Foundation/D3dErrorsTests.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/Windows/Win32/Foundation/D3dErrorsTests.cs
new file mode 100644
index 00000000000..01f240ea1d6
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/Windows/Win32/Foundation/D3dErrorsTests.cs
@@ -0,0 +1,21 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace Windows.Win32.Foundation;
+
+public class D3dErrorsTests
+{
+ [Theory]
+ [MemberData(nameof(D3dErrorTestData))]
+ public void D3dErrors_ValidateDefines(int result, int expected)
+ {
+ result.Should().Be(expected);
+ }
+
+ public static TheoryData D3dErrorTestData => new()
+ {
+ // Check a few to see that we've copied the pattern correctly
+ { (int)D3dErrors.D3DERR_DEVICEHUNG, unchecked((int)0x88760874) },
+ { (int)D3dErrors.D3DERR_OUTOFVIDEOMEMORY, unchecked((int)0x8876017C) }
+ };
+}
diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/Windows/Win32/Foundation/HResultTests.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/Windows/Win32/Foundation/HResultTests.cs
new file mode 100644
index 00000000000..fab6faa6c7c
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/Windows/Win32/Foundation/HResultTests.cs
@@ -0,0 +1,184 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.ComponentModel;
+using Windows.Win32.System.Diagnostics.Debug;
+
+namespace Windows.Win32.Foundation;
+
+public class HResultTests
+{
+ [Theory]
+ [MemberData(nameof(HResultTestData))]
+ public void HResult_GetExceptionUnwrapWin32(int result, Type expectedType)
+ {
+ Exception? e = ((HRESULT)result).GetExceptionUnwrapWin32();
+ e.Should().BeOfType(expectedType);
+ }
+
+ public static TheoryData HResultTestData => new()
+ {
+ { HRESULT.FromWin32(WIN32_ERROR.ERROR_ACCESS_DENIED), typeof(UnauthorizedAccessException) },
+ { HRESULT.COR_E_ARGUMENT, typeof(ArgumentException) },
+ { HRESULT.FromWin32(WIN32_ERROR.ERROR_INVALID_HANDLE), typeof(Win32Exception) }
+ };
+
+ [Theory]
+ [MemberData(nameof(WicFacilityTestData))]
+ public void WicFacilityCode(int result, int expectedFacility)
+ {
+ FACILITY_CODE code = ((HRESULT)result).Facility;
+ code.Should().Be((FACILITY_CODE)expectedFacility);
+ }
+
+ public static TheoryData WicFacilityTestData => new()
+ {
+ {
+ (int)HRESULT.WINCODEC_ERR_WRONGSTATE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_VALUEOUTOFRANGE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ // #define INTSAFE_E_ARITHMETIC_OVERFLOW ((HRESULT)0x80070216L) // 0x216 = 534 = ERROR_ARITHMETIC_OVERFLOW
+ //{ (int)HRESULT.WINCODEC_ERR_VALUEOVERFLOW, (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM },
+ {
+ (int)HRESULT.WINCODEC_ERR_UNKNOWNIMAGEFORMAT,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_UNSUPPORTEDVERSION,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_NOTINITIALIZED,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_PROPERTYNOTFOUND,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_PROPERTYNOTSUPPORTED,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_PROPERTYSIZE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_CODECPRESENT,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_CODECNOTHUMBNAIL,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_PALETTEUNAVAILABLE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_CODECTOOMANYSCANLINES,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_INTERNALERROR,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_COMPONENTINITIALIZEFAILURE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_COMPONENTNOTFOUND,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_UNEXPECTEDSIZE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_BADIMAGE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_BADHEADER,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_FRAMEMISSING,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_BADMETADATAHEADER,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_BADSTREAMDATA,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_STREAMWRITE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_UNSUPPORTEDOPERATION,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_IMAGESIZEOUTOFRANGE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_STREAMREAD,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_INVALIDQUERYREQUEST,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_UNEXPECTEDMETADATATYPE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_INVALIDQUERYCHARACTER,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_DUPLICATEMETADATAPRESENT,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_TOOMUCHMETADATA,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_STREAMNOTAVAILABLE,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ {
+ (int)HRESULT.WINCODEC_ERR_INSUFFICIENTBUFFER,
+ (int)FACILITY_CODE.FACILITY_WINCODEC_DWRITE_DWM
+ },
+ };
+
+}
diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/Windows/Win32/Foundation/MilErrorsTests.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/Windows/Win32/Foundation/MilErrorsTests.cs
new file mode 100644
index 00000000000..53b373d5c5c
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/System.Windows.Primitives.Tests/Windows/Win32/Foundation/MilErrorsTests.cs
@@ -0,0 +1,23 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace Windows.Win32.Foundation;
+
+public class MilErrorsTests
+{
+ [Theory]
+ [MemberData(nameof(MilErrorTestData))]
+ public void MilErrors_ValidateDefines(int result, int expected)
+ {
+ result.Should().Be(expected);
+ }
+
+ public static TheoryData MilErrorTestData => new()
+ {
+ // Check a few to see that we've copied the pattern correctly
+ { (int)MilErrors.WGXHR_CLIPPEDTOEMPTY, 0x8980001 },
+ { (int)MilErrors.WGXERR_OBJECTBUSY, unchecked((int)0x88980001) },
+ { (int)MilErrors.WGXERR_UCE_UNSUPPORTEDTRANSPORTVERSION, unchecked((int)0x88980415) },
+ { (int)MilErrors.WGXERR_AV_UNKNOWNHARDWAREERROR, unchecked((int)0x8898050E) },
+ };
+}
diff --git a/start-vs.cmd b/start-vs.cmd
index fd1f22fa298..515d4dd0b57 100644
--- a/start-vs.cmd
+++ b/start-vs.cmd
@@ -3,19 +3,21 @@ setlocal enabledelayedexpansion
:: This command launches a Visual Studio solution with environment variables required to use a local version of the .NET Core SDK.
+set _localDotNet=%~dp0.dotnet
+
:: This tells .NET Core to use the same dotnet.exe that build scripts use
-set DOTNET_ROOT=%~dp0.dotnet
-set DOTNET_ROOT(x86)=%~dp0.dotnet\x86
+set DOTNET_ROOT=%_localDotNet%
+set DOTNET_ROOT(x86)=%_localDotNet%\x86
:: This tells .NET Core not to go looking for .NET Core in other places
-set DOTNET_MULTILEVEL_LOOKUP=0
+:: set DOTNET_MULTILEVEL_LOOKUP=0
:: Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
-set PATH=%DOTNET_ROOT%;%PATH%
+set PATH=%_localDotNet%;%PATH%
call restore.cmd
-if not exist "%DOTNET_ROOT%\dotnet.exe" (
+if not exist "%_localDotNet%\dotnet.exe" (
echo [ERROR] .NET Core has not yet been installed. Run `%~dp0restore.cmd` to install tools
exit /b 1
)