Exemplo n.º 1
0
/// <summary>
/// Get the TextBoxMaskBox that is wrapped in the CidListCtl
/// </summary>
/// <returns></returns>

        TextBoxMaskBox GetCidListTextBox()
        {
            FieldInfo      fi      = typeof(TextEdit).GetField("_maskBox", BindingFlags.Instance | BindingFlags.NonPublic);   // get underlying TextBox to SendMessage to
            TextBoxMaskBox textBox = fi.GetValue(CidListCtl) as TextBoxMaskBox;

            return(textBox);
        }
Exemplo n.º 2
0
/// <summary>
/// Handle timer tick & update currently selected structure
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void Timer_Tick(object sender, EventArgs e)
        {
            string cid;
            int    count, position;

            if (ServiceFacade.ServiceFacade.InServiceCall)
            {
                return;                                                        // avoid multiplexing service calls that could cause problems
            }
            if (InTimer_Tick)
            {
                return;
            }
            InTimer_Tick = true;

            TextBoxMaskBox textBox = GetCidListTextBox();

            count    = SendMessage(textBox.Handle.ToInt32(), EM_GETLINECOUNT, 0, 0);          // total line count
            position = SendMessage(textBox.Handle.ToInt32(), EM_LINEFROMCHAR, -1, 0);         // current line
            position++;

            string txt = textBox.MaskBoxText;

            if (txt.Length > 0 && txt[txt.Length - 1] == '\n')
            {
                count--;                                                            // decrement count if last line is blank
            }
            if (position > count)
            {
                count = position;
            }
            string label = "Item " + position + " of " + count;

            if (label != DisplayFrame.Text)
            {
                DisplayFrame.Text = label;
            }

            cid = GetCurrentCid(textBox, false);
            if (PreviousCid != cid)
            {
                DisplayCidData(cid);
                PreviousCid = cid;
            }
            InTimer_Tick = false;
            return;
        }
Exemplo n.º 3
0
 void text_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (this.ActiveMdiChild != null)
     {
         if (this.ActiveMdiChild.ActiveControl != null)
         {
             if (this.ActiveMdiChild.ActiveControl.GetType().ToString() == "DevExpress.XtraEditors.TextBoxMaskBox")
             {
                 TextBoxMaskBox edit = (TextBoxMaskBox)ActiveForm.ActiveMdiChild.ActiveControl;
                 editcopy(e);
                 edit.EditValue = "";
                 edit.Paste();
                 Clipboard.Clear();
             }
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 注册窗体的KeyPress事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frm_KeyPress(object sender, KeyPressEventArgs e)
        {
            //obj_type等于"1"時爲.NET本身控件,按回車後處理跳至下個控件
            //obj_type等于"2"時爲DEV控件,因DEV控件本身已有此功能,不必再進行此處理
            if (obj_type == "1")
            {
                //按回車跳到下一控件
                if (e.KeyChar == 13) //等同于(e.KeyChar == (char)Keys.Enter)
                {
                    SendKeys.Send("{TAB}");
                    //等同于frm.SelectNextControl(frm.ActiveControl, true, true, true, true);
                }
            }

            //輸入入的值長度達到最大長度後焦點跳轉到下一控件
            switch (frm.ActiveControl.GetType().Name)
            {
            case "TextBox":
                TextBox ts0 = (TextBox)frm.ActiveControl;
                if ((ts0.TextLength - ts0.SelectionLength) == ts0.MaxLength - 1)
                {
                    SendKeys.Send("{TAB}");
                }
                break;

            case "ComboBox":
                System.Windows.Forms.ComboBox ts2 = (System.Windows.Forms.ComboBox)frm.ActiveControl;
                if ((ts2.Text.Length - ts2.SelectionLength) == ts2.MaxLength - 1)
                {
                    SendKeys.Send("{TAB}");
                }
                break;

            case "TextBoxMaskBox":
                TextBoxMaskBox ts1 = (TextBoxMaskBox)frm.ActiveControl;
                if (ts1.TextLength == ts1.MaxLength - 1)
                {
                    SendKeys.Send("{TAB}");
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Insert text following current number
        /// </summary>
        /// <param name="text"></param>

        void InsertCidListText(
            string insText)
        {
            try
            {
                int            i0, i1, i2;
                TextBoxMaskBox textBox = GetCidListTextBox();
                string         txt     = CidListCtl.Text;
                i0 = CidListCtl.SelectionStart;
                if (i0 < 0)
                {
                    return;
                }

                for (i2 = i0; i2 < txt.Length; i2++)
                {
                    if (txt[i2] == '\r' || txt[i2] == '\n')
                    {
                        break;
                    }
                }

                if (i2 >= txt.Length)
                {
                    txt += "\r\n";
                }

                i2 += 2;

                string endTxt = "";
                if (i2 < txt.Length)
                {
                    endTxt = txt.Substring(i2);
                }

                CidListCtl.Text = txt.Substring(0, i2) + insText + endTxt;                 // set new text

                CidListCtl.SelectionStart  = i2;
                CidListCtl.SelectionLength = insText.Length;
                CidListCtl.ScrollToCaret();                 // be sure visible
            }
            catch (Exception ex) { return; }
        }