Пример #1
0
        public static void RedoAllPromptIds()
        {
            List <Shadow> shadowList  = PathMaker.LookupAllShadows();
            int           count       = 100;
            StartShadow   startShadow = PathMaker.LookupStartShadow();

            if (startShadow == null)
            {
                Common.ErrorMessage("No start shape available to determine prompt id format");
                return;
            }

            string promptIdFormat = startShadow.GetDefaultSetting(Strings.DefaultSettingsPromptIDFormat);

            startShadow.RedoPromptIds(count, promptIdFormat);

            foreach (Shadow s in shadowList)
            {
                StateShadow stateShadow = s as StateShadow;
                if (stateShadow != null)
                {
                    count += stateShadow.RedoPromptIds(count, promptIdFormat);
                }
            }
        }
Пример #2
0
        /**
         * Find the off page connector associated with this one
         * This is done using the OPC fields on the shape that store
         * the partner page sheet and shape ids
         */
        private Shadow GetPartnerOffPageRefShadow()
        {
            string pageSheetId = Common.GetCellString(shape, ShapeProperties.OffPageConnectorDestinationPageID);
            string shapeId     = Common.GetCellString(shape, ShapeProperties.OffPageConnectorDestinationShapeID);

            foreach (Page page in shape.Document.Pages)
            {
                if (page.PageSheet.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID).Equals(pageSheetId))
                {
                    Shape partner = null;

                    try {
                        partner = page.Shapes[shapeId];
                    }
                    catch {
                        Common.ErrorMessage("Off page connector \"" + shape.Text + "\" missing partner on page " + shape.ContainingPage.Name + ".\nRenaming to " + Strings.ToBeDeletedLabel + ".");
                        shape.Text = Strings.ToBeDeletedLabel;
                    }

                    if (partner != null)
                    {
                        return(PathMaker.LookupShadowByShape(partner));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

            return(null);
        }
Пример #3
0
        void OnShapeExitTextEdit(Shape shape)
        {
            Shadow shadow = LookupShadowByShape(shape);

            if (shadow != null)
            {
                shadow.OnShapeExitTextEdit();
            }
            else
            {
                Shape parent = shape.Parent as Shape;

                if (parent != null)
                {
                    // for state shapes where there are multiple shapes in the stencil, we need the parent
                    shadow = LookupShadowByShape(parent);
                    if (shadow != null)
                    {
                        shadow.OnShapeExitTextEdit();
                    }
                    else
                    {
                        Common.ErrorMessage("Error - editing text on unexpected item " + shape.Name);
                    }
                }
                else
                {
                    // sometimes odd ball shapes get edited - just let them be
                    // for example, dropping a non-PathMaker shape or upgrading one could end up here
                }
            }
        }
Пример #4
0
        public override void OnShapeExitTextEdit()
        {
            List <Shadow> list = new List <Shadow>();

            // These are still only held together by name
            Page page = shape.ContainingPage;

            foreach (Shape s in page.Shapes)
            {
                if (shape.Text.Equals(s.Text))
                {
                    Shadow shadow = PathMaker.LookupShadowByShape(s);
                    if (shadow.GetType() == this.GetType())
                    {
                        list.Add(shadow);
                    }
                }
            }

            if (list.Count > 1)
            {
                Common.ErrorMessage("Error - Incoming On Page Reference \"" + shape.Text + "\" already exists.");
                shape.Text = Strings.ToBeDeletedLabel;
            }
        }
Пример #5
0
 public override void OnConnectAddInput(Shadow shadow)
 {
     if (IsIllegalLoop())
     {
         Common.ErrorMessage("Incorrectly creating a loop with connector - deleting");
         shape.Delete();
     }
 }
 public override void OnConnectAddOutput(Shadow shadow)
 {
     if (GetOutputs().Count > 1)
     {
         Common.ErrorMessage("Incorrectly adding more than one output to a Call SubDialog");
         // get busy cursor without this
         shadow.SelectShape();
     }
 }
Пример #7
0
 public ConnectorShadow(Shape shape)
     : base(shape)
 {
     if (IsIllegalLoop())
     {
         Common.ErrorMessage("There's an improper loop caused by " + shape.Name + " on page" + shape.ContainingPage.Name + " - deleting it.");
         shape.Delete();
     }
 }
Пример #8
0
 public override void OnConnectAddOutput(Shadow shadow)
 {
     if (GetInputs().Count > 0)
     {
         Common.ErrorMessage("Incorrectly adding output to an Off Page Reference that has inputs");
         // get busy cursor without this
         shadow.SelectShape();
     }
 }
Пример #9
0
        public override List <Shadow> GetSourceTargets()
        {
            List <Shadow>  list     = new List <Shadow>();
            List <Connect> connects = GetShapeInputs();

            if (connects.Count == 0)
            {
                // no inbound connectors, find the partner and go from there
                OffPageRefShadow partnerShadow = GetPartnerOffPageRefShadow() as OffPageRefShadow;
                if (partnerShadow != null)
                {
                    List <Connect> partnerConnects = partnerShadow.GetShapeInputs();
                    if (partnerConnects.Count == 0)
                    {
                        if (GetShapeOutputs().Count == 0)
                        {
                            Common.ErrorMessage("No inputs for off-page connector " + shape.Text + " on page " + shape.ContainingPage.Name);
                        }
                        else
                        {
                            Common.ErrorMessage("No inputs for off-page connector " + partnerShadow.shape.Text + " on page " + partnerShadow.shape.ContainingPage.Name);
                        }
                        list.Add(this);
                    }
                    else
                    {
                        list.AddRange(partnerShadow.GetSourceTargets());
                    }
                }
                else
                {
                    list.Add(this);
                }
            }
            else
            {
                foreach (Connect c in connects)
                {
                    // always the from sheet = connector (fromsheet = 1D, tosheet = 2D)
                    Shape  sourceShape  = c.FromSheet;
                    Shadow sourceShadow = PathMaker.LookupShadowByShape(sourceShape);
                    if (sourceShadow != null)
                    {
                        list.AddRange(sourceShadow.GetSourceTargets());
                    }
                    else
                    {
                        list.Add(this);
                    }
                }
            }
            return(list);
        }
Пример #10
0
        // NOTE - You can't just add an OnShapeDoubleClick handler to a shadow and get the event
        // You also need to change the shapesheet (in .vss file and in upgrade) to use the
        // double click handler used by others "RUNADDONWARGS(\"QueueMarkerEvent\",\"/PathMaker /CMD=1\")"
        private void OnShapeDoubleClick(Shape shape)
        {
            Shadow shadow = LookupShadowByShape(shape);

            if (shadow != null)
            {
                shadow.OnShapeDoubleClick();
            }
            else
            {
                Common.ErrorMessage("Error - double clicking on unexpected item " + shape.Name);
            }
        }
Пример #11
0
        // NOTE - You can't just add an OnShapeProperties handler to a shadow and get the event
        // You also need to change the shapesheet (in .vss file and in upgrade) to use the
        // double click handler used by others "RUNADDONWARGS(\"QueueMarkerEvent\",\"/PathMaker /CMD=2\")"
        private void OnShapeProperties(Shape shape)
        {
            Shadow shadow = LookupShadowByShape(shape);

            if (shadow != null)
            {
                shadow.OnShapeProperties();
            }
            else
            {
                Common.ErrorMessage("Error - properties on unexpected item " + shape.Name);
            }
        }
        public override void FixUIDReferencesAfterPaste(Dictionary <string, string> oldGUIDToNewGUIDMap)
        {
            string oldUID = GetSubDialogUID();
            string newUID;

            newUID = CommonShadow.GetNewUIDAfterPaste(oldUID, oldGUIDToNewGUIDMap, true);
            if (newUID.Length == 0)
            {
                Common.ErrorMessage("Call SubDialog refers to a SubDialog which can't be found, clearing");
                newUID = "";
            }
            SetSubDialogUID(newUID);
        }
        public static void Remove(StateShadow stateShadow)
        {
            string prefix, number, name;

            StateShadow.DisectStateIdIntoParts(stateShadow.GetStateId(), out prefix, out number, out name);
            int backupToNumber = currentStateNumber;

            // let's make sure this isn't an undo of a paste of a duplicate
            string      prefixPlusNumber;
            StateShadow shadow;

            if (prefixNumberToShadow.TryGetValue(prefix + number, out shadow))
            {
                if (shadow == stateShadow)
                {
                    // good match - remove
                    prefixNumberToShadow.Remove(prefix + number);
                    shadowToPrefixNumber.Remove(shadow);

                    int numberInt;
                    if (int.TryParse(number, out numberInt))
                    {
                        backupToNumber = numberInt;
                    }
                }
                else
                {
                    if (shadowToPrefixNumber.TryGetValue(stateShadow, out prefixPlusNumber))
                    {
                        // so we are registered with a different prefix + number, remove that one
                        prefixNumberToShadow.Remove(prefixPlusNumber);
                        shadowToPrefixNumber.Remove(stateShadow);

                        int numberInt;
                        if (int.TryParse(number, out numberInt))
                        {
                            backupToNumber = numberInt;
                        }
                    }
                    else
                    {
                        // should never get here...
                        Common.ErrorMessage("Removing a state which isn't in the State Id Map");
                    }
                }
                if (backupToNumber < currentStateNumber)
                {
                    currentStateNumber = backupToNumber;
                }
            }
        }
Пример #14
0
        public override void OnBeforeShapeDelete()
        {
            StatePrefixAndNumberManager.Remove(this);

            // check to see if any max handlers use this - if so change to hang up
            List <Shadow> shadowList = PathMaker.LookupAllShadows();

            foreach (Shadow s in shadowList)
            {
                if (s.RemoveGotosThatDontUseConnectors(shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)))
                {
                    Common.ErrorMessage("Shape was being used as a goto in " + s.GetGotoName() + " - changing to Hang up");
                }
            }
        }
Пример #15
0
        public override Shadow GetDestinationTarget()
        {
            List <Connect> list = GetShapeOutputs();

            System.Diagnostics.Debug.WriteLine("offpage - " + shape.Text + " page - " + shape.ContainingPage.Name);

            if (list.Count == 0 && GetShapeInputs().Count == 0)
            {
                // no in or outbound connectors
                return(this);
            }
            else if (list.Count > 0)
            {
                // find outbound link (should only be one)
                if (list.Count != 1)
                {
                    return(this);
                }

                // the FromSheet is the outgoing connector (always from = 1D, to = 2D)
                Shadow connectedToShadow = PathMaker.LookupShadowByShape(list[0].FromSheet);
                if (connectedToShadow != null)
                {
                    return(connectedToShadow.GetDestinationTarget());
                }
                else
                {
                    return(this);
                }
            }
            else
            {
                OffPageRefShadow partnerShadow = GetPartnerOffPageRefShadow() as OffPageRefShadow;

                if (partnerShadow != null && partnerShadow.GetShapeOutputs().Count > 0)
                {
                    return(partnerShadow.GetDestinationTarget());
                }
                else
                {
                    if (partnerShadow != null && partnerShadow.GetShapeInputs().Count > 0)
                    {
                        Common.ErrorMessage("Off page connector " + shape.Text + " on page " + shape.ContainingPage.Name + " and it's partner both have inputs");
                    }
                    return(this);
                }
            }
        }
Пример #16
0
        private bool ReadyForConnectorMove(out Cell nonArrowSideCell, out Shape fromShape)
        {
            nonArrowSideCell = null;
            fromShape        = null;

            if (visioControl.Document.Application.ActiveWindow.Selection.Count != 1)
            {
                Common.ErrorMessage("A single connector must be selected");
                return(false);
            }
            Shape      connector = visioControl.Document.Application.ActiveWindow.Selection[1];
            ShapeTypes type      = Common.GetShapeType(connector);

            if (type != ShapeTypes.Connector)
            {
                Common.ErrorMessage("A single connector must be selected");
                return(false);
            }

            Shadow connectorShadow = PathMaker.LookupShadowByShape(connector);

            if (connectorShadow == null)
            {
                Common.ErrorMessage("Connector is not a valid PathMaker shape");
                return(false);
            }

            nonArrowSideCell = connector.get_Cells("BeginX");
            Connect nonArrowSideConnect = null;

            foreach (Connect c in connector.Connects)
            {
                if (c.FromCell.Name.Equals(Strings.BeginConnectionPointCellName))
                {
                    nonArrowSideConnect = c;
                }
            }

            if (nonArrowSideConnect == null)
            {
                Common.ErrorMessage("Connector must be connected on the non-arrow side");
                return(false);
            }

            fromShape = nonArrowSideConnect.ToSheet;
            return(true);
        }
Пример #17
0
        public override void OnConnectAddOutput(Shadow shadow)
        {
            if (IsIllegalLoop())
            {
                Common.ErrorMessage("Incorrectly creating a loop with connector - deleting");
                shape.Delete();
            }
            else
            {
                // if non-arrow side is connected, we should mark the goto transition as changed (datestamp)
                List <Shadow> sources = GetSourceTargets();

                foreach (Shadow s in sources)
                {
                    s.OnConnectorChangeTarget(this);
                }
            }
        }
Пример #18
0
        internal Shadow GetFirstStateTarget()
        {
            List <Connect> connects = GetShapeOutputs();

            if (connects.Count == 0)
            {
                Common.ErrorMessage("SubDialog shape " + GetGotoName() + " does not have a first state connector");
                return(null);
            }
            else if (connects.Count > 1)
            {
                Common.ErrorMessage("SubDialog shape " + GetGotoName() + " has more than one output connector");
                return(null);
            }

            Shape theOne = connects[0].FromSheet;

            return(Common.GetGotoTargetFromData(theOne.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID)));
        }
