当前位置: 首页>>代码示例>>C#>>正文


C# ColorCollection类代码示例

本文整理汇总了C#中ColorCollection的典型用法代码示例。如果您正苦于以下问题:C# ColorCollection类的具体用法?C# ColorCollection怎么用?C# ColorCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ColorCollection类属于命名空间,在下文中一共展示了ColorCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

        /// <summary>
        /// Deserializes the <see cref="ColorCollection" /> contained by the specified <see cref="Stream" />.
        /// </summary>
        /// <param name="stream">The <see cref="Stream" /> that contains the palette to deserialize.</param>
        /// <returns>The <see cref="ColorCollection" /> being deserialized.</returns>
        public override ColorCollection Deserialize(Stream stream)
        {
            ColorCollection results;

              if (stream == null)
              {
            throw new ArgumentNullException("stream");
              }

              results = new ColorCollection();

              for (int i = 0; i < stream.Length / 3; i++)
              {
            int r;
            int g;
            int b;

            r = stream.ReadByte();
            g = stream.ReadByte();
            b = stream.ReadByte();

            results.Add(Color.FromArgb(r, g, b));
              }

              return results;
        }
开发者ID:MEXXIO,项目名称:Arduino-LED-Controller,代码行数:31,代码来源:RawPaletteSerializer.cs

示例2: Deserialize

        /// <summary>
        ///     Deserializes the <see cref="ColorCollection" /> contained by the specified <see cref="Stream" />.
        /// </summary>
        /// <param name="stream">The <see cref="Stream" /> that contains the palette to deserialize.</param>
        /// <returns>The <see cref="ColorCollection" /> being deserialized..</returns>
        public override ColorCollection Deserialize(Stream stream)
        {
            ColorCollection results;

            if (stream == null)
                throw new ArgumentNullException("stream");

            results = new ColorCollection();

            using (var reader = new StreamReader(stream))
            {
                while (!reader.EndOfStream)
                {
                    string line;

                    line = reader.ReadLine();
                    if (!string.IsNullOrEmpty(line) && !line.StartsWith(";") && line.Length == 8)
                    {
                        int a;
                        int r;
                        int g;
                        int b;

                        a = int.Parse(line.Substring(0, 2), NumberStyles.HexNumber);
                        r = int.Parse(line.Substring(2, 2), NumberStyles.HexNumber);
                        g = int.Parse(line.Substring(4, 2), NumberStyles.HexNumber);
                        b = int.Parse(line.Substring(6, 2), NumberStyles.HexNumber);

                        results.Add(Color.FromArgb(a, r, g, b));
                    }
                }
            }

            return results;
        }
开发者ID:samarjeet27,项目名称:ynotesamples,代码行数:40,代码来源:PaintNetPaletteSerializer.cs

示例3: CreateDawnBringer16Palette

    /// <summary>
    /// Creates the DB16 palette.
    /// </summary>
    /// <remarks>http://www.pixeljoint.com/forum/forum_posts.asp?TID=12795</remarks>
    /// <param name="pad">if set to <c>true</c> the palette is padded with black to fill 256 entries.</param>
    protected ColorCollection CreateDawnBringer16Palette(bool pad)
    {
      ColorCollection results;

      results = new ColorCollection();

      results.Add(Color.FromArgb(20, 12, 28));
      results.Add(Color.FromArgb(68, 36, 52));
      results.Add(Color.FromArgb(48, 52, 109));
      results.Add(Color.FromArgb(78, 74, 78));
      results.Add(Color.FromArgb(133, 76, 48));
      results.Add(Color.FromArgb(52, 101, 36));
      results.Add(Color.FromArgb(208, 70, 72));
      results.Add(Color.FromArgb(117, 113, 97));
      results.Add(Color.FromArgb(89, 125, 206));
      results.Add(Color.FromArgb(210, 125, 44));
      results.Add(Color.FromArgb(133, 149, 161));
      results.Add(Color.FromArgb(109, 170, 44));
      results.Add(Color.FromArgb(210, 170, 153));
      results.Add(Color.FromArgb(109, 194, 202));
      results.Add(Color.FromArgb(218, 212, 94));
      results.Add(Color.FromArgb(222, 238, 214));

      if (pad)
      {
        while (results.Count < 256)
        {
          results.Add(Color.FromArgb(0, 0, 0));
        }
      }

      return results;
    }
开发者ID:nabeshin,项目名称:Cyotek.Windows.Forms.ColorPicker,代码行数:38,代码来源:TestBase.cs

