Example #1
0
        private void dataGrid1_IndicatorColumn_CellPaint(object sender, DataGridIndicatorCellPaintEventArgs e)
        {
            e.PaintBackground(e);

            if (e.Row == null)
            {
                return;
            }
            DataGridColumn col   = dataGrid1.Columns.FindColumnByPropertyName("Continent");
            string         value = col.GetRowDisplayText(e.Row);

            if (value == "North America")
            {
                Bitmap im = Properties.Resources.Globe_North_America_16x16;
                //im.MakeTransparent();

                Rectangle imageAreaRect = e.ClientRect;
                imageAreaRect.X     = imageAreaRect.Right - 16;
                imageAreaRect.Width = 16;

                Rectangle imageArea = new Rectangle(Point.Empty, im.Size);
                imageArea = EhLibUtils.RectCenter(imageArea, imageAreaRect);

                e.Graphics.DrawImage(im, imageArea);
            }

            Rectangle newPaintRect = e.ClientRect;

            newPaintRect.Width = newPaintRect.Width - 16;
            e.ClientRect       = newPaintRect;

            e.PaintForeground(e);

            e.Handled = true;
        }
Example #2
0
        private void PaintTransportIcon(Graphics graphics, Rectangle iconRect, int iconPos)
        {
            Image image = imageList1.Images[iconPos];

            Rectangle imageArea = new Rectangle(Point.Empty, image.Size);

            imageArea = EhLibUtils.RectCenter(imageArea, iconRect);

            graphics.DrawImage(image, imageArea);
        }
Example #3
0
        private void dataGridTextColumn3_DataCellCustomAreaPaint(object sender, DataGridDataCellPaintEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            BasePaintCellStates cellPaintState = e.CellArgs.State;

            e.CellArgs.State = e.CellArgs.State & ~BasePaintCellStates.Current & ~BasePaintCellStates.Focused;
            Rectangle clientRect = e.CellArgs.ClientRect;

            Rectangle folderAreaRect = e.CellArgs.ClientRect;

            folderAreaRect.X     = e.CellArgs.CustomRect.Left;
            folderAreaRect.Width = e.CellArgs.ClientRect.Left - e.CellArgs.CustomRect.Left;

            e.CellArgs.ClientRect = folderAreaRect;
            e.PaintBackground(e);

            e.CellArgs.ClientRect = clientRect;
            e.CellArgs.State      = cellPaintState;

            FileSystemFolterTreeNode node = (FileSystemFolterTreeNode)e.Row.SourceItem;

            {
                Rectangle folderSignRect = folderAreaRect;
                Image     folderImage;
                if (node.Expanded || !node.HasChildren)
                {
                    folderImage = Properties.Resources.FolderOpen;
                }
                else
                {
                    folderImage = Properties.Resources.FolderClosed;
                }
                folderSignRect = new Rectangle(Point.Empty, folderImage.Size);
                folderSignRect = EhLibUtils.RectCenter(folderSignRect, folderAreaRect);
                //folderSignRect.X = folderSignRect.Left + 2;
                e.CellArgs.Graphics.DrawImage(folderImage, folderSignRect);
            }
        }