示例#1
0
        /// <summary>
        ///   ***********************Numeric*****************************************
        /// </summary>
        private void getRealNumericPicture()
        {
            String mask             = _picData.getMask();
            int    dec_             = _picData.getDec();
            int    whole_           = _picData.getWholes();
            bool   decimal_         = _picData.withDecimal();
            bool   dec_pnt_in_first = _picData.decInFirstPos();
            bool   isNegative       = _picData.isNegative();
            bool   isFirstPic_N     = true;
            bool   isPointInserted  = false;

            int currChar;

            for (int i = 0; i < _picData.getMaskSize(); i++)
            {
                currChar = mask[i]; // it's ASCII of the char
                switch (currChar)
                {
                case PICInterface.PIC_N:
                    if (isFirstPic_N)
                    {
                        if (isNegative)
                        {
                            setPictures('-', '0');
                        }

                        if (dec_pnt_in_first)
                        {
                            setPictures('.', '1');
                            isPointInserted = true;
                        }
                        else if (whole_ > 0)
                        {
                            whole_--;
                            setPictures('#', '0');
                        }
                        isFirstPic_N = false;
                        break;
                    }

                    if (decimal_)
                    {
                        if (whole_ > 0)
                        {
                            whole_--;
                            setPictures('#', '0');
                        }
                        else if (whole_ == 0 && !isPointInserted)
                        {
                            setPictures('.', '1');
                            isPointInserted = true;
                        }
                        else if (dec_ > 0)
                        {
                            dec_--;
                            setPictures('#', '0');
                        }
                    }
                    else
                    {
                        if (whole_ > 0)
                        {
                            whole_--;
                            setPictures('#', '0');
                        }
                    }
                    break;

                default: // const string in Alpha
                    setPictures((char)currChar, '1');
                    break;
                }
            }
            Events.WriteDevToLog(_pictureReal.ToString());
            Events.WriteDevToLog(_pictureEnable.ToString());
        }