private void ProcessPrintFullPanto(Step step) { if (step != Step.Next && step != Step.Back) //invalid { return; } if (step == Step.Back) { state = P2WizardState.FailReason; return; } #if !Print state = P2WizardState.IsValidPanto; return; #endif Dot bg = GetDot((int)nudPageNumberBG.Value, (int)nudDarknessBG.Value, txtCellBG.Text, "BG"); if (bg == null) { MessageBox.Show("You have entered an invalid page number or cell index. Please correct and try again"); return; } if (CurrentFG == null) { CurrentFG = Cartesian.First(); } byte[] data = bg.GetBytes(true); byte[] dataFg = CurrentFG.GetBytes(true); //MessageBox.Show("TODO - Print pantograph based on entered cell"); CustomConfiguration cc = new CustomConfiguration(); //Using interference pattern? if (!string.IsNullOrEmpty(IntfFontPath)) { //Set the interference enabled bit and chessboard bit cc.PantographConfiguration = "257"; } else { //Set only the chessboard bit cc.PantographConfiguration = "1"; IntfFontPath = Application.StartupPath; //TBD Temporary until I fix the panto builder. Does not like a blank string. } cc.PageOrientation = PageOrientationType.poPortrait; cc.PageType = PageType.ptLetter; cc.UseDefaultInclusionForPaperSize = true; cc.InterferencePatternId = 20; cc.CellList.Clear(); //Create a cell with the text COPY and id = 10 PantographCellDescriptorType pcdt = new PantographCellDescriptorType(); pcdt.msg = "COPY"; pcdt.pidx = 10; cc.CellList.Add(pcdt); //Set the custom pattern cc.CustomBackgroundPatternData = data; //TBD use real foreground cc.CustomForegroundPatternData = dataFg; //Create the full page pantograph string filename = "PantographProfile1Page1.pcl"; var xser = new XmlSerializer(typeof(CustomConfiguration)); string cfilename = IntfFontPath + "TroyPantographConfiguration.xml"; var writer = new StreamWriter(cfilename); xser.Serialize(writer, cc); var bp = new BuildPantographWrap.Wrapper(); int rc = bp.ManagedCreatePantograph(IntfFontPath); //Print the pantograph file PrinterLib.PrintToSpooler.SendFileToPrinter(PrinterName, filename, "Test"); //TBD Temporary kluge to make the other temporary kluge work properly if (cc.PantographConfiguration == "1") { IntfFontPath = ""; } state = P2WizardState.IsValidPanto; }
private bool SaveSettings() { PantographConfiguration pc = new PantographConfiguration(); for (int cntr = 0; cntr < 4; cntr++) { CustomConfiguration tempcc; if (PConfigs.PantographConfigurations.Count < cntr + 1) { tempcc = new CustomConfiguration(); } else { tempcc = PConfigs.PantographConfigurations[cntr]; } if (cntr == 0) { tempcc.BorderString = txtBorderTxt1.Text; tempcc.UseDynamicMp = chkDynamicMp1.Checked; tempcc.CellList.Clear(); for (int cntr1 = 0; cntr1 < 10; cntr1++) { if (Globals.CellSetups[0, cntr1].PatternEnabled) { PantographCellDescriptorType pcdt = new PantographCellDescriptorType(); pcdt.pidx = cntr1 + 1; pcdt.msg = Globals.CellSetups[0, cntr1].CellText; tempcc.CellList.Add(pcdt); } } if (!string.IsNullOrEmpty(Globals.CustomPatternName[0])) { tempcc.CustomPatternName = Globals.CustomPatternName[0]; foreach (TroyPatterns tp in Globals.customPatterns.TroyStoredPattern) { if (tp.StoredPatternName == Globals.CustomPatternName[0]) { tempcc.CustomBackgroundPatternData = tp.BackgroundPattern; tempcc.CustomForegroundPatternData = tp.ForegroundPattern; } } } tempcc.ExclusionRegions.Clear(); foreach (string str in lstExclusions1.Items) { int XInd = str.IndexOf("XAnchor:"); int YInd = str.IndexOf("YAnchor:"); int WInd = str.IndexOf("Width:"); int HInd = str.IndexOf("Height:"); if ((XInd > -1) && (YInd > -1) && (WInd > -1) && (HInd > -1)) { PantographRegionObjectType exc = new PantographRegionObjectType(); string temp = str.Substring(XInd + 9, YInd - (XInd + 9)); exc.XAnchor = Convert.ToInt32(temp); temp = str.Substring(YInd + 9, WInd - (YInd + 9)); exc.YAnchor = Convert.ToInt32(temp); temp = str.Substring(WInd + 7, HInd - (WInd + 7)); exc.Width = Convert.ToInt32(temp); temp = str.Substring(HInd + 8); exc.Height = Convert.ToInt32(temp); tempcc.ExclusionRegions.Add(exc); } } tempcc.UseDefaultInclusionForPaperSize = chkUseDefaultInclusion1.Checked; if (!chkUseDefaultInclusion1.Checked) { if (txtInclX1.Text != "") { if (tempcc.InclusionRegion == null) { tempcc.InclusionRegion = new PantographRegionObjectType(); } tempcc.InclusionRegion.XAnchor = Convert.ToInt32(txtInclX1.Text); tempcc.InclusionRegion.YAnchor = Convert.ToInt32(txtInclY1.Text); tempcc.InclusionRegion.Width = Convert.ToInt32(txtInclW1.Text); tempcc.InclusionRegion.Height = Convert.ToInt32(txtInclH1.Text); } } tempcc.InterferencePatternId = Convert.ToInt32(numIPtrn1.Value); tempcc.PantographColor = (PantographColorType) Enum.Parse(typeof(PantographColorType), "pg" + cboColor1.Text); tempcc.PageOrientation = masterPO; tempcc.PageType = masterPT; tempcc.PantographConfiguration = txtPConfig1.Text; if (radDynamicData1.Checked) { tempcc.UseDynamicTmMsg = true; tempcc.TROYmarkOn = true; } else if (radStaticData1.Checked) { tempcc.UseDynamicTmMsg = false; tempcc.TROYmarkOn = true; } else { tempcc.UseDynamicTmMsg = false; tempcc.TROYmarkOn = false; } tempcc.WarningBoxString = WbStrings[1]; } else if (cntr == 1) { tempcc.BorderString = txtBorderTxt2.Text; tempcc.UseDynamicMp = chkDynamicMp2.Checked; tempcc.CellList.Clear(); for (int cntr1 = 0; cntr1 < 10; cntr1++) { if (Globals.CellSetups[1, cntr1].PatternEnabled) { PantographCellDescriptorType pcdt = new PantographCellDescriptorType(); pcdt.pidx = cntr1 + 1; pcdt.msg = Globals.CellSetups[1, cntr1].CellText; tempcc.CellList.Add(pcdt); } } if (!string.IsNullOrEmpty(Globals.CustomPatternName[1])) { foreach (TroyPatterns tp in Globals.customPatterns.TroyStoredPattern) { if (tp.StoredPatternName == Globals.CustomPatternName[1]) { tempcc.CustomBackgroundPatternData = tp.BackgroundPattern; tempcc.CustomForegroundPatternData = tp.ForegroundPattern; } } } tempcc.ExclusionRegions.Clear(); foreach (string str in lstExclusions2.Items) { int XInd = str.IndexOf("XAnchor:"); int YInd = str.IndexOf("YAnchor:"); int WInd = str.IndexOf("Width:"); int HInd = str.IndexOf("Height:"); if ((XInd > -1) && (YInd > -1) && (WInd > -1) && (HInd > -1)) { PantographRegionObjectType exc = new PantographRegionObjectType(); string temp = str.Substring(XInd + 9, YInd - (XInd + 9)); exc.XAnchor = Convert.ToInt32(temp); temp = str.Substring(YInd + 9, WInd - (YInd + 9)); exc.YAnchor = Convert.ToInt32(temp); temp = str.Substring(WInd + 7, HInd - (WInd + 7)); exc.Width = Convert.ToInt32(temp); temp = str.Substring(HInd + 8); exc.Height = Convert.ToInt32(temp); tempcc.ExclusionRegions.Add(exc); } } tempcc.UseDefaultInclusionForPaperSize = chkUseDefaultInclusion2.Checked; if (!chkUseDefaultInclusion2.Checked) { if (txtInclX2.Text != "") { if (tempcc.InclusionRegion == null) { tempcc.InclusionRegion = new PantographRegionObjectType(); } tempcc.InclusionRegion.XAnchor = Convert.ToInt32(txtInclX2.Text); tempcc.InclusionRegion.YAnchor = Convert.ToInt32(txtInclY2.Text); tempcc.InclusionRegion.Width = Convert.ToInt32(txtInclW2.Text); tempcc.InclusionRegion.Height = Convert.ToInt32(txtInclH2.Text); } } tempcc.InterferencePatternId = Convert.ToInt32(numIPtrn2.Value); tempcc.PantographColor = (PantographColorType) Enum.Parse(typeof(PantographColorType), "pg" + cboColor2.Text); tempcc.PageOrientation = masterPO; tempcc.PageType = masterPT; tempcc.PantographConfiguration = txtPConfig2.Text; if (radDynamicData2.Checked) { tempcc.UseDynamicTmMsg = true; tempcc.TROYmarkOn = true; } else if (radStaticData2.Checked) { tempcc.UseDynamicTmMsg = false; tempcc.TROYmarkOn = true; } else { tempcc.UseDynamicTmMsg = false; tempcc.TROYmarkOn = false; } tempcc.WarningBoxString = WbStrings[2]; } else if (cntr == 2) { tempcc.BorderString = txtBorderTxt3.Text; tempcc.UseDynamicMp = chkDynamicMp3.Checked; tempcc.CellList.Clear(); for (int cntr1 = 0; cntr1 < 10; cntr1++) { if (Globals.CellSetups[2, cntr1].PatternEnabled) { PantographCellDescriptorType pcdt = new PantographCellDescriptorType(); pcdt.pidx = cntr1 + 1; pcdt.msg = Globals.CellSetups[2, cntr1].CellText; tempcc.CellList.Add(pcdt); } } if (!string.IsNullOrEmpty(Globals.CustomPatternName[2])) { foreach (TroyPatterns tp in Globals.customPatterns.TroyStoredPattern) { if (tp.StoredPatternName == Globals.CustomPatternName[2]) { tempcc.CustomBackgroundPatternData = tp.BackgroundPattern; tempcc.CustomForegroundPatternData = tp.ForegroundPattern; } } } tempcc.ExclusionRegions.Clear(); foreach (string str in lstExclusions3.Items) { int XInd = str.IndexOf("XAnchor:"); int YInd = str.IndexOf("YAnchor:"); int WInd = str.IndexOf("Width:"); int HInd = str.IndexOf("Height:"); if ((XInd > -1) && (YInd > -1) && (WInd > -1) && (HInd > -1)) { PantographRegionObjectType exc = new PantographRegionObjectType(); string temp = str.Substring(XInd + 9, YInd - (XInd + 9)); exc.XAnchor = Convert.ToInt32(temp); temp = str.Substring(YInd + 9, WInd - (YInd + 9)); exc.YAnchor = Convert.ToInt32(temp); temp = str.Substring(WInd + 7, HInd - (WInd + 7)); exc.Width = Convert.ToInt32(temp); temp = str.Substring(HInd + 8); exc.Height = Convert.ToInt32(temp); tempcc.ExclusionRegions.Add(exc); } } tempcc.UseDefaultInclusionForPaperSize = chkUseDefaultInclusion3.Checked; if (!chkUseDefaultInclusion3.Checked) { if (txtInclX3.Text != "") { if (tempcc.InclusionRegion == null) { tempcc.InclusionRegion = new PantographRegionObjectType(); } tempcc.InclusionRegion.XAnchor = Convert.ToInt32(txtInclX3.Text); tempcc.InclusionRegion.YAnchor = Convert.ToInt32(txtInclY3.Text); tempcc.InclusionRegion.Width = Convert.ToInt32(txtInclW3.Text); tempcc.InclusionRegion.Height = Convert.ToInt32(txtInclH3.Text); } } tempcc.InterferencePatternId = Convert.ToInt32(numIPtrn3.Value); tempcc.PantographColor = (PantographColorType) Enum.Parse(typeof(PantographColorType), "pg" + cboColor3.Text); tempcc.PageOrientation = masterPO; tempcc.PageType = masterPT; tempcc.PantographConfiguration = txtPConfig3.Text; if (radDynamicData3.Checked) { tempcc.UseDynamicTmMsg = true; tempcc.TROYmarkOn = true; } else if (radStaticData3.Checked) { tempcc.UseDynamicTmMsg = false; tempcc.TROYmarkOn = true; } else { tempcc.UseDynamicTmMsg = false; tempcc.TROYmarkOn = false; } tempcc.WarningBoxString = WbStrings[3]; } else if (cntr == 3) { tempcc.BorderString = txtBorderTxt4.Text; tempcc.UseDynamicMp = chkDynamicMp4.Checked; tempcc.CellList.Clear(); for (int cntr1 = 0; cntr1 < 10; cntr1++) { if (Globals.CellSetups[3, cntr1].PatternEnabled) { PantographCellDescriptorType pcdt = new PantographCellDescriptorType(); pcdt.pidx = cntr1 + 1; pcdt.msg = Globals.CellSetups[3, cntr1].CellText; tempcc.CellList.Add(pcdt); } } if (!string.IsNullOrEmpty(Globals.CustomPatternName[3])) { foreach (TroyPatterns tp in Globals.customPatterns.TroyStoredPattern) { if (tp.StoredPatternName == Globals.CustomPatternName[3]) { tempcc.CustomBackgroundPatternData = tp.BackgroundPattern; tempcc.CustomForegroundPatternData = tp.ForegroundPattern; } } } tempcc.ExclusionRegions.Clear(); foreach (string str in lstExclusions4.Items) { int XInd = str.IndexOf("XAnchor:"); int YInd = str.IndexOf("YAnchor:"); int WInd = str.IndexOf("Width:"); int HInd = str.IndexOf("Height:"); if ((XInd > -1) && (YInd > -1) && (WInd > -1) && (HInd > -1)) { PantographRegionObjectType exc = new PantographRegionObjectType(); string temp = str.Substring(XInd + 9, YInd - (XInd + 9)); exc.XAnchor = Convert.ToInt32(temp); temp = str.Substring(YInd + 9, WInd - (YInd + 9)); exc.YAnchor = Convert.ToInt32(temp); temp = str.Substring(WInd + 7, HInd - (WInd + 7)); exc.Width = Convert.ToInt32(temp); temp = str.Substring(HInd + 8); exc.Height = Convert.ToInt32(temp); tempcc.ExclusionRegions.Add(exc); } } tempcc.UseDefaultInclusionForPaperSize = chkUseDefaultInclusion4.Checked; if (!chkUseDefaultInclusion4.Checked) { if (txtInclX4.Text != "") { if (tempcc.InclusionRegion == null) { tempcc.InclusionRegion = new PantographRegionObjectType(); } tempcc.InclusionRegion.XAnchor = Convert.ToInt32(txtInclX4.Text); tempcc.InclusionRegion.YAnchor = Convert.ToInt32(txtInclY4.Text); tempcc.InclusionRegion.Width = Convert.ToInt32(txtInclW4.Text); tempcc.InclusionRegion.Height = Convert.ToInt32(txtInclH4.Text); } } tempcc.InterferencePatternId = Convert.ToInt32(numIPtrn4.Value); tempcc.PantographColor = (PantographColorType) Enum.Parse(typeof(PantographColorType), "pg" + cboColor4.Text); tempcc.PageOrientation = masterPO; tempcc.PageType = masterPT; tempcc.PantographConfiguration = txtPConfig4.Text; if (radDynamicData4.Checked) { tempcc.UseDynamicTmMsg = true; tempcc.TROYmarkOn = true; } else if (radStaticData4.Checked) { tempcc.UseDynamicTmMsg = false; tempcc.TROYmarkOn = true; } else { tempcc.UseDynamicTmMsg = false; tempcc.TROYmarkOn = false; } tempcc.WarningBoxString = WbStrings[4]; } if (tempcc != null) { pc.PantographConfigurations.Add(tempcc); } } if (pc.PantographConfigurations.Count > 3) { PConfigs = pc; } else { MessageBox.Show("Error saving pantograph configuration settings. ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } return(true); }