Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / RenderOptions.cs / 1305600 / RenderOptions.cs
//------------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description:
// The RenderOptions class provides definitions of attached properties
// which will control rendering.
//
//-----------------------------------------------------------------------------
using MS.Win32.PresentationCore;
using System;
using System.Diagnostics;
using System.Security;
using System.Security.Permissions;
using System.Windows.Interop;
namespace System.Windows.Media
{
///
/// RenderOptions -
/// The RenderOptions class provides definitions of attached properties
/// which will control rendering.
///
public static class RenderOptions
{
//
// EdgeMode
//
///
/// EdgeModeProperty - Enum which descibes the manner in which we render edges of non-text primitives.
///
public static readonly DependencyProperty EdgeModeProperty =
DependencyProperty.RegisterAttached("EdgeMode",
typeof(EdgeMode),
typeof(RenderOptions),
new UIPropertyMetadata(EdgeMode.Unspecified),
new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsEdgeModeValid));
///
/// Reads the attached property EdgeMode from the given object.
///
[AttachedPropertyBrowsableForType(typeof(DependencyObject))]
public static EdgeMode GetEdgeMode(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (EdgeMode)target.GetValue(EdgeModeProperty);
}
///
/// Writes the attached property EdgeMode to the given object.
///
public static void SetEdgeMode(DependencyObject target, EdgeMode edgeMode)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(EdgeModeProperty, edgeMode);
}
//
// BitmapScaling
//
///
/// BitmapScalingModeProperty - Enum which describes the manner in which we scale the images.
///
public static readonly DependencyProperty BitmapScalingModeProperty =
DependencyProperty.RegisterAttached("BitmapScalingMode",
typeof(BitmapScalingMode),
typeof(RenderOptions),
new UIPropertyMetadata(BitmapScalingMode.Unspecified),
new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsBitmapScalingModeValid));
///
/// Reads the attached property BitmapScalingMode from the given object.
///
[AttachedPropertyBrowsableForType(typeof(DependencyObject))]
public static BitmapScalingMode GetBitmapScalingMode(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (BitmapScalingMode)target.GetValue(BitmapScalingModeProperty);
}
///
/// Writes the attached property BitmapScalingMode to the given object.
///
public static void SetBitmapScalingMode(DependencyObject target, BitmapScalingMode bitmapScalingMode)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(BitmapScalingModeProperty, bitmapScalingMode);
}
//
// ClearTypeHint
//
///
/// ClearTypeHint - Enum which describes the ability to re-enable ClearType rendering in intermediates.
///
public static readonly DependencyProperty ClearTypeHintProperty =
DependencyProperty.RegisterAttached("ClearTypeHint",
typeof(ClearTypeHint),
typeof(RenderOptions),
new UIPropertyMetadata(ClearTypeHint.Auto),
new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsClearTypeHintValid));
///
/// Reads the attached property ClearTypeHint from the given object.
///
[AttachedPropertyBrowsableForType(typeof(DependencyObject))]
public static ClearTypeHint GetClearTypeHint(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (ClearTypeHint)target.GetValue(ClearTypeHintProperty);
}
///
/// Writes the attached property ClearTypeHint to the given object.
///
public static void SetClearTypeHint(DependencyObject target, ClearTypeHint clearTypeHint)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(ClearTypeHintProperty, clearTypeHint);
}
//
// CachingHint
//
///
/// CachingHintProperty - Hints the rendering engine that rendered content should be cached
/// when possible. This is currently supported on TileBrush.
///
public static readonly DependencyProperty CachingHintProperty =
DependencyProperty.RegisterAttached("CachingHint",
typeof(CachingHint),
typeof(RenderOptions),
new UIPropertyMetadata(CachingHint.Unspecified),
new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsCachingHintValid));
///
/// Reads the attached property CachingHint from the given object.
///
[AttachedPropertyBrowsableForType(typeof(TileBrush))]
public static CachingHint GetCachingHint(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (CachingHint)target.GetValue(CachingHintProperty);
}
///
/// Writes the attached property CachingHint to the given object.
///
public static void SetCachingHint(DependencyObject target, CachingHint cachingHint)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(CachingHintProperty, cachingHint);
}
//
// CacheInvalidationThresholdMinimum
//
///
/// CacheInvalidationThresholdMinimum -
///
public static readonly DependencyProperty CacheInvalidationThresholdMinimumProperty =
DependencyProperty.RegisterAttached("CacheInvalidationThresholdMinimum",
typeof(double),
typeof(RenderOptions),
new UIPropertyMetadata(0.707),
/* ValidateValueCallback */ null);
///
/// Reads the attached property CacheInvalidationThresholdMinimum from the given object.
///
[AttachedPropertyBrowsableForType(typeof(TileBrush))]
public static double GetCacheInvalidationThresholdMinimum(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (double)target.GetValue(CacheInvalidationThresholdMinimumProperty);
}
///
/// Writes the attached property CacheInvalidationThresholdMinimum to the given object.
///
public static void SetCacheInvalidationThresholdMinimum(DependencyObject target, double cacheInvalidationThresholdMinimum)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(CacheInvalidationThresholdMinimumProperty, cacheInvalidationThresholdMinimum);
}
//
// CacheInvalidationThresholdMaximum
//
///
/// CacheInvalidationThresholdMaximum -
///
public static readonly DependencyProperty CacheInvalidationThresholdMaximumProperty =
DependencyProperty.RegisterAttached("CacheInvalidationThresholdMaximum",
typeof(double),
typeof(RenderOptions),
new UIPropertyMetadata(1.414),
/* ValidateValueCallback */ null);
///
/// Reads the attached property CacheInvalidationThresholdMaximum from the given object.
///
[AttachedPropertyBrowsableForType(typeof(TileBrush))]
public static double GetCacheInvalidationThresholdMaximum(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (double)target.GetValue(CacheInvalidationThresholdMaximumProperty);
}
///
/// Writes the attached property CacheInvalidationThresholdMaximum to the given object.
///
public static void SetCacheInvalidationThresholdMaximum(DependencyObject target, double cacheInvalidationThresholdMaximum)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(CacheInvalidationThresholdMaximumProperty, cacheInvalidationThresholdMaximum);
}
///
/// Specifies the render mode preference for the process
///
///
/// This property specifies a preference, it does not necessarily change the actual
/// rendering mode. Among other things, this can be trumped by the registry settings.
///
/// Callers must have UIPermission(UIPermissionWindow.AllWindows) to set this property.
///
///
/// Critical: This code influences the low-level rendering code by specifying whether the
/// rendering system should use the GPU or CPU.
/// PublicOK: We don't want to enable this in partial trust, so we have a link demand
/// on the setter. It is not privileged data, so the getter is not protected.
///
public static RenderMode ProcessRenderMode
{
[SecurityCritical]
get
{
return UnsafeNativeMethods.MilCoreApi.RenderOptions_IsSoftwareRenderingForcedForProcess() ?
RenderMode.SoftwareOnly : RenderMode.Default;
}
[SecurityCritical]
[UIPermissionAttribute(SecurityAction.LinkDemand, Window = UIPermissionWindow.AllWindows)]
set
{
if (value != RenderMode.Default && value != RenderMode.SoftwareOnly)
{
throw new System.ComponentModel.InvalidEnumArgumentException("value", (int)value, typeof(RenderMode));
}
UnsafeNativeMethods.MilCoreApi.RenderOptions_ForceSoftwareRenderingModeForProcess(
value == RenderMode.SoftwareOnly
);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description:
// The RenderOptions class provides definitions of attached properties
// which will control rendering.
//
//-----------------------------------------------------------------------------
using MS.Win32.PresentationCore;
using System;
using System.Diagnostics;
using System.Security;
using System.Security.Permissions;
using System.Windows.Interop;
namespace System.Windows.Media
{
///
/// RenderOptions -
/// The RenderOptions class provides definitions of attached properties
/// which will control rendering.
///
public static class RenderOptions
{
//
// EdgeMode
//
///
/// EdgeModeProperty - Enum which descibes the manner in which we render edges of non-text primitives.
///
public static readonly DependencyProperty EdgeModeProperty =
DependencyProperty.RegisterAttached("EdgeMode",
typeof(EdgeMode),
typeof(RenderOptions),
new UIPropertyMetadata(EdgeMode.Unspecified),
new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsEdgeModeValid));
///
/// Reads the attached property EdgeMode from the given object.
///
[AttachedPropertyBrowsableForType(typeof(DependencyObject))]
public static EdgeMode GetEdgeMode(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (EdgeMode)target.GetValue(EdgeModeProperty);
}
///
/// Writes the attached property EdgeMode to the given object.
///
public static void SetEdgeMode(DependencyObject target, EdgeMode edgeMode)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(EdgeModeProperty, edgeMode);
}
//
// BitmapScaling
//
///
/// BitmapScalingModeProperty - Enum which describes the manner in which we scale the images.
///
public static readonly DependencyProperty BitmapScalingModeProperty =
DependencyProperty.RegisterAttached("BitmapScalingMode",
typeof(BitmapScalingMode),
typeof(RenderOptions),
new UIPropertyMetadata(BitmapScalingMode.Unspecified),
new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsBitmapScalingModeValid));
///
/// Reads the attached property BitmapScalingMode from the given object.
///
[AttachedPropertyBrowsableForType(typeof(DependencyObject))]
public static BitmapScalingMode GetBitmapScalingMode(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (BitmapScalingMode)target.GetValue(BitmapScalingModeProperty);
}
///
/// Writes the attached property BitmapScalingMode to the given object.
///
public static void SetBitmapScalingMode(DependencyObject target, BitmapScalingMode bitmapScalingMode)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(BitmapScalingModeProperty, bitmapScalingMode);
}
//
// ClearTypeHint
//
///
/// ClearTypeHint - Enum which describes the ability to re-enable ClearType rendering in intermediates.
///
public static readonly DependencyProperty ClearTypeHintProperty =
DependencyProperty.RegisterAttached("ClearTypeHint",
typeof(ClearTypeHint),
typeof(RenderOptions),
new UIPropertyMetadata(ClearTypeHint.Auto),
new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsClearTypeHintValid));
///
/// Reads the attached property ClearTypeHint from the given object.
///
[AttachedPropertyBrowsableForType(typeof(DependencyObject))]
public static ClearTypeHint GetClearTypeHint(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (ClearTypeHint)target.GetValue(ClearTypeHintProperty);
}
///
/// Writes the attached property ClearTypeHint to the given object.
///
public static void SetClearTypeHint(DependencyObject target, ClearTypeHint clearTypeHint)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(ClearTypeHintProperty, clearTypeHint);
}
//
// CachingHint
//
///
/// CachingHintProperty - Hints the rendering engine that rendered content should be cached
/// when possible. This is currently supported on TileBrush.
///
public static readonly DependencyProperty CachingHintProperty =
DependencyProperty.RegisterAttached("CachingHint",
typeof(CachingHint),
typeof(RenderOptions),
new UIPropertyMetadata(CachingHint.Unspecified),
new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsCachingHintValid));
///
/// Reads the attached property CachingHint from the given object.
///
[AttachedPropertyBrowsableForType(typeof(TileBrush))]
public static CachingHint GetCachingHint(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (CachingHint)target.GetValue(CachingHintProperty);
}
///
/// Writes the attached property CachingHint to the given object.
///
public static void SetCachingHint(DependencyObject target, CachingHint cachingHint)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(CachingHintProperty, cachingHint);
}
//
// CacheInvalidationThresholdMinimum
//
///
/// CacheInvalidationThresholdMinimum -
///
public static readonly DependencyProperty CacheInvalidationThresholdMinimumProperty =
DependencyProperty.RegisterAttached("CacheInvalidationThresholdMinimum",
typeof(double),
typeof(RenderOptions),
new UIPropertyMetadata(0.707),
/* ValidateValueCallback */ null);
///
/// Reads the attached property CacheInvalidationThresholdMinimum from the given object.
///
[AttachedPropertyBrowsableForType(typeof(TileBrush))]
public static double GetCacheInvalidationThresholdMinimum(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (double)target.GetValue(CacheInvalidationThresholdMinimumProperty);
}
///
/// Writes the attached property CacheInvalidationThresholdMinimum to the given object.
///
public static void SetCacheInvalidationThresholdMinimum(DependencyObject target, double cacheInvalidationThresholdMinimum)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(CacheInvalidationThresholdMinimumProperty, cacheInvalidationThresholdMinimum);
}
//
// CacheInvalidationThresholdMaximum
//
///
/// CacheInvalidationThresholdMaximum -
///
public static readonly DependencyProperty CacheInvalidationThresholdMaximumProperty =
DependencyProperty.RegisterAttached("CacheInvalidationThresholdMaximum",
typeof(double),
typeof(RenderOptions),
new UIPropertyMetadata(1.414),
/* ValidateValueCallback */ null);
///
/// Reads the attached property CacheInvalidationThresholdMaximum from the given object.
///
[AttachedPropertyBrowsableForType(typeof(TileBrush))]
public static double GetCacheInvalidationThresholdMaximum(DependencyObject target)
{
if (target == null) { throw new ArgumentNullException("target"); }
return (double)target.GetValue(CacheInvalidationThresholdMaximumProperty);
}
///
/// Writes the attached property CacheInvalidationThresholdMaximum to the given object.
///
public static void SetCacheInvalidationThresholdMaximum(DependencyObject target, double cacheInvalidationThresholdMaximum)
{
if (target == null) { throw new ArgumentNullException("target"); }
target.SetValue(CacheInvalidationThresholdMaximumProperty, cacheInvalidationThresholdMaximum);
}
///
/// Specifies the render mode preference for the process
///
///
/// This property specifies a preference, it does not necessarily change the actual
/// rendering mode. Among other things, this can be trumped by the registry settings.
///
/// Callers must have UIPermission(UIPermissionWindow.AllWindows) to set this property.
///
///
/// Critical: This code influences the low-level rendering code by specifying whether the
/// rendering system should use the GPU or CPU.
/// PublicOK: We don't want to enable this in partial trust, so we have a link demand
/// on the setter. It is not privileged data, so the getter is not protected.
///
public static RenderMode ProcessRenderMode
{
[SecurityCritical]
get
{
return UnsafeNativeMethods.MilCoreApi.RenderOptions_IsSoftwareRenderingForcedForProcess() ?
RenderMode.SoftwareOnly : RenderMode.Default;
}
[SecurityCritical]
[UIPermissionAttribute(SecurityAction.LinkDemand, Window = UIPermissionWindow.AllWindows)]
set
{
if (value != RenderMode.Default && value != RenderMode.SoftwareOnly)
{
throw new System.ComponentModel.InvalidEnumArgumentException("value", (int)value, typeof(RenderMode));
}
UnsafeNativeMethods.MilCoreApi.RenderOptions_ForceSoftwareRenderingModeForProcess(
value == RenderMode.SoftwareOnly
);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlSchemaAny.cs
- MembershipPasswordException.cs
- ZipPackage.cs
- ListParagraph.cs
- DropShadowEffect.cs
- ResourceAssociationTypeEnd.cs
- TableChangeProcessor.cs
- MasterPageCodeDomTreeGenerator.cs
- StretchValidation.cs
- PerformanceCounterLib.cs
- Configuration.cs
- CapabilitiesPattern.cs
- TextPatternIdentifiers.cs
- DesignColumn.cs
- OdbcConnectionPoolProviderInfo.cs
- KeyedHashAlgorithm.cs
- ProgressBar.cs
- HWStack.cs
- ProfileElement.cs
- RNGCryptoServiceProvider.cs
- WCFBuildProvider.cs
- UserUseLicenseDictionaryLoader.cs
- DataListItemCollection.cs
- PermissionAttributes.cs
- XmlSchemaSimpleContent.cs
- RowToFieldTransformer.cs
- CellRelation.cs
- ToolStripTextBox.cs
- CultureInfo.cs
- BooleanKeyFrameCollection.cs
- BaseTemplateBuildProvider.cs
- ITreeGenerator.cs
- XmlTypeMapping.cs
- CompiledQueryCacheKey.cs
- EncodingDataItem.cs
- ControlPropertyNameConverter.cs
- SelectionGlyph.cs
- InputReferenceExpression.cs
- ISAPIWorkerRequest.cs
- Html32TextWriter.cs
- ArrayConverter.cs
- DocComment.cs
- XmlSchemaProviderAttribute.cs
- RepeatEnumerable.cs
- RangeValidator.cs
- XmlSchemaSimpleTypeList.cs
- MouseButton.cs
- PresentationSource.cs
- webclient.cs
- FigureHelper.cs
- Attributes.cs
- CursorConverter.cs
- ThemeableAttribute.cs
- SHA512Cng.cs
- SHA384Cng.cs
- TabControlAutomationPeer.cs
- UnaryNode.cs
- CodeBinaryOperatorExpression.cs
- RegionInfo.cs
- IfAction.cs
- SerializationSectionGroup.cs
- SourceFileBuildProvider.cs
- CorrelationTokenTypeConvertor.cs
- RegexParser.cs
- StrongNameIdentityPermission.cs
- InternalResources.cs
- SQLRoleProvider.cs
- MatrixUtil.cs
- InstanceHandleReference.cs
- RegexTypeEditor.cs
- IHttpResponseInternal.cs
- VisualCollection.cs
- PackagePartCollection.cs
- RealProxy.cs
- MembershipValidatePasswordEventArgs.cs
- ComponentDispatcher.cs
- XmlElementElement.cs
- ApplicationProxyInternal.cs
- WsdlWriter.cs
- DataGridViewRowPostPaintEventArgs.cs
- StylusPlugInCollection.cs
- NameTable.cs
- ObjectQuery_EntitySqlExtensions.cs
- WebPartPersonalization.cs
- CodeValidator.cs
- mda.cs
- MenuItem.cs
- SystemGatewayIPAddressInformation.cs
- PageRanges.cs
- ServicesUtilities.cs
- BitmapEffectGroup.cs
- IncrementalCompileAnalyzer.cs
- XamlStream.cs
- StreamResourceInfo.cs
- LinqDataSourceDeleteEventArgs.cs
- RegexParser.cs
- NGCPageContentCollectionSerializerAsync.cs
- MultiTargetingUtil.cs
- EnumerableRowCollectionExtensions.cs
- CompModSwitches.cs