Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / MS / Internal / PtsHost / SectionVisual.cs / 1 / SectionVisual.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: SectionVisual.cs
//
// Description: Visual representing a section.
//
// History:
// 05/20/2003 : grzegorz - created.
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
using MS.Internal.Text;
using MS.Internal.PtsHost.UnsafeNativeMethods;
namespace MS.Internal.PtsHost
{
// ---------------------------------------------------------------------
// Visual representing a section.
// ---------------------------------------------------------------------
internal class SectionVisual : DrawingVisual
{
// ------------------------------------------------------------------
// Constructor.
// -----------------------------------------------------------------
internal SectionVisual()
{
}
// ------------------------------------------------------------------
// Set information about column rules that are necessary for rendering
// process. Draw column rules if necessary.
//
// arrayColumnDesc - column description including rectangle coordinates, etc
// columnVStart - vertical start coordinate of column rule
// columnHeight - height of column rule
// columnProperties - column properties.
// ------------------------------------------------------------------
internal void DrawColumnRules(ref PTS.FSTRACKDESCRIPTION[] arrayColumnDesc, double columnVStart, double columnHeight, ColumnPropertiesGroup columnProperties)
{
// Compute column rules data first.
Point[] rulePositions = null;
double ruleWidth = columnProperties.ColumnRuleWidth;
if (arrayColumnDesc.Length > 1)
{
if (ruleWidth > 0)
{
int gapWidth = (arrayColumnDesc[1].fsrc.u - (arrayColumnDesc[0].fsrc.u + arrayColumnDesc[0].fsrc.du)) / 2;
rulePositions = new Point[(arrayColumnDesc.Length - 1)*2];
for (int index = 1; index < arrayColumnDesc.Length; index++)
{
double u = TextDpi.FromTextDpi(arrayColumnDesc[index].fsrc.u - gapWidth);
double v = columnVStart;
double dv = columnHeight;
rulePositions[(index-1)*2].X = u;
rulePositions[(index-1)*2].Y = v;
rulePositions[(index-1)*2+1].X = u;
rulePositions[(index-1)*2+1].Y = v + dv;
}
}
}
// Check if update of the visual render data is needed.
bool needsUpdate = _ruleWidth != ruleWidth;
if (!needsUpdate && _rulePositions != rulePositions)
{
int prevSize = _rulePositions == null ? 0 : _rulePositions.Length;
int newSize = rulePositions == null ? 0 : rulePositions.Length;
if (prevSize == newSize)
{
for (int index = 0; index < rulePositions.Length; index++)
{
if (!DoubleUtil.AreClose(rulePositions[index].X, _rulePositions[index].X) ||
!DoubleUtil.AreClose(rulePositions[index].Y, _rulePositions[index].Y))
{
needsUpdate = true;
break;
}
}
}
else
{
needsUpdate = true;
}
}
// Draw column rules if necessary
if (needsUpdate)
{
_ruleWidth = ruleWidth;
_rulePositions = rulePositions;
// Open DrawingContext and draw background.
// If background is not set, Open will clear the render data, but it
// will preserve visual children.
using (DrawingContext dc = RenderOpen())
{
if (rulePositions != null)
{
// We do not want to cause the user's Brush to become frozen when we
// freeze pen below, therefore we make our own copy of the Brush if
// it is not already frozen.
Brush columnRuleBrush = (Brush)FreezableOperations.GetAsFrozenIfPossible(columnProperties.ColumnRuleBrush);
Pen pen = new Pen(columnRuleBrush, ruleWidth);
// Freeze the pen if possible. Doing this avoids the overhead of
// maintaining changed handlers.
if (pen.CanFreeze) { pen.Freeze(); }
for (int index = 0; index < rulePositions.Length; index += 2)
{
dc.DrawLine(pen, rulePositions[index], rulePositions[index + 1]);
}
}
}
}
}
// -----------------------------------------------------------------
// Column rules positions
// ------------------------------------------------------------------
private Point[] _rulePositions;
// -----------------------------------------------------------------
// Pen for column rule.
// -----------------------------------------------------------------
private double _ruleWidth;
}
}
// 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: SectionVisual.cs
//
// Description: Visual representing a section.
//
// History:
// 05/20/2003 : grzegorz - created.
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
using MS.Internal.Text;
using MS.Internal.PtsHost.UnsafeNativeMethods;
namespace MS.Internal.PtsHost
{
// ---------------------------------------------------------------------
// Visual representing a section.
// ---------------------------------------------------------------------
internal class SectionVisual : DrawingVisual
{
// ------------------------------------------------------------------
// Constructor.
// -----------------------------------------------------------------
internal SectionVisual()
{
}
// ------------------------------------------------------------------
// Set information about column rules that are necessary for rendering
// process. Draw column rules if necessary.
//
// arrayColumnDesc - column description including rectangle coordinates, etc
// columnVStart - vertical start coordinate of column rule
// columnHeight - height of column rule
// columnProperties - column properties.
// ------------------------------------------------------------------
internal void DrawColumnRules(ref PTS.FSTRACKDESCRIPTION[] arrayColumnDesc, double columnVStart, double columnHeight, ColumnPropertiesGroup columnProperties)
{
// Compute column rules data first.
Point[] rulePositions = null;
double ruleWidth = columnProperties.ColumnRuleWidth;
if (arrayColumnDesc.Length > 1)
{
if (ruleWidth > 0)
{
int gapWidth = (arrayColumnDesc[1].fsrc.u - (arrayColumnDesc[0].fsrc.u + arrayColumnDesc[0].fsrc.du)) / 2;
rulePositions = new Point[(arrayColumnDesc.Length - 1)*2];
for (int index = 1; index < arrayColumnDesc.Length; index++)
{
double u = TextDpi.FromTextDpi(arrayColumnDesc[index].fsrc.u - gapWidth);
double v = columnVStart;
double dv = columnHeight;
rulePositions[(index-1)*2].X = u;
rulePositions[(index-1)*2].Y = v;
rulePositions[(index-1)*2+1].X = u;
rulePositions[(index-1)*2+1].Y = v + dv;
}
}
}
// Check if update of the visual render data is needed.
bool needsUpdate = _ruleWidth != ruleWidth;
if (!needsUpdate && _rulePositions != rulePositions)
{
int prevSize = _rulePositions == null ? 0 : _rulePositions.Length;
int newSize = rulePositions == null ? 0 : rulePositions.Length;
if (prevSize == newSize)
{
for (int index = 0; index < rulePositions.Length; index++)
{
if (!DoubleUtil.AreClose(rulePositions[index].X, _rulePositions[index].X) ||
!DoubleUtil.AreClose(rulePositions[index].Y, _rulePositions[index].Y))
{
needsUpdate = true;
break;
}
}
}
else
{
needsUpdate = true;
}
}
// Draw column rules if necessary
if (needsUpdate)
{
_ruleWidth = ruleWidth;
_rulePositions = rulePositions;
// Open DrawingContext and draw background.
// If background is not set, Open will clear the render data, but it
// will preserve visual children.
using (DrawingContext dc = RenderOpen())
{
if (rulePositions != null)
{
// We do not want to cause the user's Brush to become frozen when we
// freeze pen below, therefore we make our own copy of the Brush if
// it is not already frozen.
Brush columnRuleBrush = (Brush)FreezableOperations.GetAsFrozenIfPossible(columnProperties.ColumnRuleBrush);
Pen pen = new Pen(columnRuleBrush, ruleWidth);
// Freeze the pen if possible. Doing this avoids the overhead of
// maintaining changed handlers.
if (pen.CanFreeze) { pen.Freeze(); }
for (int index = 0; index < rulePositions.Length; index += 2)
{
dc.DrawLine(pen, rulePositions[index], rulePositions[index + 1]);
}
}
}
}
}
// -----------------------------------------------------------------
// Column rules positions
// ------------------------------------------------------------------
private Point[] _rulePositions;
// -----------------------------------------------------------------
// Pen for column rule.
// -----------------------------------------------------------------
private double _ruleWidth;
}
}
// 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
- GroupDescription.cs
- TextSpan.cs
- HttpHandlerActionCollection.cs
- RNGCryptoServiceProvider.cs
- ValidatingReaderNodeData.cs
- BooleanSwitch.cs
- CssClassPropertyAttribute.cs
- FlowDocumentPageViewerAutomationPeer.cs
- RtfToXamlReader.cs
- DataGridTextColumn.cs
- GCHandleCookieTable.cs
- IgnoreDataMemberAttribute.cs
- SystemColorTracker.cs
- ConfigXmlWhitespace.cs
- UpdateExpressionVisitor.cs
- QilTypeChecker.cs
- SQLMoney.cs
- DrawingContextWalker.cs
- DrawingCollection.cs
- AppDomainGrammarProxy.cs
- TextServicesDisplayAttribute.cs
- ErrorsHelper.cs
- EmptyStringExpandableObjectConverter.cs
- EdgeProfileValidation.cs
- DataGridViewColumnHeaderCell.cs
- TextAdaptor.cs
- EntityPropertyMappingAttribute.cs
- LineServicesRun.cs
- DataSourceCache.cs
- DataStreamFromComStream.cs
- ImageSourceConverter.cs
- CodeBlockBuilder.cs
- BitmapFrameEncode.cs
- CalendarModeChangedEventArgs.cs
- BinaryCommonClasses.cs
- HtmlInputSubmit.cs
- PrintPageEvent.cs
- OperandQuery.cs
- IRCollection.cs
- ChooseAction.cs
- DataSourceXmlSerializer.cs
- ChannelBase.cs
- Wildcard.cs
- PhysicalOps.cs
- VisualBasic.cs
- QuaternionRotation3D.cs
- DetailsViewUpdateEventArgs.cs
- TableColumnCollection.cs
- XMLSchema.cs
- Schema.cs
- HostingEnvironmentWrapper.cs
- SchemaNotation.cs
- WindowsFormsHostAutomationPeer.cs
- BypassElementCollection.cs
- WmpBitmapDecoder.cs
- SecurityElement.cs
- QuerySubExprEliminator.cs
- ArithmeticException.cs
- ProxyWebPartConnectionCollection.cs
- WaitHandle.cs
- FlowDocumentPage.cs
- MbpInfo.cs
- SqlBulkCopyColumnMapping.cs
- StrongNameMembershipCondition.cs
- DataPointer.cs
- Configuration.cs
- CssStyleCollection.cs
- Visitors.cs
- DataPagerFieldItem.cs
- CreateParams.cs
- Matrix3DStack.cs
- ControlPaint.cs
- ToRequest.cs
- AmbientProperties.cs
- LinkClickEvent.cs
- Vector3D.cs
- NotifyIcon.cs
- ParamArrayAttribute.cs
- DataGridViewSelectedCellCollection.cs
- XsltContext.cs
- DbModificationCommandTree.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- TypeBinaryExpression.cs
- FunctionNode.cs
- EventLogWatcher.cs
- GroupDescription.cs
- TraceListener.cs
- TcpStreams.cs
- baseshape.cs
- SerializerProvider.cs
- ForwardPositionQuery.cs
- EarlyBoundInfo.cs
- Int32EqualityComparer.cs
- shaper.cs
- SudsParser.cs
- WaitForChangedResult.cs
- CounterCreationData.cs
- DBCommand.cs
- ProfileServiceManager.cs
- CapabilitiesUse.cs