ListItem.cs source code in C# .NET

Source code for the .NET framework in C#

                        

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 / ListItem.cs / 1 / ListItem.cs

                            //---------------------------------------------------------------------------- 
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
// Description: ListItem acts by default like a Paragraph, but with 
//              different margins/padding and features to support markers
//              such as bullets and numbering. 
// 
// History:
//  06/06/2003 : grzegorz - created. 
//  10/28/2004 : grzegorz - ContentElements refactoring.
//
//---------------------------------------------------------------------------
 
using MS.Internal;                  // Invariant
using System.Windows.Markup; // ContentProperty 
using System.ComponentModel;        // TypeConverter 
using System.Windows.Media;         // Brush
 
namespace System.Windows.Documents
{
    /// 
    /// ListItem acts by default like a Paragraph, but with different 
    /// margins/padding and features to support markers such as bullets and
    /// numbering. 
    ///  
    [ContentProperty("Blocks")]
    public class ListItem : TextElement 
    {
        //-------------------------------------------------------------------
        //
        //  Constructors 
        //
        //------------------------------------------------------------------- 
 
        #region Constructors
 
        /// 
        /// Initializes a new instance of a ListItem element.
        /// 
        public ListItem() 
            : base()
        { 
        } 

        ///  
        /// Initializes a new instance of a ListItem element specifying a Paragraph element as its initial child.
        /// 
        /// 
        /// Paragraph added as a single child of a ListItem 
        /// 
        public ListItem(Paragraph paragraph) 
            : base() 
        {
            if (paragraph == null) 
            {
                throw new ArgumentNullException("paragraph");
            }
 
            this.Blocks.Add(paragraph);
        } 
 
        #endregion Constructors
 
        //--------------------------------------------------------------------
        //
        // Public Properties
        // 
        //-------------------------------------------------------------------
 
        #region Public Properties 

        ///  
        /// Parent element as IBlockItemParent through which a Children collection
        /// containing this BlockItem is available for Adding/Removing purposes.
        /// 
        public List List 
        {
            get 
            { 
                Invariant.Assert(this.Parent == null || this.Parent is List);
                return (List)this.Parent; 
            }
        }

        ///  
        /// Collection of BlockItems contained in this ListItem.
        /// Usually this collection contains only one Paragraph element. 
        /// In case of nested lists it can contain List element as a second 
        /// item of the collection.
        /// More Paragraphs can be added to a collection as well. 
        /// 
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public BlockCollection Blocks
        { 
            get
            { 
                return  new BlockCollection(this, /*isOwnerParent*/true); 
            }
        } 

        /// 
        /// A collection of ListItems containing this one in its sequential tree.
        /// May return null if an element is not inserted into any tree. 
        /// 
        public ListItemCollection SiblingListItems 
        { 
            get
            { 
                if (this.Parent == null)
                {
                    return null;
                } 

                return new ListItemCollection(this, /*isOwnerParent*/false); 
            } 
        }
 
        /// 
        /// Returns a ListItem immediately following this one
        /// 
        public ListItem NextListItem 
        {
            get 
            { 
                return this.NextElement as ListItem;
            } 
        }

        /// 
        /// Returns a block immediately preceding this one 
        /// on the same level of siblings
        ///  
        public ListItem PreviousListItem 
        {
            get 
            {
                return this.PreviousElement as ListItem;
            }
        } 

        ///  
        /// DependencyProperty for  property. 
        /// 
        public static readonly DependencyProperty MarginProperty = 
                Block.MarginProperty.AddOwner(
                        typeof(ListItem),
                        new FrameworkPropertyMetadata(
                                new Thickness(), 
                                FrameworkPropertyMetadataOptions.AffectsMeasure));
 
        ///  
        /// The Margin property specifies the margin of the element.
        ///  
        public Thickness Margin
        {
            get { return (Thickness)GetValue(MarginProperty); }
            set { SetValue(MarginProperty, value); } 
        }
 
        ///  
        /// DependencyProperty for  property.
        ///  
        public static readonly DependencyProperty PaddingProperty =
                Block.PaddingProperty.AddOwner(
                        typeof(ListItem),
                        new FrameworkPropertyMetadata( 
                                new Thickness(),
                                FrameworkPropertyMetadataOptions.AffectsMeasure)); 
 
