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 Outside(CPOutside 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();
                //int new_row = dgvReflectors.Rows.Count;

                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;
            tbDistance.Text = data.Distance.ToString();
            cbFading.SelectedIndex = data.SoundFadingIndex;
            cbAngle.SelectedIndex = data.AngleIndex;

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

            switch (data.Microphone)
            {
                case 0:
                    rbNoMicrofon.Checked = true;
                    break;
                case 1:
                    rbParabolMicrofon.Checked = true;
                    tbMicLength.Text = data.MicrophoneText.ToString();
                    break;
                case 2:
                    rbTrubchatiyMicrofon.Checked = true;
                    tbMicLength.Text = data.MicrophoneText.ToString();
                    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 CPOutside loadOutside(XmlNode cp)
        {
            CPOutside outside = new CPOutside(cp.SelectSingleNode("name").FirstChild.Value);
            outside.SignalLevelIndex = getIntValue(cp, "signal_level");
            outside.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");
                outside.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");
                outside.absorbersList.Add(absorber);
            }

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

            outside.Volume = getDoubleValue(cp, "volume");
            outside.RoomTypeIndex = getIntValue(cp, "room_type");
            outside.Distance = getDoubleValue(cp, "distance");
            outside.SoundFadingIndex = getIntValue(cp, "sound_fading");
            outside.AngleIndex = getIntValue(cp, "angle");
            outside.NoiseReduction = getIntValue(cp, "noise_reduction");
            outside.Microphone = getIntValue(cp, "microphone");
            outside.MicrophoneText = getDoubleValue(cp, "mic_value");

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

            return outside;
        }
        private void getDataFromOutside(CPOutside cp, Outside outside)
        {
            cp.SignalLevelIndex = outside.SignalLevel;
            cp.NoiseTypeIndex = outside.NoiseType;
            cp.Volume = outside.Volume;
            cp.RoomTypeIndex = outside.RoomType;
            cp.Distance = outside.Distance;
            cp.SoundFadingIndex = outside.SoundFading;
            cp.AngleIndex = outside.Angle;
            cp.Microphone = outside.Microphone;
            cp.MicrophoneText = outside.MicrophoneValue;
            cp.NoiseReduction = outside.NoiseReduction;

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

            cp.Results = outside.Result;
        }