Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Documents / FixedSOMTable.cs / 1 / FixedSOMTable.cs
/*++
File: FixedSOMTable.cs
Copyright (C) 2005 Microsoft Corporation. All rights reserved.
Description:
This class reprsents a table on the page
History:
05/17/2005: eleese - Created
--*/
namespace System.Windows.Documents
{
using System.Windows.Shapes;
using System.Windows.Media;
using System.Diagnostics;
using System.Windows;
using System.Globalization;
internal sealed class FixedSOMTable : FixedSOMPageElement
{
//--------------------------------------------------------------------
//
// Constructors
//
//---------------------------------------------------------------------
#region Constructors
public FixedSOMTable(FixedSOMPage page) : base(page)
{
_numCols = 0;
}
#endregion Constructors
//-------------------------------------------------------------------
//
// Public Methods
//
//---------------------------------------------------------------------
#region Public Methods
#if DEBUG
public override void Render(DrawingContext dc, string label, DrawDebugVisual debugVisual)
{
Pen pen = new Pen(Brushes.Green, 5);
Rect rect = _boundingRect;
dc.DrawRectangle(null, pen , rect);
CultureInfo EnglishCulture = CultureInfo.GetCultureInfoByIetfLanguageTag("en-US");
FormattedText ft = new FormattedText(label,
EnglishCulture,
FlowDirection.LeftToRight,
new Typeface("Courier New"),
20,
Brushes.Blue);
Point labelLocation = new Point(rect.Left-25, (rect.Bottom + rect.Top)/2 - 10);
// dc.DrawText(ft, labelLocation);
for (int i = 0; i < _semanticBoxes.Count; i++)
{
_semanticBoxes[i].Render(dc, label + " " + i.ToString(),debugVisual);
}
}
#endif
public void AddRow(FixedSOMTableRow row)
{
base.Add(row);
int colCount = row.SemanticBoxes.Count;
if (colCount > _numCols)
{
_numCols = colCount;
}
}
public bool AddContainer(FixedSOMContainer container)
{
Rect bounds = container.BoundingRect;
//Allow couple pixels margin
double verticalOverlap = bounds.Height * 0.2;
double horizontalOverlap = bounds.Width * 0.2;
bounds.Inflate(-horizontalOverlap,-verticalOverlap);
if (this.BoundingRect.Contains(bounds))
{
foreach (FixedSOMTableRow row in this.SemanticBoxes)
{
if (row.BoundingRect.Contains(bounds))
{
foreach (FixedSOMTableCell cell in row.SemanticBoxes)
{
if (cell.BoundingRect.Contains(bounds))
{
cell.AddContainer(container);
FixedSOMFixedBlock block = container as FixedSOMFixedBlock;
if (block != null)
{
if (block.IsRTL)
{
_RTLCount++;
}
else
{
_LTRCount++;
}
}
return true;
}
}
}
}
}
return false;
}
public override void SetRTFProperties(FixedElement element)
{
if (element.Type == typeof(Table))
{
element.SetValue(Table.CellSpacingProperty, 0.0);
}
}
#endregion Public Methods
#region Public Properties
public override bool IsRTL
{
get
{
return _RTLCount > _LTRCount;
}
}
#endregion Public Properties
#region Internal Properties
internal override FixedElement.ElementType[] ElementTypes
{
get
{
return new FixedElement.ElementType[2] { FixedElement.ElementType.Table, FixedElement.ElementType.TableRowGroup };
}
}
internal bool IsEmpty
{
get
{
foreach (FixedSOMTableRow row in this.SemanticBoxes)
{
if (!row.IsEmpty)
{
return false;
}
}
return true;
}
}
internal bool IsSingleCelled
{
get
{
if (this.SemanticBoxes.Count == 1)
{
FixedSOMTableRow row = this.SemanticBoxes[0] as FixedSOMTableRow;
Debug.Assert(row != null);
return (row.SemanticBoxes.Count == 1);
}
return false;
}
}
#endregion Internal Properties
#region Internal methods
internal void DeleteEmptyRows()
{
for (int i=0; i nextCol)
{
deleteCol = false;
}
}
}
if (deleteCol)
{
for (r = 0; r < nRows; r++)
{
FixedSOMTableRow row = (FixedSOMTableRow)(this.SemanticBoxes[r]);
row.SemanticBoxes.RemoveAt(indexInRow[r]);
}
if (nextCol == double.MaxValue)
{
break;
}
else
{
continue;
}
}
// are we done?
if (nextCol == double.MaxValue)
{
break;
}
// increment ColumnSpans, indexInRow
for (r = 0; r < nRows; r++)
{
FixedSOMTableRow row = (FixedSOMTableRow)(this.SemanticBoxes[r]);
int idx = indexInRow[r];
if (idx + 1 < row.SemanticBoxes.Count && row.SemanticBoxes[idx + 1].BoundingRect.Left == nextCol)
{
indexInRow[r] = idx + 1;
}
else
{
((FixedSOMTableCell)row.SemanticBoxes[idx]).ColumnSpan++;
}
}
}
}
#endregion Internal methods
//--------------------------------------------------------------------
//
// Private Fields
//
//---------------------------------------------------------------------
#region Private Fields
const double _minColumnWidth = 5; // empty columns narrower than this will be deleted
const double _minRowHeight = 10; //empty rows smaller than this will be deleted
private int _RTLCount;
private int _LTRCount;
int _numCols;
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
/*++
File: FixedSOMTable.cs
Copyright (C) 2005 Microsoft Corporation. All rights reserved.
Description:
This class reprsents a table on the page
History:
05/17/2005: eleese - Created
--*/
namespace System.Windows.Documents
{
using System.Windows.Shapes;
using System.Windows.Media;
using System.Diagnostics;
using System.Windows;
using System.Globalization;
internal sealed class FixedSOMTable : FixedSOMPageElement
{
//--------------------------------------------------------------------
//
// Constructors
//
//---------------------------------------------------------------------
#region Constructors
public FixedSOMTable(FixedSOMPage page) : base(page)
{
_numCols = 0;
}
#endregion Constructors
//-------------------------------------------------------------------
//
// Public Methods
//
//---------------------------------------------------------------------
#region Public Methods
#if DEBUG
public override void Render(DrawingContext dc, string label, DrawDebugVisual debugVisual)
{
Pen pen = new Pen(Brushes.Green, 5);
Rect rect = _boundingRect;
dc.DrawRectangle(null, pen , rect);
CultureInfo EnglishCulture = CultureInfo.GetCultureInfoByIetfLanguageTag("en-US");
FormattedText ft = new FormattedText(label,
EnglishCulture,
FlowDirection.LeftToRight,
new Typeface("Courier New"),
20,
Brushes.Blue);
Point labelLocation = new Point(rect.Left-25, (rect.Bottom + rect.Top)/2 - 10);
// dc.DrawText(ft, labelLocation);
for (int i = 0; i < _semanticBoxes.Count; i++)
{
_semanticBoxes[i].Render(dc, label + " " + i.ToString(),debugVisual);
}
}
#endif
public void AddRow(FixedSOMTableRow row)
{
base.Add(row);
int colCount = row.SemanticBoxes.Count;
if (colCount > _numCols)
{
_numCols = colCount;
}
}
public bool AddContainer(FixedSOMContainer container)
{
Rect bounds = container.BoundingRect;
//Allow couple pixels margin
double verticalOverlap = bounds.Height * 0.2;
double horizontalOverlap = bounds.Width * 0.2;
bounds.Inflate(-horizontalOverlap,-verticalOverlap);
if (this.BoundingRect.Contains(bounds))
{
foreach (FixedSOMTableRow row in this.SemanticBoxes)
{
if (row.BoundingRect.Contains(bounds))
{
foreach (FixedSOMTableCell cell in row.SemanticBoxes)
{
if (cell.BoundingRect.Contains(bounds))
{
cell.AddContainer(container);
FixedSOMFixedBlock block = container as FixedSOMFixedBlock;
if (block != null)
{
if (block.IsRTL)
{
_RTLCount++;
}
else
{
_LTRCount++;
}
}
return true;
}
}
}
}
}
return false;
}
public override void SetRTFProperties(FixedElement element)
{
if (element.Type == typeof(Table))
{
element.SetValue(Table.CellSpacingProperty, 0.0);
}
}
#endregion Public Methods
#region Public Properties
public override bool IsRTL
{
get
{
return _RTLCount > _LTRCount;
}
}
#endregion Public Properties
#region Internal Properties
internal override FixedElement.ElementType[] ElementTypes
{
get
{
return new FixedElement.ElementType[2] { FixedElement.ElementType.Table, FixedElement.ElementType.TableRowGroup };
}
}
internal bool IsEmpty
{
get
{
foreach (FixedSOMTableRow row in this.SemanticBoxes)
{
if (!row.IsEmpty)
{
return false;
}
}
return true;
}
}
internal bool IsSingleCelled
{
get
{
if (this.SemanticBoxes.Count == 1)
{
FixedSOMTableRow row = this.SemanticBoxes[0] as FixedSOMTableRow;
Debug.Assert(row != null);
return (row.SemanticBoxes.Count == 1);
}
return false;
}
}
#endregion Internal Properties
#region Internal methods
internal void DeleteEmptyRows()
{
for (int i=0; i nextCol)
{
deleteCol = false;
}
}
}
if (deleteCol)
{
for (r = 0; r < nRows; r++)
{
FixedSOMTableRow row = (FixedSOMTableRow)(this.SemanticBoxes[r]);
row.SemanticBoxes.RemoveAt(indexInRow[r]);
}
if (nextCol == double.MaxValue)
{
break;
}
else
{
continue;
}
}
// are we done?
if (nextCol == double.MaxValue)
{
break;
}
// increment ColumnSpans, indexInRow
for (r = 0; r < nRows; r++)
{
FixedSOMTableRow row = (FixedSOMTableRow)(this.SemanticBoxes[r]);
int idx = indexInRow[r];
if (idx + 1 < row.SemanticBoxes.Count && row.SemanticBoxes[idx + 1].BoundingRect.Left == nextCol)
{
indexInRow[r] = idx + 1;
}
else
{
((FixedSOMTableCell)row.SemanticBoxes[idx]).ColumnSpan++;
}
}
}
}
#endregion Internal methods
//--------------------------------------------------------------------
//
// Private Fields
//
//---------------------------------------------------------------------
#region Private Fields
const double _minColumnWidth = 5; // empty columns narrower than this will be deleted
const double _minRowHeight = 10; //empty rows smaller than this will be deleted
private int _RTLCount;
private int _LTRCount;
int _numCols;
#endregion Private Fields
}
}
// 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
- SecurityContext.cs
- XmlTextReaderImplHelpers.cs
- Soap.cs
- ProfilePropertySettings.cs
- ScrollBar.cs
- CodeActivityMetadata.cs
- SoapSchemaExporter.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- xml.cs
- OdbcParameterCollection.cs
- SafeArrayRankMismatchException.cs
- ItemDragEvent.cs
- ConfigurationValidatorBase.cs
- SqlProvider.cs
- PtsCache.cs
- PathFigureCollectionValueSerializer.cs
- NavigationPropertyEmitter.cs
- RouteParametersHelper.cs
- TimeEnumHelper.cs
- SimpleBitVector32.cs
- XmlDocumentSchema.cs
- SecurityPolicySection.cs
- HostedElements.cs
- TabControl.cs
- SchemaTableColumn.cs
- CorrelationKeyCalculator.cs
- DataSvcMapFile.cs
- Walker.cs
- DelayedRegex.cs
- DATA_BLOB.cs
- InternalCache.cs
- FileDataSourceCache.cs
- ToolStripItemImageRenderEventArgs.cs
- SqlException.cs
- CodeStatementCollection.cs
- Int32Storage.cs
- LinkLabelLinkClickedEvent.cs
- Int64Converter.cs
- DocumentOrderQuery.cs
- XamlValidatingReader.cs
- Sorting.cs
- RightsManagementEncryptedStream.cs
- DesignerPerfEventProvider.cs
- Simplifier.cs
- ObjectList.cs
- TimelineClockCollection.cs
- Span.cs
- AdornerHitTestResult.cs
- Geometry.cs
- ToolboxComponentsCreatingEventArgs.cs
- AppDomainUnloadedException.cs
- ActivityIdHeader.cs
- PreservationFileWriter.cs
- PassportPrincipal.cs
- DataTableReader.cs
- OperationInvokerTrace.cs
- DataGridCellItemAutomationPeer.cs
- DataListItem.cs
- BitmapEffectState.cs
- ConstNode.cs
- MulticastDelegate.cs
- ResourceDictionary.cs
- ByteAnimation.cs
- cookieexception.cs
- SpecialNameAttribute.cs
- TabRenderer.cs
- XmlSiteMapProvider.cs
- _SecureChannel.cs
- ForEachDesigner.xaml.cs
- ComponentDispatcherThread.cs
- RuleAction.cs
- NetWebProxyFinder.cs
- EntryIndex.cs
- XmlSchemaAll.cs
- WebPartConnectionCollection.cs
- ConfigurationPropertyAttribute.cs
- MachineKeyConverter.cs
- MimePart.cs
- NamedPipeConnectionPoolSettingsElement.cs
- FunctionMappingTranslator.cs
- SafeViewOfFileHandle.cs
- ComboBoxRenderer.cs
- TimeStampChecker.cs
- StandardTransformFactory.cs
- SourceLineInfo.cs
- EditingScopeUndoUnit.cs
- ScriptingAuthenticationServiceSection.cs
- WebPartConnectionCollection.cs
- PageThemeCodeDomTreeGenerator.cs
- Helper.cs
- ConnectionManagementSection.cs
- ValidationEventArgs.cs
- PerformanceCounterPermissionAttribute.cs
- HttpInputStream.cs
- AnimationStorage.cs
- BrowsableAttribute.cs
- ArraySortHelper.cs
- FrameworkContentElement.cs
- X509SecurityTokenParameters.cs
- SymbolType.cs