From 4c0fed9dceb68bd30c0761a31a55317dd83009b5 Mon Sep 17 00:00:00 2001 From: Rich Date: Sat, 12 Sep 2015 15:49:37 +0000 Subject: [PATCH] Added Enhanced Document Menus SetAdministrator Support for Import and Export Procedure Sets, Import Procedure, Export Procedure Added ROID PDF Destinations to Complete RO Report so that PDF Links can go to a specific Refenced Object in the Complete RO Report PDF. Add PDF Links for Enhanced Documents and Complete RO Report --- .../Volian.Controls.Library/StepTabRibbon.cs | 120 +++++++++++++++++- PROMS/Volian.Controls.Library/vlnTreeView.cs | 12 +- PROMS/Volian.Print.Library/CompleteRORpt.cs | 27 ++++ PROMS/Volian.Print.Library/vlnParagraph.cs | 41 +++++- 4 files changed, 192 insertions(+), 8 deletions(-) diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index bd524525..b169e968 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -121,10 +121,118 @@ namespace Volian.Controls.Library private Dictionary MyAvailableROs; public void SetContextMenu() { + AddEnhancedDocumentMenu(btnCMRtfEdit); AddWROContext(btnCMRtfEdit); _ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit); } + private void AddEnhancedDocumentMenu(DevComponents.DotNetBar.ButtonItem myButtonItem) + { + DevComponents.DotNetBar.BaseItem btnSourceToBackground = null; + DevComponents.DotNetBar.BaseItem btnBackgroundToSource = null; + DevComponents.DotNetBar.BaseItem btnSourceToDeviation = null; + DevComponents.DotNetBar.BaseItem btnDeviationToSource = null; + #region background + if (!myButtonItem.SubItems.Contains("btnSourceToBackground")) + { + btnSourceToBackground = new DevComponents.DotNetBar.ButtonItem("btnSourceToBackground", "Go To Background Document"); + btnSourceToBackground.Visible = false; + btnSourceToBackground.Click += btnSourceToBackground_Click; + myButtonItem.SubItems.Add(btnSourceToBackground); + } + else + btnSourceToBackground = myButtonItem.SubItems["btnSourceToBackground"]; + if (!myButtonItem.SubItems.Contains("btnBackgroundToSource")) + { + btnBackgroundToSource = new DevComponents.DotNetBar.ButtonItem("btnBackgroundToSource", "Go To Source Document"); + btnBackgroundToSource.Visible = false; + btnBackgroundToSource.Click += btnBackgroundToSource_Click; + myButtonItem.SubItems.Add(btnBackgroundToSource); + } + else + btnBackgroundToSource = myButtonItem.SubItems["btnBackgroundToSource"]; + StepConfig sc = new StepConfig(_MyStepRTB.MyItemInfo.MyContent.Config); + if (sc.Step_SourceToBackground != null) + { + btnSourceToBackground.Tag = sc.Step_SourceToBackground; + btnSourceToBackground.Visible = true; + } + else + { + btnSourceToBackground.Tag = string.Empty; + btnSourceToBackground.Visible = false; + } + if (sc.Step_BackgroundToSource != null) + { + btnBackgroundToSource.Tag = sc.Step_BackgroundToSource; + btnBackgroundToSource.Visible = true; + } + else + { + btnBackgroundToSource.Tag = string.Empty; + btnBackgroundToSource.Visible = false; + } + #endregion + #region deviation + if (!myButtonItem.SubItems.Contains("btnSourceToDeviation")) + { + btnSourceToDeviation = new DevComponents.DotNetBar.ButtonItem("btnSourceToDeviation", "Go To Deviation Document"); + btnSourceToDeviation.Visible = false; + btnSourceToDeviation.Click += btnSourceToBackground_Click; + myButtonItem.SubItems.Add(btnSourceToDeviation); + } + else + btnSourceToDeviation = myButtonItem.SubItems["btnSourceToDeviation"]; + if (!myButtonItem.SubItems.Contains("btnDeviationToSource")) + { + btnDeviationToSource = new DevComponents.DotNetBar.ButtonItem("btnDeviationToSource", "Go To Source Document"); + btnDeviationToSource.Visible = false; + btnDeviationToSource.Click += btnBackgroundToSource_Click; + myButtonItem.SubItems.Add(btnDeviationToSource); + } + else + btnDeviationToSource = myButtonItem.SubItems["btnDeviationToSource"]; + if (sc.Step_SourceToDeviation != null) + { + btnSourceToDeviation.Tag = sc.Step_SourceToDeviation; + btnSourceToDeviation.Visible = true; + } + else + { + btnSourceToDeviation.Tag = string.Empty; + btnSourceToDeviation.Visible = false; + } + if (sc.Step_DeviationToSource != null) + { + btnDeviationToSource.Tag = sc.Step_DeviationToSource; + btnDeviationToSource.Visible = true; + } + else + { + btnDeviationToSource.Tag = string.Empty; + btnDeviationToSource.Visible = false; + } + #endregion + } + + void btnBackgroundToSource_Click(object sender, EventArgs e) + { + DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem; + ItemInfo ii = ItemInfo.Get(int.Parse(btn.Tag.ToString())); + StepTabPanel tmp = Parent as StepTabPanel; + tmp.MyDisplayTabControl.OpenItem(ii); + } + + void btnSourceToBackground_Click(object sender, EventArgs e) + { + DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem; + ItemInfo ii = ItemInfo.Get(int.Parse(btn.Tag.ToString())); + //StepTabPanel tmp = Parent as StepTabPanel; + //tmp.MyDisplayTabControl.OpenItem(ii); +// OpenEnhancedDocument(this, new StepTabRibbonEventArgs(ii)); + MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(ii)); + } + #region set up save ro menu jcb 20121221 private void AddWROContext(DevComponents.DotNetBar.ButtonItem myButtonItem) { @@ -645,7 +753,12 @@ namespace Volian.Controls.Library } #endregion #region Events - + //public event StepTabRibbonEvent OpenEnhancedDocument; + //private void OnOpenEnhancedDocument(StepTabRibbonEventArgs args) + //{ + // if (OpenEnhancedDocument != null) + // OpenEnhancedDocument(this, args); + //} public event StepTabRibbonEvent PrintRequest; private void OnPrintRequest(StepTabRibbonEventArgs args) { @@ -1921,6 +2034,11 @@ namespace Volian.Controls.Library btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View; MyEditItem.MyStepRTB.SpellCheckContextMenuOn(MyEditItem.MyStepPanel.VwMode != E_ViewMode.View); } + //private void btnEnhancedDocSync_Click(object sender, System.EventArgs e) + //{ + // btnEnhancedDocSync.Checked = !btnEnhancedDocSync.Checked; + //} + private void btnROEdit_Click(object sender, EventArgs e) { diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index 871cf09f..be7e75a3 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -21,7 +21,7 @@ namespace Volian.Controls.Library public delegate void vlnTreeViewEvent(object sender, vlnTreeEventArgs args); public delegate void vlnTreeViewTimeEvent(object sender, vlnTreeTimeEventArgs args); public delegate void vlnTreeViewStatusEvent(object sender, vlnTreeStatusEventArgs args); - public delegate ItemInfo vlnTreeViewClipboardStatusEvent(object sender, vlnTreeEventArgs args); + public delegate ItemInfo vlnTreeViewClipboardStatusEvent(object sender, vlnTreeEventArgs args); public delegate void vlnTreeViewItemInfoEvent(object sender, vlnTreeItemInfoEventArgs args); public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args); public delegate bool vlnTreeViewItemInfoDeleteEvent(object sender, vlnTreeItemInfoEventArgs args); @@ -606,7 +606,7 @@ namespace Volian.Controls.Library // add docversion. FolderInfo fi = tn.VEObject as FolderInfo; bool DoSpecificInfo = fi.ActiveFormat.PlantFormat.FormatData.SpecificInfo; - if (ui.IsAdministrator())// && fi.MyParent == null) //VEPROMS level + if (ui.IsAdministrator() || ui.IsSetAdministrator(fi))// && fi.MyParent == null) //VEPROMS level { if(fi.HasWorkingDraft) cm.MenuItems.Add("Export Procedure Set", new EventHandler(mi_Click)); @@ -632,7 +632,7 @@ namespace Volian.Controls.Library else if (tn.VEObject as DocVersionInfo != null) // DocVersions can only contain procs { DocVersionInfo dvi = tn.VEObject as DocVersionInfo; - if (ui.IsAdministrator()) + if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi)) { cm.MenuItems.Add("Import Procedure", mi_Click); } @@ -725,7 +725,7 @@ namespace Volian.Controls.Library { ProcedureInfo pri = tn.VEObject as ProcedureInfo; oi = OwnerInfo.GetByItemID(pri.ItemID, CheckOutType.Procedure); - if (ui.IsAdministrator()) + if (ui.IsAdministrator() || ui.IsSetAdministrator(pri.MyDocVersion)) { cm.MenuItems.Add("Export Procedure", mi_Click); } @@ -2012,7 +2012,7 @@ namespace Volian.Controls.Library if (!hasMetaSubs) doPseudo = true; } } - using (Section section = CreateNewSection()) + using(Section section = CreateNewSection()) { ShowBrokenRules(section.BrokenRulesCollection); SetLastValues(SectionInfo.Get(section.ItemID)); @@ -2095,7 +2095,7 @@ namespace Volian.Controls.Library int indx = tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1); if (indx >= par.Nodes.Count || (par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString()) { - tn = new VETreeNode(_LastSectionInfo); + tn = new VETreeNode(_LastSectionInfo); par.Nodes.Insert(indx, tn); } } diff --git a/PROMS/Volian.Print.Library/CompleteRORpt.cs b/PROMS/Volian.Print.Library/CompleteRORpt.cs index 3010c031..a2844bcb 100644 --- a/PROMS/Volian.Print.Library/CompleteRORpt.cs +++ b/PROMS/Volian.Print.Library/CompleteRORpt.cs @@ -375,6 +375,12 @@ namespace Volian.Print.Library } private string processingRO = ""; + private string _MyROID = null; + public string MyROID + { + get { return _MyROID; } + set { _MyROID = value; } + } public void PrintReport() { @@ -416,6 +422,9 @@ namespace Volian.Print.Library case 7: processingRO = KeyField(); break; + case 8: + MyROID = ROIDField(); + break; case 100: // Text Field - sometimes also XY Plot Text(); Application.DoEvents(); @@ -825,6 +834,12 @@ namespace Volian.Print.Library Chunk chk = LastHeader(); Phrase p = new Phrase(); PdfPCell cell = new PdfPCell(); + if (MyROID != null) + { + chk.SetLocalDestination(string.Format("ROID={0}", MyROID)); // Destination + //Console.WriteLine("\"ROID\"\t\"{0}\"", MyROID); + MyROID = null; + } p.Add(chk); // add the header chunk cell.BackgroundColor = Color.WHITE; cell.BorderColor = Color.WHITE; @@ -880,6 +895,18 @@ namespace Volian.Print.Library //Console.WriteLine("Key Text: {0}", szStr); //Console.WriteLine("----------------------------------------------"); } + public string ROIDField() + { + // use the key field as the PDF bookbark + string szStr = RO_df.ReadText(); + //PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); + //PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr); + //DestSample(outl); + return szStr; + //Console.WriteLine("Key Field"); + //Console.WriteLine("Key Text: {0}", szStr); + //Console.WriteLine("----------------------------------------------"); + } // Read in the image filename, height, and width public void ImageFile() diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 93d3f638..883301d2 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -943,14 +943,28 @@ namespace Volian.Print.Library } } else // Remote Go To + { foreach (Chunk chk in IParagraph.Chunks) { //Console.WriteLine("\"RemoteGoTo\"\t{0}", tiDefault.ItemID); chk.SetRemoteGoto(ti.MyItemToID.MyProcedure.DisplayNumber.Replace("/", "_") + ".pdf", string.Format("ItemID={0}", tiDefault.ItemID)); chk.SetBackground(new Color(System.Drawing.Color.PeachPuff)); } + } } - // MyPageHelper.BottomContent = yLocation - Height; + if (MyItemInfo.MyContent.ContentRoUsageCount > 0) + { + RoUsageInfo ru = MyItemInfo.MyContent.ContentRoUsages[0]; + foreach (Chunk chk in IParagraph.Chunks) + { + chk.SetRemoteGoto("completeroreport.pdf", string.Format("ROID={0}", ru.ROID.Substring(0, 12))); + chk.SetBackground(new Color(System.Drawing.Color.LightGreen)); + } + } + StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config); + AddLinkToEnhancedDocument(cb, yLocation, sc.Step_SourceToBackground, "B", 6); + AddLinkToEnhancedDocument(cb, yLocation, sc.Step_SourceToDeviation, "D", 20); + // MyPageHelper.BottomContent = yLocation - Height; //if (MyItemInfo.InList(39048)) Console.WriteLine("Here"); } MyPageHelper.BottomContent = yLocation - (Height * MyPageHelper.YMultiplier); @@ -983,6 +997,31 @@ namespace Volian.Print.Library } return retval; } + private static void AddLinkToEnhancedDocument(PdfContentByte cb, float yLocation, string bdItemID, String token, int xLocation) + { + if (bdItemID != null) + { + int i = int.Parse(bdItemID); + ItemInfo ii = ItemInfo.Get(i); + string prefix = ii.MyDocVersion.DocVersionConfig.Print_PDFFilePrefix ?? ""; + string suffix = ii.MyDocVersion.DocVersionConfig.Print_PDFFileSuffix ?? ""; + ColumnText ct = new ColumnText(cb); + ct.SetSimpleColumn(xLocation, yLocation - 12, xLocation + 30, 12 + yLocation); + iTextSharp.text.Font font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12); + Chunk chk = new Chunk(token); + chk.SetRemoteGoto(prefix + ii.MyProcedure.DisplayNumber.Replace("/", "_") + suffix + ".pdf", string.Format("ItemID={0}", ii.ItemID)); + chk.SetBackground(new Color(System.Drawing.Color.LemonChiffon)); + ct.AddElement(chk); + cb.SetColorFill(Color.BLUE); + ct.Go(); + + //foreach (Chunk chk in IParagraph.Chunks) + //{ + // chk.SetRemoteGoto(ii.MyProcedure.DisplayNumber.Replace("/", "_") + ".pdf", string.Format("ItemID={0}",ii.ItemID)); + // chk.SetBackground(new Color(System.Drawing.Color.LemonChiffon)); + //} + } + } private ItemInfo GetDefaultItemInfo(ItemInfo myItemInfo) {