Exemplo n.º 1
0
        /// <summary>
        /// Gets the config string
        /// </summary>
        public string GetConfigString()
        {
            StringBuilder sb = new StringBuilder();

            foreach (Color c in Colors)
            {
                sb.Append(ColorParser.GetColorString(c));
            }
            return(sb.ToString());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sets the config string
 /// </summary>
 /// <param name="config">sting in format RRGGBB</param>
 public void SetConfigString(string config)
 {
     Colors.Clear();
     for (int i = 0; i < config.Length; i += 6)
     {
         string sub = config.Substring(i, 6);
         if (sub.Length < 6)
         {
             break;
         }
         Colors.Add(ColorParser.GetColor(sub));
         if (Colors.Count >= 27)
         {
             break;
         }
         Image  old_bmp = pictureBox1.Image;
         Bitmap bmp     = PrepareHSVBitmap();
         pictureBox1.Image = bmp;
         if (old_bmp != null)
         {
             old_bmp.Dispose();
         }
     }
 }
Exemplo n.º 3
0
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            int   x  = m_X + e.X;
            int   y  = m_Y + e.Y;
            Color cc = Color.Black;

            if (x >= 0 && y >= 0 && x < m_Image.Width && y < m_Image.Height)
            {
                cc = m_Image.GetPixel(x, y);
            }
            string c = ColorParser.GetColorString(cc);

            bool[] modifier_Shift = new bool[3];
            modifier_Shift[0] = GetAsyncKeyState(Keys.ShiftKey) < 0;
            modifier_Shift[1] = GetAsyncKeyState(Keys.ControlKey) < 0;
            modifier_Shift[2] = GetAsyncKeyState(Keys.Alt) < 0;

            if (e.Button == MouseButtons.Left)
            {
                m_LastClickX = x;
                m_LastClickY = y;
                if (OnDigitizerEventReceived != null)
                {
                    OnDigitizerEventReceived(x, y, 0, 0, c, e, modifier_Shift);
                }
                StringBuilder sb = new StringBuilder();
                sb.Append("Origin: X=");
                sb.Append(m_LastClickX.ToString());
                sb.Append(", Y=");
                sb.Append(m_LastClickY.ToString());
                sb.Append(", C=");
                sb.Append(c);
                toolStripStatusLabel1.Text = sb.ToString();
                return;
            }
            if (e.Button == MouseButtons.Right)
            {
                int x1 = x;
                int y1 = y;
                if (m_LastClickX > 0)
                {
                    x1 = x - m_LastClickX;
                }
                if (m_LastClickY > 0)
                {
                    y1 = y - m_LastClickY;
                }
                if (OnDigitizerEventReceived == null)
                {
                    return;
                }
                OnDigitizerEventReceived(x, y, x1, y1, c, e, modifier_Shift);
                return;
            }
            if (e.Button == MouseButtons.Middle)
            {
                if (OnDigitizerEventReceived == null)
                {
                    return;
                }
                OnDigitizerEventReceived(x, y, 0, 0, c, e, modifier_Shift);
                return;
            }
            ((HandledMouseEventArgs)e).Handled = true;
        }