예제 #1
0
 public static PrefixListShadow LookupPrefixListShadow()
 {
     foreach (Shadow shadow in shadowShapeMap.Values)
     {
         PrefixListShadow appDescShadow = shadow as PrefixListShadow;
         if (appDescShadow != null)
         {
             return(shadow as PrefixListShadow);
         }
     }
     return(null);
 }
예제 #2
0
 public DialogResult ShowDialog(PrefixListShadow shadow)
 {
     this.shadow = shadow;
     return(ShowDialog());
 }
예제 #3
0
        // Creates a shadow from a shape.  Should only be called from PathMaker
        // event handlers when things are loaded, added, etc.
        public static Shadow MakeShapeShadow(Shape shape)
        {
            ShapeTypes shapeType = Common.GetShapeType(shape);
            Shadow shadow = null;

            switch (shapeType) {
                case ShapeTypes.CallSubDialog:
                    shadow = new CallSubDialogShadow(shape);
                    break;
                case ShapeTypes.ChangeLog:
                    shadow = new ChangeLogShadow(shape);
                    break;
                case ShapeTypes.AppDesc:
                    shadow = new AppDescShadow(shape);
                    break;
                case ShapeTypes.PrefixList:
                    shadow = new PrefixListShadow(shape);
                    break;
                case ShapeTypes.Comment:
                    shadow = new IgnoredShadow(shape);
                    break;
                case ShapeTypes.Connector:
                    shadow = new ConnectorShadow(shape);
                    break;
                case ShapeTypes.Data:
                    shadow = new DataShadow(shape);
                    break;
                case ShapeTypes.Decision:
                    shadow = new DecisionShadow(shape);
                    break;
                case ShapeTypes.DocTitle:
                    shadow = new DocTitleShadow(shape);
                    break;
                case ShapeTypes.HangUp:
                    shadow = new HangUpShadow(shape);
                    break;
                case ShapeTypes.Interaction:
                    shadow = new InteractionShadow(shape);
                    break;
                case ShapeTypes.None:
                    break;
                case ShapeTypes.OffPageRef:
                    shadow = new OffPageRefShadow(shape);
                    break;
                case ShapeTypes.OnPageRefIn:
                    shadow = new OnPageRefInShadow(shape);
                    break;
                case ShapeTypes.OnPageRefOut:
                    shadow = new OnPageRefOutShadow(shape);
                    break;
                case ShapeTypes.Page:
                    break;
                case ShapeTypes.Placeholder:
                    shadow = new IgnoredShadow(shape);
                    break;
                case ShapeTypes.Play:
                    shadow = new PlayShadow(shape);
                    break;
                case ShapeTypes.Return:
                    shadow = new ReturnShadow(shape);
                    break;
                case ShapeTypes.Start:
                    shadow = new StartShadow(shape);
                    break;
                case ShapeTypes.SubDialog:
                    shadow = new SubDialogShadow(shape);
                    break;
                case ShapeTypes.Transfer:
                    shadow = new TransferShadow(shape);
                    break;
            }
            return shadow;
        }
        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;
        }
        private static void AddPrefixList(Document doc, PrefixListShadow prefixListShadow, String label)
        {
            Microsoft.Office.Interop.Word.Table prefixListTable = null;
            if (label.Contains("VUI"))
            {
                prefixListTable = doc.Tables[Templates.PrefixList];
                Table table = prefixListShadow.GetPrefixListTable();
                InsertWordTableRows(prefixListTable, 2, table.GetNumRows() - 1);

                int wordRow = 2;
                for (int row = 0; row < table.GetNumRows(); row++)
                {
                    prefixListTable.Cell(wordRow, 1).Range.InsertAfter(table.GetData(row, (int)TableColumns.PrefixList.Prefix));
                    prefixListTable.Cell(wordRow, 2).Range.InsertAfter(table.GetData(row, (int)TableColumns.PrefixList.Meaning));
                    wordRow++;
                }
            }
        }
        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();
        }
예제 #7
0
        // Creates a shadow from a shape.  Should only be called from PathMaker
        // event handlers when things are loaded, added, etc.
        public static Shadow MakeShapeShadow(Shape shape)
        {
            ShapeTypes shapeType = Common.GetShapeType(shape);
            Shadow     shadow    = null;

            switch (shapeType)
            {
            case ShapeTypes.CallSubDialog:
                shadow = new CallSubDialogShadow(shape);
                break;

            case ShapeTypes.ChangeLog:
                shadow = new ChangeLogShadow(shape);
                break;

            case ShapeTypes.AppDesc:
                shadow = new AppDescShadow(shape);
                break;

            case ShapeTypes.PrefixList:
                shadow = new PrefixListShadow(shape);
                break;

            case ShapeTypes.Comment:
                shadow = new IgnoredShadow(shape);
                break;

            case ShapeTypes.Connector:
                shadow = new ConnectorShadow(shape);
                break;

            case ShapeTypes.Data:
                shadow = new DataShadow(shape);
                break;

            case ShapeTypes.Decision:
                shadow = new DecisionShadow(shape);
                break;

            case ShapeTypes.DocTitle:
                shadow = new DocTitleShadow(shape);
                break;

            case ShapeTypes.HangUp:
                shadow = new HangUpShadow(shape);
                break;

            case ShapeTypes.Interaction:
                shadow = new InteractionShadow(shape);
                break;

            case ShapeTypes.None:
                break;

            case ShapeTypes.OffPageRef:
                shadow = new OffPageRefShadow(shape);
                break;

            case ShapeTypes.OnPageRefIn:
                shadow = new OnPageRefInShadow(shape);
                break;

            case ShapeTypes.OnPageRefOut:
                shadow = new OnPageRefOutShadow(shape);
                break;

            case ShapeTypes.Page:
                break;

            case ShapeTypes.Placeholder:
                shadow = new IgnoredShadow(shape);
                break;

            case ShapeTypes.Play:
                shadow = new PlayShadow(shape);
                break;

            case ShapeTypes.Return:
                shadow = new ReturnShadow(shape);
                break;

            case ShapeTypes.Start:
                shadow = new StartShadow(shape);
                break;

            case ShapeTypes.SubDialog:
                shadow = new SubDialogShadow(shape);
                break;

            case ShapeTypes.Transfer:
                shadow = new TransferShadow(shape);
                break;
            }
            return(shadow);
        }
 public DialogResult ShowDialog(PrefixListShadow shadow)
 {
     this.shadow = shadow;
     return ShowDialog();
 }