예제 #1
0
파일: TableModel.cs 프로젝트: virl/yttrium
            /// <summary>
            /// Adds the Cells between the last selection start Cell and the Cell at the 
            /// specified row/column indicies to the current selection.  Any Cells that are 
            /// between the last start and end Cells that are not in the new area are 
            /// removed from the current selection
            /// </summary>
            /// <param name="row">The row index of the shift selected Cell</param>
            /// <param name="column">The column index of the shift selected Cell</param>
            public void AddShiftSelectedCell(int row, int column)
            {
                int[] oldSelectedIndicies = this.SelectedIndicies;

                if (this.shiftSelectStart == CellPos.Empty)
                {
                    this.shiftSelectStart = new CellPos(0, 0);
                }

                bool changed = false;

                if (this.shiftSelectEnd != CellPos.Empty)
                {
                    changed = this.InternalRemoveCells(this.shiftSelectStart, this.shiftSelectEnd);
                    changed |= this.InternalAddCells(this.shiftSelectStart, new CellPos(row, column));
                }
                else
                {
                    changed = this.InternalAddCells(0, 0, row, column);
                }

                if (changed)
                {
                    this.owner.OnSelectionChanged(new SelectionEventArgs(this.owner, oldSelectedIndicies, this.SelectedIndicies));
                }

                this.shiftSelectEnd = new CellPos(row, column);
            }
예제 #2
0
파일: TableModel.cs 프로젝트: virl/yttrium
            /// <summary>
            /// Removes all selected Rows and Cells from the selection
            /// </summary>
            public void Clear()
            {
                if (this.rows.Count > 0)
                {
                    int[] oldSelectedIndicies = this.SelectedIndicies;

                    this.InternalClear();

                    this.shiftSelectStart = CellPos.Empty;
                    this.shiftSelectEnd = CellPos.Empty;

                    this.owner.OnSelectionChanged(new SelectionEventArgs(this.owner, oldSelectedIndicies, this.SelectedIndicies));
                }
            }
예제 #3
0
파일: TableModel.cs 프로젝트: virl/yttrium
 public Cell this[CellPos cellPos]
 {
     get
     {
         return this[cellPos.Row, cellPos.Column];
     }
 }
예제 #4
0
파일: TableModel.cs 프로젝트: virl/yttrium
 /// <summary>
 /// Adds the Cell at the specified row and column indicies to the current selection
 /// </summary>
 /// <param name="cellPos">A CellPos that specifies the Cell to add to the selection</param>
 public void AddCell(CellPos cellPos)
 {
     this.AddCell(cellPos.Row, cellPos.Column);
 }
예제 #5
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 DropDownColumn))
			{
				throw new InvalidOperationException("Cannot edit Cell as DropDownCellEditor can only be used with a DropDownColumn");
			}
			
			return base.PrepareForEditing (cell, table, cellPos, cellRect, userSetEditorValues);
		}
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the CellMouseEventArgs class with 
 /// the specified source Cell, table, row index, column index and 
 /// cell bounds
 /// </summary>
 /// <param name="cell">The Cell that Raised the event</param>
 /// <param name="table">The Table the Cell belongs to</param>
 /// <param name="cellPos"></param>
 /// <param name="cellRect">The Cell's bounding rectangle</param>
 public CellMouseEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect)
     : base(MouseButtons.None, 0, -1, -1, 0)
 {
     this.cell = cell;
     this.table = table;
     this.row = cellPos.Row;
     this.column = cellPos.Column;
     this.cellRect = cellRect;
 }
예제 #7
0
파일: Table.cs 프로젝트: nithinphilips/SMOz
		/// <summary>
		/// Resets the last known cell position that the mouse was over to empty
		/// </summary>
		internal void ResetLastMouseCell()
		{
			if (!this.lastMouseCell.IsEmpty)
			{
				this.ResetMouseEventArgs();

				CellPos oldLastMouseCell = this.lastMouseCell;
				this.lastMouseCell = CellPos.Empty;
							
				this.RaiseCellMouseLeave(oldLastMouseCell);
			}
		}
