Ejemplo n.º 1
0
 public static AppDescShadow LookupAppDescShadow()
 {
     foreach (Shadow shadow in shadowShapeMap.Values)
     {
         AppDescShadow appDescShadow = shadow as AppDescShadow;
         if (appDescShadow != null)
         {
             return(shadow as AppDescShadow);
         }
     }
     return(null);
 }
Ejemplo n.º 2
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 AddAppDescription(Document doc, AppDescShadow appDescShadow, String label)
        {
            Microsoft.Office.Interop.Word.Table appDescTable = null;
            if (label.Contains("VUI"))
            {
                appDescTable = doc.Tables[Templates.AppDescription];
                String tableText = appDescShadow.GetDescriptionText();

               if ((tableText == null) || (tableText == "")) {
                    tableText = "Please go back to PathMaker and enter a brief description about your application.";
               }
               appDescTable.Cell(2, 1).Range.Text = tableText;

               //Selection content = doc.Application.Selection;
            }
        }
        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();
        }
Ejemplo n.º 6
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);
        }