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
- SynchronizingStream.cs
- BaseParagraph.cs
- Size.cs
- XmlAttributeCache.cs
- GlyphingCache.cs
- IndicFontClient.cs
- FieldReference.cs
- MappingMetadataHelper.cs
- PerformanceCountersElement.cs
- ExtenderProvidedPropertyAttribute.cs
- DataGridViewMethods.cs
- OutputCacheProfileCollection.cs
- SchemaImporterExtensionElementCollection.cs
- ScriptControlDescriptor.cs
- SendKeys.cs
- MouseButtonEventArgs.cs
- _NTAuthentication.cs
- PropertyNames.cs
- ObjectTag.cs
- AuthenticationModulesSection.cs
- WebZone.cs
- Int32CollectionValueSerializer.cs
- AutomationElementCollection.cs
- EvidenceTypeDescriptor.cs
- DataGridPagerStyle.cs
- HttpCookieCollection.cs
- SmtpSection.cs
- RC2CryptoServiceProvider.cs
- XmlNullResolver.cs
- DataServiceRequestOfT.cs
- ExternalException.cs
- MultilineStringConverter.cs
- WorkflowDesignerColors.cs
- KeyValuePair.cs
- WebPartManagerInternals.cs
- TreeChangeInfo.cs
- CrossContextChannel.cs
- VisemeEventArgs.cs
- XmlSchemaChoice.cs
- DSASignatureDeformatter.cs
- PathFigureCollectionConverter.cs
- UrlMappingCollection.cs
- localization.cs
- PrintDocument.cs
- SqlParameter.cs
- DbModificationCommandTree.cs
- FollowerQueueCreator.cs
- SRGSCompiler.cs
- WebPartZoneAutoFormat.cs
- Size3DValueSerializer.cs
- CriticalFinalizerObject.cs
- TreeNodeCollectionEditor.cs
- __ConsoleStream.cs
- Exceptions.cs
- ZipIORawDataFileBlock.cs
- Converter.cs
- PieceDirectory.cs
- ConfigurationLocationCollection.cs
- FieldToken.cs
- SingleSelectRootGridEntry.cs
- GradientStop.cs
- CustomError.cs
- DocumentViewerBaseAutomationPeer.cs
- QuaternionAnimationBase.cs
- WebBrowserHelper.cs
- MenuCommands.cs
- ServiceDeploymentInfo.cs
- webeventbuffer.cs
- BaseDataList.cs
- AttributeProviderAttribute.cs
- WmlPanelAdapter.cs
- ClaimComparer.cs
- WebBaseEventKeyComparer.cs
- DisposableCollectionWrapper.cs
- SqlCaseSimplifier.cs
- DynamicObject.cs
- MenuItemBinding.cs
- SrgsElementFactory.cs
- EventRoute.cs
- Vector3DAnimationUsingKeyFrames.cs
- PermissionAttributes.cs
- StreamGeometry.cs
- XmlWellformedWriter.cs
- Encoder.cs
- TableChangeProcessor.cs
- ToolStripItemEventArgs.cs
- MutexSecurity.cs
- UInt64Converter.cs
- DeferredElementTreeState.cs
- XsltSettings.cs
- XmlSchemaChoice.cs
- PathSegmentCollection.cs
- DocumentApplicationJournalEntry.cs
- CodePropertyReferenceExpression.cs
- EntityDataSourceContextDisposingEventArgs.cs
- DataGridViewCellFormattingEventArgs.cs
- PrinterUnitConvert.cs
- ParallelEnumerableWrapper.cs
- InlinedAggregationOperatorEnumerator.cs
- TextTabProperties.cs