CurrentChangingEventArgs.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Base / System / ComponentModel / CurrentChangingEventArgs.cs / 1 / CurrentChangingEventArgs.cs

                            //---------------------------------------------------------------------------- 
//
// 
//    Copyright (C) Microsoft Corporation.  All rights reserved.
//  
//
// Description: CurrentChanging event arguments 
// 
//---------------------------------------------------------------------------
 
using System;
using System.Windows;

namespace System.ComponentModel 
{
 
    ///  
    /// Arguments for the CurrentChanging event.
    /// A collection that supports ICollectionView raises this event 
    /// whenever the CurrentItem is changing, or when the contents
    /// of the collection has been reset.
    /// By default, the event is cancelable when CurrentChange is
    /// caused by a move current operation and uncancelable when 
    /// caused by an irreversable collection change operation.
    ///  
    public class CurrentChangingEventArgs : EventArgs 
    {
        //----------------------------------------------------- 
        //
        //  Constructors
        //
        //----------------------------------------------------- 

        ///  
        /// Construct a cancelable CurrentChangingEventArgs that is used 
        /// to notify listeners when CurrentItem is about to change.
        ///  
        public CurrentChangingEventArgs()
        {
            Initialize(true);
        } 

        ///  
        /// Construct a CurrentChangingEventArgs that is used to notify listeners when CurrentItem is about to change. 
        /// 
        /// if false, setting Cancel to true will cause an InvalidOperationException to be thrown. 
        public CurrentChangingEventArgs(bool isCancelable)
        {
            Initialize(isCancelable);
        } 

        private void Initialize(bool isCancelable) 
        { 
            _isCancelable = isCancelable;
        } 

        //------------------------------------------------------
        //
        //  Public Properties 
        //
        //----------------------------------------------------- 
 
        /// 
        /// If this event can be canceled.  When this is False, setting Cancel to True will cause an InvalidOperationException to be thrown. 
        /// 
        public bool IsCancelable
        {
            get { return _isCancelable; } 
        }
 
        ///  
        /// When set to true, this event will be canceled.
        ///  
        /// 
        /// If IsCancelable is False, setting this value to True will cause an InvalidOperationException to be thrown.
        /// 
        public bool Cancel 
        {
            get { return _cancel; } 
            set 
            {
                if (IsCancelable) 
                {
                    _cancel = value;
                }
                else if (value) 
                {
                    throw new InvalidOperationException(SR.Get(SRID.CurrentChangingCannotBeCanceled)); 
                } 
            }
        } 

        //------------------------------------------------------
        //
        //  Private Fields 
        //
        //------------------------------------------------------ 
 
        private bool _cancel = false;
        private bool _isCancelable; 
    }

    /// 
    ///     The delegate to use for handlers that receive the CurrentChanging event. 
    /// 
    public delegate void CurrentChangingEventHandler(object sender, CurrentChangingEventArgs e); 
 
}
 


// 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: CurrentChanging event arguments 
// 
//---------------------------------------------------------------------------
 
using System;
using System.Windows;

namespace System.ComponentModel 
{
 
    ///  
    /// Arguments for the CurrentChanging event.
    /// A collection that supports ICollectionView raises this event 
    /// whenever the CurrentItem is changing, or when the contents
    /// of the collection has been reset.
    /// By default, the event is cancelable when CurrentChange is
    /// caused by a move current operation and uncancelable when 
    /// caused by an irreversable collection change operation.
    ///  
    public class CurrentChangingEventArgs : EventArgs 
    {
        //----------------------------------------------------- 
        //
        //  Constructors
        //
        //----------------------------------------------------- 

        ///  
        /// Construct a cancelable CurrentChangingEventArgs that is used 
        /// to notify listeners when CurrentItem is about to change.
        ///  
        public CurrentChangingEventArgs()
        {
            Initialize(true);
        } 

        ///  
        /// Construct a CurrentChangingEventArgs that is used to notify listeners when CurrentItem is about to change. 
        /// 
        /// if false, setting Cancel to true will cause an InvalidOperationException to be thrown. 
        public CurrentChangingEventArgs(bool isCancelable)
        {
            Initialize(isCancelable);
        } 

        private void Initialize(bool isCancelable) 
        { 
            _isCancelable = isCancelable;
        } 

        //------------------------------------------------------
        //
        //  Public Properties 
        //
        //----------------------------------------------------- 
 
        /// 
        /// If this event can be canceled.  When this is False, setting Cancel to True will cause an InvalidOperationException to be thrown. 
        /// 
        public bool IsCancelable
        {
            get { return _isCancelable; } 
        }
 
        ///  
        /// When set to true, this event will be canceled.
        ///  
        /// 
        /// If IsCancelable is False, setting this value to True will cause an InvalidOperationException to be thrown.
        /// 
        public bool Cancel 
        {
            get { return _cancel; } 
            set 
            {
                if (IsCancelable) 
                {
                    _cancel = value;
                }
                else if (value) 
                {
                    throw new InvalidOperationException(SR.Get(SRID.CurrentChangingCannotBeCanceled)); 
                } 
            }
        } 

        //------------------------------------------------------
        //
        //  Private Fields 
        //
        //------------------------------------------------------ 
 
        private bool _cancel = false;
        private bool _isCancelable; 
    }

    /// 
    ///     The delegate to use for handlers that receive the CurrentChanging event. 
    /// 
    public delegate void CurrentChangingEventHandler(object sender, CurrentChangingEventArgs e); 
 
}
 


// 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