Ejemplo n.º 1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if(keyData == Keys.Left)
            {
                if(selectedColumn > 0)
                    selectedColumn--;

                Redraw();

                return true;
            }
            else if(keyData == Keys.Right)
            {
                if(selectedColumn < intValue.ToString().Length)
                    selectedColumn++;

                Redraw();

                return true;
            }
            else if(keyData == Keys.Up || keyData == Keys.Down)
            {
                string numberString = intValue.ToString();

                if(selectedColumn >= 0)
                {
                    char columnChar = '0';

                    if(selectedColumn < numberString.Length)
                        columnChar = numberString[selectedColumn];
                    else
                    {
                        numberString += "0";
                    }

                    if(Char.IsNumber(columnChar))
                    {
                        int newValue = Convert.ToInt32(columnChar.ToString());

                        if(keyData == Keys.Up)
                            newValue++;
                        else
                            newValue--;

                        if(newValue > 9)
                            newValue = 0;
                        else if(newValue < 0)
                            newValue = 9;

                        numberString = numberString.Remove(selectedColumn, 1);
                        numberString = numberString.Insert(selectedColumn, newValue.ToString());

                        SetStringValue(numberString);
                    }
                }

                return true;
            }
            else
                return base.ProcessCmdKey(ref msg, keyData);
        }
Ejemplo n.º 2
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if(popupWindow.Visible && listBox.Items.Count > 0)
            {
                if(keyData == Keys.Up)
                {
                    if(listBox.SelectedIndex <= 0)
                        listBox.SelectedIndex = listBox.Items.Count - 1;
                    else
                        listBox.SelectedIndex--;

                    return true;
                }
                else if(keyData == Keys.Down)
                {
                    if(listBox.SelectedIndex >= listBox.Items.Count - 1)
                        listBox.SelectedIndex = 0;
                    else
                        listBox.SelectedIndex++;

                    return true;
                }
            }

            return base.ProcessCmdKey (ref msg, keyData);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 判断是否是enter按键
 /// </summary>
 private bool IsTerminatorKey(Keys key)
 {
     return key == Keys.Enter;
 }