Пример #19
0
        public override void FixUIDReferencesAfterPaste(Dictionary <string, string> oldGUIDToNewGUIDMap)
        {
            Table table = GetCommandTransitions();

            for (int row = table.GetNumRows() - 1; row >= 0; row--)
            {
                string oldUID = table.GetData(row, (int)TableColumns.CommandTransitions.Goto);
                string newUID = CommonShadow.GetNewUIDAfterPaste(oldUID, oldGUIDToNewGUIDMap, false);
                if (newUID == null)
                {
                    Common.ErrorMessage("Transition in Start refers to state which can't be found, changing to hang up");
                    table.SetData(row, (int)TableColumns.CommandTransitions.Goto, Strings.HangUpKeyword);
                }
                else if (oldUID != newUID)
                {
                    table.SetData(row, (int)TableColumns.CommandTransitions.Goto, newUID);
                }
            }
            SetCommandTransitions(table);

            table = GetMaxHandling();
            for (int row = table.GetNumRows() - 1; row >= 0; row--)
            {
                string oldUID = table.GetData(row, (int)TableColumns.MaxHandling.Goto);
                if (oldUID == null || oldUID.Length == 0)
                {
                    continue;
                }
                string newUID = CommonShadow.GetNewUIDAfterPaste(oldUID, oldGUIDToNewGUIDMap, true);
                if (newUID == null)
                {
                    Common.ErrorMessage("MaxHandler for Start refers to state which can't be found, changing to hang up");
                    table.SetData(row, (int)TableColumns.MaxHandling.Goto, Strings.HangUpKeyword);
                }
                else if (oldUID != newUID)
                {
                    table.SetData(row, (int)TableColumns.MaxHandling.Goto, newUID);
                }
            }
            SetMaxHandling(table);
        }
