Пример #1
0
        public CExpression FExpression;            //显示方式

        public CExpressEdit Clone()
        {
            CExpressEdit obj = (CExpressEdit)this.MemberwiseClone();

            if (FExpression != null)
            {
                obj.FExpression = FExpression.Clone();
            }
            return(obj);
        }
Пример #2
0
        public override Object EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value)
        {
            CExpressEdit expressEdit = (CExpressEdit)(value);

            if (expressEdit != null)
            {
                return((Object)expressEdit.Edit());
            }
            else
            {
                return((Object)expressEdit);
            }
        }
Пример #3
0
        public override Object ConvertTo(ITypeDescriptorContext context,
                                         CultureInfo culture,
                                         Object value,
                                         Type destinationType)
        {
            if (destinationType.Equals(Type.GetType("System.String")) &&
                value.GetType().Equals(Type.GetType("DMS.DMS_CommModel.CExpressEdit")))
            {
                CExpressEdit ExpressEdit = (CExpressEdit)(value);
                return(ExpressEdit.szExpress);
            }
            TypeConverter aa = new TypeConverter();

            return(aa.ConvertTo(context, culture, value, destinationType));
        }
Пример #4
0
        //实现内部函数

        //public	virtual bool SaveToDB(DbCommand command) override;
        public virtual bool LoadFromNode(XmlElement Node)
        {
            Name        = Node.GetAttribute("Name");
            Description = Node.GetAttribute("Description");
            DAType      = (EDAType)Convert.ToInt32(Node.GetAttribute("DAType"));
            VarType     = (EVarTYPE)Convert.ToInt32(Node.GetAttribute("VarType"));
            Unit        = Node.GetAttribute("Unit");
            ByteAddr    = Convert.ToInt32(Node.GetAttribute("ByteAddr"));
            BitAddr     = Convert.ToInt32(Node.GetAttribute("BitAddr"));

            for (int i = 0; i < 10; i++)
            {
                IntTag[i] = Convert.ToSingle(Node.GetAttribute("IntTag" + i.ToString()));
            }
            for (int i = 0; i < 5; i++)
            {
                StrTag[i] = Node.GetAttribute("StrTag" + i.ToString());
            }

            Length     = Convert.ToInt32(Node.GetAttribute("Length"));
            bHighLow   = Convert.ToInt32(Node.GetAttribute("bHighLow"), 16);
            bHighByte  = BitConverter.GetBytes(bHighLow);
            BaseValue  = Convert.ToSingle(Node.GetAttribute("BaseValue"));
            RatioValue = Convert.ToSingle(Node.GetAttribute("RatioValue"));
            Readable   = Convert.ToInt32(Node.GetAttribute("Readable"));
            Writeable  = Convert.ToInt32(Node.GetAttribute("Writeable"));
            Default    = Node.GetAttribute("Value");
            SaveToDB   = Convert.ToInt32(Node.GetAttribute("SaveToDB"));

            if (StrTag[3].Length > 0)
            {
                ExpressR = new CExpressEdit(StrTag[3]);
            }
            if (StrTag[4].Length > 0)
            {
                ExpressW = new CExpressEdit(StrTag[4]);
            }
            switch (VarType)
            {
            case EVarTYPE.Var_INT:
                iDBByteNum = sizeof(int);
                break;

            case EVarTYPE.Var_UINT:
                iDBByteNum = sizeof(uint);
                break;

            case EVarTYPE.Var_LINT:
                iDBByteNum = sizeof(long);
                break;

            case EVarTYPE.Var_ULINT:
                iDBByteNum = sizeof(ulong);
                break;

            case EVarTYPE.Var_FLOAT:
                iDBByteNum = sizeof(float);
                break;

            case EVarTYPE.Var_DOUBLE:
                iDBByteNum = sizeof(double);
                break;

            case EVarTYPE.Var_CHAR:       //"字符型";
                iDBByteNum = sizeof(char);
                break;

            case EVarTYPE.Var_UCHAR:    //"无符号字符型";
                iDBByteNum = sizeof(char);
                break;

            case EVarTYPE.Var_BOOL:    // "布尔型";
                iDBByteNum = sizeof(bool);
                break;

            case EVarTYPE.Var_STRING:    //"字符串型";
                iDBByteNum = 0;
                break;

            case EVarTYPE.Var_BLOB:    //"二进制型";
                iDBByteNum = 1;
                break;

            default:
                iDBByteNum = 0;
                break;
            }
            return(true);
        }