コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the RowStyle class with default settings
 /// </summary>
 public I3RowStyle()
 {
     this.backColor = Color.Empty;
     this.foreColor = Color.Empty;
     this.font      = null;
     this.alignment = I3RowAlignment.Center;
 }
コード例 #2
0
        /// <summary>
        /// Gets the Rectangle that specifies the Size and Location of
        /// the check box contained in the current Cell
        /// </summary>
        /// <returns>A Rectangle that specifies the Size and Location of
        /// the check box contained in the current Cell</returns>
        protected Rectangle CalcCheckBoxDisplayRect(I3RowAlignment rowAlignment, I3ColumnAlignment columnAlignment, I3CheckBoxColumn checkBoxColumn)
        {
            if (checkBoxColumn.CustomCheckImage != null && checkBoxColumn.CustomCheckImageFillClient)
            {
                return(this.ClientRectangle);
            }

            Rectangle checkRect = new Rectangle(this.ClientRectangle.Location, this.CheckSize);

            if (checkRect.Height > this.ClientRectangle.Height)
            {
                checkRect.Height = this.ClientRectangle.Height;
                checkRect.Width  = checkRect.Height;
            }

            switch (rowAlignment)
            {
            case I3RowAlignment.Center:
            {
                checkRect.Y += (this.ClientRectangle.Height - checkRect.Height) / 2;

                break;
            }

            case I3RowAlignment.Bottom:
            {
                checkRect.Y = this.ClientRectangle.Bottom - checkRect.Height;

                break;
            }
            }

            if (!this.DrawText)
            {
                if (columnAlignment == I3ColumnAlignment.Center)
                {
                    checkRect.X += (this.ClientRectangle.Width - checkRect.Width) / 2;
                }
                else if (columnAlignment == I3ColumnAlignment.Right)
                {
                    checkRect.X = this.ClientRectangle.Right - checkRect.Width;
                }
            }

            if (checkBoxColumn != null && checkBoxColumn.CheckBoxColumnStyle == I3CheckBoxColumnStyle.Image)
            {
                Size size = checkBoxColumn.CustomCheckImageSize;
                checkRect.X     -= Convert.ToInt32((size.Width - checkRect.Width) / 2);
                checkRect.Width  = size.Width;
                checkRect.Y     -= Convert.ToInt32((size.Height - checkRect.Height) / 2);
                checkRect.Height = size.Height;
            }

            return(checkRect);
        }
コード例 #3
0
        /// <summary>
        /// Returns a Rectangle that specifies the size and location of the Color
        /// rectangle
        /// </summary>
        /// <param name="rowAlignment">The alignment of the Cells Row</param>
        /// <param name="columnAlignment">The alignment of the Cells Column</param>
        /// <returns>A Rectangle that specifies the size and location of the Color
        /// rectangle</returns>
        protected Rectangle CalcColorRect(I3RowAlignment rowAlignment, I3ColumnAlignment columnAlignment)
        {
            Rectangle rect = this.ClientRectangle;

            rect.X      += 2;
            rect.Y      += 2;
            rect.Height -= 6;
            rect.Width   = 16;

            return(rect);
        }
コード例 #4
0
        /// <summary>
        /// Gets the Rectangle that specifies the Size and Location of
        /// the Image contained in the current Cell
        /// </summary>
        /// <param name="image">The Image to be drawn</param>
        /// <param name="sizeMode">An ImageSizeMode that specifies how the
        /// specified Image is scaled</param>
        /// <param name="rowAlignment">The alignment of the current Cell's row</param>
        /// <param name="columnAlignment">The alignment of the current Cell's Column</param>
        /// <returns>A Rectangle that specifies the Size and Location of
        /// the Image contained in the current Cell</returns>
        protected Rectangle CalcImageRect(Image image, I3ImageSizeMode sizeMode, I3RowAlignment rowAlignment, I3ColumnAlignment columnAlignment)
        {
            if (this.DrawText)
            {
                sizeMode = I3ImageSizeMode.ScaledToFit;
            }

            Rectangle imageRect = this.ClientRectangle;

            if (sizeMode == I3ImageSizeMode.Normal)
            {
                if (image.Width < imageRect.Width)
                {
                    imageRect.Width = image.Width;
                }

                if (image.Height < imageRect.Height)
                {
                    imageRect.Height = image.Height;
                }
            }
            else if (sizeMode == I3ImageSizeMode.ScaledToFit)
            {
                if (image.Width >= imageRect.Width || image.Height >= imageRect.Height)
                {
                    double hScale = ((double)imageRect.Width) / ((double)image.Width);
                    double vScale = ((double)imageRect.Height) / ((double)image.Height);

                    double scale = Math.Min(hScale, vScale);

                    imageRect.Width  = (int)(((double)image.Width) * scale);
                    imageRect.Height = (int)(((double)image.Height) * scale);
                }
                else
                {
                    imageRect.Width  = image.Width;
                    imageRect.Height = image.Height;
                }
            }

            if (rowAlignment == I3RowAlignment.Center)
            {
                imageRect.Y += (this.ClientRectangle.Height - imageRect.Height) / 2;
            }
            else if (rowAlignment == I3RowAlignment.Bottom)
            {
                imageRect.Y = this.ClientRectangle.Bottom - imageRect.Height;
            }

            if (!this.DrawText)
            {
                if (columnAlignment == I3ColumnAlignment.Center)
                {
                    imageRect.X += (this.ClientRectangle.Width - imageRect.Width) / 2;
                }
                else if (columnAlignment == I3ColumnAlignment.Right)
                {
                    imageRect.X = this.ClientRectangle.Width - imageRect.Width;
                }
            }

            return(imageRect);
        }