示例4: HueColorSlider

 public HueColorSlider()
 {
     BarStyle = ColorBarStyle.Custom;
     Maximum = 359;
     CustomColors =
         new ColorCollection(Enumerable.Range(0, 359).Select(h => new HslColor(h, 1, 0.5).ToRgbColor()));
 }
开发者ID:samarjeet27,项目名称:ynotesamples,代码行数:7,代码来源:HueColorSlider.cs

示例5: ColorGrid

 protected ColorGrid(ColorCollection colors, ColorCollection customColors, ColorPalette palette)
 {
     _cellBackground = Resources.cellbackground;
     _cellBackgroundBrush = new TextureBrush(_cellBackground, WrapMode.Tile);
     SetStyle(
         ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer |
         ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick |
         ControlStyles.SupportsTransparentBackColor, true);
     HotIndex = InvalidIndex;
     ColorRegions = new Dictionary<int, Rectangle>();
     if (Palette != ColorPalette.None)
         Colors = colors;
     else
         Palette = palette;
     CustomColors = customColors;
     ShowCustomColors = true;
     CellSize = new Size(12, 12);
     Spacing = new Size(3, 3);
     Columns = 16;
     AutoSize = true;
     Padding = new Padding(5);
     AutoAddColors = true;
     CellBorderColor = SystemColors.ButtonShadow;
     ShowToolTips = true;
     SeparatorHeight = 8;
     EditMode = ColorEditingMode.CustomOnly;
     Color = Color.Black;
     CellBorderStyle = ColorCellBorderStyle.FixedSingle;
     SelectedCellStyle = ColorGridSelectedCellStyle.Zoomed;
 }
开发者ID:samarjeet27,项目名称:ynotesamples,代码行数:30,代码来源:ColorGrid.cs