예제 #8
0
파일: TableModel.cs 프로젝트: virl/yttrium
            /// <summary>
            /// Replaces the currently selected Cells with the Cells located between the specified 
            /// start and end row/column indicies
            /// </summary>
            /// <param name="startRow">The row index of the start Cell</param>
            /// <param name="startColumn">The column index of the start Cell</param>
            /// <param name="endRow">The row index of the end Cell</param>
            /// <param name="endColumn">The column index of the end Cell</param>
            public void SelectCells(int startRow, int startColumn, int endRow, int endColumn)
            {
                int[] oldSelectedIndicies = this.SelectedIndicies;

                this.InternalClear();

                if (this.InternalAddCells(startRow, startColumn, endRow, endColumn))
                {
                    this.owner.OnSelectionChanged(new SelectionEventArgs(this.owner, oldSelectedIndicies, this.SelectedIndicies));
                }

                this.shiftSelectStart = new CellPos(startRow, startColumn);
                this.shiftSelectEnd = new CellPos(endRow, endColumn);
            }
예제 #9
0
 /// <summary>
 /// Adds the Cells located between the specified start and end CellPos to the
 /// current selection
 /// </summary>
 /// <param name="start">A CellPos that specifies the start Cell</param>
 /// <param name="end">A CellPos that specifies the end Cell</param>
 public void AddCells(CellPos start, CellPos end)
 {
     this.AddCells(start.Row, start.Column, end.Row, end.Column);
 }
예제 #10
0
 /// <summary>
 /// Adds the Cells located between the specified start and end CellPos to the
 /// current selection without raising an event
 /// </summary>
 /// <param name="start">A CellPos that specifies the start Cell</param>
 /// <param name="end">A CellPos that specifies the end Cell</param>
 /// <returns>true if any Cells were added, false otherwise</returns>
 private bool InternalAddCells(CellPos start, CellPos end)
 {
     return(this.InternalAddCells(start.Row, start.Column, end.Row, end.Column));
 }
예제 #11
0
 /// <summary>
 /// Adds the Cell at the specified row and column indicies to the current selection
 /// </summary>
 /// <param name="cellPos">A CellPos that specifies the Cell to add to the selection</param>
 public void AddCell(CellPos cellPos)
 {
     this.AddCell(cellPos.Row, cellPos.Column);
 }
예제 #12
0
 /// <summary>
 /// Replaces the currently selected Cells with the Cells located between the specified
 /// start and end CellPos
 /// </summary>
 /// <param name="start">A CellPos that specifies the start Cell</param>
 /// <param name="end">A CellPos that specifies the end Cell</param>
 public void SelectCells(CellPos start, CellPos end)
 {
     this.SelectCells(start.Row, start.Column, end.Row, end.Column);
 }
예제 #13
0
 /// <summary>
 /// Replaces the currently selected Cells with the Cell at the specified CellPos
 /// </summary>
 /// <param name="cellPos">A CellPos thst specifies the row and column indicies of
 /// the Cell to be selected</param>
 public void SelectCell(CellPos cellPos)
 {
     this.SelectCell(cellPos.Row, cellPos.Column);
 }
예제 #14
0
파일: TableModel.cs 프로젝트: virl/yttrium
 /// <summary>
 /// Removes the Cell at the specified row and column indicies from the current selection
 /// </summary>
 /// <param name="cellPos">A CellPos that specifies the Cell to remove from the selection</param>
 public void RemoveCell(CellPos cellPos)
 {
     this.RemoveCell(cellPos.Row, cellPos.Column);
 }
