Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UpdateCommand.cs
- BitmapSourceSafeMILHandle.cs
- ZipIOLocalFileBlock.cs
- Stylus.cs
- DataListCommandEventArgs.cs
- HttpHeaderCollection.cs
- Util.cs
- RootCodeDomSerializer.cs
- elementinformation.cs
- XmlAttribute.cs
- AutomationProperties.cs
- BoolExpression.cs
- CodeTypeReference.cs
- MachineKeySection.cs
- TemplateControlCodeDomTreeGenerator.cs
- XmlSchemaSubstitutionGroup.cs
- InputLangChangeEvent.cs
- XmlSerializerNamespaces.cs
- RelatedCurrencyManager.cs
- InputMethodStateTypeInfo.cs
- PassportAuthenticationModule.cs
- SqlBuffer.cs
- EdmComplexPropertyAttribute.cs
- PriorityItem.cs
- DocumentViewerAutomationPeer.cs
- ChooseAction.cs
- RelationshipConstraintValidator.cs
- NetworkStream.cs
- DbRetry.cs
- Metadata.cs
- PathSegmentCollection.cs
- NativeCppClassAttribute.cs
- MessageSecurityOverTcp.cs
- TimelineGroup.cs
- TcpChannelHelper.cs
- RegionIterator.cs
- TextBoxBase.cs
- BitmapEffectrendercontext.cs
- EventLogConfiguration.cs
- PeerReferralPolicy.cs
- ConfigurationSettings.cs
- WebConfigurationHost.cs
- CodePrimitiveExpression.cs
- Publisher.cs
- DispatcherEventArgs.cs
- ParameterElementCollection.cs
- PolygonHotSpot.cs
- FormsAuthenticationUserCollection.cs
- QuadraticBezierSegment.cs
- DataGridViewComboBoxEditingControl.cs
- KeyGesture.cs
- EditableRegion.cs
- PolicyException.cs
- SetterBaseCollection.cs
- MarkupObject.cs
- IFormattable.cs
- Wildcard.cs
- DataGridViewSortCompareEventArgs.cs
- Compiler.cs
- MetabaseSettings.cs
- AssemblySettingAttributes.cs
- StylusPointPropertyUnit.cs
- Menu.cs
- EntityTypeEmitter.cs
- _DigestClient.cs
- OleDbConnectionFactory.cs
- AssemblyFilter.cs
- CheckBoxRenderer.cs
- JournalEntry.cs
- NavigationProperty.cs
- TemplateEditingVerb.cs
- SafeHandles.cs
- SqlConnectionFactory.cs
- SafeHandles.cs
- WorkflowMessageEventArgs.cs
- StylusPoint.cs
- MetaTableHelper.cs
- Random.cs
- Stopwatch.cs
- CommandExpr.cs
- CodeSubDirectory.cs
- MonthCalendar.cs
- webeventbuffer.cs
- ITreeGenerator.cs
- TextMetrics.cs
- HostProtectionPermission.cs
- SrgsItemList.cs
- Size.cs
- CacheChildrenQuery.cs
- HostedHttpContext.cs
- SiteMapPath.cs
- FieldBuilder.cs
- BindingExpression.cs
- SizeFConverter.cs
- UniqueConstraint.cs
- ADConnectionHelper.cs
- FormattedTextSymbols.cs
- ToolStripSeparator.cs
- BaseValidator.cs
- CultureTable.cs