示例6: Serialize

    /// <summary>
    /// Serializes the specified <see cref="ColorCollection" /> and writes the palette to a file using the specified <see cref="Stream" />.
    /// </summary>
    /// <param name="stream">The <see cref="Stream" /> used to write the palette.</param>
    /// <param name="palette">The <see cref="ColorCollection" /> to serialize.</param>
    public override void Serialize(Stream stream, ColorCollection palette)
    {
      if (stream == null)
        throw new ArgumentNullException("stream");

      if (palette == null)
        throw new ArgumentNullException("palette");

      // TODO: Allow name and columns attributes to be specified

      using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
      {
        writer.WriteLine("GIMP Palette");
        writer.WriteLine("Name: ");
        writer.WriteLine("Columns: 8");
        writer.WriteLine("#");
        foreach (Color color in palette)
        {
          writer.Write("{0,-3} ", color.R);
          writer.Write("{0,-3} ", color.G);
          writer.Write("{0,-3} ", color.B);
          if (color.IsNamedColor)
            writer.Write(color.Name);
          else
            writer.Write("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
          writer.WriteLine();
        }
      }
    }
开发者ID:koponk,项目名称:Cyotek.Windows.Forms.ColorPicker,代码行数:34,代码来源:GimpPaletteSerializer.cs

示例7: Deserialize

        /// <summary>
        ///     Deserializes the <see cref="ColorCollection" /> contained by the specified <see cref="Stream" />.
        /// </summary>
        /// <param name="stream">The <see cref="Stream" /> that contains the palette to deserialize.</param>
        /// <returns>The <see cref="ColorCollection" /> being deserialized..</returns>
        public override ColorCollection Deserialize(Stream stream)
        {
            ColorCollection results;

            if (stream == null)
                throw new ArgumentNullException("stream");

            results = new ColorCollection();

            using (var reader = new StreamReader(stream))
            {
                string header;
                string startHeader;

                // check signature
                header = reader.ReadLine();
                startHeader = reader.ReadLine();

                if (header != "GIMP Palette")
                    throw new InvalidDataException("Invalid palette file");

                while (startHeader != "#")
                    startHeader = reader.ReadLine();

                while (!reader.EndOfStream)
                {
                    int r;
                    int g;
                    int b;
                    string data;
                    string[] parts;

                    data = reader.ReadLine();
                    parts = !string.IsNullOrEmpty(data)
                        ? data.Split(new[]
                        {
                            ' ', '\t'
                        }, StringSplitOptions.RemoveEmptyEntries)
                        : new string[0];

                    if (!int.TryParse(parts[0], out r) || !int.TryParse(parts[1], out g) ||
                        !int.TryParse(parts[2], out b))
                        throw new InvalidDataException(string.Format("Invalid palette contents found with data '{0}'",
                            data));

                    results.Add(Color.FromArgb(r, g, b));
                }
            }

            return results;
        }
开发者ID:samarjeet27,项目名称:ynotesamples,代码行数:56,代码来源:GimpPaletteSerializer.cs

示例8: Deserialize

        /// <summary>
        ///     Deserializes the <see cref="ColorCollection" /> contained by the specified <see cref="Stream" />.
        /// </summary>
        /// <param name="stream">The <see cref="Stream" /> that contains the palette to deserialize.</param>
        /// <returns>The <see cref="ColorCollection" /> being deserialized..</returns>
        public override ColorCollection Deserialize(Stream stream)
        {
            ColorCollection results;

            if (stream == null)
                throw new ArgumentNullException("stream");

            results = new ColorCollection();

            using (var reader = new StreamReader(stream))
            {
                string header;
                string version;
                int colorCount;

                // check signature
                header = reader.ReadLine();
                version = reader.ReadLine();

                if (header != "JASC-PAL" || version != "0100")
                    throw new InvalidDataException("Invalid palette file");

                colorCount = Convert.ToInt32(reader.ReadLine());
                for (int i = 0; i < colorCount; i++)
                {
                    int r;
                    int g;
                    int b;
                    string data;
                    string[] parts;

                    data = reader.ReadLine();
                    parts = !string.IsNullOrEmpty(data)
                        ? data.Split(new[]
                        {
                            ' ', '\t'
                        }, StringSplitOptions.RemoveEmptyEntries)
                        : new string[0];

                    if (!int.TryParse(parts[0], out r) || !int.TryParse(parts[1], out g) ||
                        !int.TryParse(parts[2], out b))
                        throw new InvalidDataException(string.Format("Invalid palette contents found with data '{0}'",
                            data));

                    results.Add(Color.FromArgb(r, g, b));
                }
            }

            return results;
        }
开发者ID:samarjeet27,项目名称:ynotesamples,代码行数:55,代码来源:JascPaletteSerializer.cs

示例9: EqualsNullTest

    public void EqualsNullTest()
    {
      // arrange
      ColorCollection target;
      bool actual;

      target = new ColorCollection();

      // act
      actual = target.Equals(null);

      // assert
      actual.Should().BeFalse();
    }
开发者ID:nabeshin,项目名称:Cyotek.Windows.Forms.ColorPicker,代码行数:14,代码来源:ColorCollectionTests.cs

示例10: CreateDawnBringer32Palette

    /// <summary>
    /// Creates the DB32 palette.
    /// </summary>
    /// <remarks>http://www.pixeljoint.com/forum/forum_posts.asp?TID=16247</remarks>
    /// <param name="pad">if set to <c>true</c> the palette is padded with black to fill 256 entries.</param>
    protected ColorCollection CreateDawnBringer32Palette(bool pad)
    {
      ColorCollection results;

      results = new ColorCollection();

      results.Add(Color.FromArgb(0, 0, 0));
      results.Add(Color.FromArgb(34, 32, 52));
      results.Add(Color.FromArgb(69, 40, 60));
      results.Add(Color.FromArgb(102, 57, 49));
      results.Add(Color.FromArgb(143, 86, 59));
      results.Add(Color.FromArgb(223, 113, 38));
      results.Add(Color.FromArgb(217, 160, 102));
      results.Add(Color.FromArgb(238, 195, 154));
      results.Add(Color.FromArgb(251, 242, 54));
      results.Add(Color.FromArgb(153, 229, 80));
      results.Add(Color.FromArgb(106, 190, 48));
      results.Add(Color.FromArgb(55, 148, 110));
      results.Add(Color.FromArgb(75, 105, 47));
      results.Add(Color.FromArgb(82, 75, 36));
      results.Add(Color.FromArgb(50, 60, 57));
      results.Add(Color.FromArgb(63, 63, 116));
      results.Add(Color.FromArgb(48, 96, 130));
      results.Add(Color.FromArgb(91, 110, 225));
      results.Add(Color.FromArgb(99, 155, 255));
      results.Add(Color.FromArgb(95, 205, 228));
      results.Add(Color.FromArgb(203, 219, 252));
      results.Add(Color.FromArgb(255, 255, 255));
      results.Add(Color.FromArgb(155, 173, 183));
      results.Add(Color.FromArgb(132, 126, 135));
      results.Add(Color.FromArgb(105, 106, 106));
      results.Add(Color.FromArgb(89, 86, 82));
      results.Add(Color.FromArgb(118, 66, 138));
      results.Add(Color.FromArgb(172, 50, 50));
      results.Add(Color.FromArgb(217, 87, 99));
      results.Add(Color.FromArgb(215, 123, 186));
      results.Add(Color.FromArgb(143, 151, 74));
      results.Add(Color.FromArgb(138, 111, 48));

      if (pad)
      {
        while (results.Count < 256)
        {
          results.Add(Color.FromArgb(0, 0, 0));
        }
      }

      return results;
    }
开发者ID:nabeshin,项目名称:Cyotek.Windows.Forms.ColorPicker,代码行数:54,代码来源:TestBase.cs

示例11: Serialize

    /// <summary>
    /// Serializes the specified <see cref="ColorCollection" /> and writes the palette to a file using the specified <see cref="Stream" />.
    /// </summary>
    /// <param name="stream">The <see cref="Stream" /> used to write the palette.</param>
    /// <param name="palette">The <see cref="ColorCollection" /> to serialize.</param>
    public override void Serialize(Stream stream, ColorCollection palette)
    {
      if (stream == null)
        throw new ArgumentNullException("stream");

      if (palette == null)
        throw new ArgumentNullException("palette");

      using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
      {
        writer.WriteLine("JASC-PAL");
        writer.WriteLine("0100");
        writer.WriteLine(palette.Count);
        foreach (Color color in palette)
        {
          writer.Write("{0} ", color.R);
          writer.Write("{0} ", color.G);
          writer.Write("{0} ", color.B);
          writer.WriteLine();
        }
      }
    }
开发者ID:koponk,项目名称:Cyotek.Windows.Forms.ColorPicker,代码行数:27,代码来源:JascPaletteSerializer.cs

示例12: Serialize

    /// <summary>
    /// Serializes the specified <see cref="ColorCollection" /> and writes the palette to a file using the specified <see cref="Stream" />.
    /// </summary>
    /// <param name="stream">The <see cref="Stream" /> used to write the palette.</param>
    /// <param name="palette">The <see cref="ColorCollection" /> to serialize.</param>
    public override void Serialize(Stream stream, ColorCollection palette)
    {
      if (stream == null)
        throw new ArgumentNullException("stream");

      if (palette == null)
        throw new ArgumentNullException("palette");

      // TODO: Not writing 96 colors, but the entire contents of the palette, wether that's less than 96 or more

      using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
      {
        writer.WriteLine(@"; Paint.NET Palette File
; Lines that start with a semicolon are comments
; Colors are written as 8-digit hexadecimal numbers: aarrggbb
; For example, this would specify green: FF00FF00
; The alpha ('aa') value specifies how transparent a color is. FF is fully opaque, 00 is fully transparent.
; A palette must consist of ninety six (96) colors. If there are less than this, the remaining color
; slots will be set to white (FFFFFFFF). If there are more, then the remaining colors will be ignored.");
        foreach (Color color in palette)
          writer.WriteLine("{0:X2}{1:X2}{2:X2}{3:X2}", color.A, color.R, color.G, color.B);
      }
    }
开发者ID:koponk,项目名称:Cyotek.Windows.Forms.ColorPicker,代码行数:28,代码来源:PaintNetPaletteSerializer.cs

示例13: Serialize

    public void Serialize(Stream stream, ColorCollection palette, AdobePhotoshopColorSwatchFileVersion version, AdobePhotoshopColorSwatchColorSpace colorSpace)
    {
      if (stream == null)
      {
        throw new ArgumentNullException(nameof(stream));
      }

      if (palette == null)
      {
        throw new ArgumentNullException(nameof(palette));
      }

      if (version == AdobePhotoshopColorSwatchFileVersion.Version2)
      {
        this.WritePalette(stream, palette, AdobePhotoshopColorSwatchFileVersion.Version1, colorSpace);
      }
      this.WritePalette(stream, palette, version, colorSpace);
    }
开发者ID:FrankGITDeveloper,项目名称:Landsknecht_GreenScreen,代码行数:18,代码来源:AdobePhotoShopColorSwatchSerializer.cs

示例14: ApplyColorCollection

        private void ApplyColorCollection(ColorCollection Collection, bool RandomOrder)
        {
            if (!Collection.Color.Any())
                return;

            bool strayElement = false;
            Color thisColor, thisColor2 = Color.White;
            int iPos = 0;

            foreach (Element elem in TimelineControl.SelectedElements)
            {
                string effectName = elem.EffectNode.Effect.EffectName;
                object[] parms = new object[elem.EffectNode.Effect.ParameterValues.Count()];
                List<Color> validColors = new List<Color>();

                Array.Copy(elem.EffectNode.Effect.ParameterValues, parms, parms.Count());
                validColors.AddRange(elem.EffectNode.Effect.TargetNodes.SelectMany(x => ColorModule.getValidColorsForElementNode(x, true)));

                if (RandomOrder)
                {
                    int r1 = rnd.Next(Collection.Color.Count());
                    int r2 = rnd.Next(Collection.Color.Count());

                    int n = 0;
                    while (r1 == r2 && n <= 5)
                    {
                        r2 = rnd.Next(Collection.Color.Count());
                        n++;
                    }

                    thisColor = Collection.Color[r1];
                    thisColor2 = Collection.Color[r2];
                }
                else
                {
                    if (iPos == Collection.Color.Count()) { iPos = 0; }
                    thisColor = Collection.Color[iPos];
                    iPos++;
                    if (effectName == "Alternating")
                    {
                        thisColor2 = Collection.Color[iPos];
                        iPos++;
                    }
                }

                if (validColors.Any() && !validColors.Contains(thisColor)) { thisColor = validColors[rnd.Next(validColors.Count())]; }

                if (effectName == "Alternate")
                {
                    if (validColors.Any() && !validColors.Contains(thisColor2)) { thisColor2 = validColors[rnd.Next(validColors.Count())]; }

                    int n2 = 0;
                    while (thisColor2 == thisColor && n2 <= 5)
                    {
                        thisColor2 = validColors[rnd.Next(validColors.Count())];
                        n2++;
                    }
                }

                switch (effectName)
                {
                    case "Candle Flicker":
                    case "LipSync":
                    case "Nutcracker":
                    case "Launcher":
                    case "RDS":
                        strayElement = true;
                        break;
                    case "Custom Value":
                        //Disabled until we fix the custom value null reference errors - not related to this.
                        //parms[0] = 4; //Set it to a type of color value
                        //parms[5] = thisColor;
                        strayElement = true;
                        break;
                    case "Alternating":
                        parms[1] = thisColor;
                        parms[3] = thisColor2;
                        parms[8] = parms[9] = true;
                        break;
                    case "Set Level":
                        parms[1] = thisColor;
                        break;
                    case "Pulse":
                        parms[1] = new ColorGradient(thisColor);
                        break;
                    case "Chase":
                        parms[0] = 0; // StaticColor
                        parms[3] = thisColor;
                        break;
                    case "Spin":
                        parms[2] = 0; // StaticColor
                        parms[9] = thisColor;
                        break;
                    case "Twinkle":
                        parms[7] = 0; // StaticColor
                        parms[8] = thisColor;
                        break;
                    case "Wipe":
                        parms[0] = new ColorGradient(thisColor);
                        break;
//.........这里部分代码省略.........
开发者ID:komby,项目名称:vixen,代码行数:101,代码来源:TimedSequenceEditorForm.cs

示例15: PopulateCollectionColors

        private void PopulateCollectionColors(ColorCollection collection)
        {
            listViewColors.BeginUpdate();
            listViewColors.Items.Clear();

            listViewColors.LargeImageList = new ImageList();
            listViewColors.LargeImageList.ColorDepth = ColorDepth.Depth32Bit;
            listViewColors.LargeImageList.ImageSize = new Size(48, 48);

            foreach (Color colorItem in collection.Color)
            {
                Bitmap result = new Bitmap(48,48);
                Graphics gfx = Graphics.FromImage(result);
                using (SolidBrush brush = new SolidBrush(colorItem))
                {
                    gfx.FillRectangle(brush, 0, 0, 48, 48);
                    gfx.DrawRectangle(_borderPen, 0, 0, 48, 48);
                }

                listViewColors.LargeImageList.Images.Add(colorItem.ToString(), result);

                ListViewItem item = new ListViewItem
                {
                    ToolTipText = string.Format("R: {0} G: {1} B: {2}", colorItem.R, colorItem.G, colorItem.B),
                    ImageKey = colorItem.ToString(),
                    Tag = colorItem
                };

                listViewColors.Items.Add(item);
            }
            listViewColors.EndUpdate();
            buttonAddColor.Enabled = true;
        }
开发者ID:jaredb7,项目名称:vixen,代码行数:33,代码来源:ColorCollectionLibrary_Form.cs


注:本文中的ColorCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。