public ValidateForm(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl, string vuiFileName, BackgroundWorker backgroundWorkerPathMaker) { this.vuiFileName = vuiFileName; this.backgroundWorkerPathMaker = backgroundWorkerPathMaker; this.visioControl = visioControl; InitializeComponent(); }
public static string getCurrentFileDirectory(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl) { if (visioControl.Src.Contains(Strings.VisioTemplateFileSuffix)) return Environment.GetFolderPath(Environment.SpecialFolder.Personal); else return System.IO.Path.GetDirectoryName(visioControl.Src); }
public ValidateResultsForm(string results, AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControlIn, string formName) { InitializeComponent(); UISpecResults_Load(results); this.BringToFront(); visioControl = visioControlIn; this.results = results; //Close any open UI Spec results form CloseAllForms(formName); }
public DialogResult SaveDrawing(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl, bool promptFirst, bool saveAs) { if (visioControl == null) return DialogResult.Cancel; if (visioControl.Document.Saved && !saveAs) return DialogResult.Ignore; DialogResult result = DialogResult.No; string targetFilename = string.Empty; string currentFileName = string.Empty; Document targetDocument; targetFilename = visioControl.Src; targetDocument = (Document)visioControl.Document; currentFileName = System.IO.Path.GetFileName(targetFilename); // Prompt to save changes. if (promptFirst == true) { string prompt = string.Empty; string title = string.Empty; title = Common.GetResourceString(Strings.SaveDialogTitleRes); if (targetFilename == null) return DialogResult.Cancel; // Save changes to the existing drawing. if ((saveAs || targetFilename.Length > 0) && (!targetFilename.Contains(Strings.VisioTemplateFileSuffix))) { prompt = Common.GetResourceString(Strings.SavePromptRes); prompt += Environment.NewLine; prompt += targetFilename; } else { // Save changes as new drawing. prompt = Common.GetResourceString(Strings.SaveAsPromptRes); } result = MessageBox.Show(prompt, title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); } else result = DialogResult.Yes; // Display a file browse dialog to select path and filename. if ((DialogResult.Yes == result) && (saveAs || targetFilename.Length == 0 || targetFilename.Contains(Strings.VisioTemplateFileSuffix))) { // Set up the save file dialog and let the user specify the // name to save the document to. if (saveFileDialog == null) { saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = Common.GetResourceString(Strings.SaveDialogTitleRes); saveFileDialog.Filter = Common.GetResourceString(Strings.SaveDialogFilterRes); saveFileDialog.FilterIndex = 1; } saveFileDialog.InitialDirectory = getCurrentFileDirectory(); if (targetFilename.Contains(Strings.VisioTemplateFileSuffix)) saveFileDialog.FileName = Strings.DefaultFileName; else saveFileDialog.FileName = Common.StripExtensionFileName(currentFileName) + Strings.DefaultCopyFileNameSuffix; if (saveFileDialog.ShowDialog() == DialogResult.OK) targetFilename = saveFileDialog.FileName; else targetFilename = string.Empty; } // Save the document to the filename specified by // the end user in the save file dialog, or the existing file name. if ((DialogResult.Yes == result) && (targetFilename.Length > 0)) { if (targetDocument != null) targetDocument.SaveAs(targetFilename); // without these garbage collection calls in here, we get an access violation... GC.Collect(); GC.WaitForPendingFinalizers(); if (!visioControl.Src.Equals(targetFilename)) { visioControl.Src = targetFilename; OnSrcDocumentChange(); } visioControl.Document.Saved = true; } return result; }
internal static void ExportPromptList(DateTime? onOrAfterDate, bool hyperLinks, AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl) { string targetFilename; string currentFileName; if (saveFileDialog == null) { saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = Common.GetResourceString(Strings.SavePromptsTitleRes); saveFileDialog.Filter = Common.GetResourceString(Strings.SavePromptsFilterRes); saveFileDialog.FilterIndex = 1; // Excel will ask about overwriting and I can't find a way to bypass that - so // skip it here and let excel do it on wb.close saveFileDialog.OverwritePrompt = false; } saveFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(visioControl); targetFilename = visioControl.Src; currentFileName = System.IO.Path.GetFileName(targetFilename); saveFileDialog.FileName = Common.StripExtensionFileName(currentFileName) + ".xlsx"; if (saveFileDialog.ShowDialog() == DialogResult.OK) targetFilename = saveFileDialog.FileName; else return; Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application(); if (excelApp == null) { Common.ErrorMessage("Couldn't start Excel - make sure it's installed"); return; } excelApp.Visible = false; Workbook wb = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet); Worksheet ws = (Worksheet)wb.Worksheets[1]; if (ws == null) { Common.ErrorMessage("Excel worksheet couldn't be created."); return; } DocTitleShadow shadow = PathMaker.LookupDocTitleShadow(); string client = ""; string project = ""; if (shadow != null) { client = shadow.GetClientName(); project = shadow.GetProjectName(); } ws.Cells[1, 1].Value = "Client: " + client; ws.Cells[2, 1].Value = "Project: " + project; ws.Cells[3, 1].Value = "Date: " + DateTime.Now.ToString(Strings.DateColumnFormatString); ws.Columns["A:A"].ColumnWidth = 8; ws.Columns["B:C"].ColumnWidth = 30; ws.Columns["D:E"].ColumnWidth = 50; ((Range)ws.Columns["C:E"]).EntireColumn.WrapText = true; ws.Cells[5, 1].Value = "Count"; ws.Cells[5, 2].Value = "Prompt ID"; ws.Cells[5, 3].Value = "Duplicate IDs"; ws.Cells[5, 4].Value = "Prompt Wording"; ws.Cells[5, 5].Value = "Notes"; ws.Cells[5, 1].Font.Bold = true; ws.Cells[5, 2].Font.Bold = true; ws.Cells[5, 3].Font.Bold = true; ws.Cells[5, 4].Font.Bold = true; ws.Cells[5, 5].Font.Bold = true; PromptRecordingList recordingList = Common.GetPromptRecordingList(onOrAfterDate); List<string> duplicateIdList = recordingList.GetDuplicatePromptIds(); if (duplicateIdList.Count > 0) { string list = String.Empty; int lineCounter = 1; foreach (string s in duplicateIdList) { list += s; list += ", "; if (list.Length > (lineCounter * 60)) { list += "\n"; lineCounter++; } } list = list.Substring(0, list.Length - 2); Common.ErrorMessage("Warning: multiple copies of prompt ids in the design.\n" + "Management and testing of each is NOT handled by the tools.\n" + "You are responsible for reviewing and testing that each is correct.\n" + "Recommended that you fix the prompt numbers and let the tools handle it.\n" + "\n" + "Duplicates:\n" + list); } int row = 7; int count = 1; foreach (PromptRecordingList.PromptRecording recording in recordingList.GetPromptRecordings()) { ws.Cells[row, 1] = count; ws.Cells[row, 2] = recording.PromptId; ws.Cells[row, 3] = MakeDuplicateString(recording.GetDuplicateIds()); string wording = Common.StripBracketLabels(recording.Wording); ws.Cells[row, 4] = wording; // if the whole wording is the label, there are no []s string label = Common.MakeLabelName(recording.Wording); if (label.Length != wording.Length) ws.Cells[row, 5] = Common.MakeLabelName(recording.Wording); if (hyperLinks) { string recordingFile = Common.GetResourceString(Strings.PromptRecordingLocationRes); recordingFile += "\\" + recording.PromptId + ".wav"; ws.Hyperlinks.Add(ws.Cells[row, 2], recordingFile); } row++; count++; } try { wb.SaveAs(targetFilename); } catch { } excelApp.Quit(); ; System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp); excelApp = null; }
internal static void ExportDesignNotes(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl) { string targetFilename; string currentFileName; if (saveFileDialog == null) { saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = Common.GetResourceString(Strings.SavePromptsTitleRes); saveFileDialog.Filter = Common.GetResourceString(Strings.SavePromptsFilterRes); saveFileDialog.FilterIndex = 1; // Excel will ask about overwriting and I can't find a way to bypass that - so // skip it here and let excel do it on wb.close saveFileDialog.OverwritePrompt = false; } saveFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(visioControl); targetFilename = visioControl.Src; currentFileName = System.IO.Path.GetFileName(targetFilename); saveFileDialog.FileName = Common.StripExtensionFileName(currentFileName) + "_DesignNotes.xlsx"; if (saveFileDialog.ShowDialog() == DialogResult.OK) targetFilename = saveFileDialog.FileName; else return; Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application(); if (excelApp == null) { Common.ErrorMessage("Couldn't start Excel - make sure it's installed"); return; } excelApp.Visible = false; Workbook wb = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet); Worksheet ws = (Worksheet)wb.Worksheets[1]; if (ws == null) { Common.ErrorMessage("Excel worksheet couldn't be created."); return; } DocTitleShadow shadow = PathMaker.LookupDocTitleShadow(); string client = ""; string project = ""; if (shadow != null) { client = shadow.GetClientName(); project = shadow.GetProjectName(); } ws.Cells[1, 1].Value = "Client: " + client; ws.Cells[2, 1].Value = "Project: " + project; ws.Cells[3, 1].Value = "Date: " + DateTime.Now.ToString(Strings.DateColumnFormatString); ws.Cells[1, 1].Font.Bold = true; ws.Cells[2, 1].Font.Bold = true; ws.Cells[3, 1].Font.Bold = true; ws.Columns["A:A"].ColumnWidth = 6; ws.Columns["B:B"].ColumnWidth = 40; ws.Columns["C:C"].ColumnWidth = 100; ws.Columns["D:D"].ColumnWidth = 16; ((Range)ws.Columns["C:C"]).EntireColumn.WrapText = true; ws.Cells[5, 1].Value = "Count"; ws.Cells[5, 2].Value = "State Name"; ws.Cells[5, 3].Value = "Design Notes"; ws.Cells[5, 4].Value = "Last Updated"; ws.Cells[5, 1].Font.Bold = true; ws.Cells[5, 2].Font.Bold = true; ws.Cells[5, 3].Font.Bold = true; ws.Cells[5, 4].Font.Bold = true; ws.Cells[5, 4].HorizontalAlignment = XlHAlign.xlHAlignLeft; ws.Columns["D:D"].HorizontalAlignment = XlHAlign.xlHAlignLeft; DesignNotesList designNotesList = Common.GetDesignNotesList(); char[] delimiterChars = { '@' }; //raw text looks like this... "design notes have been updated again@@02/18/2014" //splitting inot two parts for XLS writing int row = 6; int count = 1; if (designNotesList.GetDesignNotes().Count >= 1) { foreach (DesignNotesList.DesignNoteContent designNote in designNotesList.GetDesignNotes()) { ws.Cells[row, 1] = count; ws.Cells[row, 2] = designNote.StateId; //string wording = Common.StripBracketLabels(designNote.Wording); string[] notes = Common.StripBracketLabels(designNote.Wording).Split(delimiterChars); if (notes[0].Length > 0) { ws.Cells[row, 3] = notes[0]; string lastUpdated = notes[2]; ws.Cells[row, 4] = lastUpdated; ws.Rows[row].VerticalAlignment = XlVAlign.xlVAlignCenter; ws.Cells[row, 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; } row++; count++; } try { wb.SaveAs(targetFilename); } catch { Common.ErrorMessage("Excel worksheet couldn't be created."); } } else { Common.ErrorMessage("Excel worksheet generation skipped - no Design Notes found in VUI file."); } excelApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp); excelApp = null; }
internal static void ExportHighLevelDesignDoc(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl) { DocTitleShadow docTitleShadow = PathMaker.LookupDocTitleShadow(); if (docTitleShadow == null) { Common.ErrorMessage("Missing Document Title shape"); return; } changeLogShadow = PathMaker.LookupChangeLogShadow(); if (changeLogShadow == null) { Common.ErrorMessage("Missing Change Log shape"); return; } StartShadow startShadow = PathMaker.LookupStartShadow(); if (startShadow == null) { Common.ErrorMessage("Missing Start shape"); return; } string targetFilename; string currentFileName; if (saveFileDialog == null) saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(visioControl); saveFileDialog.Title = Common.GetResourceString(Strings.SaveHLDSpecTitleRes); saveFileDialog.Filter = Common.GetResourceString(Strings.SaveHLDSpecFilterRes); saveFileDialog.FilterIndex = 1; targetFilename = visioControl.Src; currentFileName = System.IO.Path.GetFileName(targetFilename); saveFileDialog.FileName = Common.StripExtensionFileName(currentFileName) + "_HLD.docx"; if (saveFileDialog.ShowDialog() == DialogResult.OK) targetFilename = saveFileDialog.FileName; else return; Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application(); wordApp.Visible = false; string templateFilename = System.Windows.Forms.Application.StartupPath + @"\" + Common.GetResourceString(Strings.HLDTemplateFileNameRes); Document doc = wordApp.Documents.Add(templateFilename); doc.BuiltInDocumentProperties["Author"] = "Convergys PathMaker"; bool saved = visioControl.Document.Saved; // output visio Selection content = wordApp.Selection; content.GoTo(What: WdGoToItem.wdGoToBookmark, Name: "CallFlowDiagram"); content.ClearFormatting(); content.set_Style("Normal"); content.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; InlineShape shp = null; foreach (Microsoft.Office.Interop.Visio.Page page in visioControl.Document.Pages) { if (!page.Name.StartsWith("Background-") && !page.Name.Equals("Title") && !page.Name.Equals("App Description") && !page.Name.Equals("Revision History")) { string tmpFileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".jpg"; page.Export(tmpFileName); shp = content.InlineShapes.AddPicture(tmpFileName); shp.ScaleHeight = 90;//set to 90% to handle minor differences content.InsertBreak(WdBreakType.wdPageBreak); } } visioControl.Document.Saved = saved; AddTitleAndLogo(doc, docTitleShadow); AddChangeLog(doc, changeLogShadow, "HLD"); doc.Fields.Update(); doc.SaveAs(targetFilename); ((_Application)wordApp).Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); wordApp = null; }
internal static void ImportUISpec(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControlIn) { ParamCache paramCache = new ParamCache(); paramCache.visioControl = visioControlIn; Common.WarningMessage("WARNING: Importing VUI Spec changes requires the 'Track Changes Option' is set ON in your MS Word Dcoument."); ProgressBarForm progressBarForm = new ProgressBarForm("Import User Interface Spec Changes", ImportUserInterfaceSpecWorker, paramCache); progressBarForm.ShowDialog(); }
internal static void ExportUserInterfaceSpec(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl, Boolean skipDiagramExport) { ParamCache paramCache = new ParamCache(); paramCache.visioControl = visioControl; paramCache.skipDiagramExport = skipDiagramExport;//JDK recent feature enhancement paramCache.docTitleShadow = PathMaker.LookupDocTitleShadow(); if (paramCache.docTitleShadow == null) { Common.ErrorMessage("Missing Document Title shape"); return; } paramCache.startShadow = PathMaker.LookupStartShadow(); if (paramCache.startShadow == null) { Common.ErrorMessage("Missing Start shape"); return; } //Get changeLogShawdow to get version and date information changeLogShadow = PathMaker.LookupChangeLogShadow(); if (changeLogShadow == null) { Common.ErrorMessage("Missing Change Log shape"); return; } //Get appDescShadow to get detailed information //using text box GUID for this new field appDescShadow = PathMaker.LookupAppDescShadow(); if (appDescShadow == null) { //Common.ErrorMessage("Missing App Description shape");//JDK removed check for compatibility //return; } //Get prefixListShadow to get detailed information //using text box GUID for this new field prefixListShadow = PathMaker.LookupPrefixListShadow(); if (prefixListShadow == null) { //Common.ErrorMessage("Missing Prefix List shape");//JDK removed check for compatibility //return; } if (saveFileDialog == null) saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(visioControl); saveFileDialog.Title = Common.GetResourceString(Strings.SaveUISpecTitleRes); saveFileDialog.Filter = Common.GetResourceString(Strings.SaveUISpecFilterRes); saveFileDialog.FilterIndex = 1; paramCache.targetFilename = paramCache.visioControl.Src; paramCache.currentFileName = System.IO.Path.GetFileName(paramCache.targetFilename); saveFileDialog.FileName = Common.StripExtensionFileName(paramCache.currentFileName) + ".docx"; if (saveFileDialog.ShowDialog() == DialogResult.OK) paramCache.targetFilename = saveFileDialog.FileName; else return; ProgressBarForm progressBarForm = new ProgressBarForm("Exporting UI", ExportUserInterfaceSpecWorker, paramCache); progressBarForm.ShowDialog(); }
internal static string ExportFastPathXML(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl, bool useTmpFile) { DocTitleShadow docTitleShadow = PathMaker.LookupDocTitleShadow(); if (docTitleShadow == null) { Common.ErrorMessage("Missing Document Title shape"); return null; } StartShadow startShadow = PathMaker.LookupStartShadow(); if (startShadow == null) { Common.ErrorMessage("Missing Start shape"); return null; } changeLogShadow = PathMaker.LookupChangeLogShadow(); if (changeLogShadow == null) { Common.ErrorMessage("Missing Change Log shape"); return null; } if (saveFileDialog == null) { saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = Common.GetResourceString(Strings.SaveFastPathXMLTitleRes); saveFileDialog.Filter = Common.GetResourceString(Strings.SaveFastPathXMLFilterRes); saveFileDialog.FilterIndex = 1; } saveFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(visioControl); saveFileDialog.RestoreDirectory = true; targetFilename = visioControl.Src; currentFileName = System.IO.Path.GetFileName(targetFilename); saveFileDialog.FileName = Common.StripExtensionFileName(currentFileName) + ".xml"; if (!useTmpFile) { if (saveFileDialog.ShowDialog() == DialogResult.OK) targetFilename = saveFileDialog.FileName; else return null; } else targetFilename = saveFileDialog.FileName + ".tmp"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.XmlResolver = null; xmlDoc.LoadXml(xmlStrings.Header); xmlDoc.DocumentElement.SetAttribute(xmlStrings.Project, docTitleShadow.GetProjectName()); xmlDoc.DocumentElement.SetAttribute(xmlStrings.Client, docTitleShadow.GetClientName()); xmlDoc.DocumentElement.SetAttribute(xmlStrings.LastModified, changeLogShadow.GetLastLogChangeDate()); xmlDoc.DocumentElement.SetAttribute(xmlStrings.Version, changeLogShadow.GetLastChangeVersion()); AddStartElement(xmlDoc, startShadow); List<Shadow> shadowList = PathMaker.LookupAllShadows(); // sorting them here helps the Missed statements in PathRunner come out in order string stateSortOrder = startShadow.GetDefaultSetting(Strings.DefaultSettingsStateSortOrder); if (stateSortOrder.Equals(Strings.StateSortOrderAlphaNumerical)) shadowList.Sort(Common.StateIdShadowSorterAlphaNumerical); else if (stateSortOrder.Equals(Strings.StateSortOrderNumericalOnly)) shadowList.Sort(Common.StateIdShadowSorterNumericalAlpha); else Common.StateIdShadowSorterVisioHeuristic(shadowList, visioControl.Document, startShadow); foreach (Shadow shadow in shadowList) { switch (shadow.GetShapeType()) { case ShapeTypes.Interaction: AddInteractionElement(xmlDoc, shadow as InteractionShadow); break; case ShapeTypes.Play: AddPlayElement(xmlDoc, shadow as PlayShadow); break; case ShapeTypes.Decision: AddDecisionElement(xmlDoc, shadow as DecisionShadow); break; case ShapeTypes.Data: AddDataElement(xmlDoc, shadow as DataShadow); break; case ShapeTypes.SubDialog: AddSubDialogElement(xmlDoc, shadow as SubDialogShadow); break; default: break; } } xmlDoc.Save(targetFilename); return targetFilename; }
internal static string ExportFastPathXML(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl) { return ExportFastPathXML(visioControl, false); }
internal static void ImportUISpec(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControlIn) { ParamCache paramCache = new ParamCache(); paramCache.visioControl = visioControlIn; ProgressBarForm progressBarForm = new ProgressBarForm("Import User Interface Spec Changes", ImportUserInterfaceSpecWorker, paramCache); progressBarForm.ShowDialog(); }
internal static void ExportUserInterfaceSpec(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl) { ParamCache paramCache = new ParamCache(); paramCache.visioControl = visioControl; paramCache.docTitleShadow = PathMaker.LookupDocTitleShadow(); if (paramCache.docTitleShadow == null) { Common.ErrorMessage("Missing Document Title shape"); return; } paramCache.startShadow = PathMaker.LookupStartShadow(); if (paramCache.startShadow == null) { Common.ErrorMessage("Missing Start shape"); return; } //Get changeLogShawdow to get version and date information changeLogShadow = PathMaker.LookupChangeLogShadow(); if (changeLogShadow == null) { Common.ErrorMessage("Missing Change Log shape"); return; } if (saveFileDialog == null) saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(visioControl); saveFileDialog.Title = Common.GetResourceString(Strings.SaveUISpecTitleRes); saveFileDialog.Filter = Common.GetResourceString(Strings.SaveUISpecFilterRes); saveFileDialog.FilterIndex = 1; paramCache.targetFilename = paramCache.visioControl.Src; paramCache.currentFileName = System.IO.Path.GetFileName(paramCache.targetFilename); saveFileDialog.FileName = Common.StripExtensionFileName(paramCache.currentFileName) + ".docx"; if (saveFileDialog.ShowDialog() == DialogResult.OK) paramCache.targetFilename = saveFileDialog.FileName; else return; ProgressBarForm progressBarForm = new ProgressBarForm("Exporting UI", ExportUserInterfaceSpecWorker, paramCache); progressBarForm.ShowDialog(); }