Пример #20
0
        override public void OnBeforeShapeDelete()
        {
            // clean up our connections to other states - ConnectDelete is not called when the shape is deleted

            Connect c = GetConnect(false);

            if (c == null)
            {
                return;
            }

            // determine which end of the connector is connected to the nonConnectorShadow
            // In this case, it's always the c.FromCell that tells us
            bool arrowSide = false;

            if (c.FromCell.Name.Equals(Strings.EndConnectionPointCellName))
            {
                arrowSide = true;
            }

            Shadow connectedToShadow = PathMaker.LookupShadowByShape(c.ToSheet);

            if (connectedToShadow != null)
            {
                if (arrowSide)
                {
                    connectedToShadow.OnConnectDeleteInput(this);
                }
                else
                {
                    connectedToShadow.OnConnectDeleteOutput(this);
                }
            }
            else
            {
                Common.ErrorMessage("Connector goes to unknown shape " + c.ToSheet.Name);
            }
        }
Пример #21
0
        private void OnSrcDocumentChange()
        {
            int  pathMakerVersion = Common.GetDocumentSchemaVersion(visioControl.Document);
            bool repaired         = false;

            StatePrefixAndNumberManager.Initialize();

            if (pathMakerVersion < Common.GetResourceInt(Strings.PathMakerSchemaVersionRes))
            {
                if (!Repair.UpgradeDocumentToCurrentSchemaVersion(visioControl.Document))
                {
                    visioControl.Src = System.Windows.Forms.Application.StartupPath + @"\\" + Strings.VisioTemplateFile;
                }
                else
                {
                    repaired = true;
                }
            }

            if (pathMakerVersion > Common.GetResourceInt(Strings.PathMakerSchemaVersionRes))
            {
                Common.ErrorMessage("This file was created using a newer schema than this version of\n"
                                    + "PathMaker supports.  Upgrade to a newer version to edit this file.");
                visioControl.Src = System.Windows.Forms.Application.StartupPath + @"\\" + Strings.VisioTemplateFile;
                repaired         = false;
            }

            try {
                // For some reason our template will cause an exception if you add a new
                // page to it before you have put a shape on it.  My guess is something to
                // do with it being a vst but it only happens in the activeX control, not
                // standard visio.  Either way, this little trick of putting a connector on and
                // deleting it seems to solve the problem.  One other note, the shape you drop
                // matters.  A comment shape didn't work...
                Page     page    = visioControl.Document.Application.ActivePage;
                Document stencil = visioControl.Document.Application.Documents[Strings.StencilFileName];
                if (page != null)
                {
                    Shape shape = page.Drop(stencil.Masters["Dynamic connector"], 1, 1);
                    shape.Delete();
                }
            }
            catch {
                // fails if the window isn't up yet - can be ignored
            }

            // when starting from the template, the doc title and change log cut copy paste temp
            // data isn't set - so let's set it here
            foreach (Page page in visioControl.Document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                {
                    string uid = shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID);
                    Common.SetCellString(shape, Strings.CutCopyPasteTempCellName, uid);
                }
            }

            // if we didn't do a repair, make it so the hack above doesn't mean we have to save
            if (!repaired)
            {
                visioControl.Document.Saved = true;
            }

            // set up our gotoPageComboBox on the toolbar
            gotoPageComboBox.Items.Clear();
            gotoPageComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            foreach (Page p in visioControl.Document.Pages)
            {
                gotoPageComboBox.Items.Add(p.Name);
            }
            if (visioControl.Document.Application.ActivePage != null)
            {
                string pageName = visioControl.Document.Application.ActivePage.Name;
                int    index    = visioControl.Document.Pages[pageName].Index;
                gotoPageComboBox.SelectedIndex = index - 1;
            }

            StencilCleanup();

            // set titlebar
            string filename = System.IO.Path.GetFileName(visioControl.Src);

            if (filename.Contains(Strings.VisioTemplateFileSuffix))
            {
                Text = Common.StripExtensionFileName(Strings.DefaultFileName) + Strings.TitleBarSuffix;
            }
            else
            {
                Text = Common.StripExtensionFileName(filename) + Strings.TitleBarSuffix;
            }

            // we rebuild this every time we get a new document
            BuildShadowShapeMap();
            // and add the event handlers which are associated with the document (as opposed to the application)
            SetupDocumentEventHandlersAndRemoveAccelerators();


            //JDK added this to update older formats for date stamps to version stamps
            Common.RedoAllHiddenPromptMarkers();
        }
