Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / Effects / DropShadowEffect.cs / 1305600 / DropShadowEffect.cs
//------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, 2007 // // File: DropShadowEffect.cs //----------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Media; namespace System.Windows.Media.Effects { ////// DropShadowEffect /// public partial class DropShadowEffect { #region Constructors ////// Constructor /// public DropShadowEffect() { } #endregion ////// Takes in content bounds, and returns the bounds of the rendered /// output of that content after the Effect is applied. /// internal override Rect GetRenderBounds(Rect contentBounds) { Point topLeft = new Point(); Point bottomRight = new Point(); double radius = BlurRadius; topLeft.X = contentBounds.TopLeft.X - radius; topLeft.Y = contentBounds.TopLeft.Y - radius; bottomRight.X = contentBounds.BottomRight.X + radius; bottomRight.Y = contentBounds.BottomRight.Y + radius; double depth = ShadowDepth; double direction = Math.PI/180 * Direction; double offsetX = depth * Math.Cos(direction); double offsetY = depth * Math.Sin(direction); // If the shadow is horizontally aligned or to the right of the original element... if (offsetX >= 0.0f) { bottomRight.X += offsetX; } // If the shadow is to the left of the original element... else { topLeft.X += offsetX; } // If the shadow is above the original element... if (offsetY >= 0.0f) { topLeft.Y -= offsetY; } // If the shadow is below the original element... else { bottomRight.Y -= offsetY; } return new Rect(topLeft, bottomRight); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, 2007 // // File: DropShadowEffect.cs //----------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Media; namespace System.Windows.Media.Effects { ////// DropShadowEffect /// public partial class DropShadowEffect { #region Constructors ////// Constructor /// public DropShadowEffect() { } #endregion ////// Takes in content bounds, and returns the bounds of the rendered /// output of that content after the Effect is applied. /// internal override Rect GetRenderBounds(Rect contentBounds) { Point topLeft = new Point(); Point bottomRight = new Point(); double radius = BlurRadius; topLeft.X = contentBounds.TopLeft.X - radius; topLeft.Y = contentBounds.TopLeft.Y - radius; bottomRight.X = contentBounds.BottomRight.X + radius; bottomRight.Y = contentBounds.BottomRight.Y + radius; double depth = ShadowDepth; double direction = Math.PI/180 * Direction; double offsetX = depth * Math.Cos(direction); double offsetY = depth * Math.Sin(direction); // If the shadow is horizontally aligned or to the right of the original element... if (offsetX >= 0.0f) { bottomRight.X += offsetX; } // If the shadow is to the left of the original element... else { topLeft.X += offsetX; } // If the shadow is above the original element... if (offsetY >= 0.0f) { topLeft.Y -= offsetY; } // If the shadow is below the original element... else { bottomRight.Y -= offsetY; } return new Rect(topLeft, bottomRight); } } } // 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
- StructuredType.cs
- AssociatedControlConverter.cs
- BaseValidator.cs
- SqlInfoMessageEvent.cs
- ZipPackagePart.cs
- ModelUtilities.cs
- DriveInfo.cs
- ItemCheckEvent.cs
- CommandManager.cs
- KeyValueConfigurationCollection.cs
- QualifierSet.cs
- OdbcCommand.cs
- BufferedReadStream.cs
- DateTimeConverter.cs
- SafeProcessHandle.cs
- ManagedFilter.cs
- StrongNameKeyPair.cs
- HttpRuntime.cs
- DataGridToolTip.cs
- RequestCachePolicy.cs
- ListItemDetailViewAttribute.cs
- FullTextLine.cs
- DbConnectionPoolOptions.cs
- XmlSchemaFacet.cs
- CopyOnWriteList.cs
- ListParaClient.cs
- FrameSecurityDescriptor.cs
- CompModHelpers.cs
- StorageBasedPackageProperties.cs
- SchemaExporter.cs
- GenericTypeParameterBuilder.cs
- LicenseProviderAttribute.cs
- XmlTextAttribute.cs
- DesignTimeParseData.cs
- CompensationToken.cs
- CancellationTokenSource.cs
- _SSPIWrapper.cs
- XmlSerializerNamespaces.cs
- Parallel.cs
- ComponentResourceKeyConverter.cs
- SqlProviderManifest.cs
- Blend.cs
- ManagedFilter.cs
- CacheHelper.cs
- TextMarkerSource.cs
- FrameworkReadOnlyPropertyMetadata.cs
- ListMarkerSourceInfo.cs
- DelegateSerializationHolder.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- DataGridViewCellStyle.cs
- OdbcConnectionStringbuilder.cs
- SHA256Managed.cs
- SizeChangedInfo.cs
- StickyNoteAnnotations.cs
- ScrollItemPatternIdentifiers.cs
- CodeExporter.cs
- FactoryGenerator.cs
- Visual3D.cs
- WsatProxy.cs
- XmlSerializableReader.cs
- Annotation.cs
- Utils.cs
- ReverseQueryOperator.cs
- _NetRes.cs
- ComPlusContractBehavior.cs
- QilVisitor.cs
- RequestResizeEvent.cs
- Solver.cs
- BackStopAuthenticationModule.cs
- EndGetFileNameFromUserRequest.cs
- SafeThreadHandle.cs
- Mapping.cs
- FixedTextView.cs
- PageBuildProvider.cs
- TextDecorationUnitValidation.cs
- MappingItemCollection.cs
- InternalRelationshipCollection.cs
- CodeTypeDelegate.cs
- ModifiableIteratorCollection.cs
- ValidationSummary.cs
- ParagraphVisual.cs
- SortDescription.cs
- SvcMapFileSerializer.cs
- DataSourceCacheDurationConverter.cs
- RelationshipConverter.cs
- DES.cs
- SecurityException.cs
- TextServicesHost.cs
- SQLSingleStorage.cs
- While.cs
- XmlQualifiedNameTest.cs
- Stacktrace.cs
- DesignerOptionService.cs
- WebPartActionVerb.cs
- DetailsViewModeEventArgs.cs
- NTAccount.cs
- RetrieveVirtualItemEventArgs.cs
- AsymmetricKeyExchangeFormatter.cs
- precedingquery.cs
- WebPartsPersonalizationAuthorization.cs