using System; using System.Collections; using System.ComponentModel; using System.Linq; using DevExpress.XtraReports.UI; using BeWo.Report.ReportObjects; using BeWo.Report; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Text.RegularExpressions; using BS.Shared.Core; namespace BeWo.SeWo { public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport { public Stundenzettel() { InitializeComponent(); } public void SetReportDataSource(ServicesOverviewRO pRO) { lblHeader.Text = "Leistungsnachweis über Fachleistungsstunden"; var catDict = new Dictionary(); if (pRO.Services != null) { List servicesBillable = new List(); foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services) { if (s.IsBillable) { ServicesOverviewRO.CreateSignatureString(s); if (s.IsGroup) s.FLSQualifiedString = "G"; else s.FLSQualifiedString = "E"; servicesBillable.Add(s); } if (!catDict.ContainsKey(s.ServiceCategory)) { catDict.Add(s.ServiceCategory, s.ServiceCategory); } } pRO.Services = servicesBillable; } if (catDict.Count == 1) { lblHeader.Text = String.Format("Leistungsnachweis über {0}", catDict.Values.FirstOrDefault()); } this.bindingSource1.DataSource = pRO; } private void picSignature_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { XRPictureBox xrBox = sender as XRPictureBox; //var test = this.GetCurrent string base64String = xrBox.Tag as string; if (!String.IsNullOrWhiteSpace(base64String)) { var base64Data = Regex.Match(base64String, @"data:image/(?.+?),(?.+)").Groups["data"].Value; var binData = Convert.FromBase64String(base64Data); Image img = ByteArrayToImage(binData); xrBox.Image = Utils.CropImage(img); } else { xrBox.Image = null; } } public Image ByteArrayToImage(byte[] byteArrayIn) { Image returnImage = null; MemoryStream ms = new System.IO.MemoryStream(byteArrayIn); returnImage = Image.FromStream(ms); return returnImage; } } }