Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / Documents / FixedSOMImage.cs / 1 / 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
- WebPartExportVerb.cs
- TextCollapsingProperties.cs
- DataGridViewColumnCollection.cs
- DrawingBrush.cs
- SymbolType.cs
- ServicePointManager.cs
- DataErrorValidationRule.cs
- XslTransform.cs
- SystemIPGlobalProperties.cs
- DetailsViewRow.cs
- BindingManagerDataErrorEventArgs.cs
- FontConverter.cs
- DependencyPropertyChangedEventArgs.cs
- DateTimePicker.cs
- TextEditorThreadLocalStore.cs
- Switch.cs
- HtmlElementErrorEventArgs.cs
- GcHandle.cs
- HitTestWithPointDrawingContextWalker.cs
- FacetValues.cs
- DataGridCaption.cs
- CodeDomDesignerLoader.cs
- CategoryAttribute.cs
- ListParaClient.cs
- ExecutionContext.cs
- RedistVersionInfo.cs
- FastEncoderWindow.cs
- DependencyProperty.cs
- TableRow.cs
- UpdatableWrapper.cs
- DrawingServices.cs
- Baml2006KnownTypes.cs
- RequestCache.cs
- RegisteredDisposeScript.cs
- QueuePathDialog.cs
- SizeIndependentAnimationStorage.cs
- OracleDataAdapter.cs
- FragmentQuery.cs
- WorkflowQueueInfo.cs
- DataGridCell.cs
- CalculatedColumn.cs
- LoginDesigner.cs
- SequentialOutput.cs
- ConfigurationElementCollection.cs
- PackageRelationshipSelector.cs
- Code.cs
- FrugalList.cs
- SelectionGlyph.cs
- SqlUtil.cs
- AttributeEmitter.cs
- SerializationAttributes.cs
- FolderBrowserDialog.cs
- WebBrowserUriTypeConverter.cs
- StringUtil.cs
- FileLevelControlBuilderAttribute.cs
- TypeToStringValueConverter.cs
- OleDbConnectionInternal.cs
- UpdateTracker.cs
- SchemaInfo.cs
- BitmapEncoder.cs
- HtmlInputHidden.cs
- FunctionDefinition.cs
- TextProperties.cs
- ClientTarget.cs
- COM2ColorConverter.cs
- DiscreteKeyFrames.cs
- BrowserCapabilitiesFactoryBase.cs
- WebPartConnectionsDisconnectVerb.cs
- StickyNote.cs
- WebPartMinimizeVerb.cs
- LocatorGroup.cs
- CompositeKey.cs
- NamespaceEmitter.cs
- SchemaCollectionCompiler.cs
- XmlIncludeAttribute.cs
- CodeDOMUtility.cs
- PeerApplicationLaunchInfo.cs
- IgnorePropertiesAttribute.cs
- MonthChangedEventArgs.cs
- ZipIOBlockManager.cs
- ContractDescription.cs
- Journal.cs
- TripleDES.cs
- BlurBitmapEffect.cs
- PointHitTestResult.cs
- XmlSecureResolver.cs
- Item.cs
- StyleSelector.cs
- CompositionAdorner.cs
- FontFaceLayoutInfo.cs
- TokenBasedSetEnumerator.cs
- DefaultPropertyAttribute.cs
- ValidationResult.cs
- DynamicValidatorEventArgs.cs
- NameTable.cs
- SchemaType.cs
- InternalConfigSettingsFactory.cs
- ObjectParameterCollection.cs
- ProviderSettingsCollection.cs
- MediaTimeline.cs