diff --git a/PROMS/Baseline/frmBaseline.cs b/PROMS/Baseline/frmBaseline.cs index d634f138..8551661e 100644 --- a/PROMS/Baseline/frmBaseline.cs +++ b/PROMS/Baseline/frmBaseline.cs @@ -456,7 +456,7 @@ namespace Baseline switch (myLast) { case LastWas.Pagination: - line = OpenPDF(line); + OpenPDF(line); break; case LastWas.Baseline: // TODO: Need to add code here to open matching file OpenOnePDF(myLine,1); @@ -479,7 +479,7 @@ namespace Baseline switch (myLast) { case LastWas.Pagination: - line = OpenPDF(line); + OpenPDF(line); break; case LastWas.Baseline: // TODO: Need to add code here to open matching file OpenOnePDF(myLine,2); @@ -491,34 +491,99 @@ namespace Baseline break; } } - string exePath; - private string OpenPDF(string line) + + /// + /// This will return the full path to the PDF file + /// + /// + /// + /// + private string GetPFDFileAndPath(FileInfo fi, string patern) { - int page = int.Parse(line.Substring(0, 6)); + string[] fileList = Directory.GetFiles(fi.DirectoryName, patern); + // sort the list of file list + Array.Sort((string[])fileList); + return fileList.First(); // the PDF file that we what should be top of the list then. + } + + /// + /// This will parse out the procedure number for the PROMS ShortPath representation of a procedure section or step part + /// In the PROMS ShortPath, ".S" is used to delimit the procedure number, section then uses "..S" for the step parts + /// This method was written to handle cases where ".S" is used as part of the procedure number + /// + /// + /// + private string ParseOutProcedureNumberFromLine(string txt) + { + // old logic was looking for the first occurence of ".S" in the txt string as the ending point of the procedure nuumber + // Beaver Valley has a procedure number "1.SBGEN" in which the old logic would not work + // 1.SBGEN.SC. ==> short path of attachment section "C" + // 1.SBGEN.SC..S1. ==> short path of Step 1 in attachment section "C" + string rtnstr = null; + int lidx = -1; + // if the item is to a high levels step or sub-step the short path as "..S" for each part of the step + // so look for the last occurence of ".." which will be the end of the section information + lidx = txt.LastIndexOf(".."); + if (lidx > 0) + { + lidx = txt.LastIndexOf(".S", lidx); // this will position us to the end of the procedure number + } + else + { + lidx = txt.LastIndexOf(".S"); // this will position us to the end of the procedure number if there was no step information + } // B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file. - line = line.Substring(8, line.IndexOf(".S") - 8).Replace("/", "_").Replace("\\", "_"); + rtnstr = txt.Substring(8, lidx - 8).Replace("/", "_").Replace("\\", "_"); + return rtnstr; + } + + string exePath; + private void OpenPDF(string line) + { + int pageNum = int.Parse(line.Substring(0, 6)); + // B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file. + string ProcNum = ParseOutProcedureNumberFromLine(line); + string procPatern = string.Format("*{0}*.pdf", string.IsNullOrEmpty(line) ? "noProcNumber" : ProcNum); + FindFile ff = lbDifferent.SelectedItem as FindFile; FileInfo fi1 = new FileInfo(ff.File1); FileInfo fi2 = new FileInfo(ff.File2); + string PDFfileName1 = GetPFDFileAndPath(fi1,procPatern); + string PDFfileName2 = GetPFDFileAndPath(fi2,procPatern); + if (string.IsNullOrEmpty(PDFfileName1) || string.IsNullOrEmpty(PDFfileName2)) return; + // If you don't know where the Reader executable is for PDFs Open a PDF and Check to see where the path points if (exePath == null) { - System.Diagnostics.Process p = System.Diagnostics.Process.Start(fi1.DirectoryName + "\\" + line + ".pdf"); - exePath = TryToGetPath(p); - p.Kill(); // No need to keep it open + try + { + System.Diagnostics.Process p = System.Diagnostics.Process.Start(PDFfileName1); + exePath = TryToGetPath(p); + p.Kill(); // No need to keep it open + } + catch (Exception ex) + { + Application.DoEvents(); + string msg = string.Format("{0} - {1}", ex.GetType().Name, ex.Message); + Console.WriteLine(msg); + MessageBox.Show(msg, "Error opening default PDF Viewer"); + return; + } } + // Open the first PDF on a Specific Page - System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A page={0} ", page) + fi1.DirectoryName + "\\" + line + ".pdf "); + System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format(" /A \"page={0}\" \"{1}\" ", pageNum,PDFfileName1)); System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(psi1); // Move the PDF Reader window to 0,0 MoveProcess(p1, 0, 0); - // Open the first PDF on a Specific Page - System.Diagnostics.ProcessStartInfo psi2 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A page={0} ", page) + fi2.DirectoryName + "\\" + line + ".pdf "); + + // Open the second PDF on a Specific Page + System.Diagnostics.ProcessStartInfo psi2 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format(" /A \"page={0}\" \"{1}\" ", pageNum, PDFfileName2)); System.Diagnostics.Process p2 = System.Diagnostics.Process.Start(psi2); // Move the PDF Reader window to 960,0 // TODO: This Offset could be a Setting MoveProcess(p2, 960, 0); - return line; + return; } /// /// Try to get the location of the PDF Reader executable @@ -530,7 +595,7 @@ namespace Baseline p.WaitForInputIdle(); while (p.MainModule == null) { - Console.WriteLine("{0} - {1}", p.MainWindowTitle,p.ProcessName); + Console.WriteLine("{0} - {1}", p.MainWindowTitle, p.ProcessName); p.WaitForInputIdle(); Application.DoEvents(); } @@ -594,40 +659,52 @@ namespace Baseline /// private void OpenOnePDF(Line myLine, int list) { + if (myLine == null) return; // no PDF to open // B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file. string proc = myLine.MyProc.Number.Replace("/","_").Replace("\\","_"); + + // if no procedure number, PROMS creates pdf filename "NoProcNumber.pdf" + // create pattern to use to get the PDF from the directory + // add wildcards (*) to file the file if any prefix or suffix was added to the filename + string procPatern = string.Format("*{0}*.pdf", proc == string.Empty ? "noProcNumber" : proc); int pagenum = myLine.MyPage.Number; FindFile ff = lbDifferent.SelectedItem as FindFile; - FileInfo fi1 = new FileInfo(ff.File1); - FileInfo fi2 = new FileInfo(ff.File2); - if (exePath == null) - { - System.Diagnostics.Process p = System.Diagnostics.Process.Start(fi1.DirectoryName + "\\" + proc + ".pdf"); - while (exePath == null) - { - try - { - - exePath = p.MainModule.FileName; - } - catch (Exception ex) - { - Application.DoEvents(); - Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message); - } - } - p.Kill(); - } + string PDFfileName = null; if (list == 1) { - System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A page={0} ", pagenum) + fi1.DirectoryName + "\\" + proc + ".pdf "); - System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(psi1); + FileInfo fi1 = new FileInfo(ff.File1); + PDFfileName = GetPFDFileAndPath(fi1, procPatern); } - else + else // list == 2 { - System.Diagnostics.ProcessStartInfo psi2 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A page={0} ", pagenum) + fi2.DirectoryName + "\\" + proc + ".pdf "); - System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(psi2); + FileInfo fi2 = new FileInfo(ff.File2); + PDFfileName = GetPFDFileAndPath(fi2, procPatern); } + if (string.IsNullOrEmpty(PDFfileName)) return; // no PDF to open + + // if exePath is null, then open the found PDF with the default PDF viewer and + // capture/save the entire name and path of the default PDF viewer + if (exePath == null) + { + try + { + System.Diagnostics.Process tp = System.Diagnostics.Process.Start(PDFfileName); + exePath = TryToGetPath(tp); + tp.Kill(); + } + catch (Exception ex) + { + Application.DoEvents(); + string msg = string.Format("{0} - {1}", ex.GetType().Name, ex.Message); + Console.WriteLine(msg); + MessageBox.Show(msg, "Error opening default PDF Viewer"); + return; + } + } + // open the PDF and jump to the page number + System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A \"page={0}\" \"{1}\" ", pagenum,PDFfileName)); + psi1.UseShellExecute = false; + System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(psi1); } /// /// Perform Debug Meta file comparison for all of the folders within the automated testing folders @@ -709,11 +786,12 @@ namespace Baseline private void lbProcedures_SelectedIndexChanged(object sender, EventArgs e) { //Initialize Results List Box - lbResults1.Items.Clear(); Procedure myProc = lbProcedures.SelectedItem as Procedure; + if (myProc == null) return; // clicked on the white space (blank line) in the list of different procedures //TODO: May need to consider if there are duplicate procedure numers and titles Procedure myProc1 = MyProcs1.Find(x => x.Number == myProc.Number && x.Title == myProc.Title); // Build the results ListBox for the left window + lbResults1.Items.Clear(); if (myProc1 != null) { foreach (Page myPage in myProc1.MyPages) diff --git a/PROMS/Formats/fmtall/VEGP1all.xml b/PROMS/Formats/fmtall/VEGP1all.xml index 09565922..3904e24a 100644 Binary files a/PROMS/Formats/fmtall/VEGP1all.xml and b/PROMS/Formats/fmtall/VEGP1all.xml differ diff --git a/PROMS/LBWordLibrary/LBObjectExtension.cs b/PROMS/LBWordLibrary/LBObjectExtension.cs index 139a52df..8af4c527 100644 --- a/PROMS/LBWordLibrary/LBObjectExtension.cs +++ b/PROMS/LBWordLibrary/LBObjectExtension.cs @@ -422,150 +422,6 @@ namespace LBWordLibrary return true; return false; } - /// - /// If document contains symbol characters, returns problem font. - /// - public string FontHasSymbolCharacters - { - get - { - LBRange myRange = Range(); - myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100); - myRange.Start = 0; - int end = myRange.End; - string myText = GetRangeText(myRange); - //return _RegFindSymbol.IsMatch(myText); - MatchCollection problems = _RegFindSymbol.Matches(myText); - int offset = 0; - List alreadyProcessed = new List(); - List fontHasSymbols = new List(); - foreach (Match problem in problems) - { - if (!alreadyProcessed.Contains(problem.Value)) - { - myRange.Start = problem.Index + offset; - myRange.End = problem.Index + problem.Length + offset; - int newOffset = FindRangeOffset(myRange, problem, offset, end); - string fontName = myRange.Font.Name; - if (IsSymbolFont(fontName)) - { - if( !fontHasSymbols.Contains(fontName)) - { - fontHasSymbols.Add(fontName); - // Found symbol font - _MyLog.InfoFormat("Font '{0}' has Symbols", fontName); - } - //Console.WriteLine("Font '{0}' has Symbols", myRange.Font.Name); - //return true; - } - else - return myRange.Font.Name; - offset = newOffset; - alreadyProcessed.Add(problem.Value); - } - } - return null; - } - } - /// - /// Debug Tool - Return a string containing a list of the fonts that have symbol characters. - /// - public string FontsHaveSymbolCharacters - { - get - { - string sep = ""; - StringBuilder sb = new StringBuilder(); - List fonts=new List(); - LBRange myRange = Range(); - myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100); - myRange.Start = 0; - int end = myRange.End; - string myText = GetRangeText(myRange); - //return _RegFindSymbol.IsMatch(myText); - MatchCollection problems = _RegFindSymbol.Matches(myText); - int offset = 0; - foreach (Match problem in problems) - { - myRange.Start = problem.Index + offset; - myRange.End = problem.Index + problem.Length + offset; - int newOffset = FindRangeOffset(myRange, problem, offset, end); - if (!fonts.Contains(myRange.Font.Name)) - { - fonts.Add(myRange.Font.Name); - sb.Append(sep + "'" + myRange.Font.Name + "'"); - sep = ","; - } - offset = newOffset; - } - if (sb.Length > 0) return sb.ToString(); - return null; - } - } - /// - /// Debug Tool - Return a list of symbol characters using VESYMB font. - /// - public string FontsHaveSymbolCharacters2 - { - get - { - try - { - Dictionary> fonts = new Dictionary>(); - LBRange myRange = Range(); - myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100); - myRange.Start = 0; - int end = myRange.End; - string myText = GetRangeText(myRange); - //return _RegFindSymbol.IsMatch(myText); - MatchCollection problems = _RegFindSymbol.Matches(myText); - int offset = 0; - foreach (Match problem in problems) - { - myRange.Start = problem.Index + offset; - myRange.End = problem.Index + problem.Length + offset; - int newOffset = FindRangeOffset(myRange, problem, offset, end); - string sFont = myRange.Font.Name; - if (sFont.ToUpper().StartsWith("VESYM")) - { - if (!fonts.ContainsKey(sFont)) - { - fonts.Add(sFont, new List()); - } - List symbols = fonts[sFont]; - string myTextSymb = GetRangeText(myRange); - foreach (char c in myTextSymb) - { - if (!symbols.Contains((int)c)) - symbols.Add((int)c); - } - } - offset = newOffset; - } - if (fonts.Count > 0) - { - string sep = ""; - StringBuilder sb = new StringBuilder(); - foreach (string font in fonts.Keys) - { - sb.Append(sep + "'" + font + "'"); - sep = ","; - foreach (int i in fonts[font]) - { - sb.Append(sep); - sb.Append(i); - } - } - return sb.ToString(); - } - } - catch (Exception ex) - { - Console.WriteLine("{0},{1},{2}", ex.GetType().Name, ex.Message, ex.StackTrace); - } - return null; - } - } /// /// Checks to see if the document contains symbol characters @@ -601,86 +457,7 @@ namespace LBWordLibrary } } Regex _RegFindSymbol = new Regex("[\\uF020-\\uF07F]+"); - /// - /// FixSymbolCharacters - Fix any symbol characters in the document - /// - public void FixSymbolCharacters() - { - // Set up range object to be used to process text - LBRange myRange = Range(); - myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100); - int end = myRange.End; - myRange.Start = 0; - string myText = GetRangeText(myRange); - MatchCollection problems = _RegFindSymbol.Matches(myText); - int offset = 0; - foreach (Match problem in problems) - { - myRange.Start = problem.Index + offset; - myRange.End = problem.Index + problem.Length + offset; - int newOffset = FindRangeOffset(myRange, problem, offset, end); - if (myRange.Font.Name == "") - { - int wrdStart = myRange.Start; - int wrdEnd = myRange.End; - int wrdMiddle = wrdStart; - while (myRange.Font.Name == "") - { - do - { - myRange.End = ++wrdMiddle; - } while(myRange.Font.Name != ""); - myRange.End = wrdMiddle - 1; - ReplaceSymbolCharacters(myRange); - myRange.Start = wrdMiddle -1; - myRange.End = wrdEnd; - } - ReplaceSymbolCharacters(myRange); - } - else - { - ReplaceSymbolCharacters(myRange); - } - offset = newOffset; - } - } - /// - /// Try to fix the first character in the symbol range F000 to F0FF. If it cannot be - /// fixed, it is an indicator that the font is not installed properly. Regardless of - /// whether there is success, the change is undone so that the document will not be - /// considered dirty, i.e. will not prompt user for save. - /// - /// - public bool AttemptToFixASymbolCharacter() - { - // Set up range object to be used to process text - LBRange myRange = Range(); - myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100); - - int end = myRange.End; - myRange.Start = 0; - string myText = GetRangeText(myRange); - MatchCollection problems = _RegFindSymbol.Matches(myText); - if (problems.Count>0) - { - Match problem = problems[0]; - myRange.Start = problem.Index; - myRange.End = myRange.Start + 1; - if (IsSymbolFont(myRange.Font.Name)) return true; // if it's a symbol font already, no issue. - string before = GetRangeText(myRange); - string updated = ReplaceSymbolCharacters(before); - myRange.Text = updated; - string after = GetRangeText(myRange); - Undo(1); - //Console.WriteLine("Undo1 results = {0}", tst); - //tst = Undo(1); - //Console.WriteLine("Undo2 results = {0}", tst); - //tst = Undo(1); - //Console.WriteLine("Undo3 results = {0}", tst); - return (updated == after); - } - return true; - } + /// /// Get the Range Text with error handling. myRange.Text sometimes will get a null reference exception. /// @@ -737,35 +514,6 @@ namespace LBWordLibrary return myRange.Start - problem.Index; } /// - /// ReplaceSymbolCharacters Replaces any symbol characters in the specified range - /// - /// - private static void ReplaceSymbolCharacters(LBRange myRange) - { - try - { - if (IsSymbolFont(myRange.Font.Name)) - return; - string before = GetRangeText(myRange); - string updated = ReplaceSymbolCharacters(before); - myRange.Text = updated; - string after = GetRangeText(myRange); - if (after != updated) // If the Word text doesn't match try including a character before and after and do it again. - { - Console.WriteLine("'TryEntireRange Failed',{0},{1},'{2}','{3}','{4}'", myRange.Start, myRange.End, before, updated, after); - int end = myRange.End; - myRange.Start = myRange.Start - 1; - myRange.End = end + 1; - myRange.Text = ReplaceSymbolCharacters(GetRangeText(myRange)); - Console.WriteLine("'TryEntireRange Failed',{0},{1},'{2}'", myRange.Start, myRange.End, GetRangeText(myRange)); - } - } - catch (Exception ex) - { - Console.WriteLine("'TryEntireRange Exception',{0},{1},'{2}'", myRange.Start, myRange.End, ex.Message); - } - } - /// /// ReplaceSymbolCharacters processes the string returned and changes any symbols (0xF0??) to normal characters /// /// diff --git a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs index cdbfc521..6062ac78 100644 --- a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs +++ b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs @@ -1343,31 +1343,23 @@ namespace VEPROMS //// so change bars update //// on any open StepPanel - //B2026-019 Attempt to prevent an Access Error by utilizing a different Refresh if a Procedure is Open - DisplayTabItem dti = MyFrmVEPROMS.GetTabContainingProcedure(pi.ItemID); + newproc = ItemInfo.ResetProcedure(pi.ItemID); + + //B2026-019 Attempt to prevent an Access Error by utilizing a different Refresh if a Procedure is Open + DisplayTabItem dti = MyFrmVEPROMS.GetTabContainingProcedure(pi.ItemID); if (dti != null) { if (!dti.MyStepTabPanel.MyStepPanel.ContainsFocus) dti.MyStepTabPanel.MyStepPanel.Focus(); - foreach (EditItem eitm in dti.MyStepTabPanel.MyStepPanel.Controls.OfType()) - { - eitm.ChangeBar = eitm.MyItemInfo.HasChangeBar; - } + dti.MyStepTabPanel.MyStepTabRibbon.RefreshProcedure(); + Application.DoEvents(); - dti.MyStepTabPanel.MyStepTabRibbon.RefreshProcedure(); - Application.DoEvents(); - newproc = ProcedureInfo.Get(pi.ItemID); + } - } - else - { - newproc = ItemInfo.ResetProcedure(pi.ItemID); - } - - //since in a separate form, need to update the tree view - //so "Showing Change Bars" Content Menu Item is correct - MyFrmVEPROMS.RefreshProcedureNode(newproc); + //since in a separate form, need to update the tree view + //so "Showing Change Bars" Content Menu Item is correct + MyFrmVEPROMS.RefreshProcedureNode(newproc); } else UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS, selectedSlave); @@ -1478,19 +1470,34 @@ namespace VEPROMS { ProcedureConfig pc = procedureInfo.MyConfig as ProcedureConfig; if (pc == null) return; - pc.SelectedSlave = selectedSlave; + + pc.SelectedSlave = selectedSlave; pc.Print_Rev = revNumber; //AppRevDate Change pc.Print_RevDate = revDate.ToString("MM/dd/yyyy"); - pc.Print_ChangeBarDate = dts.ToString("MM/dd/yyyy HH:mm:ss"); + pc.Print_ChangeBarDate = dts.ToString("MM/dd/yyyy HH:mm:ss"); //this is needed to set the changebar date for an indeividual unit also using (Item itm = Item.Get(procedureInfo.ItemID)) { itm.MyContent.Config = pc.ToString(); //itm.DTS = dts; itm.UserID = Volian.Base.Library.VlnSettings.UserID; itm.Save(); - } + //C2026-015 set overall change bar date + if (selectedSlave > 0) + { + pc.SelectedSlave = 0; + pc.Print_Rev = revNumber; + pc.Print_RevDate = revDate.ToString("MM/dd/yyyy"); + pc.Print_ChangeBarDate = dts.ToString("MM/dd/yyyy HH:mm:ss"); //this is needed to set the changebar date for an indeividual unit also + using (Item itm2 = Item.Get(procedureInfo.ItemID)) + { + itm2.MyContent.Config = pc.ToString(); + itm2.UserID = Volian.Base.Library.VlnSettings.UserID; + itm2.Save(); + } + } + } } } public class RevType diff --git a/PROMS/VEPROMS User Interface/dlgSetChangeBarStartDate.cs b/PROMS/VEPROMS User Interface/dlgSetChangeBarStartDate.cs index a9ba9321..1ccd47a5 100644 --- a/PROMS/VEPROMS User Interface/dlgSetChangeBarStartDate.cs +++ b/PROMS/VEPROMS User Interface/dlgSetChangeBarStartDate.cs @@ -68,8 +68,26 @@ namespace VEPROMS MyProcConfig.Print_ChangeBarDate = dateTimeInput1.Value.ToString("MM/dd/yyyy HH:mm:ss");// ("MM/dd/yyyy HH:mm:ss"); //CSM - C2026-010 - Add Audit Record for Change Bar Audit History - ChangeBarAuditHistory.AddAudit(MyProcInfo.ItemID, $"Set ChangeBars set to ({ dateTimeInput1.Value.ToString("MM/dd/yyyy HH:mm:ss")}) by ({ VlnSettings.UserID}) on ({DateTime.Now})", DateTime.Now, VlnSettings.UserID, 0); + ChangeBarAuditHistory.AddAudit(MyProcInfo.ItemID, $"Set ChangeBars set to ({dateTimeInput1.Value.ToString("MM/dd/yyyy HH:mm:ss")}) by ({VlnSettings.UserID}) on ({DateTime.Now})", DateTime.Now, VlnSettings.UserID, 0); + //CSM C2026-014 if multi-unit, set for each unit + System.Data.DataTable dt = RevisionData.GetRevisionDataByUnit(MyProcInfo.ItemID); + if (RevisionData.HasUnits(dt)) + { + //Change the ChangeBarDate for each unit + foreach (DataRow r in dt.Rows) + { + if (!r.IsNull("UnitID")) + { + MyProcConfig.SelectedSlave = Convert.ToInt32(r["UnitID"]); + MyProcConfig.Print_ChangeBarDate = dateTimeInput1.Value.ToString("MM/dd/yyyy HH:mm:ss"); + + //CSM - C2026-010 - Add Audit Record for Change Bar Audit History + ChangeBarAuditHistory.AddAudit(MyProcInfo.ItemID, $"Set ChangeBars set to ({dateTimeInput1.Value.ToString("MM/dd/yyyy HH:mm:ss")}) by ({VlnSettings.UserID}) on ({DateTime.Now}) for (Unit {r["UnitName"]})", DateTime.Now, VlnSettings.UserID, MyProcConfig.SelectedSlave); + } + } + MyProcConfig.SelectedSlave = 0; + } } @@ -108,7 +126,10 @@ namespace VEPROMS sb.Append($" The Procedure Viewer Change Bar Date will be set to ({maxDTS})."); foreach (DataRow r in dt.Rows) { - sb.Append($"\r\n The Change Bar Date for Unit ({r["UnitName"]}) will be set to ({Convert.ToDateTime(r["DTS"]):MM/dd/yyyy HH:mm:ss})."); + if (!r.IsNull("UnitID")) + { + sb.Append($"\r\n The Change Bar Date for Unit ({r["UnitName"]}) will be set to ({Convert.ToDateTime(r["DTS"]):MM/dd/yyyy HH:mm:ss})."); + } } sb.Append("\r\n Any Change Bars for Units not listed above will use the Overall/Procedure Viewer Change Bar Date (as these Units have no approvals)."); @@ -121,12 +142,14 @@ namespace VEPROMS //Change the ChangeBarDate for each unit foreach (DataRow r in dt.Rows) { - MyProcConfig.SelectedSlave = Convert.ToInt32(r["UnitID"]); - MyProcConfig.Print_ChangeBarDate = Convert.ToDateTime(r["DTS"]).ToString("MM / dd / yyyy HH: mm: ss"); - - //CSM - C2026-010 - Add Audit Record for Change Bar Audit History - ChangeBarAuditHistory.AddAudit(MyProcInfo.ItemID, $"Reset ChangeBars performed by ({VlnSettings.UserID}) on ({DateTime.Now}). ChangeBars reset to show since last approval ({Convert.ToDateTime(r["DTS"]):MM/dd/yyyy HH:mm:ss}) for (Unit {r["UnitName"]})", DateTime.Now, VlnSettings.UserID, MyProcConfig.SelectedSlave); + if (!r.IsNull("UnitID")) + { + MyProcConfig.SelectedSlave = Convert.ToInt32(r["UnitID"]); + MyProcConfig.Print_ChangeBarDate = Convert.ToDateTime(r["DTS"]).ToString("MM / dd / yyyy HH: mm: ss"); + //CSM - C2026-010 - Add Audit Record for Change Bar Audit History + ChangeBarAuditHistory.AddAudit(MyProcInfo.ItemID, $"Reset ChangeBars performed by ({VlnSettings.UserID}) on ({DateTime.Now}). ChangeBars reset to show since last approval ({Convert.ToDateTime(r["DTS"]):MM/dd/yyyy HH:mm:ss}) for (Unit {r["UnitName"]})", DateTime.Now, VlnSettings.UserID, MyProcConfig.SelectedSlave); + } } MyProcConfig.SelectedSlave = 0; DialogResult = DialogResult.OK; diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs index d2f33d9d..2da63893 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs @@ -83,7 +83,6 @@ namespace VEPROMS this.lblUser = new DevComponents.DotNetBar.LabelItem(); this.lblLastChange = new DevComponents.DotNetBar.LabelItem(); this.btnStepRTF = new DevComponents.DotNetBar.ButtonItem(); - this.btnFixMSWord = new DevComponents.DotNetBar.ButtonItem(); this.epAnnotations = new DevComponents.DotNetBar.ExpandablePanel(); this.ctrlAnnotationDetails = new Volian.Controls.Library.AnnotationDetails(); this.btnAnnoDetailsPushPin = new DevComponents.DotNetBar.ButtonX(); @@ -541,8 +540,7 @@ namespace VEPROMS this.btnEditItem, this.lblUser, this.lblLastChange, - this.btnStepRTF, - this.btnFixMSWord}); + this.btnStepRTF}); this.bottomBar.Location = new System.Drawing.Point(5, 573); this.bottomBar.Name = "bottomBar"; this.bottomBar.Size = new System.Drawing.Size(1185, 25); @@ -728,14 +726,6 @@ namespace VEPROMS this.btnStepRTF.Text = "Step RTF"; this.btnStepRTF.Click += new System.EventHandler(this.btnStepRTF_Click); // - // btnFixMSWord - // - this.btnFixMSWord.ForeColor = System.Drawing.Color.Black; - this.btnFixMSWord.Name = "btnFixMSWord"; - this.btnFixMSWord.Text = "Fix Symbol Fonts"; - this.btnFixMSWord.Visible = false; - this.btnFixMSWord.Click += new System.EventHandler(this.btnFixMSWord_Click); - // // epAnnotations // this.epAnnotations.CanvasColor = System.Drawing.SystemColors.Control; @@ -1775,7 +1765,6 @@ namespace VEPROMS private DevComponents.DotNetBar.ButtonItem btnItemInfo; private DevComponents.DotNetBar.ButtonItem btnFilter; private DevComponents.DotNetBar.TextBoxItem txtFilter; - private DevComponents.DotNetBar.ButtonItem btnFixMSWord; private Volian.Controls.Library.DisplayBookMarks displayBookMarks; //private DevComponents.DotNetBar.LabelItem lblLocked; private DevComponents.DotNetBar.ButtonItem btnShortCuts; diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index c73eb983..10210c96 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -234,7 +234,7 @@ namespace VEPROMS System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); displayRO.TabControl = tc; // B2019-043 this was being passed in as a parameter for DisplayRO which caused issues with the Visual Studio designer - SetupFolder(MyDocVersion.FolderID); + SetupFolder(MyDocVersion.FolderID); tc.MySessionInfo = MyParent.MySessionInfo; displaySearch1.TopFolderID = myDocVersion.FolderID; SelectedDVI = myDocVersion; @@ -1578,13 +1578,13 @@ namespace VEPROMS } else { - SelectedROFst = myDTP.MyDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; + SelectedROFst = myDTP.MyDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; } } } else if (tc.MyEditItem != null && displayRO.MyROFST != null && tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].ROFstID != displayRO.MyROFST.ROFstID) { - SelectedROFst = tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; + SelectedROFst = tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; } // need this to update RO Tree after UpdateRofst (B2015-226) @@ -1592,9 +1592,9 @@ namespace VEPROMS if (displayRO.MyROFST != SelectedROFst) { displayRO.MyROFST = SelectedROFst; - // B2023-021: force Load of Step Prop/RO panel RO tree by passing in - // true to LoadTree - displayRO.LoadTree(true); + // B2023-021: force Load of Step Prop/RO panel RO tree by passing in + // true to LoadTree + displayRO.LoadTree(true); } } @@ -2396,8 +2396,8 @@ namespace VEPROMS tv.MyUserInfo = MyUserInfo; StepTabRibbon.MySessionInfo = MySessionInfo; - // Initialize Caption with Server name and Database name. - SetCaption(tv.TopNode as VETreeNode); + // Initialize Caption with Server name and Database name. + SetCaption(tv.TopNode as VETreeNode); System.Threading.AutoResetEvent autoEvent = new System.Threading.AutoResetEvent(false); //System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(MySessionInfo.PingSession); @@ -4552,8 +4552,8 @@ namespace VEPROMS SetCaption(tv.SelectedNode as VETreeNode); displayApplicability.MyDisplayTabItem = tc.SelectedDisplayTabItem; - - if (tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0) + + if (tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0) { displayRO.MyROFST = tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; } @@ -4628,8 +4628,6 @@ namespace VEPROMS if (args != null && args.MyEditItem != null && !args.MyEditItem.MyStepPanel.ContainsFocus) return; - btnFixMSWord.Visible = (args != null && (args.MyItemInfo != null && args.MyEditItem == null)); - if (_LastStepRTB != null && !_LastStepRTB.Disposing && !_LastStepRTB.Closed) _LastStepRTB.EditModeChanged -= new StepRTBEvent(_LastStepRTB_EditModeChanged); @@ -4767,9 +4765,9 @@ namespace VEPROMS // B2022-026 RO Memory reduction coding (Jakes Merge) displayRO.ProgressBar = bottomProgBar; displayRO.MyRTB = args.MyEditItem.MyStepRTB; - displayRO.LoadTree(); + displayRO.LoadTree(); - displayBookMarks.MyEditItem = args.MyEditItem; + displayBookMarks.MyEditItem = args.MyEditItem; displayHistory.MyEditItem = args.MyEditItem; lblEditView.Text = args.MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit ? "Edit" : "View"; @@ -4932,7 +4930,7 @@ namespace VEPROMS // B2022-026 RO Memory reduction coding (Jakes Merge) displayRO.LoadTree(); - } + } #endregion @@ -5241,19 +5239,6 @@ namespace VEPROMS Clipboard.SetDataObject(mydo); } } - private void btnFixMSWord_Click(object sender, EventArgs e) - { - if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyDSOTabPanel != null) - { - string btnText = btnFixMSWord.Text; - btnFixMSWord.FixedSize = btnFixMSWord.Size; - btnFixMSWord.Text = "Processing ..."; - this.Cursor = Cursors.WaitCursor; - tc.SelectedDisplayTabItem.MyDSOTabPanel.FixSymbolCharacters(); - btnFixMSWord.Text = btnText; - this.Cursor = Cursors.Default; - } - } private void epAnnotations_Resize(object sender, EventArgs e) { diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index a2c4960e..a8656812 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -4054,7 +4054,7 @@ namespace VEPROMS.CSLA.Library // date). Print_ViewableAfterChangeBarDate was created to get only that user specified date, if it exists. If it does exist, we compare // that with the Content datetime, otherwise we proceed as before. DateTime? viewableStartingDateTime = (MyProcedure.MyConfig as ProcedureConfig).Print_ViewableStartingChangeBarDate; - if (viewableStartingDateTime != null && viewableStartingDateTime > MyProcedure.ChangeBarDate) + if (viewableStartingDateTime != null && viewableStartingDateTime > MyProcedure.ChangeBarDate && (MyProcedure.MyConfig as ProcedureConfig).SelectedSlave == 0) return (MyContent.DTS > viewableStartingDateTime); return (MyContent.DTS > MyProcedure.ChangeBarDate); } @@ -6215,8 +6215,13 @@ namespace VEPROMS.CSLA.Library if (!SectionHasCheckOffs()) return null; int stpCoIndx = CheckOffIndex(); // this step has a checkoff defined if (stpCoIndx == -1) return null; + //B2026-040 - Signoff/Checkoffs not printing unless set to Section Default + if (stpCoIndx > 1) + { + return ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffList[stpCoIndx]; // DO override of CheckOffList[] + } - int sectCoIndx = SectionDefaultCheckOffIndex(); // no checkoff on step, see if there is a section default. + int sectCoIndx = SectionDefaultCheckOffIndex(); // no checkoff on step, see if there is a section default. if (sectCoIndx == -1) return null; if ((ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffOnHLSOnly && IsHigh) || (!ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffOnHLSOnly && IsLowestLevelStep && stpCheckOff)) // && !RNOsHighHasCheckOff())) diff --git a/PROMS/Volian.Controls.Library/AnnotationDetails.cs b/PROMS/Volian.Controls.Library/AnnotationDetails.cs index 27577b01..45cbeb1d 100644 --- a/PROMS/Volian.Controls.Library/AnnotationDetails.cs +++ b/PROMS/Volian.Controls.Library/AnnotationDetails.cs @@ -1,16 +1,17 @@ +using JR.Utils.GUI.Forms; using System; using System.Collections.Generic; using System.ComponentModel; -using System.Drawing; using System.Data; +using System.Diagnostics; +using System.Drawing; using System.Text; +using System.Text.RegularExpressions; using System.Windows.Forms; +using System.Xml; using VEPROMS.CSLA.Library; using Volian.Base.Library; using Volian.Pipe.Library; -using System.Xml; -using System.Diagnostics; -using JR.Utils.GUI.Forms; namespace Volian.Controls.Library { @@ -220,7 +221,10 @@ namespace Volian.Controls.Library { if (!DesignMode) // B2019-043 need to check if we are just saving changes to the user interface { - rtxbComment.Text = value; + if (value != null) + { + rtxbComment.Text = Regex.Replace(value, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString()); + } if (rtxbComment.Text != string.Empty) rtxbComment.SelectionStart = rtxbComment.TextLength; // position cursor to end of text } diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index 45b5b70c..a97e038a 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -14,736 +14,701 @@ using Volian.Base.Library; namespace Volian.Controls.Library { - public partial class DSOTabPanel : DevComponents.DotNetBar.PanelDockContainer - { - #region Private Fields - private DisplayTabControl _MyDisplayTabControl; - private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private AxEDWordLib.AxEDWord _MyEdWord; // B2017-133 Edraw DSO Framer Replacement - public AxEDWordLib.AxEDWord MyEdWord - { - get { return _MyEdWord; } - set { _MyEdWord = value; } - } - private TransparentPanel _MyTransparentPanel; - private static int _Count = 0; - private DocumentInfo _MyDocumentInfo; - private int _MyCount; - private DisplayTabItem _MyDisplayTabItem; - private DSOFile _DSOFile; - public static int MSWordLimit = 10; - #endregion - #region Public Properties - private String _SearchString; - public String SearchString - { - get { return _SearchString; } - set { _SearchString = value; FindSearchString(); } - } - /// - /// Count of DSO Pages open. Limited to 18 in DisplayTabControl - /// - public static int Count - { - get { return _Count; } - set { _Count = value; } - } - /// - /// Pointer to the related DisplayTabItem - /// - public DisplayTabItem MyDisplayTabItem - { - get { return _MyDisplayTabItem; } - set - { - _MyDisplayTabItem = value; - _MyDisplayTabItem.Visible = false; - _MyDisplayTabItem.Visible = true; - } - } - /// - /// DocumentInfo record for the Word document - /// - public DocumentInfo MyDocumentInfo - { - get { return _MyDocumentInfo; } - } - /// - /// Temporary Word file used for editing. - /// - internal DSOFile MyDSOFile - { - get - { - if (_DSOFile == null) - _DSOFile = new DSOFile(_MyDocumentInfo); - return _DSOFile; - } - } - /// - /// Dirty status. Only saved if dirty. - /// - public bool IsDirty - { - get - { - if (_MyEdWord == null) return false; // B2017-133 Edraw Is Dirty Property - // B2017-249 Recover Temporary File And AutoSave support for MSWord - return _MyEdWord.IsDirty() || MyDSOFile.ContentIsDirty; - //LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); - //return !doc.Saved; - } - } - private bool _OverrideClose = false; - public bool OverrideClose - { - get { return _OverrideClose; } - set { _OverrideClose = value; } - } - public E_ViewMode PanelViewEditMode = E_ViewMode.Edit; - #endregion - //private frmPG _frm = null; - #region Constructors - private Timer _RefreshTimer; - private ItemInfo _ItemInfo; - private bool _AllowedToEdit; - public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myDisplayTabControl, ItemInfo itemInfo, bool allowedToEdit) - { - _MyDisplayTabControl = myDisplayTabControl; - _ItemInfo = itemInfo; - _AllowedToEdit = allowedToEdit; - InitializeComponent(); - SetupDSOTabPanel(); - _MyDocumentInfo = documentInfo; - SetupDSO(); - if (_MyEdWord == null) return; //B2017-219 could not open the word attachment so just return + public partial class DSOTabPanel : DevComponents.DotNetBar.PanelDockContainer + { + #region Private Fields + private DisplayTabControl _MyDisplayTabControl; + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private AxEDWordLib.AxEDWord _MyEdWord; // B2017-133 Edraw DSO Framer Replacement + public AxEDWordLib.AxEDWord MyEdWord + { + get { return _MyEdWord; } + set { _MyEdWord = value; } + } + private TransparentPanel _MyTransparentPanel; + private static int _Count = 0; + private DocumentInfo _MyDocumentInfo; + private int _MyCount; + private DisplayTabItem _MyDisplayTabItem; + private DSOFile _DSOFile; + public static int MSWordLimit = 10; + #endregion + #region Public Properties + private String _SearchString; + public String SearchString + { + get { return _SearchString; } + set { _SearchString = value; FindSearchString(); } + } + /// + /// Count of DSO Pages open. Limited to 18 in DisplayTabControl + /// + public static int Count + { + get { return _Count; } + set { _Count = value; } + } + /// + /// Pointer to the related DisplayTabItem + /// + public DisplayTabItem MyDisplayTabItem + { + get { return _MyDisplayTabItem; } + set + { + _MyDisplayTabItem = value; + _MyDisplayTabItem.Visible = false; + _MyDisplayTabItem.Visible = true; + } + } + /// + /// DocumentInfo record for the Word document + /// + public DocumentInfo MyDocumentInfo + { + get { return _MyDocumentInfo; } + } + /// + /// Temporary Word file used for editing. + /// + internal DSOFile MyDSOFile + { + get + { + if (_DSOFile == null) + _DSOFile = new DSOFile(_MyDocumentInfo); + return _DSOFile; + } + } + /// + /// Dirty status. Only saved if dirty. + /// + public bool IsDirty + { + get + { + if (_MyEdWord == null) return false; // B2017-133 Edraw Is Dirty Property + // B2017-249 Recover Temporary File And AutoSave support for MSWord + return _MyEdWord.IsDirty() || MyDSOFile.ContentIsDirty; + //LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); + //return !doc.Saved; + } + } + private bool _OverrideClose = false; + public bool OverrideClose + { + get { return _OverrideClose; } + set { _OverrideClose = value; } + } + public E_ViewMode PanelViewEditMode = E_ViewMode.Edit; + #endregion + //private frmPG _frm = null; + #region Constructors + private Timer _RefreshTimer; + private ItemInfo _ItemInfo; + private bool _AllowedToEdit; + public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myDisplayTabControl, ItemInfo itemInfo, bool allowedToEdit) + { + _MyDisplayTabControl = myDisplayTabControl; + _ItemInfo = itemInfo; + _AllowedToEdit = allowedToEdit; + InitializeComponent(); + SetupDSOTabPanel(); + _MyDocumentInfo = documentInfo; + SetupDSO(); + if (_MyEdWord == null) return; //B2017-219 could not open the word attachment so just return _RefreshTimer = new Timer(); // Enabled is false and interval is 1/10th of second. - _RefreshTimer.Interval = 500;// B2017-133 Edraw - ClientSizeChanged += new EventHandler(DSOTabPanel_ClientSizeChanged); - _RefreshTimer.Tick += new EventHandler(_RefreshTimer_Tick); - // B2018-070 Activate MS Word Panel - _RefreshTimer.Enabled = true; - _MyEdWord.BeforeDocumentSaved += _MyEdWord_BeforeDocumentSaved;// B2017-133 Edraw - } - void _MyEdWord_BeforeDocumentSaved(object sender, EventArgs e)// B2017-133 Edraw - { - _MyEdWord.Save(); // B2017-135 Only open the Message Box once - } - void DisableWordCommands()// B2017-133 Edraw - { - _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableClose, true); - _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableNew, true); - _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrint, true); - _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintPreview, true); - _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintQuick, true); - _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSave, true); - _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSaveAs, true); - _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeSave, true); - _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeClose, true); - _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypePrint, true); - _MyEdWord.DisableSaveHotKey(true); - _MyEdWord.DisablePrintHotKey(true); - } - // B2019-161 When tracking timing time this action - private static VolianTimer _TimeActivity = new VolianTimer("DSOTabPanel.cs _RefreshTimer_Tick", 148); + _RefreshTimer.Interval = 500;// B2017-133 Edraw + ClientSizeChanged += new EventHandler(DSOTabPanel_ClientSizeChanged); + _RefreshTimer.Tick += new EventHandler(_RefreshTimer_Tick); + // B2018-070 Activate MS Word Panel + _RefreshTimer.Enabled = true; + _MyEdWord.BeforeDocumentSaved += _MyEdWord_BeforeDocumentSaved;// B2017-133 Edraw + } + void _MyEdWord_BeforeDocumentSaved(object sender, EventArgs e)// B2017-133 Edraw + { + _MyEdWord.Save(); // B2017-135 Only open the Message Box once + } + void DisableWordCommands()// B2017-133 Edraw + { + _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableClose, true); + _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableNew, true); + _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrint, true); + _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintPreview, true); + _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintQuick, true); + _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSave, true); + _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSaveAs, true); + _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeSave, true); + _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeClose, true); + _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypePrint, true); + _MyEdWord.DisableSaveHotKey(true); + _MyEdWord.DisablePrintHotKey(true); + } + // B2019-161 When tracking timing time this action + private static VolianTimer _TimeActivity = new VolianTimer("DSOTabPanel.cs _RefreshTimer_Tick", 148); - void _RefreshTimer_Tick(object sender, EventArgs e) - { - _TimeActivity.Open(); - _RefreshTimer.Enabled = false; - if (_MyEdWord != null)// B2017-133 Edraw - { - // B2018-070 Activate MS Word Panel - _MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null); - } - //else - //{ - // _MyDisplayTabControl.CloseTabItem(_MyDisplayTabItem); - //} - _TimeActivity.Close(); - } + void _RefreshTimer_Tick(object sender, EventArgs e) + { + _TimeActivity.Open(); + _RefreshTimer.Enabled = false; + if (_MyEdWord != null)// B2017-133 Edraw + { + // B2018-070 Activate MS Word Panel + _MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null); + } + //else + //{ + // _MyDisplayTabControl.CloseTabItem(_MyDisplayTabItem); + //} + _TimeActivity.Close(); + } - void DSOTabPanel_ClientSizeChanged(object sender, EventArgs e) - { - // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel - if (_InDSOTabPanel) - { + void DSOTabPanel_ClientSizeChanged(object sender, EventArgs e) + { + // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel + if (_InDSOTabPanel) + { _RefreshTimer.Enabled = false; // This assures that interval is used from last event. - _RefreshTimer.Enabled = true; - } - } - #endregion - #region Private Methods - private void SetupDSOTabPanel() - { - Dock = System.Windows.Forms.DockStyle.Fill; // Automatically Fill the panel - } - private void SetupDSO() - { - _Count++; // Increment the count of open Word documents (Limit = MSWordLimit) - _MyCount = _Count; - this._MyTransparentPanel = new TransparentPanel(); - this._MyEdWord = new AxEDWordLib.AxEDWord();// B2017-133 Edraw - _MyEdWord.BeginInit(); - this.Controls.Add(this._MyEdWord); - this.Controls.Add(this._MyTransparentPanel); // A transparent panel is added over top of the DSO Framer window so that - // the related tab can be activated when the user clicks on a Word Document. Since the Word document is actually running - // in a different thread, it does not behave properly with focus events. - this.components.Add(this._MyEdWord);// B2017-133 Edraw - this.components.Add(this._MyTransparentPanel); - this._MyTransparentPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this._MyTransparentPanel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this._MyTransparentPanel.ForeColor = System.Drawing.Color.Brown; // This is the color used to show InActive on the right side on the Word - // document menu line. - //this._MyTransPanel.Location = new System.Drawing.Point(0, 0); - //this._MyTransPanel.Name = "transPanel1"; - //this._MyTransPanel.Size = new System.Drawing.Size(370, 423); - //this._MyTransPanel.TabIndex = 1; - this._MyTransparentPanel.Click += new EventHandler(_MyTransparentPanel_Click); - this._MyEdWord.Dock = System.Windows.Forms.DockStyle.Fill; - //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab)); - //this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState"))); - _MyEdWord.EndInit(); - LBDocumentClass doc; - try - { - try - { - this._MyEdWord.LicenseName = "Volian7573291802";// B2017-133 Edraw - this._MyEdWord.LicenseCode = "EDW8-5527-1201-AB8A";// B2017-133 Edraw - DisableWordCommands(); - this._MyEdWord.Open(MyDSOFile.MyFile.FullName); - doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); - } - catch (Exception ex) - { - // B2017-137 Restore Previous valid version if the current version cannot be opened, - using (DocumentAuditInfoList dail = DocumentAuditInfoList.Get(MyDocumentInfo.DocID)) - { - if (dail.Count > 0) - { - //DocumentAuditInfo dai = dail[0]; - //foreach (DocumentAuditInfo tmpa in dail) - //{ - // if (tmpa.DTS > dai.DTS) dai = tmpa; - //} - if (MessageBox.Show("Do you want to revert to a previous version?", "Error in MS Word section", - MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - using (Document myDoc = Document.Get(MyDocumentInfo.DocID)) - { - myDoc.RestoreWordDoc(_ItemInfo); - } - using (Document myDoc = Document.Get(MyDocumentInfo.DocID)) - { - System.IO.FileStream fs = MyDSOFile.MyFile.Create(); - fs.Write(myDoc.DocContent, 0, myDoc.DocContent.Length); - fs.Close(); - MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the restored document to database - this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions - return; - //_MyDocumentInfo = DocumentInfo.Get(MyDocumentInfo.DocID); - //DocumentInfo.Refresh(myDoc); - ////_DSOFile = null; - //this._MyEdWord.Open(MyDSOFile.MyFile.FullName); - //doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); - //doc.Range(1, 1); - } - } + _RefreshTimer.Enabled = true; + } + } + #endregion + #region Private Methods + private void SetupDSOTabPanel() + { + Dock = System.Windows.Forms.DockStyle.Fill; // Automatically Fill the panel + } + private void SetupDSO() + { + _Count++; // Increment the count of open Word documents (Limit = MSWordLimit) + _MyCount = _Count; + this._MyTransparentPanel = new TransparentPanel(); + this._MyEdWord = new AxEDWordLib.AxEDWord();// B2017-133 Edraw + _MyEdWord.BeginInit(); + this.Controls.Add(this._MyEdWord); + this.Controls.Add(this._MyTransparentPanel); // A transparent panel is added over top of the DSO Framer window so that + // the related tab can be activated when the user clicks on a Word Document. Since the Word document is actually running + // in a different thread, it does not behave properly with focus events. + this.components.Add(this._MyEdWord);// B2017-133 Edraw + this.components.Add(this._MyTransparentPanel); + this._MyTransparentPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this._MyTransparentPanel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this._MyTransparentPanel.ForeColor = System.Drawing.Color.Brown; // This is the color used to show InActive on the right side on the Word + // document menu line. + //this._MyTransPanel.Location = new System.Drawing.Point(0, 0); + //this._MyTransPanel.Name = "transPanel1"; + //this._MyTransPanel.Size = new System.Drawing.Size(370, 423); + //this._MyTransPanel.TabIndex = 1; + this._MyTransparentPanel.Click += new EventHandler(_MyTransparentPanel_Click); + this._MyEdWord.Dock = System.Windows.Forms.DockStyle.Fill; + //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab)); + //this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState"))); + _MyEdWord.EndInit(); + LBDocumentClass doc; + try + { + try + { + this._MyEdWord.LicenseName = "Volian7573291802";// B2017-133 Edraw + this._MyEdWord.LicenseCode = "EDW8-5527-1201-AB8A";// B2017-133 Edraw + DisableWordCommands(); + this._MyEdWord.Open(MyDSOFile.MyFile.FullName); + doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); + } + catch (Exception ex) + { + // B2017-137 Restore Previous valid version if the current version cannot be opened, + using (DocumentAuditInfoList dail = DocumentAuditInfoList.Get(MyDocumentInfo.DocID)) + { + if (dail.Count > 0) + { + //DocumentAuditInfo dai = dail[0]; + //foreach (DocumentAuditInfo tmpa in dail) + //{ + // if (tmpa.DTS > dai.DTS) dai = tmpa; + //} + if (MessageBox.Show("Do you want to revert to a previous version?", "Error in MS Word section", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + using (Document myDoc = Document.Get(MyDocumentInfo.DocID)) + { + myDoc.RestoreWordDoc(_ItemInfo); + } + using (Document myDoc = Document.Get(MyDocumentInfo.DocID)) + { + System.IO.FileStream fs = MyDSOFile.MyFile.Create(); + fs.Write(myDoc.DocContent, 0, myDoc.DocContent.Length); + fs.Close(); + MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the restored document to database + this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions + return; + //_MyDocumentInfo = DocumentInfo.Get(MyDocumentInfo.DocID); + //DocumentInfo.Refresh(myDoc); + ////_DSOFile = null; + //this._MyEdWord.Open(MyDSOFile.MyFile.FullName); + //doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); + //doc.Range(1, 1); + } + } - } - else - { - System.IO.FileStream fs = MyDSOFile.MyFile.Create(); - fs.Close(); - MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the blank document to database - MessageBox.Show("Reverting to Blank Document", "Error in MS Word section", - MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions - return; - } - } - this._MyEdWord.Open(MyDSOFile.MyFile.FullName);// B2017-133 Edraw - } - doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); - //Console.WriteLine("Version {0}", doc.Application.Version); - float ver; - if (!float.TryParse(doc.Application.Version, out ver)) - ver = 12.0F; - this.Enter += new EventHandler(DSOTabPanel_Enter); - // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel - this.Leave += DSOTabPanel_Leave; - Application.DoEvents(); - // The following line corrects Symbol characters in MSWord Sections - // CheckForSymbolCharacters(doc); - InitializeWordDocument(doc); - FindSearchString(); - } - catch (Exception ex) - { - //string message = ShowException(ex); - //Console.WriteLine("\r\n-------------\r\n{0}{1}{2}\r\n-------------\r\n", MyDSOFile.MyFile.FullName, ex.GetType().Name, message); - // TODO: Should output a message - // TODO: Should try to do a direct open using Word. - } - } + } + else + { + System.IO.FileStream fs = MyDSOFile.MyFile.Create(); + fs.Close(); + MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the blank document to database + MessageBox.Show("Reverting to Blank Document", "Error in MS Word section", + MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions + return; + } + } + this._MyEdWord.Open(MyDSOFile.MyFile.FullName);// B2017-133 Edraw + } + doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); + //Console.WriteLine("Version {0}", doc.Application.Version); + float ver; + if (!float.TryParse(doc.Application.Version, out ver)) + ver = 12.0F; + this.Enter += new EventHandler(DSOTabPanel_Enter); + // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel + this.Leave += DSOTabPanel_Leave; + Application.DoEvents(); + // The following line corrects Symbol characters in MSWord Sections + // CheckForSymbolCharacters(doc); + InitializeWordDocument(doc); + FindSearchString(); + } + catch (Exception ex) + { + //string message = ShowException(ex); + //Console.WriteLine("\r\n-------------\r\n{0}{1}{2}\r\n-------------\r\n", MyDSOFile.MyFile.FullName, ex.GetType().Name, message); + // TODO: Should output a message + // TODO: Should try to do a direct open using Word. + } + } - void DSOTabPanel_Leave(object sender, EventArgs e) - { - // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel - _InDSOTabPanel = false; - } - public void FixSymbolCharacters() - { - CheckForSymbolCharacters(new LBDocumentClass(_MyEdWord.ActiveDocument()));// B2017-133 Edraw - } - private void CheckForSymbolCharacters(LBDocumentClass doc) - { - string fontHasSymbolCharacters = doc.FontHasSymbolCharacters; - if (fontHasSymbolCharacters != null) - { - // do a string for the log message, depending if this is a libdoc. - string msg = null; - if (MyDocumentInfo.LibTitle == null || MyDocumentInfo.LibTitle == "") - { - if (MyDocumentInfo.DocumentEntryCount>0) - msg = string.Format("Procedure = {0}, Section {1}", MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyProcedure, MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].DisplayText); - else - msg = string.Format("Procedure and Section can't be determined"); - } - else - msg = string.Format("Library Document: {0}", MyDocumentInfo.LibTitle); - if (doc.AttemptToFixASymbolCharacter()) // font is installed correctly, 'fix' this file. - { - //MessageBox.Show(string.Format("This document uses the font {0}, which previously had an error.\r\nThe program will attempt to fix the problem for this Word section.", fontHasSymbolCharacters), - // "Font Being Corrected", MessageBoxButtons.OK); - doc.FixSymbolCharacters(); - _MyLog.Info(string.Format("Font problem being fixed in Font: {0}, {1}.",fontHasSymbolCharacters, msg)); - } - else - { - MessageBox.Show(string.Format("This document uses the font {0}, which has an error.\r\n\r\nReinstall this font.", fontHasSymbolCharacters), - "Reinstall Font", MessageBoxButtons.OK); - _MyLog.Info(string.Format("Font problem found in Font: {0}, {1}.",fontHasSymbolCharacters, msg)); - } - } - } + void DSOTabPanel_Leave(object sender, EventArgs e) + { + // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel + _InDSOTabPanel = false; + } - private void InitializeWordDocument(LBDocumentClass doc) - { - if (MyDocumentInfo.Config == null || MyDocumentInfo.Config == "" && MyDocumentInfo.DocumentEntryCount > 0) - { - DocStyle ds = MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyDocStyle; - // this will cause an error and goto the Catch if the family or size is null, - // Westinghouse needs it to to this - at least for now - //if (ds.Font.Family != null) doc.Application.Selection.Font.Name = ds.Font.Family; - //if (ds.Font.Size != null) doc.Application.Selection.Font.Size = (float)ds.Font.Size; - doc.Application.Selection.Font.Name = ds.Font.Family; - doc.Application.Selection.Font.Size = (float)ds.Font.Size; - doc.Application.Selection.ParagraphFormat.SpaceBefore = 0; - doc.Application.Selection.ParagraphFormat.SpaceAfter = 0; - doc.Application.Selection.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly; - doc.Application.Selection.ParagraphFormat.LineSpacing = 72 / 6; // for 6 LPI - MSWordToPDF.AdjustMargins(ds, doc, false); - } - if (doc.ActiveWindow.ActivePane.View.Zoom.Percentage < 40) - doc.ActiveWindow.ActivePane.View.Zoom.Percentage = 100; - } - public void FindSearchString() - { - if (SearchString == null) return; - // Get the Document + private void InitializeWordDocument(LBDocumentClass doc) + { + if (MyDocumentInfo.Config == null || MyDocumentInfo.Config == "" && MyDocumentInfo.DocumentEntryCount > 0) + { + DocStyle ds = MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyDocStyle; + // this will cause an error and goto the Catch if the family or size is null, + // Westinghouse needs it to to this - at least for now + //if (ds.Font.Family != null) doc.Application.Selection.Font.Name = ds.Font.Family; + //if (ds.Font.Size != null) doc.Application.Selection.Font.Size = (float)ds.Font.Size; + doc.Application.Selection.Font.Name = ds.Font.Family; + doc.Application.Selection.Font.Size = (float)ds.Font.Size; + doc.Application.Selection.ParagraphFormat.SpaceBefore = 0; + doc.Application.Selection.ParagraphFormat.SpaceAfter = 0; + doc.Application.Selection.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly; + doc.Application.Selection.ParagraphFormat.LineSpacing = 72 / 6; // for 6 LPI + MSWordToPDF.AdjustMargins(ds, doc, false); + } + if (doc.ActiveWindow.ActivePane.View.Zoom.Percentage < 40) + doc.ActiveWindow.ActivePane.View.Zoom.Percentage = 100; + } + public void FindSearchString() + { + if (SearchString == null) return; + // Get the Document LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument()); - //LBSelection sel = wordDoc.Application.Selection; - LBFind find = wordDoc.Application.Selection.Find; - find.ClearFormatting(); - bool wildCards = SearchString.Contains("?") || SearchString.Contains("*"); - bool found = find.Execute(SearchString, false, false, wildCards, false, false, true, LBWdFindWrap.wdFindContinue, null, null, null, false, false, false, false); - //Console.WriteLine("find = {0}", found); - } - /// - /// Text will either replace current selection or be inserted at the current cursor position if no selection - /// - /// - public void InsertText(string txt) - { - if (txt == null || txt.Length == 0) return; //nothing to insert - // Get the Document - LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument()); - //This will get the selected range or just the current cursor position - LBSelection sel = wordDoc.Application.Selection; - // This will replace the selection or insert at current position - sel.Text = txt; - } + //LBSelection sel = wordDoc.Application.Selection; + LBFind find = wordDoc.Application.Selection.Find; + find.ClearFormatting(); + bool wildCards = SearchString.Contains("?") || SearchString.Contains("*"); + bool found = find.Execute(SearchString, false, false, wildCards, false, false, true, LBWdFindWrap.wdFindContinue, null, null, null, false, false, false, false); + //Console.WriteLine("find = {0}", found); + } + /// + /// Text will either replace current selection or be inserted at the current cursor position if no selection + /// + /// + public void InsertText(string txt) + { + if (txt == null || txt.Length == 0) return; //nothing to insert + // Get the Document + LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument()); + //This will get the selected range or just the current cursor position + LBSelection sel = wordDoc.Application.Selection; + // This will replace the selection or insert at current position + sel.Text = txt; + } - public string GetSelectedString() - { - LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument()); - //This will get the selected range or just the current cursor position - LBSelection sel = wordDoc.Application.Selection; - // if the start & end are the same, nothing is selected: - if (sel.Start == sel.End) return null; - return sel.Text; - } + public string GetSelectedString() + { + LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument()); + //This will get the selected range or just the current cursor position + LBSelection sel = wordDoc.Application.Selection; + // if the start & end are the same, nothing is selected: + if (sel.Start == sel.End) return null; + return sel.Text; + } - private string ShowException(Exception ex) - { - string sep = "\r\n "; - StringBuilder sb = new StringBuilder(); - do - { - sb.Append(sep + ex.Message); - sep += " "; - ex = ex.InnerException; - } while (ex != null); - return sb.ToString(); - } + private string ShowException(Exception ex) + { + string sep = "\r\n "; + StringBuilder sb = new StringBuilder(); + do + { + sb.Append(sep + ex.Message); + sep += " "; + ex = ex.InnerException; + } while (ex != null); + return sb.ToString(); + } - //void _MyDSOFramer_Leave(object sender, EventArgs e) - //{ - // vlnStackTrace.ShowStack("DSO Leave {0}", this.MyDocumentInfo.DocID); - //} + //void _MyDSOFramer_Leave(object sender, EventArgs e) + //{ + // vlnStackTrace.ShowStack("DSO Leave {0}", this.MyDocumentInfo.DocID); + //} - //void _MyDSOFramer_Enter(object sender, EventArgs e) - //{ - // vlnStackTrace.ShowStack("DSO Enter {0}", this.MyDocumentInfo.DocID); - //} + //void _MyDSOFramer_Enter(object sender, EventArgs e) + //{ + // vlnStackTrace.ShowStack("DSO Enter {0}", this.MyDocumentInfo.DocID); + //} - //void _MyDSOFramer_GotFocus(object sender, EventArgs e) - //{ - // vlnStackTrace.ShowStack("DSO Got Focus {0}",this.MyDocumentInfo.DocID); - //} + //void _MyDSOFramer_GotFocus(object sender, EventArgs e) + //{ + // vlnStackTrace.ShowStack("DSO Got Focus {0}",this.MyDocumentInfo.DocID); + //} - //void _MyDSOFramer_LostFocus(object sender, EventArgs e) - //{ - // vlnStackTrace.ShowStack("DSO Lost Focus {0}", this.MyDocumentInfo.DocID); - //} - public void EnterPanel() - { - DSOTabPanel_Enter(this, new EventArgs()); - } - //void DSOTabPanel_LostFocus(object sender, EventArgs e) - //{ - // vlnStackTrace.ShowStack("DSOTabPanel_LostFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName); - //} - //void DSOTabPanel_GotFocus(object sender, EventArgs e) - //{ - // vlnStackTrace.ShowStack("DSOTabPanel_GotFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName); - //} - #endregion - #region Event Handlers - /// - /// Display MyTransparentPanel over the DSOPanel so that the Word "Inactive" appears in the upper right hand corner. - /// - public void InActive() - { - _MyTransparentPanel.BringToFront(); - } - /// - /// Force this item to be selected when the transparent window is clicked. - /// This will in-turn send the Transparent Panel to back and make the DSO Panel - /// editable. - /// - /// - /// - void _MyTransparentPanel_Click(object sender, EventArgs e) - { - this.Select(); - } - ///// - ///// If the user presses the save button, tell the file to save it's contents to the database - ///// - ///// - ///// - //void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e) - //{ - // _MyLog.WarnFormat("_MyDSOFramer_OnSaveCompleted"); - // Volian.Base.Library.vlnStackTrace.ShowStack("_MyDSOFramer_OnSaveCompleted"); - // SaveDSO_Phase2(); - //} + //void _MyDSOFramer_LostFocus(object sender, EventArgs e) + //{ + // vlnStackTrace.ShowStack("DSO Lost Focus {0}", this.MyDocumentInfo.DocID); + //} + public void EnterPanel() + { + DSOTabPanel_Enter(this, new EventArgs()); + } + //void DSOTabPanel_LostFocus(object sender, EventArgs e) + //{ + // vlnStackTrace.ShowStack("DSOTabPanel_LostFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName); + //} + //void DSOTabPanel_GotFocus(object sender, EventArgs e) + //{ + // vlnStackTrace.ShowStack("DSOTabPanel_GotFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName); + //} + #endregion + #region Event Handlers + /// + /// Display MyTransparentPanel over the DSOPanel so that the Word "Inactive" appears in the upper right hand corner. + /// + public void InActive() + { + _MyTransparentPanel.BringToFront(); + } + /// + /// Force this item to be selected when the transparent window is clicked. + /// This will in-turn send the Transparent Panel to back and make the DSO Panel + /// editable. + /// + /// + /// + void _MyTransparentPanel_Click(object sender, EventArgs e) + { + this.Select(); + } + ///// + ///// If the user presses the save button, tell the file to save it's contents to the database + ///// + ///// + ///// + //void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e) + //{ + // _MyLog.WarnFormat("_MyDSOFramer_OnSaveCompleted"); + // Volian.Base.Library.vlnStackTrace.ShowStack("_MyDSOFramer_OnSaveCompleted"); + // SaveDSO_Phase2(); + //} - private void SaveDSO_Phase2() - { - // Unfortunately, the only way to handle view mode for DSO Framer is to not save. - if (PanelViewEditMode == E_ViewMode.View) - { - MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip); - return; - } - LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); - //while (doc.Saved = false) - // Application.DoEvents(); - string tmp = GetReflectiveProperty(_MyEdWord.ActiveDocument(), "FullName"); - if (System.IO.File.Exists(tmp)) - MyDSOFile.FullName = tmp; - else - _MyLog.FatalFormat("File does not exist {0}\r\nFile was {1}", tmp, MyDSOFile.FullName); - // if this was a library document, ask user if it should be saved for all usages. - bool cvtLibDoc = false; - if (MyDisplayTabItem.MyItemInfo != null) // B2016-131 if myiteminfo is null then the lib doc is not referenced, so just save the changes - don't generate a pdf - { - EntryInfo myei = MyDisplayTabItem.MyItemInfo.MyContent.MyEntry; - if (myei != null && myei.MyDocument != null && myei.MyDocument.LibTitle != null && myei.MyDocument.LibTitle != "") - { - // C2019-033 - make save options more clear with respect to library documents - string msgstr = "Save to Library Document?" + - "\n\n YES - Save for all usages of this Library Document." + - "\n\n NO - Unlink this Section from the Library Document and Save in this Word Section.\n\n" + - _MyDocumentInfo.LibraryDocumentUsageAll; - DialogResult ans = FlexibleMessageBox.Show(msgstr, "Document Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (ans == DialogResult.No) cvtLibDoc = true; - } - } - MyDSOFile.SaveFile(doc.Length, doc.Ascii, MyDisplayTabItem.MyItemInfo, cvtLibDoc, StatusChanged); - if (cvtLibDoc) - { - MyDisplayTabItem.Text = MyDisplayTabItem.MyItemInfo.TabTitle; - MyDisplayTabItem.Tooltip = MyDisplayTabItem.MyItemInfo.TabToolTip; - MyDisplayTabItem.SetPrivateTooltip(MyDisplayTabItem.MyItemInfo.TabToolTip); - } - } - public void StatusChanged(VolianStatusType type, int count, string text) - { - if (Parent != null && Parent.Parent != null && Parent.Parent.Parent is DisplayTabControl) - { - DisplayTabControl tc = Parent.Parent.Parent as DisplayTabControl; - tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text)); - } - } - ///// - ///// Before a document closes check to see if it's contents should be saved. - ///// - ///// - ///// - //void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e) - //{ - // SaveDSOPhase1(); - //} + private void SaveDSO_Phase2() + { + // Unfortunately, the only way to handle view mode for DSO Framer is to not save. + if (PanelViewEditMode == E_ViewMode.View) + { + MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip); + return; + } + LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); + //while (doc.Saved = false) + // Application.DoEvents(); + string tmp = GetReflectiveProperty(_MyEdWord.ActiveDocument(), "FullName"); + if (System.IO.File.Exists(tmp)) + MyDSOFile.FullName = tmp; + else + _MyLog.FatalFormat("File does not exist {0}\r\nFile was {1}", tmp, MyDSOFile.FullName); + // if this was a library document, ask user if it should be saved for all usages. + bool cvtLibDoc = false; + if (MyDisplayTabItem.MyItemInfo != null) // B2016-131 if myiteminfo is null then the lib doc is not referenced, so just save the changes - don't generate a pdf + { + EntryInfo myei = MyDisplayTabItem.MyItemInfo.MyContent.MyEntry; + if (myei != null && myei.MyDocument != null && myei.MyDocument.LibTitle != null && myei.MyDocument.LibTitle != "") + { + // C2019-033 - make save options more clear with respect to library documents + string msgstr = "Save to Library Document?" + + "\n\n YES - Save for all usages of this Library Document." + + "\n\n NO - Unlink this Section from the Library Document and Save in this Word Section.\n\n" + + _MyDocumentInfo.LibraryDocumentUsageAll; + DialogResult ans = FlexibleMessageBox.Show(msgstr, "Document Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (ans == DialogResult.No) cvtLibDoc = true; + } + } + MyDSOFile.SaveFile(doc.Length, doc.Ascii, MyDisplayTabItem.MyItemInfo, cvtLibDoc, StatusChanged); + if (cvtLibDoc) + { + MyDisplayTabItem.Text = MyDisplayTabItem.MyItemInfo.TabTitle; + MyDisplayTabItem.Tooltip = MyDisplayTabItem.MyItemInfo.TabToolTip; + MyDisplayTabItem.SetPrivateTooltip(MyDisplayTabItem.MyItemInfo.TabToolTip); + } + } + public void StatusChanged(VolianStatusType type, int count, string text) + { + if (Parent != null && Parent.Parent != null && Parent.Parent.Parent is DisplayTabControl) + { + DisplayTabControl tc = Parent.Parent.Parent as DisplayTabControl; + tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text)); + } + } + ///// + ///// Before a document closes check to see if it's contents should be saved. + ///// + ///// + ///// + //void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e) + //{ + // SaveDSOPhase1(); + //} - private void SaveDSO_Phase1() - { - try - { - if (!IsBeingDeleted) - SaveDirty(); - this.Enter -= new EventHandler(DSOTabPanel_Enter); - // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel - this.Leave -= DSOTabPanel_Leave; - // SaveDirty(); // SaveDirty happens in CloseDSO(bool) - } - catch (Exception ex) - { - _MyLog.Warn("Before Closing Document ", ex); - } - } - /// - /// Save the contents of the Word Document to a file - /// and save the file to the database - /// - /// - public bool SaveDSO() - { - bool result = true; - try - { - bool stat = _MyEdWord.Save();// B2017-133 Edraw - //Console.WriteLine("Save = {0}", stat); - SaveDSO_Phase2(); - //_MyDSOFramer_OnSaveCompleted(this, null); - // These are handled in the method above - //LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); - //MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName"); - //MyDSOFile.SaveFile(doc.Length, doc.Ascii); - } - catch (Exception ex) - { - if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO", ex); - MessageBox.Show(ex.Message, "Error Saving Document", MessageBoxButtons.OK, MessageBoxIcon.Error); - result = false; - } - return result; - } - /// - /// Check to see if a Word document should be saved. If it is dirty ask the user if the - /// changes should be changed. Save the changes if the user says "yes". - /// - /// - public bool SaveDirty() - { - if (OverrideClose) - return false; - // B2017-249 Recover Temporary File And AutoSave support for MSWord - if (IsDirty || MyDSOFile.MyDocument.ContentIsDirty) - { - // Unfortunately, the only way to handle view mode for DSO Framer is to not save. - if (PanelViewEditMode == E_ViewMode.View || !_AllowedToEdit) - { - MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip); - return false; - } - //if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.MyItemInfo.TabTitle + "\r\n" + _MyDisplayTabItem.MyItemInfo.TabToolTip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - // B2017-249 Recover Temporary File And AutoSave support for MSWord - // C2019-033 - make save options more clear with respect to library documents second dialog will appear if Yes is selected and it's a library document - string msgstr = "Save changes to " + (MyDSOFile.MyDocument.ContentIsDirty ? "Recovered Version of " : "") + _MyDisplayTabItem.Text; + private void SaveDSO_Phase1() + { + try + { + if (!IsBeingDeleted) + SaveDirty(); + this.Enter -= new EventHandler(DSOTabPanel_Enter); + // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel + this.Leave -= DSOTabPanel_Leave; + // SaveDirty(); // SaveDirty happens in CloseDSO(bool) + } + catch (Exception ex) + { + _MyLog.Warn("Before Closing Document ", ex); + } + } + /// + /// Save the contents of the Word Document to a file + /// and save the file to the database + /// + /// + public bool SaveDSO() + { + bool result = true; + try + { + bool stat = _MyEdWord.Save();// B2017-133 Edraw + //Console.WriteLine("Save = {0}", stat); + SaveDSO_Phase2(); + //_MyDSOFramer_OnSaveCompleted(this, null); + // These are handled in the method above + //LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); + //MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName"); + //MyDSOFile.SaveFile(doc.Length, doc.Ascii); + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO", ex); + MessageBox.Show(ex.Message, "Error Saving Document", MessageBoxButtons.OK, MessageBoxIcon.Error); + result = false; + } + return result; + } + /// + /// Check to see if a Word document should be saved. If it is dirty ask the user if the + /// changes should be changed. Save the changes if the user says "yes". + /// + /// + public bool SaveDirty() + { + if (OverrideClose) + return false; + // B2017-249 Recover Temporary File And AutoSave support for MSWord + if (IsDirty || MyDSOFile.MyDocument.ContentIsDirty) + { + // Unfortunately, the only way to handle view mode for DSO Framer is to not save. + if (PanelViewEditMode == E_ViewMode.View || !_AllowedToEdit) + { + MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip); + return false; + } + //if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.MyItemInfo.TabTitle + "\r\n" + _MyDisplayTabItem.MyItemInfo.TabToolTip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + // B2017-249 Recover Temporary File And AutoSave support for MSWord + // C2019-033 - make save options more clear with respect to library documents second dialog will appear if Yes is selected and it's a library document + string msgstr = "Save changes to " + (MyDSOFile.MyDocument.ContentIsDirty ? "Recovered Version of " : "") + _MyDisplayTabItem.Text; if (FlexibleMessageBox.Show(msgstr, (IsDirty ? "Document has Changed" : "Previous Changes were not Saved"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - return SaveDSO(); - //Console.WriteLine("Delete {0}", MyDSOFile.MyFile.Name); - DeleteOnClose = true; - return false; - } - return true; - } - // B2017-249 Recover Temporary File And AutoSave support for MSWord - private bool _DeleteOnClose = false; + return SaveDSO(); + //Console.WriteLine("Delete {0}", MyDSOFile.MyFile.Name); + DeleteOnClose = true; + return false; + } + return true; + } + // B2017-249 Recover Temporary File And AutoSave support for MSWord + private bool _DeleteOnClose = false; - public bool DeleteOnClose - { - get { return _DeleteOnClose; } - set { _DeleteOnClose = value; } - } - public static bool IgnoreEnter = false; + public bool DeleteOnClose + { + get { return _DeleteOnClose; } + set { _DeleteOnClose = value; } + } + public static bool IgnoreEnter = false; private bool _In_DSOTabPanel_Enter=false; - // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel - private bool _InDSOTabPanel = false; - /// - /// When a Word document is selected make sure it's tab is activated and - /// the SelectedItem for the DisplayTabControl is updated. - /// - /// - /// - private void DSOTabPanel_Enter(object sender, EventArgs e) - { - // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel - _InDSOTabPanel = true; - if (IgnoreEnter) return; - _MyTransparentPanel.SendToBack(); + // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel + private bool _InDSOTabPanel = false; + /// + /// When a Word document is selected make sure it's tab is activated and + /// the SelectedItem for the DisplayTabControl is updated. + /// + /// + /// + private void DSOTabPanel_Enter(object sender, EventArgs e) + { + // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel + _InDSOTabPanel = true; + if (IgnoreEnter) return; + _MyTransparentPanel.SendToBack(); - // Set whether this worddoc is in view/edit mode by checking whether the - // procedure is in view/edit mode (based on the steppanel. This occurs on - // the enter event so that the mode is determined any time this panel becomes - // active. - // find steptabpanel and its view/edit. If it doesn't have a steptabpanel - // use default - edit. Later when we have ownership, need to use that. + // Set whether this worddoc is in view/edit mode by checking whether the + // procedure is in view/edit mode (based on the steppanel. This occurs on + // the enter event so that the mode is determined any time this panel becomes + // active. + // find steptabpanel and its view/edit. If it doesn't have a steptabpanel + // use default - edit. Later when we have ownership, need to use that. PanelViewEditMode = E_ViewMode.Edit; // default to edit - if (MyDisplayTabItem.MyItemInfo != null) // lib doc with no associated active procedure defaults to edit - { - StepTabPanel stpanel = _MyDisplayTabControl.GetProcedureTabPanel(MyDisplayTabItem.MyItemInfo); - PanelViewEditMode = (stpanel == null) ? E_ViewMode.Edit : stpanel.MyStepPanel.VwMode; - } - try - { - //_MyDSOFramer.EventsEnabled = true; - //_MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; - } - catch (Exception ex) - { - if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex); - } - if (_In_DSOTabPanel_Enter) return; - //vlnStackTrace.ShowStack("DSOTabPanel_Enter {0} DocID {1} Index {2} {3}",_In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName); - _In_DSOTabPanel_Enter = true; + if (MyDisplayTabItem.MyItemInfo != null) // lib doc with no associated active procedure defaults to edit + { + StepTabPanel stpanel = _MyDisplayTabControl.GetProcedureTabPanel(MyDisplayTabItem.MyItemInfo); + PanelViewEditMode = (stpanel == null) ? E_ViewMode.Edit : stpanel.MyStepPanel.VwMode; + } + try + { + //_MyDSOFramer.EventsEnabled = true; + //_MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex); + } + if (_In_DSOTabPanel_Enter) return; + //vlnStackTrace.ShowStack("DSOTabPanel_Enter {0} DocID {1} Index {2} {3}",_In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName); + _In_DSOTabPanel_Enter = true; if (MyDisplayTabItem.MyItemInfo != null) _MyDisplayTabControl.OnItemSelectedChanged(this,new ItemSelectedChangedEventArgs(MyDisplayTabItem.MyItemInfo)); - _MyEdWord.Focus(); - _In_DSOTabPanel_Enter = false; - _MyDisplayTabControl.SelectedDisplayTabItem = MyDisplayTabItem; - // B2018-070 Position the text cursor - Activate MS Word Panel - _MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null); - } - #endregion - #region Public Methods - private bool _IsBeingDeleted = false; - public bool IsBeingDeleted - { - get { return _IsBeingDeleted; } - set { _IsBeingDeleted = value; } - } - /// - /// Cleans-up the DSO Framer window - /// - /// - public bool CloseDSO() - { - return CloseDSO(false); - } - /// - /// Cleans-up the DSO Framer window - /// - /// - /// - public bool CloseDSO(bool force) - { - _MyLog.Debug("CloseDSO"); - bool result = true; - try - { - if (_MyEdWord != null) - { - SaveDSO_Phase1(); - _MyEdWord.CloseDoc(); - Controls.Remove(_MyEdWord); - components.Remove(_MyEdWord); - _MyEdWord.Dispose(); - _MyEdWord = null; - // B2017-249 Recover Temporary File And AutoSave support for MSWord - if (DeleteOnClose) MyDSOFile.MyFile.Delete(); - _Count--; - } - } - catch (Exception ex) - { - if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO - " + this.Name, ex); - result = false; - } - return result; - } - /// - /// Activates the current DSO Framer window (Word) - /// - public void Activate() - { - try - { - //this._MyEdWord.Activate(); - //if (_MyCount <= MSWordLimit) - // this._MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; - } - catch (Exception ex) - { - if (_MyLog.IsErrorEnabled) _MyLog.Error("Activate", ex); - } - } - #endregion - #region DocumentProperties + _MyEdWord.Focus(); + _In_DSOTabPanel_Enter = false; + _MyDisplayTabControl.SelectedDisplayTabItem = MyDisplayTabItem; + // B2018-070 Position the text cursor - Activate MS Word Panel + _MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null); + } + #endregion + #region Public Methods + private bool _IsBeingDeleted = false; + public bool IsBeingDeleted + { + get { return _IsBeingDeleted; } + set { _IsBeingDeleted = value; } + } + /// + /// Cleans-up the DSO Framer window + /// + /// + public bool CloseDSO() + { + return CloseDSO(false); + } + /// + /// Cleans-up the DSO Framer window + /// + /// + /// + public bool CloseDSO(bool force) + { + _MyLog.Debug("CloseDSO"); + bool result = true; + try + { + if (_MyEdWord != null) + { + SaveDSO_Phase1(); + _MyEdWord.CloseDoc(); + Controls.Remove(_MyEdWord); + components.Remove(_MyEdWord); + _MyEdWord.Dispose(); + _MyEdWord = null; + // B2017-249 Recover Temporary File And AutoSave support for MSWord + if (DeleteOnClose) MyDSOFile.MyFile.Delete(); + _Count--; + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO - " + this.Name, ex); + result = false; + } + return result; + } + /// + /// Activates the current DSO Framer window (Word) + /// + public void Activate() + { + try + { + //this._MyEdWord.Activate(); + //if (_MyCount <= MSWordLimit) + // this._MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Activate", ex); + } + } + #endregion + #region DocumentProperties - private string GetReflectiveProperty(object objectToInspect, string propertyName) - { - string returnString = ""; - //To use reflection on an object, you - // first need to get an instance - // of that object's type. - Type objectType = objectToInspect.GetType(); - //After you have the object's type, you can get - // information on that type. In this case, we're - // asking the type to tell us all the - // properties that it contains. - PropertyInfo[] properties = objectType.GetProperties(); - //You can then use the PropertyInfo array - // to loop through each property of the type. - foreach (PropertyInfo property in properties) - { - //The interest part of this code - // is the GetValue method. This method - // returns the value of the property. + private string GetReflectiveProperty(object objectToInspect, string propertyName) + { + string returnString = ""; + //To use reflection on an object, you + // first need to get an instance + // of that object's type. + Type objectType = objectToInspect.GetType(); + //After you have the object's type, you can get + // information on that type. In this case, we're + // asking the type to tell us all the + // properties that it contains. + PropertyInfo[] properties = objectType.GetProperties(); + //You can then use the PropertyInfo array + // to loop through each property of the type. + foreach (PropertyInfo property in properties) + { + //The interest part of this code + // is the GetValue method. This method + // returns the value of the property. if(property.Name == propertyName) - return property.GetValue(objectToInspect, null).ToString(); - } - return null; - } - #endregion - public override string ToString() - { - return string.Format("DSOTabPanel Document {0}", MyDocumentInfo.DocID); - } - } + return property.GetValue(objectToInspect, null).ToString(); + } + return null; + } + #endregion + public override string ToString() + { + return string.Format("DSOTabPanel Document {0}", MyDocumentInfo.DocID); + } + } } diff --git a/PROMS/Volian.Controls.Library/DisplayApplicability.Designer.cs b/PROMS/Volian.Controls.Library/DisplayApplicability.Designer.cs index cc37fbea..e51b1e5b 100644 --- a/PROMS/Volian.Controls.Library/DisplayApplicability.Designer.cs +++ b/PROMS/Volian.Controls.Library/DisplayApplicability.Designer.cs @@ -23,7 +23,6 @@ namespace Volian.Controls.Library base.Dispose(disposing); } - #region Component Designer generated code /// @@ -34,7 +33,6 @@ namespace Volian.Controls.Library { this.gpMode = new DevComponents.DotNetBar.Controls.GroupPanel(); this.gpItem = new DevComponents.DotNetBar.Controls.GroupPanel(); - this.btnApplicabilitychg2 = new DevComponents.DotNetBar.ButtonItem(); this.btnApplicabilitychg = new DevComponents.DotNetBar.ButtonX(); this.superTooltip1 = new DevComponents.DotNetBar.SuperTooltip(); this.gpItem.SuspendLayout(); @@ -42,14 +40,14 @@ namespace Volian.Controls.Library // // btnApplicabilitychg // - this.btnApplicabilitychg.Location = new System.Drawing.Point(60, 8); + this.btnApplicabilitychg.Location = new System.Drawing.Point(90, 8); this.btnApplicabilitychg.Margin = new System.Windows.Forms.Padding(4); this.btnApplicabilitychg.BackColor = System.Drawing.SystemColors.Control; this.btnApplicabilitychg.Name = "btnApplicabilitychg"; - this.btnApplicabilitychg.Size = new System.Drawing.Size(80, 22); + this.btnApplicabilitychg.Size = new System.Drawing.Size(87, 22); this.btnApplicabilitychg.Margin = new System.Windows.Forms.Padding(2); this.btnApplicabilitychg.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.superTooltip1.SetSuperTooltip(this.btnApplicabilitychg, new DevComponents.DotNetBar.SuperTooltipInfo("Change applicability settings - All At Level", "", "When clicked, all steps at the level of the current step will have their applicability settings changed. Note that for two column procedures, the left column and right column are handled separately.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray)); + this.superTooltip1.SetSuperTooltip(this.btnApplicabilitychg, new DevComponents.DotNetBar.SuperTooltipInfo("Set All at Level", "", "When clicked, all steps at that level of the current step will be set to the selected applicability. Note that the Set All at Level button is disabled for RNO step types unless they are substeps off of a RNO step.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray)); // C2026-034 fix tool tip text. this.btnApplicabilitychg.TabIndex = 0; this.btnApplicabilitychg.Text = "Set All at Level"; this.btnApplicabilitychg.ColorTable = DevComponents.DotNetBar.eButtonColor.BlueOrb; @@ -106,13 +104,12 @@ namespace Volian.Controls.Library this.gpItem.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.gpItem.CanvasColor = System.Drawing.SystemColors.Control; this.gpItem.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; - //this.gpItem.Controls.Add(this.btnApplicabilitychg); this.gpItem.DisabledBackColor = System.Drawing.Color.Empty; this.gpItem.Dock = System.Windows.Forms.DockStyle.Top; this.gpItem.Location = new System.Drawing.Point(0, 49); this.gpItem.Margin = new System.Windows.Forms.Padding(4); this.gpItem.Name = "gpItem"; - this.gpItem.Padding = new System.Windows.Forms.Padding(13, 12, 13, 37); + this.gpItem.Padding = new System.Windows.Forms.Padding(0, 20, 0, 0); this.gpItem.Size = new System.Drawing.Size(432, 85); // // @@ -169,9 +166,9 @@ namespace Volian.Controls.Library private DevComponents.DotNetBar.Controls.GroupPanel gpMode; private DevComponents.DotNetBar.Controls.GroupPanel gpItem; - private DevComponents.DotNetBar.ButtonItem btnApplicabilitychg2; private DevComponents.DotNetBar.ButtonX btnApplicabilitychg; private DevComponents.DotNetBar.SuperTooltip superTooltip1; } } + diff --git a/PROMS/Volian.Controls.Library/DisplayApplicability.cs b/PROMS/Volian.Controls.Library/DisplayApplicability.cs index 48b7003e..1f4a388c 100644 --- a/PROMS/Volian.Controls.Library/DisplayApplicability.cs +++ b/PROMS/Volian.Controls.Library/DisplayApplicability.cs @@ -21,20 +21,24 @@ namespace Volian.Controls.Library if (ApplicabilityViewModeChanged != null) ApplicabilityViewModeChanged(this, new EventArgs()); } + private DisplayTabItem _MyDisplayTabItem = null; public DisplayTabItem MyDisplayTabItem { get { return _MyDisplayTabItem; } set { - if (DesignMode) return; // B2019-043 need to check if we are just saving changes to the user interface + if (DesignMode) return; // B2019-043 need to check if we are just saving changes to the user interface _MyDisplayTabItem = value; gpMode.Controls.Clear(); gpItem.Controls.Clear(); MyCheckBoxes.Clear(); if (_MyDisplayTabItem != null) { - DocVersionConfig dcfg = _MyDisplayTabItem.MyItemInfo.MyDocVersion.MyConfig as DocVersionConfig; + //B2026-043 Fix "Set All At Level" button. + DevComponents.DotNetBar.Controls.GroupPanel gpSubItem = InitializegpSubItem(); + + DocVersionConfig dcfg = _MyDisplayTabItem.MyItemInfo.MyDocVersion.MyConfig as DocVersionConfig; List names = new List(); for (int n = 1; n <= dcfg.Unit_Count; n++) { @@ -42,7 +46,7 @@ namespace Volian.Controls.Library names.Add(dcfg.Unit_Name); } dcfg.SelectedSlave = 0; -// string[] names = dcfg.Unit_Name.Split(','); + // string[] names = dcfg.Unit_Name.Split(','); int apple = -1; if(_MyDisplayTabItem.MyStepTabPanel != null) apple = _MyDisplayTabItem.MyStepTabPanel.MyStepPanel.ApplDisplayMode; @@ -54,11 +58,13 @@ namespace Volian.Controls.Library AddViewMode(name.Trim(), i.ToString(), apple == i); } - AddItemMode("All", "-1"); + AddItemMode("All", "-1", ref gpSubItem); i = 0; foreach (string name in names) - AddItemMode(name.Trim(), (++i).ToString()); - AddItemMode("None", "0"); + AddItemMode(name.Trim(), (++i).ToString(), ref gpSubItem); + AddItemMode("None", "0", ref gpSubItem); + gpItem.Controls.Add(gpSubItem); + gpSubItem.BringToFront(); gpItem.Controls.Add(btnApplicabilitychg); btnApplicabilitychg.BringToFront(); if (_MyDisplayTabItem.MyStepTabPanel != null) @@ -85,6 +91,37 @@ namespace Volian.Controls.Library return 0; } } + private DevComponents.DotNetBar.Controls.GroupPanel InitializegpSubItem() //B2026-043 Fix "Set All At Level" button. + { + DevComponents.DotNetBar.Controls.GroupPanel gpSubItem; + gpSubItem = new DevComponents.DotNetBar.Controls.GroupPanel + { + // + // gpSubItem + // + AutoSize = true, + AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink, + CanvasColor = System.Drawing.SystemColors.Control, + ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007, + DisabledBackColor = System.Drawing.Color.Empty, + Dock = System.Windows.Forms.DockStyle.Top, + Location = new System.Drawing.Point(0, 49), + Margin = new System.Windows.Forms.Padding(4), + Name = "gpSubItem", + Padding = new System.Windows.Forms.Padding(13, 12, 13, 37) + }; + gpSubItem.BackColor = Color.Transparent; + gpSubItem.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center; + gpSubItem.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; + gpSubItem.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near; + gpSubItem.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square; + gpSubItem.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; + gpSubItem.TabIndex = 1; + gpSubItem.Text = ""; + gpSubItem.Location = new System.Drawing.Point(0, 49); + gpSubItem.Size = new System.Drawing.Size(400, 250); + return gpSubItem; + } private Dictionary MyCheckBoxes = new Dictionary(); private string _MyApplicability = string.Empty; public string MyApplicability @@ -128,20 +165,25 @@ namespace Volian.Controls.Library // } //} //} - private void AddItemMode(string name, string value) + private void AddItemMode(string name, string value, ref DevComponents.DotNetBar.Controls.GroupPanel gpSubItem) { CheckBox cb = new CheckBox(); cb.BackColor = Color.Transparent; + cb.Height = 24; + cb.Width = 75; + cb.AutoSize = true; cb.Text = name; cb.Tag = value; cb.Dock = DockStyle.Top; - gpItem.Controls.Add(cb); + gpSubItem.Controls.Add(cb); cb.BringToFront(); cb.CheckedChanged += new EventHandler(cb_CheckedChanged); MyCheckBoxes.Add(value == null ? -1 : int.Parse(value), cb); } private void cb_CheckedChanged(object sender, EventArgs e) { + EditItem ei = MyDisplayTabItem.MyStepTabPanel.SelectedEditItem; + ei.SaveCurrentAndContents(); // C2026-035 save unsaved step text. UnwireCheckboxes(false); CheckBox cb = sender as CheckBox; CheckState cs = cb.CheckState; @@ -287,8 +329,12 @@ namespace Volian.Controls.Library MasterSlave_ApplicabilityTmp = sc.MasterSlave_Applicability; StringBuilder sb = new StringBuilder(); + EditItem ei = MyDisplayTabItem.MyStepTabPanel.SelectedEditItem; + ei.SaveCurrentAndContents(); // C2026-035 save unsaved step text. - ItemInfo startitm = MyItemInfo.FirstSibling; + + + ItemInfo startitm = MyItemInfo.FirstSibling; while (startitm != null) { @@ -390,10 +436,18 @@ namespace Volian.Controls.Library } } } - _MyItemInfo = value; + _MyItemInfo = value; if (_MyItemInfo != null) { if (this.Visible == false) return; + if (_MyItemInfo.IsRNOPart == true) // Check if step is an RNO disable "Set All To Level" button. + { + btnApplicabilitychg.Enabled = false; + } + else + { + btnApplicabilitychg.Enabled = true; + } IItemConfig cfg = _MyItemInfo.MyConfig as IItemConfig; List apples = cfg.MasterSlave_Applicability.GetFlags(); UnwireCheckboxes(true); @@ -489,7 +543,7 @@ namespace Volian.Controls.Library public DisplayApplicability() { - InitializeComponent(); + InitializeComponent(); //B2026-043 Fix "Set All At Level" button. this.VisibleChanged += new EventHandler(DisplayApplicability_VisibleChanged); } @@ -500,3 +554,4 @@ namespace Volian.Controls.Library } } } + diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index de678a4b..dcd0572a 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -960,7 +960,9 @@ namespace Volian.Print.Library OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage); if (myProcedure.Sections == null) { - MessageBox.Show("This procedure has no content and will not be printed.", "Empty Procedure", MessageBoxButtons.OK, MessageBoxIcon.Information); + // C2026-033 if we are running baselines, don't display the empty procedure message box, instead continue on as if OK was pressed. + if (!BaselineTesting) + MessageBox.Show("This procedure has no content and will not be printed.", "Empty Procedure", MessageBoxButtons.OK, MessageBoxIcon.Information); ProfileTimer.Pop(profileDepth); // B2024-062 Added check for EmptyProcedure. This is to prevent the Try Again message // from appearing after the user clicks on the OK button from the Empty Procedure message