コード例 #1
0
        private void panel_Paint(object sender, PaintEventArgs e)
        {
            if (minColumnWidth == 0 || rowHeight == 0)
            {
                return;
            }

            AllocTitleBrush();

            // Paint each column
            for (int c = 0; c < columnCount; c++)
            {
                // Find starting row in this column
                int  gi        = 0;
                int  ci        = -1;
                bool blankLine = false;

                for (int r = 0; r < vScrollBar.Value; r++)
                {
                    NextRow(c, ref gi, ref ci, ref blankLine);
                }

                // Paint each visible row
                for (int r = 0; r < fullRowsDisplayed + partialRowsDisplayed; r++)
                {
                    Rectangle rect = new Rectangle(columnX[c],
                                                   rowHeight * r,
                                                   columnWidth[c],
                                                   rowHeight);

                    if (blankLine)
                    {
                        //e.Graphics.FillRectangle(SystemBrushes.Window, rect);
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(22, 22, 22)), rect);

                        continue;
                    }

                    ColorGroup g = colorGroups[c][gi];

                    if (ci == -1)
                    {
                        //e.Graphics.FillRectangle(SystemBrushes.Window, rect);
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(22, 22, 22)), rect);

                        e.Graphics.DrawString(g.Title, titleFont, titleBrush, rect, StringFormat.GenericDefault);
                    }
                    else
                    {
                        Color color = g.Colors[ci];
                        bool  sel   = (selGroup == g) && (selIndex == ci);

                        // Background color
                        //e.Graphics.FillRectangle(sel ? SystemBrushes.Highlight : SystemBrushes.Window, rect);
                        e.Graphics.FillRectangle(sel ? new SolidBrush(Color.FromArgb(100, 100, 100)) : new SolidBrush(Color.FromArgb(22, 22, 22)), rect);


                        // Draw color box
                        Brush     colorBrush = new SolidBrush(color);
                        Rectangle colorRect  = new Rectangle(rect.X + colorBoxOffset,
                                                             rect.Y + colorBoxOffset,
                                                             colorBoxWidth,
                                                             rect.Height - 2 * colorBoxOffset);
                        e.Graphics.FillRectangle(colorBrush, colorRect);
                        e.Graphics.DrawRectangle(SystemPens.WindowText, colorRect);
                        colorBrush.Dispose();

                        // Text
                        Rectangle textRect = new Rectangle(rect.X + colorTextOffset,
                                                           rect.Y,
                                                           rect.Width - colorTextOffset,
                                                           rect.Height);
                        e.Graphics.DrawString(" " + color.Name, colorFont,
                                              sel ? Brushes.Gray : SystemBrushes.Highlight,
                                              textRect, StringFormat.GenericDefault);
                    }

                    NextRow(c, ref gi, ref ci, ref blankLine);
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///     Generate color groups.
        /// </summary>
        /// <returns>Array of color groups.</returns>
        public override ColorGroup[] GenerateColorGroups()
        {
            systemColors = new ColorGroup("System Colors");



            //systemColors.Add(SystemColors.ActiveBorder);
            //systemColors.Add(SystemColors.ActiveCaption);
            //systemColors.Add(SystemColors.ActiveCaptionText);
            //systemColors.Add(SystemColors.AppWorkspace);
            //systemColors.Add(SystemColors.ButtonFace);
            //systemColors.Add(SystemColors.ButtonHighlight);
            //systemColors.Add(SystemColors.ButtonShadow);
            //systemColors.Add(SystemColors.Control);
            //systemColors.Add(SystemColors.ControlDark);
            //systemColors.Add(SystemColors.ControlDarkDark);
            //systemColors.Add(SystemColors.ControlLight);
            //systemColors.Add(SystemColors.ControlLightLight);
            //systemColors.Add(SystemColors.ControlText);
            //systemColors.Add(SystemColors.Desktop);
            //systemColors.Add(SystemColors.GradientActiveCaption);
            //systemColors.Add(SystemColors.GradientInactiveCaption);
            //systemColors.Add(SystemColors.GrayText);
            //systemColors.Add(SystemColors.Highlight);
            //systemColors.Add(SystemColors.HighlightText);
            //systemColors.Add(SystemColors.HotTrack);
            //systemColors.Add(SystemColors.InactiveBorder);
            //systemColors.Add(SystemColors.InactiveCaption);
            //systemColors.Add(SystemColors.InactiveCaptionText);
            //systemColors.Add(SystemColors.Info);
            //systemColors.Add(SystemColors.InfoText);
            //systemColors.Add(SystemColors.Menu);
            //systemColors.Add(SystemColors.MenuBar);
            //systemColors.Add(SystemColors.MenuHighlight);
            //systemColors.Add(SystemColors.MenuText);
            //systemColors.Add(SystemColors.ScrollBar);
            //systemColors.Add(SystemColors.Window);
            //systemColors.Add(SystemColors.WindowFrame);
            //systemColors.Add(SystemColors.WindowText);

            systemColors.Add(WebColor.Zaffre);
            systemColors.Add(WebColor.ZinnwalditeBrown);
            systemColors.Add(WebColor.Zomp);
            systemColors.Add(WebColor.Zaffre);
            systemColors.Add(WebColor.ZinnwalditeBrown);
            systemColors.Add(WebColor.Zomp);
            systemColors.Add(WebColor.Zaffre);
            systemColors.Add(WebColor.ZinnwalditeBrown);
            systemColors.Add(WebColor.Zomp);
            systemColors.Add(WebColor.Zaffre);
            systemColors.Add(WebColor.ZinnwalditeBrown);
            systemColors.Add(WebColor.Zomp);
            systemColors.Add(WebColor.Zaffre);
            systemColors.Add(WebColor.ZinnwalditeBrown);
            systemColors.Add(WebColor.Zomp);
            systemColors.Add(WebColor.Zaffre);
            systemColors.Add(WebColor.ZinnwalditeBrown);
            systemColors.Add(WebColor.Zaffre);
            systemColors.Add(WebColor.ZinnwalditeBrown);
            systemColors.Add(WebColor.Zomp);
            systemColors.Add(WebColor.Zomp);

            return(new ColorGroup[] { systemColors });
        }
