コード例 #1
0
        /// <summary>
        /// Returns the intersection between the two ranges.
        /// If one of the range is empty then the return is empty.
        /// </summary>
        /// <param name="p_Range1">The range1.</param>
        /// <param name="p_Range2">The range2.</param>
        /// <returns></returns>
        public static Range Intersect(Range p_Range1, Range p_Range2)
        {
            if (p_Range1.IsEmpty() || p_Range2.IsEmpty())
            {
                return(Range.Empty);
            }

            return(new Range(Position.MergeMinor(p_Range1.Start, p_Range2.Start),
                             Position.MergeMinor(p_Range1.End, p_Range2.End), false));
        }
コード例 #2
0
        /// <summary>
        /// Returns a range with the smaller Start and the bigger End, the Union of the two ranges.
        /// If one of the range is empty then returns other range.
        /// </summary>
        /// <param name="p_Range1">The range1.</param>
        /// <param name="p_Range2">The range2.</param>
        /// <returns></returns>
        public static Range Union(Range p_Range1, Range p_Range2)
        {
            if (p_Range1.IsEmpty())
            {
                return(p_Range2);
            }
            else if (p_Range2.IsEmpty())
            {
                return(p_Range1);
            }

            return(new Range(Position.MergeMinor(p_Range1.Start, p_Range2.Start),
                             Position.MergeMajor(p_Range1.End, p_Range2.End), false));
        }
コード例 #3
0
ファイル: Range.cs プロジェクト: stewartadcock/meddatagrid
        /// <summary>
        /// Returns a range with the smaller Start and the bigger End, the Union of the two ranges.
        /// If one of the range is empty then returns other range.
        /// </summary>
        /// <param name="p_Range1">The range1.</param>
        /// <param name="p_Range2">The range2.</param>
        /// <returns></returns>
        public static Range Union(Range p_Range1, Range p_Range2)
        {
            if (p_Range1.IsEmpty())
              {
            return p_Range2;
              }
              else if (p_Range2.IsEmpty())
              {
            return p_Range1;
              }

              return new Range(Position.MergeMinor(p_Range1.Start, p_Range2.Start),
                Position.MergeMajor(p_Range1.End, p_Range2.End), false);
        }
コード例 #4
0
ファイル: Range.cs プロジェクト: stewartadcock/meddatagrid
        /// <summary>
        /// Returns the intersection between the two ranges.
        /// If one of the range is empty then the return is empty.
        /// </summary>
        /// <param name="p_Range1">The range1.</param>
        /// <param name="p_Range2">The range2.</param>
        /// <returns></returns>
        public static Range Intersect(Range p_Range1, Range p_Range2)
        {
            if (p_Range1.IsEmpty() || p_Range2.IsEmpty())
              {
            return Range.Empty;
              }

              return new Range(Position.MergeMinor(p_Range1.Start, p_Range2.Start),
              Position.MergeMinor(p_Range1.End, p_Range2.End), false);
        }
コード例 #5
0
        /// <summary>
        /// Deselect and remove from the collection the specified range of cells
        /// </summary>
        /// <param name="range">The range.</param>
        /// <remarks>
        /// if GridSelectionMode is Cell this method work only if we have 1 cell in the range
        /// </remarks>
        public void RemoveRange(Range range)
        {
            if (range.IsEmpty() == true)
              {
            return;
              }

              if (selectionMode == GridSelectionMode.Row)
              {
            RemoveRangeRow(range);
              }
              else if (selectionMode == GridSelectionMode.Column)
              {
            RemoveRangeColumn(range);
              }
              else // GridSelectionMode.Cell
              {
            RemoveRangeCell(range);
              }
        }
コード例 #6
0
        /// <summary>
        /// Select the specified Range of cells
        /// </summary>
        /// <param name="p_Range">The range.</param>
        public void AddRange(Range p_Range)
        {
            if (p_Range.IsEmpty() == true || grid.ColumnsCount == 0 || grid.RowsCount == 0)
              {
            return;
              }

              Range l_RangeToSelect = p_Range;

              // Apply SelectionMode
              if (selectionMode == GridSelectionMode.Row)
              {
            AddRangeRow(l_RangeToSelect);
              }
              else if (selectionMode == GridSelectionMode.Column)
              {
            AddRangeColumn(l_RangeToSelect);
              }
              else // if (selectionMode == GridSelectionMode.Cell)
              {
            l_RangeToSelect = AddRangeCell(l_RangeToSelect);
              }
        }