Пример #22
0
        internal static void ImportPromptList(string initialDirectory)
        {
            string fileName;

            // 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.OpenPromptsTitleRes);
                openFileDialog.Filter      = Common.GetResourceString(Strings.OpenPromptsFilterRes);
                openFileDialog.FilterIndex = 1;
            }

            openFileDialog.InitialDirectory = initialDirectory;

            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.
                fileName = openFileDialog.FileName;

                Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();

                if (excelApp == null)
                {
                    Common.ErrorMessage("Couldn't start Excel - make sure it's installed");
                    return;
                }
                excelApp.Visible = false;

                Workbook wb = excelApp.Workbooks.Open(fileName, ReadOnly: true);
                if (wb.Worksheets.Count > 0)
                {
                    Worksheet ws = (Worksheet)wb.Worksheets[1];

                    string promptId, dupIds, wording, notes;

                    PromptRecordingList recordingList = new PromptRecordingList();

                    int row = 7;
                    do
                    {
                        promptId = ws.Cells[row, 2].Text;
                        dupIds   = ws.Cells[row, 3].Text;
                        wording  = ws.Cells[row, 4].Text;
                        notes    = ws.Cells[row, 5].Text;

                        if (notes.Length > 0)
                        {
                            wording = wording + " " + Strings.LabelStartBracket + notes + Strings.LabelEndBracket;
                        }

                        if (promptId != null && promptId.Length > 0 && wording != null)
                        {
                            recordingList.AddPromptRecording(promptId, wording);

                            if (dupIds != null && dupIds.Length > 0)
                            {
                                string[] otherIds = dupIds.Split(DuplicateIdDelimiter);

                                foreach (string dupId in otherIds)
                                {
                                    recordingList.AddPromptRecording(dupId, wording);
                                }
                            }
                        }
                        row++;
                    } while (promptId != null && promptId.Length > 0);

                    Common.ApplyPromptRecordingList(recordingList);
                }

                wb.Close();
                excelApp.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
                excelApp = null;
            }
        }
