Пример #1
0
        //saves data to a file
        private void saveResultsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //open fileDialog
            SaveFileDialog writeFile = new SaveFileDialog();

            writeFile.Filter           = "TXT Files | *.txt";
            writeFile.InitialDirectory = @"C:\";
            writeFile.ShowDialog();

            string fileName = writeFile.FileName;

            if (fileName == "")
            {
                return;
            }

            //gets data from the textboxes and the dataEntryBox
            fileIO writeData = new fileIO();

            if (dataEntryBox.Text == null)
            {
                return;                             //return if nothing was in dataEntryBox
            }
            if (meanLabel.Text == null)
            {
                return;                             //return if no calculation was done
            }
            //convert needed values
            float mean = Convert.ToSingle(meanLabel.Text);
            float var  = Convert.ToSingle(varLabel.Text);
            float sd   = Convert.ToSingle(sdLabel.Text);

            //5 number sum
            float med = Convert.ToSingle(medianLabel.Text);
            float max = Convert.ToSingle(maxLabel.Text);
            float min = Convert.ToSingle(minLabel.Text);
            float fq  = Convert.ToSingle(firstQLabel.Text);
            float tq  = Convert.ToSingle(thirdQLabel.Text);

            //get data from dataEntryBox
            List <float> data = new List <float>();
            numbObtainer no   = new numbObtainer();

            data = no.generateList(dataEntryBox.Text);

            //call function to write to a file
            writeData.writeFile(fileName, fileName, mean, var, sd, med, fq, tq, data, max, min);
        }
Пример #2
0
        private void readFromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fileIO         fileReader = new fileIO();
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter           = "TXT Files | *.txt";
            fileDialog.InitialDirectory = @"C:\";
            fileDialog.ShowDialog();

            //get the file name to open
            string filename = fileDialog.FileName;

            if (filename == "")
            {
                return;
            }

            //call the file_io read function
            string data = fileReader.readFile(filename);

            //place data that was read into dataEntryBox
            dataEntryBox.Text = data;
        }