Esempio n. 1
0
 private void save(BinaryWriter writer, Kontrolka kontrolka)
 {
     writer.Write(kontrolka.checkedControl);
     if (kontrolka.listBoxCollection == null)
     {
         writer.Write(0);
         writer.Write("null");
     }
     else
     {
         writer.Write(kontrolka.listBoxCount);
         if (kontrolka.checkedControl == 0)
         {
             foreach (var item in kontrolka.listBoxCollection)
             {
                 writer.Write(Int32.Parse(item.ToString()));
             }
         }
         else if (kontrolka.checkedControl == 1)
         {
             foreach (var item in kontrolka.listBoxCollection)
             {
                 writer.Write(Double.Parse(item.ToString()));
             }
         }
         else
         {
             foreach (var item in kontrolka.listBoxCollection)
             {
                 writer.Write(item.ToString());
             }
         }
     }
 }
Esempio n. 2
0
        private void read(BinaryReader reader, Kontrolka kontrolka)
        {
            int rb = reader.ReadInt32();

            kontrolka.checkedControl = rb;

            List <object> lista = new List <object>();
            int           count = reader.ReadInt32();


            if (count == 0)
            {
                string temp = reader.ReadString();
                if (!temp.Equals("null"))
                {
                    lista.Add(temp);
                }
                kontrolka.listBoxCollection = lista;
            }
            else
            {
                if (rb == 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        lista.Add(reader.ReadInt32());
                    }
                    kontrolka.listBoxCollection = lista;
                }
                else if (rb == 1)
                {
                    for (int i = 0; i < count; i++)
                    {
                        lista.Add(reader.ReadDouble());
                    }
                    kontrolka.listBoxCollection = lista;
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        lista.Add(reader.ReadString());
                    }
                    kontrolka.listBoxCollection = lista;
                }
            }
        }