예제 #15
0
파일: Table.cs 프로젝트: nithinphilips/SMOz
		/// <summary>
		/// Raises the MouseUp event
		/// </summary>
		/// <param name="e">A MouseEventArgs that contains the event data</param>
		protected override void OnMouseUp(MouseEventArgs e)
		{
			base.OnMouseUp(e);

			if (!this.CanRaiseEvents)
			{
				return;
			}

			// work out the current state of  play
			this.CalcTableState(e.X, e.Y);
			
			TableRegion region = this.HitTest(e.X, e.Y);

			if (e.Button == MouseButtons.Left)
			{
				// if the left mouse button was down for a cell, 
				// Raise a mouse up for that cell
				if (!this.LastMouseDownCell.IsEmpty)
				{
					if (this.IsValidCell(this.LastMouseDownCell))
					{
						this.RaiseCellMouseUp(this.LastMouseDownCell, e);
					}

					// reset the lastMouseDownCell
					this.lastMouseDownCell = CellPos.Empty;
				}

				// if we have just finished resizing, it might
				// be a good idea to relayout the table
				if (this.resizingColumnIndex != -1)
				{
					if (this.resizingColumnWidth != -1)
					{
						this.DrawReversibleLine(this.ColumnRect(this.resizingColumnIndex).Left + this.resizingColumnWidth);
					}
					
					this.ColumnModel.Columns[this.resizingColumnIndex].Width = this.resizingColumnWidth;
					
					this.resizingColumnIndex = -1;
					this.resizingColumnWidth = -1;

					this.UpdateScrollBars();
					this.Invalidate(this.PseudoClientRect, true);
				}

				// check if the mouse was released in a column header
				if (region == TableRegion.ColumnHeader)
				{
					int column = this.ColumnIndexAt(e.X, e.Y);

					// if we are in the header, check if we are in the pressed column
					if (this.pressedColumn != -1)
					{
						if (this.pressedColumn == column)
						{
							if (this.hotColumn != -1 && this.hotColumn != column)
							{
								this.ColumnModel.Columns[this.hotColumn].InternalColumnState = ColumnState.Normal;
							}
						
							this.ColumnModel.Columns[this.pressedColumn].InternalColumnState = ColumnState.Hot;

							this.RaiseHeaderMouseUp(column, e);
						}

						this.pressedColumn = -1;

						// only sort the column if we have rows to sort
						if (this.ColumnModel.Columns[column].Sortable)
						{
							if (this.TableModel != null && this.TableModel.Rows.Count > 0)
							{
								this.Sort(column);
							}
						}

						this.Invalidate(this.HeaderRectangle, false);
					}

					return;
				}

				// the mouse wasn't released in a column header, so if we 
				// have a pressed column then we need to make it unpressed
				if (this.pressedColumn != -1)
				{
					this.pressedColumn = -1;

					this.Invalidate(this.HeaderRectangle, false);
				}
			}
		}
예제 #16
0
파일: TableModel.cs 프로젝트: virl/yttrium
 /// <summary>
 /// Removes the Cells located between the specified start and end CellPos from the
 /// current selection
 /// </summary>
 /// <param name="start">A CellPos that specifies the start Cell</param>
 /// <param name="end">A CellPos that specifies the end Cell</param>
 public void RemoveCells(CellPos start, CellPos end)
 {
     this.RemoveCells(start.Row, start.Column, end.Row, end.Column);
 }
