Ejemplo n.º 1
0
        public void SavePDF(Massaohjelma massaOhjelma)
        {
            Massaohjelma _massa = massaOhjelma;

            //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, _massa);
        }
Ejemplo n.º 2
0
        public void GetValuesFromTextBoxes(Massaohjelma massaOhjelma)
        {
            Massaohjelma _massa = massaOhjelma;

            urakkaHolder     = _massa.urakka.Text.Trim();
            sekAsemaHolder   = _massa.sekoitusAsema.Text.Trim();
            lisatietoHolder  = _massa.lisatietoja.Text.Trim();
            nayteHolder      = _massa.naytteenOttaja.Text.Trim();
            tyoKohdeHolder   = _massa.tyokohde.Text.Trim();
            alaOtsikkoHolder = _massa.alempiOtsikko.Text.Trim();
            lahiOsoiteHolder = _massa.lahiOsoite.Text.Trim();
            osoiteHolder     = _massa.osoite.Text.Trim();
            puhHolder        = _massa.puh.Text.Trim();

            paallysteHolder = _massa.paallyste.Text.Trim();
            nayteNroHolder  = _massa.nayteNro.Text.Trim();
            paivaysHolder   = _massa.paivays.Text.Trim();
            kloHolder       = _massa.klo.Text.Trim();
            paaluHolder     = _massa.paaluKaista.Text.Trim();

            naytePainoHolder = _massa.naytteenPaino.Text.Trim();
            //kiviAineHolder = _massa.kiviaineksenYhteispaino.Text.Trim();
            sideAineMHolder = _massa.sideainemaara.Text.Trim();
            sideainePHolder = _massa.sideainepitoisuus.Text.Trim();

            sideAinePitHolder = _massa.sideainepitoisuusOhjeArvo.Text.Trim();
            tayteJauheHolder  = _massa.tayteJauheenMaara.Text.Trim();
            rak12Holder       = _massa.rakeisuus12mm.Text.Trim();
            rak8Holder        = _massa.rakeisuus8mm.Text.Trim();
            rak4Holder        = _massa.rakeisuus4mm.Text.Trim();
            rak2Holder        = _massa.rakeisuus2mm.Text.Trim();
            rak05Holder       = _massa.rakeisuus05mm.Text.Trim();
            rak0063Holder     = _massa.rakeisuus0065mm.Text.Trim();
        }
Ejemplo n.º 3
0
 private void OpenMassa(object sender, RoutedEventArgs e) //Avaa massaohjelman
 {
     if (_massa == null)
     {
         _massa = new Massaohjelma(this);
         _massa.Show();
     }
     else
     {
         _massa.Activate();
     }
 }
