Exemplo n.º 1
0
        //Удаление обьекта
        private void btn_del_obj_Click(object sender, EventArgs e)
        {
            ObjectPOS[] temp = new ObjectPOS[objectp.Length - 1];
            number_of_objects--;
            for (int i = 0, z = 0; i < objectp.Length - 1; i++, z++)
            {
                if (i == lst_objects.SelectedIndex)
                {
                    z++;
                    temp[i] = objectp[z];

                }
                temp[i] = objectp[z];
            }
            objectp = temp;
            lst_objects.Items.Clear();
            lst_pos.Items.Clear();
            for (int i = 0; i < number_of_objects; i++)
            {
                lst_objects.Items.Add(objectp[i].name);
            }
            try
            {
                lst_objects.Focus();
                lst_objects.SelectedIndex = 0;
            }
            catch
            {
            }
        }
Exemplo n.º 2
0
 public static ObjectPOS[] get_obj()
 {
     IniFile cfg = new IniFile(Directory.GetCurrentDirectory() + "\\cfg.ini");
     int number_of_objects = 0;
     ObjectPOS[] objectp;
     string[] tmp;
     try
     {
         number_of_objects = int.Parse(cfg.IniReadValue("objects", "numberofobjects"));
     }
     catch
     {
         return null;
     }
     try
     {
         if (number_of_objects != 0)
         {
             objectp = new ObjectPOS[number_of_objects];
             for (int i = 0; i < number_of_objects; i++)
             {
                 objectp[i] = new ObjectPOS();
                 objectp[i].name = cfg.IniReadValue("objects", "obj" + (i + 1));
                 objectp[i].pos_number = int.Parse(cfg.IniReadValue(objectp[i].name, "numofpos"));
                 tmp = new string[objectp[i].pos_number];
                 for (int z = 0; z < objectp[i].pos_number; z++)
                 {
                     tmp[z] = cfg.IniReadValue(objectp[i].name, "pos" + (z + 1));
                 }
                 objectp[i].pos = tmp;
             }
             return objectp;
         }
         else
         {
             return null;
         }
     }
     catch
     {
         return null;
     }
 }
Exemplo n.º 3
0
 //Добавление обьекта
 private void btn_new_obj_Click(object sender, EventArgs e)
 {
     Form add = new frm_add();
     add.Owner = this;
     add.ShowDialog();
     if (add.DialogResult == System.Windows.Forms.DialogResult.OK)
     {
         ObjectPOS[] temp = objectp;
         Array.Resize(ref temp, temp.Length + 1);
         temp[number_of_objects] = new ObjectPOS();
         temp[number_of_objects].name = tmp;
         temp[number_of_objects].pos_number = 0;
         objectp = temp;
         number_of_objects++;
     }
     lst_objects.Items.Clear();
     for (int i = 0; i < number_of_objects; i++)
     {
         lst_objects.Items.Add(objectp[i].name);
     }
     lst_objects.Focus();
     lst_objects.SelectedIndex = 0;
 }