        /// 
        /// The Padding property specifies the padding of the element. 
        /// 
        public Thickness Padding
        {
            get { return (Thickness)GetValue(PaddingProperty); } 
            set { SetValue(PaddingProperty, value); }
        } 
 
        /// 
        /// DependencyProperty for  property. 
        /// 
        public static readonly DependencyProperty BorderThicknessProperty =
                Block.BorderThicknessProperty.AddOwner(
                        typeof(ListItem), 
                        new FrameworkPropertyMetadata(
                                new Thickness(), 
                                FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender)); 

        ///  
        /// The BorderThickness property specifies the border of the element.
        /// 
        public Thickness BorderThickness
        { 
            get { return (Thickness)GetValue(BorderThicknessProperty); }
            set { SetValue(BorderThicknessProperty, value); } 
        } 

        ///  
        /// DependencyProperty for  property.
        /// 
        public static readonly DependencyProperty BorderBrushProperty =
                Block.BorderBrushProperty.AddOwner( 
                        typeof(ListItem),
                        new FrameworkPropertyMetadata( 
                                null, 
                                FrameworkPropertyMetadataOptions.AffectsRender));
 
        /// 
        /// The BorderBrush property specifies the brush of the border.
        /// 
        public Brush BorderBrush 
        {
            get { return (Brush)GetValue(BorderBrushProperty); } 
            set { SetValue(BorderBrushProperty, value); } 
        }
 
        /// 
        /// DependencyProperty for  property.
        /// 
        public static readonly DependencyProperty TextAlignmentProperty = 
                Block.TextAlignmentProperty.AddOwner(typeof(ListItem));
 
        ///  
        ///
        ///  
        public TextAlignment TextAlignment
        {
            get { return (TextAlignment)GetValue(TextAlignmentProperty); }
            set { SetValue(TextAlignmentProperty, value); } 
        }
 
        ///  
        /// DependencyProperty for  property.
        ///  
        public static readonly DependencyProperty FlowDirectionProperty =
                Block.FlowDirectionProperty.AddOwner(typeof(ListItem));

        ///  
        /// The FlowDirection property specifies the flow direction of the element.
        ///  
        public FlowDirection FlowDirection 
        {
            get { return (FlowDirection)GetValue(FlowDirectionProperty); } 
            set { SetValue(FlowDirectionProperty, value); }
        }

        ///  
        /// DependencyProperty for  property.
        ///  
        public static readonly DependencyProperty LineHeightProperty = 
                Block.LineHeightProperty.AddOwner(typeof(ListItem));
 
        /// 
        /// The LineHeight property specifies the height of each generated line box.
        /// 
        [TypeConverter(typeof(LengthConverter))] 
        public double LineHeight
        { 
            get { return (double)GetValue(LineHeightProperty); } 
            set { SetValue(LineHeightProperty, value); }
        } 

        /// 
        /// DependencyProperty for  property.
        ///  
        public static readonly DependencyProperty LineStackingStrategyProperty =
                Block.LineStackingStrategyProperty.AddOwner(typeof(ListItem)); 
 
        /// 
        /// The LineStackingStrategy property specifies how lines are placed 
        /// 
        public LineStackingStrategy LineStackingStrategy
        {
            get { return (LineStackingStrategy)GetValue(LineStackingStrategyProperty); } 
            set { SetValue(LineStackingStrategyProperty, value); }
        } 
 
        #endregion Public Properties
 
        #region Internal Methods

        /// 
        /// This method is used by TypeDescriptor to determine if this property should 
        /// be serialized.
        ///  
        [EditorBrowsable(EditorBrowsableState.Never)] 
        public bool ShouldSerializeBlocks(XamlDesignerSerializationManager manager)
        { 
            return manager != null && manager.XmlWriter == null;
        }

        #endregion 

        //------------------------------------------------------ 
        // 
        //  Internal Properties
        // 
        //------------------------------------------------------

        #region Internal Properties
 
        /// 
        /// Marks this element's left edge as visible to IMEs. 
        /// This means element boundaries will act as word breaks. 
        /// 
        internal override bool IsIMEStructuralElement 
        {
            get
            {
                return true; 
            }
        } 
 