Пример #23
0
        internal static void ExportDesignNotes(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl)
        {
            string targetFilename;
            string currentFileName;

            if (saveFileDialog == null)
            {
                saveFileDialog             = new SaveFileDialog();
                saveFileDialog.Title       = Common.GetResourceString(Strings.SavePromptsTitleRes);
                saveFileDialog.Filter      = Common.GetResourceString(Strings.SavePromptsFilterRes);
                saveFileDialog.FilterIndex = 1;

                // Excel will ask about overwriting and I can't find a way to bypass that - so
                // skip it here and let excel do it on wb.close
                saveFileDialog.OverwritePrompt = false;
            }

            saveFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(visioControl);

            targetFilename          = visioControl.Src;
            currentFileName         = System.IO.Path.GetFileName(targetFilename);
            saveFileDialog.FileName = Common.StripExtensionFileName(currentFileName) + "_DesignNotes.xlsx";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                targetFilename = saveFileDialog.FileName;
            }
            else
            {
                return;
            }

            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();

            if (excelApp == null)
            {
                Common.ErrorMessage("Couldn't start Excel - make sure it's installed");
                return;
            }
            excelApp.Visible = false;

            Workbook  wb = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
            Worksheet ws = (Worksheet)wb.Worksheets[1];

            if (ws == null)
            {
                Common.ErrorMessage("Excel worksheet couldn't be created.");
                return;
            }

            DocTitleShadow shadow  = PathMaker.LookupDocTitleShadow();
            string         client  = "";
            string         project = "";

            if (shadow != null)
            {
                client  = shadow.GetClientName();
                project = shadow.GetProjectName();
            }

            ws.Cells[1, 1].Value = "Client: " + client;
            ws.Cells[2, 1].Value = "Project: " + project;
            ws.Cells[3, 1].Value = "Date: " + DateTime.Now.ToString(Strings.DateColumnFormatString);

            ws.Cells[1, 1].Font.Bold = true;
            ws.Cells[2, 1].Font.Bold = true;
            ws.Cells[3, 1].Font.Bold = true;

            ws.Columns["A:A"].ColumnWidth = 6;
            ws.Columns["B:B"].ColumnWidth = 40;
            ws.Columns["C:C"].ColumnWidth = 100;
            ws.Columns["D:D"].ColumnWidth = 16;

            ((Range)ws.Columns["C:C"]).EntireColumn.WrapText = true;

            ws.Cells[5, 1].Value = "Count";
            ws.Cells[5, 2].Value = "State Name";
            ws.Cells[5, 3].Value = "Design Notes";
            ws.Cells[5, 4].Value = "Last Updated";

            ws.Cells[5, 1].Font.Bold = true;
            ws.Cells[5, 2].Font.Bold = true;
            ws.Cells[5, 3].Font.Bold = true;
            ws.Cells[5, 4].Font.Bold = true;

            ws.Cells[5, 4].HorizontalAlignment    = XlHAlign.xlHAlignLeft;
            ws.Columns["D:D"].HorizontalAlignment = XlHAlign.xlHAlignLeft;

            DesignNotesList designNotesList = Common.GetDesignNotesList();

            char[] delimiterChars = { '@' };
            //raw text looks like this... "design notes have been updated again@@02/18/2014"
            //splitting inot two parts for XLS writing

            int row   = 6;
            int count = 1;

            if (designNotesList.GetDesignNotes().Count >= 1)
            {
                foreach (DesignNotesList.DesignNoteContent designNote in designNotesList.GetDesignNotes())
                {
                    ws.Cells[row, 1] = count;
                    ws.Cells[row, 2] = designNote.StateId;

                    //string wording = Common.StripBracketLabels(designNote.Wording);
                    string[] notes = Common.StripBracketLabels(designNote.Wording).Split(delimiterChars);

                    if (notes[0].Length > 0)
                    {
                        ws.Cells[row, 3] = notes[0];
                        string lastUpdated = notes[2];
                        ws.Cells[row, 4] = lastUpdated;
                        ws.Rows[row].VerticalAlignment       = XlVAlign.xlVAlignCenter;
                        ws.Cells[row, 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    }
                    row++;
                    count++;
                }

                try
                {
                    wb.SaveAs(targetFilename);
                }
                catch
                {
                    Common.ErrorMessage("Excel worksheet couldn't be created.");
                }
            }
            else
            {
                Common.ErrorMessage("Excel worksheet generation skipped - no Design Notes found in VUI file.");
            }
            excelApp.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
            excelApp = null;
        }