コード例 #7
0
        /// <summary>
        /// Returns the relative rectangle to the current scrollable area of the specified Range. Returns a 0 rectangle if the Range is not valid
        /// </summary>
        /// <param name="p_Range">The range.</param>
        /// <returns></returns>
        public Rectangle RangeToDisplayRect(Range p_Range)
        {
            if (p_Range.IsEmpty())
              {
            return new Rectangle(0, 0, 0, 0);
              }

              Rectangle l_Absolute = RangeToAbsoluteRect(p_Range);
              Rectangle l_Display = RectangleAbsoluteToRelative(l_Absolute);

              CellPositionType l_Type = GetPositionType(p_Range.Start);
              if (l_Type == CellPositionType.FixedTopLeft)
              {
            return new Rectangle(l_Absolute.X, l_Absolute.Y, l_Absolute.Width, l_Absolute.Height);
              }
              else if (l_Type == CellPositionType.FixedTop)
              {
            return new Rectangle(l_Display.X, l_Absolute.Y, l_Absolute.Width, l_Absolute.Height);
              }
              else if (l_Type == CellPositionType.FixedLeft)
              {
            return new Rectangle(l_Absolute.X, l_Display.Y, l_Absolute.Width, l_Absolute.Height);
              }
              else if (l_Type == CellPositionType.Scrollable)
              {
            return l_Display;
              }
              else
              {
            return new Rectangle(0, 0, 0, 0);
              }
        }
コード例 #8
0
        /// <summary>
        /// Returns the absolute rectangle relative to the total scrollable area of the specified Range. Returns a 0 rectangle if the Range is not valid
        /// </summary>
        /// <param name="p_Range">The range.</param>
        /// <returns></returns>
        public virtual Rectangle RangeToAbsoluteRect(Range p_Range)
        {
            if (p_Range.IsEmpty())
              {
            return new Rectangle(0, 0, 0, 0);
              }

              int l_Left = Columns[p_Range.Start.Column].Left;
              int l_Top = Rows[p_Range.Start.Row].Top;

              return new Rectangle(l_Left, // x
                          l_Top,  // y
                          Columns[p_Range.End.Column].Right - l_Left,   // width
                          Rows[p_Range.End.Row].Bottom - l_Top);  // height
        }
コード例 #9
0
 /// <summary>
 /// Force a range of cells to redraw. If Redraw is set to false this function has no effects
 /// </summary>
 /// <param name="p_Range">The range.</param>
 public void InvalidateRange(Range p_Range)
 {
     p_Range = Range.Intersect(p_Range, CompleteRange); // to ensure the range is valid
       if (Redraw && p_Range.IsEmpty() == false)// && !this.DrawColLine)
       {
     Rectangle l_GridRectangle = RangeToDisplayRect(p_Range);
     Invalidate(l_GridRectangle, true);
       }
 }
コード例 #10
0
        /// <summary>
        /// Auto size all the columns and all the rows with the required width and height
        /// </summary>
        /// <param name="p_MinHeight">Minimum Height</param>
        /// <param name="p_MinWidth">Minimum Width</param>
        /// <param name="p_RangeToAutoSize">Range to autosize.</param>
        public virtual void AutoSizeRange(int p_MinHeight, int p_MinWidth, Range p_RangeToAutoSize)
        {
            if (p_RangeToAutoSize.IsEmpty() == false)
              {
            bool l_bOldRedraw = Redraw;
            bool l_bOldAutoCalculateTop = Rows.AutoCalculateTop;
            bool l_bOldAutoCalculateLeft = Columns.AutoCalculateLeft;
            try
            {
              Redraw = false;
              Rows.AutoCalculateTop = false;
              Columns.AutoCalculateLeft = false;

              for (int c = p_RangeToAutoSize.End.Column; c >= p_RangeToAutoSize.Start.Column; c--)
              {
            AutoSizeColumnRange(c, p_MinWidth, p_RangeToAutoSize.Start.Row, p_RangeToAutoSize.End.Row);
              }
              for (int r = p_RangeToAutoSize.End.Row; r >= p_RangeToAutoSize.Start.Row; r--)
              {
            AutoSizeRowRange(r, p_MinHeight, p_RangeToAutoSize.Start.Column, p_RangeToAutoSize.End.Column);
              }
            }
            finally
            {
              Rows.AutoCalculateTop = l_bOldAutoCalculateTop;
              Columns.AutoCalculateLeft = l_bOldAutoCalculateLeft;
              Redraw = l_bOldRedraw;
            }

            // questo codice deve essere fatto dopo AutoCalculateTop e AutoCalculateLeft
            if (AutoStretchColumnsToFitWidth)
            {
              StretchColumnsToFitWidth();
            }
            if (AutoStretchRowsToFitHeight)
            {
              StretchRowsToFitHeight();
            }
              }
        }