123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Threading.Tasks;
- using System.IO;
- using System.Windows.Forms;
- using Microsoft.AspNetCore.Components;
- using FastReport.Dialog;
- using System.Globalization;
- namespace FastReport.Web.Blazor.Components.Internal.Dialog
- {
- public abstract class DialogBaseComponent<T> : Microsoft.AspNetCore.Components.ComponentBase
- where T : DialogControl
- {
- [Parameter]
- public WebReport WebReport { get; set; }
- [Parameter]
- public T Control { get; set; }
- protected virtual string GetStyle
- => $"{GetControlPosition()} {GetControlFont()} {GetForeColor()} {GetBackColor()}";
-
- protected string GetForeColor()
- {
- if (!Control.ForeColor.IsEmpty)
- return $"color: {ColorTranslator.ToHtml(Control.ForeColor)};";
- return string.Empty;
- }
- protected string GetBackColor()
- {
- if (!Control.BackColor.IsEmpty)
- return $"background-color: {ColorTranslator.ToHtml(Control.BackColor)};";
- return string.Empty;
- }
- protected string GetControlFont()
- {
- Font font = Control.Font;
- string fontStyle = (((font.Style & FontStyle.Bold) > 0) ? "font-weight:bold;" : String.Empty) +
- (((font.Style & FontStyle.Italic) > 0) ? "font-style:italic;" : "font-style:normal;");
- if ((font.Style & FontStyle.Underline) > 0 && (font.Style & FontStyle.Strikeout) > 0)
- fontStyle += "text-decoration:underline|line-through;";
- else if ((font.Style & FontStyle.Underline) > 0)
- fontStyle += "text-decoration:underline;";
- else if ((font.Style & FontStyle.Strikeout) > 0)
- fontStyle += "text-decoration:line-through;";
- return $"font-size:{WebReport.Dialog.Zoom(font.Size)}pt;font-family:{font.FontFamily.Name};{fontStyle};display:inline-block;";
- }
- protected string GetControlPosition()
- {
- Web.Dialog dialog = WebReport.Dialog;
- return $"position:absolute;" +
- $"left:{dialog.ZoomWithRescale(Control.Left)}px;" +
- $"top:{dialog.ZoomWithRescale(Control.Top)}px;" +
- $"width:{dialog.ZoomWithRescale(Control.Width)}px;" +
- $"height:{dialog.ZoomWithRescale(Control.Height)}px;" +
- $"padding:0px;margin:0px;";
- }
- protected virtual string GetControlAlign()
- {
- if (Control is LabelControl labelControl)
- return GetAlign(labelControl.TextAlign);
- return string.Empty;
- }
- protected string GetEditAlign(HorizontalAlignment align)
- {
- if (align == HorizontalAlignment.Left)
- return "text-align:left;";
- else if (align == HorizontalAlignment.Center)
- return "text-align:center;";
- else if (align == HorizontalAlignment.Right)
- return "text-align:right;";
- else
- return "";
- }
- protected string GetAlign(ContentAlignment align)
- {
- if (align == ContentAlignment.TopLeft)
- return "text-align:left;vertical-align:top;";
- else if (align == ContentAlignment.TopCenter)
- return "text-align:center;vertical-align:top;";
- else if (align == ContentAlignment.TopRight)
- return "text-align:right;vertical-align:top;";
- else if (align == ContentAlignment.BottomLeft)
- return "text-align:left;vertical-align:bottom;";
- else if (align == ContentAlignment.BottomCenter)
- return "text-align:center;vertical-align:bottom;";
- else if (align == ContentAlignment.TopRight)
- return "text-align:right;vertical-align:bottom;";
- else if (align == ContentAlignment.MiddleLeft)
- return "text-align:left;vertical-align:middle;";
- else if (align == ContentAlignment.MiddleCenter)
- return "text-align:center;vertical-align:middle;";
- else if (align == ContentAlignment.MiddleRight)
- return "text-align:right;vertical-align:middle;";
- else
- return "";
- }
- }
- }
|