Esempio n. 1
0
        private void Txt_Enter(object sender, EventArgs e)
        {
            strFocusedContrName = (sender as Control).Name;
            FocusedControl      = sender as Control;

            Control ctrParent = FocusedControl.Parent;

            if (ctrParent != null)
            {
                if (strEnterGc != ctrParent.Name)
                {
                    strEnterGc    = ctrParent.Name;
                    ParentControl = GcOrdControls[strEnterGc];
                    arrContrSeq   = GcOrdarrContrSeq[strEnterGc];
                }
                if (FocusedControl.GetType().ToString() == "ProduceManager.UcTxtPopup")
                {
                    ProduceManager.UcTxtPopup ucp = FocusedControl as ProduceManager.UcTxtPopup;
                    ucp.DrFilterFieldsInfo = GridViewEdit.GetFocusedDataRow();
                }
                else if (FocusedControl.GetType().ToString() == "ProduceManager.UcTreeList")
                {
                    ProduceManager.UcTreeList ucp = FocusedControl as ProduceManager.UcTreeList;
                    ucp.DrFilterFieldsInfo = GridViewEdit.GetFocusedDataRow();
                }
            }
        }
Esempio n. 2
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            CApplication.App.CurrentSession.TimerId = 0;
            frmEditorBase frm = CApplication.CurrForm as frmEditorBase;

            if (frm == null)
            {
                return(base.ProcessCmdKey(ref msg, keyData));
            }

            int k = msg.WParam.ToInt32();

            blPrevFindControl = false;
            if (k == 123) //F12
            {
                if (CApplication.Com_Prot != null)
                {
                    CApplication.Com_Prot.port_Send();
                }
            }
            else if (k == 27)//Esc
            {
                frm.Close();
                frm.Dispose();
            }
            else if (k == 13)//Enter
            {
                if (string.IsNullOrEmpty(strFocusedContrName) || FocusedControl == null)
                {
                    return(base.ProcessCmdKey(ref msg, keyData));
                }
                if (!blNoEnterToSave)
                {
                    int index = arrContrSeq.IndexOf(strFocusedContrName);
                    if (index == arrContrSeq.Count - 1 && BtnEnterSave != null)
                    {
                        string strBtnType = BtnEnterSave.GetType().ToString();
                        if (strBtnType == "DevExpress.XtraEditors.SimpleButton")
                        {
                            (BtnEnterSave as SimpleButton).PerformClick();
                        }
                        else if (strBtnType == "DevExpress.XtraBars.BarButtonItem")
                        {
                            (BtnEnterSave as BarButtonItem).PerformClick();
                        }
                        return(base.ProcessCmdKey(ref msg, keyData));
                    }
                }
                if (FocusedControl is BaseEdit)
                {
                    BaseEdit bc = FocusedControl as BaseEdit;
                    if (bc.Properties.ReadOnly)
                    {
                        return(base.ProcessCmdKey(ref msg, keyData));
                    }
                }
                else if (FocusedControl is ProduceManager.UcTxtPopup)
                {
                    ProduceManager.UcTxtPopup bc = FocusedControl as ProduceManager.UcTxtPopup;
                    if (bc.ReadOnly)
                    {
                        return(base.ProcessCmdKey(ref msg, keyData));
                    }
                }
                else if (FocusedControl is ProduceManager.UcTreeList)
                {
                    ProduceManager.UcTreeList bc = FocusedControl as ProduceManager.UcTreeList;
                    if (bc.ReadOnly)
                    {
                        return(base.ProcessCmdKey(ref msg, keyData));
                    }
                }
                string strType = FocusedControl.GetType().ToString();
                if (strType == "DevExpress.XtraEditors.LookUpEdit")
                {
                    if (!(FocusedControl as DevExpress.XtraEditors.LookUpEdit).IsPopupOpen)
                    {
                        frm.SetContrMoveNext(strFocusedContrName, blPrevFindControl);
                    }
                }
                else if (strType == "ExtendControl.ExtPopupTree")
                {
                    if (!(FocusedControl as ExtendControl.ExtPopupTree).IsPopupOpen)
                    {
                        frm.SetContrMoveNext(strFocusedContrName, blPrevFindControl);
                    }
                }
                else if (strType == "ProduceManager.UcTxtPopup")
                {
                    if (!(FocusedControl as ProduceManager.UcTxtPopup).IsPopupOpen)
                    {
                        frm.SetContrMoveNext(strFocusedContrName, blPrevFindControl);
                    }
                }
                else if (strType == "ProduceManager.UcTreeList")
                {
                    if (!(FocusedControl as ProduceManager.UcTreeList).IsPopupOpen)
                    {
                        frm.SetContrMoveNext(strFocusedContrName, blPrevFindControl);
                    }
                }
                else
                {
                    frm.SetContrMoveNext(strFocusedContrName, blPrevFindControl);
                }
            }
            else if (k == 187 || k == 107 || k == 227) // +
            {
                if (keyData.ToString().ToUpper().IndexOf("CONTROL") != -1)
                {
                    if (string.IsNullOrEmpty(strFocusedContrName) || FocusedControl == null)
                    {
                        return(base.ProcessCmdKey(ref msg, keyData));
                    }
                    if (FocusedControl is BaseEdit)
                    {
                        BaseEdit bc = FocusedControl as BaseEdit;
                        if (bc.Properties.ReadOnly)
                        {
                            return(base.ProcessCmdKey(ref msg, keyData));
                        }
                    }
                    else if (FocusedControl is ProduceManager.UcTxtPopup)
                    {
                        ProduceManager.UcTxtPopup bc = FocusedControl as ProduceManager.UcTxtPopup;
                        if (bc.ReadOnly)
                        {
                            return(base.ProcessCmdKey(ref msg, keyData));
                        }
                    }
                    else if (FocusedControl is ProduceManager.UcTreeList)
                    {
                        ProduceManager.UcTreeList bc = FocusedControl as ProduceManager.UcTreeList;
                        if (bc.ReadOnly)
                        {
                            return(base.ProcessCmdKey(ref msg, keyData));
                        }
                    }

                    string strType = FocusedControl.GetType().ToString();
                    if (strType == "DevExpress.XtraEditors.LookUpEdit" &&
                        (FocusedControl as DevExpress.XtraEditors.LookUpEdit).IsPopupOpen)
                    {
                        blPrevFindControl = true;
                        (FocusedControl as DevExpress.XtraEditors.LookUpEdit).ClosePopup();
                        blPrevFindControl = false;
                    }
                    else if (strType == "ExtendControl.ExtPopupTree" &&
                             (FocusedControl as ExtendControl.ExtPopupTree).IsPopupOpen)
                    {
                        blPrevFindControl = true;
                        (FocusedControl as ExtendControl.ExtPopupTree).ClosePopup();
                        blPrevFindControl = false;
                    }
                    else if (strType == "ProduceManager.UcTxtPopup" &&
                             (FocusedControl as ProduceManager.UcTxtPopup).IsPopupOpen)
                    {
                        blPrevFindControl = true;
                        (FocusedControl as ProduceManager.UcTxtPopup).ClosePopup();
                        blPrevFindControl = false;
                    }
                    else if (strType == "ProduceManager.UcTreeList" &&
                             (FocusedControl as ProduceManager.UcTreeList).IsPopupOpen)
                    {
                        blPrevFindControl = true;
                        (FocusedControl as ProduceManager.UcTreeList).ClosePopup();
                        blPrevFindControl = false;
                    }
                    frm.SetContrMoveNext(strFocusedContrName, blPrevFindControl, 3);

                    return(true);
                }
            }
            else if (k == 189 || k == 109 || k == 229) // - //36:Home
            {
                if (keyData.ToString().ToUpper().IndexOf("CONTROL") != -1)
                {
                    if (string.IsNullOrEmpty(strFocusedContrName) || FocusedControl == null)
                    {
                        return(base.ProcessCmdKey(ref msg, keyData));
                    }
                    if (FocusedControl is BaseEdit)
                    {
                        BaseEdit bc = FocusedControl as BaseEdit;
                        if (bc.Properties.ReadOnly)
                        {
                            return(base.ProcessCmdKey(ref msg, keyData));
                        }
                    }
                    else if (FocusedControl is ProduceManager.UcTxtPopup)
                    {
                        ProduceManager.UcTxtPopup bc = FocusedControl as ProduceManager.UcTxtPopup;
                        if (bc.ReadOnly)
                        {
                            return(base.ProcessCmdKey(ref msg, keyData));
                        }
                    }
                    else if (FocusedControl is ProduceManager.UcTreeList)
                    {
                        ProduceManager.UcTreeList bc = FocusedControl as ProduceManager.UcTreeList;
                        if (bc.ReadOnly)
                        {
                            return(base.ProcessCmdKey(ref msg, keyData));
                        }
                    }
                    blPrevFindControl = true;

                    string strType = FocusedControl.GetType().ToString();
                    if (strType == "DevExpress.XtraEditors.LookUpEdit" &&
                        (FocusedControl as DevExpress.XtraEditors.LookUpEdit).IsPopupOpen)
                    {
                        (FocusedControl as DevExpress.XtraEditors.LookUpEdit).ClosePopup();
                    }
                    else if (strType == "ExtendControl.ExtPopupTree" &&
                             (FocusedControl as ExtendControl.ExtPopupTree).IsPopupOpen)
                    {
                        (FocusedControl as ExtendControl.ExtPopupTree).ClosePopup();
                    }
                    else if (strType == "ProduceManager.UcTxtPopup" &&
                             (FocusedControl as ProduceManager.UcTxtPopup).IsPopupOpen)
                    {
                        (FocusedControl as ProduceManager.UcTxtPopup).ClosePopup();
                    }
                    else if (strType == "ProduceManager.UcTreeList" &&
                             (FocusedControl as ProduceManager.UcTreeList).IsPopupOpen)
                    {
                        (FocusedControl as ProduceManager.UcTreeList).ClosePopup();
                    }
                    frm.SetContrMoveNext(strFocusedContrName, blPrevFindControl);

                    return(true);
                }
            }
            else if (k == 33)//PgUp
            {
                if (GridViewEdit != null)
                {
                    GridViewEdit.MovePrev();
                    return(true);
                }
            }
            else if (k == 34)//PgDn
            {
                if (GridViewEdit != null)
                {
                    GridViewEdit.MoveNext();
                    return(true);
                }
            }
            else if (k == 46)//Delete
            {
                frm.DeleteFocusedItem();
                return(true);
                //if (GridViewEdit != null && GridViewEdit.GetFocusedDataRow() != null && frmEditorMode=="VIEW")
                //{
                //    frm.DeleteFocusedItem();
                //}
            }
            else if (k == 116)//F5
            {
                frm.RefreshItem();
                return(true);
            }
            else if (k == 20)//CapsLk
            {
                if (keyData.ToString().ToUpper().IndexOf("ALT") != -1)
                {
                    int idex = arrOpenedForms.IndexOf(this);
                    if (idex == -1)
                    {
                        return(true);
                    }

                    if (idex == 0)
                    {
                        idex = arrOpenedForms.Count - 1;
                    }
                    else
                    {
                        idex -= 1;
                    }


                    Form[] charr = this.ParentForm.MdiChildren;
                    foreach (Form chform in charr)
                    {
                        if (chform.Name.ToUpper() == arrOpenedForms[idex].Name.ToUpper())
                        {
                            chform.Show();
                            chform.Activate();

                            return(true);
                        }
                    }
                    return(true);
                }
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Esempio n. 3
0
        public virtual void SetContrMoveNext(string strContrName, bool blPrev, int iSeed)
        {
            int index = arrContrSeq.IndexOf(strContrName);

            if (index == -1)
            {
                return;
            }
            if (!blPrev && index == arrContrSeq.Count - 1 || blPrev && index == 0)
            {
                return;
            }
            if (FocusedControl.GetType().ToString() == "DevExpress.XtraEditors.CheckedComboBoxEdit")
            {
                DevExpress.XtraEditors.CheckedComboBoxEdit cklis = FocusedControl as DevExpress.XtraEditors.CheckedComboBoxEdit;
                string   strText  = string.Empty;
                string[] arrTexts = cklis.Text.Split(",,".ToCharArray());

                foreach (CheckedListBoxItem item in cklis.Properties.Items)
                {
                    foreach (string strT in arrTexts)
                    {
                        string strTxt = strT.Trim();
                        if (strTxt == string.Empty)
                        {
                            continue;
                        }

                        if (item.Value.ToString().ToLower() == strTxt.ToLower() ||
                            item.Description.ToLower() == strTxt.ToLower())
                        {
                            strText += strText == string.Empty ? item.Value.ToString() : "," + item.Value.ToString();
                        }
                    }
                }
                cklis.EditValue = strText;
                cklis.RefreshEditValue();
            }

            int iFidx = 0;

            if (blPrev)
            {
                iFidx = index - iSeed < 0 ? 0 : index - iSeed;
            }
            else
            {
                iFidx = index + iSeed > arrContrSeq.Count - 1 ? arrContrSeq.Count - 1 : index + iSeed;
            }

            Control[] contrs = FocusedControl.Parent.Controls.Find(arrContrSeq[iFidx], false);
            if (contrs.Length <= 0)
            {
                return;
            }

            Control contr = contrs[0];

            if (contr is BaseEdit)
            {
                BaseEdit bse = contr as BaseEdit;
                if (bse.Properties.ReadOnly || !bse.Visible)
                {
                    SetContrMoveNext(arrContrSeq[iFidx], blPrev, 1);
                    return;
                }
            }
            else if (contr is ProduceManager.UcTxtPopup)
            {
                ProduceManager.UcTxtPopup bc = contr as ProduceManager.UcTxtPopup;
                if (bc.ReadOnly || !bc.Visible)
                {
                    SetContrMoveNext(arrContrSeq[iFidx], blPrev, 1);
                    return;
                }
            }
            else if (contr is ProduceManager.UcTreeList)
            {
                ProduceManager.UcTreeList bc = contr as ProduceManager.UcTreeList;
                if (bc.ReadOnly || !bc.Visible)
                {
                    SetContrMoveNext(arrContrSeq[iFidx], blPrev, 1);
                    return;
                }
            }
            switch (contr.GetType().ToString())
            {
            case "DevExpress.XtraEditors.TextEdit":
                DevExpress.XtraEditors.TextEdit txt = contr as DevExpress.XtraEditors.TextEdit;
                txt.Focus();
                txt.SelectAll();
                break;

            case "DevExpress.XtraEditors.MemoEdit":
                DevExpress.XtraEditors.MemoEdit mTxt = contr as DevExpress.XtraEditors.MemoEdit;
                mTxt.Focus();
                mTxt.SelectAll();
                break;

            case "DevExpress.XtraEditors.SimpleButton":
                DevExpress.XtraEditors.SimpleButton btn = contr as DevExpress.XtraEditors.SimpleButton;
                btn.Select();
                break;

            case "DevExpress.XtraEditors.LookUpEdit":
                DevExpress.XtraEditors.LookUpEdit dpl = contr as DevExpress.XtraEditors.LookUpEdit;
                dpl.Focus();
                dpl.ShowPopup();
                break;

            case "DevExpress.XtraEditors.CheckedComboBoxEdit":
                DevExpress.XtraEditors.CheckedComboBoxEdit ckcob = contr as DevExpress.XtraEditors.CheckedComboBoxEdit;
                ckcob.Focus();
                ckcob.SelectAll();
                break;

            case "DevExpress.XtraEditors.DateEdit":
                DevExpress.XtraEditors.DateEdit dt = contr as DevExpress.XtraEditors.DateEdit;
                dt.Focus();
                dt.Select();
                break;

            case "ExtendControl.ExtPopupTree":
                ExtendControl.ExtPopupTree ext = contr as ExtendControl.ExtPopupTree;
                ext.Focus();
                ext.ShowPopup();
                break;

            case "ProduceManager.UcTxtPopup":
                ProduceManager.UcTxtPopup ucp = contr as ProduceManager.UcTxtPopup;
                ucp.Focus();
                ucp.ShowPopup();
                break;

            case "ProduceManager.UcTreeList":
                ProduceManager.UcTreeList uct = contr as ProduceManager.UcTreeList;
                uct.Focus();
                uct.ShowPopup();
                break;

            case "DevExpress.XtraEditors.ComboBoxEdit":
                DevExpress.XtraEditors.ComboBoxEdit cob = contr as DevExpress.XtraEditors.ComboBoxEdit;
                cob.Focus();
                cob.ShowPopup();
                break;

            default:
                break;
            }
        }
Esempio n. 4
0
        /// <summary>获取当前控件按回车跳转到的下一个控件的ID的索引
        ///
        /// </summary>
        /// <param name="FocusCtlName"></param>
        /// <param name="ArrayStr"></param>
        /// <returns></returns>
        public string[] GetNextIndex(List <string> ArrayStr)
        {
            string[] NextStrArray;
            if (FocusedControl.Tag != null)
            {
                Nextindex = ArrayStr.IndexOf(FocusedControl.TabIndex.ToString() + "," + FocusedControl.Name + "," + FocusedControl.GetType() + "," + FocusedControl.Tag.ToString());
            }
            else
            {
                Nextindex = ArrayStr.IndexOf(FocusedControl.TabIndex.ToString() + "," + FocusedControl.Name + "," + FocusedControl.GetType());
            }

            if (Nextindex < StringArrary.Count - 1)
            {
                NextStrArray = StringArrary[Nextindex + 1].Split(',');
            }
            else
            {
                NextStrArray = StringArrary[ArrayStr.Count - 1].Split(',');
            }
            return(NextStrArray);
        }