/// <summary>
 /// 根据指定键获取字符串
 /// </summary>
 /// <param name="requestKey"></param>
 /// <param name="required"></param>
 /// <returns></returns>
 protected string TryGetString(string requestKey, bool required)
 {
     InputCheckType[] ict = null;
     if (required)
     {
         ict = new InputCheckType[] { InputCheckType.NotNUll };
     }
     return(TryGetString(requestKey, requestKey, ict));
 }
Example #2
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            checkType = (InputCheckType)EditorGUILayout.EnumPopup("Check type:", checkType);

            parameterID = Action.ChooseParameterGUI(checkType.ToString() + " name:", parameters, parameterID, ParameterType.String);
            if (parameterID < 0)
            {
                inputName = EditorGUILayout.TextField(checkType.ToString() + " name:", inputName);
            }

            if (checkType == InputCheckType.Axis)
            {
                EditorGUILayout.BeginHorizontal();
                axisCondition = (IntCondition)EditorGUILayout.EnumPopup(axisCondition);
                axisValue     = EditorGUILayout.FloatField(axisValue);
                EditorGUILayout.EndHorizontal();
            }
        }
Example #3
0
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            checkType = (InputCheckType) EditorGUILayout.EnumPopup ("Check type:" , checkType);

            if (checkType == InputCheckType.Axis || checkType == InputCheckType.Button)
            {
                parameterID = Action.ChooseParameterGUI (checkType.ToString () + " name:", parameters, parameterID, ParameterType.String);
                if (parameterID < 0)
                {
                    inputName = EditorGUILayout.TextField (checkType.ToString () + " name:", inputName);
                }

                if (checkType == InputCheckType.Axis)
                {
                    EditorGUILayout.BeginHorizontal ();
                    axisCondition = (IntCondition) EditorGUILayout.EnumPopup (axisCondition);
                    axisValue = EditorGUILayout.FloatField (axisValue);
                    EditorGUILayout.EndHorizontal ();
                }
            }
        }
Example #4
0
        /// <summary>
        /// Действия, которые нужно совершить, если пользователь ввёл неверные данные
        /// </summary>
        /// <param name="ShowErrMsg">
        /// Нужно ли показывать сообщения об ошибке. Это не нужно делать, например, если AdditionalRightInputCond == false
        /// </param>
        private void OnErrorInput(bool ShowErrMsg)
        {
            if (InputCheckType == enInputCheckType.None && AdditionalRightInputCond == null)
            {
                return;
            }

            if (ReturnPrevValOnErrInput)
            {
                HandleTextChanged = false;
                PrevValReturned   = true;
                Text = m_TextOnGotFocus;
            }

            if (ShowErrMsg && Math.Abs(Environment.TickCount - m_ShowErrorMsgMs) > MIN_TIME_BETWEEN_CHECK_ERROR_INPUT_MS)
            {
                string ResMsgStr = null;
                string Msg       = null;

                string strErrDesc = LocalizationManager.ResourceManager.GetString("resfmt" + InputCheckType.ToString() + "InvalidNumber");
                if (InputCheckType == enInputCheckType.Float ||
                    InputCheckType == enInputCheckType.FloatOrEmpty ||
                    InputCheckType == enInputCheckType.NotNegativeFloat ||
                    InputCheckType == enInputCheckType.NotNegativeFloatOrEmpty ||
                    InputCheckType == enInputCheckType.PositiveFloat ||
                    InputCheckType == enInputCheckType.PositiveFloatOrEmpty)
                {   /* Добавляем в строку десятичный разделитель, свойственный для выбранного языка */
                    strErrDesc = string.Format(strErrDesc, Properties.Resources.resDecimalPointOrComma);
                }

                if (ElementCoords.IsEmpty())
                {
                    ResMsgStr = ErrorMsgResString == null ?
                                ErrorMsgString :
                                LocalizationManager.ResourceManager.GetString(ErrorMsgResString);
                    if (ErrorMsgResString == STD_ERROR_MSG_RES_STRING || ErrorMsgResString == null)
                    {
                        if (AddWhatWrongStr)
                        {
                            Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, FieldName, strErrDesc, Properties.Resources.resStdInputErrMsgEnd) :
                                  string.Format(ResMsgStr, FieldName, strErrDesc);
                        }
                        else
                        {
                            Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, FieldName, Properties.Resources.resStdInputErrMsgEnd) :
                                  string.Format(ResMsgStr, FieldName);
                        }
                    }
                    else
                    if (string.IsNullOrEmpty(FieldName))
                    {
                        if (AddWhatWrongStr)
                        {
                            Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, strErrDesc, Properties.Resources.resStdInputErrMsgEnd) :
                                  string.Format(ResMsgStr, strErrDesc);
                        }
                        else
                        {
                            Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, Properties.Resources.resStdInputErrMsgEnd) :
                                  ResMsgStr;
                        }
                    }
                    else
                    if (AddWhatWrongStr)
                    {
                        Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, FieldName, strErrDesc, Properties.Resources.resStdInputErrMsgEnd) :
                              string.Format(ResMsgStr, FieldName, strErrDesc);
                    }
                    else
                    {
                        Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, FieldName, Properties.Resources.resStdInputErrMsgEnd) :
                              string.Format(ResMsgStr, FieldName, ResMsgStr);
                    }
                }
                else
                {
                    ResMsgStr = LocalizationManager.ResourceManager.GetString(ErrorMsgResStringWithRowNum);
                    if (ErrorMsgResStringWithRowNum == STD_ERROR_MSG_RES_STRING_WITH_ROW_NUM)
                    {
                        if (AddWhatWrongStr)
                        {
                            Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, FieldName, ElementCoords.Y + 1, strErrDesc, Properties.Resources.resStdInputErrMsgEnd) :
                                  string.Format(ResMsgStr, FieldName, ElementCoords.Y + 1, strErrDesc);
                        }
                        else
                        {
                            Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, FieldName, ElementCoords.Y + 1, Properties.Resources.resStdInputErrMsgEnd) :
                                  string.Format(ResMsgStr, FieldName, ElementCoords.Y + 1);
                        }
                    }
                    else
                    if (string.IsNullOrEmpty(FieldName))
                    {
                        if (AddWhatWrongStr)
                        {
                            Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, ElementCoords.Y + 1, strErrDesc, Properties.Resources.resStdInputErrMsgEnd) :
                                  string.Format(ResMsgStr, ElementCoords.Y + 1, strErrDesc);
                        }
                        else
                        {
                            Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, ElementCoords.Y + 1, Properties.Resources.resStdInputErrMsgEnd) :
                                  string.Format(ResMsgStr, ElementCoords.Y + 1);
                        }
                    }
                    else
                    if (AddWhatWrongStr)
                    {
                        Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, FieldName, ElementCoords.Y + 1, strErrDesc, Properties.Resources.resStdInputErrMsgEnd) :
                              string.Format(ResMsgStr, FieldName, ElementCoords.Y + 1, strErrDesc);
                    }
                    else
                    {
                        Msg = UseStdErrMsgEnd ? string.Format(ResMsgStr, FieldName, ElementCoords.Y + 1, Properties.Resources.resStdInputErrMsgEnd) :
                              string.Format(ResMsgStr, FieldName, ElementCoords.Y + 1);
                    }
                }
                HandleGotFocus = false;
                /* Здесь Owner не задаём, т.к. это будет геморрой, а без Owner должно работать нормально */
                MessageBox.Show(Msg, AppAttributes.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                m_ShowErrorMsgMs = Environment.TickCount;
            }
        }