Esempio n. 1
0
        /// <summary>
        /// Clone
        /// </summary>
        /// <returns></returns>

        public new ImageMx Clone()
        {
            ImageMx iMx = (ImageMx)this.MemberwiseClone();

            if (iMx.MdtExAttr != null)
            {
                iMx.MdtExAttr = MdtExAttr.Clone();
            }
            return(iMx);
        }
Esempio n. 2
0
        /// <summary>
        /// Binary Deserialize
        /// </summary>
        /// <param name="br"></param>
        /// <returns></returns>

        public static ImageMx DeserializeBinary(BinaryReader br)
        {
            ImageMx ix = new ImageMx();

            MobiusDataType.DeserializeBinary(br, ix);

            if (br.ReadBoolean())
            {
                int          len   = br.ReadInt32();
                byte[]       bytes = br.ReadBytes(len);
                MemoryStream ms    = new MemoryStream(bytes, 0, len);
                ix.Value = new Bitmap(ms);
            }

            ix.Caption = br.ReadString();

            return(ix);
        }
Esempio n. 3
0
        /// <summary>
        /// Custom Compact deserialization
        /// </summary>
        /// <param name="sa"></param>
        /// <param name="sai"></param>
        /// <returns></returns>

        public static ImageMx Deserialize(string[] sa, int sai)
        {
            ImageMx ix = new ImageMx();

            if (!Lex.IsNullOrEmpty(sa[0]))
            {
                string       s          = sa[0];
                int          p          = s.IndexOf(':');
                int          length     = Convert.ToInt32(s.Substring(0, p));
                byte[]       memorydata = Convert.FromBase64String(s.Substring(p + 1));
                MemoryStream rs         = new MemoryStream(memorydata, 0, length);
                ix.Value = new Bitmap(rs);
            }

            if (!Lex.IsNullOrEmpty(sa[1]))
            {
                ix.Caption = sa[1];
            }
            return(ix);
        }
Esempio n. 4
0
        /// <summary>
        /// Convert object to a MobiusDataType
        /// </summary>
        /// <param name="o"></param>
        /// <param name="type"></param>
        /// <returns></returns>

        public static MobiusDataType ConvertToMobiusDataType(
            MetaColumnType type,
            Object o)
        {
            switch (type)
            {
            case MetaColumnType.Integer:
            case MetaColumnType.Number:
            case MetaColumnType.DictionaryId:
                return(NumberMx.ConvertTo(o));

            case MetaColumnType.QualifiedNo:
                return(QualifiedNumber.ConvertTo(o));

            case MetaColumnType.String:
            case MetaColumnType.MolFormula:
            case MetaColumnType.Hyperlink:
            case MetaColumnType.Html:
            case MetaColumnType.Binary:
                return(StringMx.ConvertTo(o));

            case MetaColumnType.Date:
                return(DateTimeMx.ConvertTo(o));

            case MetaColumnType.CompoundId:
                return(CompoundId.ConvertTo(o));

            case MetaColumnType.Structure:
                return(MoleculeMx.ConvertTo(o));

            case MetaColumnType.Image:
                return(ImageMx.ConvertTo(o));                        // assume text is dblink

            default:
                throw new Exception("Unrecognized data type: " + type);
            }
        }
Esempio n. 5
0
        /////////////////////////////////////////////////////////////////
        //////////////////////////// Methods ////////////////////////////
        /////////////////////////////////////////////////////////////////

/// <summary>
/// Create a Mobius data type based on the supplied MetaColumn type
/// </summary>
/// <param name="type"></param>
/// <returns></returns>

        public static MobiusDataType New(
            MetaColumnType type)
        {
            MobiusDataType o;

            if (type == MetaColumnType.Integer)
            {
                o = new NumberMx();
            }
            else if (type == MetaColumnType.Number)
            {
                o = new NumberMx();
            }
            else if (type == MetaColumnType.QualifiedNo)
            {
                o = new QualifiedNumber();
            }
            else if (type == MetaColumnType.String)
            {
                o = new StringMx();
            }
            else if (type == MetaColumnType.Date)
            {
                o = new DateTimeMx();
            }
            else if (type == MetaColumnType.Binary)
            {
                o = new StringMx();
            }
            else if (type == MetaColumnType.CompoundId)
            {
                o = new CompoundId();
            }
            else if (type == MetaColumnType.Structure)
            {
                o = new MoleculeMx();
            }
            else if (type == MetaColumnType.MolFormula)
            {
                o = new StringMx();
            }
            else if (type == MetaColumnType.Image)
            {
                o = new ImageMx();
            }
            else if (type == MetaColumnType.DictionaryId)
            {
                o = new NumberMx();
            }
            else if (type == MetaColumnType.Hyperlink)
            {
                o = new StringMx();
            }
            else if (type == MetaColumnType.Html)
            {
                o = new StringMx();
            }
            else
            {
                throw new Exception("Unrecognized data type: " + type);
            }

            return(o);
        }
