Пример #1
0
        public static void Main()
        {
            _tabColors = new Double[4];

            _color = new ColorClick(Hardware.SC20260_1);

            _color.LedR.Write(GpioPinValue.High);
            _color.LedG.Write(GpioPinValue.High);
            _color.LedB.Write(GpioPinValue.High);

            _color.Gain            = ColorClick.Gains.x4;
            _color.IntegrationTime = 200;

            Debug.WriteLine($"Color ID : {_color.GetID()}");
            Debug.WriteLine($"Integration time : {_color.IntegrationTime}");
            Debug.WriteLine($"Wait time : {_color.WaitTime}");
            Debug.WriteLine($"Wait long : {_color.WaitLong}");
            Debug.WriteLine($"Gain : {_color.Gain}");

            while (true)
            {
                var colorTmp = 0.0;

                for (var i = 0; i < 5; i++)
                {
                    _tabColors = _color.GetAllChannels();
                    colorTmp  += _color.RGBtoHSL(_tabColors[0] / _tabColors[3], _tabColors[1] / _tabColors[3], _tabColors[2] / _tabColors[3]);
                }
                colorTmp /= 16;

                Debug.WriteLine("Color : " + colorTmp);

                Thread.Sleep(1200);
            }
        }
Пример #2
0
        private void picPalette_MouseDown(object sender, MouseEventArgs e)
        {
            float xPos = (float)e.X / picPalette.Width;
            float yPos = (float)e.Y / picPalette.Height;

            float y = yPos < 0.5 ? yPos : (yPos - 0.5f);
            float x = yPos < 0.5 ? xPos : (xPos + 1);

            int offset = (int)(x * 8) + (int)(y * 8) * 16;

            ColorClick?.Invoke(offset);
        }
Пример #3
0
        private void CreateColorPanel()
        {
            ColorList colorList = bmp.colorCountList;

            for (int i = 0; i < colorList.Count; i++)
            {
                if (colorList[i].ColorCount == 0)
                {
                    continue;
                }
                colorCount++;
                Panel p = new Panel();
                p.Width  = 130;
                p.Height = 16;
                //p.BackColor = colors[i];

                Panel p1 = new Panel();
                p1.Width     = 16;
                p1.Height    = 16;
                p1.BackColor = colorList[i].Brush.Color;
                p1.Tag       = colorList[i].Tag;
                p1.Cursor    = Cursors.Hand;
                if (!string.IsNullOrEmpty(colorList[i].Name))
                {
                    toolTip1.SetToolTip(p1, colorList[i].Name);
                }
                p1.Click += (s, e) => { ColorClick?.Invoke(p1, this.bmp); };
                p.Controls.Add(p1);


                Label l = new Label();
                l.Width     = 114;
                l.Height    = 16;
                l.Left      = 18;
                l.TextAlign = ContentAlignment.MiddleLeft;
                l.AutoSize  = false;
                l.Text      = colorList[i].ColorCount.ToString();
                p.Controls.Add(l);


                flowLayoutPanel1.Controls.Add(p);
            }
        }
Пример #4
0
        public static void Main()
        {
            _tabColors = new Double[4];

            _color = new ColorClick(Hardware.SocketOne);

            _color.LedR.Write(true);
            _color.LedG.Write(true);
            _color.LedB.Write(true);

            _color.Gain            = ColorClick.Gains.x4;
            _color.IntegrationTime = 200;

            Debug.Print("Color ID : " + _color.GetID());
            Debug.Print("Integration time : " + _color.IntegrationTime);
            Debug.Print("Wait time : " + _color.WaitTime);
            Debug.Print("Wait long : " + _color.WaitLong);
            Debug.Print("Gain : " + _color.Gain);

            while (true)
            {
                var colorTmp = 0.0;

                for (var i = 0; i < 5; i++)
                {
                    _tabColors = _color.GetAllChannels();
// ReSharper disable PossibleLossOfFraction
                    colorTmp += _color.RGBtoHSL(_tabColors[0] / _tabColors[3], _tabColors[1] / _tabColors[3], _tabColors[2] / _tabColors[3]);
// ReSharper enable PossibleLossOfFraction
                }
                colorTmp /= 16;

                Debug.Print("Color : " + colorTmp);

                Thread.Sleep(1200);
            }
// ReSharper disable once FunctionNeverReturns
        }
Пример #5
0
        public override void Update(Universe universe, Vector2 origin, AvatarController avatar, List <ScanCode> input, bool ctrl, bool shift, IReadOnlyList <InterfaceLogicalButton> inputPressed,
                                    Vector2 mouseLocation, bool click, bool clickHold)
        {
            if (!Window.CallUpdates && !Window.Visible)
            {
                return;
            }

            var location = Helpers.VectorLocation(origin,
                                                  new Vector2(origin.X + _colorWheel.Width, origin.Y + _colorWheel.Height),
                                                  mouseLocation);

            if (location.X == -1 || location.Y == -1)
            {
                return;
            }

            Color color;

            try {
                color = Helpers.GetColorByCoordinate(_colorWheel.GetTexture(null), location);
            } catch {
                return;
            }

            if (color == Color.Transparent)
            {
                return;
            }

            ColorHover?.Invoke(color);

            if (click || clickHold)
            {
                ColorClick?.Invoke(color);
            }
        }
Пример #6
0
 void ColorPickup_MouseClick(object sender, MouseEventArgs e)
 {
     ColorClick?.Invoke(GetColor(new Point(e.X, e.Y)));
 }
Пример #7
0
 protected virtual void OnColorClick(EventArgs e, ColorButton sender)
 {
     ColorClick?.Invoke(sender, e);
 }
Пример #8
0
 public void OnColorClick(object sender, RibbonEventArgs e) =>
 ColorClick?.Invoke(sender, e);
Пример #9
0
 protected virtual void OnColorClick(ButtonPressEventArgs e, object sender)
 {
     ColorClick?.Invoke(sender, e);
 }