예제 #17
0
파일: Table.cs 프로젝트: nithinphilips/SMOz
		/// <summary>
		/// Raises the MouseMove event
		/// </summary>
		/// <param name="e">A MouseEventArgs that contains the event data</param>
		protected override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove(e);

			// don't go any further if the table is editing
			if (this.TableState == TableState.Editing)
			{
				return;
			}

			// if the left mouse button is down, check if the LastMouseDownCell 
			// references a valid cell.  if it does, send the mouse move message 
			// to the cell and then exit (this will stop other cells/headers 
			// from getting the mouse move message even if the mouse is over 
			// them - this seems consistent with the way windows does it for 
			// other controls)
			if (e.Button == MouseButtons.Left)
			{
				if (!this.LastMouseDownCell.IsEmpty)
				{
					if (this.IsValidCell(this.LastMouseDownCell))
					{
						this.RaiseCellMouseMove(this.LastMouseDownCell, e);

						return;
					}
				}
			}

			// are we resizing a column?
			if (this.resizingColumnIndex != -1)
			{
				if (this.resizingColumnWidth != -1)
				{
					this.DrawReversibleLine(this.ColumnRect(this.resizingColumnIndex).Left + this.resizingColumnWidth);
				}
				
				// calculate the new width for the column
				int width = this.ClientToDisplayRect(e.X, e.Y).X - this.resizingColumnAnchor - this.resizingColumnOffset;

				// make sure the new width isn't smaller than the minimum allowed
				// column width, or larger than the maximum allowed column width
				if (width < Column.MinimumWidth)
				{
					width = Column.MinimumWidth;
				}
				else if (width > Column.MaximumWidth)
				{
					width = Column.MaximumWidth;
				}

				this.resizingColumnWidth = width;
				
				//this.ColumnModel.Columns[this.resizingColumnIndex].Width = width;
				this.DrawReversibleLine(this.ColumnRect(this.resizingColumnIndex).Left + this.resizingColumnWidth);

				return;
			}

			// work out the potential state of play
			this.CalcTableState(e.X, e.Y);

			TableRegion hitTest = this.HitTest(e.X, e.Y);

			#region ColumnHeader

			if (hitTest == TableRegion.ColumnHeader)
			{
				// this next bit is pretty complicated. need to work 
				// out which column is displayed as pressed or hot 
				// (so we have the same behaviour as a themed ListView
				// in Windows XP)
				
				int column = this.ColumnIndexAt(e.X, e.Y);
				
				// if this isn't the current hot column, reset the
				// hot columns state to normal and set this column
				// to be the hot column
				if (this.hotColumn != column)
				{
					if (this.hotColumn != -1)
					{
						this.ColumnModel.Columns[this.hotColumn].InternalColumnState = ColumnState.Normal;

						this.RaiseHeaderMouseLeave(this.hotColumn);
					}

					if (this.TableState != TableState.ColumnResizing)
					{
						this.hotColumn = column;				

						if (this.hotColumn != -1 && this.ColumnModel.Columns[column].Enabled)
						{
							this.ColumnModel.Columns[column].InternalColumnState = ColumnState.Hot;

							this.RaiseHeaderMouseEnter(column);
						}
					}
				}
				else
				{
					if (column != -1 && this.ColumnModel.Columns[column].Enabled)
					{
						this.RaiseHeaderMouseMove(column, e);
					}
				}
				
				// if this isn't the pressed column, then the pressed columns
				// state should be set back to normal
				if (this.pressedColumn != -1 && this.pressedColumn != column)
				{
					this.ColumnModel.Columns[this.pressedColumn].InternalColumnState = ColumnState.Normal;
				}
					// else if this is the pressed column and its state is not
					// pressed, then we had better set it
				else if (column != -1 && this.pressedColumn == column && this.ColumnModel.Columns[this.pressedColumn].ColumnState != ColumnState.Pressed)
				{
					this.ColumnModel.Columns[this.pressedColumn].InternalColumnState = ColumnState.Pressed;
				}
				
				// set the cursor to a resizing cursor if necesary
				if (this.TableState == TableState.ColumnResizing)
				{
					Rectangle columnRect = this.ColumnModel.ColumnHeaderRect(column);
					int x = this.ClientToDisplayRect(e.X, e.Y).X;
					
					this.Cursor = Cursors.VSplit;

					// if the left mouse button is down, we don't want
					// the resizing cursor so set it back to the default
					if (e.Button == MouseButtons.Left)
					{
						this.Cursor = Cursors.Default;
					}
					
					// if the mouse is in the left side of the column, 
					// the first non-hidden column to the left needs to
					// become the hot column (so the user knows which
					// column would be resized if a resize action were
					// to take place
					if (x < columnRect.Left + Column.ResizePadding)
					{
						int col = column;
					
						while (col != 0)
						{
							col--;
						
							if (this.ColumnModel.Columns[col].Visible)
							{
								break;
							}
						}

						if (col != -1)
						{
							if (this.ColumnModel.Columns[col].Enabled)
							{
								if (this.hotColumn != -1)
								{
									this.ColumnModel.Columns[this.hotColumn].InternalColumnState = ColumnState.Normal;
								}						
							
								this.hotColumn = col;
								this.ColumnModel.Columns[this.hotColumn].InternalColumnState = ColumnState.Hot;

								this.RaiseHeaderMouseEnter(col);
							}
							else
							{
								this.Cursor = Cursors.Default;
							}
						}
					}
					else 
					{
						if (this.ColumnModel.Columns[column].Enabled)
						{
							// this mouse is in the right side of the column, 
							// so this column needs to be dsiplayed hot
							this.hotColumn = column;
							this.ColumnModel.Columns[this.hotColumn].InternalColumnState = ColumnState.Hot;
						}
						else
						{
							this.Cursor = Cursors.Default;
						}
					}
				}
				else
				{
					// we're not in a resizing area, so make sure the cursor
					// is the default cursor (we may have just come from a
					// resizing area)
					this.Cursor = Cursors.Default;
				}

				// reset the last cell the mouse was over
				this.ResetLastMouseCell();

				return;
			}
			
			#endregion

			// we're outside of the header, so if there is a hot column,
			// it need to be reset
			if (this.hotColumn != -1)
			{
				this.ColumnModel.Columns[this.hotColumn].InternalColumnState = ColumnState.Normal;
				this.ResetHotColumn();
				this.Cursor = Cursors.Default;
			}

			// if there is a pressed column, its state need to beset to normal
			if (this.pressedColumn != -1)
			{
				this.ColumnModel.Columns[this.pressedColumn].InternalColumnState = ColumnState.Normal;
			}

			#region Cells

			if (hitTest == TableRegion.Cells)
			{
				// find the cell the mouse is over
				CellPos cellPos = new CellPos(this.RowIndexAt(e.X, e.Y), this.ColumnIndexAt(e.X, e.Y));

				if (!cellPos.IsEmpty)
				{
					if (cellPos != this.lastMouseCell)
					{
						// check if the cell exists (ie is not null)
						if (this.IsValidCell(cellPos))
						{
							CellPos oldLastMouseCell = this.lastMouseCell;
							
							if (!oldLastMouseCell.IsEmpty)
							{
								this.ResetLastMouseCell();
							}

							this.lastMouseCell = cellPos;

							this.RaiseCellMouseEnter(cellPos);
						}
						else
						{
							this.ResetLastMouseCell();

							// make sure the cursor is the default cursor 
							// (we may have just come from a resizing area in the header)
							this.Cursor = Cursors.Default;
						}
					}
					else
					{
						this.RaiseCellMouseMove(cellPos, e);
					}
				}
				else
				{
					this.ResetLastMouseCell();

					if (this.TableModel == null)
					{
						this.ResetToolTip();
					}
				}

				return;
			}
			else
			{
				this.ResetLastMouseCell();

				if (!this.lastMouseDownCell.IsEmpty)
				{
					this.RaiseCellMouseLeave(this.lastMouseDownCell);
				}

				if (this.TableModel == null)
				{
					this.ResetToolTip();
				}

				// make sure the cursor is the default cursor 
				// (we may have just come from a resizing area in the header)
				this.Cursor = Cursors.Default;
			}
		
			#endregion
		}
