예제 #1
0
		/// <summary>
		/// Adds the specified Cell to the end of the collection
		/// </summary>
		/// <param name="cell">The Cell to add</param>
		public int Add(Cell cell)
		{
			if (cell == null) 
			{
				throw new System.ArgumentNullException("Cell is null");
			}

			int index = this.List.Add(cell);

			this.OnCellAdded(new RowEventArgs(this.owner, cell, index, index));

			return index;
		}
		/// <summary>
		/// Gets the ButtonCellRenderer specific data used by the Renderer from 
		/// the specified Cell
		/// </summary>
		/// <param name="cell">The Cell to get the ButtonCellRenderer data for</param>
		/// <returns>The ButtonCellRenderer data for the specified Cell</returns>
		protected ButtonRendererData GetButtonRendererData(Cell cell)
		{
			object rendererData = this.GetRendererData(cell);

			if (rendererData == null || !(rendererData is ButtonRendererData))
			{
				rendererData = new ButtonRendererData();

				this.SetRendererData(cell, rendererData);
			}

			return (ButtonRendererData) rendererData;
		}
예제 #3
0
		/// <summary>
		/// Initializes a new instance of the RowEventArgs class with 
		/// the specified Row source, row index, start index, end index 
		/// and affected Cell
		/// </summary>
		/// <param name="source">The Row that originated the event</param>
		/// <param name="cell">The affected Cell</param>
		/// <param name="cellFromIndex">The start index of the affected Cell(s)</param>
		/// <param name="cellToIndex">The end index of the affected Cell(s)</param>
		public RowEventArgs(Row source, Cell cell, int cellFromIndex, int cellToIndex) : this(source, -1, cell, cellFromIndex, cellToIndex, RowEventType.Unknown)
		{
			
		}
예제 #4
0
		/// <summary>
		/// Gets the renderer specific data used by the Renderer from 
		/// the specified Cell
		/// </summary>
		/// <param name="cell">The Cell to get the renderer data for</param>
		/// <returns>The renderer data for the specified Cell</returns>
		protected object GetRendererData(Cell cell)
		{
			return cell.RendererData;
		}
예제 #5
0
		/// <summary>
		/// Initializes a new instance of the CellEventArgs class with 
		/// the specified Cell source and event type
		/// </summary>
		/// <param name="source">The Cell that Raised the event</param>
		public CellEventArgsBase(Cell source) : this(source, -1, -1)
		{
			
		}
예제 #6
0
			/// <summary>
			/// 
			/// </summary>
			/// <param name="model"></param>
			/// <returns></returns>
			public void AddColumns(ColumnModel model)
			{
				this.model = model;

				CellStyle cellStyle = new CellStyle();
				cellStyle.Padding = new CellPadding(6, 0, 0, 0);

				this.columnTable.BeginUpdate();
				
				for (int i=0; i<model.Columns.Count; i++)
				{
					Row row = new Row();
				
					Cell cell = new Cell(model.Columns[i].Text, model.Columns[i].Visible);
					cell.Tag = model.Columns[i].Width;
					cell.CellStyle = cellStyle;
				
					row.Cells.Add(cell);

					this.columnTable.TableModel.Rows.Add(row);
				}

				this.columnTable.SelectionChanged += new SelectionEventHandler(columnTable_SelectionChanged);
				this.columnTable.CellCheckChanged += new CellCheckBoxEventHandler(columnTable_CellCheckChanged);

				if (this.columnTable.VScroll)
				{
					this.columnTable.ColumnModel.Columns[0].Width -= SystemInformation.VerticalScrollBarWidth;
				}

				if (this.columnTable.TableModel.Rows.Count > 0)
				{
					this.columnTable.TableModel.Selections.SelectCell(0, 0);

					this.showButton.Enabled = !this.model.Columns[0].Visible;
					this.hideButton.Enabled = this.model.Columns[0].Visible;

					this.widthTextBox.Text = this.model.Columns[0].Width.ToString();
				}

				this.columnTable.EndUpdate();
			}