Пример #24
0
        void OnShapeAdd(Shape shape)
        {
            ShapeTypes type = Common.GetShapeType(shape);
            bool       is1D = shape.OneD != 0;

            // Tricky - when pasting, Visio gives out new uids to the shapes if there are duplicates
            // in this document.  So, we are going to stash the original ones - unless we are pasting.
            // If we are pasting, the paste end will fix the ones that were added.
            if (!visioControl.Document.Application.get_IsInScope((int)VisUICmds.visCmdUFEditPaste) &&
                !visioControl.Document.Application.get_IsInScope((int)VisUICmds.visCmdUFEditDuplicate))
            {
                string uid    = shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID);
                string cached = Common.GetCellString(shape, Strings.CutCopyPasteTempCellName);

                // when undoing a delete page, you can't write this yet so this check will ignore it
                if (!uid.Equals(cached))
                {
                    Common.SetCellString(shape, Strings.CutCopyPasteTempCellName, uid);
                }
            }
            else if (Common.GetShapeType(shape) == ShapeTypes.OffPageRef)
            {
                Common.ErrorMessage("Pasted off-page reference needs to be connected.  Double click on it to repair.");
                // Because these can be cut and pasted from a single document, clearing these fields
                // allows us to avoid having more than one off page connector pointing to a single other one
                // which causes issues with tracking things in the shadows.  This way here, double clicking
                // on the connector will ask which page to connect it to.
                Common.SetCellString(shape, ShapeProperties.OffPageConnectorDestinationPageID, "");
                Common.SetCellString(shape, ShapeProperties.OffPageConnectorDestinationShapeID, "");
            }

            if (type == ShapeTypes.None && is1D)
            {
                // rogue connector - need to make it conform
                Common.SetCellString(shape, ShapeProperties.ShapeType, ((int)ShapeTypes.Connector).ToString());
                shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
                                   (short)VisRowIndices.visRowLine,
                                   (short)VisCellIndices.visLineEndArrow).FormulaU = "13";
                shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
                                   (short)VisRowIndices.visRowLine,
                                   (short)VisCellIndices.visLineRounding).FormulaU = "0.25 in";
                shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
                                   (short)VisRowIndices.visRowLock,
                                   (short)VisCellIndices.visLockTextEdit).FormulaU = "1";

                // just in case
                Common.FixConnectorTextControl(shape);

                // make every row in the shape data section invisible
                short row = (short)VisRowIndices.visRowFirst;
                while (shape.get_CellsSRCExists((short)VisSectionIndices.visSectionProp, row, (short)VisCellIndices.visCustPropsInvis, (short)VisExistsFlags.visExistsAnywhere) != 0)
                {
                    shape.get_CellsSRC((short)VisSectionIndices.visSectionProp, row++, (short)VisCellIndices.visCustPropsInvis).FormulaU = "TRUE";
                }
            }

            // when a shape is copied and pasted, it will be an exact copy of the previous shape
            // we need fix the duplicate name issue before we do anything else
            string oldPastedStateName = String.Empty;

            if (visioControl.Document.Application.get_IsInScope((int)VisUICmds.visCmdUFEditPaste) ||
                visioControl.Document.Application.get_IsInScope((int)VisUICmds.visCmdUFEditDuplicate))
            {
                string stateId = Common.GetCellString(shape, ShapeProperties.StateId);
                if (stateId.Length > 0)
                {
                    if (!StatePrefixAndNumberManager.IsStateIdOkayForUse(stateId))
                    {
                        oldPastedStateName = stateId;
                        // NEVER, NEVER do this without going through the shadow except here, before the shadow is made
                        Common.SetCellString(shape, ShapeProperties.StateId, String.Empty);
                    }
                }
            }

            Shadow shadow = Common.MakeShapeShadow(shape);

            if (shadow != null)
            {
                // if we have a pasted name that conflicted, this will reuse the name portion
                // but get us a new prefix and number and then renumber any prompts
                if (oldPastedStateName.Length > 0)
                {
                    string prefix, number, name;
                    StateShadow.DisectStateIdIntoParts(oldPastedStateName, out prefix, out number, out name);
                    shape.Text = StateShadow.StateIdForDisplay(name).Trim();
                    // this just pretends we just typed the name portion into the shape itself
                    shadow.OnShapeExitTextEdit();

                    // and now let's renumber any prompts if we're not using the "number" option
                    List <Shadow> shadowList = LookupShadowsByShapeType(ShapeTypes.Start);
                    if (shadowList.Count > 0)
                    {
                        StartShadow startShadow    = shadowList[0] as StartShadow;
                        string      promptIdFormat = startShadow.GetDefaultSetting(Strings.DefaultSettingsPromptIDFormat);
                        if (promptIdFormat.Equals(Strings.PromptIdFormatFull) || promptIdFormat.Equals(Strings.PromptIdFormatPartial))
                        {
                            StateShadow stateShadow = shadow as StateShadow;
                            if (stateShadow != null)
                            {
                                stateShadow.RedoPromptIds(0, promptIdFormat);
                            }
                        }
                    }
                }
                shadowShapeMap.Add(shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID), shadow);
                shadow.OnShapeAdd();

                if (shadow.GetShapeType() == ShapeTypes.DocTitle ||
                    shadow.GetShapeType() == ShapeTypes.ChangeLog ||
                    shadow.GetShapeType() == ShapeTypes.AppDesc ||
                    shadow.GetShapeType() == ShapeTypes.PrefixList ||
                    shadow.GetShapeType() == ShapeTypes.Start)
                {
                    if (LookupShadowsByShapeType(shadow.GetShapeType()).Count > 1)
                    {
                        Common.ErrorMessage("Cannot have two Start, Change Log, or Document Title, App Description or Prefix List shapes");
                        Common.ForcedSetShapeText(shape, Strings.ToBeDeletedLabel);
                    }
                }
            }
            else
            {
                Common.ErrorMessage("Invalid non-PathMaker shape added");
                try {
                    Common.ForcedSetShapeText(shape, Strings.ToBeDeletedLabel);
                }
                catch {
                    // it may be a shape with two subshapes (play/interaction) so try this too
                    try {
                        Common.ForcedSetShapeText(shape.Shapes[0], Strings.ToBeDeletedLabel);
                    }
                    catch {
                        // copying from non-PathMaker visios can cause this to fail depending on shape sheets, locks, etc.
                        // We did our best - we can ignore these
                    }
                }
            }
        }
Пример #25
0
 public override void OnConnectAddInput(Shadow shadow)
 {
     Common.ErrorMessage("Incorrectly adding input to an Incoming On Page Reference");
     // get busy cursor without this
     shadow.SelectShape();
 }
