Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Media / DrawingImage.cs / 1 / DrawingImage.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: DrawingImage class
// An ImageSource with a Drawing for content
//
//
// History:
// 05/26/2005 : jordanpa - Created it
//
//---------------------------------------------------------------------------
using MS.Internal;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Media.Imaging;
namespace System.Windows.Media
{
///
/// The class definition for DrawingImage
///
public sealed partial class DrawingImage : ImageSource
{
///
/// Default DrawingImage ctor
///
public DrawingImage()
{
}
///
/// DrawingImage ctor that takes a Drawing
///
/// The content of the DrawingImage
public DrawingImage(Drawing drawing)
{
Drawing = drawing;
}
///
/// Width of the DrawingImage
///
public override double Width
{
get
{
ReadPreamble();
return Size.Width;
}
}
///
/// Height of the DrawingImage
///
public override double Height
{
get
{
ReadPreamble();
return Size.Height;
}
}
///
/// Get the Metadata of the DrawingImage
///
public override ImageMetadata Metadata
{
get
{
ReadPreamble();
// DrawingImage does not have any metadata currently defined.
return null;
}
}
///
/// Size for the DrawingImage
///
internal override Size Size
{
get
{
Drawing drawing = Drawing;
if (drawing != null)
{
Size size = drawing.GetBounds().Size;
if (!size.IsEmpty)
{
return size;
}
else
{
return new Size();
}
}
else
{
return new Size();
}
}
}
///
/// Precompute is called during the frame preparation phase. Derived classes
/// typically check if the brush requires realizations during this phase.
///
internal override void Precompute()
{
Drawing drawing = Drawing;
_requiresRealizationUpdates = false;
if (drawing != null)
{
drawing.PrecomputeCore();
_requiresRealizationUpdates = drawing.RequiresRealizationUpdates;
}
}
///
/// Checks if realization updates are requried for this resource.
///
internal override bool RequiresRealizationUpdates { get { return _requiresRealizationUpdates; } }
///
/// Derived classes must override this method and update realizations on dependent
/// resources if required.
///
internal override void UpdateRealizations(RealizationContext ctx)
{
if (_requiresRealizationUpdates)
{
Drawing drawing = Drawing;
Debug.Assert(drawing != null); // Otherwise _requiresRealizationUpdates would be false.
drawing.UpdateRealizations(ctx);
}
}
///
/// This node can introduce graphness
///
internal override bool CanIntroduceGraphness()
{
return true;
}
private bool _requiresRealizationUpdates;
}
}
// 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.
//
//
//
// Description: DrawingImage class
// An ImageSource with a Drawing for content
//
//
// History:
// 05/26/2005 : jordanpa - Created it
//
//---------------------------------------------------------------------------
using MS.Internal;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Media.Imaging;
namespace System.Windows.Media
{
///
/// The class definition for DrawingImage
///
public sealed partial class DrawingImage : ImageSource
{
///
/// Default DrawingImage ctor
///
public DrawingImage()
{
}
///
/// DrawingImage ctor that takes a Drawing
///
/// The content of the DrawingImage
public DrawingImage(Drawing drawing)
{
Drawing = drawing;
}
///
/// Width of the DrawingImage
///
public override double Width
{
get
{
ReadPreamble();
return Size.Width;
}
}
///
/// Height of the DrawingImage
///
public override double Height
{
get
{
ReadPreamble();
return Size.Height;
}
}
///
/// Get the Metadata of the DrawingImage
///
public override ImageMetadata Metadata
{
get
{
ReadPreamble();
// DrawingImage does not have any metadata currently defined.
return null;
}
}
///
/// Size for the DrawingImage
///
internal override Size Size
{
get
{
Drawing drawing = Drawing;
if (drawing != null)
{
Size size = drawing.GetBounds().Size;
if (!size.IsEmpty)
{
return size;
}
else
{
return new Size();
}
}
else
{
return new Size();
}
}
}
///
/// Precompute is called during the frame preparation phase. Derived classes
/// typically check if the brush requires realizations during this phase.
///
internal override void Precompute()
{
Drawing drawing = Drawing;
_requiresRealizationUpdates = false;
if (drawing != null)
{
drawing.PrecomputeCore();
_requiresRealizationUpdates = drawing.RequiresRealizationUpdates;
}
}
///
/// Checks if realization updates are requried for this resource.
///
internal override bool RequiresRealizationUpdates { get { return _requiresRealizationUpdates; } }
///
/// Derived classes must override this method and update realizations on dependent
/// resources if required.
///
internal override void UpdateRealizations(RealizationContext ctx)
{
if (_requiresRealizationUpdates)
{
Drawing drawing = Drawing;
Debug.Assert(drawing != null); // Otherwise _requiresRealizationUpdates would be false.
drawing.UpdateRealizations(ctx);
}
}
///
/// This node can introduce graphness
///
internal override bool CanIntroduceGraphness()
{
return true;
}
private bool _requiresRealizationUpdates;
}
}
// 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
- DiscoveryCallbackBehavior.cs
- TimeEnumHelper.cs
- IPEndPoint.cs
- MiniLockedBorderGlyph.cs
- XamlToRtfWriter.cs
- ColorInterpolationModeValidation.cs
- FormViewRow.cs
- StylusDownEventArgs.cs
- RenderContext.cs
- ExpressionVisitor.cs
- xdrvalidator.cs
- ProcessModelSection.cs
- StateItem.cs
- GridItem.cs
- Triangle.cs
- DataBoundControlHelper.cs
- StylusTouchDevice.cs
- ControlCollection.cs
- TextPenaltyModule.cs
- LineGeometry.cs
- XmlSchemaParticle.cs
- SerializerDescriptor.cs
- TableLayoutPanel.cs
- DbConnectionHelper.cs
- DiscreteKeyFrames.cs
- DataFieldConverter.cs
- ObjectConverter.cs
- JoinQueryOperator.cs
- HtmlInputCheckBox.cs
- ColumnCollection.cs
- IFormattable.cs
- FontWeight.cs
- EncodingNLS.cs
- DbLambda.cs
- ChangePasswordAutoFormat.cs
- ScrollEventArgs.cs
- TextRangeAdaptor.cs
- CompositeFontFamily.cs
- SiteMapNodeItemEventArgs.cs
- TableStyle.cs
- HttpStreamXmlDictionaryWriter.cs
- EntityChangedParams.cs
- CodeIdentifier.cs
- TemplateField.cs
- TableCellAutomationPeer.cs
- FragmentNavigationEventArgs.cs
- LinearKeyFrames.cs
- MultiTrigger.cs
- InternalConfigHost.cs
- MSG.cs
- FileUpload.cs
- HtmlTextViewAdapter.cs
- RequestCachingSection.cs
- BitmapInitialize.cs
- DataErrorValidationRule.cs
- RectangleGeometry.cs
- Expander.cs
- CodeSubDirectory.cs
- COAUTHIDENTITY.cs
- FormsAuthenticationCredentials.cs
- RowType.cs
- Delegate.cs
- MessageSecurityOverMsmqElement.cs
- List.cs
- WebGetAttribute.cs
- Calendar.cs
- FrameworkTextComposition.cs
- DrawingBrush.cs
- securitycriticaldata.cs
- NotFiniteNumberException.cs
- XpsSerializationException.cs
- RowParagraph.cs
- RuleSettingsCollection.cs
- UxThemeWrapper.cs
- WebPageTraceListener.cs
- RegisteredExpandoAttribute.cs
- ApplicationDirectoryMembershipCondition.cs
- IgnoreFlushAndCloseStream.cs
- XPathException.cs
- XmlNode.cs
- MenuAdapter.cs
- PrePrepareMethodAttribute.cs
- TextEditorTables.cs
- XhtmlConformanceSection.cs
- WebPartUserCapability.cs
- DesignerCategoryAttribute.cs
- FileVersion.cs
- ExpandableObjectConverter.cs
- StylusCollection.cs
- SapiRecoInterop.cs
- WebScriptMetadataInstanceContextProvider.cs
- AppDomain.cs
- Form.cs
- ResourceDictionaryCollection.cs
- IMembershipProvider.cs
- IIS7UserPrincipal.cs
- ExceptionAggregator.cs
- MsmqBindingFilter.cs
- MemoryRecordBuffer.cs
- ConfigErrorGlyph.cs