Exemplo n.º 1
0
        /////////////////////////////////////////////////////////////////////////////////////////////
        private void button1_Click(object sender, EventArgs e)
        {
            bool isMinimumFrequencyFieldIsEmpty = frequencyTextField.Text.Length == 0;
            bool isMaximumFrequencyFieldIsEmpty = frequencyMaxTextBox.Text.Length == 0;
            bool isDiameterFieldIsEmpty = diameterTextBox.Text.Length == 0;

            if (isMinimumFrequencyFieldIsEmpty || isMaximumFrequencyFieldIsEmpty)
            {
                return;
            }

            DirectivityDependence newMDIChild = new DirectivityDependence();

            int numberOfCheckedCheckboxes = Convert.ToInt32(checkBox1.Checked) + Convert.ToInt32(checkBox2.Checked) + Convert.ToInt32(checkBox3.Checked);

            List<Microphone> microphonesList = new List<Microphone>();

            int index = 0;

            if (checkBox1.Checked) // linear mic
            {
                bool isDelthaFieldIsEmpty = deltaTextField.Text.Length == 0;
                bool isMicrophonesCountFieldIsEmpty = numberTextField.Text.Length == 0;

                if (isDelthaFieldIsEmpty || isMicrophonesCountFieldIsEmpty)
                {
                    return;
                }

                MicrophoneProperties properties = new MicrophoneProperties(MicrophoneType.MicrophoneTypeLinear, (Convert.ToDouble(deltaTextField.Text) / (double)100), Convert.ToInt32(numberTextField.Text), 0);
                String title = "Линейная группа микрофонов";

                Microphone microphone = new Microphone(title, properties);

                microphonesList.Add(microphone);
            }

            if (checkBox2.Checked) // organ mic
            {
                bool isDelthaFieldIsEmpty = deltaTextField.Text.Length == 0;
                bool isTubesCountFieldIsEmpty = numberTextField.Text.Length == 0;

                if (isDelthaFieldIsEmpty || isTubesCountFieldIsEmpty)
                {
                    return;
                }

                MicrophoneProperties properties = new MicrophoneProperties(MicrophoneType.MicrophoneTypeOrgan, (Convert.ToDouble(deltaTextField.Text) / (double)100), Convert.ToInt32(numberTextField.Text), 0);
                String title = "Микрофон органного типа";

                Microphone microphone = new Microphone(title, properties);

                microphonesList.Add(microphone);
            }

            if (checkBox3.Checked) // parabolic mic
            {
                if (isDiameterFieldIsEmpty)
                {
                    return;
                }

                double diameter = Convert.ToDouble(diameterTextBox.Text) / (float)100;
                MicrophoneProperties properties = new MicrophoneProperties(MicrophoneType.MicrophoneTypeParabolic, 0.0, 0, diameter);
                String title = "Параболический микрофон";

                Microphone microphone = new Microphone(title, properties);

                microphonesList.Add(microphone);
            }

            newMDIChild.maxFrequency = Convert.ToDouble(frequencyMaxTextBox.Text);
            newMDIChild.minFrequency = Convert.ToDouble(frequencyTextField.Text);
            if (isOpenedForAddingGraph && dependenceForm != null)
            {
                foreach (Microphone mic in microphonesList)
                {
                    mic.buildDirectivityDepencity(newMDIChild.minFrequency, newMDIChild.maxFrequency);
                    dependenceForm.microphonesList.Add(mic);
                }

                dependenceForm.RebuildGraph();
                this.Close();
                return;
            }
            else
            {
                newMDIChild.microphonesList = microphonesList;
            }
            newMDIChild.Show();
        }
Exemplo n.º 2
0
        // build directivity diagram
        /////////////////////////////////////////////////////////////////////////////////////////////
        private void button2_Click(object sender, EventArgs e)
        {
            // It opens directivity diagram form only, graph build after form loading
            double[] array = null;
            System.String plotTitle = "";
            Microphone microphone;
            MicrophoneProperties properties = null;

            if (organRadioButton.Checked)
            {
                plotTitle = "Микрофон органного типа";
                properties = new MicrophoneProperties(MicrophoneType.MicrophoneTypeOrgan, 0, 0, 0);
            }
            else if (lineGroupRadioButton.Checked)
            {
                plotTitle = "Линейная группа микрофонов";
                properties = new MicrophoneProperties(MicrophoneType.MicrophoneTypeLinear, 0, 0, 0);
            }
            else if (parabolicRadioButton.Checked)
            {
                plotTitle = "Параболический микрофон";
                properties = new MicrophoneProperties(MicrophoneType.MicrophoneTypeParabolic, 0, 0, 0);
            }

            microphone = new Microphone(plotTitle, properties);

            DirectivityDiagram newMDIChild = new DirectivityDiagram();

            newMDIChild.microphone = microphone;
            newMDIChild.Show();
        }