Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Advanced / MetafileHeader.cs / 1305376 / MetafileHeader.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing.Imaging {
using System.Configuration.Assemblies;
using System.Diagnostics;
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Drawing.Internal;
///
///
/// Contains attributes of an
/// associated .
///
[StructLayout(LayoutKind.Sequential)]
public sealed class MetafileHeader
{
// determine which to use by nullity
internal MetafileHeaderWmf wmf;
internal MetafileHeaderEmf emf;
internal MetafileHeader()
{
}
///
///
/// Gets the type of the associated .
///
public MetafileType Type
{
get
{
return IsWmf() ? wmf.type : emf.type;
}
}
///
///
///
/// Gets the size, in bytes, of the associated
/// .
///
///
public int MetafileSize
{
get
{
return IsWmf() ? wmf.size : emf.size;
}
}
///
///
/// Gets the version number of the associated
/// .
///
public int Version
{
get
{
return IsWmf() ? wmf.version : emf.version;
}
}
/* FxCop rule 'AvoidBuildingNonCallableCode' - Left here in case it is needed in the future.
private EmfPlusFlags EmfPlusFlags
{
get
{
return IsWmf() ? wmf.emfPlusFlags : emf.emfPlusFlags;
}
}
*/
///
///
/// Gets the horizontal resolution, in
/// dots-per-inch, of the associated .
///
public float DpiX
{
get
{
return IsWmf() ? wmf.dpiX : emf.dpiX;
}
}
///
///
/// Gets the vertical resolution, in
/// dots-per-inch, of the associated .
///
public float DpiY
{
get
{
return IsWmf() ? wmf.dpiY : emf.dpiY;
}
}
///
///
/// Gets a that bounds the associated
/// .
///
public Rectangle Bounds
{
get
{
return IsWmf() ?
new Rectangle(wmf.X, wmf.Y, wmf.Width, wmf.Height) :
new Rectangle(emf.X, emf.Y, emf.Width, emf.Height);
}
}
///
///
/// Returns a value indicating whether the
/// associated is in the Windows metafile
/// format.
///
public bool IsWmf()
{
if ((wmf == null) && (emf == null))
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
if ((wmf != null) &&
((wmf.type == MetafileType.Wmf) ||
(wmf.type == MetafileType.WmfPlaceable)))
return true;
else
return false;
}
///
///
///
/// Returns a value indicating whether the
/// associated is in the Windows Placeable metafile
/// format.
///
///
public bool IsWmfPlaceable()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((wmf != null) && (wmf.type == MetafileType.WmfPlaceable));
}
///
///
/// Returns a value indicating whether the
/// associated is in the Windows enhanced metafile
/// format.
///
public bool IsEmf()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type == MetafileType.Emf));
}
///
///
/// Returns a value indicating whether the
/// associated is in the Windows enhanced metafile
/// format or the Windows enhanced metafile plus.
///
public bool IsEmfOrEmfPlus()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type >= MetafileType.Emf));
}
///
///
/// Returns a value indicating whether the
/// associated is in the Windows enhanced metafile
/// plus format.
///
public bool IsEmfPlus()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type >= MetafileType.EmfPlusOnly));
}
///
///
/// Returns a value indicating whether the
/// associated is in the Dual enhanced
/// metafile format. This format supports both the enhanced and the enhanced
/// plus format.
///
public bool IsEmfPlusDual()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type == MetafileType.EmfPlusDual));
}
///
///
///
/// Returns a value indicating whether the associated supports only the Windows
/// enhanced metafile plus format.
///
///
public bool IsEmfPlusOnly()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type == MetafileType.EmfPlusOnly));
}
///
///
///
/// Returns a value indicating whether the associated is device-dependent.
///
///
public bool IsDisplay()
{
return IsEmfPlus() &&
((((int)emf.emfPlusFlags) & ((int)EmfPlusFlags.Display)) != 0);
}
///
///
/// Gets the WMF header file for the associated
/// .
///
public MetaHeader WmfHeader
{
get
{
if (wmf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return wmf.WmfHeader;
}
}
///
///
///
/// Gets the WMF header file for the associated .
///
///
/* FxCop rule 'AvoidBuildingNonCallableCode' - Left here in case it is needed in the future.
internal SafeNativeMethods.ENHMETAHEADER EmfHeader
{
get
{
if (emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return emf.EmfHeader;
}
}
*/
///
///
/// Gets the size, in bytes, of the
/// enhanced metafile plus header file.
///
public int EmfPlusHeaderSize
{
get {
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return IsWmf() ? wmf.EmfPlusHeaderSize : emf.EmfPlusHeaderSize;
}
}
///
///
///
/// Gets the logical horizontal resolution, in
/// dots-per-inch, of the associated .
///
///
public int LogicalDpiX
{
get {
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return IsWmf() ? wmf.LogicalDpiX : emf.LogicalDpiX;
}
}
///
///
/// Gets the logical vertical resolution, in
/// dots-per-inch, of the associated .
///
public int LogicalDpiY
{
get {
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return IsWmf() ? wmf.LogicalDpiY : emf.LogicalDpiX;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing.Imaging {
using System.Configuration.Assemblies;
using System.Diagnostics;
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Drawing.Internal;
///
///
/// Contains attributes of an
/// associated .
///
[StructLayout(LayoutKind.Sequential)]
public sealed class MetafileHeader
{
// determine which to use by nullity
internal MetafileHeaderWmf wmf;
internal MetafileHeaderEmf emf;
internal MetafileHeader()
{
}
///
///
/// Gets the type of the associated .
///
public MetafileType Type
{
get
{
return IsWmf() ? wmf.type : emf.type;
}
}
///
///
///
/// Gets the size, in bytes, of the associated
/// .
///
///
public int MetafileSize
{
get
{
return IsWmf() ? wmf.size : emf.size;
}
}
///
///
/// Gets the version number of the associated
/// .
///
public int Version
{
get
{
return IsWmf() ? wmf.version : emf.version;
}
}
/* FxCop rule 'AvoidBuildingNonCallableCode' - Left here in case it is needed in the future.
private EmfPlusFlags EmfPlusFlags
{
get
{
return IsWmf() ? wmf.emfPlusFlags : emf.emfPlusFlags;
}
}
*/
///
///
/// Gets the horizontal resolution, in
/// dots-per-inch, of the associated .
///
public float DpiX
{
get
{
return IsWmf() ? wmf.dpiX : emf.dpiX;
}
}
///
///
/// Gets the vertical resolution, in
/// dots-per-inch, of the associated .
///
public float DpiY
{
get
{
return IsWmf() ? wmf.dpiY : emf.dpiY;
}
}
///
///
/// Gets a that bounds the associated
/// .
///
public Rectangle Bounds
{
get
{
return IsWmf() ?
new Rectangle(wmf.X, wmf.Y, wmf.Width, wmf.Height) :
new Rectangle(emf.X, emf.Y, emf.Width, emf.Height);
}
}
///
///
/// Returns a value indicating whether the
/// associated is in the Windows metafile
/// format.
///
public bool IsWmf()
{
if ((wmf == null) && (emf == null))
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
if ((wmf != null) &&
((wmf.type == MetafileType.Wmf) ||
(wmf.type == MetafileType.WmfPlaceable)))
return true;
else
return false;
}
///
///
///
/// Returns a value indicating whether the
/// associated is in the Windows Placeable metafile
/// format.
///
///
public bool IsWmfPlaceable()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((wmf != null) && (wmf.type == MetafileType.WmfPlaceable));
}
///
///
/// Returns a value indicating whether the
/// associated is in the Windows enhanced metafile
/// format.
///
public bool IsEmf()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type == MetafileType.Emf));
}
///
///
/// Returns a value indicating whether the
/// associated is in the Windows enhanced metafile
/// format or the Windows enhanced metafile plus.
///
public bool IsEmfOrEmfPlus()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type >= MetafileType.Emf));
}
///
///
/// Returns a value indicating whether the
/// associated is in the Windows enhanced metafile
/// plus format.
///
public bool IsEmfPlus()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type >= MetafileType.EmfPlusOnly));
}
///
///
/// Returns a value indicating whether the
/// associated is in the Dual enhanced
/// metafile format. This format supports both the enhanced and the enhanced
/// plus format.
///
public bool IsEmfPlusDual()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type == MetafileType.EmfPlusDual));
}
///
///
///
/// Returns a value indicating whether the associated supports only the Windows
/// enhanced metafile plus format.
///
///
public bool IsEmfPlusOnly()
{
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return ((emf != null) && (emf.type == MetafileType.EmfPlusOnly));
}
///
///
///
/// Returns a value indicating whether the associated is device-dependent.
///
///
public bool IsDisplay()
{
return IsEmfPlus() &&
((((int)emf.emfPlusFlags) & ((int)EmfPlusFlags.Display)) != 0);
}
///
///
/// Gets the WMF header file for the associated
/// .
///
public MetaHeader WmfHeader
{
get
{
if (wmf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return wmf.WmfHeader;
}
}
///
///
///
/// Gets the WMF header file for the associated .
///
///
/* FxCop rule 'AvoidBuildingNonCallableCode' - Left here in case it is needed in the future.
internal SafeNativeMethods.ENHMETAHEADER EmfHeader
{
get
{
if (emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return emf.EmfHeader;
}
}
*/
///
///
/// Gets the size, in bytes, of the
/// enhanced metafile plus header file.
///
public int EmfPlusHeaderSize
{
get {
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return IsWmf() ? wmf.EmfPlusHeaderSize : emf.EmfPlusHeaderSize;
}
}
///
///
///
/// Gets the logical horizontal resolution, in
/// dots-per-inch, of the associated .
///
///
public int LogicalDpiX
{
get {
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return IsWmf() ? wmf.LogicalDpiX : emf.LogicalDpiX;
}
}
///
///
/// Gets the logical vertical resolution, in
/// dots-per-inch, of the associated .
///
public int LogicalDpiY
{
get {
if (wmf == null && emf == null)
throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
return IsWmf() ? wmf.LogicalDpiY : emf.LogicalDpiX;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Int16Storage.cs
- SynchronizationLockException.cs
- SqlBuilder.cs
- ViewStateException.cs
- AffineTransform3D.cs
- Hash.cs
- FontFamilyConverter.cs
- Input.cs
- ExpressionPrinter.cs
- BamlLocalizabilityResolver.cs
- ExtensionWindowHeader.cs
- EntityDescriptor.cs
- Effect.cs
- SelectionProviderWrapper.cs
- EntityClientCacheEntry.cs
- Classification.cs
- ReadWriteObjectLock.cs
- ProviderSettings.cs
- CompilerState.cs
- WebPartCatalogAddVerb.cs
- CultureTableRecord.cs
- XpsResource.cs
- FixedSOMElement.cs
- CLSCompliantAttribute.cs
- TreeViewImageIndexConverter.cs
- BooleanFunctions.cs
- SmtpTransport.cs
- DataServiceRequestOfT.cs
- HMACMD5.cs
- XsdCachingReader.cs
- AttachedAnnotationChangedEventArgs.cs
- RepeaterItem.cs
- MessageFault.cs
- TextEditorTables.cs
- MSAAEventDispatcher.cs
- StrongNamePublicKeyBlob.cs
- WebPartDisplayModeCollection.cs
- HebrewCalendar.cs
- TableLayoutRowStyleCollection.cs
- DispatcherExceptionFilterEventArgs.cs
- SemanticResolver.cs
- InsufficientMemoryException.cs
- Selection.cs
- RedirectionProxy.cs
- XsltLibrary.cs
- VectorConverter.cs
- IdentityModelDictionary.cs
- MDIClient.cs
- MemberRelationshipService.cs
- StrokeRenderer.cs
- TargetControlTypeAttribute.cs
- SharedPerformanceCounter.cs
- Socket.cs
- FieldInfo.cs
- InstanceCreationEditor.cs
- ObjectQueryProvider.cs
- OutputCacheSection.cs
- TypeDescriptorFilterService.cs
- DataGridViewRowsAddedEventArgs.cs
- Win32SafeHandles.cs
- ReflectionServiceProvider.cs
- CryptoKeySecurity.cs
- ListViewContainer.cs
- TreeViewItem.cs
- PeerMessageDispatcher.cs
- GlobalItem.cs
- AsyncSerializedWorker.cs
- ImportCatalogPart.cs
- XmlTextEncoder.cs
- Viewport2DVisual3D.cs
- ExpressionsCollectionConverter.cs
- DispatchWrapper.cs
- XmlElementAttribute.cs
- WebScriptServiceHostFactory.cs
- WhitespaceRule.cs
- ParseHttpDate.cs
- Stopwatch.cs
- AddingNewEventArgs.cs
- CallInfo.cs
- ResourceContainer.cs
- ObjectTag.cs
- BuildProvider.cs
- Authorization.cs
- EventLog.cs
- TreeNodeCollectionEditor.cs
- ReaderWriterLock.cs
- List.cs
- _CookieModule.cs
- RegexRunnerFactory.cs
- JournalNavigationScope.cs
- AddInController.cs
- View.cs
- CqlQuery.cs
- WrapPanel.cs
- BackgroundFormatInfo.cs
- Timer.cs
- LayoutTable.cs
- DBSqlParserTable.cs
- OrderedDictionaryStateHelper.cs
- CharEntityEncoderFallback.cs