private void PopulateListWithColorGradients()
        {
            listViewColorGradients.BeginUpdate();
            listViewColorGradients.Items.Clear();

            listViewColorGradients.LargeImageList            = new ImageList();
            listViewColorGradients.LargeImageList.ColorDepth = ColorDepth.Depth32Bit;

            foreach (KeyValuePair <string, ColorGradient> kvp in Library)
            {
                ColorGradient gradient = kvp.Value;
                string        name     = kvp.Key;

                listViewColorGradients.LargeImageList.ImageSize = new Size(64, 64);
                listViewColorGradients.LargeImageList.Images.Add(name, gradient.GenerateColorGradientImage(new Size(64, 64)));

                ListViewItem item = new ListViewItem();
                item.Text     = name;
                item.Name     = name;
                item.ImageKey = name;
                item.Tag      = gradient;

                listViewColorGradients.Items.Add(item);
            }

            listViewColorGradients.EndUpdate();

            buttonEditColorGradient.Enabled   = false;
            buttonDeleteColorGradient.Enabled = false;
        }
Ejemplo n.º 2
0
        private void PopulateListWithColorGradients()
        {
            listViewColorGradients.BeginUpdate();
            listViewColorGradients.Items.Clear();

            listViewColorGradients.LargeImageList            = new ImageList();
            listViewColorGradients.LargeImageList.ColorDepth = ColorDepth.Depth32Bit;

            foreach (KeyValuePair <string, ColorGradient> kvp in Library)
            {
                ColorGradient gradient = kvp.Value;
                string        name     = kvp.Key;

                listViewColorGradients.LargeImageList.ImageSize = new Size(68, 68);

                var      image = gradient.GenerateColorGradientImage(new Size(68, 68), false);
                Graphics gfx   = Graphics.FromImage(image);
                gfx.DrawRectangle(_borderPen, 0, 0, 68, 68);

                listViewColorGradients.LargeImageList.Images.Add(name, image);

                ListViewItem item = new ListViewItem();
                item.Text     = name;
                item.Name     = name;
                item.ImageKey = name;
                item.Tag      = gradient;

                listViewColorGradients.Items.Add(item);
            }

            listViewColorGradients.EndUpdate();

            buttonEditColorGradient.Enabled     = false;
            buttonDeleteColorGradient.Enabled   = false;
            buttonEditColorGradient.ForeColor   = ThemeColorTable.ForeColorDisabled;
            buttonDeleteColorGradient.ForeColor = ThemeColorTable.ForeColorDisabled;
            ;
        }
Ejemplo n.º 3
0
        //draw gradient and faders
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (this.Width < BORDER * 2 || this.Height < BORDER * 2)
            {
                return;
            }
            e.Graphics.SmoothingMode =
                System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            //draw gradient
            Rectangle area = new Rectangle(BORDER, BORDER,
                                           this.Width - BORDER * 2 - 1, this.Height - BORDER * 2 - 1);

            if (_blend != null)
            {
                using (HatchBrush brs = new HatchBrush(HatchStyle.LargeCheckerBoard,
                                                       Color.Silver, Color.White)) {
                    e.Graphics.FillRectangle(brs, area);
                }
                using (Bitmap bmp = _blend.GenerateColorGradientImage(area.Size, DiscreteColors)) {
                    e.Graphics.DrawImage(bmp, area.X, area.Y);
                }
            }
            //border
            e.Graphics.DrawRectangle(Pens.Silver, area);
            if (_blend != null)
            {
                List <ColorPoint> sortedColors = new List <ColorPoint>(_blend.Colors.SortedArray());
                // we'll assume they're sorted, so any colorpoints at the same position are contiguous in the array
                for (int i = 0; i < sortedColors.Count; i++)
                {
                    ColorPoint   currentPoint  = sortedColors[i];
                    double       currentPos    = currentPoint.Position;
                    List <Color> currentColors = new List <Color>();
                    currentColors.Add(currentPoint.GetColor(Color.Black));

                    while (i + 1 < sortedColors.Count && sortedColors[i + 1].Position == currentPos)
                    {
                        currentColors.Add(sortedColors[i + 1].GetColor(Color.Black));
                        i++;
                    }

                    DrawFader(e.Graphics, currentPoint.Position, currentColors, false,
                              _selection != null && _selection.Contains(currentPoint) && !_focussel);
                }

                ////draw color points
                //foreach (ColorPoint pnt in _blend.Colors)
                //    DrawFader(e.Graphics, pnt.Position,
                //        pnt.GetColor(Color.Black),
                //        false, pnt == _selection && !_focussel);
                // MS: 25/09/11: disable drawing alpha points, we don't want to use them (yet).
                // draw alpha points
                //foreach (AlphaPoint pnt in _blend.Alphas)
                //    DrawFader(e.Graphics, pnt.Position,
                //        pnt.GetColor(Color.Black),
                //        true, pnt == _selection && !_focussel);

                // draw selected focus
                if (_selection != null && _selection.Count > 0)
                {
                    DrawDiamond(e.Graphics, _blend.GetFocusPosition(_selection.First()),
                                _selection.First() is AlphaPoint, _focussel);
                }
            }
        }