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
- QualificationDataItem.cs
- CacheOutputQuery.cs
- HtmlSelect.cs
- FunctionCommandText.cs
- SelectQueryOperator.cs
- BigInt.cs
- CheckBoxList.cs
- NullableIntSumAggregationOperator.cs
- VsPropertyGrid.cs
- HtmlTable.cs
- GeneralTransform2DTo3DTo2D.cs
- XPathChildIterator.cs
- EDesignUtil.cs
- DoWorkEventArgs.cs
- CfgParser.cs
- MenuEventArgs.cs
- TranslateTransform.cs
- MatrixIndependentAnimationStorage.cs
- SurrogateEncoder.cs
- AxImporter.cs
- InstanceDataCollectionCollection.cs
- CustomSignedXml.cs
- WsiProfilesElement.cs
- ObjectCloneHelper.cs
- ResourceContainerWrapper.cs
- UTF8Encoding.cs
- SpeechSynthesizer.cs
- VisualSerializer.cs
- HierarchicalDataBoundControlAdapter.cs
- ColorContext.cs
- ContainerFilterService.cs
- panel.cs
- codemethodreferenceexpression.cs
- CellConstant.cs
- DomainConstraint.cs
- ReferencedAssembly.cs
- BuilderInfo.cs
- EventLogTraceListener.cs
- MaskedTextProvider.cs
- SafeFileMappingHandle.cs
- MailDefinition.cs
- SystemBrushes.cs
- StateRuntime.cs
- BasePattern.cs
- FontDialog.cs
- ClientTargetSection.cs
- WorkflowApplicationIdleEventArgs.cs
- DateTimeConstantAttribute.cs
- COM2Enum.cs
- IndependentAnimationStorage.cs
- FormCollection.cs
- ToolboxItemCollection.cs
- AtlasWeb.Designer.cs
- MetadataSerializer.cs
- FontConverter.cs
- ArcSegment.cs
- ListViewSelectEventArgs.cs
- TimerEventSubscriptionCollection.cs
- CommandDevice.cs
- StringOutput.cs
- UIElementIsland.cs
- AlphaSortedEnumConverter.cs
- ApplicationSettingsBase.cs
- PeerName.cs
- XAMLParseException.cs
- ProvideValueServiceProvider.cs
- DiagnosticTraceSchemas.cs
- AssemblyBuilder.cs
- GrammarBuilderWildcard.cs
- DispatcherExceptionFilterEventArgs.cs
- SingleAnimationUsingKeyFrames.cs
- GPPOINTF.cs
- OdbcHandle.cs
- TableLayoutStyleCollection.cs
- SmiEventSink_DeferedProcessing.cs
- Switch.cs
- CursorInteropHelper.cs
- PersonalizationProviderCollection.cs
- AppDomainProtocolHandler.cs
- OleDbCommand.cs
- ParentQuery.cs
- SecurityDocument.cs
- CodeNamespaceImport.cs
- MediaContextNotificationWindow.cs
- DateTime.cs
- TemplateNameScope.cs
- SupportsPreviewControlAttribute.cs
- BinaryWriter.cs
- QuaternionRotation3D.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- DataListItemCollection.cs
- ValuePatternIdentifiers.cs
- CancellationToken.cs
- xdrvalidator.cs
- storepermissionattribute.cs
- SystemIPGlobalProperties.cs
- ScriptReferenceBase.cs
- BitmapEffectInputConnector.cs
- DesignerActionList.cs
- Propagator.Evaluator.cs