        #endregion Internal Properties
    } 
}

// 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: ListItem acts by default like a Paragraph, but with 
//              different margins/padding and features to support markers
//              such as bullets and numbering. 
// 
// History:
//  06/06/2003 : grzegorz - created. 
//  10/28/2004 : grzegorz - ContentElements refactoring.
//
//---------------------------------------------------------------------------
 
using MS.Internal;                  // Invariant
using System.Windows.Markup; // ContentProperty 
using System.ComponentModel;        // TypeConverter 
using System.Windows.Media;         // Brush
 
namespace System.Windows.Documents
{
    /// 
    /// ListItem acts by default like a Paragraph, but with different 
    /// margins/padding and features to support markers such as bullets and
    /// numbering. 
    ///  
    [ContentProperty("Blocks")]
    public class ListItem : TextElement 
    {
        //-------------------------------------------------------------------
        //
        //  Constructors 
        //
        //------------------------------------------------------------------- 
 
        #region Constructors
 
        /// 
        /// Initializes a new instance of a ListItem element.
        /// 
        public ListItem() 
            : base()
        { 
        } 

        ///  
        /// Initializes a new instance of a ListItem element specifying a Paragraph element as its initial child.
        /// 
        /// 
        /// Paragraph added as a single child of a ListItem 
        /// 
        public ListItem(Paragraph paragraph) 
            : base() 
        {
            if (paragraph == null) 
            {
                throw new ArgumentNullException("paragraph");
            }
 
            this.Blocks.Add(paragraph);
        } 
 
        #endregion Constructors
 
        //--------------------------------------------------------------------
        //
        // Public Properties
        // 
        //-------------------------------------------------------------------
 
        #region Public Properties 

        ///  
        /// Parent element as IBlockItemParent through which a Children collection
        /// containing this BlockItem is available for Adding/Removing purposes.
        /// 
        public List List 
        {
            get 
            { 
                Invariant.Assert(this.Parent == null || this.Parent is List);
                return (List)this.Parent; 
            }
        }

        ///  
        /// Collection of BlockItems contained in this ListItem.
        /// Usually this collection contains only one Paragraph element. 
        /// In case of nested lists it can contain List element as a second 
        /// item of the collection.
        /// More Paragraphs can be added to a collection as well. 
        /// 
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public BlockCollection Blocks
        { 
            get
            { 
                return  new BlockCollection(this, /*isOwnerParent*/true); 
            }
        } 

        /// 
        /// A collection of ListItems containing this one in its sequential tree.
        /// May return null if an element is not inserted into any tree. 
        /// 
        public ListItemCollection SiblingListItems 
        { 
            get
            { 
                if (this.Parent == null)
                {
                    return null;
                } 

                return new ListItemCollection(this, /*isOwnerParent*/false); 
            } 
        }
 
        /// 
        /// Returns a ListItem immediately following this one
        /// 
        public ListItem NextListItem 
        {
            get 
            { 
                return this.NextElement as ListItem;
            } 
        }

        /// 
        /// Returns a block immediately preceding this one 
        /// on the same level of siblings
        ///  
        public ListItem PreviousListItem 
        {
            get 
            {
                return this.PreviousElement as ListItem;
            }
        } 

        ///  
        /// DependencyProperty for  property. 
        /// 
        public static readonly DependencyProperty MarginProperty = 
                Block.MarginProperty.AddOwner(
                        typeof(ListItem),
                        new FrameworkPropertyMetadata(
                                new Thickness(), 
                                FrameworkPropertyMetadataOptions.AffectsMeasure));
 
        ///  
        /// The Margin property specifies the margin of the element.
        ///  
        public Thickness Margin
        {
            get { return (Thickness)GetValue(MarginProperty); }
            set { SetValue(MarginProperty, value); } 
        }
 
        ///  
        /// DependencyProperty for  property.
        ///  
        public static readonly DependencyProperty PaddingProperty =
                Block.PaddingProperty.AddOwner(
                        typeof(ListItem),
                        new FrameworkPropertyMetadata( 
                                new Thickness(),
                                FrameworkPropertyMetadataOptions.AffectsMeasure)); 
 