예제 #7
0
		/// <summary>
		/// Initializes a new instance of the CellEventArgs class with 
		/// the specified Cell source, column index and row index
		/// </summary>
		/// <param name="source">The Cell that Raised the event</param>
		/// <param name="editor">The CellEditor used to edit the Cell</param>
		/// <param name="table">The Table that the Cell belongs to</param>
		public CellEditEventArgs(Cell source, ICellEditor editor, Table table) : this(source, editor, table, -1, -1, Rectangle.Empty)
		{
			
		}
		/// <summary>
		/// Prepares the CellEditor to edit the specified Cell
		/// </summary>
		/// <param name="cell">The Cell to be edited</param>
		/// <param name="table">The Table that contains the Cell</param>
		/// <param name="cellPos">A CellPos representing the position of the Cell</param>
		/// <param name="cellRect">The Rectangle that represents the Cells location and size</param>
		/// <param name="userSetEditorValues">Specifies whether the ICellEditors 
		/// starting value has already been set by the user</param>
		/// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns>
		public override bool PrepareForEditing(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, bool userSetEditorValues)
		{
			if (!(table.ColumnModel.Columns[cellPos.Column] is DropDownColumn))
			{
				throw new InvalidOperationException("Cannot edit Cell as DropDownCellEditor can only be used with a DropDownColumn");
			}
			
			return base.PrepareForEditing (cell, table, cellPos, cellRect, userSetEditorValues);
		}
예제 #9
0
		/// <summary>
		/// Initializes a new instance of the Row class with an array of strings 
		/// representing Cells and the foreground color, background color, and font 
		/// of the Row
		/// </summary>
		/// <param name="items">An array of strings that represent the Cells of the Row</param>
		/// <param name="foreColor">The foreground Color of the Row</param>
		/// <param name="backColor">The background Color of the Row</param>
		/// <param name="font">The Font used to draw the text in the Row's Cells</param>
		public Row(string[] items, Color foreColor, Color backColor, Font font)
		{
			if (items == null)
			{
				throw new ArgumentNullException("items", "string[] cannot be null");
			}
			
			this.Init();

			this.ForeColor = foreColor;
			this.BackColor = backColor;
			this.Font = font;

			if (items.Length > 0)
			{
				Cell[] cells = new Cell[items.Length];

				for (int i=0; i<items.Length; i++)
				{
					cells[i] = new Cell(items[i]);
				}

				this.Cells.AddRange(cells);
			}
		}
예제 #10
0
		/// <summary>
		/// Initializes a new instance of the Row class with an array of Cell objects 
		/// </summary>
		/// <param name="cells">An array of Cell objects that represent the Cells of the Row</param>
		public Row(Cell[] cells)
		{
			if (cells == null)
			{
				throw new ArgumentNullException("cells", "Cell[] cannot be null");
			}
			
			this.Init();

			if (cells.Length > 0)
			{
				this.Cells.AddRange(cells);
			}
		}
예제 #11
0
		/// <summary>
		/// Initializes a new instance of the Row class with an array of strings 
		/// representing Cells
		/// </summary>
		/// <param name="items">An array of strings that represent the Cells of 
		/// the Row</param>
		public Row(string[] items)
		{
			if (items == null)
			{
				throw new ArgumentNullException("items", "string[] cannot be null");
			}
			
			this.Init();

			if (items.Length > 0)
			{
				Cell[] cells = new Cell[items.Length];

				for (int i=0; i<items.Length; i++)
				{
					cells[i] = new Cell(items[i]);
				}

				this.Cells.AddRange(cells);
			}
		}
		/// <summary>
		/// Initializes a new instance of the CellButtonEventArgs class with 
		/// the specified Cell source, row index and column index
		/// </summary>
		/// <param name="source">The Cell that raised the event</param>
		/// <param name="column">The Column index of the Cell</param>
		/// <param name="row">The Row index of the Cell</param>
		public CellButtonEventArgs(Cell source, int column, int row) : base(source, column, column)
		{
			
		}
