private static bool ExportUserInterfaceSpecWorker(Object arg, ProgressBarForm progressBarForm) { ParamCache paramCache = arg as ParamCache; gotoNameCache = new Dictionary<Shadow, string>(); Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application(); wordApp.Visible = false;//JDK set to true for help in debugging string templateFilename = System.Windows.Forms.Application.StartupPath + @"\" + Common.GetResourceString(Strings.VUITemplateFileNameRes); Document doc = wordApp.Documents.Add(templateFilename); doc.BuiltInDocumentProperties["Author"] = "PathMaker User"; // output visio Selection content = wordApp.Selection; content.GoTo(What: WdGoToItem.wdGoToBookmark, Name: "CallFlowDiagram"); content.ClearFormatting(); content.set_Style("Normal"); content.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; //if we skip the export - we need to also remove the HEADING for "Call Flow Diagrams" if (paramCache.skipDiagramExport) { //JDK 08-20-2015 added for killing section label content.Text = "\r\nThis section has been intentionally skipped.\r\n\r\n"; } //new option added to allow skipping the export of all Visio diagram files into the Word Doc if (!paramCache.skipDiagramExport) { InlineShape shp = null; foreach (Microsoft.Office.Interop.Visio.Page page in paramCache.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.LockAspectRatio = msoTrue; shp.ScaleHeight = 90;//set to 90% to handle minor differences content.InsertBreak(WdBreakType.wdPageBreak); } } } List<Shadow> shadowList = PathMaker.LookupAllShadows(); // just show we're moving a little earlier progressBarForm.SetProgressPercentage(1, 100); AddTitleAndLogo(doc, paramCache.docTitleShadow); AddChangeLog(doc, changeLogShadow, "VUI"); //need to check if the appDesc and prefixList shadows exist before calling these functions - old designs may not include them if (shadowList.Contains(appDescShadow)) { AddAppDescription(doc, appDescShadow, "VUI");//JDK 08-12-2014 added appDescription } else { //need to remove template header and empty table //RemoveAppDescription(doc, "VUI");//JDK 09-12-2014 added appDescription removal } if (shadowList.Contains(prefixListShadow)) { AddPrefixList(doc, prefixListShadow, "VUI");//JDK 08-22-2014 added prefixList } else { //need to remove template header and empty table //RemovePrefixList(doc, "VUI");//JDK 09-12-2014 added prefixList removal } AddStartTables(doc, paramCache.startShadow); for (int i = shadowList.Count - 1; i >= 0; i--) { StateShadow tmpShadow = shadowList[i] as StateShadow; if (tmpShadow == null) shadowList.RemoveAt(i); } SetUpGotoMaxHandlerCache(); string stateSortOrder = paramCache.startShadow.GetDefaultSetting(Strings.DefaultSettingsStateSortOrder); if (stateSortOrder.Equals(Strings.StateSortOrderAlphaNumerical)) shadowList.Sort(Common.StateIdShadowSorterAlphaNumerical); else if (stateSortOrder.Equals(Strings.StateSortOrderNumericalOnly)) shadowList.Sort(Common.StateIdShadowSorterNumericalAlpha); else if (stateSortOrder.Equals(Strings.StateSortOrderVisioHeuristic)) Common.StateIdShadowSorterVisioHeuristic(shadowList, paramCache.visioControl.Document, paramCache.startShadow); else Common.StateIdShadowSorterVisioPageGrouping(shadowList, paramCache.visioControl.Document, paramCache.startShadow);//JDK Added new sort option 12-11-2015 int total = shadowList.Count; int progress = 0; foreach (Shadow shadow in shadowList) { progress++; switch (shadow.GetShapeType()) { case ShapeTypes.Interaction: AddInteractionTable(doc, shadow as InteractionShadow); break; case ShapeTypes.Play: AddPlayTable(doc, shadow as PlayShadow); break; case ShapeTypes.Decision: AddDecisionTable(doc, shadow as DecisionShadow); break; case ShapeTypes.Data: AddDataTable(doc, shadow as DataShadow); break; case ShapeTypes.SubDialog: AddSubDialogTable(doc, shadow as SubDialogShadow); break; default: break; } progressBarForm.SetProgressPercentage(progress, total); if (progressBarForm.Cancelled) { ((_Application)wordApp).Quit(false); System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); gotoNameCache = null; gotoMaxHandlerCache = null; wordApp = null; return false; } } //if (!shadowList.Contains(appDescShadow)) appDescShadow = PathMaker.LookupAppDescShadow(); if (appDescShadow == null) { doc.Bookmarks["ApplicationDescriptionCleanup"].Range.Delete();//JDK 10-14-2014 added for empty app desc removal } //if (!shadowList.Contains(prefixListShadow)) prefixListShadow = PathMaker.LookupPrefixListShadow(); if (prefixListShadow == null) { doc.Bookmarks["PrefixListCleanup"].Range.Delete();//JDK 10-14-2014 added for empty prefixList removal } doc.Tables[Templates.GlobalCommands].Delete(); doc.Tables[Templates.GlobalPromptTypes].Delete(); doc.Tables[Templates.DefaultSettings].Delete(); doc.Tables[Templates.GlobalMaxHandler].Delete(); if (paramCache.startShadow.GetDefaultSetting(Strings.DefaultSettingsMode).Equals(Strings.ModeSpeech)) doc.Bookmarks["TouchTone"].Range.Delete(); else doc.Bookmarks["Speech"].Range.Delete(); doc.Bookmarks["TempPages"].Range.Delete(); doc.Fields.Update(); gotoNameCache = null; gotoMaxHandlerCache = null; progressBarForm.SetProgressPercentage(total, total); System.Windows.Forms.Application.DoEvents(); doc.SaveAs(paramCache.targetFilename); ((_Application)wordApp).Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); wordApp = null; return true; }
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 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(); }
// tried to do this as a BackgroundWorker - way too slow. Need to use the ProgressBarForm this way for // good performance. internal static bool DoVersion1Upgrade(Object arg, ProgressBarForm progressBarForm) { Document document = arg as Document; // these should only ever be used here... const string OffPageReferenceShapeName = "Off-page reference"; const string DynamicConnectorShapeName = "Dynamic connector"; const string OnPageReferenceIncomingShapeName = "On-page reference.Incoming"; const string OnPageReferenceOutgoingShapeName = "On-page reference.Outgoing"; const string SubDialogCallShapeName = "Call Sub-Dialog"; const string CommentShapeName = "Comment"; const string PageShapeName = "Sheet"; const string ReturnShapeName = "Return"; const string PlaceHolderShapeName = "Placeholder"; const string DMTypeCellName = "Prop.DMType"; const string DocumentTitleShapeName = "Document Title"; const string ChangeLogShapeName = "Change Log"; const string TransferShapeName = "Transfer"; const string TransferShapeName2 = "Terminator"; const string HangUpShapeName = "Hang up"; // most transitions can point to terminals (hangup/transfer/return) but not // maxhandlers - so we need a list without terminals to use for maxhandler conversions Dictionary <string, List <string> > uniqueIdMap = new Dictionary <string, List <string> >(); Dictionary <string, List <string> > uniqueIdMapNoTerminals = new Dictionary <string, List <string> >(); int total = 0; foreach (Page page in document.Pages) { total += page.Shapes.Count; } total = total * 4; // add some extra for the stuff done outside of this loop at the end int counter = 0; foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { ShapeTypes shapeType = ShapeTypes.None; progressBarForm.SetProgressPercentage(counter++, total); if (progressBarForm.Cancelled) { return(false); } string dmType = Common.GetCellString(shape, DMTypeCellName); if (dmType.Equals("IA", StringComparison.Ordinal)) { shapeType = ShapeTypes.Interaction; } else if (dmType.Equals("PP", StringComparison.Ordinal)) { shapeType = ShapeTypes.Play; } else if (dmType.Equals("DE", StringComparison.Ordinal)) { shapeType = ShapeTypes.Decision; } else if (dmType.Equals("DR", StringComparison.Ordinal)) { shapeType = ShapeTypes.Data; } else if (dmType.Equals("SD", StringComparison.Ordinal)) { shapeType = ShapeTypes.SubDialog; } else if (dmType.Equals("ST", StringComparison.Ordinal)) { shapeType = ShapeTypes.Start; } if (shapeType == ShapeTypes.None) { // Figure out what else it could be... if (shape.Name.StartsWith(DocumentTitleShapeName)) { shapeType = ShapeTypes.DocTitle; } else if (shape.Name.StartsWith(ChangeLogShapeName)) { shapeType = ShapeTypes.ChangeLog; } else if (shape.Name.StartsWith(TransferShapeName) || shape.Name.StartsWith(TransferShapeName2)) { shapeType = ShapeTypes.Transfer; } else if (shape.Name.StartsWith(HangUpShapeName)) { shapeType = ShapeTypes.HangUp; } else if (shape.Name.StartsWith(OffPageReferenceShapeName)) { shapeType = ShapeTypes.OffPageRef; } else if (shape.Name.StartsWith(DynamicConnectorShapeName)) { shapeType = ShapeTypes.Connector; } else if (shape.Name.StartsWith(OnPageReferenceIncomingShapeName)) { shapeType = ShapeTypes.OnPageRefIn; } else if (shape.Name.StartsWith(OnPageReferenceOutgoingShapeName)) { shapeType = ShapeTypes.OnPageRefOut; } else if (shape.Name.StartsWith(SubDialogCallShapeName)) { shapeType = ShapeTypes.CallSubDialog; } else if (shape.Name.StartsWith(CommentShapeName)) { shapeType = ShapeTypes.Comment; } else if (shape.Name.StartsWith(PageShapeName)) { shapeType = ShapeTypes.Page; } else if (shape.Name.StartsWith(ReturnShapeName)) { shapeType = ShapeTypes.Return; } else if (shape.Name.StartsWith(PlaceHolderShapeName)) { shapeType = ShapeTypes.Placeholder; } else { postUpgradeReportString += "Shape could not be upgraded properly - " + ShapeDescription(shape) + "\n\n"; shape.Text = Strings.ToBeDeletedLabel; continue; } } System.Diagnostics.Debug.Assert(shapeType != ShapeTypes.None); // we really don't need to do anything with the page shapes // this also includes the rectangles drawn for revision history if (shapeType == ShapeTypes.Page) { continue; } // remove the action properties on all shapes RemoveRightMouseAction(shape, "P&roperties"); // and fix the actions for the ones we care about if (shapeType != ShapeTypes.OffPageRef && shapeType != ShapeTypes.HangUp && shapeType != ShapeTypes.OnPageRefIn && shapeType != ShapeTypes.OnPageRefOut && shapeType != ShapeTypes.Return && shapeType != ShapeTypes.Transfer && shapeType != ShapeTypes.Comment && shapeType != ShapeTypes.Placeholder && shapeType != ShapeTypes.Connector) { AddRightMouseAction(shape, "P&roperties", "RUNADDONWARGS(\"QueueMarkerEvent\",\"/PathMaker /CMD=2\")", true, false, false, false); } // delete old rows no longer used DeleteOldPropertyCell(shape, "Prop.TestPlanSetting"); DeleteOldPropertyCell(shape, "Prop.CheckPoints"); DeleteOldPropertyCell(shape, "Prop.UpdateData"); DeleteOldPropertyCell(shape, "Prop.LineName"); DeleteOldPropertyCell(shape, "Prop.Input"); DeleteOldPropertyCell(shape, "Prop.Output"); DeleteOldPropertyCell(shape, "Prop.OSDM"); DeleteOldPropertyCell(shape, "Prop.Destination"); DeleteOldPropertyCell(shape, "Prop.ColumnData"); DeleteOldPropertyCell(shape, "Prop.EnteringFrom"); DeleteOldPropertyCell(shape, "Prop.StartingDialogState"); DeleteOldPropertyCell(shape, "Prop.StartingDM"); DeleteOldPropertyCell(shape, "Prop.ChangeDate"); DeleteOldPropertyCell(shape, "Prop.InitialDate"); DeleteOldPropertyCell(shape, "Prop.LogoFilePath"); DeleteOldPropertyCell(shape, "Prop.LastUpdate"); if (shapeType == ShapeTypes.CallSubDialog) { // none of these are used... DeleteOldPropertyCell(shape, "Prop.DMName"); DeleteOldPropertyCell(shape, "Prop.EnteringFrom"); DeleteOldPropertyCell(shape, "Prop.StartingDialogState"); DeleteOldPropertyCell(shape, "Prop.Notes"); DeleteOldPropertyCell(shape, "Prop.LastUpdate"); DeleteOldPropertyCell(shape, "Prop.Transitions"); } else if (shapeType == ShapeTypes.SubDialog) { DeleteOldPropertyCell(shape, "Prop.Transitions"); } // Add a new cell containing the name of the subdialog being called // Later it will be converted to a UID if (shapeType == ShapeTypes.CallSubDialog) { Common.SetCellString(shape, ShapeProperties.CallSubDialog.SubDialogUID, shape.Text); } // rename rows that are confusing RenameRow(shape, "Prop.DialogParameters", ShapeProperties.SpecialSettings, "Special Settings"); RenameRow(shape, "Prop.DMName", ShapeProperties.StateId, "State Name"); RenameRow(shape, "Prop.DMType", ShapeProperties.ShapeType, "Shape Type"); RenameRow(shape, "Prop.InputData", ShapeProperties.Start.Initialization, "Initialization"); RenameRow(shape, "Prop.GlobalCommands", ShapeProperties.CommandTransitions, "Command Transitions"); RenameRow(shape, "Prop.GlobalPrompts", ShapeProperties.PromptTypes, "Prompt Types"); RenameRow(shape, "Prop.GlobalConfirmations", ShapeProperties.ConfirmationPrompts, "Confirmation Prompts"); RenameRow(shape, "Prop.TitleLine1", ShapeProperties.DocTitle.ClientName, "Client Name"); RenameRow(shape, "Prop.TitleLine2", ShapeProperties.DocTitle.ProjectName, "Project Name"); if (shapeType == ShapeTypes.Interaction) { RenameRow(shape, "Prop.Transitions", "Prop.CommandTransitions", "Command Transitions"); RenameRow(shape, "Prop.Prompts", "Prop.PromptTypes", "Prompt Types"); } // undo encoding we'll never use UnencodeProperty(shape, ShapeProperties.ChangeLog.Changes); UnencodeProperty(shape, ShapeProperties.Start.DefaultSettings); UnencodeProperty(shape, ShapeProperties.Start.Initialization); UnencodeProperty(shape, ShapeProperties.MaxHandling); UnencodeProperty(shape, ShapeProperties.Play.Prompts); UnencodeProperty(shape, ShapeProperties.PromptTypes); UnencodeProperty(shape, ShapeProperties.Transitions); UnencodeProperty(shape, ShapeProperties.CommandTransitions); UnencodeProperty(shape, ShapeProperties.SpecialSettings); UnencodeProperty(shape, ShapeProperties.DeveloperNotes); UnencodeProperty(shape, ShapeProperties.ConfirmationPrompts); UnencodeProperty(shape, ShapeProperties.LastUpdate); // make each shape get a GUID string uniqueId = shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID); // off page refs have two shapes with the same name and we don't need them for this if (shapeType != ShapeTypes.OffPageRef) { List <string> list = null; if (uniqueIdMap.TryGetValue(shape.Name, out list)) { list.Add(uniqueId); } else { list = new List <string>(); list.Add(uniqueId); uniqueIdMap.Add(shape.Name, list); } if (shapeType != ShapeTypes.Placeholder && shapeType != ShapeTypes.HangUp && shapeType != ShapeTypes.Transfer && shapeType != ShapeTypes.Return) { list = null; if (uniqueIdMapNoTerminals.TryGetValue(shape.Name, out list)) { list.Add(uniqueId); } else { list = new List <string>(); list.Add(uniqueId); uniqueIdMapNoTerminals.Add(shape.Name, list); } } } // change all double click handlers if (shapeType == ShapeTypes.DocTitle || shapeType == ShapeTypes.ChangeLog || shapeType == ShapeTypes.Start || shapeType == ShapeTypes.Interaction || shapeType == ShapeTypes.Play || shapeType == ShapeTypes.Decision || shapeType == ShapeTypes.Data || shapeType == ShapeTypes.SubDialog || shapeType == ShapeTypes.CallSubDialog) { Common.SetCellFormula(shape, "EventDblClick", "RUNADDONWARGS(\"QueueMarkerEvent\",\"/PathMaker /CMD=1\")"); } // global transitions need a new column to match the interaction transitions if (shapeType == ShapeTypes.Start) { Table table = Common.GetCellTable(shape, ShapeProperties.CommandTransitions); if (!table.IsEmpty()) { int newCol = table.AddColumn(); System.Diagnostics.Debug.Assert(newCol == 18); // copies the goto column to the line column to match interactions table.CopyColumn(7, 18); Common.SetCellTable(shape, ShapeProperties.CommandTransitions, table); } } // unlock most shape text edits - remember play and interaction are multiple shapes if (shapeType == ShapeTypes.Data || shapeType == ShapeTypes.Decision || shapeType == ShapeTypes.Interaction || shapeType == ShapeTypes.Play || shapeType == ShapeTypes.SubDialog) { shape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visLockTextEdit).FormulaU = "0"; } if (shapeType == ShapeTypes.Interaction || shapeType == ShapeTypes.Play) { shape.Shapes[1].get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visLockTextEdit).FormulaU = "0"; // and bring it to front so you are editing the shape name by default shape.Shapes[1].BringToFront(); } // the old stuff never locked call sub dialogs - we want to if (shapeType == ShapeTypes.CallSubDialog) { shape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visLockTextEdit).FormulaU = "1"; } // normalize/fix all the grid datastore stuff - get rid of unused columns, etc. // remove plus, minus, goto, update_plus, update_minus, cp_idx RemoveColumnsFromCellTable(shape, ShapeProperties.CommandTransitions, new int[6] { 3, 5, 7, 12, 14, 19 }); // remove plus, minus, update_plus, update_minus RemoveColumnsFromCellTable(shape, ShapeProperties.ConfirmationPrompts, new int[4] { 1, 3, 7, 9 }); // remove plus, minus, updateplus, updateminus RemoveColumnsFromCellTable(shape, ShapeProperties.PromptTypes, new int[4] { 1, 3, 7, 9 }); // remove plus, minus, updateplus, updateminus, cp_idx RemoveColumnsFromCellTable(shape, ShapeProperties.Play.Prompts, new int[5] { 0, 2, 5, 7, 10 }); // remove plus, minus, goto, updateplus, updateminus RemoveColumnsFromCellTable(shape, ShapeProperties.Transitions, new int[5] { 0, 2, 4, 5, 7 }); // remove highlight index column RemoveColumnsFromCellTable(shape, ShapeProperties.ChangeLog.Changes, new int[1] { 5 }); // clear any old changelog descriptions from the page itself if (shapeType == ShapeTypes.ChangeLog) { Page changeLogPage = shape.ContainingPage; for (int count = changeLogPage.Shapes.Count; count > 0; count--) { if (changeLogPage.Shapes[count] != shape) { changeLogPage.Shapes[count].Delete(); } } } // Start has the max handlers in a different order than the interaction states - fix it here if (shapeType == ShapeTypes.Start) { SwapRowsInCellTable(shape, ShapeProperties.MaxHandling, 0, 1); } // Get rid of expressware checkpoints default setting if (shapeType == ShapeTypes.Start) { Table table = Common.GetCellTable(shape, ShapeProperties.Start.DefaultSettings); for (int r = 0; r < table.GetNumRows(); r++) { if (table.GetData(r, 0).Equals("ExpressWare Checkpoints")) { table.DeleteRow(r); break; } } } // apparently subDialogs developer notes were not written out as a two column entry (one for date of change) if (shapeType == ShapeTypes.SubDialog) { EnsureTwoColumns(shape, ShapeProperties.DeveloperNotes); } // set shape type - this will add it if necessary - make sure to use int value Common.SetCellFormula(shape, ShapeProperties.ShapeType, ((int)shapeType).ToString()); SetRowLabel(shape, ShapeProperties.ShapeType, "Shape Type"); } } // we remove change log stuff above - need to recount the remaining totals total = 0; foreach (Page page in document.Pages) { total += page.Shapes.Count; } total = counter + (total * 3); // we'll go through 3 times below // The following stuff needed to wait until every state had a GUID // change all references from state ids/names to use GUIDs foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { // column 13 should now be the link column ReplaceStateIdsWithUniqueIds(shape, uniqueIdMap, ShapeProperties.CommandTransitions, 13); // column 5 should be the link column ReplaceStateIdsWithUniqueIds(shape, uniqueIdMap, ShapeProperties.Transitions, 5); // column 3 should be the goto column ReplaceStateIdsWithUniqueIds(shape, uniqueIdMapNoTerminals, ShapeProperties.MaxHandling, 3); // it's a singleton, not a table - only exists on call subdialogs ReplaceStateIdWithUniqueIds(shape, uniqueIdMap, ShapeProperties.CallSubDialog.SubDialogUID); progressBarForm.SetProgressPercentage(counter++, total); if (progressBarForm.Cancelled) { return(false); } } } // fix off page connectors Dictionary <string, Shape> offPageShapeNameMap = new Dictionary <string, Shape>(); foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { if (Common.GetShapeType(shape) == ShapeTypes.OffPageRef) { // common fixes // hyperlinks point to pages, not shapes, even if the shape is deleted - drop these short row; if (shape.get_CellExists(ShapeProperties.OffPageRef.HyperLink, (short)VisExistsFlags.visExistsAnywhere) != 0) { row = shape.get_CellsRowIndex(ShapeProperties.OffPageRef.HyperLink); shape.DeleteRow((short)VisSectionIndices.visSectionHyperlink, row); } if (shape.get_CellExists("Hyperlink.PageLinkDest", (short)VisExistsFlags.visExistsAnywhere) != 0) { row = shape.get_CellsRowIndex("Hyperlink.PageLinkDest"); shape.DeleteRow((short)VisSectionIndices.visSectionHyperlink, row); } // the standard off-page connector dbl click handler works fine Common.SetCellFormula(shape, ShapeProperties.EventDblClick, Strings.OffPageConnectorDblClickCommand); // the standard off-page connector drop handler works fine Common.SetCellFormula(shape, ShapeProperties.EventDrop, Strings.OffPageConnectorDropCommand); // keep the text synchronized Common.SetCellFormula(shape, ShapeProperties.TheText, Strings.OffPageConnectorTextCommand); // delete actions to change shape to circle/arrow row = shape.get_CellsRowIndex("Actions.Row_3"); shape.DeleteRow((short)VisSectionIndices.visSectionAction, row); row = shape.get_CellsRowIndex("Actions.Row_4"); shape.DeleteRow((short)VisSectionIndices.visSectionAction, row); Shape target; if (offPageShapeNameMap.TryGetValue(shape.Text, out target)) { // we have a pair... Common.SetCellString(shape, ShapeProperties.OffPageConnectorShapeID, shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(shape, ShapeProperties.OffPageConnectorDestinationPageID, target.ContainingPage.PageSheet.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(shape, ShapeProperties.OffPageConnectorDestinationShapeID, target.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(target, ShapeProperties.OffPageConnectorShapeID, target.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(target, ShapeProperties.OffPageConnectorDestinationPageID, shape.ContainingPage.PageSheet.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(target, ShapeProperties.OffPageConnectorDestinationShapeID, shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); offPageShapeNameMap.Remove(shape.Text); } else { offPageShapeNameMap.Add(shape.Text, shape); } } progressBarForm.SetProgressPercentage(counter++, total); if (progressBarForm.Cancelled) { return(false); } } } // In CID you could have on-page connectors backwards - check for them here foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { if (Common.GetShapeType(shape) == ShapeTypes.OnPageRefIn) { bool arrowSide = false; foreach (Connect c in shape.FromConnects) { // determine which end of the connector is connected to the nonConnectorShadow if (c.FromCell.Name.Equals(Strings.EndConnectionPointCellName)) { arrowSide = true; } } // if we are on the arrow side of the connector, that means this is an input connector if (arrowSide) { postUpgradeReportString += "On page reference input can't have inputs - " + ShapeDescription(shape) + "\n\n"; catastrophicError = true; } } else if (Common.GetShapeType(shape) == ShapeTypes.OnPageRefOut) { bool arrowSide = true; foreach (Connect c in shape.FromConnects) { // determine which end of the connector is connected to the nonConnectorShadow if (c.FromCell.Name.Equals(Strings.EndConnectionPointCellName)) { arrowSide = true; } // if we are on the non-arrow side of the connector, that means this is an output connector if (!arrowSide) { postUpgradeReportString += "On page reference output can't have outputs - " + ShapeDescription(shape) + "\n\n"; catastrophicError = true; } } } } } // any left over are not hooked up - this is a problem... if (offPageShapeNameMap.Count > 0) { for (int i = 0; i < offPageShapeNameMap.Count; i++) { Shape noMatch = offPageShapeNameMap.Values.ElementAt(i); postUpgradeReportString += "No matching off page connector found for " + ShapeDescription(noMatch) + "\n\n"; noMatch.Text = Strings.ToBeDeletedLabel; } } // Last thing to do - now that we can use all the new column names, we want to find all table fields using $$ and fix them foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { FixDollarDollarTableFields(shape, ShapeProperties.CommandTransitions); FixDollarDollarTableFields(shape, ShapeProperties.PromptTypes); FixDollarDollarTableFields(shape, ShapeProperties.ConfirmationPrompts); FixDollarDollarTableFields(shape, ShapeProperties.MaxHandling); FixDollarDollarTableFields(shape, ShapeProperties.DeveloperNotes); FixDollarDollarTableFields(shape, ShapeProperties.SpecialSettings); FixDollarDollarTableFields(shape, ShapeProperties.Transitions); FixDollarDollarTableFields(shape, ShapeProperties.Play.Prompts); FixDollarDollarTableFields(shape, ShapeProperties.Start.DefaultSettings); FixDollarDollarTableFields(shape, ShapeProperties.Start.Initialization); progressBarForm.SetProgressPercentage(counter++, total); if (progressBarForm.Cancelled) { return(false); } } } progressBarForm.SetProgressPercentage(100, 100); progressBarForm.Hide(); progressBarForm = null; return(true); }
private static bool ImportUserInterfaceSpecWorker(Object arg, ProgressBarForm progressBarForm) { ParamCache paramCache = arg as ParamCache; int total = 0; int progress = 0; int WordingCol = 0; int PromptCol = 0; Rows x; List<string> notProcessedList = new List<string>(); string notFoundText = string.Empty; string STATE = "State: "; string shapeName = string.Empty; string fieldSeparator = "[\r\a\t]"; object saveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges; object originalFormat = Type.Missing; object routeDocument = Type.Missing; Dictionary<string, string> promptIdToStateNameMap = new Dictionary<string, string>(); Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application(); try { // Set up the open file dialog and let the user select the file to open. if (openFileDialog == null) { openFileDialog = new OpenFileDialog(); openFileDialog.Title = Common.GetResourceString(Strings.OpenUISpecTitleRes); openFileDialog.Filter = Common.GetResourceString(Strings.OpenUISpecFilterRes); openFileDialog.FilterIndex = 1; } openFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(paramCache.visioControl); if (openFileDialog.ShowDialog() == DialogResult.OK) { // The user selected a valid file name and hit OK. Get the // file name from the dialog and open the file. paramCache.currentFileName = openFileDialog.FileName; if (wordApp == null) { Common.ErrorMessage("Couldn't start Word - make sure it's installed"); return false; } Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(paramCache.currentFileName, ReadOnly: true, Visible: false); doc.Activate(); // just show we're moving a little earlier progressBarForm.SetProgressPercentage(1, 100); total = doc.Revisions.Count; //turn off show changes, otherwise it be included in revised text //doc.ActiveWindow.View.ShowInsertionsAndDeletions = false; notProcessedList.Clear(); PromptChangesList recordingList = new PromptChangesList(); foreach (Revision arev in doc.Revisions) { progress++; try { if (arev.Range.Information[WdInformation.wdWithInTable]) { x = arev.Range.Rows; notFoundText = Regex.Replace((STATE + arev.Range.Tables[1].Cell(1, 1).Range.Text + "\n\t" + x.First.Range.Text), fieldSeparator, " ").Trim() + "\r\n\n"; string tempStateName = arev.Range.Tables[1].Cell(1, 1).Range.Text.Replace("\r\a", string.Empty).Trim();//JDK added to help with unprocessed edits processing //TODO Make sure import and export consistant in the cols. shapeName = arev.Range.Tables[1].Cell(1, 2).Range.Text.Replace("\r\a", string.Empty).Trim(); ; if (shapeName.Equals(Strings.Interaction)) { WordingCol = 1; PromptCol = 2; //notFoundText = Regex.Replace((STATE + arev.Range.Tables[1].Cell(1, 1).Range.Text + "\n\t\t\t" + x.First.Range.Text), fieldSeparator, " ").Trim() + "\r\n\n"; } else if (shapeName.Equals(Strings.PlayPrompt)) { WordingCol = 0; PromptCol = 1; //notFoundText = Regex.Replace((STATE + arev.Range.Tables[1].Cell(1, 1).Range.Text + "\n\t\t\t" + x.First.Range.Text), fieldSeparator, " ").Trim() + "\r\n\n"; } else if (shapeName.Equals("Version")) { WordingCol = 0; PromptCol = 0; if (notFoundText.Trim().Length >= 18) { notFoundText = Regex.Replace((STATE + "Revision History \n\t" + x.First.Range.Text), fieldSeparator, " ").Trim() + "\r\n\n"; notProcessedList.Add(notFoundText); } continue; } else { WordingCol = 0; PromptCol = 0; notProcessedList.Add(notFoundText); continue; } string[] lines = Regex.Split(x.First.Range.Text, "\r\a"); if (lines[WordingCol] != "" && lines[PromptCol] != "") { recordingList.AddPromptRecording(lines[PromptCol], lines[WordingCol]); promptIdToStateNameMap.Add(lines[PromptCol].Trim(), tempStateName); } else { if (!notProcessedList.Contains(notFoundText)) notProcessedList.Add(notFoundText); } } else { if (!notProcessedList.Contains(arev.Range.Sentences.First.Text.Trim() + "\r\n\n")) notProcessedList.Add(arev.Range.Sentences.First.Text.Trim() + "\r\n\n"); } progressBarForm.SetProgressPercentage(progress, total); if (progressBarForm.Cancelled) { ((_Application)wordApp).Quit(false); System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); wordApp = null; return false; } } catch { if (!notProcessedList.Contains(notFoundText)) notProcessedList.Add(notFoundText); } } Common.ApplyPromptRecordingList(recordingList); //Process not process records to display string unprocessed = string.Empty; for (int y = 0; y < notProcessedList.Count; y++) { unprocessed += notProcessedList[y].ToString(); } Dictionary<string, string> unprocessChangeList = recordingList.getUnusedPromptChanges(); if (unprocessChangeList.Count > 0) { //JDK - use this to get more context to display - tempStateName foreach (KeyValuePair<string, string> pair in unprocessChangeList) { if (promptIdToStateNameMap.ContainsKey(pair.Key)) { //grab tempStateName out of dictionary for the "id" string tempStateName = ""; if (promptIdToStateNameMap.TryGetValue(pair.Key, out tempStateName)) { unprocessed += STATE + tempStateName + " \n\t\t" + pair.Value + " " + pair.Key + "\r\n\n"; } else { unprocessed += STATE + "UNKOWN STATE NAME \n\t\t" + pair.Value + " " + pair.Key + "\r\n\n"; } } else { unprocessed += pair.Value + " " + pair.Key + "\r\n\n"; } } } if (total == 0) unprocessed += "No changes found \r\n\n"; if (unprocessed.Length > 0) { ValidateResultsForm frm = new ValidateResultsForm(unprocessed, paramCache.visioControl, Strings.UISPECTIMPORTRESULTS); frm.Text = "Changes Requiring Manual Updates"; frm.Name = Strings.UISPECTIMPORTRESULTS; frm.Show(); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { if (wordApp != null) { // Quit without saving changes. try { wordApp.Documents.Close(ref saveChanges, ref originalFormat, ref routeDocument); }catch { //do nothing not open } ((_Application)wordApp).Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); wordApp = null; } } progressBarForm.SetProgressPercentage(total, total); System.Windows.Forms.Application.DoEvents(); return true; }
// This is where you plug in your upgrade if need be. These should only be // necessary for schema changes - releases where the shape data has changed. // Add an if statement for your version as described below internal static bool UpgradeDocumentToCurrentSchemaVersion(Document document) { int docSchemaVersion = Common.GetDocumentSchemaVersion(document); postUpgradeReportString = ""; catastrophicError = false; /** * Add another if statement here NOT AN ELSE IF so that the document will go * through all upgrades that are less than it's schema version * For example, two upgrades would look like this * if (docSchemaVersion < 1) * progressBarForm = new ProgressBarForm(DoVersion1Upgrade); * if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) * return false; * if (docSchemaVersion < 2) * progressBarForm = new ProgressBarForm(DoVersion1Upgrade); * if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) * return false; * etc. */ if (docSchemaVersion < 1) { // initial release of PathRunner ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 1", DoVersion1Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false; } if (docSchemaVersion < 2) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 2", DoVersion2Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false; } if (docSchemaVersion < 3) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 3", DoVersion3Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false; } if (docSchemaVersion < 4) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 4", DoVersion4Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false; } if (docSchemaVersion < 5) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 5", DoVersion5Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false; } if (docSchemaVersion < 6) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 6", DoVersion6Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false; } if (docSchemaVersion < Common.GetResourceInt(Strings.PathMakerSchemaVersionRes)) { if (postUpgradeReportString.Length > 0) { if (catastrophicError) postUpgradeReportString = "The upgrade of this file resulted in at least one major error that requires you " + "go back into CID and fix something. You'll need to do that and export to PathMaker " + "again before proceeding.\n\n" + postUpgradeReportString; else postUpgradeReportString = "The upgrade of this file resulted in one or more minor issues. " + "To cleanup errors, search for shapes with the label \"" + Strings.ToBeDeletedLabel + "\". " + "Those shapes will need to be removed and replaced if necessary - do not use them.\n\n" + postUpgradeReportString; System.Windows.Forms.MessageBox.Show(postUpgradeReportString, "Upgrade Problem Report"); } if (catastrophicError) return false; Common.SetDocumentSchemaVersion(document); } return true; }
// This is where you plug in your upgrade if need be. These should only be // necessary for schema changes - releases where the shape data has changed. // Add an if statement for your version as described below internal static bool UpgradeDocumentToCurrentSchemaVersion(Document document) { int docSchemaVersion = Common.GetDocumentSchemaVersion(document); postUpgradeReportString = ""; catastrophicError = false; /** * Add another if statement here NOT AN ELSE IF so that the document will go * through all upgrades that are less than it's schema version * For example, two upgrades would look like this * if (docSchemaVersion < 1) * progressBarForm = new ProgressBarForm(DoVersion1Upgrade); * if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) * return false; * if (docSchemaVersion < 2) * progressBarForm = new ProgressBarForm(DoVersion1Upgrade); * if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) * return false; * etc. */ if (docSchemaVersion < 1) { // initial release of PathRunner ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 1", DoVersion1Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } } if (docSchemaVersion < 2) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 2", DoVersion2Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } } if (docSchemaVersion < 3) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 3", DoVersion3Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } } if (docSchemaVersion < 4) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 4", DoVersion4Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } } if (docSchemaVersion < 5) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 5", DoVersion5Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } } if (docSchemaVersion < 6) { ProgressBarForm progressBarForm = new ProgressBarForm("Upgrading to schema version 6", DoVersion6Upgrade, document); if (progressBarForm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } } if (docSchemaVersion < Common.GetResourceInt(Strings.PathMakerSchemaVersionRes)) { if (postUpgradeReportString.Length > 0) { if (catastrophicError) { postUpgradeReportString = "The upgrade of this file resulted in at least one major error that requires you " + "go back into CID and fix something. You'll need to do that and export to PathMaker " + "again before proceeding.\n\n" + postUpgradeReportString; } else { postUpgradeReportString = "The upgrade of this file resulted in one or more minor issues. " + "To cleanup errors, search for shapes with the label \"" + Strings.ToBeDeletedLabel + "\". " + "Those shapes will need to be removed and replaced if necessary - do not use them.\n\n" + postUpgradeReportString; } System.Windows.Forms.MessageBox.Show(postUpgradeReportString, "Upgrade Problem Report"); } if (catastrophicError) { return(false); } Common.SetDocumentSchemaVersion(document); } return(true); }
internal static bool DoVersion5Upgrade(Object arg, ProgressBarForm progressBarForm) { // Removing restrictions on change connector label text Document document = arg as Document; int total = 0; foreach (Page page in document.Pages) total += page.Shapes.Count; int count = 0; foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { if (Common.GetShapeType(shape) == ShapeTypes.Connector) { shape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visLockTextEdit).FormulaU = "0"; shape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visSLOSplittable).FormulaU = "1"; } count++; } progressBarForm.SetProgressPercentage(count, total); } return true; }
internal static bool DoVersion6Upgrade(Object arg, ProgressBarForm progressBarForm) { // Added State Sort Order to DefaultSettings Document document = arg as Document; int total = 0; foreach (Page page in document.Pages) total += page.Shapes.Count; int count = 0; foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { if (Common.GetShapeType(shape) == ShapeTypes.Start) { Table table = Common.GetCellTable(shape, ShapeProperties.Start.DefaultSettings); if (!table.IsEmpty()) { int row = table.AddRow(); table.SetData(row, (int)TableColumns.NameValuePairs.Name, Strings.DefaultSettingsStateSortOrder); table.SetData(row, (int)TableColumns.NameValuePairs.Value, Strings.StateSortOrderAlphaNumerical); Common.SetCellTable(shape, ShapeProperties.Start.DefaultSettings, table); } } count++; } progressBarForm.SetProgressPercentage(count, total); } return true; }
internal static bool DoVersion3Upgrade(Object arg, ProgressBarForm progressBarForm) { // Took version and last modified date off of DocTitle Document document = arg as Document; int total = 0; foreach (Page page in document.Pages) total += page.Shapes.Count; int count = 0; foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { if (Common.GetShapeType(shape) == ShapeTypes.DocTitle) { DeleteOldPropertyCell(shape, "Prop.LastModifiedDate"); DeleteOldPropertyCell(shape, "Prop.Version"); } count++; } progressBarForm.SetProgressPercentage(count, total); } return true; }
internal static bool DoVersion4Upgrade(Object arg, ProgressBarForm progressBarForm) { // Adding text control handles to connector text Document document = arg as Document; int total = 0; foreach (Page page in document.Pages) total += page.Shapes.Count; int count = 0; foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { Common.FixConnectorTextControl(shape); count++; } progressBarForm.SetProgressPercentage(count, total); } return true; }
internal static bool DoVersion2Upgrade(Object arg, ProgressBarForm progressBarForm) { // needed to track the previous uid for cut/copy/paste // cannot be done on selection because with no selection you can still // right click on a page and select copy drawing Document document = arg as Document; int total = 0; foreach (Page page in document.Pages) total += page.Shapes.Count; int count = 0; foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { string uid = shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID); Common.SetCellString(shape, Strings.CutCopyPasteTempCellName, uid); count++; } progressBarForm.SetProgressPercentage(count, total); } return true; }
// tried to do this as a BackgroundWorker - way too slow. Need to use the ProgressBarForm this way for // good performance. internal static bool DoVersion1Upgrade(Object arg, ProgressBarForm progressBarForm) { Document document = arg as Document; // these should only ever be used here... const string OffPageReferenceShapeName = "Off-page reference"; const string DynamicConnectorShapeName = "Dynamic connector"; const string OnPageReferenceIncomingShapeName = "On-page reference.Incoming"; const string OnPageReferenceOutgoingShapeName = "On-page reference.Outgoing"; const string SubDialogCallShapeName = "Call Sub-Dialog"; const string CommentShapeName = "Comment"; const string PageShapeName = "Sheet"; const string ReturnShapeName = "Return"; const string PlaceHolderShapeName = "Placeholder"; const string DMTypeCellName = "Prop.DMType"; const string DocumentTitleShapeName = "Document Title"; const string ChangeLogShapeName = "Change Log"; const string TransferShapeName = "Transfer"; const string TransferShapeName2 = "Terminator"; const string HangUpShapeName = "Hang up"; // most transitions can point to terminals (hangup/transfer/return) but not // maxhandlers - so we need a list without terminals to use for maxhandler conversions Dictionary<string, List<string>> uniqueIdMap = new Dictionary<string, List<string>>(); Dictionary<string, List<string>> uniqueIdMapNoTerminals = new Dictionary<string, List<string>>(); int total = 0; foreach (Page page in document.Pages) total += page.Shapes.Count; total = total * 4; // add some extra for the stuff done outside of this loop at the end int counter = 0; foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { ShapeTypes shapeType = ShapeTypes.None; progressBarForm.SetProgressPercentage(counter++, total); if (progressBarForm.Cancelled) return false; string dmType = Common.GetCellString(shape, DMTypeCellName); if (dmType.Equals("IA", StringComparison.Ordinal)) shapeType = ShapeTypes.Interaction; else if (dmType.Equals("PP", StringComparison.Ordinal)) shapeType = ShapeTypes.Play; else if (dmType.Equals("DE", StringComparison.Ordinal)) shapeType = ShapeTypes.Decision; else if (dmType.Equals("DR", StringComparison.Ordinal)) shapeType = ShapeTypes.Data; else if (dmType.Equals("SD", StringComparison.Ordinal)) shapeType = ShapeTypes.SubDialog; else if (dmType.Equals("ST", StringComparison.Ordinal)) shapeType = ShapeTypes.Start; if (shapeType == ShapeTypes.None) { // Figure out what else it could be... if (shape.Name.StartsWith(DocumentTitleShapeName)) shapeType = ShapeTypes.DocTitle; else if (shape.Name.StartsWith(ChangeLogShapeName)) shapeType = ShapeTypes.ChangeLog; else if (shape.Name.StartsWith(TransferShapeName) || shape.Name.StartsWith(TransferShapeName2)) shapeType = ShapeTypes.Transfer; else if (shape.Name.StartsWith(HangUpShapeName)) shapeType = ShapeTypes.HangUp; else if (shape.Name.StartsWith(OffPageReferenceShapeName)) shapeType = ShapeTypes.OffPageRef; else if (shape.Name.StartsWith(DynamicConnectorShapeName)) shapeType = ShapeTypes.Connector; else if (shape.Name.StartsWith(OnPageReferenceIncomingShapeName)) shapeType = ShapeTypes.OnPageRefIn; else if (shape.Name.StartsWith(OnPageReferenceOutgoingShapeName)) shapeType = ShapeTypes.OnPageRefOut; else if (shape.Name.StartsWith(SubDialogCallShapeName)) shapeType = ShapeTypes.CallSubDialog; else if (shape.Name.StartsWith(CommentShapeName)) shapeType = ShapeTypes.Comment; else if (shape.Name.StartsWith(PageShapeName)) shapeType = ShapeTypes.Page; else if (shape.Name.StartsWith(ReturnShapeName)) shapeType = ShapeTypes.Return; else if (shape.Name.StartsWith(PlaceHolderShapeName)) shapeType = ShapeTypes.Placeholder; else { postUpgradeReportString += "Shape could not be upgraded properly - " + ShapeDescription(shape) + "\n\n"; shape.Text = Strings.ToBeDeletedLabel; continue; } } System.Diagnostics.Debug.Assert(shapeType != ShapeTypes.None); // we really don't need to do anything with the page shapes // this also includes the rectangles drawn for revision history if (shapeType == ShapeTypes.Page) continue; // remove the action properties on all shapes RemoveRightMouseAction(shape, "P&roperties"); // and fix the actions for the ones we care about if (shapeType != ShapeTypes.OffPageRef && shapeType != ShapeTypes.HangUp && shapeType != ShapeTypes.OnPageRefIn && shapeType != ShapeTypes.OnPageRefOut && shapeType != ShapeTypes.Return && shapeType != ShapeTypes.Transfer && shapeType != ShapeTypes.Comment && shapeType != ShapeTypes.Placeholder && shapeType != ShapeTypes.Connector) AddRightMouseAction(shape, "P&roperties", "RUNADDONWARGS(\"QueueMarkerEvent\",\"/PathMaker /CMD=2\")", true, false, false, false); // delete old rows no longer used DeleteOldPropertyCell(shape, "Prop.TestPlanSetting"); DeleteOldPropertyCell(shape, "Prop.CheckPoints"); DeleteOldPropertyCell(shape, "Prop.UpdateData"); DeleteOldPropertyCell(shape, "Prop.LineName"); DeleteOldPropertyCell(shape, "Prop.Input"); DeleteOldPropertyCell(shape, "Prop.Output"); DeleteOldPropertyCell(shape, "Prop.OSDM"); DeleteOldPropertyCell(shape, "Prop.Destination"); DeleteOldPropertyCell(shape, "Prop.ColumnData"); DeleteOldPropertyCell(shape, "Prop.EnteringFrom"); DeleteOldPropertyCell(shape, "Prop.StartingDialogState"); DeleteOldPropertyCell(shape, "Prop.StartingDM"); DeleteOldPropertyCell(shape, "Prop.ChangeDate"); DeleteOldPropertyCell(shape, "Prop.InitialDate"); DeleteOldPropertyCell(shape, "Prop.LogoFilePath"); DeleteOldPropertyCell(shape, "Prop.LastUpdate"); if (shapeType == ShapeTypes.CallSubDialog) { // none of these are used... DeleteOldPropertyCell(shape, "Prop.DMName"); DeleteOldPropertyCell(shape, "Prop.EnteringFrom"); DeleteOldPropertyCell(shape, "Prop.StartingDialogState"); DeleteOldPropertyCell(shape, "Prop.Notes"); DeleteOldPropertyCell(shape, "Prop.LastUpdate"); DeleteOldPropertyCell(shape, "Prop.Transitions"); } else if (shapeType == ShapeTypes.SubDialog) DeleteOldPropertyCell(shape, "Prop.Transitions"); // Add a new cell containing the name of the subdialog being called // Later it will be converted to a UID if (shapeType == ShapeTypes.CallSubDialog) Common.SetCellString(shape, ShapeProperties.CallSubDialog.SubDialogUID, shape.Text); // rename rows that are confusing RenameRow(shape, "Prop.DialogParameters", ShapeProperties.SpecialSettings, "Special Settings"); RenameRow(shape, "Prop.DMName", ShapeProperties.StateId, "State Name"); RenameRow(shape, "Prop.DMType", ShapeProperties.ShapeType, "Shape Type"); RenameRow(shape, "Prop.InputData", ShapeProperties.Start.Initialization, "Initialization"); RenameRow(shape, "Prop.GlobalCommands", ShapeProperties.CommandTransitions, "Command Transitions"); RenameRow(shape, "Prop.GlobalPrompts", ShapeProperties.PromptTypes, "Prompt Types"); RenameRow(shape, "Prop.GlobalConfirmations", ShapeProperties.ConfirmationPrompts, "Confirmation Prompts"); RenameRow(shape, "Prop.TitleLine1", ShapeProperties.DocTitle.ClientName, "Client Name"); RenameRow(shape, "Prop.TitleLine2", ShapeProperties.DocTitle.ProjectName, "Project Name"); if (shapeType == ShapeTypes.Interaction) { RenameRow(shape, "Prop.Transitions", "Prop.CommandTransitions", "Command Transitions"); RenameRow(shape, "Prop.Prompts", "Prop.PromptTypes", "Prompt Types"); } // undo encoding we'll never use UnencodeProperty(shape, ShapeProperties.ChangeLog.Changes); UnencodeProperty(shape, ShapeProperties.Start.DefaultSettings); UnencodeProperty(shape, ShapeProperties.Start.Initialization); UnencodeProperty(shape, ShapeProperties.MaxHandling); UnencodeProperty(shape, ShapeProperties.Play.Prompts); UnencodeProperty(shape, ShapeProperties.PromptTypes); UnencodeProperty(shape, ShapeProperties.Transitions); UnencodeProperty(shape, ShapeProperties.CommandTransitions); UnencodeProperty(shape, ShapeProperties.SpecialSettings); UnencodeProperty(shape, ShapeProperties.DeveloperNotes); UnencodeProperty(shape, ShapeProperties.ConfirmationPrompts); UnencodeProperty(shape, ShapeProperties.LastUpdate); // make each shape get a GUID string uniqueId = shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID); // off page refs have two shapes with the same name and we don't need them for this if (shapeType != ShapeTypes.OffPageRef) { List<string> list = null; if (uniqueIdMap.TryGetValue(shape.Name, out list)) list.Add(uniqueId); else { list = new List<string>(); list.Add(uniqueId); uniqueIdMap.Add(shape.Name, list); } if (shapeType != ShapeTypes.Placeholder && shapeType != ShapeTypes.HangUp && shapeType != ShapeTypes.Transfer && shapeType != ShapeTypes.Return) { list = null; if (uniqueIdMapNoTerminals.TryGetValue(shape.Name, out list)) list.Add(uniqueId); else { list = new List<string>(); list.Add(uniqueId); uniqueIdMapNoTerminals.Add(shape.Name, list); } } } // change all double click handlers if (shapeType == ShapeTypes.DocTitle || shapeType == ShapeTypes.ChangeLog || shapeType == ShapeTypes.Start || shapeType == ShapeTypes.Interaction || shapeType == ShapeTypes.Play || shapeType == ShapeTypes.Decision || shapeType == ShapeTypes.Data || shapeType == ShapeTypes.SubDialog || shapeType == ShapeTypes.CallSubDialog) Common.SetCellFormula(shape, "EventDblClick", "RUNADDONWARGS(\"QueueMarkerEvent\",\"/PathMaker /CMD=1\")"); // global transitions need a new column to match the interaction transitions if (shapeType == ShapeTypes.Start) { Table table = Common.GetCellTable(shape, ShapeProperties.CommandTransitions); if (!table.IsEmpty()) { int newCol = table.AddColumn(); System.Diagnostics.Debug.Assert(newCol == 18); // copies the goto column to the line column to match interactions table.CopyColumn(7, 18); Common.SetCellTable(shape, ShapeProperties.CommandTransitions, table); } } // unlock most shape text edits - remember play and interaction are multiple shapes if (shapeType == ShapeTypes.Data || shapeType == ShapeTypes.Decision || shapeType == ShapeTypes.Interaction || shapeType == ShapeTypes.Play || shapeType == ShapeTypes.SubDialog) shape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visLockTextEdit).FormulaU = "0"; if (shapeType == ShapeTypes.Interaction || shapeType == ShapeTypes.Play) { shape.Shapes[1].get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visLockTextEdit).FormulaU = "0"; // and bring it to front so you are editing the shape name by default shape.Shapes[1].BringToFront(); } // the old stuff never locked call sub dialogs - we want to if (shapeType == ShapeTypes.CallSubDialog) shape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visLockTextEdit).FormulaU = "1"; // normalize/fix all the grid datastore stuff - get rid of unused columns, etc. // remove plus, minus, goto, update_plus, update_minus, cp_idx RemoveColumnsFromCellTable(shape, ShapeProperties.CommandTransitions, new int[6] { 3, 5, 7, 12, 14, 19 }); // remove plus, minus, update_plus, update_minus RemoveColumnsFromCellTable(shape, ShapeProperties.ConfirmationPrompts, new int[4] { 1, 3, 7, 9 }); // remove plus, minus, updateplus, updateminus RemoveColumnsFromCellTable(shape, ShapeProperties.PromptTypes, new int[4] { 1, 3, 7, 9 }); // remove plus, minus, updateplus, updateminus, cp_idx RemoveColumnsFromCellTable(shape, ShapeProperties.Play.Prompts, new int[5] { 0, 2, 5, 7, 10 }); // remove plus, minus, goto, updateplus, updateminus RemoveColumnsFromCellTable(shape, ShapeProperties.Transitions, new int[5] { 0, 2, 4, 5, 7 }); // remove highlight index column RemoveColumnsFromCellTable(shape, ShapeProperties.ChangeLog.Changes, new int[1] { 5 }); // clear any old changelog descriptions from the page itself if (shapeType == ShapeTypes.ChangeLog) { Page changeLogPage = shape.ContainingPage; for (int count = changeLogPage.Shapes.Count; count > 0; count--) if (changeLogPage.Shapes[count] != shape) changeLogPage.Shapes[count].Delete(); } // Start has the max handlers in a different order than the interaction states - fix it here if (shapeType == ShapeTypes.Start) SwapRowsInCellTable(shape, ShapeProperties.MaxHandling, 0, 1); // Get rid of expressware checkpoints default setting if (shapeType == ShapeTypes.Start) { Table table = Common.GetCellTable(shape, ShapeProperties.Start.DefaultSettings); for (int r = 0; r < table.GetNumRows(); r++) { if (table.GetData(r, 0).Equals("ExpressWare Checkpoints")) { table.DeleteRow(r); break; } } } // apparently subDialogs developer notes were not written out as a two column entry (one for date of change) if (shapeType == ShapeTypes.SubDialog) EnsureTwoColumns(shape, ShapeProperties.DeveloperNotes); // set shape type - this will add it if necessary - make sure to use int value Common.SetCellFormula(shape, ShapeProperties.ShapeType, ((int)shapeType).ToString()); SetRowLabel(shape, ShapeProperties.ShapeType, "Shape Type"); } } // we remove change log stuff above - need to recount the remaining totals total = 0; foreach (Page page in document.Pages) total += page.Shapes.Count; total = counter + (total * 3); // we'll go through 3 times below // The following stuff needed to wait until every state had a GUID // change all references from state ids/names to use GUIDs foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { // column 13 should now be the link column ReplaceStateIdsWithUniqueIds(shape, uniqueIdMap, ShapeProperties.CommandTransitions, 13); // column 5 should be the link column ReplaceStateIdsWithUniqueIds(shape, uniqueIdMap, ShapeProperties.Transitions, 5); // column 3 should be the goto column ReplaceStateIdsWithUniqueIds(shape, uniqueIdMapNoTerminals, ShapeProperties.MaxHandling, 3); // it's a singleton, not a table - only exists on call subdialogs ReplaceStateIdWithUniqueIds(shape, uniqueIdMap, ShapeProperties.CallSubDialog.SubDialogUID); progressBarForm.SetProgressPercentage(counter++, total); if (progressBarForm.Cancelled) return false; } } // fix off page connectors Dictionary<string, Shape> offPageShapeNameMap = new Dictionary<string, Shape>(); foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { if (Common.GetShapeType(shape) == ShapeTypes.OffPageRef) { // common fixes // hyperlinks point to pages, not shapes, even if the shape is deleted - drop these short row; if (shape.get_CellExists(ShapeProperties.OffPageRef.HyperLink, (short)VisExistsFlags.visExistsAnywhere) != 0) { row = shape.get_CellsRowIndex(ShapeProperties.OffPageRef.HyperLink); shape.DeleteRow((short)VisSectionIndices.visSectionHyperlink, row); } if (shape.get_CellExists("Hyperlink.PageLinkDest", (short)VisExistsFlags.visExistsAnywhere) != 0) { row = shape.get_CellsRowIndex("Hyperlink.PageLinkDest"); shape.DeleteRow((short)VisSectionIndices.visSectionHyperlink, row); } // the standard off-page connector dbl click handler works fine Common.SetCellFormula(shape, ShapeProperties.EventDblClick, Strings.OffPageConnectorDblClickCommand); // the standard off-page connector drop handler works fine Common.SetCellFormula(shape, ShapeProperties.EventDrop, Strings.OffPageConnectorDropCommand); // keep the text synchronized Common.SetCellFormula(shape, ShapeProperties.TheText, Strings.OffPageConnectorTextCommand); // delete actions to change shape to circle/arrow row = shape.get_CellsRowIndex("Actions.Row_3"); shape.DeleteRow((short)VisSectionIndices.visSectionAction, row); row = shape.get_CellsRowIndex("Actions.Row_4"); shape.DeleteRow((short)VisSectionIndices.visSectionAction, row); Shape target; if (offPageShapeNameMap.TryGetValue(shape.Text, out target)) { // we have a pair... Common.SetCellString(shape, ShapeProperties.OffPageConnectorShapeID, shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(shape, ShapeProperties.OffPageConnectorDestinationPageID, target.ContainingPage.PageSheet.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(shape, ShapeProperties.OffPageConnectorDestinationShapeID, target.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(target, ShapeProperties.OffPageConnectorShapeID, target.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(target, ShapeProperties.OffPageConnectorDestinationPageID, shape.ContainingPage.PageSheet.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); Common.SetCellString(target, ShapeProperties.OffPageConnectorDestinationShapeID, shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)); offPageShapeNameMap.Remove(shape.Text); } else offPageShapeNameMap.Add(shape.Text, shape); } progressBarForm.SetProgressPercentage(counter++, total); if (progressBarForm.Cancelled) return false; } } // In CID you could have on-page connectors backwards - check for them here foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { if (Common.GetShapeType(shape) == ShapeTypes.OnPageRefIn) { bool arrowSide = false; foreach (Connect c in shape.FromConnects) { // determine which end of the connector is connected to the nonConnectorShadow if (c.FromCell.Name.Equals(Strings.EndConnectionPointCellName)) arrowSide = true; } // if we are on the arrow side of the connector, that means this is an input connector if (arrowSide) { postUpgradeReportString += "On page reference input can't have inputs - " + ShapeDescription(shape) + "\n\n"; catastrophicError = true; } } else if (Common.GetShapeType(shape) == ShapeTypes.OnPageRefOut) { bool arrowSide = true; foreach (Connect c in shape.FromConnects) { // determine which end of the connector is connected to the nonConnectorShadow if (c.FromCell.Name.Equals(Strings.EndConnectionPointCellName)) arrowSide = true; // if we are on the non-arrow side of the connector, that means this is an output connector if (!arrowSide) { postUpgradeReportString += "On page reference output can't have outputs - " + ShapeDescription(shape) + "\n\n"; catastrophicError = true; } } } } } // any left over are not hooked up - this is a problem... if (offPageShapeNameMap.Count > 0) for (int i = 0; i < offPageShapeNameMap.Count; i++) { Shape noMatch = offPageShapeNameMap.Values.ElementAt(i); postUpgradeReportString += "No matching off page connector found for " + ShapeDescription(noMatch) + "\n\n"; noMatch.Text = Strings.ToBeDeletedLabel; } // Last thing to do - now that we can use all the new column names, we want to find all table fields using $$ and fix them foreach (Page page in document.Pages) { foreach (Shape shape in page.Shapes) { FixDollarDollarTableFields(shape, ShapeProperties.CommandTransitions); FixDollarDollarTableFields(shape, ShapeProperties.PromptTypes); FixDollarDollarTableFields(shape, ShapeProperties.ConfirmationPrompts); FixDollarDollarTableFields(shape, ShapeProperties.MaxHandling); FixDollarDollarTableFields(shape, ShapeProperties.DeveloperNotes); FixDollarDollarTableFields(shape, ShapeProperties.SpecialSettings); FixDollarDollarTableFields(shape, ShapeProperties.Transitions); FixDollarDollarTableFields(shape, ShapeProperties.Play.Prompts); FixDollarDollarTableFields(shape, ShapeProperties.Start.DefaultSettings); FixDollarDollarTableFields(shape, ShapeProperties.Start.Initialization); progressBarForm.SetProgressPercentage(counter++, total); if (progressBarForm.Cancelled) return false; } } progressBarForm.SetProgressPercentage(100, 100); progressBarForm.Hide(); progressBarForm = null; return true; }
private static bool ExportUserInterfaceSpecWorker(Object arg, ProgressBarForm progressBarForm) { ParamCache paramCache = arg as ParamCache; gotoNameCache = new Dictionary<Shadow, string>(); 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.VUITemplateFileNameRes); Document doc = wordApp.Documents.Add(templateFilename); doc.BuiltInDocumentProperties["Author"] = "Convergys PathMaker"; // output visio Selection content = wordApp.Selection; content.GoTo(What: WdGoToItem.wdGoToBookmark, Name: "CallFlowDiagram"); content.ClearFormatting(); content.set_Style("Normal"); content.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; foreach (Microsoft.Office.Interop.Visio.Page page in paramCache.visioControl.Document.Pages) { if (!page.Name.StartsWith("Background-") && !page.Name.Equals("Title") && !page.Name.Equals("Revision History")) { string tmpFileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".jpg"; page.Export(tmpFileName); content.InlineShapes.AddPicture(tmpFileName); content.InsertBreak(WdBreakType.wdPageBreak); } } // just show we're moving a little earlier progressBarForm.SetProgressPercentage(1, 100); AddTitleAndLogo(doc, paramCache.docTitleShadow); AddChangeLog(doc, changeLogShadow); AddStartTables(doc, paramCache.startShadow); List<Shadow> shadowList = PathMaker.LookupAllShadows(); for (int i = shadowList.Count - 1; i >= 0; i--) { StateShadow tmpShadow = shadowList[i] as StateShadow; if (tmpShadow == null) shadowList.RemoveAt(i); } SetUpGotoMaxHandlerCache(); string stateSortOrder = paramCache.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, paramCache.visioControl.Document, paramCache.startShadow); int total = shadowList.Count; int progress = 0; foreach (Shadow shadow in shadowList) { progress++; switch (shadow.GetShapeType()) { case ShapeTypes.Interaction: AddInteractionTable(doc, shadow as InteractionShadow); break; case ShapeTypes.Play: AddPlayTable(doc, shadow as PlayShadow); break; case ShapeTypes.Decision: AddDecisionTable(doc, shadow as DecisionShadow); break; case ShapeTypes.Data: AddDataTable(doc, shadow as DataShadow); break; case ShapeTypes.SubDialog: AddSubDialogTable(doc, shadow as SubDialogShadow); break; default: break; } progressBarForm.SetProgressPercentage(progress, total); if (progressBarForm.Cancelled) { ((_Application)wordApp).Quit(false); System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); gotoNameCache = null; gotoMaxHandlerCache = null; wordApp = null; return false; } } doc.Tables[Templates.GlobalCommands].Delete(); doc.Tables[Templates.GlobalPromptTypes].Delete(); doc.Tables[Templates.DefaultSettings].Delete(); doc.Tables[Templates.GlobalMaxHandler].Delete(); if (paramCache.startShadow.GetDefaultSetting(Strings.DefaultSettingsMode).Equals(Strings.ModeSpeech)) doc.Bookmarks["TouchTone"].Range.Delete(); else doc.Bookmarks["Speech"].Range.Delete(); doc.Bookmarks["TempPages"].Range.Delete(); doc.Fields.Update(); gotoNameCache = null; gotoMaxHandlerCache = null; progressBarForm.SetProgressPercentage(total, total); System.Windows.Forms.Application.DoEvents(); doc.SaveAs(paramCache.targetFilename); ((_Application)wordApp).Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); wordApp = null; return true; }
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(); }