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 / Documents / TableRow.cs / 1 / TableRow.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Table row implementation // // See spec at http://avalon/layout/Tables/WPP%20TableOM.doc // // History: // 05/19/2003 : olego - Created // //--------------------------------------------------------------------------- using MS.Internal; using MS.Internal.PtsHost; using MS.Internal.PtsTable; using MS.Internal.Text; using MS.Utility; using System; using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.Security; using System.Windows.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Markup; using MS.Internal.PtsHost.UnsafeNativeMethods; namespace System.Windows.Documents { ////// Table row /// [ContentProperty("Cells")] public class TableRow : TextElement, IAddChild { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors ////// Creates an instance of a Row /// public TableRow() : base() { PrivateInitialize(); } #endregion //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods ////// void IAddChild.AddChild(object value) { if (value == null) { throw new ArgumentNullException("value"); } TableCell cell = value as TableCell; if (cell != null) { Cells.Add(cell); return; } throw (new ArgumentException(SR.Get(SRID.UnexpectedParameterType, value.GetType(), typeof(TableCell)), "value")); } ////// /// void IAddChild.AddText(string text) { XamlSerializerUtil.ThrowIfNonWhiteSpaceInAddText(text, this); } ////// /// Called when tablerow gets new parent /// /// /// New parent of cell /// internal override void OnNewParent(DependencyObject newParent) { DependencyObject oldParent = this.Parent; if(newParent != null && !(newParent is TableRowGroup)) { throw new InvalidOperationException(SR.Get(SRID.TableInvalidParentNodeType, newParent.GetType().ToString())); } if(oldParent != null) { ((TableRowGroup)oldParent).Rows.InternalRemove(this); } base.OnNewParent(newParent); if (newParent != null) { ((TableRowGroup)newParent).Rows.InternalAdd(this); } } #endregion Public Methods //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods #endregion Protected Methods //----------------------------------------------------- // // Internal Methods // //------------------------------------------------------ #region Internal Methods ////// Callback used to notify the Row about entering model tree. /// internal void OnEnterParentTree() { if(Table != null) { Table.OnStructureChanged(); } } ////// Callback used to notify the RowGroup about exitting model tree. /// internal void OnExitParentTree() { } ////// Callback used to notify the Row about exitting model tree. /// internal void OnAfterExitParentTree(TableRowGroup rowGroup) { if(rowGroup.Table != null) { Table.OnStructureChanged(); } } ////// ValidateStructure /// internal void ValidateStructure(RowSpanVector rowSpanVector) { Debug.Assert(rowSpanVector != null); SetFlags(!rowSpanVector.Empty(), Flags.HasForeignCells); SetFlags(false, Flags.HasRealCells); _formatCellCount = 0; _columnCount = 0; int firstAvailableIndex; int firstOccupiedIndex; rowSpanVector.GetFirstAvailableRange(out firstAvailableIndex, out firstOccupiedIndex); for (int i = 0; i < _cells.Count; ++i) { TableCell cell = _cells[i]; // Get cloumn span and row span. Row span is limited to the number of rows in the row group. // Since we do not know the number of columns in the table at this point, column span is limited only // by internal constants int columnSpan = cell.ColumnSpan; int rowSpan = cell.RowSpan; while (firstAvailableIndex + columnSpan > firstOccupiedIndex) { rowSpanVector.GetNextAvailableRange(out firstAvailableIndex, out firstOccupiedIndex); } Debug.Assert(i <= firstAvailableIndex); cell.ValidateStructure(firstAvailableIndex); if (rowSpan > 1) { rowSpanVector.Register(cell); } else { _formatCellCount++; } firstAvailableIndex += columnSpan; } _columnCount = firstAvailableIndex; bool isLastRowOfAnySpan = false; rowSpanVector.GetSpanCells(out _spannedCells, out isLastRowOfAnySpan); Debug.Assert(_spannedCells != null); if((_formatCellCount > 0) || isLastRowOfAnySpan == true) { SetFlags(true, Flags.HasRealCells); } _formatCellCount += _spannedCells.Length; Debug.Assert(_cells.Count <= _formatCellCount); } #endregion Internal Methods //----------------------------------------------------- // // Internal Properties // //----------------------------------------------------- #region Internal Properties ////// RowGroup owner accessor /// internal TableRowGroup RowGroup { get { return (Parent as TableRowGroup); } } ////// Table owner accessor /// internal Table Table { get { return (RowGroup != null ? RowGroup.Table : null); } } ////// Returns the row's cell collection /// [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public TableCellCollection Cells { get { return (_cells); } } ////// This method is used by TypeDescriptor to determine if this property should /// be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeCells() { return (Cells.Count > 0); } ////// Row's index in the parents collection. /// internal int Index { get { return (_parentIndex); } set { Debug.Assert(value >= -1 && _parentIndex != value); _parentIndex = value; } } ////// Stores temporary data for where to insert a new cell /// internal int InsertionIndex { get { return _cellInsertionIndex; } set { _cellInsertionIndex = value; } } ////// Returns span cells vector /// internal TableCell[] SpannedCells { get { return (_spannedCells); } } ////// Count of columns in the table /// internal int ColumnCount { get { return (_columnCount); } } ////// Returns "true" if there are row spanned cells belonging to previous rows /// internal bool HasForeignCells { get { return (CheckFlags(Flags.HasForeignCells)); } } ////// Returns "true" if there are row spanned cells belonging to previous rows /// internal bool HasRealCells { get { return (CheckFlags(Flags.HasRealCells)); } } ////// Count of columns in the table /// internal int FormatCellCount { get { return (_formatCellCount); } } ////// Marks this element's left edge as visible to IMEs. /// This means element boundaries will act as word breaks. /// internal override bool IsIMEStructuralElement { get { return true; } } #endregion Internal Properties //----------------------------------------------------- // // Private Methods // //------------------------------------------------------ #region Private Methods ////// Private ctor time initialization. /// private void PrivateInitialize() { _cells = new TableCellCollection(this); _parentIndex = -1; _cellInsertionIndex = -1; } ////// SetFlags is used to set or unset one or multiple flags on the row. /// private void SetFlags(bool value, Flags flags) { _flags = value ? (_flags | flags) : (_flags & (~flags)); } ////// CheckFlags returns true if all flags in the bitmask flags are set. /// private bool CheckFlags(Flags flags) { return ((_flags & flags) == flags); } #endregion Private Methods //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private TableCellCollection _cells; // collection of cells belonging to the row private TableCell[] _spannedCells; // row spanned cell storage private int _parentIndex; // row's index in parent's children collection private int _cellInsertionIndex; // Insertion index a cell private int _columnCount; private Flags _flags; // flags reflecting various aspects of row's state private int _formatCellCount; // count of the cell to be formatted in this row #endregion Private Fields //------------------------------------------------------ // // Private Structures / Classes // //----------------------------------------------------- #region Private Structures Classes [System.Flags] private enum Flags { // // state flags // HasForeignCells = 0x00000010, // there are hanging cells from the previous rows HasRealCells = 0x00000020, // real cells in row (not just spanning) (Only known by validation, not format) } #endregion Private Structures Classes } } // 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. // // // // Description: Table row implementation // // See spec at http://avalon/layout/Tables/WPP%20TableOM.doc // // History: // 05/19/2003 : olego - Created // //--------------------------------------------------------------------------- using MS.Internal; using MS.Internal.PtsHost; using MS.Internal.PtsTable; using MS.Internal.Text; using MS.Utility; using System; using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.Security; using System.Windows.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Markup; using MS.Internal.PtsHost.UnsafeNativeMethods; namespace System.Windows.Documents { ////// Table row /// [ContentProperty("Cells")] public class TableRow : TextElement, IAddChild { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors ////// Creates an instance of a Row /// public TableRow() : base() { PrivateInitialize(); } #endregion //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods ////// void IAddChild.AddChild(object value) { if (value == null) { throw new ArgumentNullException("value"); } TableCell cell = value as TableCell; if (cell != null) { Cells.Add(cell); return; } throw (new ArgumentException(SR.Get(SRID.UnexpectedParameterType, value.GetType(), typeof(TableCell)), "value")); } ////// /// void IAddChild.AddText(string text) { XamlSerializerUtil.ThrowIfNonWhiteSpaceInAddText(text, this); } ////// /// Called when tablerow gets new parent /// /// /// New parent of cell /// internal override void OnNewParent(DependencyObject newParent) { DependencyObject oldParent = this.Parent; if(newParent != null && !(newParent is TableRowGroup)) { throw new InvalidOperationException(SR.Get(SRID.TableInvalidParentNodeType, newParent.GetType().ToString())); } if(oldParent != null) { ((TableRowGroup)oldParent).Rows.InternalRemove(this); } base.OnNewParent(newParent); if (newParent != null) { ((TableRowGroup)newParent).Rows.InternalAdd(this); } } #endregion Public Methods //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods #endregion Protected Methods //----------------------------------------------------- // // Internal Methods // //------------------------------------------------------ #region Internal Methods ////// Callback used to notify the Row about entering model tree. /// internal void OnEnterParentTree() { if(Table != null) { Table.OnStructureChanged(); } } ////// Callback used to notify the RowGroup about exitting model tree. /// internal void OnExitParentTree() { } ////// Callback used to notify the Row about exitting model tree. /// internal void OnAfterExitParentTree(TableRowGroup rowGroup) { if(rowGroup.Table != null) { Table.OnStructureChanged(); } } ////// ValidateStructure /// internal void ValidateStructure(RowSpanVector rowSpanVector) { Debug.Assert(rowSpanVector != null); SetFlags(!rowSpanVector.Empty(), Flags.HasForeignCells); SetFlags(false, Flags.HasRealCells); _formatCellCount = 0; _columnCount = 0; int firstAvailableIndex; int firstOccupiedIndex; rowSpanVector.GetFirstAvailableRange(out firstAvailableIndex, out firstOccupiedIndex); for (int i = 0; i < _cells.Count; ++i) { TableCell cell = _cells[i]; // Get cloumn span and row span. Row span is limited to the number of rows in the row group. // Since we do not know the number of columns in the table at this point, column span is limited only // by internal constants int columnSpan = cell.ColumnSpan; int rowSpan = cell.RowSpan; while (firstAvailableIndex + columnSpan > firstOccupiedIndex) { rowSpanVector.GetNextAvailableRange(out firstAvailableIndex, out firstOccupiedIndex); } Debug.Assert(i <= firstAvailableIndex); cell.ValidateStructure(firstAvailableIndex); if (rowSpan > 1) { rowSpanVector.Register(cell); } else { _formatCellCount++; } firstAvailableIndex += columnSpan; } _columnCount = firstAvailableIndex; bool isLastRowOfAnySpan = false; rowSpanVector.GetSpanCells(out _spannedCells, out isLastRowOfAnySpan); Debug.Assert(_spannedCells != null); if((_formatCellCount > 0) || isLastRowOfAnySpan == true) { SetFlags(true, Flags.HasRealCells); } _formatCellCount += _spannedCells.Length; Debug.Assert(_cells.Count <= _formatCellCount); } #endregion Internal Methods //----------------------------------------------------- // // Internal Properties // //----------------------------------------------------- #region Internal Properties ////// RowGroup owner accessor /// internal TableRowGroup RowGroup { get { return (Parent as TableRowGroup); } } ////// Table owner accessor /// internal Table Table { get { return (RowGroup != null ? RowGroup.Table : null); } } ////// Returns the row's cell collection /// [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public TableCellCollection Cells { get { return (_cells); } } ////// This method is used by TypeDescriptor to determine if this property should /// be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeCells() { return (Cells.Count > 0); } ////// Row's index in the parents collection. /// internal int Index { get { return (_parentIndex); } set { Debug.Assert(value >= -1 && _parentIndex != value); _parentIndex = value; } } ////// Stores temporary data for where to insert a new cell /// internal int InsertionIndex { get { return _cellInsertionIndex; } set { _cellInsertionIndex = value; } } ////// Returns span cells vector /// internal TableCell[] SpannedCells { get { return (_spannedCells); } } ////// Count of columns in the table /// internal int ColumnCount { get { return (_columnCount); } } ////// Returns "true" if there are row spanned cells belonging to previous rows /// internal bool HasForeignCells { get { return (CheckFlags(Flags.HasForeignCells)); } } ////// Returns "true" if there are row spanned cells belonging to previous rows /// internal bool HasRealCells { get { return (CheckFlags(Flags.HasRealCells)); } } ////// Count of columns in the table /// internal int FormatCellCount { get { return (_formatCellCount); } } ////// Marks this element's left edge as visible to IMEs. /// This means element boundaries will act as word breaks. /// internal override bool IsIMEStructuralElement { get { return true; } } #endregion Internal Properties //----------------------------------------------------- // // Private Methods // //------------------------------------------------------ #region Private Methods ////// Private ctor time initialization. /// private void PrivateInitialize() { _cells = new TableCellCollection(this); _parentIndex = -1; _cellInsertionIndex = -1; } ////// SetFlags is used to set or unset one or multiple flags on the row. /// private void SetFlags(bool value, Flags flags) { _flags = value ? (_flags | flags) : (_flags & (~flags)); } ////// CheckFlags returns true if all flags in the bitmask flags are set. /// private bool CheckFlags(Flags flags) { return ((_flags & flags) == flags); } #endregion Private Methods //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private TableCellCollection _cells; // collection of cells belonging to the row private TableCell[] _spannedCells; // row spanned cell storage private int _parentIndex; // row's index in parent's children collection private int _cellInsertionIndex; // Insertion index a cell private int _columnCount; private Flags _flags; // flags reflecting various aspects of row's state private int _formatCellCount; // count of the cell to be formatted in this row #endregion Private Fields //------------------------------------------------------ // // Private Structures / Classes // //----------------------------------------------------- #region Private Structures Classes [System.Flags] private enum Flags { // // state flags // HasForeignCells = 0x00000010, // there are hanging cells from the previous rows HasRealCells = 0x00000020, // real cells in row (not just spanning) (Only known by validation, not format) } #endregion Private Structures Classes } } // 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
- Types.cs
- SqlServer2KCompatibilityAnnotation.cs
- CheckBoxBaseAdapter.cs
- CompareValidator.cs
- ColorBuilder.cs
- ApplicationSecurityInfo.cs
- ValueSerializer.cs
- Base64Encoder.cs
- ComMethodElement.cs
- TextCharacters.cs
- Hashtable.cs
- BindingMemberInfo.cs
- RuntimeCompatibilityAttribute.cs
- HandlerBase.cs
- Html32TextWriter.cs
- ApplicationId.cs
- UrlAuthFailedErrorFormatter.cs
- HttpPostServerProtocol.cs
- ObjectDataSource.cs
- RemoteWebConfigurationHostServer.cs
- _BasicClient.cs
- InvokeGenerator.cs
- FlowDocumentPageViewerAutomationPeer.cs
- TextMarkerSource.cs
- GuidelineCollection.cs
- PropertyGridView.cs
- newinstructionaction.cs
- ListViewInsertionMark.cs
- Label.cs
- XmlSchemaSubstitutionGroup.cs
- ThemeableAttribute.cs
- DesignerView.xaml.cs
- WorkflowControlEndpoint.cs
- DbQueryCommandTree.cs
- XmlSchemaProviderAttribute.cs
- CrossSiteScriptingValidation.cs
- PartitionResolver.cs
- FontStyle.cs
- Span.cs
- InnerItemCollectionView.cs
- SQLDouble.cs
- VectorCollection.cs
- TransformGroup.cs
- AuthenticationException.cs
- MimeTypeMapper.cs
- KerberosRequestorSecurityToken.cs
- ExceptionUtil.cs
- BadImageFormatException.cs
- ExecutionScope.cs
- RecognizedPhrase.cs
- RadioButtonAutomationPeer.cs
- XmlDictionaryWriter.cs
- DtrList.cs
- XamlSerializerUtil.cs
- PropertyPushdownHelper.cs
- DoubleLinkList.cs
- VersionConverter.cs
- ResourcesBuildProvider.cs
- PageVisual.cs
- XmlElementAttributes.cs
- EventProxy.cs
- DataGridViewBindingCompleteEventArgs.cs
- WCFModelStrings.Designer.cs
- TraceEventCache.cs
- AttributeCollection.cs
- ZoneLinkButton.cs
- Main.cs
- DataBindingHandlerAttribute.cs
- WindowAutomationPeer.cs
- ObjectDataSourceSelectingEventArgs.cs
- DataGridViewRowCancelEventArgs.cs
- PingReply.cs
- URIFormatException.cs
- HwndSource.cs
- KeyedHashAlgorithm.cs
- TimerEventSubscriptionCollection.cs
- ToolStripSystemRenderer.cs
- DataGridViewComboBoxColumn.cs
- NullEntityWrapper.cs
- SchemaSetCompiler.cs
- Process.cs
- FontStyle.cs
- ClientData.cs
- SystemIcmpV6Statistics.cs
- CodeTypeMember.cs
- FontInfo.cs
- XsltArgumentList.cs
- DrawingGroup.cs
- FormViewModeEventArgs.cs
- Win32.cs
- TraceLog.cs
- LocatorPart.cs
- BrowserCapabilitiesCompiler.cs
- PasswordTextContainer.cs
- TokenFactoryBase.cs
- DataMemberFieldEditor.cs
- CultureMapper.cs
- ToolBarButton.cs
- ReliableReplySessionChannel.cs
- ElementNotEnabledException.cs