예제 #13
0
		/// <summary>
		/// Prepares the CellEditor to edit the specified Cell
		/// </summary>
		/// <param name="cell">The Cell to be edited</param>
		/// <param name="table">The Table that contains the Cell</param>
		/// <param name="cellPos">A CellPos representing the position of the Cell</param>
		/// <param name="cellRect">The Rectangle that represents the Cells location and size</param>
		/// <param name="userSetEditorValues">Specifies whether the ICellEditors 
		/// starting value has already been set by the user</param>
		/// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns>
		public override bool PrepareForEditing(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, bool userSetEditorValues)
		{
			//
			if (!(table.ColumnModel.Columns[cellPos.Column] is NumberColumn))
			{
				throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn");
			}
			
			if (!(table.ColumnModel.GetCellRenderer(cellPos.Column) is NumberCellRenderer))
			{
				throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn that uses a NumberCellRenderer");
			}
			
			this.Minimum = ((NumberColumn) table.ColumnModel.Columns[cellPos.Column]).Minimum;
			this.Maximum = ((NumberColumn) table.ColumnModel.Columns[cellPos.Column]).Maximum;
			this.Increment = ((NumberColumn) table.ColumnModel.Columns[cellPos.Column]).Increment;
			
			return base.PrepareForEditing (cell, table, cellPos, cellRect, userSetEditorValues);
		}
예제 #14
0
		/// <summary>
		/// Gets the NumberRendererData specific data used by the Renderer from 
		/// the specified Cell
		/// </summary>
		/// <param name="cell">The Cell to get the NumberRendererData data for</param>
		/// <returns>The NumberRendererData data for the specified Cell</returns>
		protected NumberRendererData GetNumberRendererData(Cell cell)
		{
			object rendererData = this.GetRendererData(cell);

			if (rendererData == null || !(rendererData is NumberRendererData))
			{
				rendererData = new NumberRendererData();

				this.SetRendererData(cell, rendererData);
			}

			return (NumberRendererData) rendererData;
		}
예제 #15
0
		/// <summary>
		/// Initializes a new instance of the RowEventArgs class with 
		/// the specified Row source, row index, start index, end index 
		/// and affected Cell
		/// </summary>
		/// <param name="source">The Row that originated the event</param>
		/// <param name="rowIndex">The index of the Row</param>
		/// <param name="cell">The affected Cell</param>
		/// <param name="cellFromIndex">The start index of the affected Cell(s)</param>
		/// <param name="cellToIndex">The end index of the affected Cell(s)</param>
		/// <param name="eventType">The type of event</param>
		public RowEventArgs(Row source, int rowIndex, Cell cell, int cellFromIndex, int cellToIndex, RowEventType eventType) : base()
		{
			this.source = source;
			this.rowIndex = rowIndex;
			this.cell = cell;
			this.cellFromIndex = cellFromIndex;
			this.cellToIndex = cellToIndex;
			this.eventType = eventType;
		}
예제 #16
0
		/// <summary>
		/// Inserts an array of Cells into the collection at the specified index
		/// </summary>
		/// <param name="index">The zero-based index at which the cells should be inserted</param>
		/// <param name="cells">An array of Cells to be inserted into the collection</param>
		public void InsertRange(int index, Cell[] cells)
		{
			if (cells == null) 
			{
				throw new System.ArgumentNullException("Cell[] is null");
			}

			if (index < 0)
			{
				throw new IndexOutOfRangeException();
			}

			if (index >= this.Count)
			{
				this.AddRange(cells);
			}
			else
			{
				for (int i=cells.Length-1; i>=0; i--)
				{
					this.Insert(index, cells[i]);
				}
			}
		}
예제 #17
0
		/// <summary>
		///	Returns the index of the specified Cell in the model
		/// </summary>
		/// <param name="cell">The Cell to look for</param>
		/// <returns>The index of the specified Cell in the model</returns>
		public int IndexOf(Cell cell)
		{
			for (int i=0; i<this.Count; i++)
			{
				if (this[i] == cell)
				{
					return i;
				}
			}

			return -1;
		}
예제 #18
0
		/// <summary>
		/// Initializes a new instance of the Row class with an array of Cell objects and 
		/// the foreground color, background color, and font of the Row
		/// </summary>
		/// <param name="cells">An array of Cell objects that represent the Cells of the Row</param>
		/// <param name="foreColor">The foreground Color of the Row</param>
		/// <param name="backColor">The background Color of the Row</param>
		/// <param name="font">The Font used to draw the text in the Row's Cells</param>
		public Row(Cell[] cells, Color foreColor, Color backColor, Font font)
		{
			if (cells == null)
			{
				throw new ArgumentNullException("cells", "Cell[] cannot be null");
			}
			
			this.Init();

			this.ForeColor = foreColor;
			this.BackColor = backColor;
			this.Font = font;

			if (cells.Length > 0)
			{
				this.Cells.AddRange(cells);
			}
		}