예제 #18
0
 /// <summary>
 /// Returns whether the Cell at the specified CellPos is currently selected
 /// </summary>
 /// <param name="cellPos">A CellPos the represents the row and column indicies
 /// of the Cell to check</param>
 /// <returns>true if the Cell at the specified CellPos is currently selected,
 /// false otherwise</returns>
 public bool IsCellSelected(CellPos cellPos)
 {
     return(this.IsCellSelected(cellPos.Row, cellPos.Column));
 }
예제 #19
0
파일: Table.cs 프로젝트: nithinphilips/SMOz
		/*/// <summary>
		/// Specifies whether pressing the Tab key while editing moves the 
		/// editor to the next available cell
		/// </summary>
		private bool tabMovesEditor;*/

		#endregion

		#endregion


		#region Constructor

		/// <summary>
		/// Initializes a new instance of the Table class with default settings
		/// </summary>
		public Table()
		{
			// starting setup
			this.init = true;
			
			// This call is required by the Windows.Forms Form Designer.
			components = new System.ComponentModel.Container();

			//
			this.SetStyle(ControlStyles.UserPaint, true);
			this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			this.SetStyle(ControlStyles.DoubleBuffer, true);
			this.SetStyle(ControlStyles.ResizeRedraw, true);
			this.SetStyle(ControlStyles.Selectable, true);
			this.TabStop = true;

			this.Size = new Size(150, 150);

			this.BackColor = Color.White;

			//
			this.columnModel = null;
			this.tableModel = null;

			// header
			this.headerStyle = ColumnHeaderStyle.Clickable;
			this.headerFont = this.Font;
			this.headerRenderer = new XPHeaderRenderer();
			//this.headerRenderer = new GradientHeaderRenderer();
			//this.headerRenderer = new FlatHeaderRenderer();
			this.headerRenderer.Font = this.headerFont;
			this.headerContextMenu = new HeaderContextMenu();
			
			this.columnResizing = true;
			this.resizingColumnIndex = -1;
			this.resizingColumnWidth = -1;
			this.hotColumn = -1;
			this.pressedColumn = -1;
			this.lastSortedColumn = -1;
			this.sortedColumnBackColor = Color.WhiteSmoke;

			// borders
			this.borderStyle = BorderStyle.Fixed3D;

			// scrolling
			this.scrollable = true;

			this.hScrollBar = new HScrollBar();
			this.hScrollBar.Visible = false;
			this.hScrollBar.Location = new Point(this.BorderWidth, this.Height - this.BorderWidth - SystemInformation.HorizontalScrollBarHeight);
			this.hScrollBar.Width = this.Width - (this.BorderWidth * 2) - SystemInformation.VerticalScrollBarWidth;
			this.hScrollBar.Scroll += new ScrollEventHandler(this.OnHorizontalScroll);
			this.Controls.Add(this.hScrollBar);

			this.vScrollBar = new VScrollBar();
			this.vScrollBar.Visible = false;
			this.vScrollBar.Location = new Point(this.Width - this.BorderWidth - SystemInformation.VerticalScrollBarWidth, this.BorderWidth);
			this.vScrollBar.Height = this.Height - (this.BorderWidth * 2) - SystemInformation.HorizontalScrollBarHeight;
			this.vScrollBar.Scroll += new ScrollEventHandler(this.OnVerticalScroll);
			this.Controls.Add(this.vScrollBar);

			//
			this.gridLines = GridLines.None;;
			this.gridColor = SystemColors.Control;
			this.gridLineStyle = GridLineStyle.Solid;

			this.allowSelection = true;
			this.multiSelect = false;
			this.fullRowSelect = false;
			this.hideSelection = false;
			this.selectionBackColor = SystemColors.Highlight;
			this.selectionForeColor = SystemColors.HighlightText;
			this.unfocusedSelectionBackColor = SystemColors.Control;
			this.unfocusedSelectionForeColor = SystemColors.ControlText;
			this.selectionStyle = SelectionStyle.ListView;
			this.alternatingRowColor = Color.Transparent;

			// current table state
			this.tableState = TableState.Normal;

			this.lastMouseCell = new CellPos(-1, -1);
			this.lastMouseDownCell = new CellPos(-1, -1);
			this.focusedCell = new CellPos(-1, -1);
			this.hoverTime = 1000;
			this.trackMouseEvent = null;
			this.ResetMouseEventArgs();

			this.toolTip = new ToolTip(this.components);
			this.toolTip.Active = false;
			this.toolTip.InitialDelay = 1000;

			this.noItemsText = "There are no items in this view";

			this.editingCell = new CellPos(-1, -1);
			this.curentCellEditor = null;
			this.editStartAction = EditStartAction.DoubleClick;
			this.customEditKey = Keys.F5;
			//this.tabMovesEditor = true;

			// finished setting up
			this.beginUpdateCount = 0;
			this.init = false;
			this.preview = false;
		}
