123456789101112131415161718192021222324252627282930313233343536 |
- @using System.IO
- @using System.Drawing
- @inherits DialogBaseComponent<PictureBoxControl>
- <div style="@GetStyle"></div>
- @code {
- protected override string GetStyle
- => $"{GetControlPosition()} {GetControlAlign()} {GetPictureBoxURL(Control.Image)} padding:0;margin:0;";
- protected string GetPictureBoxURL(Image image)
- {
- #if WASM
- // TODO: add support for Wasm
- return "";
- #else
- int hash = image.GetHashCode();
- if (!WebReport.PictureCache.ContainsKey(hash.ToString()))
- {
- using (MemoryStream picStream = new MemoryStream())
- {
- image.Save(picStream, image.RawFormat);
- byte[] imageArray = new byte[picStream.Length];
- picStream.Position = 0;
- picStream.Read(imageArray, 0, (int)picStream.Length);
- WebReport.PictureCache.Add(hash.ToString(), imageArray);
- }
- }
- string url = WebUtils.ToUrl(WebReport.template_ROUTE_BASE_PATH, $"preview.getPicture?");
- return $"background: url('{url}reportId={WebReport.ID}&pictureId={hash}') no-repeat !important;-webkit-print-color-adjust:exact;";
- #endif
- }
- }
|