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 / Figure.cs / 1 / Figure.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// Description: Figure element.
//
//---------------------------------------------------------------------------
using System.ComponentModel; // TypeConverter
using System.Windows.Controls; // TextBlock
using MS.Internal;
using MS.Internal.PtsHost.UnsafeNativeMethods; // PTS restrictions
namespace System.Windows.Documents
{
///
/// Figure element.
///
public class Figure : AnchoredBlock
{
//-------------------------------------------------------------------
//
// Constructors
//
//-------------------------------------------------------------------
#region Constructors
///
/// Initialized the new instance of a Figure
///
public Figure() : this(null)
{
}
///
/// Initialized the new instance of a Figure specifying a Block added
/// to a Figure as its first child.
///
///
/// Block added as a first initial child of the Figure.
///
public Figure(Block childBlock) : this(childBlock, null)
{
}
///
/// Creates a new Figure instance.
///
///
/// Optional child of the new Figure, may be null.
///
///
/// Optional position at which to insert the new Figure. May
/// be null.
///
public Figure(Block childBlock, TextPointer insertionPosition) : base(childBlock, insertionPosition)
{
}
#endregion Constructors
//--------------------------------------------------------------------
//
// Public Properties
//
//-------------------------------------------------------------------
#region Public Properties
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty HorizontalAnchorProperty =
DependencyProperty.Register(
"HorizontalAnchor",
typeof(FigureHorizontalAnchor),
typeof(Figure),
new FrameworkPropertyMetadata(
FigureHorizontalAnchor.ColumnRight,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidHorizontalAnchor));
///
///
///
public FigureHorizontalAnchor HorizontalAnchor
{
get { return (FigureHorizontalAnchor)GetValue(HorizontalAnchorProperty); }
set { SetValue(HorizontalAnchorProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty VerticalAnchorProperty =
DependencyProperty.Register(
"VerticalAnchor",
typeof(FigureVerticalAnchor),
typeof(Figure),
new FrameworkPropertyMetadata(
FigureVerticalAnchor.ParagraphTop,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidVerticalAnchor));
///
///
///
public FigureVerticalAnchor VerticalAnchor
{
get { return (FigureVerticalAnchor)GetValue(VerticalAnchorProperty); }
set { SetValue(VerticalAnchorProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty HorizontalOffsetProperty =
DependencyProperty.Register(
"HorizontalOffset",
typeof(double),
typeof(Figure),
new FrameworkPropertyMetadata(
0.0,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidOffset));
///
///
///
[TypeConverter(typeof(LengthConverter))]
public double HorizontalOffset
{
get { return (double)GetValue(HorizontalOffsetProperty); }
set { SetValue(HorizontalOffsetProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty VerticalOffsetProperty =
DependencyProperty.Register(
"VerticalOffset",
typeof(double),
typeof(Figure),
new FrameworkPropertyMetadata(
0.0,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidOffset));
///
///
///
[TypeConverter(typeof(LengthConverter))]
public double VerticalOffset
{
get { return (double)GetValue(VerticalOffsetProperty); }
set { SetValue(VerticalOffsetProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty CanDelayPlacementProperty =
DependencyProperty.Register(
"CanDelayPlacement",
typeof(bool),
typeof(Figure),
new FrameworkPropertyMetadata(
true,
FrameworkPropertyMetadataOptions.AffectsParentMeasure));
///
///
///
public bool CanDelayPlacement
{
get { return (bool)GetValue(CanDelayPlacementProperty); }
set { SetValue(CanDelayPlacementProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty WrapDirectionProperty =
DependencyProperty.Register(
"WrapDirection",
typeof(WrapDirection),
typeof(Figure),
new FrameworkPropertyMetadata(
WrapDirection.Both,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidWrapDirection));
///
///
///
public WrapDirection WrapDirection
{
get { return (WrapDirection)GetValue(WrapDirectionProperty); }
set { SetValue(WrapDirectionProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty WidthProperty =
DependencyProperty.Register(
"Width",
typeof(FigureLength),
typeof(Figure),
new FrameworkPropertyMetadata(
new FigureLength(1.0, FigureUnitType.Auto),
FrameworkPropertyMetadataOptions.AffectsMeasure));
///
/// The Width property specifies the width of the element.
///
public FigureLength Width
{
get { return (FigureLength)GetValue(WidthProperty); }
set { SetValue(WidthProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty HeightProperty =
DependencyProperty.Register(
"Height",
typeof(FigureLength),
typeof(Figure),
new FrameworkPropertyMetadata(
new FigureLength(1.0, FigureUnitType.Auto),
FrameworkPropertyMetadataOptions.AffectsMeasure));
///
/// The Height property specifies the height of the element.
///
public FigureLength Height
{
get { return (FigureLength)GetValue(HeightProperty); }
set { SetValue(HeightProperty, value); }
}
#endregion Public Properties
//--------------------------------------------------------------------
//
// Private Methods
//
//--------------------------------------------------------------------
#region Private Methods
private static bool IsValidHorizontalAnchor(object o)
{
FigureHorizontalAnchor value = (FigureHorizontalAnchor)o;
return value == FigureHorizontalAnchor.ContentCenter
|| value == FigureHorizontalAnchor.ContentLeft
|| value == FigureHorizontalAnchor.ContentRight
|| value == FigureHorizontalAnchor.PageCenter
|| value == FigureHorizontalAnchor.PageLeft
|| value == FigureHorizontalAnchor.PageRight
|| value == FigureHorizontalAnchor.ColumnCenter
|| value == FigureHorizontalAnchor.ColumnLeft
|| value == FigureHorizontalAnchor.ColumnRight;
// || value == FigureHorizontalAnchor.CharacterCenter
// || value == FigureHorizontalAnchor.CharacterLeft
// || value == FigureHorizontalAnchor.CharacterRight;
}
private static bool IsValidVerticalAnchor(object o)
{
FigureVerticalAnchor value = (FigureVerticalAnchor)o;
return value == FigureVerticalAnchor.ContentBottom
|| value == FigureVerticalAnchor.ContentCenter
|| value == FigureVerticalAnchor.ContentTop
|| value == FigureVerticalAnchor.PageBottom
|| value == FigureVerticalAnchor.PageCenter
|| value == FigureVerticalAnchor.PageTop
|| value == FigureVerticalAnchor.ParagraphTop;
// || value == FigureVerticalAnchor.CharacterBottom
// || value == FigureVerticalAnchor.CharacterCenter
// || value == FigureVerticalAnchor.CharacterTop;
}
private static bool IsValidWrapDirection(object o)
{
WrapDirection value = (WrapDirection)o;
return value == WrapDirection.Both
|| value == WrapDirection.None
|| value == WrapDirection.Left
|| value == WrapDirection.Right;
}
private static bool IsValidOffset(object o)
{
double offset = (double)o;
double maxOffset = Math.Min(1000000, PTS.MaxPageSize);
double minOffset = -maxOffset;
if (Double.IsNaN(offset))
{
return false;
}
if (offset < minOffset || offset > maxOffset)
{
return false;
}
return true;
}
#endregion Private Methods
}
}
// 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: Figure element.
//
//---------------------------------------------------------------------------
using System.ComponentModel; // TypeConverter
using System.Windows.Controls; // TextBlock
using MS.Internal;
using MS.Internal.PtsHost.UnsafeNativeMethods; // PTS restrictions
namespace System.Windows.Documents
{
///
/// Figure element.
///
public class Figure : AnchoredBlock
{
//-------------------------------------------------------------------
//
// Constructors
//
//-------------------------------------------------------------------
#region Constructors
///
/// Initialized the new instance of a Figure
///
public Figure() : this(null)
{
}
///
/// Initialized the new instance of a Figure specifying a Block added
/// to a Figure as its first child.
///
///
/// Block added as a first initial child of the Figure.
///
public Figure(Block childBlock) : this(childBlock, null)
{
}
///
/// Creates a new Figure instance.
///
///
/// Optional child of the new Figure, may be null.
///
///
/// Optional position at which to insert the new Figure. May
/// be null.
///
public Figure(Block childBlock, TextPointer insertionPosition) : base(childBlock, insertionPosition)
{
}
#endregion Constructors
//--------------------------------------------------------------------
//
// Public Properties
//
//-------------------------------------------------------------------
#region Public Properties
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty HorizontalAnchorProperty =
DependencyProperty.Register(
"HorizontalAnchor",
typeof(FigureHorizontalAnchor),
typeof(Figure),
new FrameworkPropertyMetadata(
FigureHorizontalAnchor.ColumnRight,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidHorizontalAnchor));
///
///
///
public FigureHorizontalAnchor HorizontalAnchor
{
get { return (FigureHorizontalAnchor)GetValue(HorizontalAnchorProperty); }
set { SetValue(HorizontalAnchorProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty VerticalAnchorProperty =
DependencyProperty.Register(
"VerticalAnchor",
typeof(FigureVerticalAnchor),
typeof(Figure),
new FrameworkPropertyMetadata(
FigureVerticalAnchor.ParagraphTop,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidVerticalAnchor));
///
///
///
public FigureVerticalAnchor VerticalAnchor
{
get { return (FigureVerticalAnchor)GetValue(VerticalAnchorProperty); }
set { SetValue(VerticalAnchorProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty HorizontalOffsetProperty =
DependencyProperty.Register(
"HorizontalOffset",
typeof(double),
typeof(Figure),
new FrameworkPropertyMetadata(
0.0,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidOffset));
///
///
///
[TypeConverter(typeof(LengthConverter))]
public double HorizontalOffset
{
get { return (double)GetValue(HorizontalOffsetProperty); }
set { SetValue(HorizontalOffsetProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty VerticalOffsetProperty =
DependencyProperty.Register(
"VerticalOffset",
typeof(double),
typeof(Figure),
new FrameworkPropertyMetadata(
0.0,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidOffset));
///
///
///
[TypeConverter(typeof(LengthConverter))]
public double VerticalOffset
{
get { return (double)GetValue(VerticalOffsetProperty); }
set { SetValue(VerticalOffsetProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty CanDelayPlacementProperty =
DependencyProperty.Register(
"CanDelayPlacement",
typeof(bool),
typeof(Figure),
new FrameworkPropertyMetadata(
true,
FrameworkPropertyMetadataOptions.AffectsParentMeasure));
///
///
///
public bool CanDelayPlacement
{
get { return (bool)GetValue(CanDelayPlacementProperty); }
set { SetValue(CanDelayPlacementProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty WrapDirectionProperty =
DependencyProperty.Register(
"WrapDirection",
typeof(WrapDirection),
typeof(Figure),
new FrameworkPropertyMetadata(
WrapDirection.Both,
FrameworkPropertyMetadataOptions.AffectsParentMeasure),
new ValidateValueCallback(IsValidWrapDirection));
///
///
///
public WrapDirection WrapDirection
{
get { return (WrapDirection)GetValue(WrapDirectionProperty); }
set { SetValue(WrapDirectionProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty WidthProperty =
DependencyProperty.Register(
"Width",
typeof(FigureLength),
typeof(Figure),
new FrameworkPropertyMetadata(
new FigureLength(1.0, FigureUnitType.Auto),
FrameworkPropertyMetadataOptions.AffectsMeasure));
///
/// The Width property specifies the width of the element.
///
public FigureLength Width
{
get { return (FigureLength)GetValue(WidthProperty); }
set { SetValue(WidthProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty HeightProperty =
DependencyProperty.Register(
"Height",
typeof(FigureLength),
typeof(Figure),
new FrameworkPropertyMetadata(
new FigureLength(1.0, FigureUnitType.Auto),
FrameworkPropertyMetadataOptions.AffectsMeasure));
///
/// The Height property specifies the height of the element.
///
public FigureLength Height
{
get { return (FigureLength)GetValue(HeightProperty); }
set { SetValue(HeightProperty, value); }
}
#endregion Public Properties
//--------------------------------------------------------------------
//
// Private Methods
//
//--------------------------------------------------------------------
#region Private Methods
private static bool IsValidHorizontalAnchor(object o)
{
FigureHorizontalAnchor value = (FigureHorizontalAnchor)o;
return value == FigureHorizontalAnchor.ContentCenter
|| value == FigureHorizontalAnchor.ContentLeft
|| value == FigureHorizontalAnchor.ContentRight
|| value == FigureHorizontalAnchor.PageCenter
|| value == FigureHorizontalAnchor.PageLeft
|| value == FigureHorizontalAnchor.PageRight
|| value == FigureHorizontalAnchor.ColumnCenter
|| value == FigureHorizontalAnchor.ColumnLeft
|| value == FigureHorizontalAnchor.ColumnRight;
// || value == FigureHorizontalAnchor.CharacterCenter
// || value == FigureHorizontalAnchor.CharacterLeft
// || value == FigureHorizontalAnchor.CharacterRight;
}
private static bool IsValidVerticalAnchor(object o)
{
FigureVerticalAnchor value = (FigureVerticalAnchor)o;
return value == FigureVerticalAnchor.ContentBottom
|| value == FigureVerticalAnchor.ContentCenter
|| value == FigureVerticalAnchor.ContentTop
|| value == FigureVerticalAnchor.PageBottom
|| value == FigureVerticalAnchor.PageCenter
|| value == FigureVerticalAnchor.PageTop
|| value == FigureVerticalAnchor.ParagraphTop;
// || value == FigureVerticalAnchor.CharacterBottom
// || value == FigureVerticalAnchor.CharacterCenter
// || value == FigureVerticalAnchor.CharacterTop;
}
private static bool IsValidWrapDirection(object o)
{
WrapDirection value = (WrapDirection)o;
return value == WrapDirection.Both
|| value == WrapDirection.None
|| value == WrapDirection.Left
|| value == WrapDirection.Right;
}
private static bool IsValidOffset(object o)
{
double offset = (double)o;
double maxOffset = Math.Min(1000000, PTS.MaxPageSize);
double minOffset = -maxOffset;
if (Double.IsNaN(offset))
{
return false;
}
if (offset < minOffset || offset > maxOffset)
{
return false;
}
return true;
}
#endregion Private Methods
}
}
// 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
- Panel.cs
- SequenceFullException.cs
- EmptyEnumerator.cs
- PenCursorManager.cs
- SurrogateEncoder.cs
- MonikerUtility.cs
- ConnectionOrientedTransportManager.cs
- CompModSwitches.cs
- PersonalizationStateInfo.cs
- VScrollBar.cs
- InvalidComObjectException.cs
- CodePageEncoding.cs
- XmlSchemaObject.cs
- GradientStop.cs
- JournalEntryStack.cs
- PermissionToken.cs
- StandardCommands.cs
- PathSegment.cs
- milexports.cs
- PointCollection.cs
- ISCIIEncoding.cs
- Operator.cs
- DecimalConstantAttribute.cs
- StaticSiteMapProvider.cs
- HttpWebRequest.cs
- ViewPort3D.cs
- PointCollectionValueSerializer.cs
- SettingsAttributeDictionary.cs
- XmlTextReader.cs
- ToolStripSystemRenderer.cs
- ReadOnlyDataSource.cs
- SiteMapNode.cs
- XmlSignatureProperties.cs
- SmtpClient.cs
- Equal.cs
- bindurihelper.cs
- CodeIdentifiers.cs
- RequiredAttributeAttribute.cs
- VariableAction.cs
- MessageAction.cs
- PassportPrincipal.cs
- InstallerTypeAttribute.cs
- XPathScanner.cs
- Canonicalizers.cs
- WindowShowOrOpenTracker.cs
- BamlTreeNode.cs
- EnumUnknown.cs
- SymbolMethod.cs
- AutomationPeer.cs
- GridViewItemAutomationPeer.cs
- HttpGetProtocolImporter.cs
- ParamArrayAttribute.cs
- TreeViewTemplateSelector.cs
- StdValidatorsAndConverters.cs
- NamespaceInfo.cs
- ServiceChannel.cs
- GridItemProviderWrapper.cs
- TailCallAnalyzer.cs
- ToggleProviderWrapper.cs
- PeerCollaborationPermission.cs
- ContextMarshalException.cs
- AttributeTable.cs
- CmsInterop.cs
- DocumentPageHost.cs
- DesignerActionTextItem.cs
- GroupQuery.cs
- XsdCachingReader.cs
- StylusPointPropertyInfo.cs
- COM2TypeInfoProcessor.cs
- ToolStripDropDownClosedEventArgs.cs
- PolygonHotSpot.cs
- HtmlTableRow.cs
- TreeNodeStyle.cs
- RenderTargetBitmap.cs
- GregorianCalendarHelper.cs
- XmlReturnReader.cs
- SimpleBitVector32.cs
- ArrayList.cs
- DataPagerFieldCollection.cs
- SplineKeyFrames.cs
- LineBreakRecord.cs
- TextControlDesigner.cs
- HttpCachePolicyBase.cs
- TraceInternal.cs
- Variable.cs
- TokenBasedSetEnumerator.cs
- HttpCacheParams.cs
- XmlSchemaImport.cs
- WindowsFormsSectionHandler.cs
- AdornerDecorator.cs
- DynamicArgumentDesigner.xaml.cs
- SmiEventSink_DeferedProcessing.cs
- HtmlPanelAdapter.cs
- ToolStripDropDown.cs
- ScriptingSectionGroup.cs
- SystemInformation.cs
- OrderablePartitioner.cs
- Crypto.cs
- XmlExceptionHelper.cs
- ProxyWebPartConnectionCollection.cs