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
- CatalogZone.cs
- MarkupExtensionParser.cs
- ViewBase.cs
- ToolStripArrowRenderEventArgs.cs
- XmlBuffer.cs
- ConversionContext.cs
- CheckBox.cs
- ClientData.cs
- SupportsEventValidationAttribute.cs
- BitmapSource.cs
- FixedDocumentSequencePaginator.cs
- IssuedSecurityTokenProvider.cs
- SqlCacheDependencyDatabaseCollection.cs
- SignatureHelper.cs
- BamlLocalizationDictionary.cs
- KeyboardEventArgs.cs
- EnumUnknown.cs
- EmptyCollection.cs
- BulletChrome.cs
- AsmxEndpointPickerExtension.cs
- FileEnumerator.cs
- ImmComposition.cs
- HttpVersion.cs
- ContentType.cs
- mongolianshape.cs
- DataGrid.cs
- SqlColumnizer.cs
- ExpressionEditor.cs
- RadioButtonBaseAdapter.cs
- DataExpression.cs
- PermissionToken.cs
- HiddenField.cs
- PropertyChangedEventManager.cs
- IgnoreFileBuildProvider.cs
- CodeDelegateInvokeExpression.cs
- OLEDB_Util.cs
- SectionUpdates.cs
- WasEndpointConfigContainer.cs
- TimeSpanStorage.cs
- PanelDesigner.cs
- PageCatalogPart.cs
- DesignTimeTemplateParser.cs
- SqlError.cs
- Point4D.cs
- ConfigurationManagerHelper.cs
- ListViewGroup.cs
- SafeNativeMethods.cs
- XmlCountingReader.cs
- IFlowDocumentViewer.cs
- SafeWaitHandle.cs
- ClientFormsAuthenticationCredentials.cs
- _AutoWebProxyScriptWrapper.cs
- PathFigureCollectionConverter.cs
- DSASignatureDeformatter.cs
- EntityDataSourceContextDisposingEventArgs.cs
- PreservationFileReader.cs
- SystemUdpStatistics.cs
- Group.cs
- SessionState.cs
- TextBoxAutoCompleteSourceConverter.cs
- StringResourceManager.cs
- PersonalizableAttribute.cs
- LocalFileSettingsProvider.cs
- TypeDependencyAttribute.cs
- HuffModule.cs
- SecurityTokenSpecification.cs
- DataGridHeaderBorder.cs
- WeakReadOnlyCollection.cs
- BitmapMetadataEnumerator.cs
- RawStylusInputCustomDataList.cs
- InternalReceiveMessage.cs
- ColumnMap.cs
- BinaryUtilClasses.cs
- QilList.cs
- ToolboxDataAttribute.cs
- ConnectionPointCookie.cs
- transactioncontext.cs
- DocumentPageTextView.cs
- BrowserCapabilitiesCompiler.cs
- MDIWindowDialog.cs
- XmlSerializerFactory.cs
- GraphicsContext.cs
- CircleHotSpot.cs
- NonSerializedAttribute.cs
- TypeDependencyAttribute.cs
- Unit.cs
- ExcCanonicalXml.cs
- COM2TypeInfoProcessor.cs
- CodeThrowExceptionStatement.cs
- WebPartEditorApplyVerb.cs
- ProtocolsConfigurationEntry.cs
- ControlCollection.cs
- OdbcErrorCollection.cs
- SqlPersonalizationProvider.cs
- ToolStripMenuItem.cs
- OptimalBreakSession.cs
- ScalarOps.cs
- TextProperties.cs
- DecimalStorage.cs
- FunctionImportElement.cs