protected override void OnPaint(PaintEventArgs e) { GridSubPanelType panelType = ContainerType; if (panelType == GridSubPanelType.Hidden) { return; } base.OnPaint(e); using (DevAge.Drawing.GraphicsCache graphics = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle)) { if (panelType == GridSubPanelType.TopLeft) { m_GridContainer.OnTopLeftPanelPaint(graphics); } else if (panelType == GridSubPanelType.Left) { m_GridContainer.OnLeftPanelPaint(graphics); } else if (panelType == GridSubPanelType.Top) { m_GridContainer.OnTopPanelPaint(graphics); } else //scrollable { m_GridContainer.OnScrollablePanelPaint(graphics); } } ////Use this code to test panels //e.Graphics.DrawEllipse(Pens.Black, ClientRectangle); //e.Graphics.DrawString(ContainerType.ToString(), Font, Brushes.Black, ClientRectangle); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //#warning temporaneo per testare i panels // GridSubPanelType l_Type = ContainerType; // if (l_Type == GridSubPanelType.TopLeft) // e.Graphics.FillRectangle(new SolidBrush(Color.Yellow),e.ClipRectangle); // else if (l_Type == GridSubPanelType.Left) // e.Graphics.FillRectangle(new SolidBrush(Color.Red),e.ClipRectangle); // else if (l_Type == GridSubPanelType.Top) // e.Graphics.FillRectangle(new SolidBrush(Color.Green),e.ClipRectangle); // else // e.Graphics.FillRectangle(new SolidBrush(Color.Black),e.ClipRectangle); // ControlPaint.DrawBorder(e.Graphics, DisplayRectangle,Color.Blue,ButtonBorderStyle.Solid); GridSubPanelType l_Type = ContainerType; if (l_Type == GridSubPanelType.TopLeft) { m_GridContainer.OnTopLeftPanelPaint(e); } else if (l_Type == GridSubPanelType.Left) { m_GridContainer.OnLeftPanelPaint(e); } else if (l_Type == GridSubPanelType.Top) { m_GridContainer.OnTopPanelPaint(e); } else //scrollable { m_GridContainer.OnScrollablePanelPaint(e); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); using (DevAge.Drawing.GraphicsCache graphics = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle)) { GridSubPanelType l_Type = ContainerType; if (l_Type == GridSubPanelType.TopLeft) { m_GridContainer.OnTopLeftPanelPaint(graphics); } else if (l_Type == GridSubPanelType.Left) { m_GridContainer.OnLeftPanelPaint(graphics); } else if (l_Type == GridSubPanelType.Top) { m_GridContainer.OnTopPanelPaint(graphics); } else //scrollable { m_GridContainer.OnScrollablePanelPaint(graphics); } } }
/// <summary> /// Constructor /// </summary> /// <param name="gridContainer"></param> /// <param name="containerType"></param> public GridSubPanelBase(GridVirtual gridContainer, GridSubPanelType containerType) { ContainerType = containerType; toolTip = new System.Windows.Forms.ToolTip(); ToolTipText = ""; m_GridContainer = gridContainer; }
/// <summary> /// Constructor /// </summary> /// <param name="gridContainer"></param> /// <param name="containerType"></param> public GridSubPanelBase(GridVirtual gridContainer, GridSubPanelType containerType) { ContainerType = containerType; toolTip = new System.Windows.Forms.ToolTip(); ToolTipText = ""; m_GridContainer = gridContainer; }
public GridSubPanel(GridVirtual gridContainer, GridSubPanelType containerType) : base(gridContainer, containerType) { AllowDrop = true; //to remove flicker and use custom draw SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.ContainerControl, true); SetStyle(ControlStyles.Selectable, false); m_ControlsRepository = new ControlsRepository(this); TabStop = false; //The grid control is a special control and usually don't receive the focus with the Tab }
public GridSubPanel(GridVirtual gridContainer, GridSubPanelType containerType) : base(gridContainer, containerType) { AllowDrop = true; //to remove flicker and use custom draw SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.ContainerControl, true); SetStyle(ControlStyles.Selectable, false); m_ControlsRepository = new ControlsRepository(this); TabStop = false; //The grid control is a special control and usually don't receive the focus with the Tab }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); GridSubPanelType l_Type = ContainerType; switch (l_Type) { case GridSubPanelType.TopLeft: gridContainer.OnTopLeftPanelPaint(e); break; case GridSubPanelType.Top: gridContainer.OnTopPanelPaint(e); break; case GridSubPanelType.Left: gridContainer.OnLeftPanelPaint(e); break; default: gridContainer.OnScrollablePanelPaint(e); break; } }
/// <summary> /// Returns a range of cells from the specified rectangle, relative to the current grid container, using scrolling information. /// </summary> /// <param name="p_RelativeRect">A grid relative rectangle (not panel relative)</param> /// <returns></returns> public Range RangeAtDisplayRect(Rectangle p_RelativeRect) { Rectangle l_Absolute = gridContainer.RectangleRelativeToAbsolute(p_RelativeRect); GridSubPanelType l_Type = ContainerType; if (l_Type == GridSubPanelType.TopLeft) { return RangeAtAbsRect(new Rectangle(p_RelativeRect.X, p_RelativeRect.Y, l_Absolute.Width, l_Absolute.Height)); } else if (l_Type == GridSubPanelType.Top) { return RangeAtAbsRect(new Rectangle(l_Absolute.X, p_RelativeRect.Y, l_Absolute.Width, l_Absolute.Height)); } else if (l_Type == GridSubPanelType.Left) { return RangeAtAbsRect(new Rectangle(p_RelativeRect.X, l_Absolute.Y, l_Absolute.Width, l_Absolute.Height)); } else//scrollable { return RangeAtAbsRect(l_Absolute); } }
/// <summary> /// Returns a range of cells from the specified absolute rectangle. Returns Empty if no valid cells are found. /// </summary> /// <param name="p_AbsoluteRect">The absolute rectangle.</param> /// <returns></returns> public Range RangeAtAbsRect(Rectangle p_AbsoluteRect) { int l_Start_R, l_Start_C, l_End_R, l_End_C; GridSubPanelType l_Type = ContainerType; Range l_tmp = gridContainer.RangeAtAbsRect(p_AbsoluteRect); if (l_tmp.IsEmpty()) { return l_tmp; } l_Start_R = l_tmp.Start.Row; l_Start_C = l_tmp.Start.Column; l_End_R = l_tmp.End.Row; l_End_C = l_tmp.End.Column; if (l_Type == GridSubPanelType.TopLeft) { if (l_Start_R >= gridContainer.FixedRows) { l_Start_R = Position.EmptyIndex; } if (l_Start_C >= gridContainer.FixedColumns) { l_Start_C = Position.EmptyIndex; } if (l_End_R >= gridContainer.FixedRows) { l_End_R = gridContainer.FixedRows - 1; } if (l_End_C >= gridContainer.FixedColumns) { l_End_C = gridContainer.FixedColumns - 1; } } else if (l_Type == GridSubPanelType.Top) { if (l_Start_R >= gridContainer.FixedRows) { l_Start_R = Position.EmptyIndex; } if (l_End_R >= gridContainer.FixedRows) { l_End_R = gridContainer.FixedRows - 1; } if (l_Start_C < gridContainer.FixedColumns) { l_Start_C = gridContainer.FixedColumns; if (l_Start_C >= gridContainer.ColumnsCount) { l_Start_C = Position.EmptyIndex; } } if (l_End_C < gridContainer.FixedColumns) { l_End_C = gridContainer.FixedColumns; if (l_End_C >= gridContainer.ColumnsCount) { l_End_C = Position.EmptyIndex; } } } else if (l_Type == GridSubPanelType.Left) { if (l_Start_C >= gridContainer.FixedColumns) { l_Start_C = Position.EmptyIndex; } if (l_End_C >= gridContainer.FixedColumns) { l_End_C = gridContainer.FixedColumns - 1; } if (l_Start_R < gridContainer.FixedRows) { l_Start_R = gridContainer.FixedRows; if (l_Start_R >= gridContainer.RowsCount) { l_Start_R = Position.EmptyIndex; } } if (l_End_R < gridContainer.FixedRows) { l_End_R = gridContainer.FixedRows; if (l_End_R >= gridContainer.RowsCount) { l_End_R = Position.EmptyIndex; } } } if (l_Start_R == Position.EmptyIndex || l_Start_C == Position.EmptyIndex || l_End_C == Position.EmptyIndex || l_End_R == Position.EmptyIndex) { return Range.Empty; } return new Range(l_Start_R, l_Start_C, l_End_R, l_End_C); }
/// <summary> /// Returns the cell at the specified grid view relative point (the point must be relative to the grid display region not to the panel display region) /// </summary> /// <param name="p_RelativeViewPoint">Point</param> /// <returns></returns> public virtual Position PositionAtPoint(Point p_RelativeViewPoint) { int l_Row, l_Col; GridSubPanelType l_Type = ContainerType; if (l_Type == GridSubPanelType.TopLeft) { l_Row = gridContainer.Rows.RowAtPoint(p_RelativeViewPoint.Y, true); l_Col = gridContainer.Columns.ColumnAtPoint(p_RelativeViewPoint.X, true); if (l_Row >= gridContainer.FixedRows) { l_Row = Position.EmptyIndex; } if (l_Col >= gridContainer.FixedColumns) { l_Col = Position.EmptyIndex; } } else if (l_Type == GridSubPanelType.Top) { Point l_AbsPoint = gridContainer.PointRelativeToAbsolute(p_RelativeViewPoint); l_Row = gridContainer.Rows.RowAtPoint(p_RelativeViewPoint.Y, true); l_Col = gridContainer.Columns.ColumnAtPoint(l_AbsPoint.X, true); if (l_Row >= gridContainer.FixedRows) { l_Row = Position.EmptyIndex; } if (l_Col < gridContainer.FixedColumns) { l_Col = Position.EmptyIndex; } } else if (l_Type == GridSubPanelType.Left) { Point l_AbsPoint = gridContainer.PointRelativeToAbsolute(p_RelativeViewPoint); l_Row = gridContainer.Rows.RowAtPoint(l_AbsPoint.Y, true); l_Col = gridContainer.Columns.ColumnAtPoint(p_RelativeViewPoint.X, true); if (l_Col >= gridContainer.FixedColumns) { l_Col = Position.EmptyIndex; } if (l_Row < gridContainer.FixedRows) { l_Row = Position.EmptyIndex; } } else //scrollable { Point l_AbsPoint = gridContainer.PointRelativeToAbsolute(p_RelativeViewPoint); l_Row = gridContainer.Rows.RowAtPoint(l_AbsPoint.Y, true); l_Col = gridContainer.Columns.ColumnAtPoint(l_AbsPoint.X, true); } if (l_Row == Position.EmptyIndex || l_Col == Position.EmptyIndex) { return Position.Empty; } return new Position(l_Row, l_Col); }
/// <summary> /// Returns a range of cells from the specified absolute rectangle. Returns Empty if no valid cells are found. /// </summary> /// <param name="p_AbsoluteRect"></param> /// <returns></returns> public Range RangeAtAbsRect(Rectangle p_AbsoluteRect) { int l_Start_R, l_Start_C, l_End_R, l_End_C; GridSubPanelType l_Type = ContainerType; Range l_tmp = m_GridContainer.RangeAtAbsRect(p_AbsoluteRect); if (l_tmp.IsEmpty()) { return(l_tmp); } l_Start_R = l_tmp.Start.Row; l_Start_C = l_tmp.Start.Column; l_End_R = l_tmp.End.Row; l_End_C = l_tmp.End.Column; if (l_Type == GridSubPanelType.TopLeft) { if (l_Start_R >= m_GridContainer.FixedRows) { l_Start_R = Position.c_EmptyIndex; } if (l_Start_C >= m_GridContainer.FixedColumns) { l_Start_C = Position.c_EmptyIndex; } if (l_End_R >= m_GridContainer.FixedRows) { l_End_R = m_GridContainer.FixedRows - 1; } if (l_End_C >= m_GridContainer.FixedColumns) { l_End_C = m_GridContainer.FixedColumns - 1; } } else if (l_Type == GridSubPanelType.Top) { if (l_Start_R >= m_GridContainer.FixedRows) { l_Start_R = Position.c_EmptyIndex; } if (l_End_R >= m_GridContainer.FixedRows) { l_End_R = m_GridContainer.FixedRows - 1; } if (l_Start_C < m_GridContainer.FixedColumns) { l_Start_C = m_GridContainer.FixedColumns; if (l_Start_C >= m_GridContainer.ColumnsCount) { l_Start_C = Position.c_EmptyIndex; } } if (l_End_C < m_GridContainer.FixedColumns) { l_End_C = m_GridContainer.FixedColumns; if (l_End_C >= m_GridContainer.ColumnsCount) { l_End_C = Position.c_EmptyIndex; } } } else if (l_Type == GridSubPanelType.Left) { if (l_Start_C >= m_GridContainer.FixedColumns) { l_Start_C = Position.c_EmptyIndex; } if (l_End_C >= m_GridContainer.FixedColumns) { l_End_C = m_GridContainer.FixedColumns - 1; } if (l_Start_R < m_GridContainer.FixedRows) { l_Start_R = m_GridContainer.FixedRows; if (l_Start_R >= m_GridContainer.RowsCount) { l_Start_R = Position.c_EmptyIndex; } } if (l_End_R < m_GridContainer.FixedRows) { l_End_R = m_GridContainer.FixedRows; if (l_End_R >= m_GridContainer.RowsCount) { l_End_R = Position.c_EmptyIndex; } } } //TODO nel caso di ScrollablePanel dovrei verificare di non restituire celle fisse? if (l_Start_R == Position.c_EmptyIndex || l_Start_C == Position.c_EmptyIndex || l_End_C == Position.c_EmptyIndex || l_End_R == Position.c_EmptyIndex) { return(Range.Empty); } return(new Range(l_Start_R, l_Start_C, l_End_R, l_End_C)); }
/// <summary> /// Returns the cell at the specified grid view relative point (the point must be relative to the grid display region not to the panel display region) /// </summary> /// <param name="p_RelativeViewPoint">Point</param> /// <returns></returns> public virtual Position PositionAtPoint(Point p_RelativeViewPoint) { int l_Row, l_Col; GridSubPanelType l_Type = ContainerType; if (l_Type == GridSubPanelType.TopLeft) { l_Row = m_GridContainer.Rows.RowAtPoint(p_RelativeViewPoint.Y, true); l_Col = m_GridContainer.Columns.ColumnAtPoint(p_RelativeViewPoint.X, true); if (l_Row >= m_GridContainer.FixedRows) { l_Row = Position.c_EmptyIndex; } if (l_Col >= m_GridContainer.FixedColumns) { l_Col = Position.c_EmptyIndex; } } else if (l_Type == GridSubPanelType.Top) { Point l_AbsPoint = m_GridContainer.PointRelativeToAbsolute(p_RelativeViewPoint); l_Row = m_GridContainer.Rows.RowAtPoint(p_RelativeViewPoint.Y, true); l_Col = m_GridContainer.Columns.ColumnAtPoint(l_AbsPoint.X, true); if (l_Row >= m_GridContainer.FixedRows) { l_Row = Position.c_EmptyIndex; } if (l_Col < m_GridContainer.FixedColumns) { l_Col = Position.c_EmptyIndex; } } else if (l_Type == GridSubPanelType.Left) { Point l_AbsPoint = m_GridContainer.PointRelativeToAbsolute(p_RelativeViewPoint); l_Row = m_GridContainer.Rows.RowAtPoint(l_AbsPoint.Y, true); l_Col = m_GridContainer.Columns.ColumnAtPoint(p_RelativeViewPoint.X, true); if (l_Col >= m_GridContainer.FixedColumns) { l_Col = Position.c_EmptyIndex; } if (l_Row < m_GridContainer.FixedRows) { l_Row = Position.c_EmptyIndex; } } else //scrollable { Point l_AbsPoint = m_GridContainer.PointRelativeToAbsolute(p_RelativeViewPoint); l_Row = m_GridContainer.Rows.RowAtPoint(l_AbsPoint.Y, true); l_Col = m_GridContainer.Columns.ColumnAtPoint(l_AbsPoint.X, true); //TODO devo controllare che non cada nelle celle fisse? } if (l_Row == Position.c_EmptyIndex || l_Col == Position.c_EmptyIndex) { return(Position.Empty); } return(new Position(l_Row, l_Col)); }