Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Documents / Floater.cs / 1 / Floater.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// Description: Floater element.
//
//---------------------------------------------------------------------------
using System.ComponentModel;
using MS.Internal;
using MS.Internal.PtsHost.UnsafeNativeMethods; // PTS restrictions
namespace System.Windows.Documents
{
///
/// Floater element
///
public class Floater : AnchoredBlock
{
//-------------------------------------------------------------------
//
// Constructors
//
//-------------------------------------------------------------------
#region Constructors
///
/// Static ctor. Initializes property metadata.
///
static Floater()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Floater), new FrameworkPropertyMetadata(typeof(Floater)));
}
///
/// Initialized the new instance of a Floater
///
public Floater() : this(null, null)
{
}
///
/// Initialized the new instance of a Floater specifying a Block added
/// to a Floater as its first child.
///
///
/// Block added as a first initial child of the Floater.
///
public Floater(Block childBlock) : this(childBlock, null)
{
}
///
/// Creates a new Floater instance.
///
///
/// Optional child of the new Floater, may be null.
///
///
/// Optional position at which to insert the new Floater. May
/// be null.
///
public Floater(Block childBlock, TextPointer insertionPosition) : base(childBlock, insertionPosition)
{
}
#endregion Constructors
//--------------------------------------------------------------------
//
// Public Properties
//
//-------------------------------------------------------------------
#region Public Properties
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty HorizontalAlignmentProperty =
FrameworkElement.HorizontalAlignmentProperty.AddOwner(
typeof(Floater),
new FrameworkPropertyMetadata(
HorizontalAlignment.Stretch,
FrameworkPropertyMetadataOptions.AffectsMeasure));
///
///
///
public HorizontalAlignment HorizontalAlignment
{
get { return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty); }
set { SetValue(HorizontalAlignmentProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty WidthProperty =
DependencyProperty.Register(
"Width",
typeof(double),
typeof(Floater),
new FrameworkPropertyMetadata(
Double.NaN,
FrameworkPropertyMetadataOptions.AffectsMeasure),
new ValidateValueCallback(IsValidWidth));
///
/// The Width property specifies the width of the element.
///
[TypeConverter(typeof(LengthConverter))]
public double Width
{
get { return (double)GetValue(WidthProperty); }
set { SetValue(WidthProperty, value); }
}
#endregion Public Properties
//--------------------------------------------------------------------
//
// Private Methods
//
//--------------------------------------------------------------------
#region Private Methods
private static bool IsValidWidth(object o)
{
double width = (double)o;
double maxWidth = Math.Min(1000000, PTS.MaxPageSize);
if (Double.IsNaN(width))
{
// Default value of width is NaN
return true;
}
if (width < 0 || width > maxWidth)
{
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: Floater element.
//
//---------------------------------------------------------------------------
using System.ComponentModel;
using MS.Internal;
using MS.Internal.PtsHost.UnsafeNativeMethods; // PTS restrictions
namespace System.Windows.Documents
{
///
/// Floater element
///
public class Floater : AnchoredBlock
{
//-------------------------------------------------------------------
//
// Constructors
//
//-------------------------------------------------------------------
#region Constructors
///
/// Static ctor. Initializes property metadata.
///
static Floater()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Floater), new FrameworkPropertyMetadata(typeof(Floater)));
}
///
/// Initialized the new instance of a Floater
///
public Floater() : this(null, null)
{
}
///
/// Initialized the new instance of a Floater specifying a Block added
/// to a Floater as its first child.
///
///
/// Block added as a first initial child of the Floater.
///
public Floater(Block childBlock) : this(childBlock, null)
{
}
///
/// Creates a new Floater instance.
///
///
/// Optional child of the new Floater, may be null.
///
///
/// Optional position at which to insert the new Floater. May
/// be null.
///
public Floater(Block childBlock, TextPointer insertionPosition) : base(childBlock, insertionPosition)
{
}
#endregion Constructors
//--------------------------------------------------------------------
//
// Public Properties
//
//-------------------------------------------------------------------
#region Public Properties
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty HorizontalAlignmentProperty =
FrameworkElement.HorizontalAlignmentProperty.AddOwner(
typeof(Floater),
new FrameworkPropertyMetadata(
HorizontalAlignment.Stretch,
FrameworkPropertyMetadataOptions.AffectsMeasure));
///
///
///
public HorizontalAlignment HorizontalAlignment
{
get { return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty); }
set { SetValue(HorizontalAlignmentProperty, value); }
}
///
/// DependencyProperty for property.
///
public static readonly DependencyProperty WidthProperty =
DependencyProperty.Register(
"Width",
typeof(double),
typeof(Floater),
new FrameworkPropertyMetadata(
Double.NaN,
FrameworkPropertyMetadataOptions.AffectsMeasure),
new ValidateValueCallback(IsValidWidth));
///
/// The Width property specifies the width of the element.
///
[TypeConverter(typeof(LengthConverter))]
public double Width
{
get { return (double)GetValue(WidthProperty); }
set { SetValue(WidthProperty, value); }
}
#endregion Public Properties
//--------------------------------------------------------------------
//
// Private Methods
//
//--------------------------------------------------------------------
#region Private Methods
private static bool IsValidWidth(object o)
{
double width = (double)o;
double maxWidth = Math.Min(1000000, PTS.MaxPageSize);
if (Double.IsNaN(width))
{
// Default value of width is NaN
return true;
}
if (width < 0 || width > maxWidth)
{
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
- ProgressBarRenderer.cs
- EditingCommands.cs
- Vector3D.cs
- XPathExpr.cs
- UIInitializationException.cs
- CommandExpr.cs
- WebConfigurationManager.cs
- EdmProviderManifest.cs
- MemoryRecordBuffer.cs
- UIElement3D.cs
- ItemChangedEventArgs.cs
- BitArray.cs
- ZipPackagePart.cs
- WindowsMenu.cs
- PathSegmentCollection.cs
- WindowsGraphicsCacheManager.cs
- BulletChrome.cs
- ExcCanonicalXml.cs
- FlowLayoutPanel.cs
- DiagnosticTrace.cs
- DiscoveryClientReferences.cs
- PerformanceCounterCategory.cs
- SapiAttributeParser.cs
- OutputCacheModule.cs
- KnownBoxes.cs
- CompModSwitches.cs
- CodeDomComponentSerializationService.cs
- AsymmetricSignatureDeformatter.cs
- BulletedListDesigner.cs
- DataGridToolTip.cs
- GC.cs
- CapabilitiesState.cs
- _LazyAsyncResult.cs
- DataGridViewColumnEventArgs.cs
- CharAnimationBase.cs
- FixedTextContainer.cs
- ChildrenQuery.cs
- AnnotationAuthorChangedEventArgs.cs
- DetailsViewInsertedEventArgs.cs
- PagerSettings.cs
- ExpressionWriter.cs
- BlurEffect.cs
- GroupItemAutomationPeer.cs
- DocumentPage.cs
- DBCSCodePageEncoding.cs
- DeviceSpecificChoice.cs
- UrlPath.cs
- ObjectDataSourceMethodEventArgs.cs
- RestHandler.cs
- CachedBitmap.cs
- HtmlInputControl.cs
- PolyBezierSegment.cs
- GetPolicyDetailsRequest.cs
- WorkflowDebuggerSteppingAttribute.cs
- BackStopAuthenticationModule.cs
- PathStreamGeometryContext.cs
- MoveSizeWinEventHandler.cs
- MaskInputRejectedEventArgs.cs
- OleDbFactory.cs
- DiscoveryDocumentLinksPattern.cs
- DataGridViewToolTip.cs
- XmlNavigatorFilter.cs
- Domain.cs
- ToolStripItemEventArgs.cs
- TableDetailsRow.cs
- BufferedGraphics.cs
- RelationalExpressions.cs
- RootBrowserWindowProxy.cs
- DesignerTextWriter.cs
- CacheMemory.cs
- MembershipSection.cs
- SmtpNetworkElement.cs
- SettingsProperty.cs
- TrackBar.cs
- CallContext.cs
- ThreadStateException.cs
- DrawItemEvent.cs
- RelatedEnd.cs
- DataGridViewUtilities.cs
- DocumentOutline.cs
- CapiHashAlgorithm.cs
- ClientTargetSection.cs
- GridErrorDlg.cs
- ExtentKey.cs
- Duration.cs
- PropertyNames.cs
- XmlNodeReader.cs
- ConfigurationStrings.cs
- DataRowComparer.cs
- DataControlCommands.cs
- ObjectTokenCategory.cs
- SegmentInfo.cs
- PaperSource.cs
- ExpandableObjectConverter.cs
- Parameter.cs
- QuotedPrintableStream.cs
- XmlAnyElementAttribute.cs
- LockCookie.cs
- TdsEnums.cs
- TextEffectResolver.cs