Ejemplo n.º 4
0
        public void PDFCreation(string fileName, Massaohjelma massaOhjelma)
        {
            GetValuesFromTextBoxes(massaOhjelma);

            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 otsikot ja niiden arvot PDF-tiedostoon

            string filePath;
            filePath = ((ComboBoxItem)massaOhjelma.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, 27, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(lahiOsoiteHolder, osoiteFont, XBrushes.Black, new XRect(50, 33, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(osoiteHolder, 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("PANK 4102", textFont, XBrushes.Black, new XRect(150, 30, page.Width, page.Height), XStringFormats.TopCenter);
            graphics.DrawString("P Ä Ä L L Y S T E T U T K I M U S", otsikkoFont, XBrushes.Black, new XRect(50, 60, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Urakka", textFont, XBrushes.Black, new XRect(50, 90, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(urakkaHolder, textFont, XBrushes.Black, new XRect(130, 90, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Sek.asema", textFont, XBrushes.Black, new XRect(50, 105, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(sekAsemaHolder, textFont, XBrushes.Black, new XRect(130, 105, page.Width, page.Height), XStringFormats.TopLeft);

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

            graphics.DrawString("Näytteen ottaja", textFont, XBrushes.Black, new XRect(340, 90, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(nayteHolder, textFont, XBrushes.Black, new XRect(426, 90, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Työkohde", textFont, XBrushes.Black, new XRect(340, 105, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(tyoKohdeHolder, textFont, XBrushes.Black, new XRect(426, 105, page.Width, page.Height), XStringFormats.TopLeft);

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

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

            graphics.DrawString("Seulalle jäi g", textFont, XBrushes.Black, new XRect(100, 150, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG0.Text, textFont, XBrushes.Black, new XRect(100, 160, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG1.Text, textFont, XBrushes.Black, new XRect(100, 175, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG2.Text, textFont, XBrushes.Black, new XRect(100, 190, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG3.Text, textFont, XBrushes.Black, new XRect(100, 205, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG4.Text, textFont, XBrushes.Black, new XRect(100, 220, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG5.Text, textFont, XBrushes.Black, new XRect(100, 235, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG6.Text, textFont, XBrushes.Black, new XRect(100, 250, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG7.Text, textFont, XBrushes.Black, new XRect(100, 265, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG8.Text, textFont, XBrushes.Black, new XRect(100, 280, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG9.Text, textFont, XBrushes.Black, new XRect(100, 295, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG10.Text, textFont, XBrushes.Black, new XRect(100, 310, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG11.Text, textFont, XBrushes.Black, new XRect(100, 325, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG12.Text, textFont, XBrushes.Black, new XRect(100, 340, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG13.Text, textFont, XBrushes.Black, new XRect(100, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG14.Text, textFont, XBrushes.Black, new XRect(100, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG15.Text, textFont, XBrushes.Black, new XRect(100, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulaG16.Text, textFont, XBrushes.Black, new XRect(100, 400, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Seulalle jäi %", textFont, XBrushes.Black, new XRect(180, 150, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros1.Text, textFont, XBrushes.Black, new XRect(180, 160, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros2.Text, textFont, XBrushes.Black, new XRect(180, 175, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros3.Text, textFont, XBrushes.Black, new XRect(180, 190, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros4.Text, textFont, XBrushes.Black, new XRect(180, 205, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros5.Text, textFont, XBrushes.Black, new XRect(180, 220, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros6.Text, textFont, XBrushes.Black, new XRect(180, 235, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros7.Text, textFont, XBrushes.Black, new XRect(180, 250, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros8.Text, textFont, XBrushes.Black, new XRect(180, 265, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros9.Text, textFont, XBrushes.Black, new XRect(180, 280, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros10.Text, textFont, XBrushes.Black, new XRect(180, 295, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros11.Text, textFont, XBrushes.Black, new XRect(180, 310, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros12.Text, textFont, XBrushes.Black, new XRect(180, 325, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros13.Text, textFont, XBrushes.Black, new XRect(180, 340, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros14.Text, textFont, XBrushes.Black, new XRect(180, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros15.Text, textFont, XBrushes.Black, new XRect(180, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros16.Text, textFont, XBrushes.Black, new XRect(180, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.seulapros17.Text, textFont, XBrushes.Black, new XRect(180, 400, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Läpäisy %", textFont, XBrushes.Black, new XRect(260, 150, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros1.Text, textFont, XBrushes.Black, new XRect(260, 160, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros2.Text, textFont, XBrushes.Black, new XRect(260, 175, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros3.Text, textFont, XBrushes.Black, new XRect(260, 190, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros4.Text, textFont, XBrushes.Black, new XRect(260, 205, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros5.Text, textFont, XBrushes.Black, new XRect(260, 220, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros6.Text, textFont, XBrushes.Black, new XRect(260, 235, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros7.Text, textFont, XBrushes.Black, new XRect(260, 250, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros8.Text, textFont, XBrushes.Black, new XRect(260, 265, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros9.Text, textFont, XBrushes.Black, new XRect(260, 280, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros10.Text, textFont, XBrushes.Black, new XRect(260, 295, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros11.Text, textFont, XBrushes.Black, new XRect(260, 310, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros12.Text, textFont, XBrushes.Black, new XRect(260, 325, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros13.Text, textFont, XBrushes.Black, new XRect(260, 340, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros14.Text, textFont, XBrushes.Black, new XRect(260, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros15.Text, textFont, XBrushes.Black, new XRect(260, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(massaOhjelma.lapaisypros16.Text, textFont, XBrushes.Black, new XRect(260, 385, page.Width, page.Height), XStringFormats.TopLeft);

            //Piirtää otsikkotietoja PDF-dokumenttiin
            graphics.DrawString("Päällyste", textFont, XBrushes.Black, new XRect(340, 150, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(paallysteHolder, textFont, XBrushes.Black, new XRect(426, 150, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Näyte no", textFont, XBrushes.Black, new XRect(340, 165, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(nayteNroHolder, textFont, XBrushes.Black, new XRect(426, 165, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Päiväys", textFont, XBrushes.Black, new XRect(340, 180, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(paivaysHolder, textFont, XBrushes.Black, new XRect(426, 180, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Klo", textFont, XBrushes.Black, new XRect(340, 195, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kloHolder, textFont, XBrushes.Black, new XRect(426, 195, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Paalu/kaista", textFont, XBrushes.Black, new XRect(340, 210, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(paaluHolder, textFont, XBrushes.Black, new XRect(426, 210, page.Width, page.Height), XStringFormats.TopLeft);

            //Piirtää sideainepitoisuuksien määritykset PDF-dokumenttiin
            graphics.DrawString("SIDEAINEMÄÄRITYS", textFont, XBrushes.Black, new XRect(340, 230, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Näytteen paino", textFont, XBrushes.Black, new XRect(340, 245, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("g", textFont, XBrushes.Black, new XRect(450, 245, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(naytePainoHolder, textFont, XBrushes.Black, new XRect(475, 245, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Kiviain. yht. paino", textFont, XBrushes.Black, new XRect(340, 260, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("g", textFont, XBrushes.Black, new XRect(450, 260, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(kiviAineHolder, textFont, XBrushes.Black, new XRect(475, 260, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Sideainemäärä", textFont, XBrushes.Black, new XRect(340, 275, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("g", textFont, XBrushes.Black, new XRect(450, 275, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(sideAineMHolder, textFont, XBrushes.Black, new XRect(475, 275, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Sideainepitoisuus", textFont, XBrushes.Black, new XRect(340, 290, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("%", textFont, XBrushes.Black, new XRect(450, 290, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(sideainePHolder, textFont, XBrushes.Black, new XRect(475, 290, page.Width, page.Height), XStringFormats.TopLeft);

            /*
            //Piirtää ohjearvojen määritykset PDF-dokumenttiin
            graphics.DrawString("OHJEARVOT", textFont, XBrushes.Black, new XRect(340, 310, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Sideainepitoisuus", textFont, XBrushes.Black, new XRect(340, 325, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("%", textFont, XBrushes.Black, new XRect(450, 325, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(sideAinePitHolder, textFont, XBrushes.Black, new XRect(475, 325, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Täytejauheen määrä", textFont, XBrushes.Black, new XRect(340, 340, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("%", textFont, XBrushes.Black, new XRect(450, 340, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(tayteJauheHolder, textFont, XBrushes.Black, new XRect(475, 340, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Rakeisuus", textFont, XBrushes.Black, new XRect(340, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("#", textFont, XBrushes.Black, new XRect(400, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("12", textFont, XBrushes.Black, new XRect(415, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("mm", textFont, XBrushes.Black, new XRect(450, 355, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(rak12Holder, textFont, XBrushes.Black, new XRect(475, 355, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Rakeisuus", textFont, XBrushes.Black, new XRect(340, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("#", textFont, XBrushes.Black, new XRect(400, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("8", textFont, XBrushes.Black, new XRect(415, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("mm", textFont, XBrushes.Black, new XRect(450, 370, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(rak8Holder, textFont, XBrushes.Black, new XRect(475, 370, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Rakeisuus", textFont, XBrushes.Black, new XRect(340, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("#", textFont, XBrushes.Black, new XRect(400, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("4", textFont, XBrushes.Black, new XRect(415, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("mm", textFont, XBrushes.Black, new XRect(450, 385, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(rak4Holder, textFont, XBrushes.Black, new XRect(475, 385, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Rakeisuus", textFont, XBrushes.Black, new XRect(340, 400, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("#", textFont, XBrushes.Black, new XRect(400, 400, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("2", textFont, XBrushes.Black, new XRect(415, 400, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("mm", textFont, XBrushes.Black, new XRect(450, 400, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(rak2Holder, textFont, XBrushes.Black, new XRect(475, 400, page.Width, page.Height), XStringFormats.TopLeft);


            graphics.DrawString("Rakeisuus", textFont, XBrushes.Black, new XRect(340, 415, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("#", textFont, XBrushes.Black, new XRect(400, 415, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("0.5", textFont, XBrushes.Black, new XRect(415, 415, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("mm", textFont, XBrushes.Black, new XRect(450, 415, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(rak05Holder, textFont, XBrushes.Black, new XRect(475, 415, page.Width, page.Height), XStringFormats.TopLeft);

            graphics.DrawString("Rakeisuus", textFont, XBrushes.Black, new XRect(340, 430, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("#", textFont, XBrushes.Black, new XRect(400, 430, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("0.063", textFont, XBrushes.Black, new XRect(415, 430, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString("mm", textFont, XBrushes.Black, new XRect(450, 430, page.Width, page.Height), XStringFormats.TopLeft);
            graphics.DrawString(rak0063Holder, textFont, XBrushes.Black, new XRect(475, 430, page.Width, page.Height), XStringFormats.TopLeft);
            */

            KayraImage ki = new KayraImage();
            MemoryStream kayrastream = ki.KayraKuva(massaOhjelma);
            XImage kayrakuva = XImage.FromStream(kayrastream);
            graphics.DrawImage(kayrakuva, 40, 420, 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");
            }
            
        }
Ejemplo n.º 5
0
        public void KayraPiirto(Massaohjelma mas)
        {
            Massaohjelma _massa = mas;

            //Näytetään rakeisuuskäyrä syötettyjen arvojen avulla
            if (_kayra == null)
            {
                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%



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



                foreach (Control c in _massa.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 < 2; i++)//Otetaan ohjealueet talteen yksi kolumni kerrallaan
                {
                    switch (i)
                    {
                    case 0:
                        int j = 17;
                        foreach (Control c in _massa.ohjeAlue.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "Ala")
                                    {
                                        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 _massa.ohjeAlue.Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if (((TextBox)c).Tag.ToString() != null)
                                {
                                    if (((TextBox)c).Tag.ToString() == "Yla")
                                    {
                                        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;

                    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);
                 * }*/

                _kayra = new MassaKayra(_massa, selist, tulist, selistALL, sisOhjeAla, sisOhjeYla);
                _kayra.Show();
            }
            else
            {
                _kayra.Close();
                _kayra = null;
                KayraPiirto(_massa);
            }
        }
Ejemplo n.º 6
0
        public MassaKayra(Window mas, List <SeulakirjastoIndex> s, List <SeulaLapPros> p, List <Seulakirjasto> alls, List <SeulaLapPros> sisAla, List <SeulaLapPros> sisYla)
        {
            InitializeComponent();

            _massa       = (Massaohjelma)mas;
            seulat       = s;
            prosentit    = p;
            kaikkiseulat = alls;
            sisOhjeAla   = sisAla;
            sisOhjeYla   = sisYla;

            //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;
            LinearAxis yaxis = new LinearAxis //Y-akseli
            {
                Maximum       = 100,
                Minimum       = 0,
                Title         = "Prosentti",
                TickStyle     = TickStyle.Inside,
                MinorTickSize = 4,
                Position      = AxisPosition.Left,
                //AbsoluteMaximum = 100,
                //AbsoluteMinimum = 0,
                MajorStep          = 10,
                MinorStep          = 5,
                MajorGridlineStyle = LineStyle.Dash,
                MinorGridlineStyle = LineStyle.Dot,
                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 = seulat[(seulat.Count - 1)].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;
                if (kaikkiseulat[(kaikkiseulat.Count - 1)].seula > 0)
                {
                    xaxis.Minimum = (kaikkiseulat[(kaikkiseulat.Count - 1)].seula);
                }
                else
                {
                    xaxis.Minimum = 0.001;
                }
                xaxis.AbsoluteMinimum = 0;
                xaxis.StartPosition   = 0;
                xaxis.IsZoomEnabled   = false;
                xaxis.IsPanEnabled    = false;
            }

            /*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.MajorGridlineStyle = LineStyle.Solid;
             *  caxis.MinorGridlineStyle = LineStyle.Dash;
             *  //caxis.Maximum = seulat[0].seula;
             *  //caxis.Minimum = seulat[(seulat.Count - 1)].seula;
             *  caxis.IsZoomEnabled = false;
             *  caxis.IsPanEnabled = false;
             * }
             * else
             * {
             *  caxis.Title = "Seula";
             *  caxis.TickStyle = TickStyle.Inside;
             *  caxis.Position = AxisPosition.Bottom;
             *  //caxis.MajorGridlineStyle = LineStyle.Solid;
             *  //caxis.MinorGridlineStyle = LineStyle.Dash;
             *  //caxis.Maximum = seulat[0].seula;
             *  //caxis.Minimum = seulat[(seulat.Count-1)].seula;
             *  caxis.IsZoomEnabled = true;
             *  caxis.IsPanEnabled = true;
             *  caxis.AxislineStyle = LineStyle.Solid;
             *  caxis.MinorStep = 1;
             * }
             * for (int i = kaikkiseulat.Count - 1; i >= 0; i--) //Laittaa Y-akselille otsikot, eli seulat jotka on käytössä tällä hetkellä
             * {
             *  caxis.Labels.Add(kaikkiseulat[i].seula.ToString());
             * }*/

            LineSeries l1 = new LineSeries //Tuloskäyrä/viiva
            {
                //Title = "Rakeisuuskäyrä",
                MarkerType = MarkerType.Circle,
                CanTrackerInterpolatePoints = false,
                MarkerSize = 5
            };
            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      = "Ulkoiset ohjealueet",
                MarkerType = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                MarkerSize     = 0,
                Color          = OxyColors.Indigo,
                RenderInLegend = true
            };
            //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>();

            //------------------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 _massa.ohjeAlue.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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            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);
            }


            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));
            }
            //----------------------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);
            MassaModel       = model;
            this.DataContext = this;
        }
Ejemplo n.º 7
0
        public MassaKayra(Window mas, List <SeulakirjastoIndex> s, List <SeulaLapPros> p, List <Seulakirjasto> alls, List <SeulaLapPros> sisAla, List <SeulaLapPros> sisYla)
        {
            InitializeComponent();

            _massa       = (Massaohjelma)mas;
            seulat       = s;
            prosentit    = p;
            kaikkiseulat = alls;
            sisOhjeAla   = sisAla;
            sisOhjeYla   = sisYla;

            //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;
            LinearAxis yaxis = new LinearAxis //Y-akseli
            {
                Maximum   = 100,
                Minimum   = 0,
                Title     = "Prosentti",
                TickStyle = TickStyle.Inside,
                Position  = AxisPosition.Left,
                //AbsoluteMaximum = 100,
                //AbsoluteMinimum = 0,
                MajorStep          = 10,
                MinorStep          = 2.5,
                MajorGridlineStyle = LineStyle.Solid,
                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.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.MinorGridlineStyle = LineStyle.Dash;
             *  xaxis.Maximum = seulat[0].seula;
             *  xaxis.Minimum = seulat[(seulat.Count - 1)].seula;
             *  xaxis.IsZoomEnabled = false;
             *  xaxis.IsPanEnabled = false;
             *
             * }*/
            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.MajorGridlineStyle = LineStyle.Solid;
                caxis.MinorGridlineStyle = LineStyle.Dash;
                //caxis.Maximum = seulat[0].seula;
                //caxis.Minimum = seulat[(seulat.Count - 1)].seula;
                caxis.IsZoomEnabled = false;
                caxis.IsPanEnabled  = false;
            }
            else
            {
                caxis.Title     = "Seula";
                caxis.TickStyle = TickStyle.Inside;
                caxis.Position  = AxisPosition.Bottom;
                //caxis.MajorGridlineStyle = LineStyle.Solid;
                //caxis.MinorGridlineStyle = LineStyle.Dash;
                //caxis.Maximum = seulat[0].seula;
                //caxis.Minimum = seulat[(seulat.Count-1)].seula;
                caxis.IsZoomEnabled = true;
                caxis.IsPanEnabled  = true;
                caxis.AxislineStyle = LineStyle.Solid;
                caxis.MinorStep     = 1;
            }
            for (int i = kaikkiseulat.Count - 1; i >= 0; i--) //Laittaa Y-akselille otsikot, eli seulat jotka on käytössä tällä hetkellä
            {
                caxis.Labels.Add(kaikkiseulat[i].seula.ToString());
            }

            LineSeries l1 = new LineSeries //Tuloskäyrä/viiva
            {
                Title      = "Rakeisuuskäyrä",
                MarkerType = MarkerType.Circle,
                CanTrackerInterpolatePoints = false,
                MarkerSize = 5
            };
            LineSeries ohje1 = new LineSeries
            {
                MarkerType = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                MarkerSize = 0,
                Color      = OxyColors.Bisque
            };
            LineSeries ohje2 = new LineSeries
            {
                MarkerType = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                MarkerSize = 0,
                Color      = OxyColors.Bisque
            };
            LineSeries ohje3 = new LineSeries
            {
                MarkerType = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                MarkerSize = 0,
                Color      = OxyColors.BlanchedAlmond
            };
            LineSeries ohje4 = new LineSeries
            {
                MarkerType = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                MarkerSize = 0,
                Color      = OxyColors.BlanchedAlmond
            };

            seulat.Reverse();

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

            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);
            }

            //------------------Käytetään CategoryAxisin kanssa--------------------
            List <Pisteet> la = new List <Pisteet>(); //Pääviiva
            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];
             *  la.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);
            MassaModel       = model;
            this.DataContext = this;
        }