예제 #19
0
		/// <summary>
		/// Adds an array of Cell objects to the collection
		/// </summary>
		/// <param name="cells">An array of Cell objects to add 
		/// to the collection</param>
		public void AddRange(Cell[] cells)
		{
			if (cells == null) 
			{
				throw new System.ArgumentNullException("Cell[] is null");
			}

			for (int i=0; i<cells.Length; i++)
			{
				this.Add(cells[i]);
			}
		}
예제 #20
0
		/// <summary>
		/// Initializes a new instance of the CellEventArgs class with 
		/// the specified Cell source and event type
		/// </summary>
		/// <param name="source">The Cell that Raised the event</param>
		/// <param name="eventType">The type of event</param>
		/// <param name="oldValue">The old value of the property</param>
		public CellEventArgs(Cell source, CellEventType eventType, object oldValue) : this(source, -1, -1, eventType, oldValue)
		{
			
		}
예제 #21
0
		/// <summary>
		/// Initializes a new instance of the CellEventArgs class with 
		/// the specified Cell source, column index and row index
		/// </summary>
		/// <param name="source">The Cell that Raised the event</param>
		/// <param name="editor">The CellEditor used to edit the Cell</param>
		/// <param name="table">The Table that the Cell belongs to</param>
		/// <param name="row">The Column index of the Cell</param>
		/// <param name="column">The Row index of the Cell</param>
		/// <param name="cellRect"></param>
		public CellEditEventArgs(Cell source, ICellEditor editor, Table table, int row, int column, Rectangle cellRect) : base(source, column, row)
		{
			this.editor = editor;
			this.table = table;
			this.cellRect = cellRect;

			this.cancel = false;
		}
예제 #22
0
		/// <summary>
		/// Initializes a new instance of the CellEventArgs class with 
		/// the specified Cell source, column index, row index and event type
		/// </summary>
		/// <param name="source">The Cell that Raised the event</param>
		/// <param name="column">The Column index of the Cell</param>
		/// <param name="row">The Row index of the Cell</param>
		/// <param name="eventType">The type of event</param>
		/// <param name="oldValue">The old value of the property</param>
		public CellEventArgs(Cell source, int column, int row, CellEventType eventType, object oldValue) : base(source, column, row)
		{
			this.eventType = eventType;
			this.oldValue = oldValue;
		}
예제 #23
0
		/// <summary>
		/// Compares two objects and returns a value indicating whether one is less 
		/// than, equal to or greater than the other
		/// </summary>
		/// <param name="a">First object to compare</param>
		/// <param name="b">Second object to compare</param>
		/// <returns>-1 if a is less than b, 1 if a is greater than b, or 0 if a equals b</returns>
		protected int Compare(Cell a, Cell b)
		{
			switch (this.SortOrder)
			{
				case SortOrder.None:
					return 0;

				case SortOrder.Descending:
					return -this.Comparer.Compare(a, b);

				default:
					return this.Comparer.Compare(a, b);
			}
		}
		/// <summary>
		/// Gets the CheckBoxCellRenderer specific data used by the Renderer from 
		/// the specified Cell
		/// </summary>
		/// <param name="cell">The Cell to get the CheckBoxCellRenderer data for</param>
		/// <returns>The CheckBoxCellRenderer data for the specified Cell</returns>
		protected CheckBoxRendererData GetCheckBoxRendererData(Cell cell)
		{
			object rendererData = this.GetRendererData(cell);

			if (rendererData == null || !(rendererData is CheckBoxRendererData))
			{
				if (cell.CheckState == CheckState.Unchecked)
				{
					rendererData = new CheckBoxRendererData(CheckBoxStates.UncheckedNormal);
				}
				else if (cell.CheckState == CheckState.Indeterminate && cell.ThreeState)
				{
					rendererData = new CheckBoxRendererData(CheckBoxStates.MixedNormal);
				}
				else 
				{
					rendererData = new CheckBoxRendererData(CheckBoxStates.CheckedNormal);
				}

				this.SetRendererData(cell, rendererData);
			}

			this.ValidateCheckState(cell, (CheckBoxRendererData) rendererData);

			return (CheckBoxRendererData) rendererData;
		}
		/// <summary>
		/// Corrects any differences between the check state of the specified Cell 
		/// and the check state in its rendererData
		/// </summary>
		/// <param name="cell">The Cell to chech</param>
		/// <param name="rendererData">The CheckBoxRendererData to check</param>
		private void ValidateCheckState(Cell cell, CheckBoxRendererData rendererData)
		{
			switch (cell.CheckState)
			{
				case CheckState.Checked:
				{		
					if (rendererData.CheckState <= CheckBoxStates.UncheckedDisabled)
					{
						rendererData.CheckState |= (CheckBoxStates) 4;
					}
					else if (rendererData.CheckState >= CheckBoxStates.MixedNormal)
					{
						rendererData.CheckState -= (CheckBoxStates) 4;
					}
					
					break;
				}

				case CheckState.Indeterminate:
				{		
					if (rendererData.CheckState <= CheckBoxStates.UncheckedDisabled)
					{
						rendererData.CheckState |= (CheckBoxStates) 8;
					}
					else if (rendererData.CheckState <= CheckBoxStates.CheckedDisabled)
					{
						rendererData.CheckState |= (CheckBoxStates) 4;
					}
					
					break;
				}

				default:
				{
					if (rendererData.CheckState >= CheckBoxStates.MixedNormal)
					{
						rendererData.CheckState -= (CheckBoxStates) 8;
					}
					else if (rendererData.CheckState >= CheckBoxStates.CheckedNormal)
					{
						rendererData.CheckState -= (CheckBoxStates) 4;
					}
					
					break;
				}
			}
		}