Esempio n. 6
0
        /// <summary>
        /// Custom compact Deserialization of MobiusDataType
        /// </summary>
        /// <returns></returns>

        public static MobiusDataType Deserialize(string[] sa)
        {
            int sai;

            MobiusDataType mdt  = null;
            char           type = sa[0][0];

            sai = 5;             // first array entry for specific subclass

            switch (type)
            {
            case 'M':                     // ChemicalStructure (Molecule)
                mdt = MoleculeMx.Deserialize(sa, sai);
                break;

            case 'C':                     // CompoundId
                mdt = CompoundId.Deserialize(sa, sai);
                break;

            case 'D':                     // DateTimeEx
                mdt = DateTimeMx.Deserialize(sa, sai);
                break;

            case 'I':                     // ImageEx
                mdt = ImageMx.Deserialize(sa, sai);
                break;

            case 'N':                     //NumberEx
                mdt = NumberMx.Deserialize(sa, sai);
                break;

            case 'Q':                     // QualifiedNumber
                mdt = QualifiedNumber.Deserialize(sa, sai);
                break;

            case 'S':                     // StringEx
                mdt = StringMx.Deserialize(sa, sai);
                break;

            default:
                throw new Exception("Unexpected MobiusDataType: " + type);
            }

            if (!Lex.IsNullOrEmpty(sa[1]))
            {
                mdt.BackColor = Color.FromArgb(int.Parse(sa[1]));
            }

            if (!Lex.IsNullOrEmpty(sa[2]))
            {
                mdt.ForeColor = Color.FromArgb(int.Parse(sa[2]));
            }

            if (!Lex.IsNullOrEmpty(sa[3]))
            {
                mdt.DbLink = sa[3];
            }

            if (!Lex.IsNullOrEmpty(sa[4]))
            {
                mdt.Hyperlink = sa[4];
            }

            return(mdt);
        }
Esempio n. 7
0
/// <summary>
/// Deserialize a single value object
/// </summary>
/// <param name="ba"></param>
/// <returns></returns>

        public static object ReadBinaryItem(
            BinaryReader br)
        {
            object     vo     = null;
            VoDataType voType = (VoDataType)br.ReadByte();

            switch (voType)
            {
            case VoDataType.Null:
                return(null);

            case VoDataType.DbNull:
                return(DBNull.Value);

            case VoDataType.Byte:
                return(br.ReadByte());

            case VoDataType.Int16:
                return(br.ReadInt16());

            case VoDataType.Int32:
                return(br.ReadInt32());

            case VoDataType.Int64:
                return(br.ReadInt64());

            case VoDataType.Float:
                return(br.ReadSingle());

            case VoDataType.Double:
                return(br.ReadDouble());

            case VoDataType.Char:
                return(br.ReadChar());

            case VoDataType.String:
                return(br.ReadString());

            case VoDataType.DateTime:
                return(new DateTime(br.ReadInt64()));

            case VoDataType.CompoundId:
                return(CompoundId.DeserializeBinary(br));

            case VoDataType.NumberMx:
                return(NumberMx.DeserializeBinary(br));

            case VoDataType.QualifiedNo:
                return(QualifiedNumber.DeserializeBinary(br));

            case VoDataType.StringMx:
                return(StringMx.DeserializeBinary(br));

            case VoDataType.DateTimeMx:
                return(DateTimeMx.DeserializeBinary(br));

            case VoDataType.ImageMx:
                return(ImageMx.DeserializeBinary(br));

            case VoDataType.ChemicalStructure:
                return(MoleculeMx.DeserializeBinary(br));

            default:
                throw new Exception("Unrecognized type: " + voType);
            }
        }