예제 #20
0
 /// <summary>
 /// Initializes a new instance of the CellMouseEventArgs class with 
 /// the specified source Cell, table, row index, column index and 
 /// cell bounds
 /// </summary>
 /// <param name="cell">The Cell that Raised the event</param>
 /// <param name="table">The Table the Cell belongs to</param>
 /// <param name="cellPos"></param>
 /// <param name="cellRect">The Cell's bounding rectangle</param>
 /// <param name="mea"></param>
 public CellMouseEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, MouseEventArgs mea)
     : base(mea.Button, mea.Clicks, mea.X, mea.Y, mea.Delta)
 {
     this.cell = cell;
     this.table = table;
     this.row = cellPos.Row;
     this.column = cellPos.Column;
     this.cellRect = cellRect;
 }
예제 #21
0
파일: Table.cs 프로젝트: nithinphilips/SMOz
		/// <summary>
		/// Raises the CellRemoved event
		/// </summary>
		/// <param name="e">A RowEventArgs that contains the event data</param>
		protected internal virtual void OnCellRemoved(RowEventArgs e)
		{
			if (this.CanRaiseEvents)
			{
				this.InvalidateRow(e.Index);

				if (CellRemoved != null)
				{
					CellRemoved(this, e);
				}

				if (e.CellFromIndex == -1 && e.CellToIndex == -1)
				{
					if (this.FocusedCell.Row == e.Index)
					{
						this.focusedCell = CellPos.Empty;
					}
				}
				else
				{
					for (int i=e.CellFromIndex; i<=e.CellToIndex; i++)
					{
						if (this.FocusedCell.Row == e.Index && this.FocusedCell.Column == i)
						{
							this.focusedCell = CellPos.Empty;

							break;
						}
					}
				}
			}
		}
예제 #22
0
파일: TableModel.cs 프로젝트: virl/yttrium
 /// <summary>
 /// Removes the Cells located between the specified start and end CellPos from the
 /// current selection without raising an event
 /// </summary>
 /// <param name="start">A CellPos that specifies the start Cell</param>
 /// <param name="end">A CellPos that specifies the end Cell</param>
 /// <returns>true if any Cells were added, false otherwise</returns>
 private bool InternalRemoveCells(CellPos start, CellPos end)
 {
     return this.InternalRemoveCells(start.Row, start.Column, end.Row, end.Column);
 }
