Ejemplo n.º 1
0
        /// <summary>
        /// 控件添加方法
        /// </summary>
        public override void onLoad()
        {
            base.onLoad();
            //添加按钮
            FCHost host = Native.Host;

            if (m_addButton == null)
            {
                m_addButton = host.createInternalControl(this, "addbutton") as FCButton;
                m_addButton.addEvent(m_addButtonTouchDownEvent, FCEventID.TOUCHDOWN);
                m_addButton.addEvent(m_addButtonTouchUpEvent, FCEventID.TOUCHUP);
                addControl(m_addButton);
            }
            if (m_backButton == null)
            {
                m_backButton = host.createInternalControl(this, "backbutton") as FCButton;
                addControl(m_backButton);
            }
            if (m_reduceButton == null)
            {
                m_reduceButton = host.createInternalControl(this, "reducebutton") as FCButton;
                m_reduceButton.addEvent(m_reduceButtonTouchDownEvent, FCEventID.TOUCHDOWN);
                m_reduceButton.addEvent(m_reduceButtonTouchUpEvent, FCEventID.TOUCHUP);
                addControl(m_reduceButton);
            }
            if (m_scrollButton == null)
            {
                m_scrollButton           = host.createInternalControl(this, "scrollbutton") as FCButton;
                m_scrollButton.AllowDrag = true;
                m_scrollButton.addEvent(m_scrollButtonDraggingEvent, FCEventID.DRAGGING);
                m_backButton.addControl(m_scrollButton);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 控件被添加事件
        /// </summary>
        public override void onLoad()
        {
            base.onLoad();
            FCHost host = Native.Host;

            if (m_dayDiv == null)
            {
                m_dayDiv = new DayDiv(this);
            }
            if (m_timeDiv == null)
            {
                m_timeDiv = new TimeDiv(this);
            }
            if (m_headDiv == null)
            {
                m_headDiv = host.createInternalControl(this, "headdiv") as HeadDiv;
                addControl(m_headDiv);
            }
            if (m_useAnimation)
            {
                startTimer(m_timerID, 20);
            }
            else
            {
                stopTimer(m_timerID);
            }
            if (m_years != null && m_year == 0 && m_month == 0)
            {
                DateTime date = DateTime.Now;
                m_year      = date.Year;
                m_month     = date.Month;
                SelectedDay = m_years.getYear(m_year).Months.get(m_month).Days.get(date.Day);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 重置缩放尺寸
        /// </summary>
        /// <param name="clientSize">客户端大小</param>
        public void resetScaleSize(FCSize clientSize)
        {
            FCNative native = Native;

            if (native != null)
            {
                FCHost        host         = native.Host;
                FCSize        nativeSize   = native.DisplaySize;
                List <FCView> controls     = native.getControls();
                int           controlsSize = controls.Count;
                for (int i = 0; i < controlsSize; i++)
                {
                    FCWindowFrame frame = controls[i] as FCWindowFrame;
                    if (frame != null)
                    {
                        WindowEx window = frame.getControls()[0] as WindowEx;
                        if (window != null && !window.AnimateMoving)
                        {
                            FCPoint location = window.Location;
                            if (location.x < 10 || location.x > nativeSize.cx - 10)
                            {
                                location.x = 0;
                            }
                            if (location.y < 30 || location.y > nativeSize.cy - 30)
                            {
                                location.y = 0;
                            }
                            window.Location = location;
                        }
                    }
                }
                native.ScaleSize = new FCSize((int)(clientSize.cx * m_scaleFactor), (int)(clientSize.cy * m_scaleFactor));
                native.update();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 下拉菜单显示方法
        /// </summary>
        public virtual void onDropDownOpening()
        {
            //创建下拉菜单及日历
            if (m_dropDownMenu == null)
            {
                FCHost host = Native.Host;
                m_dropDownMenu = host.createInternalControl(this, "dropdownmenu") as FCMenu;
                Native.addControl(m_dropDownMenu);
                if (m_calendar == null)
                {
                    m_calendar = CreateCalendar();
                    m_dropDownMenu.addControl(m_calendar);
                    m_calendar.Size = m_dropDownMenu.Size;
                    m_calendar.addEvent(m_selectedTimeChangedEvent, FCEventID.SELECTEDTIMECHANGED);
                }
            }
            if (m_calendar != null && !m_showTime)
            {
                m_calendar.TimeDiv.Height = 0;
            }
            m_dropDownMenu.Native = Native;
            FCPoint nativePoint = pointToNative(new FCPoint(0, Height));

            m_dropDownMenu.Location = nativePoint;
            m_dropDownMenu.Visible  = true;
            if (m_calendar != null)
            {
                m_calendar.Mode = FCCalendarMode.Day;
            }
            m_dropDownMenu.bringToFront();
            m_dropDownMenu.invalidate();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 添加控件方法
 /// </summary>
 public virtual void onLoad()
 {
     if (m_calendar != null)
     {
         FCHost host = m_calendar.Native.Host;
         if (m_spinHour == null)
         {
             m_spinHour           = new FCSpin();
             m_spinHour.Maximum   = 23;
             m_spinHour.TextAlign = FCHorizontalAlign.Right;
             m_calendar.addControl(m_spinHour);
             m_spinHour.addEvent(new FCEvent(selectedTimeChanged), FCEventID.VALUECHANGED);
         }
         if (m_spinMinute == null)
         {
             m_spinMinute           = new FCSpin();
             m_spinMinute.Maximum   = 59;
             m_spinMinute.TextAlign = FCHorizontalAlign.Right;
             m_calendar.addControl(m_spinMinute);
             m_spinMinute.addEvent(new FCEvent(selectedTimeChanged), FCEventID.VALUECHANGED);
         }
         if (m_spinSecond == null)
         {
             m_spinSecond           = new FCSpin();
             m_spinSecond.Maximum   = 59;
             m_spinSecond.TextAlign = FCHorizontalAlign.Right;
             m_calendar.addControl(m_spinSecond);
             m_spinSecond.addEvent(new FCEvent(selectedTimeChanged), FCEventID.VALUECHANGED);
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 以动画形式隐藏
        /// </summary>
        public void animateHide()
        {
            m_animateType = 1;
            FCNative native = Native;
            FCHost   host   = native.Host;

            m_animateDirection = m_rd.Next(0, 4);
            startTimer(m_timerID, 10);
            m_animateMoving   = true;
            host.AllowOperate = false;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 添加控件方法
 /// </summary>
 public override void onLoad()
 {
     base.onLoad();
     if (m_splitter == null)
     {
         FCHost host = Native.Host;
         m_splitter = host.createInternalControl(this, "splitter") as FCButton;
         m_splitter.addEvent(m_splitterDraggingEvent, FCEventID.DRAGGING);
         addControl(m_splitter);
     }
     m_oldSize = Size;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 添加控件方法
 /// </summary>
 public override void onLoad()
 {
     base.onLoad();
     if (m_dropDownButton == null)
     {
         FCHost host = Native.Host;
         m_dropDownButton = host.createInternalControl(this, "dropdownbutton") as FCButton;
         addControl(m_dropDownButton);
         m_dropDownButton.addEvent(m_dropDownButtonTouchDownEvent, FCEventID.TOUCHDOWN);
     }
     if (m_dropDownMenu != null)
     {
         m_dropDownMenu.Native = Native;
     }
 }
Ejemplo n.º 9
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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 以动画形式显示
        /// </summary>
        /// <param name="showDialog">是否对话框打开</param>
        public void animateShow(bool showDialog)
        {
            m_animateType = 0;
            FCNative native = Native;
            FCHost   host = native.Host;
            FCSize   nativeSize = native.DisplaySize;
            int      width = Width, height = Height, mx = (nativeSize.cx - width) / 2, my = (nativeSize.cy - height) / 2, x = mx, y = my;

            m_animateDirection = m_rd.Next(0, 4);
            switch (m_animateDirection)
            {
            case 0:
                x = -width;
                break;

            case 1:
                x = nativeSize.cx;
                break;

            case 2:
                y = -height;
                break;

            case 3:
                y = nativeSize.cy;
                break;
            }
            FCPoint location = new FCPoint(x, y);

            Location = location;
            if (showDialog)
            {
                base.showDialog();
            }
            else
            {
                show();
            }
            update();
            startTimer(m_timerID, 10);
            m_animateMoving   = true;
            host.AllowOperate = false;
        }
Ejemplo n.º 11
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();
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 添加控件方法
 /// </summary>
 public override void onLoad()
 {
     base.onLoad();
     if (m_tabControl != null)
     {
         if (m_headerButton == null)
         {
             FCHost host = Native.Host;
             m_headerButton = host.createInternalControl(this, "headerbutton") as FCButton;
             m_headerButton.addEvent(m_dragHeaderBeginEvent, FCEventID.DRAGBEGIN);
             m_headerButton.addEvent(m_dragHeaderEndEvent, FCEventID.DRAGEND);
             m_headerButton.addEvent(m_draggingHeaderEvent, FCEventID.DRAGGING);
             m_headerButton.addEvent(m_headerTouchDownEvent, FCEventID.TOUCHDOWN);
         }
         if (!m_tabControl.containsControl(m_headerButton))
         {
             m_tabControl.addControl(m_headerButton);
         }
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 添加控件方法
 /// </summary>
 public virtual void onLoad()
 {
     if (m_calendar != null)
     {
         FCHost host = m_calendar.Native.Host;
         if (m_dayButtons.size() == 0 || m_dayButtons_am.size() == 0)
         {
             m_dayButtons.clear();
             m_dayButtons_am.clear();
             for (int i = 0; i < 42; i++)
             {
                 DayButton dayButton = new DayButton(m_calendar);
                 m_dayButtons.add(dayButton);
                 DayButton dayButtonAm = new DayButton(m_calendar);
                 dayButtonAm.Visible = false;
                 m_dayButtons_am.add(dayButtonAm);
             }
         }
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 添加控件方法
        /// </summary>
        public override void onLoad()
        {
            base.onLoad();
            FCHost host = Native.Host;

            if (m_dateTitle == null)
            {
                m_dateTitle = host.createInternalControl(m_calendar, "datetitle") as DateTitle;
                addControl(m_dateTitle);
            }
            if (m_lastBtn == null)
            {
                m_lastBtn = host.createInternalControl(m_calendar, "lastbutton") as ArrowButton;
                addControl(m_lastBtn);
            }
            if (m_nextBtn == null)
            {
                m_nextBtn = host.createInternalControl(m_calendar, "nextbutton") as ArrowButton;
                addControl(m_nextBtn);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 添加控件方法
        /// </summary>
        public override void onLoad()
        {
            base.onLoad();
            FCHost host = Native.Host;

            if (m_downButton == null)
            {
                m_downButton = host.createInternalControl(this, "downbutton") as FCButton;
                m_downButton.addEvent(m_downButtoTouchDownEvent, FCEventID.TOUCHDOWN);
                m_downButton.addEvent(m_downButtoTouchUpEvent, FCEventID.TOUCHUP);
                addControl(m_downButton);
            }
            if (m_upButton == null)
            {
                m_upButton = host.createInternalControl(this, "upbutton") as FCButton;
                m_upButton.addEvent(m_upButtonTouchDownEvent, FCEventID.TOUCHDOWN);
                m_upButton.addEvent(m_upButtonTouchUpEvent, FCEventID.TOUCHUP);
                addControl(m_upButton);
            }
            update();
        }
Ejemplo n.º 16
0
 /// <summary>
 /// 粘贴方法
 /// </summary>
 public override void onPaste()
 {
     if (m_autoFormat)
     {
         callEvents(FCEventID.PASTE);
         FCHost host   = Native.Host;
         String insert = host.paste();
         if (insert != null && insert.Length > 0)
         {
             insertWord(insert);
             Text = FormatNum(getValueByDigit(Value, m_digit));
             onTextChanged();
             onValueChanged();
             invalidate();
         }
     }
     else
     {
         base.onPaste();
     }
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 添加控件方法
 /// </summary>
 public virtual void onLoad()
 {
     if (m_calendar != null)
     {
         FCHost host = m_calendar.Native.Host;
         if (m_monthButtons.size() == 0 || m_monthButtons_am.size() == 0)
         {
             m_monthButtons.clear();
             m_monthButtons_am.clear();
             for (int i = 0; i < 12; i++)
             {
                 MonthButton monthButton = new MonthButton(m_calendar);
                 monthButton.Month = i + 1;
                 m_monthButtons.add(monthButton);
                 MonthButton monthButtonAm = new MonthButton(m_calendar);
                 monthButtonAm.Month   = i + 1;
                 monthButtonAm.Visible = false;
                 m_monthButtons_am.add(monthButtonAm);
             }
         }
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 添加控件方法
        /// </summary>
        public override void onLoad()
        {
            base.onLoad();
            FCHost host = Native.Host;

            if (m_dropDownButton == null)
            {
                m_dropDownButton = host.createInternalControl(this, "dropdownbutton") as FCButton;
                addControl(m_dropDownButton);
                m_dropDownButton.addEvent(m_dropDownButtonTouchDownEvent, FCEventID.TOUCHDOWN);
            }
            if (m_dropDownMenu == null)
            {
                m_dropDownMenu = host.createInternalControl(this, "dropdownmenu") as FCComboBoxMenu;
                Native.addControl(m_dropDownMenu);
                m_dropDownMenu.Visible = false;
                m_dropDownMenu.addEvent(m_menuItemClickEvent, FCEventID.MENUITEMCLICK);
                m_dropDownMenu.addEvent(m_menuKeyDownEvent, FCEventID.KEYDOWN);
            }
            else
            {
                m_dropDownMenu.Native = Native;
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 秒表方法
        /// </summary>
        /// <param name="timerID">秒表ID</param>
        public override void onTimer(int timerID)
        {
            base.onTimer(timerID);
            if (m_timerID == timerID)
            {
                FCNative native = Native;
                FCHost   host = native.Host;
                FCSize   nativeSize = native.DisplaySize;
                int      x = Left, y = Top, width = Width, height = Height;
                if (m_animateType == 0)
                {
                    int   xSub    = nativeSize.cx / 4;
                    int   ySub    = nativeSize.cy / 4;
                    int   mx      = (nativeSize.cx - width) / 2;
                    int   my      = (nativeSize.cy - height) / 2;
                    float opacity = Opacity;
                    opacity += 0.1F;
                    if (opacity > 1)
                    {
                        opacity = 1;
                    }
                    Opacity = opacity;
                    bool stop = false;
                    switch (m_animateDirection)
                    {
                    //从左向右
                    case 0:
                        if (x + xSub >= mx)
                        {
                            x    = mx;
                            stop = true;
                        }
                        else
                        {
                            x += xSub;
                        }
                        break;

                    //从右向左
                    case 1:
                        if (x - xSub <= mx)
                        {
                            x    = mx;
                            stop = true;
                        }
                        else
                        {
                            x -= xSub;
                        }
                        break;

                    //从上往下
                    case 2:
                        if (y + ySub >= my)
                        {
                            y    = my;
                            stop = true;
                        }
                        else
                        {
                            y += ySub;
                        }
                        break;

                    //从下往上
                    case 3:
                        if (y - ySub <= my)
                        {
                            y    = my;
                            stop = true;
                        }
                        else
                        {
                            y -= ySub;
                        }
                        break;
                    }
                    if (stop)
                    {
                        Opacity         = 1;
                        m_animateMoving = false;
                        stopTimer(m_timerID);
                        host.AllowOperate = true;
                    }
                }
                else
                {
                    int   xSub    = nativeSize.cx / 4;
                    int   ySub    = nativeSize.cy / 4;
                    float opacity = Opacity;
                    opacity -= 0.1F;
                    if (opacity < 0)
                    {
                        opacity = 0;
                    }
                    Opacity = opacity;
                    bool stop = false;
                    switch (m_animateDirection)
                    {
                    //从右向左
                    case 0:
                        if (x - xSub <= -width)
                        {
                            x    = 0;
                            stop = true;
                        }
                        else
                        {
                            x -= xSub;
                        }
                        break;

                    //从左向右
                    case 1:
                        if (x + xSub >= nativeSize.cx)
                        {
                            x    = 0;
                            stop = true;
                        }
                        else
                        {
                            x += xSub;
                        }
                        break;

                    //从下往上
                    case 2:
                        if (y - ySub <= -height)
                        {
                            y    = 0;
                            stop = true;
                        }
                        else
                        {
                            y -= ySub;
                        }
                        break;

                    //从上往下
                    case 3:
                        if (y + ySub >= nativeSize.cy)
                        {
                            y    = 0;
                            stop = true;
                        }
                        else
                        {
                            y += ySub;
                        }
                        break;
                    }
                    if (stop)
                    {
                        Opacity         = 0;
                        m_animateMoving = false;
                        stopTimer(m_timerID);
                        host.AllowOperate = true;
                        hide();
                    }
                }
                FCPoint location = new FCPoint(x, y);
                Location = location;
                native.invalidate();
            }
        }
Ejemplo n.º 20
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);
            }
        }
Ejemplo n.º 21
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();
                }
            }
        }
Ejemplo n.º 22
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;
                    }
                }
            }
        }