Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        /// <param name="bgColor"></param>
        public static void PaintBackGround(Graphics g, Rectangle rect, Color bgColor, bool showEnabled)
        {
#if !PocketPC
            Brush brush = (showEnabled ? SolidBrushCache.GetInstance().Get(Utils.GetNearestColor(g, bgColor)) : SystemBrushes.ButtonFace);
#else
            Brush brush = (showEnabled ? SolidBrushCache.GetInstance().Get(bgColor) : SolidBrushCache.GetInstance().Get(SystemColors.Control));
#endif
            g.FillRectangle(brush, rect);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        /// <param name="bgColor"></param>
        public static void PaintRoundedRectangleBackGround(Graphics g, Rectangle rect, Color bgColor, ulong cornerRadius)
        {
#if !PocketPC
            if (rect.Width > 0 && rect.Height > 0)
            {
                Brush brush = SolidBrushCache.GetInstance().Get(Utils.GetNearestColor(g, bgColor));
                GraphicsExtension.FillRoundedRectangle(g, brush, rect.Left, rect.Top, rect.Width, rect.Height, (int)cornerRadius);
            }
#endif
        }
Exemple #3
0
        /// <summary>
        /// Fill the background of Tab
        /// </summary>
        /// <param name="index"></param>
        /// <param name="graphics"></param>
        /// <param name="path"></param>
        private static void FillTab(MgTabControl tabControl, Graphics graphics, GraphicsPath path, int index)
        {
            Brush fillBrush = GetTabBackgroundBrush(tabControl, index);

            //	Paint the background
            graphics.FillPath(fillBrush, path);

            // Fill the selected tab with selected tab color
            if (tabControl.SelectedTabColor != Color.Empty && tabControl.SelectedIndex == index)
            {
                graphics.FillRectangle(SolidBrushCache.GetInstance().Get(tabControl.SelectedTabColor), tabControl.DisplayStyleProvider.GetTabRect(index));
            }
        }
Exemple #4
0
 public static SolidBrushCache GetInstance()
 {
     if (_instance == null)
     {
         // synchronize on the class object
         lock (typeof(SolidBrushCache))
         {
             if (_instance == null)
             {
                 _instance = new SolidBrushCache();
             }
         }
     }
     return(_instance);
 }
Exemple #5
0
        internal static void CustomPaint(MgTabControl tabControl, Graphics screenGraphics)
        {
            //	We render into a bitmap that is then drawn in one shot rather than using
            //	double buffering built into the control as the built in buffering
            //  messes up the background painting.
            //	Equally the .Net 2.0 BufferedGraphics object causes the background painting
            //	to mess up, which is why we use this .Net 1.1 buffering technique.

            //	Buffer code from Gil. Schmidt http://www.codeproject.com/KB/graphics/DoubleBuffering.aspx

            if (tabControl.Width > 0 && tabControl.Height > 0)
            {
                tabControl.PaintTransparentBackground(screenGraphics);

                if (tabControl.TabCount > 0)
                {
                    //	Draw each tabpage from right to left.  We do it this way to handle
                    //	the overlap correctly.

                    for (int row = 0; row < tabControl.RowCount; row++)
                    {
                        for (int index = tabControl.TabCount - 1; index >= 0; index--)
                        {
                            if (index != tabControl.SelectedIndex && GetTabRow(tabControl, index) == row)
                            {
                                DrawTabPage(tabControl, screenGraphics, index);
                            }
                        }
                    }

                    //	The selected tab must be drawn last so it appears on top.
                    if (tabControl.SelectedIndex > -1)
                    {
                        DrawTabPage(tabControl, screenGraphics, tabControl.SelectedIndex);
                    }
                }
                else
                {
                    // When there are no tabs paint only the border.
                    Rectangle tabBorderRect = tabControl.ClientRectangle;
                    tabBorderRect.Inflate(-2, -2);
                    screenGraphics.DrawRectangle(new Pen(SolidBrushCache.GetInstance().Get(SystemColors.ControlDark)), tabBorderRect);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// get the brush for filling background
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        private static Brush GetTabBackgroundBrush(MgTabControl tabControl, int index)
        {
            Color tabBackGroundColor;

            if (tabControl.SelectedIndex == index)
            {
                tabBackGroundColor = tabControl.PageColor;
            }
            else if (index == tabControl.ActiveIndex && tabControl.HotTrackColor != Color.Empty)
            {
                tabBackGroundColor = tabControl.HotTrackColor; // Change the background of hot tracked tab for XP theme
            }
            else
            {
                tabBackGroundColor = tabControl.TitleColor;
            }

            return(SolidBrushCache.GetInstance().Get(tabBackGroundColor));
        }
Exemple #7
0
        /// <summary>
        /// paint table cell background
        /// </summary>
        public void PaintCellBackground(TableChildRendererBase tableChildRenderer, CellData cellData, Graphics g, TableItem item, bool isRowMarked, bool isSelected, ColumnsManager columnsManager)
        {
            using (var cellRegion = new Region(cellData.Rect))
            {
                g.Clip = GetClippingArea(cellRegion, g);
                //The paining of table rows is done from TableControl.OnPaint(). We should paint selected and marked rows from here.
                if (isRowMarked)
                {
                    if (tableChildRenderer.RowHighlitingStyle == RowHighlightType.BackgroundControls ||
                        tableChildRenderer.RowHighlitingStyle == RowHighlightType.Background)
                    {
                        Color color = tableChildRenderer.HightlightBgColor;

                        //paint cell background
                        Brush brush = SolidBrushCache.GetInstance().Get(Utils.GetNearestColor(g, color));
                        g.FillRectangle(brush, cellData.Rect);
                    }
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// render classic style expander (+ /- )
        /// </summary>
        /// <param name="g"></param>
        /// <param name="bounds"></param>
        /// <param name="isExpanded"></param>
        /// <param name="backColor"></param>
        /// <param name="foreColor"></param>
        public static void RenderExpanderWithClassicStyle(Graphics g, Rectangle bounds, bool isExpanded, Color backColor, Color foreColor)
        {
            Rectangle rect = new Rectangle((int)System.Math.Ceiling((bounds.Width - EXPANDER_SIZE) / 2), (int)System.Math.Ceiling((bounds.Height - EXPANDER_SIZE) / 2) + bounds.Y, (int)EXPANDER_SIZE, (int)EXPANDER_SIZE);

            if (!rect.IsEmpty)
            {
                Brush backgroundBrush = SolidBrushCache.GetInstance().Get(backColor);
                Pen   pen             = PensCache.GetInstance().Get(foreColor);

                g.FillRectangle(backgroundBrush, rect);                                // Fill rect
                g.DrawRectangle(pen, rect.X, rect.Y, rect.Width - 1, rect.Height - 1); // draw border

                int num = 2;
                // draw horizontal line
                g.DrawLine(pen, (int)(rect.X + num), (int)(rect.Y + (rect.Height / 2)), (int)(((rect.X + rect.Width) - num) - 1), (int)(rect.Y + (rect.Height / 2)));

                if (!isExpanded)
                {
                    // draw vertical line
                    g.DrawLine(pen, (int)(rect.X + (rect.Width / 2)), (int)(rect.Y + num), (int)(rect.X + (rect.Width / 2)), (int)(((rect.Y + rect.Height) - num) - 1));
                }
            }
        }