using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Shlukova_Analyza_BP
{
    public partial class Form1 : Form
    {
        Form3 form;
        public Form1(Form3 form)
        {
            InitializeComponent();
            this.form = form;
        }
        double[][] data;
        private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Control)
            {
                dataGridView1.Rows.Clear();
                dataGridView1.Columns.Clear();
                string str = Clipboard.GetText();
                string[] radky = str.Replace("\n", "").Split('\r'); // řádky jsou odděleny \r\n
                string[] sloupce;
                sloupce = radky[0].Split('\t');
                dataGridView1.Columns.Add("prom1", "prom1");
                dataGridView1.Columns.Add("prom2", "prom2");
                dataGridView1.Rows.Add(radky.GetLength(0)); 
                int radek = 0;
                int sloupec = 0;

                foreach (string s in radky)
                {
                    sloupce = s.Split('\t');
                    foreach (string policko in sloupce)
                    {
                        dataGridView1[sloupec, radek].Value = policko;
                        sloupec++;
                    }
                    sloupec = 0;
                    radek++;
                }
            }  
        }
        private void button1_Click(object sender, EventArgs e)
        {
            data = new double[dataGridView1.Rows.Count - 1][];
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                data[i] = new double[dataGridView1.Columns.Count];
                for (int j = 0; j < dataGridView1.Columns.Count; j++)
                {
                    double.TryParse(dataGridView1[j, i].Value.ToString(), out data[i][j]);
                }
            }
            form.NactenaData = data; 
        }
    }
}