예제 #23
0
파일: Table.cs 프로젝트: nithinphilips/SMOz
		/// <summary>
		/// Returns a Rectangle that specifies the size and location the cell at 
		/// the specified cell position in client coordinates
		/// </summary>
		/// <param name="cellPos">The position of the cell</param>
		/// <returns>A Rectangle that specifies the size and location the cell at 
		/// the specified cell position in client coordinates</returns>
		public Rectangle CellRect(CellPos cellPos)
		{
			return this.CellRect(cellPos.Row, cellPos.Column);
		}
예제 #24
0
파일: TableModel.cs 프로젝트: virl/yttrium
            /// <summary>
            /// Initializes a new instance of the TableModel.Selection class 
            /// that belongs to the specified TableModel
            /// </summary>
            /// <param name="owner">A TableModel representing the tableModel that owns 
            /// the Selection</param>
            public Selection(TableModel owner)
            {
                if (owner == null)
                {
                    throw new ArgumentNullException("owner", "owner cannot be null");
                }

                this.owner = owner;
                this.rows = new ArrayList();

                this.shiftSelectStart = CellPos.Empty;
                this.shiftSelectEnd = CellPos.Empty;
            }
		/// <summary>
		/// Gets whether the specified Table is using a NumericCellEditor to edit the 
		/// Cell at the specified CellPos
		/// </summary>
		/// <param name="table">The Table to check</param>
		/// <param name="cellPos">A CellPos that represents the Cell to check</param>
		/// <returns>true if the specified Table is using a NumericCellEditor to edit the 
		/// Cell at the specified CellPos, false otherwise</returns>
		internal bool TableUsingNumericCellEditor(Table table, CellPos cellPos)
		{
			return (table.IsEditing && cellPos == table.EditingCell && table.EditingCellEditor is NumberCellEditor);
		}
예제 #26
0
파일: TableModel.cs 프로젝트: virl/yttrium
 /// <summary>
 /// Adds the Cells located between the specified start and end CellPos to the
 /// current selection
 /// </summary>
 /// <param name="start">A CellPos that specifies the start Cell</param>
 /// <param name="end">A CellPos that specifies the end Cell</param>
 public void AddCells(CellPos start, CellPos end)
 {
     this.AddCells(start.Row, start.Column, end.Row, end.Column);
 }
예제 #27
0
        void table_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!AllowSelection) return;

            int cindex = ColumnIndexAt(e.X, e.Y);
            if (cindex!=0) return;

            int rindex = RowIndexAt(e.X, e.Y, true); // take virtual row
            if (rindex < 0) return;
            if (TableModel.Rows.Count > rindex) return;

            // we need to create new row and start edit mode
            int rowsToAdd = rindex - TableModel.Rows.Count + 1;
            while (rowsToAdd > 0)
            {
                VisualizeFilter("");
                rowsToAdd--;
            }

            lastMouseCell = new CellPos(rindex, 0);
            FocusedCell = lastMouseCell;
            TableModel.Selections.SelectCell(lastMouseCell);
            base.OnDoubleClick(e);
        }
예제 #28
0
파일: TableModel.cs 프로젝트: virl/yttrium
 /// <summary>
 /// Adds the Cells between the last selection start Cell and the Cell at the 
 /// specified CellPas to the current selection.  Any Cells that are 
 /// between the last start and end Cells that are not in the new area are 
 /// removed from the current selection
 /// </summary>
 /// <param name="cellPos">A CellPos that specifies the shift selected Cell</param>
 public void AddShiftSelectedCell(CellPos cellPos)
 {
     this.AddShiftSelectedCell(cellPos.Row, cellPos.Column);
 }
예제 #29
0
파일: Demo.cs 프로젝트: antiduh/XPTable
 private void button1_Click(object sender, System.EventArgs e)
 {
     CellPos cell = new CellPos((int)numericUpDown1.Value, 0);
     table.TableModel.Selections.AddCell(cell);
     table.EnsureVisible(cell);
 }
예제 #30
0
파일: TableModel.cs 프로젝트: virl/yttrium
 /// <summary>
 /// Returns whether the Cell at the specified CellPos is currently selected
 /// </summary>
 /// <param name="cellPos">A CellPos the represents the row and column indicies 
 /// of the Cell to check</param>
 /// <returns>true if the Cell at the specified CellPos is currently selected, 
 /// false otherwise</returns>
 public bool IsCellSelected(CellPos cellPos)
 {
     return this.IsCellSelected(cellPos.Row, cellPos.Column);
 }
