Exemple #1
0
        public void GetValueFromTextBoxes(Kiviohjelma kiviohjelma) //Funktio ottaa tekstilaatikoista arvot ja asettaa ne holder-muuttujille
        {
            Kiviohjelma _kivi = kiviohjelma;

            tyomaaHolder      = _kivi.tyomaa.Text.Trim();
            lajiteHolder      = _kivi.lajite.Text.Trim();
            nayteHolder       = _kivi.nayteNro.Text.Trim();
            dateHolder        = _kivi.date.Text.Trim();
            nayteOttajaHolder = _kivi.naytteenOttaja.Text.Trim();
            lisatietoHolder   = _kivi.lisatieto.Text.Trim();
            alaOtsikkoHolder  = _kivi.alempiOtsikko.Text.Trim();
            osoiteHolder      = _kivi.lahiosoite.Text.Trim();
            postiHolder       = _kivi.osoite.Text.Trim();
            puhHolder         = _kivi.puh.Text.Trim();
            tutkijaHolder     = _kivi.tutkija.Text.Trim();



            if (_kivi.rbKuivaseulonta.IsChecked == true) //Tarkastaa kumpi radiobuttoneista on valittuna
            {
                seulontaHolder = _kivi.rbKuivaseulonta.Content.ToString().Trim();
            }
            else
            {
                seulontaHolder = _kivi.rbPesuseulonta.Content.ToString().Trim();
            }
        }
Exemple #2
0
        public void SavePDF(Kiviohjelma kiviOhjelma)
        {
            Kiviohjelma _kivi = kiviOhjelma;

            //Avaa tallennus dialogin, joka tallentaa tiedoston oletuksena PDF-muodossa
            SaveFileDialog fileDialog = new SaveFileDialog();

            fileDialog.Filter           = "PDF Document (*.pdf)|*.pdf";
            fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            if (fileDialog.ShowDialog() == true)
            {
                try
                {
                    FileStream fs = (FileStream)fileDialog.OpenFile();

                    fs.Close();
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message, "Virhe");
                }
            }

            //Ottaa syötetyn tiedoston nimen sekä polun ja antaa sen parametrina PDFCreation funktiolle
            string text = fileDialog.FileName;

            Console.WriteLine(text);

            PDFCreation(text, _kivi);
        }
Exemple #3
0
        public string LoadAll(Window w, string json)
        {
            if (w.Name == "kiviohjelma")
            {
                Kiviohjelma         kiv          = (Kiviohjelma)w;
                List <KaikkiListat> kaikkilistat = new List <KaikkiListat>();

                List <SyotetytArvot>  syotteet    = new List <SyotetytArvot>();  //Kaikki käyttäjän syöttämät tiedot kentistä "Seulalle Jäi (g)"
                List <SeulaTallennus> seulacombot = new List <SeulaTallennus>(); //Seulacomboboksin arvot laitetaan tänne (mikä seula valittu, mones seula listasta se on ja mikä on comboboksin sijainti)
                //bool pesuseulValinta = false;
                JakoAsetukset       jako         = new JakoAsetukset();          //Laitetaan jaetun näytteen asetukset tänne talteen
                List <TekstiTiedot> tekstitiedot = new List <TekstiTiedot>();    //Tähän laitetaan talteen muut tiedot ohjelman yläosasta (nimi, työmaa, lajite jne...)
                List <SeulaLapPros> sisOhjeAla   = new List <SeulaLapPros>();    //Sisempi ohjealue, alempi ohje%
                List <SeulaLapPros> sisOhjeYla   = new List <SeulaLapPros>();    //Sisempi ohjealue, ylempi ohje%
                List <SeulaLapPros> uloOhjeAla   = new List <SeulaLapPros>();    //Ulompi ohjealue, alempi ohje%
                List <SeulaLapPros> uloOhjeYla   = new List <SeulaLapPros>();    //Ulompi ohjealue, ylempi ohje%


                kaikkilistat = JsonConvert.DeserializeObject <List <KaikkiListat> >(json);
                foreach (SyotetytArvot s in kaikkilistat[1].data)
                {
                    syotteet.Add(s);
                }
            }

            return(null);
        }
