Пример #1
0
        public string GenerateRasterCode(ColorCode p_cc = null)
        {
            Bitmap b = new Bitmap(IMAGE_LENGTH+1, IMAGE_WIDTH+1);
            panelDrawPad.DrawToBitmap(b, new Rectangle(0, 0, IMAGE_LENGTH + 1, IMAGE_WIDTH + 1));
            RasterInterpreter r = new RasterInterpreter(chkPowerGrayScale.Checked);
            List<ColorCode> Rasters = new List<ColorCode>();

            //Raster all if inputed ColorCode is null
            if (p_cc == null)
            {
                foreach (ColorCode cc in Colors)
                {
                    if (cc.Type == ColorCode.ColorType.Raster)
                    {
                        Rasters.Add(cc);
                    }
                }
            }
            else //Raster only the ColorCode inputed
            {
                Rasters.Add(p_cc);
            }
            
            return r.Convert(b, Rasters);
        }
Пример #2
0
        public void AddColor()
        {
            if (panelColorCodes.Controls.Count == 0)
            {
                loc = 0;
            }

            int defaultPower = 50;

            ColorCode cc = new ColorCode();
            cc.Id = colorcount;
            cc.Ccolor = CurrentColour;
            cc.Type = ColorCode.ColorType.Raster;
            cc.Power = defaultPower;
            cc.Speed = 0;
            
            ComboBox c = new ComboBox();
            c.DropDownStyle = ComboBoxStyle.DropDownList;
            c.Name = colorcount + "c";
            c.Items.Add("Vector");
            c.Items.Add("Raster");
            c.SelectedIndex = 1;
            c.SelectedText = "Vector";
            c.Location = new Point(25, loc);
            c.SelectedIndexChanged += new EventHandler(c_SelectedIndexChanged);
            panelColorCodes.Controls.Add(c);
            loc = loc + 25;

            Label l = new Label();
            l.Name = CurrentColour.Name;
            l.Width = 20;
            l.Height = 20;
            l.BackColor = CurrentColour;
            l.DoubleClick += new EventHandler(l_DoubleClick);

            l.Location = new Point(0, loc);
            panelColorCodes.Controls.Add(l);

            Label p = new Label();
            p.Text = "P";
            p.AutoSize = true;
            p.Location = new Point(25, loc);
            panelColorCodes.Controls.Add(p);

            TrackBar pt = new TrackBar();
            pt.Name = colorcount.ToString();
            pt.Minimum = 0;
            pt.Maximum = 100;
            pt.Value = defaultPower;
            //pt.Width = 100;
            //pt.Height = 45;
            pt.TickFrequency = 1;
            pt.TickStyle = TickStyle.BottomRight;
            pt.SmallChange = 1;
            pt.LargeChange = 5;
            pt.Orientation = Orientation.Horizontal;
            pt.AutoSize = true;
            pt.Scroll += new EventHandler(pt_Scroll);
            pt.Location = new Point(35, loc);
            panelColorCodes.Controls.Add(pt);

            Label val = new Label();
            val.Name = colorcount + "val";
            val.AutoSize = true;
            val.Location = new Point(pt.Location.X + pt.Width, loc);
            val.Text = pt.Value.ToString();
            panelColorCodes.Controls.Add(val);

            loc = loc + 45;

            Label sep = new Label();
            sep.AutoSize = false;
            sep.Height = 2;
            sep.Width = panelColorCodes.Width;
            sep.BorderStyle = BorderStyle.Fixed3D;
            sep.Location = new Point(0,loc);
            panelColorCodes.Controls.Add(sep);

            loc = loc + 5;


            //Power.Add(pt.Value);
            Colors.Add(cc);
            colorcount++;


            CurrentColourCode = cc;

            //loc = loc + 20;
        }