Focus() private method

private Focus ( ) : bool
return bool
Esempio n. 1
0
        public static bool CheckControlInput(Control ctrl, string strCaption, int iLength, bool blnNumber)
        {
            try
            {
                if (ctrl.GetType().ToString() == "System.Windows.Forms.TextBox")
                {
                    if (ctrl.Text.Trim() == "")
                    {
                        MsgBoxExclamation(strCaption + "不能为空,请输入" + strCaption);
                        ctrl.Focus();
                        ((TextBox)ctrl).SelectAll();
                        return false;
                    }
                    else if (iLength > 0 && ctrl.Text.Length != iLength)
                    {
                        MsgBoxExclamation("请输入" + iLength.ToString() + "位" + strCaption);
                        ctrl.Focus();
                        ((TextBox)ctrl).SelectAll();
                        return false;
                    }

                    if (blnNumber && !IsNumeric(ctrl.Text))
                    {
                        MsgBoxExclamation(strCaption + "必须为数字,请重新输入");
                        ctrl.Focus();
                        ((TextBox)ctrl).SelectAll();
                        return false;
                    }
                }
                else if (ctrl.GetType().ToString() == "System.Windows.Forms.ComboBox")
                {
                    if (ctrl.Text.Trim() == "")
                    {
                        MsgBoxExclamation(strCaption + "不能为空,请选择" + strCaption);
                        ctrl.Focus();
                        return false;
                    }
                }
                else
                {
                    if (ctrl.Text.Trim() == "")
                    {
                        MsgBoxExclamation(strCaption + "不能为空,请输入" + strCaption);
                        ctrl.Focus();
                        return false;
                    }
                }

                return true;
            }
            catch (System.Exception e)
            {
                MsgBoxException(e.Message, "GlobalFunction.CheckControlInput");
                return false;
            }
        }
        /// <summary>
        /// 入金予定表データ取得処理
        /// </summary>
        /// <param name="set">画面展開なしの場合:falesに設定する</param>
        /// <returns></returns>
        private DataTable CheckData()
        {
            for (int i = 0; i < detailControls.Length; i++)
            {
                if (CheckDetail(i, false) == false)
                {
                    detailControls[i].Focus();
                    return(null);
                }
            }

            dse = GetSearchInfo();

            M_Customer_Entity mce = new M_Customer_Entity
            {
                //StaffCD = ScStaff.TxtCode.Text
                CustomerCD = ScCustomer.TxtCode.Text
            };

            DataTable dt = mibl.D_CollectPlan_SelectForPrint(dse, mce);

            //以下の条件でデータが存在しなければエラー (Error if record does not exist)E133
            if (dt.Rows.Count == 0)
            {
                bbl.ShowMessage("E133");
                previousCtrl.Focus();
                return(null);
            }

            return(dt);
        }
    /// <summary>
    /// Handle the focus of the ActiveX control, including its child controls
    /// </summary>
    /// <param name="usrCtrl">the ActiveX control</param>
    internal static void HandleFocus(UserControl usrCtrl)
    {
        Keyboard keyboard = new Keyboard();

        if (keyboard.AltKeyDown)
        {
            // Handle accessor key
            HandleAccessorKey(usrCtrl.GetNextControl(null, true), usrCtrl);
        }
        else
        {
            // Move to the first control that can receive focus, taking into account
            // the possibility that the user pressed <Shift>+<Tab>, in which case we
            // need to start at the end and work backwards.
            for (System.Windows.Forms.Control ctrl =
                     usrCtrl.GetNextControl(null, !keyboard.ShiftKeyDown);
                 ctrl != null;
                 ctrl = usrCtrl.GetNextControl(ctrl, !keyboard.ShiftKeyDown))
            {
                if (ctrl.Enabled && ctrl.CanSelect)
                {
                    ctrl.Focus();
                    break;
                }
            }
        }
    }
        /// <summary>
        /// ȱʡ����ControlValueNullException��ʽ
        /// </summary>
        /// <param name="ex"></param>
        public void ShowError(object invalidControl, string msg)
        {
            if (invalidControl == null)
            {
                throw new ArgumentNullException("invalidControl");
            }

            IWindowControl windowControl = invalidControl as IWindowControl;
            if (windowControl != null)
            {
                //ClearError();

                if (m_firstInvalidControl == null)
                {
                    m_firstInvalidControl = windowControl.Control;
                    //if (ex.InvalidDataControl is Feng.Windows.Forms.DataControlWrapper)
                    //{
                    //    m_invalidControl = ex.InvalidDataControl as Control;
                    //}
                    m_firstInvalidControl.Focus();
                }

                ShowErrorIcon(windowControl.Control, msg);
            }
            else
            {
                ServiceProvider.GetService<IMessageBox>().ShowWarning(msg);
            }
        }
