예제 #1
0
        private static void DrawLinearGradientBack(Graphics g,
                                                   Rectangle backRect,
                                                   LinearItemColors colors)
        {
            // Reduce rect draw drawing inside the border
            backRect.Inflate(-1, -1);

            using (LinearGradientBrush  backBrush = new LinearGradientBrush(backRect, colors.Fill1, colors.Fill2, 90f))
                g.FillRectangle(backBrush, backRect);
        }
예제 #2
0
        private void UpdateCache()
        {
            // Only need to create the cache objects first time around
            if (_gradientItem == null)
            {
                _linearItem = new LinearItemColors(KCT.ButtonSelectedGradientMiddle,
                                                   CommonHelper.BlackenColor(KCT.ButtonSelectedGradientMiddle, 0.91f, 0.91f, 0.91f),
                                                   CommonHelper.BlackenColor(KCT.ButtonSelectedGradientMiddle, 0.75f, 0.75f, 0.75f));

                _gradientItem = new GradientItemColors(KCT.CheckBackground,
                                                       KCT.ButtonSelectedGradientBegin,
                                                       KCT.ButtonSelectedGradientBegin);

                _gradientTracking = new GradientItemColors(KCT.ButtonSelectedBorder,
                                                           KCT.ButtonSelectedGradientBegin,
                                                           KCT.ButtonSelectedGradientEnd);

                _gradientPressed = new GradientItemColors(KCT.ButtonPressedBorder,
                                                          KCT.ButtonPressedGradientBegin,
                                                          KCT.ButtonPressedGradientEnd);

                _gradientChecked = new GradientItemColors(KCT.ButtonPressedBorder,
                                                          KCT.ButtonCheckedGradientBegin,
                                                          KCT.ButtonCheckedGradientEnd);

                _gradientCheckedTracking = new GradientItemColors(KCT.ButtonSelectedBorder,
                                                                  KCT.ButtonPressedGradientBegin,
                                                                  KCT.ButtonCheckedGradientEnd);
            }
        }
예제 #3
0
        private static void DrawLinearGradientItem(Graphics g,
                                                   Rectangle backRect,
                                                   LinearItemColors colors)
        {
            // Cannot paint a zero sized area
            if ((backRect.Width > 0) && (backRect.Height > 0))
            {
                // Draw the background of the entire item
                DrawLinearGradientBack(g, backRect, colors);

                // Draw the border of the entire item
                DrawLinearGradientBorder(g, backRect, colors);
            }
        }
예제 #4
0
        private void DrawLinearContextMenuItem(Graphics g,
                                               ToolStripItem item,
                                               LinearItemColors colors)
        {
            // Do we need to draw with separator on the opposite edge?
            Rectangle backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height);

            // Perform actual drawing into the background
            DrawLinearGradientItem(g, backRect, colors);
        }
예제 #5
0
 private static void DrawLinearGradientBorder(Graphics g,
                                              Rectangle backRect,
                                              LinearItemColors colors)
 {
     // Drawing with anti aliasing to create smoother appearance
     using (AntiAlias aa = new AntiAlias(g))
         using (Pen borderPen = new Pen(colors.Border))
             using (GraphicsPath borderPath = CreateBorderPath(backRect, _cutMenuItemBack))
                 g.DrawPath(borderPen, borderPath);
 }