Esempio n. 1
0
        /// <summary>
        /// Creates the ClickedCellInfo from the data grid and the mouse coordinates of the click.
        /// </summary>
        /// <param name="positionX">The horizontal position value.</param>
        /// <param name="positionY">The vertical position value.</param>
        /// <param name="layout">The worksheet area.</param>
        /// <param name="HorzScrollPos">Value of the horizontal scroll bar.</param>
        /// <param name="VertScrollPos">Value of the vertical scroll bar.</param>
        public static AreaInfo GetAreaType(double positionX, double positionY, WorksheetLayout layout, int HorzScrollPos, int VertScrollPos)
        {
            //var _clickedCellRectangle = new Rect(0,0,0,0);
            var      hittedColumn = GetColumnNumber(positionX, layout, HorzScrollPos, out var left, out var width);
            var      hittedRow    = GetRowNumber(positionY, layout, VertScrollPos, out var top, out var height, out var bIsPropertyColumn);
            AreaType hittedAreaType;

            if (bIsPropertyColumn)
            {
                if (hittedColumn == -1)
                {
                    hittedAreaType = AreaType.PropertyColumnHeader;
                }
                else if (hittedColumn >= 0)
                {
                    hittedAreaType = AreaType.PropertyCell;
                }
                else
                {
                    hittedAreaType = AreaType.OutsideAll;
                }

                // Swap columns and rows since it is a property column
                int h = hittedColumn;
                hittedColumn = hittedRow;
                hittedRow    = h;
            }
            else // it is not a property related cell
            {
                if (hittedRow == -1 && hittedColumn == -1)
                {
                    hittedAreaType = AreaType.TableHeader;
                }
                else if (hittedRow == -1 && hittedColumn >= 0)
                {
                    hittedAreaType = AreaType.DataColumnHeader;
                }
                else if (hittedRow >= 0 && hittedColumn == -1)
                {
                    hittedAreaType = AreaType.DataRowHeader;
                }
                else if (hittedRow >= 0 && hittedColumn >= 0)
                {
                    hittedAreaType = AreaType.DataCell;
                }
                else
                {
                    hittedAreaType = AreaType.OutsideAll;
                }
            }

            var result = new AreaInfo()
            {
                ColumnNumber  = hittedColumn,
                RowNumber     = hittedRow,
                AreaRectangle = new RectangleD2D(left, top, width, height),
                AreaType      = hittedAreaType
            };

            return(result);
        }
Esempio n. 2
0
		/// <summary>
		/// Creates the ClickedCellInfo from the data grid and the mouse coordinates of the click.
		/// </summary>
		/// <param name="positionX">The horizontal position value.</param>
		/// <param name="positionY">The vertical position value.</param>
		/// <param name="layout">The worksheet area.</param>
		/// <param name="HorzScrollPos">Value of the horizontal scroll bar.</param>
		/// <param name="VertScrollPos">Value of the vertical scroll bar.</param>
		public static AreaInfo GetAreaType(double positionX, double positionY, WorksheetLayout layout, int HorzScrollPos, int VertScrollPos)
		{
			bool bIsPropertyColumn = false;
			double left, top, width, height; // coordinates of clicked cell
																			 //var _clickedCellRectangle = new Rect(0,0,0,0);
			var hittedColumn = GetColumnNumber(positionX, layout, HorzScrollPos, out left, out width);
			var hittedRow = GetRowNumber(positionY, layout, VertScrollPos, out top, out height, out bIsPropertyColumn);
			AreaType hittedAreaType;

			if (bIsPropertyColumn)
			{
				if (hittedColumn == -1)
					hittedAreaType = AreaType.PropertyColumnHeader;
				else if (hittedColumn >= 0)
					hittedAreaType = AreaType.PropertyCell;
				else
					hittedAreaType = AreaType.OutsideAll;

				// Swap columns and rows since it is a property column
				int h = hittedColumn;
				hittedColumn = hittedRow;
				hittedRow = h;
			}
			else // it is not a property related cell
			{
				if (hittedRow == -1 && hittedColumn == -1)
					hittedAreaType = AreaType.TableHeader;
				else if (hittedRow == -1 && hittedColumn >= 0)
					hittedAreaType = AreaType.DataColumnHeader;
				else if (hittedRow >= 0 && hittedColumn == -1)
					hittedAreaType = AreaType.DataRowHeader;
				else if (hittedRow >= 0 && hittedColumn >= 0)
					hittedAreaType = AreaType.DataCell;
				else
					hittedAreaType = AreaType.OutsideAll;
			}

			AreaInfo result = new AreaInfo()
			{
				ColumnNumber = hittedColumn,
				RowNumber = hittedRow,
				AreaRectangle = new RectangleD2D(left, top, width, height),
				AreaType = hittedAreaType
			};
			return result;
		}