コード例 #1
0
        /// <summary>
        /// Overrides OnPaint so the control can be drawn.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            foreach (ColorWellInfo c in colorWells)
            {
                ColorWellHelper.DrawColorWell(e.Graphics, Enabled, c == currentColor, c == pickColor, c);
            }

            // draw a border (or not)
            switch (borderStyle)
            {
            case BorderStyle.Fixed3D:
                ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle, Border3DStyle.Sunken);
                break;

            case BorderStyle.FixedSingle:
                ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle, Border3DStyle.Flat);
                break;
            }

            if (Focused && Enabled)
            {
                Rectangle r = ClientRectangle;
                r.Inflate(-borderSize.Width + 1, -borderSize.Height + 1);
                ControlPaint.DrawFocusRectangle(e.Graphics, r);
            }

            // call base.OnPaint last so clients can paint over the control if required
            base.OnPaint(e);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the ColorPanel class.
 /// </summary>
 /// <remarks>
 /// The default constructor initializes all fields to their default values.
 /// </remarks>
 public ColorPanel()
 {
     colorWells = ColorWellHelper.GetColorWells(colorSet, colorSortOrder);
     ResetCustomColors();
     // This call is required by the Windows.Forms Form Designer.
     InitializeComponent();
     UpdateBorderSize();
     AutoSizePanel();
 }
コード例 #3
0
        /// <summary>
        /// Override OnSystemColorsChanged to that the System color palette
        /// can be updated when a user modifies the system colors.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnSystemColorsChanged(System.EventArgs e)
        {
            base.OnSystemColorsChanged(e);

            if (colorSet == ColorSet.System)
            {
                // generate new set of system colors
                colorWells = ColorWellHelper.GetColorWells(colorSet, colorSortOrder);
                LayoutColorWells();

                UpdatePickColor();

                FireColorChanged();

                Refresh();
            }
        }