Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media / TileBrush.cs / 1 / TileBrush.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: TileBrush.cs
//
// Description: This file contains the implementation of TileBrush.
// The TileBrush is an abstract class of Brushes which describes
// a way to fill a region by tiling. The contents of the tiles
// are described by classes derived from TileBrush.
//
// History:
// 04/29/2003 : adsmith - Created it.
//
//---------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Security;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using MS.Internal;
using System.Runtime.InteropServices;
namespace System.Windows.Media
{
///
/// TileBrush
/// The TileBrush is an abstract class of Brushes which describes
/// a way to fill a region by tiling. The contents of the tiles
/// are described by classes derived from TileBrush.
///
public abstract partial class TileBrush : Brush
{
#region Constructors
///
/// Protected constructor for TileBrush.
/// Sets all values to their defaults.
/// To set property values, use the constructor which accepts paramters
///
protected TileBrush()
{
}
#endregion Constructors
///
/// Obtains the current bounds of the brush's content
///
/// Output bounds of content
protected abstract void GetContentBounds(out Rect contentBounds);
///
/// Obtains a matrix that maps the TileBrush's content to the coordinate
/// space of the shape it is filling.
///
///
/// Fill-bounds of the shape this brush is stroking/filling
///
///
/// Output matrix that maps the TileBrush's content to the coordinate
/// space of the shape it is filling
///
///
/// Critical as this code calls UnsafeNativeMethods.MilUtility_GetTileBrushMapping
/// and MILUtilities.ConvertFromD3DMATRIX.
/// Treat as safe because the first is simply a math utility function with no
/// critical data exposure, and the second is passed pointers to type-correct data.
///
[SecurityCritical,SecurityTreatAsSafe]
internal void GetTileBrushMapping(
Rect shapeFillBounds,
out Matrix tileBrushMapping
)
{
Rect contentBounds = Rect.Empty;
BrushMappingMode viewboxUnits = ViewboxUnits;
bool brushIsEmpty = false;
// Initialize out-param
tileBrushMapping = Matrix.Identity;
// Obtain content bounds for RelativeToBoundingBox ViewboxUnits
//
// If ViewboxUnits is RelativeToBoundingBox, then the tile-brush
// transform is also dependent on the bounds of the content.
if (viewboxUnits == BrushMappingMode.RelativeToBoundingBox)
{
GetContentBounds(out contentBounds);
// If contentBounds is Rect.Empty then this brush renders nothing.
// Set the empty flag & early-out.
if (contentBounds == Rect.Empty)
{
brushIsEmpty = true;
}
}
//
// Pass the properties to MilUtility_GetTileBrushMapping to calculate
// the mapping, unless the brush is already determined to be empty
//
if (!brushIsEmpty)
{
//
// Obtain properties that must be set into local variables
//
Rect viewport = Viewport;
Rect viewbox = Viewbox;
Matrix transformValue;
Matrix relativeTransformValue;
Transform.GetTransformValue(
Transform,
out transformValue
);
Transform.GetTransformValue(
RelativeTransform,
out relativeTransformValue
);
unsafe
{
D3DMATRIX d3dTransform;
D3DMATRIX d3dRelativeTransform;
D3DMATRIX d3dContentToShape;
int brushIsEmptyBOOL;
// Call MilUtility_GetTileBrushMapping, converting Matrix's to
// D3DMATRIX's when needed.
MILUtilities.ConvertToD3DMATRIX(&transformValue, &d3dTransform);
MILUtilities.ConvertToD3DMATRIX(&relativeTransformValue, &d3dRelativeTransform);
MS.Win32.PresentationCore.UnsafeNativeMethods.MilCoreApi.MilUtility_GetTileBrushMapping(
&d3dTransform,
&d3dRelativeTransform,
Stretch,
AlignmentX,
AlignmentY,
ViewportUnits,
viewboxUnits,
&shapeFillBounds,
&contentBounds,
ref viewport,
ref viewbox,
out d3dContentToShape,
out brushIsEmptyBOOL
);
// Convert the brushIsEmpty flag from BOOL to a bool.
brushIsEmpty = (brushIsEmptyBOOL != 0);
// Set output matrix if the brush isn't empty. Otherwise, the
// output of MilUtility_GetTileBrushMapping must be ignored.
if (!brushIsEmpty)
{
Matrix contentToShape;
MILUtilities.ConvertFromD3DMATRIX(&d3dContentToShape, &contentToShape);
// Set the out-param to the computed tile brush mapping
tileBrushMapping = contentToShape;
}
}
}
}
}
}
// 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.
//
// File: TileBrush.cs
//
// Description: This file contains the implementation of TileBrush.
// The TileBrush is an abstract class of Brushes which describes
// a way to fill a region by tiling. The contents of the tiles
// are described by classes derived from TileBrush.
//
// History:
// 04/29/2003 : adsmith - Created it.
//
//---------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Security;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using MS.Internal;
using System.Runtime.InteropServices;
namespace System.Windows.Media
{
///
/// TileBrush
/// The TileBrush is an abstract class of Brushes which describes
/// a way to fill a region by tiling. The contents of the tiles
/// are described by classes derived from TileBrush.
///
public abstract partial class TileBrush : Brush
{
#region Constructors
///
/// Protected constructor for TileBrush.
/// Sets all values to their defaults.
/// To set property values, use the constructor which accepts paramters
///
protected TileBrush()
{
}
#endregion Constructors
///
/// Obtains the current bounds of the brush's content
///
/// Output bounds of content
protected abstract void GetContentBounds(out Rect contentBounds);
///
/// Obtains a matrix that maps the TileBrush's content to the coordinate
/// space of the shape it is filling.
///
///
/// Fill-bounds of the shape this brush is stroking/filling
///
///
/// Output matrix that maps the TileBrush's content to the coordinate
/// space of the shape it is filling
///
///
/// Critical as this code calls UnsafeNativeMethods.MilUtility_GetTileBrushMapping
/// and MILUtilities.ConvertFromD3DMATRIX.
/// Treat as safe because the first is simply a math utility function with no
/// critical data exposure, and the second is passed pointers to type-correct data.
///
[SecurityCritical,SecurityTreatAsSafe]
internal void GetTileBrushMapping(
Rect shapeFillBounds,
out Matrix tileBrushMapping
)
{
Rect contentBounds = Rect.Empty;
BrushMappingMode viewboxUnits = ViewboxUnits;
bool brushIsEmpty = false;
// Initialize out-param
tileBrushMapping = Matrix.Identity;
// Obtain content bounds for RelativeToBoundingBox ViewboxUnits
//
// If ViewboxUnits is RelativeToBoundingBox, then the tile-brush
// transform is also dependent on the bounds of the content.
if (viewboxUnits == BrushMappingMode.RelativeToBoundingBox)
{
GetContentBounds(out contentBounds);
// If contentBounds is Rect.Empty then this brush renders nothing.
// Set the empty flag & early-out.
if (contentBounds == Rect.Empty)
{
brushIsEmpty = true;
}
}
//
// Pass the properties to MilUtility_GetTileBrushMapping to calculate
// the mapping, unless the brush is already determined to be empty
//
if (!brushIsEmpty)
{
//
// Obtain properties that must be set into local variables
//
Rect viewport = Viewport;
Rect viewbox = Viewbox;
Matrix transformValue;
Matrix relativeTransformValue;
Transform.GetTransformValue(
Transform,
out transformValue
);
Transform.GetTransformValue(
RelativeTransform,
out relativeTransformValue
);
unsafe
{
D3DMATRIX d3dTransform;
D3DMATRIX d3dRelativeTransform;
D3DMATRIX d3dContentToShape;
int brushIsEmptyBOOL;
// Call MilUtility_GetTileBrushMapping, converting Matrix's to
// D3DMATRIX's when needed.
MILUtilities.ConvertToD3DMATRIX(&transformValue, &d3dTransform);
MILUtilities.ConvertToD3DMATRIX(&relativeTransformValue, &d3dRelativeTransform);
MS.Win32.PresentationCore.UnsafeNativeMethods.MilCoreApi.MilUtility_GetTileBrushMapping(
&d3dTransform,
&d3dRelativeTransform,
Stretch,
AlignmentX,
AlignmentY,
ViewportUnits,
viewboxUnits,
&shapeFillBounds,
&contentBounds,
ref viewport,
ref viewbox,
out d3dContentToShape,
out brushIsEmptyBOOL
);
// Convert the brushIsEmpty flag from BOOL to a bool.
brushIsEmpty = (brushIsEmptyBOOL != 0);
// Set output matrix if the brush isn't empty. Otherwise, the
// output of MilUtility_GetTileBrushMapping must be ignored.
if (!brushIsEmpty)
{
Matrix contentToShape;
MILUtilities.ConvertFromD3DMATRIX(&d3dContentToShape, &contentToShape);
// Set the out-param to the computed tile brush mapping
tileBrushMapping = contentToShape;
}
}
}
}
}
}
// 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
- NotCondition.cs
- TypedElement.cs
- RayHitTestParameters.cs
- ExceptQueryOperator.cs
- listitem.cs
- Helpers.cs
- SafeTokenHandle.cs
- ToolBarDesigner.cs
- SerializationException.cs
- ParameterRetriever.cs
- MetabaseServerConfig.cs
- MouseEventArgs.cs
- WinEventHandler.cs
- ReadOnlyDictionary.cs
- FontCacheUtil.cs
- RequestTimeoutManager.cs
- BindingWorker.cs
- PaintEvent.cs
- EntityProviderServices.cs
- OuterGlowBitmapEffect.cs
- PolicyUnit.cs
- ExpandableObjectConverter.cs
- MemberAccessException.cs
- WebPartUtil.cs
- NetCodeGroup.cs
- KeyGestureValueSerializer.cs
- XmlNodeChangedEventManager.cs
- FlowLayoutPanel.cs
- UdpTransportBindingElement.cs
- LocalServiceSecuritySettingsElement.cs
- WmlPhoneCallAdapter.cs
- WebPartTransformerCollection.cs
- DatatypeImplementation.cs
- ECDsaCng.cs
- DockAndAnchorLayout.cs
- RepeaterItemEventArgs.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- FormViewDeleteEventArgs.cs
- ListItemConverter.cs
- DbConnectionPoolCounters.cs
- LiteralControl.cs
- StoragePropertyMapping.cs
- Application.cs
- ActivationServices.cs
- ExtenderControl.cs
- BooleanAnimationUsingKeyFrames.cs
- ListViewCommandEventArgs.cs
- DataColumnMappingCollection.cs
- ScrollData.cs
- FixedSchema.cs
- PathTooLongException.cs
- DiagnosticEventProvider.cs
- TextWriterTraceListener.cs
- ButtonBaseAutomationPeer.cs
- ScriptIgnoreAttribute.cs
- DurableDispatcherAddressingFault.cs
- SequenceRange.cs
- ECDsaCng.cs
- TypeGeneratedEventArgs.cs
- ProfilePropertyNameValidator.cs
- HttpListenerRequest.cs
- PathBox.cs
- Confirm.cs
- BindingExpression.cs
- XsltFunctions.cs
- ProfilePropertyNameValidator.cs
- SimpleRecyclingCache.cs
- VideoDrawing.cs
- MembershipValidatePasswordEventArgs.cs
- RecognizeCompletedEventArgs.cs
- SimpleWebHandlerParser.cs
- ManagedIStream.cs
- CfgSemanticTag.cs
- DnsEndPoint.cs
- EndpointAddress10.cs
- Range.cs
- BufferedGraphicsManager.cs
- BackgroundFormatInfo.cs
- XmlChoiceIdentifierAttribute.cs
- Metadata.cs
- ObjectItemAssemblyLoader.cs
- SqlInternalConnectionTds.cs
- IdnMapping.cs
- TextFormatter.cs
- DbCommandDefinition.cs
- Exceptions.cs
- StrokeCollection.cs
- PrintingPermissionAttribute.cs
- FrameworkRichTextComposition.cs
- FolderBrowserDialog.cs
- TreeNodeCollection.cs
- InfoCardAsymmetricCrypto.cs
- SpecialFolderEnumConverter.cs
- PreservationFileWriter.cs
- ImageButton.cs
- Cursors.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- DbConnectionOptions.cs
- SqlException.cs
- OdbcFactory.cs