Esempio n. 5
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            //Esta forma de validar, valida de a uno los errores. Como errores particulares
            //en este formulario tengo este por ahora. No lo veo mal. Habría que ver cómo se lleva
            //con los errores propios de los controles (validar campo obligatorio de user control texto y demás)
            primerControlInvalido = null;
            this.ValidateChildren();

            if (primerControlInvalido != null) primerControlInvalido.Focus();
            else
            {
                Dictionary<String, gdDataBase.ValorTipo> camposValores = new Dictionary<string, gdDataBase.ValorTipo>();
                Dictionary<int, String> errorMensaje = new Dictionary<int, string>();

                camposValores.Add("fecha_salida", new gdDataBase.ValorTipo(dateTimePickerSalida.Value.ToString("yyyy-MM-dd HH:mm:ss.000"), SqlDbType.DateTime));
                camposValores.Add("fecha_llegada_estimada", new gdDataBase.ValorTipo(dateTimePickerEstimada.Value.ToString("yyyy-MM-dd HH:mm:ss.000"), SqlDbType.DateTime));
                camposValores.Add("hoy", new gdDataBase.ValorTipo(Config.fecha.ToString(), SqlDbType.DateTime));
                camposValores.Add("matricula", new gdDataBase.ValorTipo(textBoxMatricula.Text, SqlDbType.VarChar));
                camposValores.Add("id_ruta", new gdDataBase.ValorTipo(idRuta.ToString(), SqlDbType.VarChar));

                errorMensaje.Add(60007, "La matricula ingresada no pertenece a ninguna Aeronave");
                errorMensaje.Add(600012, "La ruta ingresada no existe");
                errorMensaje.Add(600015, "El servicio brindado por la aeronave no coincide con el de la ruta");
                errorMensaje.Add(600016, "La aeronave ya posee un viaje en esas fechas");

                var ejecucion = new SPPureExec("ÑUFLO.GenerarViaje", camposValores, errorMensaje, "Viaje registrado correctamente");

                ejecucion.Exec();
                if (!ejecucion.huboError())
                    limpiar();
            }
        }
        /// <summary>
        /// 入出金予定表印刷データ取得処理
        /// </summary>
        /// <param name="set">画面展開なしの場合:falesに設定する</param>
        /// <returns></returns>
        private DataTable CheckData()
        {
            for (int i = 0; i < detailControls.Length; i++)
            {
                if (CheckDetail(i, false) == false)
                {
                    detailControls[i].Focus();
                    return(null);
                }
            }

            dpe = GetSearchInfo();

            DataTable dt = mibl.D_PaymentConfirm_SelectForPrint(dpe);

            //以下の条件でデータが存在しなければエラー (Error if record does not exist)E133
            if (dt.Rows.Count == 0)
            {
                bbl.ShowMessage("E133");
                previousCtrl.Focus();
                return(null);
            }

            return(dt);
        }
Esempio n. 7
0
        /// <summary>
        /// Focus the control with a lowest tab index in the given container.
        /// </summary>
        /// <param name="container">A Control object to pe processed.</param>
        private void FocusFirstTabIndex(System.Windows.Forms.Control container)
        {
            // init search result varialble
            Control searchResult = null;

            // find the control with the lowest tab index
            foreach (Control control in container.Controls)
            {
                if (control.CanFocus && (searchResult == null || control.TabIndex < searchResult.TabIndex))
                {
                    searchResult = control;
                }
            }

            // check if anything searchResult
            if (searchResult != null)
            {
                // focus found control
                searchResult.Focus();
            }
            else
            {
                // focus the container
                container.Focus();
            }
        }
Esempio n. 8
0
        public static void definirEndereco(String cep, System.Windows.Forms.Control ctlLogradouro, System.Windows.Forms.Control ctlBairro, System.Windows.Forms.Control ctlCidade, System.Windows.Forms.Control cboUF, System.Windows.Forms.Control ctlNr, System.Windows.Forms.Control ctlComplemento)
        {
            if (UtilValidar.validarCEP(cep))
            {
                Cursor.Current = Cursors.WaitCursor;
                Endereco objEndereco = Endereco.obterEndereco(cep);
                if (objEndereco != null)
                {
                    Disable(ctlLogradouro);
                    Disable(ctlBairro);
                    Disable(ctlCidade);
                    Disable(cboUF);

                    ctlLogradouro.Text  = objEndereco.Logradouro;
                    ctlBairro.Text      = objEndereco.Bairro;
                    ctlCidade.Text      = objEndereco.Localidade;
                    cboUF.Text          = objEndereco.UF;
                    ctlComplemento.Text = objEndereco.Complemento;
                    ctlNr.Focus();
                }
                else
                {
                    Enable(ctlLogradouro);
                    Enable(ctlBairro);
                    Enable(ctlCidade);
                    Enable(cboUF);

                    ctlLogradouro.Focus();
                }
                Cursor.Current = Cursors.Default;
            }
        }
 private void ValidateFill(System.Windows.Forms.Control ctl, bool bCurrency)
 {
     System.Windows.Forms.TextBox t = (System.Windows.Forms.TextBox)ctl;
     try
     {
         int s = System.Convert.ToInt32(ctl.Text);
         if (bCurrency)
         {
             t.Text = s.ToString("C");
         }
         System.Windows.Forms.Control c = this.GetNextControl(ctl, true);
         c.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Somente valores numéricos. Verifique!!!", "EstacionamentoFacil (FrmCom09)", MessageBoxButtons.OK, MessageBoxIcon.Error);
         if (bCurrency)
         {
             t.Text = "0,00";
         }
         else
         {
             t.Text = "0";
         }
         t.Focus();
     }
 }//validatefill