Exemple #4
0
        public void KayraPiirto(Kiviohjelma kiv)
        {
            Kiviohjelma _kivi = kiv;

            //Näytetään rakeisuuskäyrä syötettyjen arvojen avulla
            List <SeulakirjastoIndex> selist     = new List <SeulakirjastoIndex>(); //Seulat joita on käytetty laskennassa, eli X-arvot.
            List <SeulaLapPros>       tulist     = new List <SeulaLapPros>();       //Läpäisyprosenttitulokset, eli Y-arvot
            List <Seulakirjasto>      selistALL  = new List <Seulakirjasto>();      //Kaikki seulat mitä on valittuna. Tehdään täysi X-akseli tällä.
            List <SeulaLapPros>       sisOhjeAla = new List <SeulaLapPros>();       //Sisempi ohjealue, alempi ohje%
            List <SeulaLapPros>       sisOhjeYla = new List <SeulaLapPros>();       //Sisempi ohjealue, ylempi ohje%
            List <SeulaLapPros>       uloOhjeAla = new List <SeulaLapPros>();       //Ulompi ohjealue, alempi ohje%
            List <SeulaLapPros>       uloOhjeYla = new List <SeulaLapPros>();       //Ulompi ohjealue, ylempi ohje%


            //Lukee tarvittavat prosenttiarvot ja lisää ne tulist-listaan
            //Ottaa valitut seulat ohjelmasta, ottaa talteen niiden sijainnin järjestyslukuna ja laittaa ne selist-listaan
            //Tuloksissa saattaa olla välejä (kaikkeja rivejä ei täytetty) joten koodi tarkistaa sen myös

            if (_kivi.lapaisypros1.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 0,
                    tulos = Convert.ToDouble(_kivi.lapaisypros1.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula1.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 17,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 17,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros2.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 1,
                    tulos = Convert.ToDouble(_kivi.lapaisypros2.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula2.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 16,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 16,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros3.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 2,
                    tulos = Convert.ToDouble(_kivi.lapaisypros3.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula3.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 15,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 15,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros4.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 3,
                    tulos = Convert.ToDouble(_kivi.lapaisypros4.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula4.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 14,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 14,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros5.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 4,
                    tulos = Convert.ToDouble(_kivi.lapaisypros5.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula5.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 13,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 13,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros6.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 5,
                    tulos = Convert.ToDouble(_kivi.lapaisypros6.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula6.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 12,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 12,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros7.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 6,
                    tulos = Convert.ToDouble(_kivi.lapaisypros7.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula7.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 11,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 11,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros8.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 7,
                    tulos = Convert.ToDouble(_kivi.lapaisypros8.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula8.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 10,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 10,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros9.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 8,
                    tulos = Convert.ToDouble(_kivi.lapaisypros9.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula9.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 9,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 9,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros10.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 9,
                    tulos = Convert.ToDouble(_kivi.lapaisypros10.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula10.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 8,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 8,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros11.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 10,
                    tulos = Convert.ToDouble(_kivi.lapaisypros11.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula11.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 7,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 7,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros12.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 11,
                    tulos = Convert.ToDouble(_kivi.lapaisypros12.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula12.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 6,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 6,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros13.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 12,
                    tulos = Convert.ToDouble(_kivi.lapaisypros13.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula13.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 5,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 5,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros14.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 13,
                    tulos = Convert.ToDouble(_kivi.lapaisypros14.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula14.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 4,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 4,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros15.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 14,
                    tulos = Convert.ToDouble(_kivi.lapaisypros15.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula15.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 3,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 3,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros16.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 15,
                    tulos = Convert.ToDouble(_kivi.lapaisypros16.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula16.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 2,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 2,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros17.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 16,
                    tulos = Convert.ToDouble(_kivi.lapaisypros17.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula17.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 1,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 1,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }
            if (_kivi.lapaisypros18.Text != String.Empty)
            {
                SeulaLapPros sl = new SeulaLapPros
                {
                    index = 17,
                    tulos = Convert.ToDouble(_kivi.lapaisypros18.Text)
                };
                tulist.Add(sl);
                string seulatxt = _kivi.Seula18.Text;
                seulatxt = seulatxt.Replace(".", ",");
                if (Double.TryParse(seulatxt, out double r) == true)
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 0,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                else
                {
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 0,
                        seula = 0
                    };
                    selist.Add(ke);
                }
            }

            foreach (Control c in _kivi.seulaArvot.Children) //Kaikille esineille seulaArvot-canvasissa. Tarkoituksena ottaa kaikki valitut seulat dropdown-valikoista talteen
            {
                if (c.GetType() == typeof(ComboBox))         //jos esineen tyyppi on combobox
                {
                    //Console.WriteLine("Combobox text: " + ((ComboBox)c).Text+",  tag: "+ ((ComboBox)c).Tag);
                    if (((ComboBox)c).Tag.ToString() != null)        //Jos comboboxin tagi on tyhjä
                    {
                        if (((ComboBox)c).Tag.ToString() == "seula") //jos comboboxin tagi on "seula", eli kaikki seuladropdown-valikot
                        {
                            //Console.WriteLine(((ComboBox)c).Text);
                            string seulatxt = ((ComboBox)c).Text;
                            seulatxt = seulatxt.Replace(".", ",");
                            if (seulatxt != String.Empty && Double.TryParse(seulatxt, out double r) == true)
                            {
                                Seulakirjasto ke = new Seulakirjasto
                                {
                                    seula = Convert.ToDouble(seulatxt)
                                };
                                selistALL.Add(ke);
                            }

                            /*else
                             * {
                             *  Seulakirjasto ke = new Seulakirjasto
                             *  {
                             *      seula = 0
                             *  };
                             *  selistALL.Add(ke);
                             * }*/
                        }
                    }
                }
            }

            for (int i = 0; i < 4; i++)//Otetaan ohjealueet talteen yksi kolumni kerrallaan
            {
                switch (i)
                {
                case 0:
                    foreach (Control c in _kivi.ohjeArvot.Children)
                    {
                        if (c.GetType() == typeof(TextBox))
                        {
                            if (((TextBox)c).Tag.ToString() != null)
                            {
                                if (((TextBox)c).Tag.ToString() == "sisAla")
                                {
                                    if (((TextBox)c).Text != String.Empty)
                                    {
                                        string prostxt = ((TextBox)c).Text;
                                        prostxt = prostxt.Replace(".", ",");
                                        string       name = ((TextBox)c).Name;
                                        int          ind  = Convert.ToInt32(Regex.Match(name, @"\d+$").Value);//otetaan objektin järjestysnumero nimestä,
                                        SeulaLapPros ohj  = new SeulaLapPros
                                        {
                                            index = ind,
                                            tulos = Convert.ToDouble(prostxt)
                                        };
                                        sisOhjeAla.Add(ohj);

                                        /*string seulatxt = ((TextBox)c).Text;
                                         * seulatxt = seulatxt.Replace(".", ",");
                                         * SeulaLapPros ohj = new SeulaLapPros
                                         * {
                                         *  index = j,
                                         *  tulos = Convert.ToDouble(seulatxt)
                                         * };
                                         * sisOhjeAla.Add(ohj);*/
                                    }
                                }
                            }
                        }
                    }
                    break;

                case 1:
                    foreach (Control c in _kivi.ohjeArvot.Children)
                    {
                        if (c.GetType() == typeof(TextBox))
                        {
                            if (((TextBox)c).Tag.ToString() != null)
                            {
                                if (((TextBox)c).Tag.ToString() == "sisYla")
                                {
                                    if (((TextBox)c).Text != String.Empty)
                                    {
                                        string prostxt = ((TextBox)c).Text;
                                        prostxt = prostxt.Replace(".", ",");
                                        string       name = ((TextBox)c).Name;
                                        int          ind  = Convert.ToInt32(Regex.Match(name, @"\d+$").Value);//otetaan objektin järjestysnumero nimestä,
                                        SeulaLapPros ohj  = new SeulaLapPros
                                        {
                                            index = ind,
                                            tulos = Convert.ToDouble(prostxt)
                                        };
                                        sisOhjeYla.Add(ohj);
                                    }
                                }
                            }
                        }
                    }
                    break;

                case 2:
                    foreach (Control c in _kivi.ohjeArvot.Children)
                    {
                        if (c.GetType() == typeof(TextBox))
                        {
                            if (((TextBox)c).Tag.ToString() != null)
                            {
                                if (((TextBox)c).Tag.ToString() == "uloAla")
                                {
                                    if (((TextBox)c).Text != String.Empty)
                                    {
                                        string prostxt = ((TextBox)c).Text;
                                        prostxt = prostxt.Replace(".", ",");
                                        string       name = ((TextBox)c).Name;
                                        int          ind  = Convert.ToInt32(Regex.Match(name, @"\d+$").Value);//otetaan objektin järjestysnumero nimestä,
                                        SeulaLapPros ohj  = new SeulaLapPros
                                        {
                                            index = ind,
                                            tulos = Convert.ToDouble(prostxt)
                                        };
                                        uloOhjeAla.Add(ohj);
                                    }
                                }
                            }
                        }
                    }
                    break;

                case 3:
                    foreach (Control c in _kivi.ohjeArvot.Children)
                    {
                        if (c.GetType() == typeof(TextBox))
                        {
                            if (((TextBox)c).Tag.ToString() != null)
                            {
                                if (((TextBox)c).Tag.ToString() == "uloYla")
                                {
                                    if (((TextBox)c).Text != String.Empty)
                                    {
                                        string prostxt = ((TextBox)c).Text;
                                        prostxt = prostxt.Replace(".", ",");
                                        string       name = ((TextBox)c).Name;
                                        int          ind  = Convert.ToInt32(Regex.Match(name, @"\d+$").Value);//otetaan objektin järjestysnumero nimestä,
                                        SeulaLapPros ohj  = new SeulaLapPros
                                        {
                                            index = ind,
                                            tulos = Convert.ToDouble(prostxt)
                                        };
                                        uloOhjeYla.Add(ohj);
                                    }
                                }
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }

            /*foreach (SeulaLapPros s in sisOhjeAla)
             * {
             *  Console.WriteLine(s.index+", "+s.tulos);
             * }
             * Console.WriteLine("---------------------");
             * foreach (SeulaLapPros s in sisOhjeYla)
             * {
             *  Console.WriteLine(s.index + ", " + s.tulos);
             * }
             * Console.WriteLine("---------------------");
             * foreach (SeulaLapPros s in uloOhjeAla)
             * {
             *  Console.WriteLine(s.index + ", " + s.tulos);
             * }
             * Console.WriteLine("---------------------");
             * foreach (SeulaLapPros s in uloOhjeYla)
             * {
             *  Console.WriteLine(s.index + ", " + s.tulos);
             * }*/

            if (_kayra == null)
            {
                _kayra = new KiviKayra(_kivi, selist, tulist, selistALL, sisOhjeAla, sisOhjeYla, uloOhjeAla, uloOhjeYla);
                _kayra.Show();
            }
            else
            {
                _kayra.Close();
                _kayra = null;
                KayraPiirto(_kivi);
            }
        }
Exemple #5
0
        public KiviKayra(Window kiv, List <SeulakirjastoIndex> s, List <SeulaLapPros> p, List <Seulakirjasto> alls, List <SeulaLapPros> sisAla, List <SeulaLapPros> sisYla, List <SeulaLapPros> uloAla, List <SeulaLapPros> uloYla)
        {
            InitializeComponent();

            _kivi        = (Kiviohjelma)kiv;
            seulat       = s;
            prosentit    = p;
            kaikkiseulat = alls;
            sisOhjeAla   = sisAla;
            sisOhjeYla   = sisYla;
            uloOhjeAla   = uloAla;
            uloOhjeYla   = uloYla;

            //Tällä saadaan osoitin toimimaan niin, että ei tarvitse muuta tehdä kuin laittaa hiiren osoitin koordinaattipisteen päälle
            //niin se näyttää koordinaattitiedot automaattisesti
            customController = new PlotController();
            customController.UnbindMouseDown(OxyMouseButton.Left);
            customController.BindMouseEnter(PlotCommands.HoverSnapTrack);

            var model = new PlotModel {
                Title = "Rakeisuuskäyrä", Subtitle = "Vie hiiri pisteiden lähelle nähdäksesi arvot"
            };

            //model.PlotType = PlotType.XY;
            model.LegendPosition    = LegendPosition.TopRight;
            model.LegendOrientation = LegendOrientation.Horizontal;
            model.LegendPlacement   = LegendPlacement.Outside;

            /*Collection<Item> items = new Collection<Item>();
             * for (int i = kaikkiseulat.Count - 1; i >= 0; i--)
             * {
             *  items.Add(new Item(kaikkiseulat[i].seula.ToString(), kaikkiseulat[i].seula));
             * }*/
            LinearAxis yaxis = new LinearAxis //Y-akseli
            {
                Maximum            = 100,
                Minimum            = 0,
                Title              = "Prosentti",
                TickStyle          = TickStyle.Inside,
                MinorTickSize      = 4,
                Position           = AxisPosition.Left,
                MinorStep          = 5,
                MinorGridlineStyle = LineStyle.Dot,
                //AbsoluteMaximum = 100,
                //AbsoluteMinimum = 0,
                MajorStep = 10,
                //MinorStep = 5,
                MajorGridlineStyle = LineStyle.Dash,
                //MinorGridlineStyle = LineStyle.Dash,
                IsZoomEnabled = false,
                IsPanEnabled  = false
            };
            //------------------------------Logaritmiakseli-------------------------
            LogarithmicAxis xaxis = new LogarithmicAxis(); //X-akseli

            if (seulat == null || prosentit == null || seulat.Count == 0 || prosentit.Count == 0)
            {
                xaxis.Title              = "Seula";
                xaxis.TickStyle          = TickStyle.Inside;
                xaxis.Position           = AxisPosition.Bottom;
                xaxis.MajorGridlineStyle = LineStyle.Solid;
                //xaxis.MajorStep = 2;
                //xaxis.MinorGridlineStyle = LineStyle.Dash;
                //xaxis.Maximum = seulat[0].seula;
                xaxis.Minimum       = 0.001;
                xaxis.IsZoomEnabled = false;
                xaxis.IsPanEnabled  = false;
            }
            else
            {
                xaxis.Title              = "Seula";
                xaxis.TickStyle          = TickStyle.Inside;
                xaxis.Position           = AxisPosition.Bottom;
                xaxis.MajorGridlineStyle = LineStyle.Solid;
                //xaxis.Base = logbase;
                //xaxis.MajorStep =
                //xaxis.MinorGridlineStyle = LineStyle.Dash;
                xaxis.Maximum = kaikkiseulat[0].seula;
                //xaxis.Minimum = 0.001;
                if (kaikkiseulat[(kaikkiseulat.Count - 1)].seula > 0)
                {
                    xaxis.Minimum = (kaikkiseulat[(kaikkiseulat.Count - 1)].seula);
                }
                else
                {
                    xaxis.Minimum = 0.001;
                }
                xaxis.AbsoluteMinimum = 0;
                xaxis.IsZoomEnabled   = false;
                xaxis.IsPanEnabled    = false;
                xaxis.StartPosition   = 0;
            }

            /*CategoryAxis caxis = new CategoryAxis();//X-akseli
             *
             * if (seulat == null || prosentit == null || seulat.Count == 0 || prosentit.Count == 0)
             * {
             *  caxis.Title = "Seula";
             *  caxis.TickStyle = TickStyle.Inside;
             *  caxis.Position = AxisPosition.Bottom;
             *  caxis.IsTickCentered = true;
             *  caxis.MajorGridlineStyle = LineStyle.Solid;
             *  caxis.MajorGridlineColor = OxyColors.DarkSlateGray;
             *  caxis.MajorTickSize = 7;
             *  //caxis.Maximum = seulat[0].seula;
             *  //caxis.Minimum = seulat[(seulat.Count - 1)].seula;
             *  caxis.IsZoomEnabled = false;
             *  caxis.IsPanEnabled = false;
             *  caxis.MinorStep = 0.5;
             *  caxis.MajorStep = 1;
             *  caxis.ItemsSource = items;
             *  caxis.LabelField = "Label";
             * }
             * else
             * {
             *  caxis.Title = "Seula";
             *  caxis.TickStyle = TickStyle.Inside;
             *  caxis.Position = AxisPosition.Bottom;
             *  caxis.IsTickCentered = true;
             *  caxis.MajorGridlineStyle = LineStyle.Solid;
             *  caxis.MajorGridlineColor = OxyColors.DarkSlateGray;
             *  caxis.MajorTickSize = 7;
             *  //caxis.Maximum = seulat[0].seula;
             *  //caxis.Minimum = seulat[(seulat.Count-1)].seula;
             *  caxis.IsZoomEnabled = false;
             *  caxis.IsPanEnabled = false;
             *  caxis.MinorStep = 0.5;
             *  caxis.MajorStep = 1;
             *  caxis.ItemsSource = items;
             *  caxis.LabelField = "Label";
             * }
             * for (int i = kaikkiseulat.Count-1; i >= 0; i--) //Laittaa Y-akselille otsikot, eli seulat jotka on käytössä tällä hetkellä
             * {
             *  caxis.ActualLabels.Add(kaikkiseulat[i].seula.ToString());
             * }*/

            LineSeries l1 = new LineSeries //Tuloskäyrä/viiva
            {
                Title      = "Rakeisuuskäyrä",
                MarkerType = MarkerType.Circle,
                CanTrackerInterpolatePoints = false,
                MarkerSize = 5
                             //LabelFormatString = "Läp%: {1:0.0} %"
            };
            LineSeries ohje1 = new LineSeries
            {
                Title      = "Sisäiset ohjealueet",
                MarkerType = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                MarkerSize     = 0,
                Color          = OxyColors.CadetBlue,
                RenderInLegend = true
            };
            LineSeries ohje2 = new LineSeries
            {
                //Title = "Sisäinen ylempi ohjealue",
                MarkerType = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                MarkerSize     = 0,
                Color          = OxyColors.CadetBlue,
                RenderInLegend = false
            };
            LineSeries ohje3 = new LineSeries
            {
                Title      = "Ulkoiset ohjealueet",
                MarkerType = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                MarkerSize     = 0,
                Color          = OxyColors.Indigo,
                RenderInLegend = true
            };
            LineSeries ohje4 = new LineSeries
            {
                //Title = "Ulkoinen ylempi ohjealue",
                MarkerType = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                MarkerSize     = 0,
                Color          = OxyColors.Indigo,
                RenderInLegend = false
            };
            //seulat.Reverse();

            /*sisOhjeAla.Reverse();
            *  sisOhjeYla.Reverse();
            *  uloOhjeAla.Reverse();
            *  uloOhjeYla.Reverse();*/
            List <Pisteet> la = new List <Pisteet>(); //Pääviiva
            List <Pisteet> o1 = new List <Pisteet>();
            List <Pisteet> o2 = new List <Pisteet>();
            List <Pisteet> o3 = new List <Pisteet>();
            List <Pisteet> o4 = new List <Pisteet>();

            //------------------Käytetään CategoryAxisin kanssa--------------------

            /*int j = 0;
             * for (int i = prosentit.Count - 1; i >= 0; i--)
             * {
             *  Pisteet l = new Pisteet();
             *  l.X = seulat[i].index;
             *  l.Y = prosentit[j].tulos;
             *  la.Add(l);
             *  j++;
             * }//--------------------------------------------------------------------*/
            //---------------Käytetään LogarithmAxisin kanssa---------------------
            for (int i = 0; i < prosentit.Count; i++)
            {
                Pisteet l = new Pisteet();
                l.X = seulat[i].seula;//seulat[i].seula kun käytetään LogarithmAxisia
                l.Y = prosentit[i].tulos;
                la.Add(l);
            }//--------------------------------------------------------------------*/
            foreach (Control c in _kivi.ohjeArvot.Children)
            {
                if (c.GetType() == typeof(TextBox))
                {
                    if (((TextBox)c).Tag.ToString() != null)
                    {
                        if (((TextBox)c).Tag.ToString() == "seulaValue")
                        {
                            if (((TextBox)c).Text != String.Empty)
                            {
                                string seulatxt = ((TextBox)c).Text;
                                seulatxt = seulatxt.Replace(".", ",");
                                string name = ((TextBox)c).Name;
                                int    ind  = Convert.ToInt32(Regex.Match(name, @"\d+$").Value);//otetaan objektin järjestysnumero nimestä,

                                foreach (SeulaLapPros sl in sisOhjeAla)
                                {
                                    if (ind == sl.index)
                                    {
                                        if (Double.TryParse(seulatxt, out double r) == true)
                                        {
                                            sl.seulaArvo = Convert.ToDouble(seulatxt);
                                        }
                                    }
                                }
                                foreach (SeulaLapPros sl in sisOhjeYla)
                                {
                                    if (ind == sl.index)
                                    {
                                        if (Double.TryParse(seulatxt, out double r) == true)
                                        {
                                            sl.seulaArvo = Convert.ToDouble(seulatxt);
                                        }
                                    }
                                }
                                foreach (SeulaLapPros sl in uloOhjeAla)
                                {
                                    if (ind == sl.index)
                                    {
                                        if (Double.TryParse(seulatxt, out double r) == true)
                                        {
                                            sl.seulaArvo = Convert.ToDouble(seulatxt);
                                        }
                                    }
                                }
                                foreach (SeulaLapPros sl in uloOhjeYla)
                                {
                                    if (ind == sl.index)
                                    {
                                        if (Double.TryParse(seulatxt, out double r) == true)
                                        {
                                            sl.seulaArvo = Convert.ToDouble(seulatxt);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            for (int i = sisOhjeAla.Count - 1; i >= 0; i--)
            {
                Pisteet l = new Pisteet();
                l.X = sisOhjeAla[i].seulaArvo;
                l.Y = sisOhjeAla[i].tulos;
                o1.Add(l);
            }
            for (int i = sisOhjeYla.Count - 1; i >= 0; i--)
            {
                Pisteet l = new Pisteet();
                l.X = sisOhjeYla[i].seulaArvo;
                l.Y = sisOhjeYla[i].tulos;
                o2.Add(l);
            }
            for (int i = uloOhjeAla.Count - 1; i >= 0; i--)
            {
                Pisteet l = new Pisteet();
                l.X = uloOhjeAla[i].seulaArvo;
                l.Y = uloOhjeAla[i].tulos;
                o3.Add(l);
            }
            for (int i = uloOhjeYla.Count - 1; i >= 0; i--)
            {
                Pisteet l = new Pisteet();
                l.X = uloOhjeYla[i].seulaArvo;
                l.Y = uloOhjeYla[i].tulos;
                o4.Add(l);
            }


            foreach (Pisteet e in la)
            {
                l1.Points.Add(new DataPoint(e.X, e.Y));
            }
            foreach (Pisteet e in o1)
            {
                ohje1.Points.Add(new DataPoint(e.X, e.Y));
            }
            foreach (Pisteet e in o2)
            {
                ohje2.Points.Add(new DataPoint(e.X, e.Y));
            }
            foreach (Pisteet e in o3)
            {
                ohje3.Points.Add(new DataPoint(e.X, e.Y));
            }
            foreach (Pisteet e in o4)
            {
                ohje4.Points.Add(new DataPoint(e.X, e.Y));
            }
            //----------------------Kovakoodatut arvot, testitapaus-----------------------------

            /*double[] ar = new double[] { 0.063, 0.125, 0.25, 0.5, 1, 2, 4, 6, 8, 12, 16, 18, 20, 25, 30, 64, 100, 200 };
             * double[] er = new double[] { 1.8, 3, 4.5, 5.6, 6.5, 8.3, 9.0, 9.9, 13.8, 15.6, 16.5, 17.4, 18.6, 20.4, 30.8, 31.4, 50.5, 62.7 };
             * List<Pisteet> la = new List<Pisteet>();
             * for (int i = 0; i < ar.Length; i++)//prosentit.Count
             * {
             *  Pisteet l = new Pisteet();
             *  l.X = ar[i];
             *  l.Y = er[i];
             *  la.Add(l);
             * }
             * foreach (Pisteet e in la)
             * {
             *  l1.Points.Add(new DataPoint(e.X, e.Y));
             * }*///-----------------------------------------------------------------------------------

            model.Axes.Add(yaxis);
            model.Axes.Add(xaxis);
            //model.Axes.Add(caxis);
            model.Series.Add(l1);
            model.Series.Add(ohje1);
            model.Series.Add(ohje2);
            model.Series.Add(ohje3);
            model.Series.Add(ohje4);
            KiviModel        = model;
            this.DataContext = this;
        }
Exemple #6
0
        public void PDFCreation(string fileName, Kiviohjelma kiviohjelma)
        {
            GetValueFromTextBoxes(kiviohjelma);



            PdfDocument document = new PdfDocument();

            document.Info.Title = "Seulonnantulos";

            PdfPage page = document.AddPage();

            XGraphics graphics = XGraphics.FromPdfPage(page);

            //Fonttien määritykset
            XFont font           = new XFont("Verdanna", 15, XFontStyle.Regular);
            XFont textFont       = new XFont("Verdanna", 10, XFontStyle.Regular);
            XFont otsikkoFont    = new XFont("Verdanna", 15, XFontStyle.Bold);
            XFont alaOtsikkoFont = new XFont("Verdanna", 7, XFontStyle.Regular);
            XFont osoiteFont     = new XFont("Verdanna", 7, XFontStyle.Regular);

            //Piirtää tarvittavat kuvat, otsikot ja niiden arvot PDF-tiedostoon

            string filePath;

            filePath = ((ComboBoxItem)kiviohjelma.Kuvat.SelectedItem).Tag.ToString(); //Asettaa comboboxista valitun kuvan tagin mukaan
            Console.WriteLine(filePath);

            graphics.DrawImage(XImage.FromFile(filePath), 10, 0, 120, 30);
            graphics.DrawString(alaOtsikkoHolder, alaOtsikkoFont, XBrushes.Black, new XRect(50, 26, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(osoiteHolder, osoiteFont, XBrushes.Black, new XRect(50, 33, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(postiHolder, osoiteFont, XBrushes.Black, new XRect(50, 40, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(puhHolder, osoiteFont, XBrushes.Black, new XRect(50, 48, page.Width, page.Height), XStringFormats.TopLeft);


            graphics.DrawString("KIVIAINESTUTKIMUS", otsikkoFont, XBrushes.Black, new XRect(280, 50, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(seulontaHolder, textFont, XBrushes.Black, new XRect(450, 55, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("SFS-EN 933-1", textFont, XBrushes.Black, new XRect(450, 40, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Työmaa", textFont, XBrushes.Black, new XRect(50, 80, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(tyomaaHolder, textFont, XBrushes.Black, new XRect(100, 80, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Lajite", textFont, XBrushes.Black, new XRect(50, 95, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(lajiteHolder, textFont, XBrushes.Black, new XRect(100, 95, page.Width, page.Height), XStringFormats.TopLeft);

            if (!String.IsNullOrEmpty(kiviohjelma.tbKosteuspros.Text))
            {
                graphics.DrawString("Kosteus %", textFont, XBrushes.Black, new XRect(50, 110, page.Width, page.Height), XStringFormats.TopLeft);
                graphics.DrawString(kiviohjelma.tbKosteuspros.Text.Trim(), textFont, XBrushes.Black, new XRect(110, 110, page.Width, page.Height), XStringFormats.TopLeft);
            }

            graphics.DrawString(lisatietoHolder, textFont, XBrushes.Black, new XRect(50, 120, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Näyte no", textFont, XBrushes.Black, new XRect(350, 80, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(nayteHolder, textFont, XBrushes.Black, new XRect(450, 80, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Päiväys", textFont, XBrushes.Black, new XRect(350, 95, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(dateHolder, textFont, XBrushes.Black, new XRect(450, 95, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Näytteen ottaja", textFont, XBrushes.Black, new XRect(350, 120, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(nayteOttajaHolder, textFont, XBrushes.Black, new XRect(450, 120, page.Width, page.Height), XStringFormats.TopLeft);

            //Piirtää seulojen arvot PDF-dokumenttiin
            graphics.DrawString("#mm", textFont, XBrushes.Black, new XRect(50, 150, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula1.Text, textFont, XBrushes.Black, new XRect(50, 160, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula2.Text, textFont, XBrushes.Black, new XRect(50, 175, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula3.Text, textFont, XBrushes.Black, new XRect(50, 190, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula4.Text, textFont, XBrushes.Black, new XRect(50, 205, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula5.Text, textFont, XBrushes.Black, new XRect(50, 220, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula6.Text, textFont, XBrushes.Black, new XRect(50, 235, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula7.Text, textFont, XBrushes.Black, new XRect(50, 250, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula8.Text, textFont, XBrushes.Black, new XRect(50, 265, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula9.Text, textFont, XBrushes.Black, new XRect(50, 280, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula10.Text, textFont, XBrushes.Black, new XRect(50, 295, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula11.Text, textFont, XBrushes.Black, new XRect(50, 310, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula12.Text, textFont, XBrushes.Black, new XRect(50, 325, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula13.Text, textFont, XBrushes.Black, new XRect(50, 340, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula14.Text, textFont, XBrushes.Black, new XRect(50, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula15.Text, textFont, XBrushes.Black, new XRect(50, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula16.Text, textFont, XBrushes.Black, new XRect(50, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula17.Text, textFont, XBrushes.Black, new XRect(50, 400, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.Seula18.Text, textFont, XBrushes.Black, new XRect(50, 415, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("Pohja", textFont, XBrushes.Black, new XRect(50, 430, page.Width, page.Height), XStringFormats.TopLeft);

            //Piirtää seuloille jäävien grammojen arvot PDF-dokumenttiin
            graphics.DrawString("Seulalle jäi g", textFont, XBrushes.Black, new XRect(150, 150, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG0.Text, textFont, XBrushes.Black, new XRect(150, 160, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG1.Text, textFont, XBrushes.Black, new XRect(150, 175, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG2.Text, textFont, XBrushes.Black, new XRect(150, 190, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG3.Text, textFont, XBrushes.Black, new XRect(150, 205, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG4.Text, textFont, XBrushes.Black, new XRect(150, 220, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG5.Text, textFont, XBrushes.Black, new XRect(150, 235, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG6.Text, textFont, XBrushes.Black, new XRect(150, 250, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG7.Text, textFont, XBrushes.Black, new XRect(150, 265, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG8.Text, textFont, XBrushes.Black, new XRect(150, 280, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG9.Text, textFont, XBrushes.Black, new XRect(150, 295, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG10.Text, textFont, XBrushes.Black, new XRect(150, 310, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG11.Text, textFont, XBrushes.Black, new XRect(150, 325, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG12.Text, textFont, XBrushes.Black, new XRect(150, 340, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG13.Text, textFont, XBrushes.Black, new XRect(150, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG14.Text, textFont, XBrushes.Black, new XRect(150, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG15.Text, textFont, XBrushes.Black, new XRect(150, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG16.Text, textFont, XBrushes.Black, new XRect(150, 400, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG17.Text, textFont, XBrushes.Black, new XRect(150, 415, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulaG18.Text, textFont, XBrushes.Black, new XRect(150, 430, page.Width, page.Height), XStringFormats.TopLeft);

            //Piirtää seuloilla jäävien prosenttien arvot PDF-dokumenttiin
            graphics.DrawString("Seulalle jäi %", textFont, XBrushes.Black, new XRect(250, 150, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros1.Text, textFont, XBrushes.Black, new XRect(250, 160, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros2.Text, textFont, XBrushes.Black, new XRect(250, 175, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros3.Text, textFont, XBrushes.Black, new XRect(250, 190, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros4.Text, textFont, XBrushes.Black, new XRect(250, 205, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros5.Text, textFont, XBrushes.Black, new XRect(250, 220, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros6.Text, textFont, XBrushes.Black, new XRect(250, 235, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros7.Text, textFont, XBrushes.Black, new XRect(250, 250, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros8.Text, textFont, XBrushes.Black, new XRect(250, 265, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros9.Text, textFont, XBrushes.Black, new XRect(250, 280, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros10.Text, textFont, XBrushes.Black, new XRect(250, 295, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros11.Text, textFont, XBrushes.Black, new XRect(250, 310, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros12.Text, textFont, XBrushes.Black, new XRect(250, 325, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros13.Text, textFont, XBrushes.Black, new XRect(250, 340, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros14.Text, textFont, XBrushes.Black, new XRect(250, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros15.Text, textFont, XBrushes.Black, new XRect(250, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros16.Text, textFont, XBrushes.Black, new XRect(250, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros17.Text, textFont, XBrushes.Black, new XRect(250, 400, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros18.Text, textFont, XBrushes.Black, new XRect(250, 415, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.seulapros19.Text, textFont, XBrushes.Black, new XRect(250, 430, page.Width, page.Height), XStringFormats.TopLeft);

            //Piirtää läpäisy % arvot PDF-dokumenttiin
            graphics.DrawString("Läpäisy %", textFont, XBrushes.Black, new XRect(350, 150, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros1.Text, textFont, XBrushes.Black, new XRect(350, 160, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros2.Text, textFont, XBrushes.Black, new XRect(350, 175, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros3.Text, textFont, XBrushes.Black, new XRect(350, 190, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros4.Text, textFont, XBrushes.Black, new XRect(350, 205, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros5.Text, textFont, XBrushes.Black, new XRect(350, 220, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros6.Text, textFont, XBrushes.Black, new XRect(350, 235, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros7.Text, textFont, XBrushes.Black, new XRect(350, 250, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros8.Text, textFont, XBrushes.Black, new XRect(350, 265, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros9.Text, textFont, XBrushes.Black, new XRect(350, 280, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros10.Text, textFont, XBrushes.Black, new XRect(350, 295, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros11.Text, textFont, XBrushes.Black, new XRect(350, 310, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros12.Text, textFont, XBrushes.Black, new XRect(350, 325, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros13.Text, textFont, XBrushes.Black, new XRect(350, 340, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros14.Text, textFont, XBrushes.Black, new XRect(350, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros15.Text, textFont, XBrushes.Black, new XRect(350, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros16.Text, textFont, XBrushes.Black, new XRect(350, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros17.Text, textFont, XBrushes.Black, new XRect(350, 400, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviohjelma.lapaisypros18.Text, textFont, XBrushes.Black, new XRect(350, 415, page.Width, page.Height), XStringFormats.TopLeft);

            KayraImage   ki          = new KayraImage();
            MemoryStream kayrastream = ki.KayraKuva(kiviohjelma);
            XImage       kayrakuva   = XImage.FromStream(kayrastream);

            graphics.DrawImage(kayrakuva, 40, 450, 500, 300); //Piirtää käyrän kuvan PDF-dokumenttiin)
            //graphics.DrawImage(XImage.FromFile(@".\Asetukset\kuvat\kayrakuva.png"), 40, 450, 500, 300); //Piirtää käyrän kuvan PDF-dokumenttiin

            graphics.DrawString("Pvm _____._____._______", textFont, XBrushes.Black, new XRect(50, 755, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("Tutkija______________________________", textFont, XBrushes.Black, new XRect(250, 755, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(tutkijaHolder, textFont, XBrushes.Black, new XRect(320, 765, page.Width, page.Height), XStringFormats.TopLeft);


            graphics.DrawImage(XImage.FromFile(@".\Asetukset\kuvat\leima1.png"), 20, 800, 500, 49); //Piirtää leiman tiedoston alapäähän

            try
            {
                try // Avaa PDF-dokumentin tallennuksen jälkeen
                {
                    document.Save(fileName);

                    Process.Start(fileName);
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show(ex.Message, "Virhe"); //Jos tiedoston nimi on tyhjä heitetään siitä ilmoitus käyttäjälle
                }
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message, "Virhe");
            }
        }
Exemple #7
0
        public string Save(Window w, List <Seulakirjasto> seulist)
        {
            seulalista = seulist;
            string json = null;

            //--------------------------Tarkoituksena ottaa ikkunasta tiedot talteen ja muuttaa ne JSON-stringiksi ja palauttaa se------------------------------------
            if (w.Name == "kiviohjelma")                                           //Jos ikkuna mistä funktiota kutsuttiin on Kiviohjelma, mennään tästä sisälle
            {
                Kiviohjelma           kiv           = (Kiviohjelma)w;              //Otetaan kiviohjelma tähän. Tämän avulla otetaan tallennettavat tiedot
                List <SyotetytArvot>  syotteet      = new List <SyotetytArvot>();  //Kaikki käyttäjän syöttämät tiedot kentistä "Seulalle Jäi (g)"
                List <SeulaTallennus> seulacombot   = new List <SeulaTallennus>(); //Seulacomboboksin arvot laitetaan tänne (mikä seula valittu, mones seula listasta se on ja mikä on comboboksin sijainti)
                bool                pesuseulValinta = false;
                JakoAsetukset       jako            = new JakoAsetukset();         //Laitetaan jaetun näytteen asetukset tänne talteen
                List <TekstiTiedot> tekstitiedot    = new List <TekstiTiedot>();   //Tähän laitetaan talteen muut tiedot ohjelman yläosasta (nimi, työmaa, lajite jne...)
                List <SeulaLapPros> sisOhjeAla      = new List <SeulaLapPros>();   //Sisempi ohjealue, alempi ohje%
                List <SeulaLapPros> sisOhjeYla      = new List <SeulaLapPros>();   //Sisempi ohjealue, ylempi ohje%
                List <SeulaLapPros> uloOhjeAla      = new List <SeulaLapPros>();   //Ulompi ohjealue, alempi ohje%
                List <SeulaLapPros> uloOhjeYla      = new List <SeulaLapPros>();   //Ulompi ohjealue, ylempi ohje%


                //Otetaan talteen käyttäjän syöttämät tiedot kentistä "Seulalle Jäi (g)"
                foreach (Control c in kiv.seulaArvot.Children)         //Katsoo läpi kaikki objektit seulaArvot-canvasista
                {
                    if (c.GetType() == typeof(TextBox))                //jos objektin tyyppi on TextBox
                    {
                        if (((TextBox)c).Tag.ToString() != null)       //tarkistetaan ettei tag ole null. vaatii että kaikilla textbokseilla on jokin tagi
                        {
                            if (((TextBox)c).Tag.ToString() == "arvo") //tarkistaa onko tagi "arvo"
                            {
                                if (((TextBox)c).Text != String.Empty)
                                {
                                    SyotetytArvot s     = new SyotetytArvot();
                                    double        g     = Convert.ToDouble(((TextBox)c).Text);
                                    string        n     = ((TextBox)c).Name;                              //otetaan objektin nimi talteen
                                    int           index = Convert.ToInt32(Regex.Match(n, @"\d+$").Value); //otetaan objektin järjestysnumero nimestä
                                    s.syote = g;
                                    s.index = index;
                                    syotteet.Add(s);
                                }
                            }
                        }
                    }
                }

                //Otetaan talteen käyttäjän valitsemat seulat "Seula"-combobokseista
                foreach (Control c in kiv.seulaArvot.Children)
                {
                    if (c.GetType() == typeof(ComboBox))
                    {
                        if (((ComboBox)c).Tag.ToString() != null)
                        {
                            if (((ComboBox)c).Tag.ToString() == "seula")
                            {
                                if (((ComboBox)c).Text != String.Empty)
                                {
                                    SeulaTallennus s  = new SeulaTallennus();
                                    double         se = Convert.ToDouble(((ComboBox)c).Text);
                                    string         n  = ((ComboBox)c).Name;                             //otetaan objektin nimi talteen
                                    int            si = Convert.ToInt32(Regex.Match(n, @"\d+$").Value); //otetaan objektin järjestysnumero nimestä
                                    s.seularvo       = se;                                              //Tallennetaan mikä seula on valittuna
                                    s.sijainti       = si;                                              //tallennetaan valitun comboboksin sijainti/järjestysluku
                                    s.seulansijainti = ((ComboBox)c).SelectedIndex;                     //Tallennetaan mones seula valittu seula on seulalistasta
                                    seulacombot.Add(s);
                                }
                            }
                        }
                    }
                }

                //Onko valittuna kuiva- vai pesuseulonta
                if (kiv.rbPesuseulonta.IsChecked == true)
                {
                    pesuseulValinta = true;
                }
                else
                {
                    pesuseulValinta = false;
                }

                double?jakokerroin  = null;
                int    jakoseula    = kiv.JakoSeula.SelectedIndex;
                string jakoseularvo = kiv.JakoSeula.Text;
                if (kiv.tbJakoKerroin.Text != String.Empty && Double.TryParse(kiv.tbJakoKerroin.Text, out double r) == true)
                {
                    jakokerroin = Convert.ToDouble(kiv.tbJakoKerroin.Text);
                }
                jako.jakokerroin  = jakokerroin;
                jako.jakoseula    = jakoseula;
                jako.jakoseularvo = jakoseularvo;

                //Otetaan talteen tekstitiedot ohjelman yläosasta
                foreach (Control c in kiv.tietoarvot.Children)
                {
                    if (c.GetType() == typeof(TextBox))
                    {
                        TekstiTiedot t = new TekstiTiedot();
                        t.otsikko = ((TextBox)c).Name;
                        if (((TextBox)c).Text != String.Empty)
                        {
                            t.tieto = ((TextBox)c).Text;
                        }
                        else
                        {
                            t.tieto = null;
                        }
                        tekstitiedot.Add(t);
                    }
                }
                foreach (Control c in kiv.osoitearvot.Children)
                {
                    if (c.GetType() == typeof(TextBox))
                    {
                        TekstiTiedot t = new TekstiTiedot();
                        t.otsikko = ((TextBox)c).Name;
                        if (((TextBox)c).Text != String.Empty)
                        {
                            t.tieto = ((TextBox)c).Text;
                        }
                        else
                        {
                            t.tieto = null;
                        }
                        tekstitiedot.Add(t);
                    }
                }

                //Otetaan talteen ohjealueet
                for (int i = 0; i < 4; i++)//Otetaan ohjealueet talteen yksi kolumni kerrallaan
                {
                    switch (i)
                    {
                    case 0:
                        int j = 17;
                        foreach (Control c in kiv.ohjeArvot.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "sisAla")
                                    {
                                        if (((TextBox)c).Text != String.Empty)
                                        {
                                            string seulatxt = ((TextBox)c).Text;
                                            seulatxt = seulatxt.Replace(".", ",");
                                            SeulaLapPros ohj = new SeulaLapPros
                                            {
                                                index = j,
                                                tulos = Convert.ToDouble(seulatxt)
                                            };
                                            sisOhjeAla.Add(ohj);
                                        }
                                        j--;
                                    }
                                }
                            }
                        }
                        break;

                    case 1:
                        int k = 17;
                        foreach (Control c in kiv.ohjeArvot.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "sisYla")
                                    {
                                        if (((TextBox)c).Text != String.Empty)
                                        {
                                            string seulatxt = ((TextBox)c).Text;
                                            seulatxt = seulatxt.Replace(".", ",");
                                            SeulaLapPros ohj = new SeulaLapPros
                                            {
                                                index = k,
                                                tulos = Convert.ToDouble(seulatxt)
                                            };
                                            sisOhjeYla.Add(ohj);
                                        }
                                        k--;
                                    }
                                }
                            }
                        }
                        break;

                    case 2:
                        int l = 17;
                        foreach (Control c in kiv.ohjeArvot.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "uloAla")
                                    {
                                        if (((TextBox)c).Text != String.Empty)
                                        {
                                            string seulatxt = ((TextBox)c).Text;
                                            seulatxt = seulatxt.Replace(".", ",");
                                            SeulaLapPros ohj = new SeulaLapPros
                                            {
                                                index = l,
                                                tulos = Convert.ToDouble(seulatxt)
                                            };
                                            uloOhjeAla.Add(ohj);
                                        }
                                        l--;
                                    }
                                }
                            }
                        }
                        break;

                    case 3:
                        int m = 17;
                        foreach (Control c in kiv.ohjeArvot.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "uloYla")
                                    {
                                        if (((TextBox)c).Text != String.Empty)
                                        {
                                            string seulatxt = ((TextBox)c).Text;
                                            seulatxt = seulatxt.Replace(".", ",");
                                            SeulaLapPros ohj = new SeulaLapPros
                                            {
                                                index = m,
                                                tulos = Convert.ToDouble(seulatxt)
                                            };
                                            uloOhjeYla.Add(ohj);
                                        }
                                        m--;
                                    }
                                }
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
                var kaikkilistat = new { nimi = "Actual", data = new List <object>() };
                //HUOMIOI TÄMÄ! tässä näkyy se järjestys mistä nämä listat löytyy tiedostosta
                kaikkilistat.data.Add(seulalista);
                kaikkilistat.data.Add(syotteet);
                kaikkilistat.data.Add(seulacombot);
                kaikkilistat.data.Add(pesuseulValinta);
                kaikkilistat.data.Add(tekstitiedot);
                kaikkilistat.data.Add(sisOhjeAla);
                kaikkilistat.data.Add(sisOhjeYla);
                kaikkilistat.data.Add(uloOhjeAla);
                kaikkilistat.data.Add(uloOhjeYla);

                json = JsonConvert.SerializeObject(kaikkilistat);
            }
            return(json);
        }
Exemple #8
0
        public MemoryStream KayraKuva(Window win)
        {
            if (win.Name == "kiviohjelma")
            {
                Kiviohjelma _kivi = (Kiviohjelma)win;
                List <SeulakirjastoIndex> selist     = new List <SeulakirjastoIndex>(); //Seulat joita on käytetty laskennassa, eli X-arvot.
                List <SeulaLapPros>       tulist     = new List <SeulaLapPros>();       //Läpäisyprosenttitulokset, eli Y-arvot
                List <Seulakirjasto>      selistALL  = new List <Seulakirjasto>();      //Kaikki seulat mitä on valittuna. Tehdään täysi X-akseli tällä.
                List <SeulaLapPros>       sisOhjeAla = new List <SeulaLapPros>();       //Sisempi ohjealue, alempi ohje%
                List <SeulaLapPros>       sisOhjeYla = new List <SeulaLapPros>();       //Sisempi ohjealue, ylempi ohje%
                List <SeulaLapPros>       uloOhjeAla = new List <SeulaLapPros>();       //Ulompi ohjealue, alempi ohje%
                List <SeulaLapPros>       uloOhjeYla = new List <SeulaLapPros>();       //Ulompi ohjealue, ylempi ohje%


                //Lukee tarvittavat prosenttiarvot ja lisää ne tulist-listaan
                //Ottaa valitut seulat ohjelmasta, ottaa talteen niiden sijainnin järjestyslukuna ja laittaa ne selist-listaan
                //Tuloksissa saattaa olla välejä (kaikkeja rivejä ei täytetty) joten koodi tarkistaa sen myös

                if (_kivi.lapaisypros1.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 0,
                        tulos = Convert.ToDouble(_kivi.lapaisypros1.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula1.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 17,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros2.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 1,
                        tulos = Convert.ToDouble(_kivi.lapaisypros2.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula2.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 16,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros3.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 2,
                        tulos = Convert.ToDouble(_kivi.lapaisypros3.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula3.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 15,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros4.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 3,
                        tulos = Convert.ToDouble(_kivi.lapaisypros4.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula4.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 14,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros5.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 4,
                        tulos = Convert.ToDouble(_kivi.lapaisypros5.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula5.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 13,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros6.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 5,
                        tulos = Convert.ToDouble(_kivi.lapaisypros6.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula6.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 12,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros7.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 6,
                        tulos = Convert.ToDouble(_kivi.lapaisypros7.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula7.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 11,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros8.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 7,
                        tulos = Convert.ToDouble(_kivi.lapaisypros8.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula8.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 10,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros9.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 8,
                        tulos = Convert.ToDouble(_kivi.lapaisypros9.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula9.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 9,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros10.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 9,
                        tulos = Convert.ToDouble(_kivi.lapaisypros10.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula10.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 8,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros11.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 10,
                        tulos = Convert.ToDouble(_kivi.lapaisypros11.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula11.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 7,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros12.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 11,
                        tulos = Convert.ToDouble(_kivi.lapaisypros12.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula12.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 6,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros13.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 12,
                        tulos = Convert.ToDouble(_kivi.lapaisypros13.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula13.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 5,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros14.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 13,
                        tulos = Convert.ToDouble(_kivi.lapaisypros14.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula14.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 4,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros15.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 14,
                        tulos = Convert.ToDouble(_kivi.lapaisypros15.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula15.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 3,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros16.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 15,
                        tulos = Convert.ToDouble(_kivi.lapaisypros16.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula16.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 2,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros17.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 16,
                        tulos = Convert.ToDouble(_kivi.lapaisypros17.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula17.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 1,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }
                if (_kivi.lapaisypros18.Text != String.Empty)
                {
                    SeulaLapPros sl = new SeulaLapPros
                    {
                        index = 17,
                        tulos = Convert.ToDouble(_kivi.lapaisypros18.Text)
                    };
                    tulist.Add(sl);
                    string seulatxt = _kivi.Seula18.Text;
                    seulatxt = seulatxt.Replace(".", ",");
                    SeulakirjastoIndex ke = new SeulakirjastoIndex
                    {
                        index = 0,
                        seula = Convert.ToDouble(seulatxt)
                    };
                    selist.Add(ke);
                }

                foreach (Control c in _kivi.seulaArvot.Children) //Kaikille esineille seulaArvot-canvasissa. Tarkoituksena ottaa kaikki valitut seulat dropdown-valikoista talteen
                {
                    if (c.GetType() == typeof(ComboBox))         //jos esineen tyyppi on combobox
                    {
                        //Console.WriteLine("Combobox text: " + ((ComboBox)c).Text+",  tag: "+ ((ComboBox)c).Tag);
                        if (((ComboBox)c).Tag.ToString() != null)        //Jos comboboxin tagi on tyhjä
                        {
                            if (((ComboBox)c).Tag.ToString() == "seula") //jos comboboxin tagi on "seula", eli kaikki seuladropdown-valikot
                            {
                                //Console.WriteLine(((ComboBox)c).Text);
                                string seulatxt = ((ComboBox)c).Text;
                                seulatxt = seulatxt.Replace(".", ",");
                                Seulakirjasto ke = new Seulakirjasto
                                {
                                    seula = Convert.ToDouble(seulatxt)
                                };
                                selistALL.Add(ke);
                            }
                        }
                    }
                }

                for (int i = 0; i < 4; i++)//Otetaan ohjealueet talteen yksi kolumni kerrallaan
                {
                    switch (i)
                    {
                    case 0:
                        int o = 17;
                        foreach (Control c in _kivi.ohjeArvot.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "sisAla")
                                    {
                                        if (((TextBox)c).Text != String.Empty)
                                        {
                                            string seulatxt = ((TextBox)c).Text;
                                            seulatxt = seulatxt.Replace(".", ",");
                                            SeulaLapPros ohj = new SeulaLapPros
                                            {
                                                index = o,
                                                tulos = Convert.ToDouble(seulatxt)
                                            };
                                            sisOhjeAla.Add(ohj);
                                        }
                                        o--;
                                    }
                                }
                            }
                        }
                        break;

                    case 1:
                        int k = 17;
                        foreach (Control c in _kivi.ohjeArvot.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "sisYla")
                                    {
                                        if (((TextBox)c).Text != String.Empty)
                                        {
                                            string seulatxt = ((TextBox)c).Text;
                                            seulatxt = seulatxt.Replace(".", ",");
                                            SeulaLapPros ohj = new SeulaLapPros
                                            {
                                                index = k,
                                                tulos = Convert.ToDouble(seulatxt)
                                            };
                                            sisOhjeYla.Add(ohj);
                                        }
                                        k--;
                                    }
                                }
                            }
                        }
                        break;

                    case 2:
                        int l = 17;
                        foreach (Control c in _kivi.ohjeArvot.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "uloAla")
                                    {
                                        if (((TextBox)c).Text != String.Empty)
                                        {
                                            string seulatxt = ((TextBox)c).Text;
                                            seulatxt = seulatxt.Replace(".", ",");
                                            SeulaLapPros ohj = new SeulaLapPros
                                            {
                                                index = l,
                                                tulos = Convert.ToDouble(seulatxt)
                                            };
                                            uloOhjeAla.Add(ohj);
                                        }
                                        l--;
                                    }
                                }
                            }
                        }
                        break;

                    case 3:
                        int m = 17;
                        foreach (Control c in _kivi.ohjeArvot.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "uloYla")
                                    {
                                        if (((TextBox)c).Text != String.Empty)
                                        {
                                            string seulatxt = ((TextBox)c).Text;
                                            seulatxt = seulatxt.Replace(".", ",");
                                            SeulaLapPros ohj = new SeulaLapPros
                                            {
                                                index = m,
                                                tulos = Convert.ToDouble(seulatxt)
                                            };
                                            uloOhjeYla.Add(ohj);
                                        }
                                        m--;
                                    }
                                }
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
                //----------------------------------------------------------------------
                //Luodaan listoista käyrä ja otetaan kuva
                //----------------------------------------------------------------------
                PlotModel plotModel = new PlotModel();
                plotModel.PlotType        = PlotType.XY;
                plotModel.IsLegendVisible = false;
                plotModel.PlotMargins     = new OxyThickness(15, 15, 15, 15);
                //asetetaan legendan asetukset
                //plotModel.LegendPosition = LegendPosition.TopRight;
                //plotModel.LegendOrientation = LegendOrientation.Horizontal;
                //plotModel.LegendPlacement = LegendPlacement.Outside;
                //Tehdään kokoelma, jossa on kaikki käytössä olevat seulat. Nämä sidotaan X-akseliin

                /*Collection<Item> items = new Collection<Item>();
                 * for (int i = selistALL.Count - 1; i >= 0; i--)
                 * {
                 *  items.Add(new Item(selistALL[i].seula.ToString(), selistALL[i].seula));
                 * }*/
                //Luodaan Y-akseli
                LinearAxis yaxis = new LinearAxis //Y-akseli
                {
                    Maximum = 100,
                    Minimum = 0,
                    //Title = "Prosentti",
                    TickStyle          = TickStyle.Inside,
                    MinorStep          = 5,
                    MinorGridlineStyle = LineStyle.Dot,
                    Position           = AxisPosition.Left,
                    //AbsoluteMaximum = 100,
                    //AbsoluteMinimum = 0,
                    MajorStep = 10,
                    //MinorStep = 5,
                    MajorGridlineStyle = LineStyle.Dash,
                    //MinorGridlineStyle = LineStyle.Dash,
                    IsZoomEnabled = false,
                    IsPanEnabled  = false
                };
                //------------------------------Logaritmiakseli-------------------------
                LogarithmicAxis xaxis = new LogarithmicAxis(); //X-akseli

                /* double yhteensa = 0;
                 * foreach (Seulakirjasto value in selistALL)
                 * {
                 *   yhteensa += value.seula;
                 * }*/
                //double keskimaara = yhteensa / kaikkiseulat.Count;
                //double logbase = 1.0 / Math.Log(Math.E, keskimaara);
                if (selist == null || tulist == null || selist.Count == 0 || tulist.Count == 0)
                {
                    //xaxis.Title = "Seula";
                    xaxis.TickStyle          = TickStyle.Inside;
                    xaxis.Position           = AxisPosition.Bottom;
                    xaxis.MajorGridlineStyle = LineStyle.Solid;
                    //xaxis.Base = logbase;
                    //xaxis.MajorStep = 2;
                    //xaxis.MinorGridlineStyle = LineStyle.Dash;
                    //xaxis.Maximum = seulat[0].seula;
                    //xaxis.Minimum = seulat[(seulat.Count - 1)].seula;
                    xaxis.IsZoomEnabled = false;
                    xaxis.IsPanEnabled  = false;
                }
                else
                {
                    //xaxis.Title = "Seula";
                    xaxis.TickStyle          = TickStyle.Inside;
                    xaxis.Position           = AxisPosition.Bottom;
                    xaxis.MajorGridlineStyle = LineStyle.Solid;
                    //xaxis.Base = logbase;
                    //xaxis.MajorStep =
                    //xaxis.MinorGridlineStyle = LineStyle.Dash;
                    xaxis.Maximum       = selistALL[0].seula;
                    xaxis.Minimum       = selistALL[(selistALL.Count - 1)].seula;
                    xaxis.IsZoomEnabled = false;
                    xaxis.IsPanEnabled  = false;
                }
                //-------------------------------------------------------------------
                //Luodaan X-akseli

                /*CategoryAxis caxis = new CategoryAxis();//X-akseli
                 *
                 * if (selist == null || tulist == null || selist.Count == 0 || tulist.Count == 0) //Jos jokin lista on tyhjä, luodaan tyhjä perusakseli
                 * {
                 *  caxis.Title = "Seula";
                 *  caxis.TickStyle = TickStyle.Inside;
                 *  caxis.Position = AxisPosition.Bottom;
                 *  caxis.IsTickCentered = true;
                 *  caxis.MajorGridlineStyle = LineStyle.Solid;
                 *  caxis.MajorGridlineColor = OxyColors.DarkSlateGray;
                 *  caxis.MajorTickSize = 7;
                 *  //caxis.Maximum = seulat[0].seula;
                 *  //caxis.Minimum = seulat[(seulat.Count - 1)].seula;
                 *  caxis.IsZoomEnabled = false;
                 *  caxis.IsPanEnabled = false;
                 *  caxis.MinorStep = 0.5;
                 *  caxis.MajorStep = 1;
                 *  caxis.ItemsSource = items;
                 *  caxis.LabelField = "Label";
                 * }
                 * else
                 * {
                 *  caxis.Title = "Seula";
                 *  caxis.TickStyle = TickStyle.Inside;
                 *  caxis.Position = AxisPosition.Bottom;
                 *  caxis.IsTickCentered = true;
                 *  caxis.MajorGridlineStyle = LineStyle.Solid;
                 *  caxis.MajorGridlineColor = OxyColors.DarkSlateGray;
                 *  caxis.MajorTickSize = 7;
                 *  //caxis.Maximum = seulat[0].seula;
                 *  //caxis.Minimum = seulat[(seulat.Count-1)].seula;
                 *  caxis.IsZoomEnabled = false;
                 *  caxis.IsPanEnabled = false;
                 *  caxis.MinorStep = 0.5;
                 *  caxis.MajorStep = 1;
                 *  caxis.ItemsSource = items;
                 *  caxis.LabelField = "Label";
                 * }
                 * for (int i = selistALL.Count - 1; i >= 0; i--) //Laittaa Y-akselille otsikot, eli seulat jotka on käytössä tällä hetkellä
                 * {
                 *  caxis.ActualLabels.Add(selistALL[i].seula.ToString());
                 * }*/

                LineSeries l1 = new LineSeries //Tuloskäyrä/viiva
                {
                    Title      = "Rakeisuuskäyrä",
                    MarkerType = MarkerType.Circle,
                    CanTrackerInterpolatePoints = false,
                    MarkerSize = 3
                                 //LabelFormatString = "Läp%: {1:0.0} %"
                };
                //Luodaan itse viivat
                LineSeries ohje1 = new LineSeries
                {
                    MarkerType = MarkerType.None,
                    CanTrackerInterpolatePoints = false,
                    MarkerSize = 1,
                    Color      = OxyColors.CadetBlue
                };
                LineSeries ohje2 = new LineSeries
                {
                    MarkerType = MarkerType.None,
                    CanTrackerInterpolatePoints = false,
                    MarkerSize = 0,
                    Color      = OxyColors.CadetBlue
                };
                LineSeries ohje3 = new LineSeries
                {
                    MarkerType = MarkerType.None,
                    CanTrackerInterpolatePoints = false,
                    MarkerSize = 0,
                    Color      = OxyColors.Indigo
                };
                LineSeries ohje4 = new LineSeries
                {
                    MarkerType = MarkerType.None,
                    CanTrackerInterpolatePoints = false,
                    MarkerSize = 0,
                    Color      = OxyColors.Indigo
                };
                //selist.Reverse();
                //Luodaan listat joihin tulee viivojen pisteet
                List <Pisteet> la = new List <Pisteet>(); //Pääviiva
                List <Pisteet> o1 = new List <Pisteet>();
                List <Pisteet> o2 = new List <Pisteet>();
                List <Pisteet> o3 = new List <Pisteet>();
                List <Pisteet> o4 = new List <Pisteet>();
                //------------------Käytetään CategoryAxisin kanssa--------------------

                /*int j = 0;
                 * for (int i = tulist.Count - 1; i >= 0; i--)
                 * {
                 *  //Syötetään yhden pisteen koordinaatit listaan esineeksi
                 *  Pisteet l = new Pisteet();
                 *  l.X = selist[i].index;
                 *  l.Y = tulist[j].tulos;
                 *  la.Add(l);
                 *  j++;
                 * }//--------------------------------------------------------------------*/
                //---------------Käytetään LogarithmAxisin kanssa---------------------
                for (int i = 0; i < tulist.Count; i++)
                {
                    Pisteet l = new Pisteet();
                    l.X = selist[i].seula;//seulat[i].seula kun käytetään LogarithmAxisia
                    l.Y = tulist[i].tulos;
                    la.Add(l);
                }//--------------------------------------------------------------------*/

                for (int i = sisOhjeAla.Count - 1; i >= 0; i--)
                {
                    Pisteet l = new Pisteet();
                    l.X = sisOhjeAla[i].index;
                    l.Y = sisOhjeAla[i].tulos;
                    o1.Add(l);
                }
                for (int i = sisOhjeYla.Count - 1; i >= 0; i--)
                {
                    Pisteet l = new Pisteet();
                    l.X = sisOhjeYla[i].index;
                    l.Y = sisOhjeYla[i].tulos;
                    o2.Add(l);
                }
                for (int i = uloOhjeAla.Count - 1; i >= 0; i--)
                {
                    Pisteet l = new Pisteet();
                    l.X = uloOhjeAla[i].index;
                    l.Y = uloOhjeAla[i].tulos;
                    o3.Add(l);
                }
                for (int i = uloOhjeYla.Count - 1; i >= 0; i--)
                {
                    Pisteet l = new Pisteet();
                    l.X = uloOhjeYla[i].index;
                    l.Y = uloOhjeYla[i].tulos;
                    o4.Add(l);
                }

                //Laitetaan luodut pistelistat viivoihinsa
                foreach (Pisteet e in la)
                {
                    l1.Points.Add(new DataPoint(e.X, e.Y));
                }
                foreach (Pisteet e in o1)
                {
                    ohje1.Points.Add(new DataPoint(e.X, e.Y));
                }
                foreach (Pisteet e in o2)
                {
                    ohje2.Points.Add(new DataPoint(e.X, e.Y));
                }
                foreach (Pisteet e in o3)
                {
                    ohje3.Points.Add(new DataPoint(e.X, e.Y));
                }
                foreach (Pisteet e in o4)
                {
                    ohje4.Points.Add(new DataPoint(e.X, e.Y));
                }
                //----------------------Kovakoodatut arvot, testitapaus-----------------------------

                /*double[] ar = new double[] { 0.063, 0.125, 0.25, 0.5, 1, 2, 4, 6, 8, 12, 16, 18, 20, 25, 30, 64, 100, 200 };
                 * double[] er = new double[] { 1.8, 3, 4.5, 5.6, 6.5, 8.3, 9.0, 9.9, 13.8, 15.6, 16.5, 17.4, 18.6, 20.4, 30.8, 31.4, 50.5, 62.7 };
                 * List<Pisteet> la = new List<Pisteet>();
                 * for (int i = 0; i < ar.Length; i++)//prosentit.Count
                 * {
                 *  Pisteet l = new Pisteet();
                 *  l.X = ar[i];
                 *  l.Y = er[i];
                 *  la.Add(l);
                 * }
                 * foreach (Pisteet e in la)
                 * {
                 *  l1.Points.Add(new DataPoint(e.X, e.Y));
                 * }*///-----------------------------------------------------------------------------------
                //Syötetään kaikki luodut viivat ja akselit kaavioon
                plotModel.Axes.Add(yaxis);
                plotModel.Axes.Add(xaxis);
                //plotModel.Axes.Add(caxis);
                plotModel.Series.Add(l1);
                plotModel.Series.Add(ohje1);
                plotModel.Series.Add(ohje2);
                plotModel.Series.Add(ohje3);
                plotModel.Series.Add(ohje4);


                //Palautetaan kuva viivakaaviosta
                var kuvastream  = new MemoryStream();
                var pngExporter = new OxyPlot.Wpf.PngExporter {
                    Width = 750, Height = 500, Background = OxyColors.White
                };
                pngExporter.Export(plotModel, kuvastream);
                return(kuvastream);
            }
            else
            {
                return(null);
            }
        }