Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media / Effects / DropShadowBitmapEffect.cs / 3 / DropShadowBitmapEffect.cs
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, 2005
//
// File: BitmapEffectDropShadow.cs
//-----------------------------------------------------------------------------
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using MS.Internal.PresentationCore;
using System.Security;
#endregion
namespace System.Windows.Media.Effects
{
///
/// The class definition for DropShadowBitmapEffect
///
public partial class DropShadowBitmapEffect
{
///
/// Constructor
///
public DropShadowBitmapEffect()
{
}
///
/// Creates the unmanaged effect handle
///
unsafe protected override SafeHandle CreateUnmanagedEffect()
{
return Create(new Guid(0x459a3fbe, 0xd8ac, 0x4692, 0x87, 0x4b, 0x7a, 0x26, 0x57, 0x15, 0xaa, 0x16));
}
///
/// /// Update (propagetes) properties to the unmanaged effect
///
///
/// This method demands permission because effects should not be run
/// in partial trust.
///
/// SecurityCritical - because SetValue has a link demand
/// SecutiryTreatAsSafe - because it demans UIWindow permission
///
[SecurityCritical, SecurityTreatAsSafe]
protected override void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect)
{
SecurityHelper.DemandUIWindowPermission();
BitmapEffect.SetValue(unmanagedEffect, "Color", this.Color);
BitmapEffect.SetValue(unmanagedEffect, "ShadowDepth", this.ShadowDepth);
BitmapEffect.SetValue(unmanagedEffect, "Direction", this.Direction);
BitmapEffect.SetValue(unmanagedEffect, "Noise", this.Noise);
BitmapEffect.SetValue(unmanagedEffect, "Opacity", this.Opacity);
BitmapEffect.SetValue(unmanagedEffect, "Softness", this.Softness);
}
///
/// An ImageEffect can be used to emulate a DropShadowBitmapEffect with certain restrictions. This
/// method returns true when it is possible to emulate the DropShadowBitmapEffect using an ImageEffect.
///
internal override bool CanBeEmulatedUsingEffectPipeline()
{
return (Noise == 0.0);
}
///
/// Returns a ImageEffect that emulates this DropShadowBitmapEffect.
///
internal override Effect GetEmulatingEffect()
{
if (_imageEffectEmulation == null)
{
_imageEffectEmulation = new DropShadowEffect();
}
if (_imageEffectEmulation.Color != Color)
{
_imageEffectEmulation.Color = Color;
}
// The limits on ShadowDepth preserve existing behavior.
// A scale transform can scale the shadow depth to exceed 50.0,
// and this behavior is also handled correctly in the unmanaged layer.
if (_imageEffectEmulation.ShadowDepth != ShadowDepth)
{
if (ShadowDepth >= 50.0)
{
_imageEffectEmulation.ShadowDepth = 50.0;
}
else if (ShadowDepth < 0.0)
{
_imageEffectEmulation.ShadowDepth = 0.0;
}
else
{
_imageEffectEmulation.ShadowDepth = ShadowDepth;
}
}
if (_imageEffectEmulation.Direction != Direction)
{
_imageEffectEmulation.Direction = Direction;
}
if (_imageEffectEmulation.Opacity != Opacity)
{
if (Opacity >= 1.0)
{
_imageEffectEmulation.Opacity = 1.0;
}
else if (Opacity <= 0.0)
{
_imageEffectEmulation.Opacity = 0.0;
}
else
{
_imageEffectEmulation.Opacity = Opacity;
}
}
if (_imageEffectEmulation.BlurRadius / _MAX_EMULATED_BLUR_RADIUS != Softness)
{
if (Softness >= 1.0)
{
_imageEffectEmulation.BlurRadius = _MAX_EMULATED_BLUR_RADIUS;
}
else if (Softness <= 0.0)
{
_imageEffectEmulation.BlurRadius = 0.0;
}
else
{
_imageEffectEmulation.BlurRadius = _MAX_EMULATED_BLUR_RADIUS * Softness;
}
}
_imageEffectEmulation.RenderingBias = RenderingBias.Performance;
return _imageEffectEmulation;
}
DropShadowEffect _imageEffectEmulation;
private const double _MAX_EMULATED_BLUR_RADIUS = 25.0;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, 2005
//
// File: BitmapEffectDropShadow.cs
//-----------------------------------------------------------------------------
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using MS.Internal.PresentationCore;
using System.Security;
#endregion
namespace System.Windows.Media.Effects
{
///
/// The class definition for DropShadowBitmapEffect
///
public partial class DropShadowBitmapEffect
{
///
/// Constructor
///
public DropShadowBitmapEffect()
{
}
///
/// Creates the unmanaged effect handle
///
unsafe protected override SafeHandle CreateUnmanagedEffect()
{
return Create(new Guid(0x459a3fbe, 0xd8ac, 0x4692, 0x87, 0x4b, 0x7a, 0x26, 0x57, 0x15, 0xaa, 0x16));
}
///
/// /// Update (propagetes) properties to the unmanaged effect
///
///
/// This method demands permission because effects should not be run
/// in partial trust.
///
/// SecurityCritical - because SetValue has a link demand
/// SecutiryTreatAsSafe - because it demans UIWindow permission
///
[SecurityCritical, SecurityTreatAsSafe]
protected override void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect)
{
SecurityHelper.DemandUIWindowPermission();
BitmapEffect.SetValue(unmanagedEffect, "Color", this.Color);
BitmapEffect.SetValue(unmanagedEffect, "ShadowDepth", this.ShadowDepth);
BitmapEffect.SetValue(unmanagedEffect, "Direction", this.Direction);
BitmapEffect.SetValue(unmanagedEffect, "Noise", this.Noise);
BitmapEffect.SetValue(unmanagedEffect, "Opacity", this.Opacity);
BitmapEffect.SetValue(unmanagedEffect, "Softness", this.Softness);
}
///
/// An ImageEffect can be used to emulate a DropShadowBitmapEffect with certain restrictions. This
/// method returns true when it is possible to emulate the DropShadowBitmapEffect using an ImageEffect.
///
internal override bool CanBeEmulatedUsingEffectPipeline()
{
return (Noise == 0.0);
}
///
/// Returns a ImageEffect that emulates this DropShadowBitmapEffect.
///
internal override Effect GetEmulatingEffect()
{
if (_imageEffectEmulation == null)
{
_imageEffectEmulation = new DropShadowEffect();
}
if (_imageEffectEmulation.Color != Color)
{
_imageEffectEmulation.Color = Color;
}
// The limits on ShadowDepth preserve existing behavior.
// A scale transform can scale the shadow depth to exceed 50.0,
// and this behavior is also handled correctly in the unmanaged layer.
if (_imageEffectEmulation.ShadowDepth != ShadowDepth)
{
if (ShadowDepth >= 50.0)
{
_imageEffectEmulation.ShadowDepth = 50.0;
}
else if (ShadowDepth < 0.0)
{
_imageEffectEmulation.ShadowDepth = 0.0;
}
else
{
_imageEffectEmulation.ShadowDepth = ShadowDepth;
}
}
if (_imageEffectEmulation.Direction != Direction)
{
_imageEffectEmulation.Direction = Direction;
}
if (_imageEffectEmulation.Opacity != Opacity)
{
if (Opacity >= 1.0)
{
_imageEffectEmulation.Opacity = 1.0;
}
else if (Opacity <= 0.0)
{
_imageEffectEmulation.Opacity = 0.0;
}
else
{
_imageEffectEmulation.Opacity = Opacity;
}
}
if (_imageEffectEmulation.BlurRadius / _MAX_EMULATED_BLUR_RADIUS != Softness)
{
if (Softness >= 1.0)
{
_imageEffectEmulation.BlurRadius = _MAX_EMULATED_BLUR_RADIUS;
}
else if (Softness <= 0.0)
{
_imageEffectEmulation.BlurRadius = 0.0;
}
else
{
_imageEffectEmulation.BlurRadius = _MAX_EMULATED_BLUR_RADIUS * Softness;
}
}
_imageEffectEmulation.RenderingBias = RenderingBias.Performance;
return _imageEffectEmulation;
}
DropShadowEffect _imageEffectEmulation;
private const double _MAX_EMULATED_BLUR_RADIUS = 25.0;
}
}
// 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
- SendKeys.cs
- ECDsaCng.cs
- GcHandle.cs
- WindowsListViewScroll.cs
- CompilationSection.cs
- DataServiceQueryException.cs
- TextElementCollection.cs
- LocalValueEnumerator.cs
- BrowserCapabilitiesCodeGenerator.cs
- ModifierKeysConverter.cs
- FlowDocumentPageViewerAutomationPeer.cs
- SqlAliasesReferenced.cs
- SafeHGlobalHandleCritical.cs
- HtmlElementEventArgs.cs
- TransactionalPackage.cs
- PersonalizablePropertyEntry.cs
- IteratorFilter.cs
- CommandField.cs
- _emptywebproxy.cs
- XamlStyleSerializer.cs
- EventDescriptor.cs
- OutOfMemoryException.cs
- DataGridViewButtonColumn.cs
- HttpDateParse.cs
- TemplateBaseAction.cs
- WebPartTracker.cs
- LayoutExceptionEventArgs.cs
- DiscriminatorMap.cs
- HttpWriter.cs
- ScrollViewerAutomationPeer.cs
- EditorZoneBase.cs
- InvalidEnumArgumentException.cs
- TextFragmentEngine.cs
- PageThemeParser.cs
- SoapInteropTypes.cs
- HttpFileCollection.cs
- RightsManagementEncryptionTransform.cs
- PreviewPrintController.cs
- FileEnumerator.cs
- ConfigurationManagerHelperFactory.cs
- SimpleType.cs
- EdmSchemaError.cs
- ImageListStreamer.cs
- MailHeaderInfo.cs
- SafeThemeHandle.cs
- PowerStatus.cs
- HttpAsyncResult.cs
- ObjectConverter.cs
- EventBuilder.cs
- TextEncodedRawTextWriter.cs
- FilterableAttribute.cs
- RTTypeWrapper.cs
- LambdaCompiler.Expressions.cs
- Normalization.cs
- DiscoveryReference.cs
- EmbeddedObject.cs
- AmbientLight.cs
- RayHitTestParameters.cs
- HitTestDrawingContextWalker.cs
- DataGridViewColumnEventArgs.cs
- SectionInformation.cs
- HttpRequestTraceRecord.cs
- ConfigurationProviderException.cs
- ThreadExceptionEvent.cs
- shaperfactoryquerycacheentry.cs
- OleDbConnection.cs
- HashHelpers.cs
- CheckBox.cs
- RegexTypeEditor.cs
- ErrorHandler.cs
- RenderingEventArgs.cs
- AdornerDecorator.cs
- ResourcePermissionBase.cs
- DiagnosticTraceSource.cs
- EdmConstants.cs
- Int32RectConverter.cs
- TransformerConfigurationWizardBase.cs
- TablePattern.cs
- LinqDataSourceDisposeEventArgs.cs
- HttpResponseWrapper.cs
- SchemaCollectionCompiler.cs
- TextAction.cs
- EncoderNLS.cs
- __TransparentProxy.cs
- AuthorizationRuleCollection.cs
- CodeObject.cs
- Tuple.cs
- CacheHelper.cs
- CssStyleCollection.cs
- XmlKeywords.cs
- DbParameterHelper.cs
- TextSerializer.cs
- ServicePointManagerElement.cs
- TypeResolvingOptionsAttribute.cs
- TextEditorLists.cs
- TextDecorations.cs
- IDispatchConstantAttribute.cs
- SequentialWorkflowRootDesigner.cs
- PropertyKey.cs
- _RequestCacheProtocol.cs