예제 #26
0
		/// <summary>
		/// Removes the specified Cell from the model
		/// </summary>
		/// <param name="cell">The Cell to remove</param>
		public void Remove(Cell cell)
		{
			int cellIndex = this.IndexOf(cell);

			if (cellIndex != -1) 
			{
				this.RemoveAt(cellIndex);
			}
		}
예제 #27
0
		/// <summary>
		/// Initializes a new instance of the CellEventArgs class with 
		/// the specified Cell source, column index and row index
		/// </summary>
		/// <param name="source">The Cell that Raised the event</param>
		/// <param name="column">The Column index of the Cell</param>
		/// <param name="row">The Row index of the Cell</param>
		public CellEventArgsBase(Cell source, int column, int row) : base()
		{
			this.source = source;
			this.column = column;
			this.row = row;
		}
예제 #28
0
		/// <summary>
		/// Inserts a Cell into the collection at the specified index
		/// </summary>
		/// <param name="index">The zero-based index at which the Cell 
		/// should be inserted</param>
		/// <param name="cell">The Cell to insert</param>
		public void Insert(int index, Cell cell)
		{
			if (cell == null)
			{
				return;
			}

			if (index < 0)
			{
				throw new IndexOutOfRangeException();
			}
			
			if (index >= this.Count)
			{
				this.Add(cell);
			}
			else
			{
				base.List.Insert(index, cell);

				this.OnCellAdded(new RowEventArgs(this.owner, cell, index, index));
			}
		}
예제 #29
0
		/// <summary>
		/// Sets the specified renderer specific data used by the Renderer for 
		/// the specified Cell
		/// </summary>
		/// <param name="cell">The Cell for which the data is to be stored</param>
		/// <param name="value">The renderer specific data to be stored</param>
		protected void SetRendererData(Cell cell, object value)
		{
			cell.RendererData = value;
		}
예제 #30
0
		/// <summary>
		/// Initializes a new instance of the CellKeyEventArgs class with 
		/// the specified source Cell, table, row index, column index, cell 
		/// bounds and KeyEventArgs
		/// </summary>
		/// <param name="cell">The Cell that Raised the event</param>
		/// <param name="table">The Table the Cell belongs to</param>
		/// <param name="row">The Row index of the Cell</param>
		/// <param name="column">The Column index of the Cell</param>
		/// <param name="cellRect">The Cell's bounding rectangle</param>
		/// <param name="kea"></param>
		public CellKeyEventArgs(Cell cell, Table table, int row, int column, Rectangle cellRect, KeyEventArgs kea) : base(kea.KeyData)
		{
			this.cell = cell;
			this.table = table;
			this.row = row;
			this.column = column;
			this.cellRect = cellRect;
		}