public static BoxLineConfig GetDefault() { var ret = new BoxLineConfig(); ret.initialize(); return(ret); }
public PdfDrawer(PdfContentByte contentByte, ref BoxConfig messageConfig, ref BoxLineConfig optionConfig) { if (contentByte == null) { throw new ApplicationException("PdfContentByte nullo."); } this.canvas = contentByte; this.canvas.SetGState(new PdfGState { FillOpacity = messageConfig.Opacity.Value, StrokeOpacity = messageConfig.Opacity.Value }); this.layoutInstances = new Dictionary <PdfLayout, object>(); this.msgConfig = messageConfig; this.optCfg = optionConfig; }
/// <summary> /// Assegna i valori non impostati leggendoli dal file di configurazione. /// </summary> /// <param name="source"></param> /// <returns></returns> public static BoxConfig MergeWithConfig(BoxConfig source, log4net.ILog logger = null) { if (logger != null) { logger.Debug("BoxConfig::MergeWithConfig - INIT"); } var key = ConfigurationManager.AppSettings["DefaultBoxConfig"]; if (logger != null) { logger.DebugFormat("BoxConfig::MergeWithConfig - readed key = {0}", key); } if (string.IsNullOrEmpty(key)) { if (logger != null) { logger.Debug("BoxConfig::MergeWithConfig - END"); } return(source); } var retval = source ?? new BoxConfig(); try { var configured = JsonConvert.DeserializeObject <BoxConfig>(key); if (!retval.x.HasValue) { retval.x = configured.x; } if (!retval.y.HasValue) { retval.y = configured.y; } if (!retval.pageNumber.HasValue) { retval.pageNumber = configured.pageNumber; } if (!retval.isInline.HasValue) { retval.isInline = configured.isInline; } if (!retval.borderWidth.HasValue) { retval.borderWidth = configured.borderWidth; } if (!retval.opacity.HasValue) { retval.opacity = configured.opacity; } if (string.IsNullOrEmpty(retval.bgColor)) { retval.bgColor = configured.bgColor; } if (string.IsNullOrEmpty(retval.borderColor)) { retval.borderColor = configured.borderColor; } if (retval.BoxLine == null || retval.BoxLine.Length < 1) { retval.BoxLine = new[] { BoxLineConfig.GetDefault() }; } else { BoxLineConfig line; for (int idx = 0; idx < retval.BoxLine.Length; idx++) { line = retval.BoxLine[idx]; line = BoxLineConfig.MergeWithConfig(line, logger); } } } catch (Exception ex) { if (logger != null) { logger.Error(ex); logger.Debug("BoxConfig::MergeWithConfig - END"); } return(source); } if (logger != null) { logger.Debug("BoxConfig::MergeWithConfig - END"); } return(retval); }
/// <summary> /// Assegna i valori non impostati leggendoli dal file di configurazione. /// </summary> /// <param name="source"></param> /// <param name="logger"></param> /// <returns></returns> public static BoxLineConfig MergeWithConfig(BoxLineConfig source, log4net.ILog logger = null) { if (logger != null) { logger.Debug("BoxLineConfig::MergeWithConfig - INIT"); } var key = ConfigurationManager.AppSettings["DefaultBoxLineConfig"]; if (logger != null) { logger.DebugFormat("BoxLineConfig::MergeWithConfig - readed key = {0}", key); } if (string.IsNullOrEmpty(key)) { if (logger != null) { logger.Debug("BoxLineConfig::MergeWithConfig - END"); } return(source); } var retval = source ?? BoxLineConfig.GetDefault(); try { var configured = JsonConvert.DeserializeObject <BoxLineConfig>(key); if (!retval.fontSize.HasValue) { retval.fontSize = configured.fontSize; } if (!retval.height.HasValue) { retval.height = configured.height; } if (!retval.spacing.HasValue) { retval.spacing = configured.spacing; } if (!retval.tfBox.HasValue) { retval.tfBox = configured.tfBox; } if (!retval.width.HasValue) { retval.width = configured.width; } if (string.IsNullOrEmpty(retval.foreColor)) { retval.foreColor = configured.foreColor; } if (string.IsNullOrEmpty(retval.Message)) { retval.Message = configured.Message; } if (retval.Options == null || retval.Options.Length < 1) { retval.Options = configured.Options ?? new string[0]; } if (string.IsNullOrEmpty(retval.SelectedValue)) { retval.SelectedValue = configured.SelectedValue; } } catch (Exception ex) { if (logger != null) { logger.Error(ex); logger.Debug("BoxLineConfig::MergeWithConfig - END"); return(source); } } if (logger != null) { logger.Debug("BoxLineConfig::MergeWithConfig - END"); } return(retval); }