Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Automation / Peers / DocumentViewerBaseAutomationPeer.cs / 1305600 / 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);
}
}
else
{
returnValue = base.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);
}
}
else
{
returnValue = base.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
- TileBrush.cs
- NewExpression.cs
- SqlSupersetValidator.cs
- FormatterServices.cs
- ByteFacetDescriptionElement.cs
- PeerIPHelper.cs
- UpDownBaseDesigner.cs
- TdsParserSafeHandles.cs
- WindowsScrollBar.cs
- InputLanguage.cs
- UIElementIsland.cs
- UndoManager.cs
- ItemList.cs
- FixedTextPointer.cs
- SafeFileMapViewHandle.cs
- CompareInfo.cs
- RTLAwareMessageBox.cs
- XmlDataSource.cs
- ToolStripSplitButton.cs
- UnitControl.cs
- OdbcConnectionOpen.cs
- NamespaceDecl.cs
- ContentOperations.cs
- ControlBindingsConverter.cs
- Boolean.cs
- UTF32Encoding.cs
- DataServiceProcessingPipelineEventArgs.cs
- CharAnimationUsingKeyFrames.cs
- Int64Converter.cs
- wgx_commands.cs
- SecureEnvironment.cs
- OperationInvokerBehavior.cs
- cache.cs
- DBBindings.cs
- XmlSchemaImporter.cs
- FloaterBaseParagraph.cs
- SystemIPGlobalStatistics.cs
- InlineUIContainer.cs
- BaseTemplateBuildProvider.cs
- TraceContextRecord.cs
- RawStylusSystemGestureInputReport.cs
- PriorityBindingExpression.cs
- WorkflowElementDialog.cs
- DecoderReplacementFallback.cs
- TextDecorationCollection.cs
- DBConnection.cs
- EncoderParameters.cs
- TreeViewItemAutomationPeer.cs
- TextElementCollectionHelper.cs
- EntityModelBuildProvider.cs
- SystemIcmpV6Statistics.cs
- RegexCaptureCollection.cs
- ValuePattern.cs
- EventListener.cs
- ExpressionConverter.cs
- SortDescription.cs
- TextPointerBase.cs
- XmlEncodedRawTextWriter.cs
- RijndaelManaged.cs
- InvokeBinder.cs
- UIElement3D.cs
- HtmlEncodedRawTextWriter.cs
- PeerSecurityManager.cs
- WindowsSecurityToken.cs
- DocumentOrderQuery.cs
- SafeBitVector32.cs
- PriorityQueue.cs
- Helpers.cs
- HtmlInputFile.cs
- VectorAnimationBase.cs
- ScriptDescriptor.cs
- RegexGroup.cs
- EventMappingSettingsCollection.cs
- XmlCollation.cs
- GridItem.cs
- DeleteHelper.cs
- EntityTypeEmitter.cs
- DataServiceQueryException.cs
- XmlImplementation.cs
- SqlDuplicator.cs
- PolyLineSegment.cs
- PathParser.cs
- Parser.cs
- ToolStripSplitButton.cs
- _WinHttpWebProxyDataBuilder.cs
- indexingfiltermarshaler.cs
- WebPartCatalogAddVerb.cs
- PlacementWorkspace.cs
- ParsedAttributeCollection.cs
- FieldAccessException.cs
- HttpGetServerProtocol.cs
- ValidatingPropertiesEventArgs.cs
- HelpKeywordAttribute.cs
- ZoomPercentageConverter.cs
- SynchronousChannel.cs
- PropertyPathWorker.cs
- Pen.cs
- EndpointReference.cs
- DNS.cs
- Page.cs