private void InitializeFinalStage_Pre() { var statuslijst = Acumulator.Instance().BB.CheckAllMarks(null); int donecntr = 0; foreach (var kvp in statuslijst) { if (kvp.Value) { donecntr++; } } if (donecntr == statuslijst.Count) { Isvolledig = true; Save2File.IsEnabled = true; ShowPrijsRaport.IsEnabled = true; ShowTegelRaport.IsEnabled = true; SaveNeeded = !XmlMatch(null); if (SaveNeeded) { Acumulator.Instance().uitvoerPlaceHolder = null; SaveXml.IsEnabled = true; NewStatusBox.SetDataNew(PrintDatum, Isvolledig); NewStatusBox.Visibility = Visibility.Visible; if (Acumulator.Instance().oOL != null) { CurrentStatusBox.SetDataSaved(); CurrentStatusBox.Visibility = System.Windows.Visibility.Visible; } } else { Acumulator.Instance().BB.ValidateAllMarks(null); CurrentStatusBox.SetDataSaved(); CurrentStatusBox.Visibility = System.Windows.Visibility.Visible; SaveXml.IsEnabled = false; } if (Acumulator.Instance().uitvoerPlaceHolder == null) { if (Acumulator.Instance().Donwloadsactive == 0) { _uitvoerCreator = new UitvoerCreator(); var imgList = _uitvoerCreator.MaakTegelUitvoer(SaveNeeded, PrintDatum); var bpImgList = _uitvoerCreator.MaakPlattegrondUitvoer(SaveNeeded, PrintDatum); List <List <ImageTools.ExtendedImage> > l = new List <List <ImageTools.ExtendedImage> >(); l.Add(imgList); l.Add(bpImgList); UitvoerPrijsView.SetPaginaNR(_uitvoerCreator.totalPages, _uitvoerCreator.pagebreaks + 1); BW.RunWorkerAsync(l); } else { _uitvoerCreator = new UitvoerCreator(); var imgList = _uitvoerCreator.MaakTegelUitvoer(SaveNeeded, PrintDatum); List <List <ImageTools.ExtendedImage> > l = new List <List <ImageTools.ExtendedImage> >(); l.Add(imgList); UitvoerPrijsView.SetPaginaNR(_uitvoerCreator.totalPages, _uitvoerCreator.pagebreaks + 1); BW.RunWorkerAsync(l); ImageStaus.Text = "Er moeten nog plaatjes gedownload worden."; } } else if (Acumulator.Instance().uitvoerPlaceHolder != null && Acumulator.Instance().uitvoerPlaceHolder.Pdfdoc != null) { _File = Acumulator.Instance().uitvoerPlaceHolder.Pdfdoc; _uitvoerCreator = Acumulator.Instance().uitvoerPlaceHolder.uitvoerCreator; PrintDatum = Acumulator.Instance().PrevPrintDatum; Acumulator.Instance().BusyBee.IsBusy = false; } UitvoerPrijsView.Visibility = Visibility.Collapsed; UitvoerView.Visibility = Visibility.Collapsed; } else { Isvolledig = false; NewStatusBox.SetDataNew(PrintDatum, Isvolledig); NewStatusBox.Visibility = Visibility.Visible; if (Acumulator.Instance().oOL != null) { CurrentStatusBox.SetDataSaved(); CurrentStatusBox.Visibility = System.Windows.Visibility.Visible; } Acumulator.Instance().BusyBee.IsBusy = false; } if (Acumulator.Instance().HuidigGebruiker.Rol == UserRole.Demo) { SaveXml.IsEnabled = false; } }
private void MakePdf(List <ImageTools.ExtendedImage> imgList, List <ImageTools.ExtendedImage> bpImgList) { var document = new PdfDocument(); // UitvoerCreator uitvoercreator = new UitvoerCreator(); foreach (var img in imgList) { PdfPage page = document.AddPage(); page.Width = 797; page.Height = 1123; XGraphics gfx = null; UIThread.Invoke(() => { gfx = XGraphics.FromPdfPage(page); }); while (gfx == null) { System.Threading.Thread.Sleep(100); } using (MemoryStream mstream = new MemoryStream()) { //var img = UitvoerView.GetImg(); if (img != null) { img.DensityX = 300; img.DensityY = 300; JpegEncoder encoder = new JpegEncoder(); encoder.Encode(img, mstream); MemoryStream mss = new MemoryStream(mstream.ToArray()); mss.Seek(0, SeekOrigin.Begin); //JpegEncoder encoder = new JpegEncoder(); //encoder.Encode(img, mstream); //mstream.Seek(0, SeekOrigin.Begin); //XImage.FromStream(ms); XImage pdfImg = null; UIThread.Invoke(() => { pdfImg = XImage.FromStream(mss); }); while (pdfImg == null) { System.Threading.Thread.Sleep(100); } pdfImg.Interpolate = false; //gfx.DrawImage(pdfImg, 0, 0); gfx.DrawImage(pdfImg, 0, 0, 797, 1123); } } } PdfPage page2 = document.AddPage(); page2.Width = 797; page2.Height = 1123; XGraphics gfx2 = null; UIThread.Invoke(() => { gfx2 = XGraphics.FromPdfPage(page2); }); while (gfx2 == null) { System.Threading.Thread.Sleep(100); } using (MemoryStream mstream2 = new MemoryStream()) { ImageTools.ExtendedImage img2 = null; UIThread.Invoke(() => { img2 = UitvoerPrijsView.GetImg(SaveNeeded, PrintDatum); }); while (img2 == null) { System.Threading.Thread.Sleep(100); } img2.DensityX = 900; img2.DensityY = 900; JpegEncoder encoder2 = new JpegEncoder(); encoder2.Quality = 100; encoder2.Encode(img2, mstream2); MemoryStream mss2 = new MemoryStream(mstream2.ToArray()); mss2.Seek(0, SeekOrigin.Begin); XImage pdfImg2 = null; UIThread.Invoke(() => { pdfImg2 = XImage.FromStream(mss2); }); while (pdfImg2 == null) { System.Threading.Thread.Sleep(100); } pdfImg2.Interpolate = false; gfx2.DrawImage(pdfImg2, 0, 0, 797, 1123); } foreach (var img in bpImgList) { using (MemoryStream msb = new MemoryStream()) { PdfPage pageb = document.AddPage(); pageb.Width = 797; pageb.Height = 1123; XGraphics gfxb = null; UIThread.Invoke(() => { gfxb = XGraphics.FromPdfPage(pageb); }); while (gfxb == null) { System.Threading.Thread.Sleep(100); } img.DensityX = 300; img.DensityY = 300; JpegEncoder encoderb = new JpegEncoder(); encoderb.Encode(img, msb); MemoryStream msb2 = new MemoryStream(msb.ToArray()); msb2.Seek(0, SeekOrigin.Begin); XImage pdfImg = null; UIThread.Invoke(() => { pdfImg = XImage.FromStream(msb2); }); while (pdfImg == null) { System.Threading.Thread.Sleep(100); } pdfImg.Interpolate = false; gfxb.DrawImage(pdfImg, 0, 0, 797, 1123); } } _File = document; /* foreach (var Img in uitvoercreator.MaakPlattegrondUitvoer()) * { * PdfPage page3 = document.AddPage(); * page3.Width = 797; * page3.Height = 1123; * XGraphics gfx3 = XGraphics.FromPdfPage(page3); * using (MemoryStream mstream3 = new MemoryStream()) * { * if (Img != null) * { * Img.DensityX = 300; * Img.DensityY = 300; * JpegEncoder encoder = new JpegEncoder(); * encoder.Encode(Img, mstream3); * MemoryStream mss3 = new MemoryStream(mstream3.ToArray()); * mss3.Seek(0, SeekOrigin.Begin); * XImage pdfImg3 = XImage.FromStream(mss3); * pdfImg3.Interpolate = false; * gfx3.DrawImage(pdfImg3, 0, 0, 797, 1123); * * } * } * }*/ }
public void newInitPre() { //check volledig onvolledig Acumulator.Instance().BB.ShowHideAllMarks(true, null); var aantalIncompleet = (from p in Acumulator.Instance().BB.CheckAllMarks(null) where !p.Value select p.Key).Count(); aantalIncompleet += ImagesOk(); var compleet = Isvolledig = aantalIncompleet == 0; var saveXmlAanwezig = Acumulator.Instance().SavedXml != null; var memXmlAanwezig = Acumulator.Instance().lastGeneratedXml != null; var moetGenereren = true; var moetOpslaan = true; if (memXmlAanwezig) { moetGenereren = !XmlMatch(Acumulator.Instance().lastGeneratedXml); } if (saveXmlAanwezig) { moetOpslaan = !XmlMatch(Acumulator.Instance().SavedXml); CurrentStatusBox.SetDataSaved(); CurrentStatusBox.Visibility = System.Windows.Visibility.Visible; } if (compleet) { Save2File.IsEnabled = true; ShowPrijsRaport.IsEnabled = true; ShowTegelRaport.IsEnabled = true; } if (moetOpslaan) { SaveXml.IsEnabled = true; NewStatusBox.SetDataNew(PrintDatum, Isvolledig); NewStatusBox.Visibility = Visibility.Visible; } else { SaveXml.IsEnabled = false; Acumulator.Instance().BB.ValidateAllMarks(null); } if ((compleet && moetGenereren) || (compleet && !moetGenereren && Acumulator.Instance().uitvoerPlaceHolder == null)) { _uitvoerCreator = new UitvoerCreator(); var imgList = _uitvoerCreator.MaakTegelUitvoer(SaveNeeded, PrintDatum); List <List <ImageTools.ExtendedImage> > l = new List <List <ImageTools.ExtendedImage> >(); l.Add(imgList); if (Acumulator.Instance().bluePrintManager.GetAllDone()) { var bpImgList = _uitvoerCreator.MaakPlattegrondUitvoer(SaveNeeded, PrintDatum); l.Add(bpImgList); } else { ImageStaus.Text = "Er moeten nog plaatjes gedownload worden."; } UitvoerPrijsView.SetPaginaNR(_uitvoerCreator.totalPages, _uitvoerCreator.pagebreaks + 1); BW.RunWorkerAsync(l); UitvoerPrijsView.Visibility = Visibility.Collapsed; UitvoerView.Visibility = Visibility.Collapsed; } else if (compleet) { _File = Acumulator.Instance().uitvoerPlaceHolder.Pdfdoc; _uitvoerCreator = Acumulator.Instance().uitvoerPlaceHolder.uitvoerCreator; PrintDatum = Acumulator.Instance().PrevPrintDatum; Acumulator.Instance().BusyBee.IsBusy = false; } else { Acumulator.Instance().BusyBee.IsBusy = false; } if (Acumulator.Instance().HuidigGebruiker.Rol == UserRole.Demo) { SaveXml.IsEnabled = false; } }