C2021-019: Override Watermark Text and Color

This commit is contained in:
Kathy committed 2021-07-06 15:16:40 +00:00
1 parent aa9c2574bf
commit a3f89c5fa0
10 files changed
+135 -12

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+19 -1
View File
@@ -60,6 +60,7 @@ namespace VEPROMS
this.muLocID = new DevComponents.Editors.ComboItem();
this.lblWatermarkS = new DevComponents.DotNetBar.LabelX();
this.cbxWaterMark = new DevComponents.DotNetBar.Controls.ComboBoxEx();
this.lblWaterMarkOvrd = new DevComponents.DotNetBar.LabelX();
this.btnCreatePDF = new DevComponents.DotNetBar.ButtonX();
this.btnCancel = new DevComponents.DotNetBar.ButtonX();
this.DlgBrowseFolder = new System.Windows.Forms.FolderBrowserDialog();
@@ -592,7 +593,7 @@ namespace VEPROMS
this.cbxWaterMark.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbxWaterMark.FormattingEnabled = true;
this.cbxWaterMark.ItemHeight = 17;
this.cbxWaterMark.Location = new System.Drawing.Point(181, 70);
this.cbxWaterMark.Location = new System.Drawing.Point(181, 65);
this.cbxWaterMark.Margin = new System.Windows.Forms.Padding(2);
this.cbxWaterMark.Name = "cbxWaterMark";
this.cbxWaterMark.Size = new System.Drawing.Size(157, 23);
@@ -601,6 +602,21 @@ namespace VEPROMS
this.cbxWaterMark.Visible = false;
this.cbxWaterMark.WatermarkFont = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cbxWaterMark.WatermarkText = "select watermark option";
this.lblWatermarkS.Text = "Watermark";
//
// lblWaterMarkOvrd
//
this.lblWaterMarkOvrd.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.lblWaterMarkOvrd.BackColor = System.Drawing.Color.Transparent;
this.lblWaterMarkOvrd.Font = new System.Drawing.Font("Microsoft Sans Serif",7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblWaterMarkOvrd.Location = new System.Drawing.Point(181, 67);
this.lblWaterMarkOvrd.Margin = new System.Windows.Forms.Padding(2);
this.lblWaterMarkOvrd.Name = "lblWaterMarkOvrd";
this.lblWaterMarkOvrd.Size = new System.Drawing.Size(180, 23);
this.superTooltip1.SetSuperTooltip(this.lblWaterMarkOvrd, new DevComponents.DotNetBar.SuperTooltipInfo("Watermark Overrides", "", "Shows Watermark and Watermark colors as overwridden from Procedure Specific Information (PSI).", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(130, 100)));
this.lblWaterMarkOvrd.TabIndex = 106;
this.lblWaterMarkOvrd.Text = "Watermark";
this.lblWaterMarkOvrd.Visible = false;
//
// btnCreatePDF
//
@@ -1234,6 +1250,7 @@ namespace VEPROMS
this.expPrnSetting.Controls.Add(this.ppGpbxUserSpecCB);
this.expPrnSetting.Controls.Add(this.labelX5);
this.expPrnSetting.Controls.Add(this.cbxWaterMark);
this.expPrnSetting.Controls.Add(this.lblWaterMarkOvrd);
this.expPrnSetting.Controls.Add(this.lblGeneratePlacekeeper);
this.expPrnSetting.Controls.Add(this.swtbtnChgBar);
this.expPrnSetting.Controls.Add(this.swtbtnWaterMark);
@@ -1413,6 +1430,7 @@ namespace VEPROMS
private System.Windows.Forms.CheckBox cbxOverwritePDF2;
private System.Windows.Forms.CheckBox cbxOpenAfterCreate2;
private DevComponents.DotNetBar.Controls.ComboBoxEx cbxWaterMark;
private DevComponents.DotNetBar.LabelX lblWaterMarkOvrd;
private System.Windows.Forms.BindingSource docVersionConfigBindingSource;
private DevComponents.DotNetBar.Controls.TextBoxX txbPDFLocation;
private System.Windows.Forms.CheckBox cbxDebug;
@@ -425,12 +425,33 @@ namespace VEPROMS
itm.Save();
}
}
// C2021-019: Override Watermark Text and Color from PSI
string waterMarkTextOverride = pc.GetValue("PSI", "WATERMARKOVERRIDE");
if (waterMarkTextOverride != null && waterMarkTextOverride != "")
{
cbxWaterMark.Visible = false;
lblWaterMarkOvrd.Visible = true;
lblWaterMarkOvrd.Text = waterMarkTextOverride;
}
// do color override
// if there is override text, label contains overridden text in the color selected from color override
// if no override text, combo box text color is override color
string waterMarkColorOverride = pc.GetValue("PSI", "WATERMARKOVERRIDECLR");
if (waterMarkColorOverride != null && waterMarkColorOverride != "")
{
string strColor = waterMarkColorOverride.ToUpper().Contains("DEFAULT") ? "BLUE" : waterMarkColorOverride;
if (lblWaterMarkOvrd.Visible)
lblWaterMarkOvrd.ForeColor = Color.FromName(strColor);
else
cbxWaterMark.ForeColor = Color.FromName(strColor);
}
}
else
{
RevNum = "0";
RevDate = DateTime.Today.ToShortDateString();
ReviewDate = null;
cbxWaterMark.Visible = true;
}
// B2019-044 use Enum without the "None" option for the print dialog
cbxWaterMark.DataSource = EnumDetail<PrintDlgWatermarkList>.Details();
@@ -555,7 +576,26 @@ namespace VEPROMS
private void swtbtnWaterMark_ValueChanged(object sender, EventArgs e)
{
cbxWaterMark.Visible = swtbtnWaterMark.Value;
if (!swtbtnWaterMark.Value) // C2021-019: make both invisible
{
cbxWaterMark.Visible = swtbtnWaterMark.Value;
lblWaterMarkOvrd.Visible = swtbtnWaterMark.Value;
}
else // C2021-019: determine whether combo box or lable needs to be made visible
{
ProcedureConfig pc = MyProcedure.MyConfig as ProcedureConfig;
string waterMarkTextOverride = pc.GetValue("PSI", "WATERMARKOVERRIDE");
if (waterMarkTextOverride != null && waterMarkTextOverride != "")
{
cbxWaterMark.Visible = false;
lblWaterMarkOvrd.Visible = true;
}
else
{
cbxWaterMark.Visible = true;
lblWaterMarkOvrd.Visible = false;
}
}
}
private void txbPDFLocation_Leave(object sender, EventArgs e)
@@ -650,7 +690,7 @@ namespace VEPROMS
// If file exists, determine if overwrite checkbox allows overwrite, if not prompt.
Volian.Print.Library.Rtf2Pdf.PdfDebug = cbxDebug.Checked;
// B2019-128: The combo box list did not include the 'None' option so the selected value was not the correct watermark (had to add 1 to the selected index)
PrintWatermark pw = (swtbtnWaterMark.Value) ? (PrintWatermark)(cbxWaterMark.SelectedIndex+1) : PrintWatermark.None;
string waterMarkText = (swtbtnWaterMark.Value) ? cbxWaterMark.Text : "None"; // C2021-019
// Determine change bar settings. First get from config & then see if override from dialog.
// Also check that format allows override.
ChangeBarDefinition cbd = DetermineChangeBarSettings();
@@ -663,6 +703,12 @@ namespace VEPROMS
{
string locpdfname = null; // get pdf file name for later merge code
MyProcedure = myProc;
// C2021-019: Override Watermark Text, 'waterMarkText' will have whatever watermark text should be printed
ProcedureConfig procConfig = MyProcedure.MyConfig as ProcedureConfig;
string waterMarkTextOverride = "";
if (procConfig != null) waterMarkTextOverride = procConfig.GetValue("PSI", "WATERMARKOVERRIDE");
if (swtbtnWaterMark.Value && waterMarkTextOverride != null && waterMarkTextOverride != "") waterMarkText = waterMarkTextOverride;
// C2020-002 paper size is now set in the format files - default is Letter
Volian.Print.Library.Rtf2Pdf.PaperSize = myProc.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize;
if (myProc.Sections != null)
@@ -686,7 +732,7 @@ namespace VEPROMS
string myPDFPath = GetMultiunitPDFPath();
_MergedPdfPath = myPDFPath; // If Slave, need its subdirectory/unit path for merging
// RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered.
frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, pw.ToString(), cbxDebug.Checked, cbxOrPgBrk.Checked,
frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked, cbxOrPgBrk.Checked,
cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, myPDFPath, cbd, txbPDFName.Text, new Point(Left, Bottom - 50),
swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd);//C2018-009 print PROMS version
frmStatus.CloseWhenDone = true;
@@ -715,7 +761,7 @@ namespace VEPROMS
if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! {0} | {1}", MyProcedure.DisplayNumber, MyProcedure.DisplayText);
// RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered.
// B2016-249 Output Procedure to folder associated with Parent Child
frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, pw.ToString(), cbxDebug.Checked, cbxOrPgBrk.Checked,
frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked, cbxOrPgBrk.Checked,
cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text, new Point(Left, Bottom - 50),
swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd);//C2018-009 print PROMS version
frmStatus.CloseWhenDone = true;
@@ -746,7 +792,7 @@ namespace VEPROMS
if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! {0} | {1}", MyProcedure.DisplayNumber, MyProcedure.DisplayText);
ProfileTimer.Pop(profileDepth1);
// B2016-249 Output Procedure to folder associated with Parent Child
frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, pw.ToString(), cbxDebug.Checked,
frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked,
cbxOrPgBrk.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text,
new Point(Left, Bottom - 50), swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd);//C2018-009 print PROMS version
frmStatus.CloseWhenDone = true;
@@ -847,7 +893,12 @@ namespace VEPROMS
Volian.Print.Library.Rtf2Pdf.PdfDebug = cbxDebug.Checked;
// B2019-044 don't print the watermark if the watermark switch on the print dialog is turned off
cbxWaterMark.Visible = true;
string waterMarkText = (swtbtnWaterMark.Value) ? cbxWaterMark.Text : "None" ; // B2018-124 use text of watermark form drop down list instead of enum value
ProcedureConfig procConfig = MyProcedure.MyConfig as ProcedureConfig;
string waterMarkTextOverride = "";
if (procConfig != null) waterMarkTextOverride = procConfig.GetValue("PSI", "WATERMARKOVERRIDE"); // C2021-019: override watermark text
if (swtbtnWaterMark.Value && waterMarkTextOverride != null && waterMarkTextOverride != "") waterMarkText = waterMarkTextOverride;
// Determine change bar settings. First get from config & then see if override from dialog.
// Also check that format allows override.
ChangeBarDefinition cbd = DetermineChangeBarSettings();
+31
View File
@@ -16,11 +16,13 @@ namespace VEPROMS
private StepTabRibbon _MyStepTabRibbon;
private Dictionary<string, StepRTB> _DicStepRtb;
private Dictionary<string, CheckBox> _DicCheckBox;
private Dictionary<string, ComboBox> _DicComboBox;
public frmPSI(ProcedureInfo pi)
{
InitializeComponent();
_DicStepRtb = new Dictionary<string, StepRTB>();
_DicCheckBox = new Dictionary<string, CheckBox>();
_DicComboBox = new Dictionary<string, ComboBox>();
InitializeSpecificControls(pi);
_MyStepTabRibbon = new StepTabRibbon();
}
@@ -92,6 +94,23 @@ namespace VEPROMS
maxx = ((int)fld.x * 2 + (int)fld.width * 2) > maxx ? ((int)fld.x * 2 + (int)fld.width * 2) : maxx;
maxy = ((int)fld.y * 2 + (int)fld.height * 2) > maxy ? ((int)fld.y * 2 + (int)fld.height * 2) : maxy;
}
// C2021-019: override of watermark text/color - provide support for combo box in PSI dialog
if (fld.type.ToLower() == "combo")
{
ComboBox cmb = new ComboBox();
_DicComboBox.Add(fld.name, cmb);
cmb.Location = new Point((int)fld.x * 2, (int)fld.y * 2);
cmb.Visible = true;
cmb.Width = (int)fld.width * 2;
string tmp = fld.text;
string[] tmps = tmp.Split(",".ToCharArray());
foreach (string t in tmps) cmb.Items.Add(t);
string val = procConfig.GetValue("PSI", fld.name);
if (val != null && val != "") cmb.SelectedItem = val;
this.panelPSI.Controls.Add(cmb);
maxx = ((int)fld.x * 2 + (int)fld.width * 2) > maxx ? ((int)fld.x * 2 + (int)fld.width * 2) : maxx;
maxy = ((int)fld.y * 2 + (int)fld.height * 2) > maxy ? ((int)fld.y * 2 + (int)fld.height * 2) : maxy;
}
}
if (maxx > xB4Scroll)
{
@@ -163,6 +182,18 @@ namespace VEPROMS
procConfig.SetValue("PSI", fld.name, newval);
}
}
// C2021-019: override of watermark text/color - save combo box selection
else if (fld.type.ToLower() == "combo")
{
ComboBox cmbcur = _DicComboBox[fld.name];
string newval = cmbcur.Text;
string oldval = procConfig.GetValue("PSI", fld.name);
if (newval != oldval)
{
isDirty = true;
procConfig.SetValue("PSI", fld.name, newval);
}
}
}
if (isDirty)
{
@@ -817,6 +817,12 @@ namespace Volian.Print.Library
get { return _AllowAllWatermarks; }
set { _AllowAllWatermarks = value; }
}
private string _WatermarkOverrideColor = "BLUE"; // C2021-019: Override watermark color
public string WatermarkOverrideColor
{
get { return _WatermarkOverrideColor; }
set { _WatermarkOverrideColor = value; }
}
//private PdfReader readerWord;
private string PrintProcedureOrFoldout(ProcedureInfo myProcedure, SectionInfo myFoldoutSection, string outputFileName, bool makePlacekeeper, bool makeContinuousActionSummary)
{
@@ -875,6 +881,13 @@ namespace Volian.Print.Library
string LastFmtName = null;
int lastDocStyle = -1;
bool firstStepSec = true;
// C2021-019: Override the watermark color, stored in the PSI - color list set as combobox in PSI with list of colors
ProcedureConfig pc = myProcedure.MyConfig as ProcedureConfig;
if (pc != null)
{
string clr = pc.GetValue("PSI", "WATERMARKOVERRIDECLR");
if (clr != null && clr != "") WatermarkOverrideColor = clr.ToUpper().Contains("DEFAULT") ? "BLUE" : clr;
}
foreach (SectionInfo mySection in myProcedure.Sections)
{
// B2020-115 Calculate maximum available space on a page for figures
@@ -950,6 +963,7 @@ namespace Volian.Print.Library
//_MyHelper.DoZoomOMatic = DebugOutput;
_MyHelper.OriginalPageBreak = OriginalPageBreak;
_MyHelper.PROMSVersion = _PromsVersion; //C2018-009 print PROMS version
_MyHelper.WatermarkColor = WatermarkOverrideColor; // C2021-019: save the override for the watermark color
OnStatusChanged("After Set PageEvent", PromsPrinterStatusType.SetPageEvent);
}
else
+15 -6
View File
@@ -942,6 +942,12 @@ namespace Volian.Svg.Library
get { return _Watermark; }
set { _Watermark = value; }
}
private string _WatermarkColor = "BLUE";
public string WatermarkColor
{
get { return _WatermarkColor; }
set { _WatermarkColor = value; }
}
private PdfLayer _PROMSVersionLayer; //C2018-009 print PROMS version
public PdfLayer PROMSVersionLayer
{
@@ -1136,7 +1142,7 @@ namespace Volian.Svg.Library
System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix((float)Math.Cos(a), (float)Math.Sin(a), (float)-Math.Sin(a), (float)Math.Cos(a), 0, cb.PdfDocument.PageSize.Height);
cb.Transform(myMatrix);
}
SvgWatermark myWatermark = new SvgWatermark(cb, Watermark, System.Drawing.Color.Blue, .15F);
SvgWatermark myWatermark = new SvgWatermark(cb, Watermark, System.Drawing.Color.FromName(WatermarkColor), .15F);
//myWatermark.SetSquareDotPattern(.7F);
myWatermark.Draw();
if (_WatermarkLayer != null) cb.EndLayer();
@@ -1211,7 +1217,7 @@ namespace Volian.Svg.Library
{
private PdfContentByte _ContentByte;
private string _Text;
private Color _Color;
private System.Drawing.Color _Color;
private PdfPatternPainter _PatternPainter;
private BaseFont _Basefont;
private float _Fontsize;
@@ -1225,11 +1231,12 @@ namespace Volian.Svg.Library
_Text = text;
//float radius = .5F;
//float space = 3;
_Color = new Color(color);
_Color = color; // C2021-019: save color for color override
_Opacity = opacity;
//SetDotPattern(radius, space);
//SetTextLayout();
}
#region commentedout
//private void SetTextLayout()
//{
// Rectangle pageSize = _ContentByte.PdfWriter.PageSize; // Get page size
@@ -1316,6 +1323,7 @@ namespace Volian.Svg.Library
// _PatternPainter.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _Text, wid, hgtA, 0);
// _PatternPainter.EndText();
//}
#endregion
public void Draw()
{
_ContentByte.SaveState();
@@ -1364,10 +1372,11 @@ namespace Volian.Svg.Library
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gp.AddString(msg, fnt.FontFamily, 0, fntSize, new System.Drawing.PointF(-bnds.X, -bnds.Y),
System.Drawing.StringFormat.GenericTypographic);
System.Drawing.Drawing2D.HatchBrush aHatchBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent25, System.Drawing.Color.FromArgb(64,
System.Drawing.Color.Blue), System.Drawing.Color.Transparent);
// C2021-019: allow setting of watermark color
System.Drawing.Drawing2D.HatchBrush aHatchBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent25,
_Color, System.Drawing.Color.Transparent);
g.FillPath(aHatchBrush, gp);
g.DrawPath(new System.Drawing.Pen(System.Drawing.Color.FromArgb(96, System.Drawing.Color.Blue)), gp);
g.DrawPath(new System.Drawing.Pen(_Color), gp);
//g.DrawRectangle(System.Drawing.Pens.Cyan, 0, 0, bnds.Width, bnds.Height);
}
_WatermarkImage = iTextSharp.text.Image.GetInstance(bmp, System.Drawing.Imaging.ImageFormat.Png);