        /// 
        /// The Padding property specifies the padding of the element. 
        /// 
        public Thickness Padding
        {
            get { return (Thickness)GetValue(PaddingProperty); } 
            set { SetValue(PaddingProperty, value); }
        } 
 
        /// 
        /// DependencyProperty for  property. 
        /// 
        public static readonly DependencyProperty BorderThicknessProperty =
                Block.BorderThicknessProperty.AddOwner(
                        typeof(ListItem), 
                        new FrameworkPropertyMetadata(
                                new Thickness(), 
                                FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender)); 

        ///  
        /// The BorderThickness property specifies the border of the element.
        /// 
        public Thickness BorderThickness
        { 
            get { return (Thickness)GetValue(BorderThicknessProperty); }
            set { SetValue(BorderThicknessProperty, value); } 
        } 

        ///  
        /// DependencyProperty for  property.
        /// 
        public static readonly DependencyProperty BorderBrushProperty =
                Block.BorderBrushProperty.AddOwner( 
                        typeof(ListItem),
                        new FrameworkPropertyMetadata( 
                                null, 
                                FrameworkPropertyMetadataOptions.AffectsRender));
 
        /// 
        /// The BorderBrush property specifies the brush of the border.
        /// 
        public Brush BorderBrush 
        {
            get { return (Brush)GetValue(BorderBrushProperty); } 
            set { SetValue(BorderBrushProperty, value); } 
        }
 
        /// 
        /// DependencyProperty for  property.
        /// 
        public static readonly DependencyProperty TextAlignmentProperty = 
                Block.TextAlignmentProperty.AddOwner(typeof(ListItem));
 
        ///  
        ///
        ///  
        public TextAlignment TextAlignment
        {
            get { return (TextAlignment)GetValue(TextAlignmentProperty); }
            set { SetValue(TextAlignmentProperty, value); } 
        }
 
        ///  
        /// DependencyProperty for  property.
        ///  
        public static readonly DependencyProperty FlowDirectionProperty =
                Block.FlowDirectionProperty.AddOwner(typeof(ListItem));

        ///  
        /// The FlowDirection property specifies the flow direction of the element.
        ///  
        public FlowDirection FlowDirection 
        {
            get { return (FlowDirection)GetValue(FlowDirectionProperty); } 
            set { SetValue(FlowDirectionProperty, value); }
        }

        ///  
        /// DependencyProperty for  property.
        ///  
        public static readonly DependencyProperty LineHeightProperty = 
                Block.LineHeightProperty.AddOwner(typeof(ListItem));
 
        /// 
        /// The LineHeight property specifies the height of each generated line box.
        /// 
        [TypeConverter(typeof(LengthConverter))] 
        public double LineHeight
        { 
            get { return (double)GetValue(LineHeightProperty); } 
            set { SetValue(LineHeightProperty, value); }
        } 

        /// 
        /// DependencyProperty for  property.
        ///  
        public static readonly DependencyProperty LineStackingStrategyProperty =
                Block.LineStackingStrategyProperty.AddOwner(typeof(ListItem)); 
 
        /// 
        /// The LineStackingStrategy property specifies how lines are placed 
        /// 
        public LineStackingStrategy LineStackingStrategy
        {
            get { return (LineStackingStrategy)GetValue(LineStackingStrategyProperty); } 
            set { SetValue(LineStackingStrategyProperty, value); }
        } 
 
        #endregion Public Properties
 
        #region Internal Methods

        /// 
        /// This method is used by TypeDescriptor to determine if this property should 
        /// be serialized.
        ///  
        [EditorBrowsable(EditorBrowsableState.Never)] 
        public bool ShouldSerializeBlocks(XamlDesignerSerializationManager manager)
        { 
            return manager != null && manager.XmlWriter == null;
        }

        #endregion 

        //------------------------------------------------------ 
        // 
        //  Internal Properties
        // 
        //------------------------------------------------------

        #region Internal Properties
 
        /// 
        /// Marks this element's left edge as visible to IMEs. 
        /// This means element boundaries will act as word breaks. 
        /// 
        internal override bool IsIMEStructuralElement 
        {
            get
            {
                return true; 
            }
        } 
 
        #endregion Internal Properties
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK