Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / Floater.cs / 1305600 / 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
- SqlBuilder.cs
- AssemblySettingAttributes.cs
- DelayedRegex.cs
- RoutedUICommand.cs
- TreeViewHitTestInfo.cs
- CFStream.cs
- CommonDialog.cs
- GroupStyle.cs
- PropertyDescriptorCollection.cs
- CompilerGeneratedAttribute.cs
- VoiceObjectToken.cs
- CuspData.cs
- OuterProxyWrapper.cs
- assemblycache.cs
- TrustSection.cs
- SoapFault.cs
- ScrollEvent.cs
- Facet.cs
- HttpProxyCredentialType.cs
- HighContrastHelper.cs
- MobileCapabilities.cs
- RequestValidator.cs
- SecurityPermission.cs
- DataGridViewLinkColumn.cs
- Annotation.cs
- MinimizableAttributeTypeConverter.cs
- OperationCanceledException.cs
- UnsafeNativeMethods.cs
- Component.cs
- EventMappingSettings.cs
- WorkflowQueueInfo.cs
- SchemaAttDef.cs
- ZipPackagePart.cs
- ProfileSettings.cs
- ArgumentNullException.cs
- Point.cs
- EncodingNLS.cs
- MultiDataTrigger.cs
- ProcessInfo.cs
- UserMapPath.cs
- Component.cs
- XPathDocument.cs
- ContentElement.cs
- ItemsChangedEventArgs.cs
- DockingAttribute.cs
- FileUtil.cs
- _AcceptOverlappedAsyncResult.cs
- DocumentViewerBaseAutomationPeer.cs
- ISessionStateStore.cs
- ZoneIdentityPermission.cs
- CodeTypeDelegate.cs
- MemberDescriptor.cs
- ObjectTag.cs
- TraceContextEventArgs.cs
- ToolStripDropDown.cs
- ArcSegment.cs
- RepeaterItemEventArgs.cs
- MDIControlStrip.cs
- GeneralTransform.cs
- StackBuilderSink.cs
- WorkflowServiceBuildProvider.cs
- elementinformation.cs
- PropertyTab.cs
- WorkflowServiceHost.cs
- TypeReference.cs
- mediapermission.cs
- X509CertificateStore.cs
- LoginName.cs
- SecurityContext.cs
- ConfigurationLockCollection.cs
- CatalogPart.cs
- PenThreadWorker.cs
- Label.cs
- ClientOperationFormatterProvider.cs
- DomainLiteralReader.cs
- __ComObject.cs
- StringReader.cs
- UnsafeNativeMethods.cs
- Transform3DGroup.cs
- HyperlinkAutomationPeer.cs
- TextWriterTraceListener.cs
- ClientData.cs
- FormClosingEvent.cs
- SEHException.cs
- Panel.cs
- COM2ColorConverter.cs
- BufferModeSettings.cs
- PenThread.cs
- FlowDocumentScrollViewer.cs
- XmlDataCollection.cs
- StandardToolWindows.cs
- QilXmlReader.cs
- WebPartEventArgs.cs
- Comparer.cs
- BaseCodeDomTreeGenerator.cs
- SoundPlayer.cs
- SqlColumnizer.cs
- XmlEncoding.cs
- LostFocusEventManager.cs
- XmlTextReaderImplHelpers.cs