using System;
namespace DevComponents.AdvTree
{
	/// 
	/// Represents event arguments for cell editing events.
	/// 
	public class CellEditEventArgs : EventArgs
	{
		/// 
		/// Indicates the action that caused the event.
		/// 
		public eTreeAction Action=eTreeAction.Code;
		/// 
		/// Indicates the cell that is affected.
		/// 
		public DevComponents.AdvTree.Cell Cell=null;
		/// 
		/// Indicates new text that will be assigned to the cell if one is appropriate for given event.
		/// 
		public string NewText="";
        private ICellEditControl _Editor = null;
        /// 
        /// Gets reference to the cell editor control.
        /// 
        public ICellEditControl Editor
        {
            get
            {
                return _Editor;
            }
        }
		/// 
		/// Indicates whether the current action is cancelled. For BeforeCellEdit event setting this
		/// property to true will cancel the editing. For AfterCellEdit event setting this property to
		/// true will cancel any changes made to the text and edits will not be accepted. For CellEditEnding
		/// event setting this property to true will keep the cell in edit mode.
		/// 
		public bool Cancel=false;
        /// 
        /// Indicates whether editing operation was canceled by the end user, usually by pressing ESCAPE key.
        /// 
        public readonly bool IsUserCanceled;
		/// 
		/// Initializes new instance of CellEditEventArgs class.
		/// 
		/// Reference to Cell this event is raised for.
		/// Indicates the action that caused the event.
		/// Indicates new text of the cell if it applies to given event.
		public CellEditEventArgs(Cell cell, eTreeAction action, string newText)
		{
			this.Action=action;
			this.Cell=cell;
			this.NewText=newText;
            this.IsUserCanceled = false;
		}
        /// 
        /// Initializes new instance of CellEditEventArgs class.
        /// 
        /// Reference to Cell this event is raised for.
        /// Indicates the action that caused the event.
        /// Indicates new text of the cell if it applies to given event.
        public CellEditEventArgs(Cell cell, eTreeAction action, string newText, ICellEditControl editor)
        {
            this.Action = action;
            this.Cell = cell;
            this.NewText = newText;
            this.IsUserCanceled = false;
            _Editor = editor;
        }
        /// 
        /// Initializes new instance of CellEditEventArgs class.
        /// 
        /// Reference to Cell this event is raised for.
        /// Indicates the action that caused the event.
        /// Indicates new text of the cell if it applies to given event.
        /// Indicates whether action is canceled by the end user.
        public CellEditEventArgs(Cell cell, eTreeAction action, string newText, bool isUserCanceled)
        {
            this.Action = action;
            this.Cell = cell;
            this.NewText = newText;
            this.IsUserCanceled = isUserCanceled;
        }
        /// 
        /// Initializes new instance of CellEditEventArgs class.
        /// 
        /// Reference to Cell this event is raised for.
        /// Indicates the action that caused the event.
        /// Indicates new text of the cell if it applies to given event.
        /// Indicates whether action is canceled by the end user.
        public CellEditEventArgs(Cell cell, eTreeAction action, string newText, bool isUserCanceled, ICellEditControl editor)
        {
            this.Action = action;
            this.Cell = cell;
            this.NewText = newText;
            this.IsUserCanceled = isUserCanceled;
            _Editor = editor;
        }
	}
}