Пример #26
0
        void OnConnectAdd(Connects connects)
        {
            if (SuspendConnectHandlingToMoveAConnectionPoint)
            {
                return;
            }

            foreach (Connect c in connects)
            {
                // each connection should be between a 1D shape (connector or comment) and a 2D shape (everything else)
                // The 1D connector is always the To and 2D shapes are always the From
                Shape connector    = null;
                Shape nonConnector = null;
                if (c.FromSheet.OneD != 0)
                {
                    connector = c.FromSheet;
                }
                else
                {
                    nonConnector = c.FromSheet;
                }

                if (connector == null && c.ToSheet.OneD != 0)
                {
                    connector = c.ToSheet;
                }
                else if (nonConnector == null && c.ToSheet.OneD == 0)
                {
                    nonConnector = c.ToSheet;
                }

                // not sure what it is but we don't care about it
                if (connector == null || nonConnector == null)
                {
                    return;
                }

                Shadow connectorShadow    = LookupShadowByShape(connector);
                Shadow nonConnectorShadow = LookupShadowByShape(nonConnector);

                if (connectorShadow == null || nonConnectorShadow == null)
                {
                    Common.ErrorMessage("Adding connector to bogus shapes...");
                    return;
                }

                // an ignored shadow (like a comment) can sometimes have links
                // but shouldn't be added as a transition - it's irrelevant
                IgnoredShadow ignored = connectorShadow as IgnoredShadow;
                if (ignored != null)
                {
                    return;
                }

                // determine which end of the connector is connected to the nonConnectorShadow
                bool arrowSide = false;
                if (c.FromCell.Name.Equals(Strings.EndConnectionPointCellName))
                {
                    arrowSide = true;
                }

                if (arrowSide)
                {
                    connectorShadow.OnConnectAddOutput(nonConnectorShadow);
                    nonConnectorShadow.OnConnectAddInput(connectorShadow);
                }
                else
                {
                    connectorShadow.OnConnectAddInput(nonConnectorShadow);
                    nonConnectorShadow.OnConnectAddOutput(connectorShadow);
                }
            }
        }
Пример #27
0
        internal static string ExportFastPathXML(AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl, bool useTmpFile)
        {
            DocTitleShadow docTitleShadow = PathMaker.LookupDocTitleShadow();

            if (docTitleShadow == null)
            {
                Common.ErrorMessage("Missing Document Title shape");
                return(null);
            }
            StartShadow startShadow = PathMaker.LookupStartShadow();

            if (startShadow == null)
            {
                Common.ErrorMessage("Missing Start shape");
                return(null);
            }

            changeLogShadow = PathMaker.LookupChangeLogShadow();
            if (changeLogShadow == null)
            {
                Common.ErrorMessage("Missing Change Log shape");
                return(null);
            }

            if (saveFileDialog == null)
            {
                saveFileDialog             = new SaveFileDialog();
                saveFileDialog.Title       = Common.GetResourceString(Strings.SaveFastPathXMLTitleRes);
                saveFileDialog.Filter      = Common.GetResourceString(Strings.SaveFastPathXMLFilterRes);
                saveFileDialog.FilterIndex = 1;
            }

            saveFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(visioControl);
            saveFileDialog.RestoreDirectory = true;

            targetFilename          = visioControl.Src;
            currentFileName         = System.IO.Path.GetFileName(targetFilename);
            saveFileDialog.FileName = Common.StripExtensionFileName(currentFileName) + ".xml";

            if (!useTmpFile)
            {
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    targetFilename = saveFileDialog.FileName;
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                targetFilename = saveFileDialog.FileName + ".tmp";
            }

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.XmlResolver = null;
            xmlDoc.LoadXml(xmlStrings.Header);
            xmlDoc.DocumentElement.SetAttribute(xmlStrings.Project, docTitleShadow.GetProjectName());
            xmlDoc.DocumentElement.SetAttribute(xmlStrings.Client, docTitleShadow.GetClientName());
            xmlDoc.DocumentElement.SetAttribute(xmlStrings.LastModified, changeLogShadow.GetLastLogChangeDate());
            xmlDoc.DocumentElement.SetAttribute(xmlStrings.Version, changeLogShadow.GetLastChangeVersion());

            AddStartElement(xmlDoc, startShadow);

            List <Shadow> shadowList = PathMaker.LookupAllShadows();
            // sorting them here helps the Missed statements in PathRunner come out in order
            string stateSortOrder = startShadow.GetDefaultSetting(Strings.DefaultSettingsStateSortOrder);

            if (stateSortOrder.Equals(Strings.StateSortOrderAlphaNumerical))
            {
                shadowList.Sort(Common.StateIdShadowSorterAlphaNumerical);
            }
            else if (stateSortOrder.Equals(Strings.StateSortOrderNumericalOnly))
            {
                shadowList.Sort(Common.StateIdShadowSorterNumericalAlpha);
            }
            else
            {
                Common.StateIdShadowSorterVisioHeuristic(shadowList, visioControl.Document, startShadow);
            }

            foreach (Shadow shadow in shadowList)
            {
                switch (shadow.GetShapeType())
                {
                case ShapeTypes.Interaction:
                    AddInteractionElement(xmlDoc, shadow as InteractionShadow);
                    break;

                case ShapeTypes.Play:
                    AddPlayElement(xmlDoc, shadow as PlayShadow);
                    break;

                case ShapeTypes.Decision:
                    AddDecisionElement(xmlDoc, shadow as DecisionShadow);
                    break;

                case ShapeTypes.Data:
                    AddDataElement(xmlDoc, shadow as DataShadow);
                    break;

                case ShapeTypes.SubDialog:
                    AddSubDialogElement(xmlDoc, shadow as SubDialogShadow);
                    break;

                default:
                    break;
                }
            }

            xmlDoc.Save(targetFilename);
            return(targetFilename);
        }
