Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Media / Pen.cs / 1 / Pen.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: Pen.cs
//
// Description: This file contains the implementation of Pen.
// Pen is is the class which describes how to stroke a geometric
// area.
//
// History:
// 04/28/2003 : adsmith - Created it.
//
//---------------------------------------------------------------------------
using MS.Internal;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Markup;
using System.Security;
using System.Security.Permissions;
namespace System.Windows.Media
{
///
/// Pen - The pen class is used to describe how a shape is stroked.
///
[Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)]
public sealed partial class Pen : Animatable, DUCE.IResource
{
#region Constructors
///
///
///
public Pen()
{
}
///
/// Pen - Initializes the pen from the given Brush and thickness.
/// All other values as set to default.
///
/// The Brush for this Pen.
/// The thickness of the Pen.
public Pen(Brush brush,
double thickness)
{
Brush = brush;
Thickness = thickness;
}
///
/// Pen - Initializes the brush from the parameters.
///
/// The Pen's Brush.
/// The Pen's thickness.
/// The PenLineCap which applies to the start of the stroke.
/// The PenLineCap which applies to the end of the stroke.
/// The PenDashCap which applies to the ends of each dash.
/// The PenLineJoin.
/// The miter limit.
/// The dash style.
internal Pen(
Brush brush,
double thickness,
PenLineCap startLineCap,
PenLineCap endLineCap,
PenLineCap dashCap,
PenLineJoin lineJoin,
double miterLimit,
DashStyle dashStyle)
{
Thickness = thickness;
StartLineCap = startLineCap;
EndLineCap = endLineCap;
DashCap = dashCap;
LineJoin = lineJoin;
MiterLimit = miterLimit;
Brush = brush;
DashStyle = dashStyle;
}
#endregion Constructors
private MIL_PEN_CAP GetInternalCapType(PenLineCap cap)
{
Debug.Assert((MIL_PEN_CAP)PenLineCap.Flat == MIL_PEN_CAP.MilPenCapFlat);
Debug.Assert((MIL_PEN_CAP)PenLineCap.Square == MIL_PEN_CAP.MilPenCapSquare);
Debug.Assert((MIL_PEN_CAP)PenLineCap.Round == MIL_PEN_CAP.MilPenCapRound);
Debug.Assert((MIL_PEN_CAP)PenLineCap.Triangle == MIL_PEN_CAP.MilPenCapTriangle);
return (MIL_PEN_CAP)cap;
}
private MIL_PEN_JOIN GetInternalJoinType(PenLineJoin join)
{
Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Miter == MIL_PEN_JOIN.MilPenJoinMiter);
Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Bevel == MIL_PEN_JOIN.MilPenJoinBevel);
Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Round == MIL_PEN_JOIN.MilPenJoinRound);
return (MIL_PEN_JOIN)join;
}
///
/// Returns a packed structure of non-animate pen values. If a property is animated, it
/// uses the instantaneous value of the property.
///
///
/// Critical: has unsafe code blocks .Returning pen information is safe, the risk
/// is in pointer handling
///
[SecurityCritical]
internal unsafe void GetBasicPenData(MIL_PEN_DATA* pData, out double[] dashArray)
{
dashArray = null;
Invariant.Assert(pData!=null);
unsafe
{
pData->Thickness = Thickness;
pData->StartLineCap = GetInternalCapType(StartLineCap);
pData->EndLineCap = GetInternalCapType(EndLineCap);
pData->DashCap = GetInternalCapType(DashCap);
pData->LineJoin = GetInternalJoinType(LineJoin);
pData->MiterLimit = MiterLimit;
}
if (DashStyle != null)
{
DashStyle.GetDashData(pData, out dashArray);
}
}
internal bool DoesNotContainGaps
{
get
{
DashStyle style = DashStyle;
if (style != null)
{
DoubleCollection dashes = style.Dashes;
if ((dashes != null) && (dashes.Count > 0))
{
return false;
}
}
return true;
}
}
internal static bool ContributesToBounds(
Pen pen)
{
return (pen != null) && (pen.Brush != null);
}
#region Realization Support
///
/// The stroke brush might require a Precompute call. Therefore forward this call.
///
internal override void Precompute()
{
Brush b = Brush;
if (b != null)
{
b.Precompute();
}
}
///
/// The stroke brush might require realization updates. Therefore forward this call.
///
internal override bool RequiresRealizationUpdates
{
get
{
Brush b = Brush;
if (b != null)
{
return b.RequiresRealizationUpdates;
}
else
{
return false;
}
}
}
///
/// The storke brush might require realization, so simply forward this call.
///
internal void UpdateRealizations(Rect fillShapeBounds, RealizationContext ctx)
{
Brush brush = Brush;
if (brush != null)
{
brush.UpdateRealizations( fillShapeBounds, ctx);
}
}
#endregion
}
}
// 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: Pen.cs
//
// Description: This file contains the implementation of Pen.
// Pen is is the class which describes how to stroke a geometric
// area.
//
// History:
// 04/28/2003 : adsmith - Created it.
//
//---------------------------------------------------------------------------
using MS.Internal;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Markup;
using System.Security;
using System.Security.Permissions;
namespace System.Windows.Media
{
///
/// Pen - The pen class is used to describe how a shape is stroked.
///
[Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)]
public sealed partial class Pen : Animatable, DUCE.IResource
{
#region Constructors
///
///
///
public Pen()
{
}
///
/// Pen - Initializes the pen from the given Brush and thickness.
/// All other values as set to default.
///
/// The Brush for this Pen.
/// The thickness of the Pen.
public Pen(Brush brush,
double thickness)
{
Brush = brush;
Thickness = thickness;
}
///
/// Pen - Initializes the brush from the parameters.
///
/// The Pen's Brush.
/// The Pen's thickness.
/// The PenLineCap which applies to the start of the stroke.
/// The PenLineCap which applies to the end of the stroke.
/// The PenDashCap which applies to the ends of each dash.
/// The PenLineJoin.
/// The miter limit.
/// The dash style.
internal Pen(
Brush brush,
double thickness,
PenLineCap startLineCap,
PenLineCap endLineCap,
PenLineCap dashCap,
PenLineJoin lineJoin,
double miterLimit,
DashStyle dashStyle)
{
Thickness = thickness;
StartLineCap = startLineCap;
EndLineCap = endLineCap;
DashCap = dashCap;
LineJoin = lineJoin;
MiterLimit = miterLimit;
Brush = brush;
DashStyle = dashStyle;
}
#endregion Constructors
private MIL_PEN_CAP GetInternalCapType(PenLineCap cap)
{
Debug.Assert((MIL_PEN_CAP)PenLineCap.Flat == MIL_PEN_CAP.MilPenCapFlat);
Debug.Assert((MIL_PEN_CAP)PenLineCap.Square == MIL_PEN_CAP.MilPenCapSquare);
Debug.Assert((MIL_PEN_CAP)PenLineCap.Round == MIL_PEN_CAP.MilPenCapRound);
Debug.Assert((MIL_PEN_CAP)PenLineCap.Triangle == MIL_PEN_CAP.MilPenCapTriangle);
return (MIL_PEN_CAP)cap;
}
private MIL_PEN_JOIN GetInternalJoinType(PenLineJoin join)
{
Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Miter == MIL_PEN_JOIN.MilPenJoinMiter);
Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Bevel == MIL_PEN_JOIN.MilPenJoinBevel);
Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Round == MIL_PEN_JOIN.MilPenJoinRound);
return (MIL_PEN_JOIN)join;
}
///
/// Returns a packed structure of non-animate pen values. If a property is animated, it
/// uses the instantaneous value of the property.
///
///
/// Critical: has unsafe code blocks .Returning pen information is safe, the risk
/// is in pointer handling
///
[SecurityCritical]
internal unsafe void GetBasicPenData(MIL_PEN_DATA* pData, out double[] dashArray)
{
dashArray = null;
Invariant.Assert(pData!=null);
unsafe
{
pData->Thickness = Thickness;
pData->StartLineCap = GetInternalCapType(StartLineCap);
pData->EndLineCap = GetInternalCapType(EndLineCap);
pData->DashCap = GetInternalCapType(DashCap);
pData->LineJoin = GetInternalJoinType(LineJoin);
pData->MiterLimit = MiterLimit;
}
if (DashStyle != null)
{
DashStyle.GetDashData(pData, out dashArray);
}
}
internal bool DoesNotContainGaps
{
get
{
DashStyle style = DashStyle;
if (style != null)
{
DoubleCollection dashes = style.Dashes;
if ((dashes != null) && (dashes.Count > 0))
{
return false;
}
}
return true;
}
}
internal static bool ContributesToBounds(
Pen pen)
{
return (pen != null) && (pen.Brush != null);
}
#region Realization Support
///
/// The stroke brush might require a Precompute call. Therefore forward this call.
///
internal override void Precompute()
{
Brush b = Brush;
if (b != null)
{
b.Precompute();
}
}
///
/// The stroke brush might require realization updates. Therefore forward this call.
///
internal override bool RequiresRealizationUpdates
{
get
{
Brush b = Brush;
if (b != null)
{
return b.RequiresRealizationUpdates;
}
else
{
return false;
}
}
}
///
/// The storke brush might require realization, so simply forward this call.
///
internal void UpdateRealizations(Rect fillShapeBounds, RealizationContext ctx)
{
Brush brush = Brush;
if (brush != null)
{
brush.UpdateRealizations( fillShapeBounds, ctx);
}
}
#endregion
}
}
// 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
- QilValidationVisitor.cs
- RelatedView.cs
- CookieProtection.cs
- HtmlTableCell.cs
- dataprotectionpermission.cs
- ThicknessAnimation.cs
- Button.cs
- EnumConverter.cs
- MachineKeySection.cs
- TextProperties.cs
- Baml2006ReaderFrame.cs
- IssuedTokenParametersElement.cs
- UiaCoreApi.cs
- DataPager.cs
- XamlStackWriter.cs
- Rect.cs
- QilParameter.cs
- ImportDesigner.xaml.cs
- precedingsibling.cs
- DrawingContextWalker.cs
- DependencyPropertyKind.cs
- QueryExpr.cs
- shaperfactoryquerycachekey.cs
- SqlCachedBuffer.cs
- XmlException.cs
- HeaderedItemsControl.cs
- GridViewRowEventArgs.cs
- DataGridViewColumnStateChangedEventArgs.cs
- OneWayBindingElement.cs
- ISO2022Encoding.cs
- AxDesigner.cs
- TextDecorations.cs
- ClientSponsor.cs
- SqlNotificationEventArgs.cs
- XamlTypeMapper.cs
- ListViewItemSelectionChangedEvent.cs
- ECDiffieHellmanCngPublicKey.cs
- ClrProviderManifest.cs
- SpeechSeg.cs
- SafeBitVector32.cs
- FileLogRecordStream.cs
- GridViewPageEventArgs.cs
- ThreadStaticAttribute.cs
- ChannelDispatcherCollection.cs
- BuildProviderCollection.cs
- SvcMapFile.cs
- SystemWebSectionGroup.cs
- WhiteSpaceTrimStringConverter.cs
- TextEffect.cs
- ValidatedControlConverter.cs
- login.cs
- XDeferredAxisSource.cs
- ExtendedPropertyCollection.cs
- MouseDevice.cs
- TextTreeNode.cs
- BuildResult.cs
- FillErrorEventArgs.cs
- ComplusEndpointConfigContainer.cs
- PopOutPanel.cs
- DBSchemaTable.cs
- WindowsListViewItemCheckBox.cs
- ReadContentAsBinaryHelper.cs
- MissingMethodException.cs
- MatrixUtil.cs
- __Error.cs
- FormViewCommandEventArgs.cs
- DbReferenceCollection.cs
- Cursors.cs
- OdbcEnvironmentHandle.cs
- QueryRewriter.cs
- UnaryExpression.cs
- XmlValidatingReaderImpl.cs
- EpmSourcePathSegment.cs
- _SslSessionsCache.cs
- PointConverter.cs
- Utils.cs
- AuthorizationBehavior.cs
- PrivilegedConfigurationManager.cs
- EntityDesignerDataSourceView.cs
- PackageRelationshipCollection.cs
- WebPartDeleteVerb.cs
- HierarchicalDataSourceConverter.cs
- ExtenderProvidedPropertyAttribute.cs
- SoapSchemaMember.cs
- MsmqProcessProtocolHandler.cs
- GenericWebPart.cs
- PropertyChangingEventArgs.cs
- WebBrowsableAttribute.cs
- XmlKeywords.cs
- ScriptBehaviorDescriptor.cs
- TreeViewBindingsEditorForm.cs
- ExtendedPropertyInfo.cs
- DeclaredTypeValidatorAttribute.cs
- UIElementParaClient.cs
- ExpressionsCollectionEditor.cs
- ToolZoneDesigner.cs
- WCFModelStrings.Designer.cs
- Vector3DAnimationUsingKeyFrames.cs
- DataAdapter.cs
- XPathScanner.cs