Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Automation / Peers / DocumentViewerBaseAutomationPeer.cs / 1 / DocumentViewerBaseAutomationPeer.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: DocumentViewerBaseAutomationPeer.cs
//
// Description: AutomationPeer associated with DocumentViewerBase.
//
//---------------------------------------------------------------------------
using System.Collections.Generic; // List
using System.Windows.Controls.Primitives; // DocumentViewerBase
using System.Windows.Documents; // IDocumentPaginatorSource
namespace System.Windows.Automation.Peers
{
///
/// AutomationPeer associated with DocumentViewerBase.
///
public class DocumentViewerBaseAutomationPeer : FrameworkElementAutomationPeer
{
///
/// Constructor.
///
/// Owner of the AutomationPeer.
public DocumentViewerBaseAutomationPeer(DocumentViewerBase owner)
: base(owner)
{ }
///
///
///
public override object GetPattern(PatternInterface patternInterface)
{
object returnValue = null;
if (patternInterface == PatternInterface.Text)
{
// Make sure that Automation children are created.
this.GetChildren();
// Re-expose TextPattern from hosted document.
if (_documentPeer != null)
{
_documentPeer.EventsSource = this;
returnValue = _documentPeer.GetPattern(patternInterface);
}
}
return returnValue;
}
///
///
///
///
/// AutomationPeer associated with DocumentViewerBase returns an AutomationPeer
/// for hosted Document and for elements in the style.
///
protected override List GetChildrenCore()
{
// Get children for all elements in the style.
List children = base.GetChildrenCore();
// Add AutomationPeer associated with the document.
// Make it the first child of the collection.
AutomationPeer documentPeer = GetDocumentAutomationPeer();
if (_documentPeer != documentPeer)
{
if (_documentPeer != null)
{
_documentPeer.OnDisconnected();
}
_documentPeer = documentPeer as DocumentAutomationPeer;
}
if (documentPeer != null)
{
if (children == null)
{
children = new List();
}
children.Add(documentPeer);
}
return children;
}
///
///
///
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Document;
}
///
///
///
protected override string GetClassNameCore()
{
return "DocumentViewer";
}
///
/// Retrieves AutomationPeer for the document.
///
///
private AutomationPeer GetDocumentAutomationPeer()
{
AutomationPeer documentPeer = null;
IDocumentPaginatorSource document = ((DocumentViewerBase)Owner).Document;
if (document != null)
{
if (document is UIElement)
{
documentPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)document);
}
else if (document is ContentElement)
{
documentPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)document);
}
}
return documentPeer;
}
private DocumentAutomationPeer _documentPeer;
}
}
// 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: DocumentViewerBaseAutomationPeer.cs
//
// Description: AutomationPeer associated with DocumentViewerBase.
//
//---------------------------------------------------------------------------
using System.Collections.Generic; // List
using System.Windows.Controls.Primitives; // DocumentViewerBase
using System.Windows.Documents; // IDocumentPaginatorSource
namespace System.Windows.Automation.Peers
{
///
/// AutomationPeer associated with DocumentViewerBase.
///
public class DocumentViewerBaseAutomationPeer : FrameworkElementAutomationPeer
{
///
/// Constructor.
///
/// Owner of the AutomationPeer.
public DocumentViewerBaseAutomationPeer(DocumentViewerBase owner)
: base(owner)
{ }
///
///
///
public override object GetPattern(PatternInterface patternInterface)
{
object returnValue = null;
if (patternInterface == PatternInterface.Text)
{
// Make sure that Automation children are created.
this.GetChildren();
// Re-expose TextPattern from hosted document.
if (_documentPeer != null)
{
_documentPeer.EventsSource = this;
returnValue = _documentPeer.GetPattern(patternInterface);
}
}
return returnValue;
}
///
///
///
///
/// AutomationPeer associated with DocumentViewerBase returns an AutomationPeer
/// for hosted Document and for elements in the style.
///
protected override List GetChildrenCore()
{
// Get children for all elements in the style.
List children = base.GetChildrenCore();
// Add AutomationPeer associated with the document.
// Make it the first child of the collection.
AutomationPeer documentPeer = GetDocumentAutomationPeer();
if (_documentPeer != documentPeer)
{
if (_documentPeer != null)
{
_documentPeer.OnDisconnected();
}
_documentPeer = documentPeer as DocumentAutomationPeer;
}
if (documentPeer != null)
{
if (children == null)
{
children = new List();
}
children.Add(documentPeer);
}
return children;
}
///
///
///
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Document;
}
///
///
///
protected override string GetClassNameCore()
{
return "DocumentViewer";
}
///
/// Retrieves AutomationPeer for the document.
///
///
private AutomationPeer GetDocumentAutomationPeer()
{
AutomationPeer documentPeer = null;
IDocumentPaginatorSource document = ((DocumentViewerBase)Owner).Document;
if (document != null)
{
if (document is UIElement)
{
documentPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)document);
}
else if (document is ContentElement)
{
documentPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)document);
}
}
return documentPeer;
}
private DocumentAutomationPeer _documentPeer;
}
}
// 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
- CachedPathData.cs
- WebPartConnectionsCancelVerb.cs
- AnimationStorage.cs
- Int16AnimationBase.cs
- DateTimeSerializationSection.cs
- OpCodes.cs
- HebrewNumber.cs
- ConnectorEditor.cs
- CodeNamespaceImportCollection.cs
- MetadataItemEmitter.cs
- TopClause.cs
- ExtendedPropertyCollection.cs
- PartialTrustVisibleAssembly.cs
- BitmapFrameDecode.cs
- Sql8ExpressionRewriter.cs
- StaticSiteMapProvider.cs
- GetLastErrorDetailsRequest.cs
- IgnoreSectionHandler.cs
- StylusLogic.cs
- FormViewDeletedEventArgs.cs
- HttpListener.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- MergePropertyDescriptor.cs
- DocumentReferenceCollection.cs
- ParameterRetriever.cs
- InfoCardSymmetricCrypto.cs
- DATA_BLOB.cs
- Container.cs
- FamilyMap.cs
- SettingsBase.cs
- Pair.cs
- DataGridViewComponentPropertyGridSite.cs
- ContainerControl.cs
- SecurityException.cs
- DurableEnlistmentState.cs
- ImpersonateTokenRef.cs
- Filter.cs
- PointLightBase.cs
- SystemNetworkInterface.cs
- IsolatedStorage.cs
- ByValueEqualityComparer.cs
- MultiAsyncResult.cs
- ColorConvertedBitmapExtension.cs
- SmiTypedGetterSetter.cs
- DrawingState.cs
- CheckBoxBaseAdapter.cs
- DateTime.cs
- ManagementOperationWatcher.cs
- SqlUtils.cs
- TextRangeProviderWrapper.cs
- sortedlist.cs
- InheritanceService.cs
- SqlStream.cs
- ToolStripCodeDomSerializer.cs
- DataContractSerializerMessageContractImporter.cs
- XmlResolver.cs
- latinshape.cs
- XPathEmptyIterator.cs
- ECDiffieHellman.cs
- ToolStripSettings.cs
- BufferAllocator.cs
- PersistChildrenAttribute.cs
- MatrixUtil.cs
- ProgressBarRenderer.cs
- EntityCommandCompilationException.cs
- WindowsGraphicsWrapper.cs
- ButtonChrome.cs
- ServiceOperationDetailViewControl.cs
- TextInfo.cs
- MimeWriter.cs
- XmlSchemaComplexType.cs
- Script.cs
- PointConverter.cs
- _LazyAsyncResult.cs
- EncoderFallback.cs
- Rule.cs
- ObjectViewQueryResultData.cs
- Int64Converter.cs
- _emptywebproxy.cs
- DnsPermission.cs
- SignedXml.cs
- RedistVersionInfo.cs
- TextPattern.cs
- DataContractAttribute.cs
- CriticalFinalizerObject.cs
- DataGridCaption.cs
- MachineKeyConverter.cs
- ConfigXmlWhitespace.cs
- DataTransferEventArgs.cs
- String.cs
- SQLBoolean.cs
- CompositeControl.cs
- CellRelation.cs
- OracleParameterCollection.cs
- AsyncOperation.cs
- SizeAnimationUsingKeyFrames.cs
- PerformanceCountersElement.cs
- KoreanLunisolarCalendar.cs
- HtmlContainerControl.cs
- GradientBrush.cs