Пример #28
0
 public override void OnConnectAddOutput(Shadow shadow)
 {
     Common.ErrorMessage("Incorrectly adding output to a Hang up");
     // get busy cursor without this
     shadow.SelectShape();
 }
Пример #29
0
        internal static void ExportPromptList(DateTime?onOrAfterDate, bool hyperLinks, AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl visioControl)
        {
            string targetFilename;
            string currentFileName;

            if (saveFileDialog == null)
            {
                saveFileDialog             = new SaveFileDialog();
                saveFileDialog.Title       = Common.GetResourceString(Strings.SavePromptsTitleRes);
                saveFileDialog.Filter      = Common.GetResourceString(Strings.SavePromptsFilterRes);
                saveFileDialog.FilterIndex = 1;

                // Excel will ask about overwriting and I can't find a way to bypass that - so
                // skip it here and let excel do it on wb.close
                saveFileDialog.OverwritePrompt = false;
            }

            saveFileDialog.InitialDirectory = PathMaker.getCurrentFileDirectory(visioControl);

            targetFilename          = visioControl.Src;
            currentFileName         = System.IO.Path.GetFileName(targetFilename);
            saveFileDialog.FileName = Common.StripExtensionFileName(currentFileName) + "_Prompts.xlsx";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                targetFilename = saveFileDialog.FileName;
            }
            else
            {
                return;
            }

            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();

            if (excelApp == null)
            {
                Common.ErrorMessage("Couldn't start Excel - make sure it's installed");
                return;
            }
            excelApp.Visible = false;

            Workbook  wb = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
            Worksheet ws = (Worksheet)wb.Worksheets[1];

            if (ws == null)
            {
                Common.ErrorMessage("Excel worksheet couldn't be created.");
                return;
            }

            DocTitleShadow shadow  = PathMaker.LookupDocTitleShadow();
            string         client  = "";
            string         project = "";

            if (shadow != null)
            {
                client  = shadow.GetClientName();
                project = shadow.GetProjectName();
            }

            ws.Cells[1, 1].Value          = "Client: " + client;
            ws.Cells[2, 1].Value          = "Project: " + project;
            ws.Cells[3, 1].Value          = "Date: " + DateTime.Now.ToString(Strings.DateColumnFormatString);
            ws.Columns["A:A"].ColumnWidth = 8;
            ws.Columns["B:C"].ColumnWidth = 30;
            ws.Columns["D:E"].ColumnWidth = 50;

            ((Range)ws.Columns["C:E"]).EntireColumn.WrapText = true;

            ws.Cells[5, 1].Value = "Count";
            ws.Cells[5, 2].Value = "Prompt ID";
            ws.Cells[5, 3].Value = "Duplicate IDs";
            ws.Cells[5, 4].Value = "Prompt Wording";
            ws.Cells[5, 5].Value = "Notes";

            ws.Cells[5, 1].Font.Bold = true;
            ws.Cells[5, 2].Font.Bold = true;
            ws.Cells[5, 3].Font.Bold = true;
            ws.Cells[5, 4].Font.Bold = true;
            ws.Cells[5, 5].Font.Bold = true;

            PromptRecordingList recordingList = Common.GetPromptRecordingList(onOrAfterDate);

            List <string> duplicateIdList = recordingList.GetDuplicatePromptIds();

            if (duplicateIdList.Count > 0)
            {
                string list        = String.Empty;
                int    lineCounter = 1;
                foreach (string s in duplicateIdList)
                {
                    list += s;
                    list += ", ";
                    if (list.Length > (lineCounter * 60))
                    {
                        list += "\n";
                        lineCounter++;
                    }
                }
                list = list.Substring(0, list.Length - 2);

                Common.ErrorMessage("Warning: multiple copies of prompt ids in the design.\n" +
                                    "Management and testing of each is NOT handled by the tools.\n" +
                                    "You are responsible for reviewing and testing that each is correct.\n" +
                                    "Recommended that you fix the prompt numbers and let the tools handle it.\n" +
                                    "\n" +
                                    "Duplicates:\n" +
                                    list);
            }

            int row   = 7;
            int count = 1;

            foreach (PromptRecordingList.PromptRecording recording in recordingList.GetPromptRecordings())
            {
                ws.Cells[row, 1] = count;
                ws.Cells[row, 2] = recording.PromptId;
                ws.Cells[row, 3] = MakeDuplicateString(recording.GetDuplicateIds());
                string wording = Common.StripBracketLabels(recording.Wording);
                ws.Cells[row, 4] = wording;

                // if the whole wording is the label, there are no []s
                string label = Common.MakeLabelName(recording.Wording);
                if (label.Length != wording.Length)
                {
                    ws.Cells[row, 5] = Common.MakeLabelName(recording.Wording);
                }

                if (hyperLinks)
                {
                    string recordingFile = Common.GetResourceString(Strings.PromptRecordingLocationRes);
                    recordingFile += "\\" + recording.PromptId + ".wav";
                    ws.Hyperlinks.Add(ws.Cells[row, 2], recordingFile);
                }

                row++;
                count++;
            }

            try {
                wb.SaveAs(targetFilename);
            }
            catch {
            }
            excelApp.Quit();;
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
            excelApp = null;
        }