Esempio n. 10
0
        public PopupEditorHost(Control control,
            int left, int top, int width, int height,
            Func<Control, object> getControlValue, 
            Action<object> onValueUpdated)
            : this()
        {
            this.getControlValue = getControlValue;
            this.onValueUpdated = onValueUpdated;
            Content = control;

            Margin = Padding.Empty;
            Padding = Padding.Empty;
            //AutoSize = true;
            Width = width;
            Height = height;
            Left = left;
            Top = top;
            Content.Dock = DockStyle.Fill;

            BindContentHandlers();

            var host = new ToolStripControlHost(Content)
            {
                Margin = Padding.Empty,
                Padding = Padding.Empty,
                AutoSize = false,
                Width = width,
                Height = height
            };
            Items.Add(host);
            Opened += (sender, e) => Content.Focus();
        }
        private void ActivateNextControl()
        {
            if ( CurrentControl == null )
            {
                CurrentControl = ControlOrder[0];
                CurrentControl.Focus();
                CurrentControl.BackColor = Color.Yellow;
                return;
            }

            var currentIndex = ControlOrder.IndexOf( CurrentControl );
            CurrentControl.BackColor = Color.Gray;

            if ( ControlOrder.Count > currentIndex + 1 )
            {
                CurrentControl = ControlOrder[currentIndex + 1];
                CurrentControl.Focus();
                CurrentControl.BackColor = Color.Yellow;
            }
            else
            {
                kbd_SaveAndReboot.Visible = true;
                kbd_SaveAndReboot.Enabled = true;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// お買上データ取得処理
        /// </summary>
        /// <param name="set">画面展開なしの場合:falesに設定する</param>
        /// <returns></returns>
        private DataTable CheckData(out DataTable dtForUpdate)
        {
            dtForUpdate = null;

            for (int i = 0; i < detailControls.Length; i++)
            {
                if (CheckDetail(i, false) == false)
                {
                    detailControls[i].Focus();
                    return(null);
                }
            }

            dse = GetSearchInfo();

            M_Customer_Entity mce = new M_Customer_Entity
            {
                StaffCD = ScStaff.TxtCode.Text
            };

            DataTable dt = mibl.D_Billing_SelectForPrint(dse, mce);

            //以下の条件で請求データが存在しなければエラー (Error if record does not exist)E133
            if (dt.Rows.Count == 0)
            {
                bbl.ShowMessage("E133");
                previousCtrl.Focus();
                return(null);
            }
            else
            {
                //明細にデータをセット
                int i = 0;
                dtForUpdate = new DataTable();
                dtForUpdate.Columns.Add("no", Type.GetType("System.String"));

                string oldBillingNO = "";
                foreach (DataRow row in dt.Rows)
                {
                    if (row["BillingNO"].ToString() != oldBillingNO)
                    {
                        bool ret = SelectAndInsertExclusive(row["BillingNO"].ToString());
                        if (!ret)
                        {
                            return(null);
                        }

                        i++;
                        // データを追加
                        DataRow rowForUpdate;
                        rowForUpdate       = dtForUpdate.NewRow();
                        rowForUpdate["no"] = row["BillingNO"].ToString();
                        dtForUpdate.Rows.Add(rowForUpdate);
                        oldBillingNO = row["BillingNO"].ToString();
                    }
                }
            }

            return(dt);
        }
Esempio n. 13
0
        /// <summary>
        /// エラーチェック処理
        /// </summary>
        /// <param name="set">画面展開なしの場合:falesに設定する</param>
        /// <returns></returns>
        private bool CheckData()
        {
            for (int i = 0; i < detailControls.Length; i++)
            {
                if (CheckDetail(i, false) == false)
                {
                    detailControls[i].Focus();
                    return(false);
                }
            }

            DataTable dt;

            if (RdoNotOutput.Checked)
            {
                doe = GetEntityForOrder();
                dt  = mibl.D_Order_SelectAllForEDIHacchuu(doe);

                //以下の条件でデータが存在しなければエラー (Error if record does not exist)E133
                if (dt.Rows.Count == 0)
                {
                    bbl.ShowMessage("E133");
                    previousCtrl.Focus();
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 14
0
 void Show(string title, string text, Control control, ICON icon = 0, double timeOut = 0, bool allowMulti = false, bool focus = false, short x = 0, short y = 0)
 {
     if (!allowMulti)
         CloseAll();
     if (x == 0 && y == 0)
     {
         x = (short)(control.RectangleToScreen(control.ClientRectangle).Left + control.Width / 2);
         y = (short)(control.RectangleToScreen(control.ClientRectangle).Top + control.Height / 2);
     }
     TOOLINFO toolInfo = new TOOLINFO();
     toolInfo.cbSize = (uint)Marshal.SizeOf(toolInfo);
     toolInfo.uFlags = 0x20; // TTF_TRACK
     toolInfo.lpszText = text;
     IntPtr pToolInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(toolInfo));
     Marshal.StructureToPtr(toolInfo, pToolInfo, false);
     byte[] buffer = Encoding.UTF8.GetBytes(title);
     buffer = buffer.Concat(new byte[] { 0 }).ToArray();
     IntPtr pszTitle = Marshal.AllocCoTaskMem(buffer.Length);
     Marshal.Copy(buffer, 0, pszTitle, buffer.Length);
     hWnd = User32.CreateWindowEx(0x8, "tooltips_class32", "", 0xC3, 0, 0, 0, 0, control.Parent.Handle, (IntPtr)0, (IntPtr)0, (IntPtr)0);
     User32.SendMessage(hWnd, 1028, (IntPtr)0, pToolInfo); // TTM_ADDTOOL
     User32.SendMessage(hWnd, 1042, (IntPtr)0, (IntPtr)((ushort)x | ((ushort)y << 16))); // TTM_TRACKPOSITION
     //User32.SendMessage(hWnd, 1043, (IntPtr)0, (IntPtr)0); // TTM_SETTIPBKCOLOR
     //User32.SendMessage(hWnd, 1044, (IntPtr)0xffff, (IntPtr)0); // TTM_SETTIPTEXTCOLOR
     User32.SendMessage(hWnd, 1056, (IntPtr)icon, pszTitle); // TTM_SETTITLE 0:None, 1:Info, 2:Warning, 3:Error, >3:assumed to be an hIcon. ; 1057 for Unicode
     User32.SendMessage(hWnd, 1048, (IntPtr)0, (IntPtr)500); // TTM_SETMAXTIPWIDTH
     User32.SendMessage(hWnd, 0x40c, (IntPtr)0, pToolInfo); // TTM_UPDATETIPTEXT; 0x439 for Unicode
     User32.SendMessage(hWnd, 1041, (IntPtr)1, pToolInfo); // TTM_TRACKACTIVATE
     Marshal.FreeCoTaskMem(pszTitle);
     Marshal.DestroyStructure(pToolInfo, typeof(TOOLINFO));
     Marshal.FreeCoTaskMem(pToolInfo);
     if (focus)
         control.Focus();
     control.Enter += control_Event;
     control.Leave += control_Event;
     control.TextChanged += control_Event;
     control.KeyPress += control_Event;
     control.Click += control_Event;
     control.LocationChanged += control_Event;
     control.SizeChanged += control_Event;
     control.VisibleChanged += control_Event;
     if (control is DataGridView)
         ((DataGridView)control).CellBeginEdit += control_Event;
     Control parent = control.Parent;
     while(parent != null)
     {
         parent.VisibleChanged += control_Event;
         parent = parent.Parent;
     }
     control.TopLevelControl.LocationChanged += control_Event;
     ((Form)control.TopLevelControl).Deactivate += control_Event;
     timer.AutoReset = false;
     timer.Elapsed += timer_Elapsed;
     if (timeOut > 0)
     {
         timer.Interval = timeOut;
         timer.Start();
     }
 }
Esempio n. 15
0
 public ModelCamera(Control focusControl, ControlRender dev)
 {
     mControl = focusControl;
     focusControl.MouseClick += (obj, e) => focusControl.Focus();
     mDevice = dev.Device;
     mInput = dev.InputManager;
     mDevice.SetTransform(TransformState.View, Matrix.LookAtLH(mPosition, Vector3.Zero, Vector3.UnitZ));
 }
Esempio n. 16
0
        // Establecer foco en primer control de contenedor de edición

        protected void focoEnPrimerControl(System.Windows.Forms.Control contenedor)
        {
            if (contenedor.Tag != null)
            {
                System.Windows.Forms.Control control = (System.Windows.Forms.Control)contenedor.Tag;
                control.Focus();
            }
        }
Esempio n. 17
0
 public static void showControl(System.Windows.Forms.Control control, System.Windows.Forms.Control Content)
 {
     Content.Controls.Clear();
     control.Dock = DockStyle.Fill;
     control.BringToFront();
     control.Focus();
     Content.Controls.Add(control);
 }
Esempio n. 18
0
        public static void LoadProcessInControl(string _Process, Control _Control)
        {
            System.Diagnostics.Process p = System.Diagnostics.Process.Start(_Process);
            p.WaitForInputIdle();

            _Control.Focus();
            Native.SetParent(p.MainWindowHandle, _Control.Handle);
            ShowWindow(p, SW_SHOWMAXIMIZED);
        }
Esempio n. 19
0
 public static bool TryFocusInvalidInput(ErrorProvider errorProvider, Control control)
 {
     if (!string.IsNullOrEmpty(errorProvider.GetError(control)))
     {
         control.Focus();
         return true;
     }
     return false;
 }
        private void EmptyPrivateKeyField(Control focusControl)
        {
            PrivateKey.PasswordChar = (char)0;
            PrivateKey.Text = _enterPhrase;
            PrivateKey.TextAlign = HorizontalAlignment.Center;
            PrivateKey.ForeColor = Color.LightGray;

            focusControl.Focus();
        }
Esempio n. 21
0
 private bool AlertMessage(string msg, Control txtObj)
 {
     if (!string.IsNullOrEmpty(msg))
     {
         pnlLoading.Controls.Add(LoadingCtrl.LoadModel(MessageType.Error, msg));
         txtObj.Focus();
         return false;
     }
     return true;
 }
Esempio n. 22
0
 public void ShowView(IView view) {
     if (_View != null) {
         Controls.Remove(_View);
         _View = null;
     }
     _View = view as Control;
     Controls.Add(_View);
     _View.Dock = DockStyle.Fill;
     _View.Focus();
 }
Esempio n. 23
0
 /// <summary>
 /// 验证所有的控件,如果失败弹出信息并重定位焦点
 /// </summary>
 /// <param name="ctr">被验证控件</param>
 /// <param name="message">验证失败弹出的消息</param>
 /// <returns>失败返回false,成功返回true</returns>
 public static bool Validate(Control ctr, string message)
 {
     bool result = Validate(ctr);
     if (!result)
     {
         MessageBoxHelper.Show(message);
         ctr.Focus();
     }
     return result;
 }
Esempio n. 24
0
 //# __________ PROTOCOL :: PRIVATE __________ #//
 public void Focus(Control c)
 {
     c.Focus();
     if( c is TextBox ) ((TextBox)c).SelectAll();
     if( c is Button )
     {
         ButtonGotFocusType ev = _buttonFocusMap[(Button)c];
         if( ev != null ) ev();
     }
 }
Esempio n. 25
0
        private void btnUpperLower_Click(object sender, System.EventArgs e)
        {
            if (_InputControl == null)
            {
                return;
            }

            _InputControl.Focus();

            if (flag_upper)
            {
                flag_upper         = false;
                btnUpperLower.Text = "大写";
            }
            else
            {
                flag_upper         = true;
                btnUpperLower.Text = "小写";
            }
        }
Esempio n. 26
0
        public void Show(System.Windows.Forms.Control control, int x, int y, int width, int height, PopupResizeMode resizeMode)
        {
            Size controlSize = control.Size;

            InitializeHost(control);

            m_dropDown.ResizeMode = resizeMode;
            m_dropDown.Show(x, y, width, height);

            control.Focus();
        }
 public static void ErreurSaisie(Control txtSaisie, string message)
 {
     // affichage des messages d'erreur avec mise en évidence de l'erreur
     MessageBox.Show(message);
     if (txtSaisie is TextBox)
     { 
         ((TextBox)txtSaisie).SelectionStart = 0;
         ((TextBox)txtSaisie).SelectionLength = txtSaisie.Text.Length;
     }
     txtSaisie.Focus();
 }
        private bool UpdateProgramName(System.Windows.Forms.Control nameInput)
        {
            string programName = nameInput.Name.Split('_')[0];

            if (nameInput.Text == "")
            {
                var result = MessageBox.Show(
                    $"Are you sure you wish to delete the {programName} entry?", "Delete Program Entry",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation
                    );

                if (result == DialogResult.Yes)
                {
                    ConfigManager.RemovePathFromProgramMap(programName);

                    RegernateTable();
                }
                else
                {
                    nameInput.Focus();
                }

                return(true);
            }
            else
            {
                bool success = ConfigManager.UpdateProgramMapName(programName, nameInput.Text);

                if (!success)
                {
                    nameInput.Focus();

                    MessageBox.Show(
                        "The entered Program Name already exists", "Program Name Conflict",
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation
                        );
                }

                return(success);
            }
        }
Esempio n. 29
0
        bool isempty(System.Windows.Forms.Control c, String text)
        {
            bool ret = true;

            if (c.Text.Equals(""))
            {
                e.SetError(c, text);
                c.Focus();
                ret = false;
            }
            return(ret);
        }
Esempio n. 30
0
        private unsafe void SetFocusAsyncInternal(IntPtr control)
        {
            WF.Control childControl = WF.Control.FromHandle(control);

            if (childControl != null)
            {
                if (childControl.CanFocus)
                {
                    // We dont want to check if childControl.ContainsFocus for this call unlike SetFocusInternal
                    childControl.Focus();
                }
            }
        }
Esempio n. 31
0
File: apisharp.cs Progetto: xlgwr/hr
 /// <summary>
 /// set control text
 /// </summary>
 /// <param name="ctl"></param>
 /// <param name="strMsg"></param>
 /// <param name="enable"></param>
 /// <param name="visible"></param>
 public static void setControlText <T>(T tform, System.Windows.Forms.Control ctl, bool enable, bool visible)
     where T : Form
 {
     tform.Invoke(new Action(delegate
     {
         ctl.Visible = visible;
         ctl.Enabled = enable;
         if (enable)
         {
             ctl.Focus();
         }
     }));
 }
Esempio n. 32
0
        /// <summary>
        /// 检查文件输入框中的文件是否存在
        /// </summary>
        /// <param name="txt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private bool CheckFileNameTextBox(System.Windows.Forms.Control txt, string msg)
        {
            var fn = txt.Text.Trim();

            if (fn == null || fn.Length == 0 || File.Exists(fn) == false)
            {
                MessageBox.Show(this, msg);
                txt.Focus();
                txt.Select();
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// 棚卸データ取得処理
        /// </summary>
        /// <param name="set">画面展開なしの場合:falesに設定する</param>
        /// <returns></returns>
        private DataTable CheckData(out DataTable dtForUpdate)
        {
            dtForUpdate = null;

            for (int i = 0; i < detailControls.Length; i++)
            {
                if (CheckDetail(i, false) == false)
                {
                    detailControls[i].Focus();
                    return(null);
                }
            }

            //[D_Inventory_SelectForPrint]
            die = GetEntity();

            DataTable dt = tabl.D_Inventory_SelectForPrint(die);

            //以下の条件でデータが存在しなければエラー (Error if record does not exist)E133
            if (dt.Rows.Count == 0)
            {
                bbl.ShowMessage("E133");
                previousCtrl.Focus();
                return(null);
            }
            //else
            //{
            //    //明細にデータをセット
            //    int i = 0;
            //    dtForUpdate = new DataTable();
            //    dtForUpdate.Columns.Add("no", Type.GetType("System.String"));

            //    foreach (DataRow row in dt.Rows)
            //    {
            //        if (row["DisplayRows"].ToString() == "1" )
            //        {
            //            bool ret = SelectAndInsertExclusive(row["PurchaseNO"].ToString());
            //            if (!ret)
            //                return null;

            //            i++;
            //            // データを追加
            //            DataRow rowForUpdate;
            //            rowForUpdate = dtForUpdate.NewRow();
            //            rowForUpdate["no"] = row["PurchaseNO"].ToString();
            //            dtForUpdate.Rows.Add(rowForUpdate);
            //        }
            //    }
            //}
            return(dt);
        }
Esempio n. 34
0
 public void Show(string text, Control control)
 {
     if (control == null) throw new ArgumentNullException("control");
     this.tooltipText = text;
     this.CalcFinalSizes();
     this.SetLabel();
     var point = control.FindForm().PointToScreen(control.Location);
     int x = point.X - offsetX;
     int y = point.Y - this.Height;
     this.Location = new Point(x, y);
     this.Show(control);
     control.Focus();
     control.LostFocus += new EventHandler(control_LostFocus);
 }
Esempio n. 35
0
        public static bool CheckPasswordStrength(System.Windows.Forms.Control Control)
        {
            // 返回值
            bool   returnValue = true;
            string password    = Control.Text;

            if (!ValidateUtil.CheckPasswordStrength(password))
            {
                MessageBox.Show(AppMessage.MSG8000, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Control.Focus();
                returnValue = false;
            }
            return(returnValue);
        }
Esempio n. 36
0
        public static bool CheckFileName(System.Windows.Forms.Control Control, string message)
        {
            // 返回值
            bool   returnValue = true;
            string fileName    = Control.Text;

            if (!ValidateUtil.CheckFileName(fileName))
            {
                MessageBox.Show(message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Control.Focus();
                returnValue = false;
            }
            return(returnValue);
        }
Esempio n. 37
0
    /// <summary>
    /// Inserts text in specified or focused control.
    /// At current position, not as new line, replaces selection.
    /// </summary>
    /// <param name="c">If null, uses the focused control, else sets focus.</param>
    /// <param name="s">If contains '%', removes it and moves caret there.</param>
    public static void TextSimplyInControl(System.Windows.Forms.Control c, string s)
    {
        if (c == null)
        {
            c = AWnd.ThisThread.FocusedControl;
            if (c == null)
            {
                return;
            }
        }
        else
        {
            c.Focus();
        }

        int i = s.IndexOf('%');

        if (i >= 0)
        {
            Debug.Assert(!s.Contains('\r'));
            s = s.Remove(i, 1);
            i = s.Length - i;
        }

        if (c is AuScintilla sci)
        {
            if (sci.Z.IsReadonly)
            {
                return;
            }
            sci.Z.ReplaceSel(s);
            while (i-- > 0)
            {
                sci.Call(Sci.SCI_CHARLEFT);
            }
        }
        else
        {
            Task.Run(() => {
                var k = new AKeys(null);
                k.AddText(s);
                if (i > 0)
                {
                    k.AddKey(KKey.Left).AddRepeat(i);
                }
                k.Send();
            });
        }
    }
Esempio n. 38
0
        /// <summary>
        /// 判断字符串是否为电子邮件地址
        /// </summary>
        /// <param name="Control">输入控件</param>
        /// <param name="message">提示信息</param>
        /// <returns>是否电子邮件地址</returns>
        public static bool CheckEmail(System.Windows.Forms.Control Control, string message)
        {
            // 返回值
            bool   returnValue = true;
            string email       = Control.Text;

            // 文件夹名字验证,需要多一些才可以
            if (!ValidateUtil.IsEmail(email))
            {
                MessageBox.Show(message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Control.Focus();
                returnValue = false;
            }
            return(returnValue);
        }
Esempio n. 39
0
        private unsafe void SetFocusInternal(IntPtr control)
        {
            WF.Control childControl = WF.Control.FromHandle(control);

            if (childControl != null)
            {
                if (childControl.CanFocus)
                {
                    if (!childControl.ContainsFocus)
                    {
                        childControl.Focus();
                    }
                }
            }
        }
        internal static void GetTextBoxKeyPressEventForTwoControlWithCurrencyAndQuantityValidity(System.Windows.Forms.Control control, KeyPressEventArgs e)
        {
            int keyCode = Convert.ToInt16(e.KeyChar);

            if ((keyCode >= 48 && keyCode <= 57) || keyCode == 8 || keyCode == 127 || keyCode == 46)
            {
            }
            else if (keyCode == 13)
            {
                control.Focus();
            }
            else
            {
                e.Handled = true;
            }
        }
Esempio n. 41
0
 /// <summary>
 /// This method will fill the content of the form with a given usercontrol
 /// </summary>
 /// <param name="control">The user control to fill the content</param>
 /// <param name="content">A content panel that holds the work area</param>
 public static void ShowControl(System.Windows.Forms.Control control, System.Windows.Forms.Control content)
 {
     try
     {
         content.Controls.Clear();
         control.Dock = DockStyle.Fill;
         content.BringToFront();
         control.Focus();
         content.Controls.Add(control);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         System.Environment.Exit(1);
     }
 }
Esempio n. 42
0
        public static void SetFocus(Control control)
        {
            MethodInvoker miSetFocus = delegate
            {
                control.Focus();
            };

            if (control.InvokeRequired)
            {
                control.Invoke(miSetFocus);
            }
            else
            {
                miSetFocus();
            }
        }
Esempio n. 43
0
        /// <summary>
        /// 判断字符串是否为空
        /// </summary>
        /// <param name="Control">输入控件</param>
        /// <param name="message">提示信息</param>
        /// <returns>是否为空</returns>
        public static bool CheckEmpty(System.Windows.Forms.Control Control, string message)
        {
            // 返回值
            bool returnValue = true;

            if (Control.Text.Length == 0)
            {
                returnValue = false;
                Control.Focus();
                Control.Select();
                if (message.Length > 0)
                {
                    System.Windows.Forms.MessageBox.Show(message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            return(returnValue);
        }
		internal void DisplayEditor(Control editor, EditableControl owner)
		{
			if (editor == null || owner == null || CurrentNode == null)
				throw new ArgumentNullException();

			HideEditor(false);

			CurrentEditor = editor;
			CurrentEditorOwner = owner;
			_editingNode = CurrentNode;

			editor.Validating += EditorValidating;
			UpdateEditorBounds();
			UpdateView();
			editor.Parent = this;
			editor.Focus();
			owner.UpdateEditor(editor);
		}
Esempio n. 45
0
 public static void FlashControl(Control control, string message)
 {
     var oldText = control.Text;
     var oldForeColor = control.ForeColor;
     var oldFont = control.Font;
     try {
         control.Text = message;
         control.ForeColor = Color.FromArgb(0x00e00000);
         var newSize = (float)Math.Pow(oldFont.Size, 1.8) / 5.7;  // please don't ask
         control.Font = new Font(oldFont.FontFamily, oldFont.Size * 1.25f, FontStyle.Bold);
         control.Refresh();
         Thread.Sleep(750);
         control.Text = oldText;
     } finally {
         control.Text = oldText;
         control.ForeColor = oldForeColor;
         control.Font = oldFont;
         control.Focus();
     }
 }
Esempio n. 46
0
        /// <summary>
        /// Validate coordinate value
        /// </summary>
        /// <param name="coordCtrl">Control contains coordinate information</param>
        /// <returns>Whether the coordinate value is validated</returns>
        public static bool ValidateCoord(Control coordCtrl)
        {
            if (!ValidateNotNull(coordCtrl, "Coordinate"))
            {
                return false;
            }

            try
            {
                Convert.ToDouble(coordCtrl.Text);
            }
            catch (Exception)
            {
                ShowWarningMessage(resManager.GetString("CoordinateFormatWrong"),
                                   Properties.Resources.ResourceManager.GetString("FailureCaptionInvalidValue"));
                coordCtrl.Focus();
                return false;
            }

            return true;
        }
        /// <summary>
        /// 回答納期データ取得処理
        /// </summary>
        /// <param name="set">画面展開なしの場合:falesに設定する</param>
        /// <returns></returns>
        private DataTable CheckData()
        {
            for (int i = 0; i < detailControls.Length; i++)
            {
                if (CheckDetail(i, false) == false)
                {
                    detailControls[i].Focus();
                    return(null);
                }
            }
            //入荷予定日 (To)
            //入荷予定月 (To)
            //発注日     (To)
            //のどれかの入力があること
            //カーソルは               入荷予定日(To)
            if (string.IsNullOrWhiteSpace(detailControls[(int)EIndex.ArrivalPlanDateTo].Text) && string.IsNullOrWhiteSpace(detailControls[(int)EIndex.ArrivalPlanMonthTo].Text) &&
                string.IsNullOrWhiteSpace(detailControls[(int)EIndex.OrderDateTo].Text))
            {
                //E180
                bbl.ShowMessage("E180");
                detailControls[(int)EIndex.ArrivalPlanDateTo].Focus();
                return(null);
            }

            //[D_ArrivalPlan_SelectForPrint]
            doe = GetEntity();

            DataTable dt = mibl.D_ArrivalPlan_SelectForPrint(doe);

            //以下の条件でデータが存在しなければエラー (Error if record does not exist)E133
            if (dt.Rows.Count == 0)
            {
                bbl.ShowMessage("E128");
                previousCtrl.Focus();
                return(null);
            }

            return(dt);
        }
Esempio n. 48
0
 private bool ShowError(String message, int tracerIndex, Control control)
 {
     comboTracers.SelectedIndex = tracerIndex;
     MessageBox.Show(this, message, Program.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     control.Focus();
     return false;
 }
        /// <summary>
        /// Mouse button has been pressed in the view.
        /// </summary>
        /// <param name="c">Reference to the source control instance.</param>
        /// <param name="pt">Mouse position relative to control.</param>
        /// <param name="button">Mouse button pressed down.</param>
        /// <returns>True if capturing input; otherwise false.</returns>
        public virtual bool MouseDown(Control c, Point pt, MouseButtons button)
        {
            // Only interested in left mouse pressing down
            if (button == MouseButtons.Left)
            {
                // Capturing mouse input
                _captured = true;

                // Ensure the month calendar has the focus
                if ((c != null) && (c is KryptonMonthCalendar) && !c.ContainsFocus)
                    c.Focus();

                // Set the selection to be the day clicked
                DateTime? clickDay = _months.DayFromPoint(pt, false);
                if (clickDay != null)
                {
                    _months.Calendar.SetSelectionRange(clickDay.Value, clickDay.Value);
                    _months.FocusDay = clickDay.Value;
                    _months.AnchorDay = clickDay.Value;
                    _selectionStart = _months.Calendar.SelectionStart;
                    _needPaint(_months, new NeedLayoutEventArgs(true));
                }
                else
                    _selectionStart = DateTime.MinValue;
            }

            return _captured;
        }
 private bool FocusFirstControl(Control c)
 {
     if (c.CanFocus && c.CanSelect)
     {
         c.Focus();
         return true;
     }
     foreach (Control child in c.Controls)
     {
         if (FocusFirstControl(child))
             return true;
     }
     return false;
 }
Esempio n. 51
0
        public static bool ValidateIsEmailAddress(Control controlToValidate)
        {
            if (controlToValidate == null) throw new ArgumentException("controlToValidate");

            if (!StringUtils.IsValidEmailAddress(controlToValidate.Text.Trim()))
            {
                string ControlName = (controlToValidate.Tag == null) ? controlToValidate.Name : controlToValidate.Tag.ToString();
                Dialog.Error("Invalid email address in field '" + ControlName + "'", "Error");
                controlToValidate.Focus();
                return false;
            }

            // If we get here, we have a value
            return true;
        }
Esempio n. 52
0
        public static bool ValidateIsNotEmpty(Control controlToValidate)
        {
            if (controlToValidate == null) throw new ArgumentException("controlToValidate");
            if (string.IsNullOrEmpty(controlToValidate.Text.Trim()))
            {
                string ControlName = (controlToValidate.Tag == null) ? controlToValidate.Name : controlToValidate.Tag.ToString();
                Dialog.Error("Required field '" + ControlName + "' cannot be left blank", "Error");
                controlToValidate.Focus();
                return false;
            }

            // If we get here, we have a value
            return true;
        }
Esempio n. 53
0
        public static bool ValidateIsInRange(Control controlToValidate, long minValue, long maxValue)
        {
            if (controlToValidate == null) throw new ArgumentException("controlToValidate");

            long value = 0;
            if ((!long.TryParse(controlToValidate.Text, out value)) || (value < minValue) || (value > maxValue))
            {
                string ControlName = (controlToValidate.Tag == null) ? controlToValidate.Name : controlToValidate.Tag.ToString();
                Dialog.Error("Value in field '" + ControlName + "' is outside acceptable range\r\n\r\nValid range: " + minValue.ToString() + " to " + maxValue.ToString(), "Error");
                controlToValidate.Focus();
                return false;
            }

            // If we get here, we have a value
            return true;
        }
Esempio n. 54
0
        protected override void OnOpened(EventArgs e)
        {
            m_popedContainer.Focus();

            base.OnOpened(e);
        }
Esempio n. 55
0
        private void activate_pane(Control cur_pane) {
            logger.Debug("activating pane " + cur_pane);
            Debug.Assert(cur_pane != null);

            active_pane_ = cur_pane;
            var lv_pane = cur_pane as log_view;
            var list_pane = cur_pane as ObjectListView;

            util.postpone(() => {
                if (lv_pane != null)
                    lv_pane.set_focus();
                else if (list_pane != null) {
                    list_pane.Focus();
                    // maybe not such a good idea for notes pane???? TOTHINK
                    if (list_pane.SelectedIndex < 0 && list_pane.GetItemCount() > 0)
                        list_pane.SelectedIndex = 0;
                } else
                    cur_pane.Focus();
            }, 10);
        }
Esempio n. 56
0
        /// <summary>
        /// Mouse button has been pressed in the view.
        /// </summary>
        /// <param name="c">Reference to the source control instance.</param>
        /// <param name="pt">Mouse position relative to control.</param>
        /// <param name="button">Mouse button pressed down.</param>
        /// <returns>True if capturing input; otherwise false.</returns>
        public virtual bool MouseDown(Control c, Point pt, MouseButtons button)
        {
            // Only interested in left mouse pressing down
            if (button == MouseButtons.Left)
            {
                // Capturing mouse input
                _captured = true;

                if (Enabled)
                {
                    _target.Pressed = true;
                    PerformNeedPaint();
                }

                // Take the focus if allowed
                if (c.CanFocus)
                    c.Focus();
            }

            return _captured;
        }
Esempio n. 57
0
        public bool Validator(System.Windows.Forms.Control controlToValidate, ValidationTypes controlType, string userMessage)
        {
            errorContainer1.Message = "";
            var validated = false;

            switch (controlType)
            {
            case ValidationTypes.Text:
                if (String.IsNullOrWhiteSpace(controlToValidate.Text))
                {
                    errorContainer1.Control = controlToValidate;
                    if (userMessage != null)
                    {
                        errorContainer1.Message = userMessage;
                    }
                    controlToValidate.Focus();
                }
                else
                {
                    validated = true;
                }
                break;

            case ValidationTypes.Numeric:
                if (String.IsNullOrEmpty(controlToValidate.Text) || (!Tools.NumericValidators.IsNumeric(controlToValidate.Text)))
                {
                    //if (Convert.ToInt32(controlToValidate.Text) <= 0)
                    errorContainer1.Control = controlToValidate;
                    if (userMessage != null)
                    {
                        errorContainer1.Message = userMessage;
                    }
                    controlToValidate.Focus();
                }
                else
                {
                    validated = true;
                }
                break;

            case ValidationTypes.PositiveNumeric:
                if (String.IsNullOrEmpty(controlToValidate.Text) || (!Tools.NumericValidators.IsPositiveNumeric((controlToValidate.Text))))
                {
                    //if (Convert.ToInt32(controlToValidate.Text) <= 0)
                    errorContainer1.Control = controlToValidate;
                    if (userMessage != null)
                    {
                        errorContainer1.Message = userMessage;
                    }
                    controlToValidate.Focus();
                }
                else
                {
                    validated = true;
                }
                break;

            case ValidationTypes.Bool:
                if (controlToValidate is CheckBox)
                {
                    var currentCheck = (CheckBox)controlToValidate;
                    if (!currentCheck.Checked)
                    {
                        errorContainer1.Control = controlToValidate;
                        if (userMessage != null)
                        {
                            errorContainer1.Message = userMessage;
                        }
                        controlToValidate.Focus();
                    }
                    else
                    {
                        validated = true;
                    }
                }
                break;

            case ValidationTypes.Email:
                if (String.IsNullOrWhiteSpace(controlToValidate.Text))
                {
                    errorContainer1.Control = controlToValidate;
                    if (userMessage != null)
                    {
                        errorContainer1.Message = userMessage;
                    }
                    controlToValidate.Focus();
                }
                else
                {
                    validated = Regex.IsMatch(controlToValidate.Text, @"^([\w-\.+]+)@(([[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$");
                    if (!validated)
                    {
                        errorContainer1.Control = controlToValidate;
                        if (userMessage != null)
                        {
                            errorContainer1.Message = userMessage;
                        }
                        controlToValidate.Focus();
                    }
                }
                break;

            default:
                if (String.IsNullOrWhiteSpace(controlToValidate.Text))
                {
                    errorContainer1.Control = controlToValidate;
                    if (userMessage != null)
                    {
                        errorContainer1.Message = userMessage;
                    }
                    controlToValidate.Focus();
                }
                else
                {
                    validated = true;
                }
                break;
            }
            return(validated);
        }
            public void Show(Control control, int x, int y, int width, int height, PopupResizeMode resizeMode)
            {
                Size controlSize = control.Size;

                InitializeHost(control);

                m_dropDown.ResizeMode = resizeMode;
                m_dropDown.Show(x, y, width, height);

                control.Focus();
            }
Esempio n. 59
0
        /// <summary>
        ///  Plays back ink data to a specified control
        /// </summary>
        /// <param name="destinationControl">
        /// The control to play the Ink Data to.</param>           
        /// <param name="destinationRenderer">
        /// The Ink Renderer used to convert ink data to display coordinates</param>        
        /// <param name="keepDestinationAspectRatio">
        /// Specified whether to keep original aspect ratio of ink when scaling</param>
        /// <param name="playbackRate">
        /// The rate at which to play back the Ink Data</param>
        protected void PlaybackRecordedData( Control destinationControl,  
            bool keepDestinationAspectRatio,
            PacketPlaybackRate playbackRate,
            System.Drawing.Drawing2D.Matrix iTrans)
        {
            if( null != PlaybackInk ) {
                System.Drawing.Graphics g = destinationControl.CreateGraphics();
                Microsoft.Ink.Renderer destinationRenderer = new Microsoft.Ink.Renderer();
                destinationRenderer.SetViewTransform( iTrans );

                // Set whether or not to keep ink aspect ratio in the display window
                bool keepAspectRatio = keepDestinationAspectRatio;

                // Declare scaling factors
                float scaleFactorX = 1.0f;
                float scaleFactorY = 1.0f;

                // Get the size of the display window
                System.Drawing.Size displayWindowSize = destinationControl.ClientSize;

                // Get ink bounding box in ink space; convert the box's size to pixel;
                System.Drawing.Rectangle inkBoundingBox = PlaybackInk.GetBoundingBox();

                // Set the size and offset of the destination input
                System.Drawing.Point inkBoundingBoxSize = new System.Drawing.Point(inkBoundingBox.Width, inkBoundingBox.Height);

                // Convert the inkspace coordinate to pixels
                destinationRenderer.InkSpaceToPixel(g, ref inkBoundingBoxSize);

                // Get the offset of ink
                System.Drawing.Point inkOffset = inkBoundingBox.Location;

                // Determine what the scaling factor of the destination control is so
                // we know how to correctly resize the ink data
                getDisplayWindowScalingFactor(new System.Drawing.Size(inkBoundingBoxSize), displayWindowSize, keepAspectRatio, ref scaleFactorX, ref scaleFactorY);

                // Iterate through all ink strokes and extract the packet data
                foreach ( Microsoft.Ink.Stroke currentStroke in PlaybackInk.Strokes ) {
                    // Convert the stroke's packet data to INPUT structs
                    INPUT[] inputs = SendInputInterop.StrokeToInputs( currentStroke, destinationRenderer, g, scaleFactorX, scaleFactorY, destinationControl, inkOffset );

                    if ( null != inputs ) {
                        // Iterate through all the extracted INPUT data in order to send to destination control
                        for ( int i = 0; i < inputs.Length; i++ ) {
                            // Use the Win32 SendInput API to send the ink data point to the control
                            // Note that all playback will use the upper left of the destination control
                            // as the origin
                            SendInputInterop.SendInput( 1, new INPUT[] { inputs[i] }, System.Runtime.InteropServices.Marshal.SizeOf( inputs[i] ) );

                            // Determine the delay between packets (within a stroke)
                            switch( playbackRate ) {
                                case PacketPlaybackRate.Default:
                                default:
                                    System.Threading.Thread.Sleep(5);
                                    break;
                                case PacketPlaybackRate.Slow:
                                    System.Threading.Thread.Sleep(100);
                                    break;
                                case PacketPlaybackRate.Fast:
                                    break;
                            }
                        }
                    }

                    // Reset the focus to the destination control in case it has been changed
                    if( destinationControl.InvokeRequired ) {
                        GenericVoidCallback func = new GenericVoidCallback( delegate { destinationControl.Focus();  } );
                        destinationControl.Invoke( func );
                    } else
                        destinationControl.Focus();

                    // Create a delay between each stroke
                    if ( 0 != InterStrokeDelay) {
                        System.Threading.Thread.Sleep((int)(InterStrokeDelay));
                    }
                }
                // dispose the graphics object
                g.Dispose();
            }
        }
Esempio n. 60
0
 /// <summary>
 /// Called when user clicks on this panel.
 /// </summary>
 private void OnCurrentControl_MouseClick(object?sender, WinForms.MouseEventArgs e)
 {
     _currentControl?.Focus();
 }