예제 #31
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 virtual bool PrepareForEditing(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, bool userSetEditorValues)
        {
            this.cell = cell;
            this.table = table;
            this.cellPos = cellPos;
            this.cellRect = cellRect;

            // check if the user has already set the editors value for us
            if (!userSetEditorValues)
            {
                this.SetEditValue();
            }

            this.SetEditLocation(cellRect);

            // raise the BeginEdit event
            var e = new CellEditEventArgs(cell, this, table, cellPos.Row, cellPos.Column, cellRect)
                        {
                            Handled = userSetEditorValues
                        };

            this.OnBeginEdit(e);

            // if the edit has been canceled, remove the editor and return false
            if (e.Cancel)
            {
                this.RemoveEditControl();
                return false;
            }

            return true;
        }
예제 #32
0
파일: TableModel.cs 프로젝트: virl/yttrium
            /// <summary>
            /// Removes the Cells located between the specified start and end row/column indicies 
            /// from the current selection
            /// </summary>
            /// <param name="startRow">The row index of the start Cell</param>
            /// <param name="startColumn">The column index of the start Cell</param>
            /// <param name="endRow">The row index of the end Cell</param>
            /// <param name="endColumn">The column index of the end Cell</param>
            public void RemoveCells(int startRow, int startColumn, int endRow, int endColumn)
            {
                if (this.rows.Count > 0)
                {
                    int[] oldSelectedIndicies = this.SelectedIndicies;

                    if (this.InternalRemoveCells(startRow, startColumn, endRow, endColumn))
                    {
                        this.owner.OnSelectionChanged(new SelectionEventArgs(this.owner, oldSelectedIndicies, this.SelectedIndicies));
                    }

                    this.shiftSelectStart = new CellPos(startRow, startColumn);
                    this.shiftSelectEnd = new CellPos(endRow, endColumn);
                }
            }
예제 #33
0
        /// <summary>
        /// Conceals the editor from the user and removes it from the Table's 
        /// Control collection
        /// </summary>
        protected virtual void RemoveEditControl()
        {
            if (this.control != null)
            {
                this.control.Visible = false;
                this.control.Parent = null;
            }

            if (this.table != null)
            {
                this.table.Focus();
            }

            this.cell = null;
            this.table = null;
            this.cellPos = CellPos.Empty;
            this.cellRect = Rectangle.Empty;
        }
예제 #34
0
파일: TableModel.cs 프로젝트: virl/yttrium
 /// <summary>
 /// Replaces the currently selected Cells with the Cell at the specified CellPos
 /// </summary>
 /// <param name="cellPos">A CellPos thst specifies the row and column indicies of 
 /// the Cell to be selected</param>
 public void SelectCell(CellPos cellPos)
 {
     this.SelectCell(cellPos.Row, cellPos.Column);
 }
예제 #35
0
        /// <summary>
        /// Initializes a new instance of the CellEditor class with default settings
        /// </summary>
        protected CellEditor()
        {
            this.control = null;
            this.cell = null;
            this.table = null;
            this.cellPos = CellPos.Empty;
            this.cellRect = Rectangle.Empty;

            this.mouseMessageFilter = new MouseMessageFilter(this);
            this.keyMessageFilter = new KeyMessageFilter(this);
        }
예제 #36
0
파일: TableModel.cs 프로젝트: virl/yttrium
 /// <summary>
 /// Replaces the currently selected Cells with the Cells located between the specified 
 /// start and end CellPos
 /// </summary>
 /// <param name="start">A CellPos that specifies the start Cell</param>
 /// <param name="end">A CellPos that specifies the end Cell</param>
 public void SelectCells(CellPos start, CellPos end)
 {
     this.SelectCells(start.Row, start.Column, end.Row, end.Column);
 }
예제 #37
0
 /// <summary>
 /// Removes the Cells located between the specified start and end CellPos from the
 /// current selection
 /// </summary>
 /// <param name="start">A CellPos that specifies the start Cell</param>
 /// <param name="end">A CellPos that specifies the end Cell</param>
 public void RemoveCells(CellPos start, CellPos end)
 {
     this.RemoveCells(start.Row, start.Column, end.Row, end.Column);
 }