Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / TableCell.cs / 1305600 / TableCell.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Implementation of table cell // // See spec at http://avalon/layout/Tables/WPP%20TableOM.doc // // History: // 05/19/2003 : olego - Created // // Todo list: // 1) OnPropertyInvalidated is expensive and requires investigation: // a) Cell calls to base class implementation which fires back tree // change event - Cell.OnTextContainerChange. As a result Cell.Invalidate // format is called twice. // b) base.OnPropertyInvalidated *always* creates DTR for the whole cell. // Why even AffectsRender causes it? //--------------------------------------------------------------------------- using MS.Internal; using MS.Internal.PtsHost; using MS.Internal.PtsTable; using MS.Internal.Text; using MS.Utility; using System.Diagnostics; using System.Security; using System.Windows.Threading; using System.Collections; using System.Windows; using System.Windows.Automation.Peers; using System.Windows.Media; using System.Windows.Controls; using System.Windows.Markup; using System.ComponentModel; // TypeConverter using System.Collections.Generic; using MS.Internal.Documents; using System; using MS.Internal.PtsHost.UnsafeNativeMethods; namespace System.Windows.Documents { ////// Implementation of table cell /// [ContentProperty("Blocks")] public class TableCell : TextElement, IIndexedChild{ //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors /// /// Default constructor /// public TableCell() : base() { PrivateInitialize(); } ////// Default constructor /// public TableCell(Block blockItem) : base() { PrivateInitialize(); if (blockItem == null) { throw new ArgumentNullException("blockItem"); } this.Blocks.Add(blockItem); } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods ////// Called when tablecell gets new parent /// /// /// New parent of cell /// internal override void OnNewParent(DependencyObject newParent) { DependencyObject oldParent = this.Parent; TableRow newParentTR = newParent as TableRow; if((newParent != null) && (newParentTR == null)) { throw new InvalidOperationException(SR.Get(SRID.TableInvalidParentNodeType, newParent.GetType().ToString())); } if(oldParent != null) { ((TableRow)oldParent).Cells.InternalRemove(this); } base.OnNewParent(newParent); if ((newParentTR != null) && (newParentTR.Cells != null)) // keep PreSharp happy { newParentTR.Cells.InternalAdd(this); } } #endregion Public Methods //------------------------------------------------------ // // Public Properties // //------------------------------------------------------ #region Public Properties ////// Collection of Blocks contained in this Section. /// [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public BlockCollection Blocks { get { return new BlockCollection(this, /*isOwnerParent*/true); } } ////// Column span property. /// public int ColumnSpan { get { return (int) GetValue(ColumnSpanProperty); } set { SetValue(ColumnSpanProperty, value); } } ////// Row span property. /// public int RowSpan { get { return (int) GetValue(RowSpanProperty); } set { SetValue(RowSpanProperty, value); } } //------------------------------------------------------------------- // // Protected Methods // //---------------------------------------------------------------------- #region Protected Methods ////// Creates AutomationPeer ( protected override AutomationPeer OnCreateAutomationPeer() { return new TableCellAutomationPeer(this); } #endregion Protected Methods //..................................................................... // // Block Properties // //..................................................................... #region Block Properties ///) /// /// DependencyProperty for public static readonly DependencyProperty PaddingProperty = Block.PaddingProperty.AddOwner( typeof(TableCell), new FrameworkPropertyMetadata( new Thickness(), FrameworkPropertyMetadataOptions.AffectsMeasure)); ///property. /// /// The Padding property specifies the padding of the element. /// public Thickness Padding { get { return (Thickness)GetValue(PaddingProperty); } set { SetValue(PaddingProperty, value); } } ////// DependencyProperty for public static readonly DependencyProperty BorderThicknessProperty = Block.BorderThicknessProperty.AddOwner( typeof(TableCell), new FrameworkPropertyMetadata( new Thickness(), FrameworkPropertyMetadataOptions.AffectsMeasure)); ///property. /// /// The BorderThickness property specifies the border of the element. /// public Thickness BorderThickness { get { return (Thickness)GetValue(BorderThicknessProperty); } set { SetValue(BorderThicknessProperty, value); } } ////// DependencyProperty for public static readonly DependencyProperty BorderBrushProperty = Block.BorderBrushProperty.AddOwner( typeof(TableCell), new FrameworkPropertyMetadata( null, FrameworkPropertyMetadataOptions.AffectsRender)); ///property. /// /// The BorderBrush property specifies the brush of the border. /// public Brush BorderBrush { get { return (Brush)GetValue(BorderBrushProperty); } set { SetValue(BorderBrushProperty, value); } } ////// DependencyProperty for public static readonly DependencyProperty TextAlignmentProperty = Block.TextAlignmentProperty.AddOwner(typeof(TableCell)); ///property. /// /// /// public TextAlignment TextAlignment { get { return (TextAlignment)GetValue(TextAlignmentProperty); } set { SetValue(TextAlignmentProperty, value); } } ////// DependencyProperty for public static readonly DependencyProperty FlowDirectionProperty = Block.FlowDirectionProperty.AddOwner(typeof(TableCell)); ///property. /// /// The FlowDirection property specifies the flow direction of the element. /// public FlowDirection FlowDirection { get { return (FlowDirection)GetValue(FlowDirectionProperty); } set { SetValue(FlowDirectionProperty, value); } } ////// DependencyProperty for public static readonly DependencyProperty LineHeightProperty = Block.LineHeightProperty.AddOwner(typeof(TableCell)); ///property. /// /// The LineHeight property specifies the height of each generated line box. /// [TypeConverter(typeof(LengthConverter))] public double LineHeight { get { return (double)GetValue(LineHeightProperty); } set { SetValue(LineHeightProperty, value); } } ////// DependencyProperty for public static readonly DependencyProperty LineStackingStrategyProperty = Block.LineStackingStrategyProperty.AddOwner(typeof(TableCell)); ///property. /// /// The LineStackingStrategy property specifies how lines are placed /// public LineStackingStrategy LineStackingStrategy { get { return (LineStackingStrategy)GetValue(LineStackingStrategyProperty); } set { SetValue(LineStackingStrategyProperty, value); } } #endregion Block Properties #endregion Public Properties //----------------------------------------------------- // // Internal Methods // //----------------------------------------------------- #region Internal Methods #region IIndexedChild implementation void IIndexedChild.OnEnterParentTree() { this.OnEnterParentTree(); } void IIndexedChild .OnExitParentTree() { this.OnExitParentTree(); } void IIndexedChild .OnAfterExitParentTree(TableRow parent) { this.OnAfterExitParentTree(parent); } int IIndexedChild .Index { get { return this.Index; } set { this.Index = value; } } #endregion IIndexedChild implementation /// /// Callback used to notify the Cell 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 Cell after it has exitted model tree. (Structures are all updated) /// internal void OnAfterExitParentTree(TableRow row) { if(row.Table != null) { row.Table.OnStructureChanged(); } } ////// ValidateStructure -- caches column index /// internal void ValidateStructure(int columnIndex) { Invariant.Assert(columnIndex >= 0); _columnIndex = columnIndex; } #endregion Internal Methods //----------------------------------------------------- // // Internal Properties // //------------------------------------------------------ #region Internal Properties ////// Row owner accessor /// internal TableRow Row { get { return Parent as TableRow; } } ////// Table owner accessor /// internal Table Table { get { return Row != null ? Row.Table : null; } } ////// Cell's index in the parents collection. /// internal int Index { get { return (_parentIndex); } set { Debug.Assert(value >= -1 && _parentIndex != value); _parentIndex = value; } } ////// Returns cell's parenting row index. /// internal int RowIndex { get { return (Row.Index); } } ////// Returns cell's parenting row group index. /// internal int RowGroupIndex { get { return (Row.RowGroup.Index); } } ////// Returns or sets cell's parenting column index. /// ////// Called by the parent Row during (re)build of the StructuralCache. /// Change of column index causes Layout Dirtyness of the cell. /// internal int ColumnIndex { get { return (_columnIndex); } set { _columnIndex = value; } } ////// 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() { _parentIndex = -1; _columnIndex = -1; } #endregion Private Methods //------------------------------------------------------ // // Private Properties // //----------------------------------------------------- #region Private Properties #endregion Private Properties //------------------------------------------------------ // // Private Fields // //----------------------------------------------------- #region Private Fields private int _parentIndex; // cell's index in parent's children collection private int _columnIndex; // Column index for cell. #endregion Private Fields //----------------------------------------------------- // // Properties // //----------------------------------------------------- #region Properties ////// Column span property. /// public static readonly DependencyProperty ColumnSpanProperty = DependencyProperty.Register( "ColumnSpan", typeof(int), typeof(TableCell), new FrameworkPropertyMetadata( 1, FrameworkPropertyMetadataOptions.AffectsMeasure, new PropertyChangedCallback(OnColumnSpanChanged)), new ValidateValueCallback(IsValidColumnSpan)); ////// Row span property. /// public static readonly DependencyProperty RowSpanProperty = DependencyProperty.Register( "RowSpan", typeof(int), typeof(TableCell), new FrameworkPropertyMetadata( 1, FrameworkPropertyMetadataOptions.AffectsMeasure, new PropertyChangedCallback(OnRowSpanChanged)), new ValidateValueCallback(IsValidRowSpan)); #endregion Properties //------------------------------------------------------ // // Property Invalidation // //----------------------------------------------------- #region Property Invalidation ////// private static bool IsValidRowSpan(object value) { // Maximum row span is limited to 1000000. We do not have any limits from PTS or other formatting restrictions for this value. int span = (int)value; return (span >= 1 && span <= 1000000); } ////// /// private static bool IsValidColumnSpan(object value) { int span = (int)value; const int maxSpan = PTS.Restrictions.tscTableColumnsRestriction; return (span >= 1 && span <= maxSpan); } ////// /// private static void OnColumnSpanChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TableCell cell = (TableCell) d; if(cell.Table != null) { cell.Table.OnStructureChanged(); } // Update AutomaitonPeer. TableCellAutomationPeer peer = ContentElementAutomationPeer.FromElement(cell) as TableCellAutomationPeer; if (peer != null) { peer.OnColumnSpanChanged((int)e.OldValue, (int)e.NewValue); } } ////// /// private static void OnRowSpanChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TableCell cell = (TableCell) d; if(cell.Table != null) { cell.Table.OnStructureChanged(); } // Update AutomaitonPeer. TableCellAutomationPeer peer = ContentElementAutomationPeer.FromElement(cell) as TableCellAutomationPeer; if (peer != null) { peer.OnRowSpanChanged((int)e.OldValue, (int)e.NewValue); } } #endregion Property Invalidation } } // 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
- TaiwanLunisolarCalendar.cs
- WebConfigurationFileMap.cs
- Menu.cs
- DataListItemEventArgs.cs
- ProxyWebPartConnectionCollection.cs
- ResXResourceSet.cs
- IPEndPointCollection.cs
- TcpConnectionPoolSettingsElement.cs
- EndpointIdentity.cs
- SamlAuthorityBinding.cs
- Events.cs
- ObjectConverter.cs
- VisualBasicSettings.cs
- QueryRewriter.cs
- HtmlValidationSummaryAdapter.cs
- CacheVirtualItemsEvent.cs
- DashStyles.cs
- XmlDataDocument.cs
- Size.cs
- COMException.cs
- AsymmetricSignatureFormatter.cs
- Renderer.cs
- DataPager.cs
- ECDiffieHellman.cs
- ScrollPattern.cs
- namescope.cs
- AnonymousIdentificationModule.cs
- BackgroundWorker.cs
- HtmlObjectListAdapter.cs
- CodeAttributeDeclaration.cs
- RangeBase.cs
- TabControl.cs
- RowUpdatingEventArgs.cs
- ConstrainedDataObject.cs
- PasswordDeriveBytes.cs
- DataSourceView.cs
- RemotingException.cs
- SecurityContext.cs
- UrlRoutingModule.cs
- Tokenizer.cs
- InputGestureCollection.cs
- Point3DCollection.cs
- RelatedCurrencyManager.cs
- CellParagraph.cs
- Reference.cs
- Process.cs
- PeerChannelListener.cs
- DefaultPrintController.cs
- _NestedMultipleAsyncResult.cs
- ObjectContext.cs
- ExclusiveTcpListener.cs
- ConnectorMovedEventArgs.cs
- WindowsFormsSynchronizationContext.cs
- LayoutDump.cs
- ClientClassGenerator.cs
- Font.cs
- CommonObjectSecurity.cs
- CacheAxisQuery.cs
- ObjectConverter.cs
- SafeLibraryHandle.cs
- PeerToPeerException.cs
- PageTheme.cs
- EnumUnknown.cs
- StrongTypingException.cs
- localization.cs
- ResXFileRef.cs
- UndoEngine.cs
- wgx_sdk_version.cs
- ServerIdentity.cs
- TableRow.cs
- WindowsScrollBarBits.cs
- Function.cs
- PasswordPropertyTextAttribute.cs
- HttpModuleActionCollection.cs
- SerializerDescriptor.cs
- SecureConversationSecurityTokenParameters.cs
- ActivityExecutionFilter.cs
- BinaryNode.cs
- ACE.cs
- ExpressionBindings.cs
- RouteItem.cs
- DecoderBestFitFallback.cs
- LineGeometry.cs
- InvalidDataContractException.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- ConstructorNeedsTagAttribute.cs
- SafeSerializationManager.cs
- ObjectListCommand.cs
- CompiledQueryCacheEntry.cs
- ManipulationCompletedEventArgs.cs
- SplitterEvent.cs
- LockedBorderGlyph.cs
- DataViewSetting.cs
- MemoryMappedFile.cs
- SmtpTransport.cs
- LogEntryHeaderSerializer.cs
- WebPartTransformer.cs
- Subtree.cs
- DataBoundLiteralControl.cs
- RSAPKCS1KeyExchangeFormatter.cs