private void btnAddAcousticKT_Click(object sender, EventArgs e)
        {
            FormAddAcoustickKT form = new FormAddAcoustickKT();
            DialogResult res = form.ShowDialog();
            if (res == System.Windows.Forms.DialogResult.OK)
            {
                //lstAcousticList.Items.Add(form.KTName);
                switch (form.Type)
                {
                    case KTType.Outside:
                        Outside outside = new Outside();
                        outside.ShowDialog();
                        CPOutside cp = new CPOutside(form.KTName);
                        getDataFromOutside(cp, outside);

                        currentResearch.CheckPoints.Add(cp);
                        researchUpdated();
                        break;
                    case KTType.Neighbor:

                        FormNeigborRooms neighbor = new FormNeigborRooms();
                        neighbor.ShowDialog();
                        CPNeighbor cpn = new CPNeighbor(form.KTName);

                        getDataFromNeighbor(cpn, neighbor);
                        currentResearch.CheckPoints.Add(cpn);
                        researchUpdated();
                        break;
                    case KTType.Vent:
                        FormVent vent = new FormVent();
                        vent.ShowDialog();
                        CPVent cpVent = new CPVent(form.KTName);
                        getDataFromVent(cpVent, vent);
                        currentResearch.CheckPoints.Add(cpVent);
                        researchUpdated();
                        break;
                    case KTType.Vibro:
                        FormVibro vibro = new FormVibro();
                        vibro.ShowDialog();
                        CPVibro cpVibro = new CPVibro(form.KTName);
                        getDataFromVibro(cpVibro, vibro);
                        currentResearch.CheckPoints.Add(cpVibro);
                        researchUpdated();
                        break;
                }
            }
        }
        public FormNeigborRooms(CPNeighbor data)
            : this()
        {
            cbSignalLevel.SelectedIndex = data.SignalLevelIndex;
            cbNoiseType.SelectedIndex = data.NoiseTypeIndex;

            tbReflectorsNumber.Text = data.reflectorsList.Count.ToString();
            dgvReflectors.Rows.Clear();
            foreach (CPOutside.Reflector r in data.reflectorsList)
            {
                int new_row = dgvReflectors.Rows.Add();

                dgvReflectors.Rows[new_row].Cells[0].Value = r.square.ToString();
                dgvReflectors.Rows[new_row].Cells[1].Value = ((DataGridViewComboBoxCell)dgvReflectors.Rows[new_row].Cells[1]).Items[r.MaterialIndex];
            }

            tbAbsorbersNumber.Text = data.absorbersList.Count.ToString();
            dgvAbsorber.Rows.Clear();
            foreach (CPOutside.Reflector r in data.absorbersList)
            {
                int new_row = dgvAbsorber.Rows.Add();

                dgvAbsorber.Rows[new_row].Cells[0].Value = r.square.ToString();
                dgvAbsorber.Rows[new_row].Cells[1].Value = ((DataGridViewComboBoxCell)dgvAbsorber.Rows[new_row].Cells[1]).Items[r.MaterialIndex];
            }

            tbConsumersNumber.Text = data.consumersList.Count.ToString();
            dgvConsumers.Rows.Clear();
            foreach (int index in data.consumersList)
            {
                int new_row = dgvConsumers.Rows.Add();
                dgvConsumers.Rows[new_row].Cells[0].Value = ((DataGridViewComboBoxCell)dgvConsumers.Rows[new_row].Cells[0]).Items[index];
            }

            tbNeighborVolume.Text = data.Volume.ToString();
            cbRoomType.SelectedIndex = data.RoomTypeIndex;

            switch (data.NoiseReduction)
            {
                case 0:
                    rbNoNoiseReduction.Checked = true;
                    break;
                case 1:
                    rbStrongNoiseReduction.Checked = true;
                    break;
                case 2:
                    rbWeakNoiseReduction.Checked = true;
                    break;
            }

            tbSoundprofLevel125.Text = data.Results.SoundproofLefel[0].ToString();
            tbSoundprofLevel250.Text = data.Results.SoundproofLefel[1].ToString();
            tbSoundprofLevel500.Text = data.Results.SoundproofLefel[2].ToString();
            tbSoundprofLevel1000.Text = data.Results.SoundproofLefel[3].ToString();
            tbSoundprofLevel2000.Text = data.Results.SoundproofLefel[4].ToString();
            tbSoundprofLevel4000.Text = data.Results.SoundproofLefel[5].ToString();
            tbSoundprofLevel8000.Text = data.Results.SoundproofLefel[6].ToString();

            tbRatio125.Text = data.Results.Ratio[0].ToString();
            tbRatio250.Text = data.Results.Ratio[1].ToString();
            tbRatio500.Text = data.Results.Ratio[2].ToString();
            tbRatio1000.Text = data.Results.Ratio[3].ToString();
            tbRatio2000.Text = data.Results.Ratio[4].ToString();
            tbRatio4000.Text = data.Results.Ratio[5].ToString();
            tbRatio8000.Text = data.Results.Ratio[6].ToString();

            tbReadability.Text = data.Results.W.ToString();
        }
        private CPNeighbor loadNeighbor(XmlNode cp)
        {
            CPNeighbor neigh = new CPNeighbor(cp.SelectSingleNode("name").FirstChild.Value);

            neigh.SignalLevelIndex = getIntValue(cp, "signal_level");
            neigh.NoiseTypeIndex = getIntValue(cp, "noise_type");

            foreach (XmlNode reflector_node in cp.SelectNodes("reflectors/*"))
            {
                CPOutside.Reflector reflector = new CPOutside.Reflector();
                reflector.square = getDoubleValue(reflector_node, "square");
                reflector.MaterialIndex = getIntValue(reflector_node, "material");
                neigh.reflectorsList.Add(reflector);
            }

            foreach (XmlNode absorber_node in cp.SelectNodes("absorbers/*"))
            {
                CPOutside.Reflector absorber = new CPOutside.Reflector();
                absorber.square = getDoubleValue(absorber_node, "square");
                absorber.MaterialIndex = getIntValue(absorber_node, "ratio");
                neigh.absorbersList.Add(absorber);
            }

            foreach (XmlNode consumer_node in cp.SelectNodes("consumers/*"))
            {
                int consumer;
                consumer = Int32.Parse(consumer_node.FirstChild.Value);
                neigh.consumersList.Add(consumer);
            }

            neigh.Volume = getDoubleValue(cp, "volume");
            neigh.RoomTypeIndex = getIntValue(cp, "room_type");
            neigh.NoiseReduction = getIntValue(cp, "noise_reduction");

            neigh.Results = ResearchResults.FromXml(cp.SelectSingleNode("results"));

            return neigh;
        }
        private void getDataFromNeighbor(CPNeighbor cp, FormNeigborRooms outside)
        {
            cp.SignalLevelIndex = outside.SignalLevel;
            cp.NoiseTypeIndex = outside.NoiseType;
            cp.Volume = outside.Volume;
            cp.RoomTypeIndex = outside.RoomType;
            cp.NoiseReduction = outside.NoiseReduction;

            cp.reflectorsList = outside.Reflectors;
            cp.absorbersList = outside.Absorbers;
            cp.consumersList = outside.Consumers;

            cp.Results = outside.Result;
        }