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 / Automation / Peers / TableAutomationPeer.cs / 1 / TableAutomationPeer.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: TableAutomationPeer.cs
//
// Description: Automation peer for Table
//
//---------------------------------------------------------------------------
using System.Windows.Automation.Provider; // IRawElementProviderSimple
using System.Windows.Documents;
namespace System.Windows.Automation.Peers
{
///
public class TableAutomationPeer : TextElementAutomationPeer, IGridProvider
{
///
/// Constructor.
///
/// Owner of the AutomationPeer.
public TableAutomationPeer(Table owner)
: base(owner)
{
_rowCount = GetRowCount();
_columnCount = GetColumnCount();
}
///
///
///
public override object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Grid)
{
return this;
}
return null;
}
///
///
///
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Table;
}
///
///
///
protected override string GetClassNameCore()
{
return "Table";
}
///
///
///
protected override bool IsControlElementCore()
{
return true;
}
///
///
///
protected override bool IsContentElementCore()
{
return true;
}
///
/// Raises property changed events in response to structure changes.
///
internal void OnStructureInvalidated()
{
int rowCount = GetRowCount();
if (rowCount != _rowCount)
{
RaisePropertyChangedEvent(GridPatternIdentifiers.RowCountProperty, _rowCount, rowCount);
_rowCount = rowCount;
}
int columnCount = GetColumnCount();
if (columnCount != _columnCount)
{
RaisePropertyChangedEvent(GridPatternIdentifiers.ColumnCountProperty, _columnCount, columnCount);
_columnCount = columnCount;
}
}
///
/// Returns the number of rows.
///
private int GetRowCount()
{
int rows = 0;
foreach (TableRowGroup group in ((Table)Owner).RowGroups)
{
rows += group.Rows.Count;
}
return rows;
}
///
/// Returns the number of columns.
///
private int GetColumnCount()
{
return ((Table)Owner).ColumnCount;
}
private int _rowCount;
private int _columnCount;
//-------------------------------------------------------------------
//
// IGridProvider Members
//
//-------------------------------------------------------------------
#region IGridProvider Members
///
/// Returns the provider for the element that is located at the row and
/// column location requested by the client.
///
IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
{
if (row < 0 || row >= ((IGridProvider)this).RowCount)
{
throw new ArgumentOutOfRangeException("row");
}
if (column < 0 || column >= ((IGridProvider)this).ColumnCount)
{
throw new ArgumentOutOfRangeException("column");
}
int currentRow = 0;
Table table = (Table)Owner;
foreach (TableRowGroup group in table.RowGroups)
{
if (currentRow + group.Rows.Count < row)
{
currentRow += group.Rows.Count;
}
else
{
foreach (TableRow tableRow in group.Rows)
{
if (currentRow == row)
{
foreach (TableCell cell in tableRow.Cells)
{
if (cell.ColumnIndex <= column && cell.ColumnIndex + cell.ColumnSpan > column)
{
return ProviderFromPeer(CreatePeerForElement(cell));
}
}
// check spanned cells
foreach (TableCell cell in tableRow.SpannedCells)
{
if (cell.ColumnIndex <= column && cell.ColumnIndex + cell.ColumnSpan > column)
{
return ProviderFromPeer(CreatePeerForElement(cell));
}
}
}
else
{
currentRow++;
}
}
}
}
return null;
}
///
/// Returns the number of rows in the grid at the time this was requested.
///
int IGridProvider.RowCount
{
get { return _rowCount; }
}
///
/// Returns the number of columns in the grid at the time this was requested.
///
int IGridProvider.ColumnCount
{
get { return _columnCount; }
}
#endregion IGridProvider Members
}
}
// 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: TableAutomationPeer.cs
//
// Description: Automation peer for Table
//
//---------------------------------------------------------------------------
using System.Windows.Automation.Provider; // IRawElementProviderSimple
using System.Windows.Documents;
namespace System.Windows.Automation.Peers
{
///
public class TableAutomationPeer : TextElementAutomationPeer, IGridProvider
{
///
/// Constructor.
///
/// Owner of the AutomationPeer.
public TableAutomationPeer(Table owner)
: base(owner)
{
_rowCount = GetRowCount();
_columnCount = GetColumnCount();
}
///
///
///
public override object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Grid)
{
return this;
}
return null;
}
///
///
///
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Table;
}
///
///
///
protected override string GetClassNameCore()
{
return "Table";
}
///
///
///
protected override bool IsControlElementCore()
{
return true;
}
///
///
///
protected override bool IsContentElementCore()
{
return true;
}
///
/// Raises property changed events in response to structure changes.
///
internal void OnStructureInvalidated()
{
int rowCount = GetRowCount();
if (rowCount != _rowCount)
{
RaisePropertyChangedEvent(GridPatternIdentifiers.RowCountProperty, _rowCount, rowCount);
_rowCount = rowCount;
}
int columnCount = GetColumnCount();
if (columnCount != _columnCount)
{
RaisePropertyChangedEvent(GridPatternIdentifiers.ColumnCountProperty, _columnCount, columnCount);
_columnCount = columnCount;
}
}
///
/// Returns the number of rows.
///
private int GetRowCount()
{
int rows = 0;
foreach (TableRowGroup group in ((Table)Owner).RowGroups)
{
rows += group.Rows.Count;
}
return rows;
}
///
/// Returns the number of columns.
///
private int GetColumnCount()
{
return ((Table)Owner).ColumnCount;
}
private int _rowCount;
private int _columnCount;
//-------------------------------------------------------------------
//
// IGridProvider Members
//
//-------------------------------------------------------------------
#region IGridProvider Members
///
/// Returns the provider for the element that is located at the row and
/// column location requested by the client.
///
IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
{
if (row < 0 || row >= ((IGridProvider)this).RowCount)
{
throw new ArgumentOutOfRangeException("row");
}
if (column < 0 || column >= ((IGridProvider)this).ColumnCount)
{
throw new ArgumentOutOfRangeException("column");
}
int currentRow = 0;
Table table = (Table)Owner;
foreach (TableRowGroup group in table.RowGroups)
{
if (currentRow + group.Rows.Count < row)
{
currentRow += group.Rows.Count;
}
else
{
foreach (TableRow tableRow in group.Rows)
{
if (currentRow == row)
{
foreach (TableCell cell in tableRow.Cells)
{
if (cell.ColumnIndex <= column && cell.ColumnIndex + cell.ColumnSpan > column)
{
return ProviderFromPeer(CreatePeerForElement(cell));
}
}
// check spanned cells
foreach (TableCell cell in tableRow.SpannedCells)
{
if (cell.ColumnIndex <= column && cell.ColumnIndex + cell.ColumnSpan > column)
{
return ProviderFromPeer(CreatePeerForElement(cell));
}
}
}
else
{
currentRow++;
}
}
}
}
return null;
}
///
/// Returns the number of rows in the grid at the time this was requested.
///
int IGridProvider.RowCount
{
get { return _rowCount; }
}
///
/// Returns the number of columns in the grid at the time this was requested.
///
int IGridProvider.ColumnCount
{
get { return _columnCount; }
}
#endregion IGridProvider Members
}
}
// 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
- MaskedTextBox.cs
- XmlSchemaCompilationSettings.cs
- TimerEventSubscriptionCollection.cs
- ContextMenu.cs
- Environment.cs
- PathFigureCollection.cs
- ConfigPathUtility.cs
- XmlSchemaInferenceException.cs
- X509AudioLogo.cs
- StringConverter.cs
- ResourceBinder.cs
- EntityDataSourceQueryBuilder.cs
- StrokeCollectionConverter.cs
- WebServiceParameterData.cs
- DetailsViewDeleteEventArgs.cs
- FixedPageStructure.cs
- ExecutionContext.cs
- AccessibleObject.cs
- ScalarOps.cs
- DiagnosticsConfigurationHandler.cs
- SimpleMailWebEventProvider.cs
- SqlDataSourceCommandEventArgs.cs
- CodeExpressionStatement.cs
- MSAAWinEventWrap.cs
- UpdatePanel.cs
- _BufferOffsetSize.cs
- CodeAccessPermission.cs
- ListContractAdapter.cs
- XamlPointCollectionSerializer.cs
- ListViewItemSelectionChangedEvent.cs
- BitmapCodecInfo.cs
- DecoderExceptionFallback.cs
- SupportsPreviewControlAttribute.cs
- DetailsViewInsertEventArgs.cs
- DomainUpDown.cs
- Scene3D.cs
- Char.cs
- SqlReorderer.cs
- ImageMetadata.cs
- Util.cs
- TdsEnums.cs
- ScriptHandlerFactory.cs
- IriParsingElement.cs
- BitmapInitialize.cs
- IdentityHolder.cs
- PropertyEmitterBase.cs
- PaperSource.cs
- XsltLibrary.cs
- ZipIOCentralDirectoryBlock.cs
- ProfilePropertySettingsCollection.cs
- TypeInfo.cs
- EventWaitHandleSecurity.cs
- IndexingContentUnit.cs
- EpmCustomContentSerializer.cs
- Part.cs
- XmlBinaryReader.cs
- WebConfigurationHostFileChange.cs
- FixedSOMElement.cs
- BuildResult.cs
- FormsIdentity.cs
- SocketElement.cs
- ListViewSortEventArgs.cs
- SchemaCompiler.cs
- EditingScope.cs
- CompilerWrapper.cs
- SqlInfoMessageEvent.cs
- Point3DAnimation.cs
- GlyphInfoList.cs
- ListView.cs
- Columns.cs
- DragStartedEventArgs.cs
- PeerCollaborationPermission.cs
- ClientBuildManager.cs
- ButtonFlatAdapter.cs
- DBAsyncResult.cs
- HandlerFactoryCache.cs
- TextSerializer.cs
- Size.cs
- PerformanceCountersElement.cs
- CqlParserHelpers.cs
- EUCJPEncoding.cs
- KeyedQueue.cs
- GeneralTransform.cs
- RawMouseInputReport.cs
- ResolvedKeyFrameEntry.cs
- BinaryMessageFormatter.cs
- RoutedCommand.cs
- XmlNamedNodeMap.cs
- CodeComment.cs
- Geometry.cs
- ProvideValueServiceProvider.cs
- DebugInfo.cs
- HttpPostedFile.cs
- MasterPageCodeDomTreeGenerator.cs
- MessageBuilder.cs
- FixedSOMLineCollection.cs
- InstanceCollisionException.cs
- DelimitedListTraceListener.cs
- HttpInputStream.cs
- ColorInterpolationModeValidation.cs