コード例 #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());
        }
コード例 #2
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;
        }