Exemplo n.º 1
0
        /// <summary>
        /// 键盘按下方法
        /// </summary>
        /// <param name="key">按键</param>
        public override void onKeyDown(char key)
        {
            base.onKeyDown(key);
            FCHost host = Native.Host;

            if (!host.isKeyPress(0x10) && !host.isKeyPress(0x11) && !host.isKeyPress(0x12))
            {
                if (LinesCount <= 1)
                {
                    if (key == 13 || key == 38 || key == 40)
                    {
                        if (m_dropDownMenu != null)
                        {
                            m_dropDownMenu.onKeyDown(key);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 键盘按下方法
        /// </summary>
        /// <param name="key">按键</param>
        public override void onKeyDown(char key)
        {
            base.onKeyDown(key);
            FCHost host = Native.Host;

            if (!host.isKeyPress(0x10) && !host.isKeyPress(0x11) && !host.isKeyPress(0x12))
            {
                //向上
                if (key == 38)
                {
                    lineUp();
                }
                //向下
                else if (key == 40)
                {
                    lineDown();
                }
                invalidate();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 键盘方法
        /// </summary>
        /// <param name="key">按键</param>
        public override void onKeyDown(char key)
        {
            base.onKeyDown(key);
            FCHost host = Native.Host;

            if (!host.isKeyPress(0x10) && !host.isKeyPress(0x11) && !host.isKeyPress(0x12))
            {
                CMonth thisMonth = Month;
                CMonth lastMonth = getLastMonth(m_year, m_month);
                CMonth nextMonth = getNextMonth(m_year, m_month);
                int    today     = m_selectedDay.Day;
                if (key >= 37 && key <= 40)
                {
                    switch ((int)key)
                    {
                    case 37:
                        if (m_selectedDay == thisMonth.FirstDay)
                        {
                            SelectedDay = lastMonth.LastDay;
                        }
                        else
                        {
                            SelectedDay = thisMonth.Days.get(today - 1);
                        }
                        break;

                    case 38:
                        if (today <= 7)
                        {
                            SelectedDay = lastMonth.Days.get(lastMonth.Days.size() - (7 - today));
                        }
                        else
                        {
                            SelectedDay = thisMonth.Days.get(m_selectedDay.Day - 7);
                        }
                        break;

                    case 39:
                        if (m_selectedDay == thisMonth.LastDay)
                        {
                            SelectedDay = nextMonth.FirstDay;
                        }
                        else
                        {
                            SelectedDay = thisMonth.Days.get(today + 1);
                        }
                        break;

                    case 40:
                        if (today > thisMonth.Days.size() - 7)
                        {
                            SelectedDay = nextMonth.Days.get(7 - (thisMonth.Days.size() - today));
                        }
                        else
                        {
                            SelectedDay = thisMonth.Days.get(today + 7);
                        }
                        break;
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 键盘按下方法
        /// </summary>
        /// <param name="key">按键</param>
        public override void onKeyDown(char key)
        {
            if (m_autoFormat)
            {
                if (key == 8 || key == 46)
                {
                    String text = Text;
                    if (text.Length > 0)
                    {
                        int curPos = SelectionStart;
                        if (text.IndexOf(".") != -1 && text.IndexOf(".") == curPos - 1 && SelectionLength <= 1)
                        {
                            SelectionStart = curPos - 1;
                            curPos         = SelectionStart;
                        }
                        if (SelectionStart == 0)
                        {
                            int len = SelectionLength + 1;
                            if (len > text.Length)
                            {
                                len = text.Length;
                            }
                            m_text = text.Substring(len);
                        }
                        else
                        {
                            deleteWord();
                        }
                        bool deleteAll = m_text.Length == 0;
                        setRegion();
                        if (curPos > 0)
                        {
                            SelectionStart = curPos - 1;
                        }
                        else
                        {
                            SelectionStart = curPos;
                        }
                        if (deleteAll)
                        {
                            SelectionStart  = m_text.Length;
                            SelectionLength = 0;
                        }
                        else if (curPos == 0 && m_text.IndexOf("0.") == 0)
                        {
                            SelectionStart = m_text.Length;
                        }
                        m_showCursor = true;
                        onTextChanged();
                        onValueChanged();
                        invalidate();
                        return;
                    }
                }
            }
            base.onKeyDown(key);
            FCHost host = Native.Host;

            if (!host.isKeyPress(0x10) && !host.isKeyPress(0x11) && !host.isKeyPress(0x12))
            {
                if (key == 38)
                {
                    Add();
                    invalidate();
                }
                else if (key == 40)
                {
                    reduce();
                    invalidate();
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 输入文字方法
        /// </summary>
        /// <param name="ch">字符</param>
        public override void onChar(char ch)
        {
            if (m_autoFormat)
            {
                callEvents(FCEventID.CHAR);
                FCHost host = Native.Host;
                if (!host.isKeyPress(0x11))
                {
                    bool flag = false;
                    if (SelectionLength > 0)
                    {
                        flag = true;
                    }
                    char inputCharacter = ch;
                    int  curPos         = SelectionStart;
                    bool cursorIsLast   = false;
                    if (curPos == m_text.Length)
                    {
                        cursorIsLast = true;
                    }
                    int exCount = 0;
                    if (inputCharacter == 8)
                    {
                        if (SelectionLength > 0)
                        {
                            if (SelectionStart > 0 && m_text[SelectionStart - 1] == ',')
                            {
                                SelectionStart  = SelectionStart - 1;
                                SelectionLength = SelectionLength + 1;
                                curPos          = SelectionStart;
                            }
                            Text           = FormatNum(Text);
                            SelectionStart = curPos;
                        }
                        else
                        {
                            if (SelectionStart > 0 && m_text[SelectionStart - 1] == ',')
                            {
                                SelectionStart = SelectionStart - 1;
                                curPos         = SelectionStart;
                            }

                            if (SelectionStart > 0 && m_text[SelectionStart - 1] == '.')
                            {
                                string sub = m_text.Substring(SelectionStart);
                                exCount = sub.Length / 3;
                            }
                            int    length  = m_text.Length - curPos;
                            string oriText = Text;
                            int    diff    = 0;
                            if (oriText.StartsWith(","))
                            {
                                oriText = oriText.Substring(1);
                                diff    = 1;
                            }
                            m_text = FormatNum(Text);
                            if (Text.Length + diff - exCount - length > 0)
                            {
                                SelectionStart = m_text.Length + diff - exCount - length;
                            }
                        }
                        invalidate();
                        return;
                    }
                    if (inputCharacter == 46)
                    {
                        if (m_text.Contains("."))
                        {
                            if (m_text.IndexOf(".") != m_text.Length - 1)
                            {
                                SelectionStart = m_text.IndexOf(".") + 1;
                            }
                            invalidate();
                            return;
                        }
                    }
                    int backLength = m_text.Length - curPos;
                    if (inputCharacter == 46)
                    {
                        string sub = m_text.Substring(SelectionStart);
                        exCount = sub.Length - sub.Replace(",", "").Length;
                        insertWord(ch.ToString());
                        onTextChanged();
                        onValueChanged();
                        invalidate();
                        return;
                    }
                    bool removeCharFlag = false;
                    if (m_selectionLength > 0 && m_selectionLength == m_text.Length)
                    {
                        m_text          = "";
                        SelectionLength = 0;
                    }
                    else if (m_text.StartsWith("0."))
                    {
                        if (SelectionStart == 0)
                        {
                            removeCharFlag  = true;
                            m_text          = m_text.Substring(1);
                            SelectionLength = 0;
                        }
                    }
                    String oldText = Text;
                    int    index   = m_text.IndexOf(".");
                    if (m_selectionLength == 0 && index < SelectionStart)
                    {
                        m_selectionLength = 1;
                    }
                    insertWord(ch.ToString());
                    int selectionStart = SelectionStart;
                    setRegion();
                    m_selectionLength = 0;
                    String newText = Text;
                    if (newText.Length > 0 && selectionStart > newText.Length)
                    {
                        SelectionStart = newText.Length;
                    }
                    if (((m_text.IndexOf(".") != -1) && (m_text.IndexOf(".") < selectionStart)) || flag)
                    {
                        SelectionStart = selectionStart;
                    }
                    else
                    {
                        if (cursorIsLast == true)
                        {
                            SelectionStart = m_text.Length + 1;
                        }
                        else
                        {
                            if (m_text.Length + exCount - backLength >= 0)
                            {
                                SelectionStart = m_text.Length + exCount - backLength;
                            }
                        }
                    }
                    if (removeCharFlag)
                    {
                        SelectionStart = SelectionStart + 1;
                    }
                    m_showCursor = true;
                    onTextChanged();
                    onValueChanged();
                    invalidate();
                }
            }
            else
            {
                base.onChar(ch);
            }
        }