コード例 #3
0
        private void ChangeSelKey(Keys key)
        {
            int  column    = -1;
            int  row       = -1;
            int  gi        = -1;
            int  ci        = -1;
            bool blankLine = false;

            if (!GetSelColorLocation(ref column, ref row, ref gi, ref ci))
            {
                column = 0;
                gi     = 0;
                ci     = 0;
            }
            else if (key == Keys.Up)
            {
                if (ci > 0 || gi > 0)                 // go up only if not at first row
                {
                    PrevRow(column, ref gi, ref ci);
                    if (ci == -1)                     // if we hit title line, go up another line
                    {
                        PrevRow(column, ref gi, ref ci);
                    }
                }
            }
            else if (key == Keys.Down)
            {
                if (gi < colorGroups[column].Length - 1 || ci < colorGroups[column][gi].Colors.Length - 1)                 // go down only if not at last row
                {
                    NextRow(column, ref gi, ref ci, ref blankLine);
                    if (ci == -1)                     // if we hit title line, go down another line
                    {
                        NextRow(column, ref gi, ref ci, ref blankLine);
                    }
                }
            }
            else if (key == Keys.Home)             // goto top of current column
            {
                gi = 0;
                ci = 0;
            }
            else if (key == Keys.End)             // goto bottom of current column
            {
                gi = colorGroups[column].Length - 1;
                ci = colorGroups[gi][ci].Colors.Length - 1;
            }
            else if (key == Keys.PageUp)             // goto top of previous group
            {
                gi = Math.Max(0, gi - 1);
                ci = 0;
            }
            else if (key == Keys.PageDown)             // goto top of next group
            {
                gi = Math.Min(colorGroups[column].Length - 1, gi + 1);
                ci = 0;
            }
            else             // Left or Right
            {
                if (key == Keys.Left && column > 0)
                {
                    column--;
                }
                else if (key == Keys.Right && column < columnCount - 1)
                {
                    column++;
                }

                gi = 0;
                ci = -1;
                for (int r = 0; r < row; r++)
                {
                    NextRow(column, ref gi, ref ci, ref blankLine);
                }

                if (blankLine || ci == -1)                 // if gone too far, or hit title line, go back up one line
                {
                    PrevRow(column, ref gi, ref ci);
                }
            }

            selGroup = colorGroups[column][gi];
            selIndex = ci;
            ScrollToMakeSelColorVisible();
        }
コード例 #4
0
        /// <summary>
        ///     Organizes the color groups depending on the number of columns being displayed.
        /// </summary>
        /// <param name="groups">Array of array of color groups.</param>
        public override void SplitColorGroups(ColorGroup[][] groups)
        {
            groups[0] = new ColorGroup[1];

            AddColorGroup(systemColors);
        }