Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / FixedSOMImage.cs / 1305600 / FixedSOMImage.cs
/*++ File: FixedSOMImage.cs Copyright (C) 2005 Microsoft Corporation. All rights reserved. Description: SOM object that wraps an image on the page. The corresponding markup element can be either an image or a Path with an ImageBrush History: 05/17/2005: agurcan - Created --*/ namespace System.Windows.Documents { using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Globalization; using System.Diagnostics; internal sealed class FixedSOMImage : FixedSOMElement { //-------------------------------------------------------------------- // // Constructors // //--------------------------------------------------------------------- #region Constructors private FixedSOMImage(Rect imageRect, GeneralTransform trans, Uri sourceUri, FixedNode node, DependencyObject o) : base(node, trans) { _boundingRect = trans.TransformBounds(imageRect); _source = sourceUri; _startIndex = 0; _endIndex = 1; _name = AutomationProperties.GetName(o); _helpText = AutomationProperties.GetHelpText(o); } #endregion Constructors //------------------------------------------------------------------- // // Public Methods // //--------------------------------------------------------------------- #region Public Methods public static FixedSOMImage Create(FixedPage page, Image image, FixedNode fixedNode) { Uri imageUri = null; if (image.Source is BitmapImage) { BitmapImage imageSource = image.Source as BitmapImage; imageUri = imageSource.UriSource; } else if (image.Source is BitmapFrame) { BitmapFrame imageSource = image.Source as BitmapFrame; imageUri = new Uri(imageSource.ToString(), UriKind.RelativeOrAbsolute); } Rect sourceRect = new Rect(image.RenderSize); GeneralTransform transform = image.TransformToAncestor(page); return new FixedSOMImage(sourceRect, transform, imageUri, fixedNode, image); } public static FixedSOMImage Create(FixedPage page, Path path, FixedNode fixedNode) { Debug.Assert(path.Fill is ImageBrush); ImageSource source = ((ImageBrush)(path.Fill)).ImageSource; Uri imageUri = null; if (source is BitmapImage) { BitmapImage imageSource = source as BitmapImage; imageUri = imageSource.UriSource; } else if (source is BitmapFrame) { BitmapFrame imageSource = source as BitmapFrame; imageUri = new Uri(imageSource.ToString(), UriKind.RelativeOrAbsolute); } Rect sourceRect = path.Data.Bounds; GeneralTransform trans = path.TransformToAncestor(page); return new FixedSOMImage(sourceRect, trans, imageUri, fixedNode, path); } #if DEBUG public override void Render(DrawingContext dc, string label, DrawDebugVisual debugVisual) { Pen pen = new Pen(Brushes.Yellow, 1); Rect rect = _boundingRect; rect.Inflate(5,5); dc.DrawRectangle(null, pen , rect); if (label != null && debugVisual == DrawDebugVisual.Paragraphs) { base.RenderLabel(dc, label); } } #endif #endregion Public Methods //-------------------------------------------------------------------- // // Internal Properties // //--------------------------------------------------------------------- #region Internal Properties internal Uri Source { get { return _source; } } internal String Name { get { return _name; } } internal String HelpText { get { return _helpText; } } #endregion Internal Properties //-------------------------------------------------------------------- // // Private Fields // //---------------------------------------------------------------------- #region Private Fields private Uri _source; private String _name; private String _helpText; #endregion Interanl Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /*++ File: FixedSOMImage.cs Copyright (C) 2005 Microsoft Corporation. All rights reserved. Description: SOM object that wraps an image on the page. The corresponding markup element can be either an image or a Path with an ImageBrush History: 05/17/2005: agurcan - Created --*/ namespace System.Windows.Documents { using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Globalization; using System.Diagnostics; internal sealed class FixedSOMImage : FixedSOMElement { //-------------------------------------------------------------------- // // Constructors // //--------------------------------------------------------------------- #region Constructors private FixedSOMImage(Rect imageRect, GeneralTransform trans, Uri sourceUri, FixedNode node, DependencyObject o) : base(node, trans) { _boundingRect = trans.TransformBounds(imageRect); _source = sourceUri; _startIndex = 0; _endIndex = 1; _name = AutomationProperties.GetName(o); _helpText = AutomationProperties.GetHelpText(o); } #endregion Constructors //------------------------------------------------------------------- // // Public Methods // //--------------------------------------------------------------------- #region Public Methods public static FixedSOMImage Create(FixedPage page, Image image, FixedNode fixedNode) { Uri imageUri = null; if (image.Source is BitmapImage) { BitmapImage imageSource = image.Source as BitmapImage; imageUri = imageSource.UriSource; } else if (image.Source is BitmapFrame) { BitmapFrame imageSource = image.Source as BitmapFrame; imageUri = new Uri(imageSource.ToString(), UriKind.RelativeOrAbsolute); } Rect sourceRect = new Rect(image.RenderSize); GeneralTransform transform = image.TransformToAncestor(page); return new FixedSOMImage(sourceRect, transform, imageUri, fixedNode, image); } public static FixedSOMImage Create(FixedPage page, Path path, FixedNode fixedNode) { Debug.Assert(path.Fill is ImageBrush); ImageSource source = ((ImageBrush)(path.Fill)).ImageSource; Uri imageUri = null; if (source is BitmapImage) { BitmapImage imageSource = source as BitmapImage; imageUri = imageSource.UriSource; } else if (source is BitmapFrame) { BitmapFrame imageSource = source as BitmapFrame; imageUri = new Uri(imageSource.ToString(), UriKind.RelativeOrAbsolute); } Rect sourceRect = path.Data.Bounds; GeneralTransform trans = path.TransformToAncestor(page); return new FixedSOMImage(sourceRect, trans, imageUri, fixedNode, path); } #if DEBUG public override void Render(DrawingContext dc, string label, DrawDebugVisual debugVisual) { Pen pen = new Pen(Brushes.Yellow, 1); Rect rect = _boundingRect; rect.Inflate(5,5); dc.DrawRectangle(null, pen , rect); if (label != null && debugVisual == DrawDebugVisual.Paragraphs) { base.RenderLabel(dc, label); } } #endif #endregion Public Methods //-------------------------------------------------------------------- // // Internal Properties // //--------------------------------------------------------------------- #region Internal Properties internal Uri Source { get { return _source; } } internal String Name { get { return _name; } } internal String HelpText { get { return _helpText; } } #endregion Internal Properties //-------------------------------------------------------------------- // // Private Fields // //---------------------------------------------------------------------- #region Private Fields private Uri _source; private String _name; private String _helpText; #endregion Interanl Fields } } // 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
- SystemIPv6InterfaceProperties.cs
- LogConverter.cs
- TypeUnloadedException.cs
- Run.cs
- DoubleAnimationClockResource.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- InheritanceContextHelper.cs
- BuildProvidersCompiler.cs
- RectValueSerializer.cs
- WebPartUtil.cs
- DocumentPaginator.cs
- PackageDigitalSignatureManager.cs
- ImageField.cs
- ToolStripDropDownButton.cs
- NativeMethods.cs
- IntSecurity.cs
- BinaryObjectWriter.cs
- ChildChangedEventArgs.cs
- DeferredSelectedIndexReference.cs
- TreeIterators.cs
- OleDbFactory.cs
- Comparer.cs
- XmlNodeReader.cs
- HierarchicalDataSourceControl.cs
- StreamedFramingRequestChannel.cs
- AdvancedBindingEditor.cs
- PocoPropertyAccessorStrategy.cs
- SystemGatewayIPAddressInformation.cs
- _TLSstream.cs
- BmpBitmapEncoder.cs
- SelectionEditingBehavior.cs
- IdentityNotMappedException.cs
- PrePostDescendentsWalker.cs
- WebControlToolBoxItem.cs
- AdjustableArrowCap.cs
- NodeFunctions.cs
- GcHandle.cs
- DynamicILGenerator.cs
- HGlobalSafeHandle.cs
- CookieProtection.cs
- ClientConvert.cs
- DataContractSerializerOperationGenerator.cs
- SoapHeaders.cs
- ProfileSection.cs
- _SslSessionsCache.cs
- NonVisualControlAttribute.cs
- MulticastNotSupportedException.cs
- FixedDocument.cs
- HtmlTernaryTree.cs
- TreeNodeCollection.cs
- DataGridHeaderBorder.cs
- TableAutomationPeer.cs
- ScriptControlDescriptor.cs
- BaseDataListPage.cs
- WhitespaceRuleLookup.cs
- AutoGeneratedFieldProperties.cs
- UIElementHelper.cs
- AccessorTable.cs
- ImageSource.cs
- ScriptControlManager.cs
- MetabaseServerConfig.cs
- Compensation.cs
- future.cs
- ThemeInfoAttribute.cs
- XmlSchemas.cs
- ReceiveActivityDesigner.cs
- RadioButton.cs
- CacheSection.cs
- StylusEditingBehavior.cs
- COM2PropertyBuilderUITypeEditor.cs
- IdentityNotMappedException.cs
- WebPartVerbCollection.cs
- ItemCheckedEvent.cs
- ScrollBarAutomationPeer.cs
- XmlHelper.cs
- ThreadPoolTaskScheduler.cs
- InputLangChangeEvent.cs
- ClientBuildManager.cs
- MenuAutomationPeer.cs
- WaitHandleCannotBeOpenedException.cs
- OpCopier.cs
- CharacterMetricsDictionary.cs
- LayoutEngine.cs
- StringPropertyBuilder.cs
- ClassHandlersStore.cs
- ErrorEventArgs.cs
- HitTestDrawingContextWalker.cs
- DataTableMappingCollection.cs
- DataSetUtil.cs
- BamlLocalizer.cs
- InheritanceContextHelper.cs
- fixedPageContentExtractor.cs
- RsaSecurityTokenParameters.cs
- _UriSyntax.cs
- MarginCollapsingState.cs
- RuntimeIdentifierPropertyAttribute.cs
- DataSysAttribute.cs
- SignatureToken.cs
- BooleanAnimationBase.cs
- RequiredAttributeAttribute.cs