Esempio n. 1
0
        private void ProcessCommand_Page_Add(Visio.Document document, XElement pageElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            try
            {
                string newPageName = pageElement.Attribute("Name") != null?pageElement.Attribute("Name").Value : "";

                string backgroundPageName = pageElement.Attribute("BackgroundPageName") != null?pageElement.Attribute("BackgroundPageName").Value : "";

                string isBackground = pageElement.Attribute("IsBackground") != null?pageElement.Attribute("IsBackground").Value : "0";

                // TODO(crhodes):
                // Need to pass in doc so this can work for any document

                Visio.Application app = Globals.ThisAddIn.Application;

                Visio.Document doc = app.ActiveDocument;

                Visio.Page newPage = Actions.Visio_Page.CreatePage(newPageName, backgroundPageName, short.Parse(isBackground));
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }
Esempio n. 2
0
        internal static async void GetWorkItemInfo(Visio.Shape shape, WorkItemShapeInfo.WorkItemShapeVersion version)
        {
            WorkItemShapeInfo shapeInfo = new WorkItemShapeInfo(shape);

            int id = 0;

            if (!int.TryParse(shapeInfo.ID, out id))
            {
                MessageBox.Show($"Invalid WorkItem ID: ({shapeInfo.ID})");
                return;
            }

            var result = await VNC.AZDO.Helper.QueryWorkItemInfoById(shapeInfo.Organization, id);

            if (result.Count == 0)
            {
                MessageBox.Show($"Cannot find WorkItem ID: ({shapeInfo.ID})");
                return;
            }

            shapeInfo.InitializeFromWorkItem(result[0]);

            // NOTE(crhodes)
            // Go add the bugs

            int bugs = await VNC.AZDO.Helper.QueryRelatedBugsById(shapeInfo.Organization, int.Parse(shapeInfo.ID));

            shapeInfo.RelatedBugs = bugs.ToString();

            shapeInfo.PopulateShapeDataFromInfo(shape, version);

            VisioHelper.DisplayInWatchWindow($"{shapeInfo}");
        }
Esempio n. 3
0
        private void ProcessCommand_Page_Delete(Visio.Document doc, XElement pageElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            try
            {
                string pageName = pageElement.Attribute("Name") != null?pageElement.Attribute("Name").Value : "";

                if (pageName != "")
                {
                    Visio.Page deletePage = doc.Pages[pageName];

                    if (deletePage != null)
                    {
                        deletePage.Delete(0);
                    }
                    else
                    {
                        VisioHlp.DisplayInWatchWindow(string.Format("Page ({0}) not found", pageName));
                    }
                }
                else
                {
                    VisioHlp.DisplayInWatchWindow("Missing \"Name\" attribute");
                }
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }
Esempio n. 4
0
        private void ProcessCommand_Document(XElement documentElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            Visio.Application app = Globals.ThisAddIn.Application;

            // TODO(crhodes):
            // Add some error handling here.

            Visio.Document doc = app.Documents[documentElement.Attribute("Name").Value];

            if (documentElement.Elements("Layers").Any())
            {
                foreach (Visio.Page page in doc.Pages)
                {
                    ProcessCommand_Layers(page, documentElement.Element("Layers").Elements());
                }
            }

            if (documentElement.Elements("ShapeSheet").Any())
            {
                ProcessCommand_ShapeSheet(doc, documentElement.Element("ShapeSheet"));
            }
        }
Esempio n. 5
0
        private void ProcessCommand_Layer_Add(Visio.Page page, XElement addElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            try
            {
                string layerName = addElement.Attribute("Name").Value;

                string layerVisible = addElement.Attribute("IsVisible") != null?addElement.Attribute("IsVisible").Value : "1";

                string layerPrint = addElement.Attribute("IsPrint") != null?addElement.Attribute("IsPrint").Value : "1";

                string layerActive = addElement.Attribute("IsActive") != null?addElement.Attribute("IsActive").Value : "0";

                string layerLock = addElement.Attribute("IsLock") != null?addElement.Attribute("IsLock").Value : "0";

                string layerSnap = addElement.Attribute("IsSnap") != null?addElement.Attribute("IsSnap").Value : "1";

                string layerGlue = addElement.Attribute("IsGlue") != null?addElement.Attribute("IsGlue").Value : "1";

                Actions.Visio_Page.AddLayer(page, layerName, layerVisible, layerPrint, layerActive, layerLock, layerSnap, layerGlue);
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }
Esempio n. 6
0
        private void ProcessCommand_ShapeSheet_AddUserRow(Visio.Shape shape, XElement addUserRowElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            try
            {
                string row   = addUserRowElement.Attribute("Row").Value;
                string value = null;

                if (addUserRowElement.Attribute("Value") != null)
                {
                    value = addUserRowElement.Attribute("Value").Value;
                }
                else if (addUserRowElement.Attribute("ValueQuoted") != null)
                {
                    value = string.Format("\"{0}\"", addUserRowElement.Attribute("ValueQuoted").Value);
                }

                XAttribute promptAttribute = addUserRowElement.Attribute("Prompt");

                if (promptAttribute != null)
                {
                    Actions.Visio_Shape.Add_User_Row(shape, row, value, promptAttribute.Value);
                }
                else
                {
                    Actions.Visio_Shape.Add_User_Row(shape, row, value);
                }
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }
Esempio n. 7
0
        private void ProcessCommand_Page(Visio.Document doc, XElement pageElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            try
            {
                string pageName = pageElement.Attribute("Name") != null?pageElement.Attribute("Name").Value : "";

                string backgroundPageName = pageElement.Attribute("BackgroundPageName") != null?pageElement.Attribute("BackgroundPageName").Value : "";

                string isBackground = pageElement.Attribute("IsBackground") != null?pageElement.Attribute("IsBackground").Value : "0";

                if ("" != backgroundPageName)
                {
                    doc.Pages[pageName].BackPage = backgroundPageName;
                }

                doc.Pages[pageName].Background = short.Parse(isBackground);
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }
Esempio n. 8
0
        internal static async void GetWorkItemInfo2(Visio.Application app, string doc, string page, string shape, string shapeu, string[] vs)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           MethodBase.GetCurrentMethod().Name));

            Visio.Shape activeShape = app.ActivePage.Shapes[shape];

            GetWorkItemInfo(activeShape, WorkItemShapeInfo.WorkItemShapeVersion.V2);
        }
Esempio n. 9
0
        public static void DisplayLayer(string layerName, bool show)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}(layer:{1} show:{2})",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name, layerName, show.ToString()));

            foreach (Visio.Page page in Globals.ThisAddIn.Application.ActiveDocument.Pages)
            {
                Visio_Page.DisplayLayer(page, layerName, show);
            }
        }
Esempio n. 10
0
        public static void SortAllPages()
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name));

            Visio.Application app = Globals.ThisAddIn.Application;

            Visio.Document doc = app.ActiveDocument;

            System.Collections.SortedList sortedPages = new System.Collections.SortedList();
            //SortedList<string, string> sortedPages = new SortedList<string, string>();
            int  index      = 0;
            bool hasTOCPage = false;

            VisioHelper.DisplayInWatchWindow(string.Format("Document({0})", doc.Name));

            try
            {
                foreach (Visio.Page page in doc.Pages)
                {
                    VisioHelper.DisplayInWatchWindow(string.Format("Page({0} IsBackground{1})", page.NameU, page.Background));

                    if (!page.NameU.Equals("Table of Contents"))
                    {
                        if (page.Background == 0)
                        {
                            sortedPages.Add(page.NameU, page.NameU);
                            index++;
                        }
                    }
                    else
                    {
                        hasTOCPage = true;
                    }

                    //sortedPages.Add(index++, page.NameU);
                }

                // If we found a TOC page, start pages off at postion 2, else, postion 1

                int offset = hasTOCPage ? 2 : 1;

                for (int i = 0; i < index; i++)
                {
                    VisioHelper.DisplayInWatchWindow(string.Format("Moving Page({0})", sortedPages.GetByIndex(i)));
                    doc.Pages.ItemU[sortedPages.GetKey(i)].Index = (short)(i + offset);
                    //Application.ActiveDocument.Pages.ItemU("Page-2").Index = 3
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, Common.LOG_CATEGORY);
            }
        }
Esempio n. 11
0
        public static void DisplayInfo()
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodInfo.GetCurrentMethod().Name));

            Visio.Application app = Globals.ThisAddIn.Application;

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0} - {1}\n", "App.Name", app.Name);

            try
            {
                sb.AppendFormat("{0} - {1}\n", "App.ActiveDocument.Name", app.ActiveDocument.Name);
            }
            catch (Exception ex)
            {
                sb.AppendFormat("{0} - {1}\n", "App.ActiveDocument.Name", "<none>");
            }

            try
            {
                sb.AppendFormat("{0} - {1}\n", "App.ActivePage.Name", app.ActivePage.Name);
            }
            catch (Exception ex)
            {
                sb.AppendFormat("{0} - {1}\n", "App.ActivePage.Name", "<none>");
            }

            sb.AppendFormat("{0} - {1}\n", "App.AddonPaths", app.AddonPaths);
            sb.AppendFormat("{0} - {1}\n", "App.CommandLine", app.CommandLine);
            sb.AppendFormat("{0} - {1}\n", "App.Documents.Count", app.Documents.Count);
            sb.AppendFormat("{0} - {1}\n", "App.DrawingPaths", app.DrawingPaths);
            sb.AppendFormat("{0} - {1}\n", "App.HelpPaths", app.HelpPaths);
            sb.AppendFormat("{0} - {1}\n", "App.IsVisio32", app.IsVisio32);
            sb.AppendFormat("{0} - {1}\n", "App.MyShapesPath", app.MyShapesPath);
            sb.AppendFormat("{0} - {1}\n", "App.Path", app.Path);
            sb.AppendFormat("{0} - {1}\n", "App.ProcessID", app.ProcessID);
            sb.AppendFormat("{0} - {1}\n", "App.ShowChanges", app.ShowChanges);
            sb.AppendFormat("{0} - {1}\n", "App.ShowProgress", app.ShowProgress);
            sb.AppendFormat("{0} - {1}\n", "App.ShowStatusBar", app.ShowStatusBar);
            sb.AppendFormat("{0} - {1}\n", "App.ShowToolBar", app.ShowToolbar);
            sb.AppendFormat("{0} - {1}\n", "App.StartupPaths", app.StartupPaths);
            sb.AppendFormat("{0} - {1}\n", "App.StencilPaths", app.StencilPaths);
            sb.AppendFormat("{0} - {1}\n", "App.TemplatePaths", app.TemplatePaths);
            sb.AppendFormat("{0} - {1}\n", "App.TraceFlags", app.TraceFlags);
            sb.AppendFormat("{0} - {1}\n", "App.UndoEnables", app.UndoEnabled);
            sb.AppendFormat("{0} - {1}\n", "App.UserName", app.UserName);
            sb.AppendFormat("{0} - {1}\n", "App.Version", app.Version);

            //System.Windows.Forms.MessageBox.Show(sb.ToString());
            VisioHelper.DisplayInWatchWindow(sb.ToString());
        }
Esempio n. 12
0
        private void ProcessCommand_Documents(IEnumerable <XElement> documentsElement)
        {
            // <Documents>
            //    <Add />
            //    <ActiveDocument>
            //        <Layers>
            //            <DeleteAll /> - Not sure if can do this
            //            <Delete Name = "" />
            //            <Add Name = "Layer1" IsVisible = "true" IsPrint = "true" IsActive = "true" IsLock = "true" IsSnap = "true" IsGlue = "true" Color = "" />
            //         </Layers>
            //    </ActiveDocument>
            // </Documents>
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            Visio.Application app = Globals.ThisAddIn.Application;

            Visio.Document doc = app.ActiveDocument;

            foreach (XElement element in documentsElement)
            {
                VisioHlp.DisplayInWatchWindow(element.ToString());
                VisioHlp.DisplayInWatchWindow(element.Name.LocalName);

                switch (element.Name.LocalName)
                {
                case "Add":
                    ProcessCommand_Document_Add(element);
                    break;

                case "ActiveDocument":
                    ProcessCommand_ActiveDocument(element);
                    break;

                case "Document":
                    ProcessCommand_Document(element);
                    break;

                case "Layers":
                    foreach (Visio.Page page in doc.Pages)
                    {
                        ProcessCommand_Layers(page, element.Elements());
                    }

                    break;

                default:
                    VisioHlp.DisplayInWatchWindow(string.Format("Element >{0}< not supported", element.Name.LocalName));
                    break;
                }
            }
        }
Esempio n. 13
0
        public static void GetClassInfo(Visio.Application app, string doc, string page, string shape, string shapeu, String[] args)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           MethodBase.GetCurrentMethod().Name));

            Visio.Page  activePage  = app.ActivePage;
            Visio.Shape activeShape = app.ActivePage.Shapes[shape];

            ClassInfoShape classInfoShape = new ClassInfoShape(activeShape);

            VisioHelper.DisplayInWatchWindow(string.Format("{0}",
                                                           classInfoShape.ToString()));
        }
Esempio n. 14
0
        public static void RemoveLayers()
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name));

            Visio.Application app = Globals.ThisAddIn.Application;
            Visio.Document    doc = app.ActiveDocument;

            foreach (Visio.Page page in doc.Pages)
            {
                Visio_Page.DeleteLayers(page);
            }
        }
Esempio n. 15
0
        internal static void GetMethodInfo(Visio.Application app, string doc, string page, string shape, string shapeu, string[] v)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           MethodBase.GetCurrentMethod().Name));

            Visio.Page  activePage  = app.ActivePage;
            Visio.Shape activeShape = app.ActivePage.Shapes[shape];

            MethodInfoShape methodInfoShape = new MethodInfoShape(activeShape);

            VisioHelper.DisplayInWatchWindow(string.Format("{0}",
                                                           methodInfoShape.ToString()));
        }
Esempio n. 16
0
        private void UseLinqToExcel()
        {
            string path  = @"B:\Publish\SupportTools_Visio\TestData.xlsx";
            var    excel = new LTE.ExcelQueryFactory(path);

            var stuff = from c in excel.Worksheet <TestData>()
                        select c;

            foreach (var item in stuff)
            {
                VisioHlp.DisplayInWatchWindow(
                    string.Format("Col1:{0} Col2:{1} Col3:{2} Col4:{3} Col5:{4}", item.Col1, item.Col2, item.Col3, item.Col4, item.Col5)
                    );
            }
        }
Esempio n. 17
0
        public static List <Visio.Shape> GetNavigationLinks()
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name));

            List <Visio.Shape> navLinks = new List <Visio.Shape>();

            Visio.Page linkPage = Globals.ThisAddIn.Application.ActiveDocument.Pages["Navigation Links"];

            foreach (Visio.Shape shape in linkPage.Shapes)
            {
                navLinks.Add(shape);
            }

            return(navLinks);
        }
Esempio n. 18
0
        private void ProcessCommand_Layer_DeleteAll(Visio.Page page, XElement deleteAllElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            try
            {
                foreach (Visio.Layer layer in page.Layers)
                {
                    layer.Delete(0);
                }
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }
Esempio n. 19
0
        internal static void CreateMethodShapes(Visio.Application app, string doc, string page, string shape, string shapeu, string[] v)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           MethodBase.GetCurrentMethod().Name));

            Visio.Page  activePage  = app.ActivePage;
            Visio.Shape activeShape = app.ActivePage.Shapes[shape];

            try
            {
                FileInfoShape fileInfoShape = new FileInfoShape(activeShape);


                VisioHelper.DisplayInWatchWindow(string.Format("{0}",
                                                               fileInfoShape.ToString()));

                VisioHelper.DisplayInWatchWindow(string.Format("{0}",
                                                               fileInfoShape.DisplayInfo()));

                string fileNameAndPath = fileInfoShape.SourceFileFileName;

                var sourceCode = "";

                using (var sr = new StreamReader(fileNameAndPath))
                {
                    sourceCode = sr.ReadToEnd();
                }

                List <String> methodNames = VNC.CodeAnalysis.Helpers.VB.GetMethodNames(sourceCode);

                // OK.  Now we have a list of Method Names.  Let's add shapes for each of them.

                Visio.Master methodMaster = app.Documents[@"API.vssx"].Masters[@"Method"];

                foreach (string methodName in methodNames)
                {
                    Visio.Shape newMethod = activePage.Drop(methodMaster, 5.0, 5.0);
                    newMethod.CellsU["Prop.MethodName"].FormulaU = methodName.WrapInDblQuotes();
                }
            }
            catch (Exception ex)
            {
                VisioHelper.DisplayInWatchWindow(string.Format("{0}",
                                                               ex.ToString()));
            }
        }
Esempio n. 20
0
        private short GetVisPropType(string value)
        {
            short visPropType = 0;

            switch (value)
            {
            case "VisCellVals.visPropTypeBool":
                visPropType = (short)Visio.VisCellVals.visPropTypeBool;
                break;

            case "VisCellVals.visPropTypeCurrency":
                visPropType = (short)Visio.VisCellVals.visPropTypeCurrency;
                break;

            case "VisCellVals.visPropTypeDate":
                visPropType = (short)Visio.VisCellVals.visPropTypeDate;
                break;

            case "VisCellVals.visPropTypeDuration":
                visPropType = (short)Visio.VisCellVals.visPropTypeDuration;
                break;

            case "VisCellVals.visPropTypeListFix":
                visPropType = (short)Visio.VisCellVals.visPropTypeListFix;
                break;

            case "VisCellVals.visPropTypeListVar":
                visPropType = (short)Visio.VisCellVals.visPropTypeListVar;
                break;

            case "VisCellVals.visPropTypeNumber":
                visPropType = (short)Visio.VisCellVals.visPropTypeNumber;
                break;

            case "VisCellVals.visPropTypeString":
                visPropType = (short)Visio.VisCellVals.visPropTypeString;
                break;

            default:
                VisioHlp.DisplayInWatchWindow(string.Format("Unrecognized VisPropType >{0}<", value));

                break;
            }

            return(visPropType);
        }
Esempio n. 21
0
        private void ProcessCommand_ShapeSheet(Visio.Shape shape, XElement shapeSheetElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            foreach (XElement element in shapeSheetElement.Elements())
            {
                VisioHlp.DisplayInWatchWindow(element.ToString());
                VisioHlp.DisplayInWatchWindow(element.Name.LocalName);

                switch (element.Name.LocalName)
                {
                case "AddPropRow":
                    ProcessCommand_ShapeSheet_AddPropRow(shape, element);
                    break;

                case "AddUserRow":
                    ProcessCommand_ShapeSheet_AddUserRow(shape, element);
                    break;

                case "AddControlsRow":
                    ProcessCommand_ShapeSheet_AddControlsRow(shape, element);
                    break;

                case "SetFillFormat":
                    ProcessCommand_ShapeSheet_SetFillFormat(shape, element);
                    break;

                case "SetShapeTransform":
                    ProcessCommand_ShapeSheet_ShapeTransform(shape, element);
                    break;

                case "SetTextBlockFormat":
                    ProcessCommand_ShapeSheet_SetTextBlockFormat(shape, element);
                    break;

                case "SetTextTransform":
                    ProcessCommand_ShapeSheet_SetTextTransform(shape, element);
                    break;

                default:
                    VisioHlp.DisplayInWatchWindow(string.Format("Element >{0}< not supported", element.Name.LocalName));
                    break;
                }
            }
        }
Esempio n. 22
0
        private void ProcessCommand_Layer_Delete(Visio.Page page, XElement deleteElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            try
            {
                string layerName    = deleteElement.Attribute("Name").Value;
                string deleteShapes = deleteElement.Attribute("DeleteShapes").Value;

                Actions.Visio_Page.DeleteLayer(page, layerName, short.Parse(deleteShapes));
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }
Esempio n. 23
0
        public static void AutoSizePagesOn()
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name));

            int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("AutoSizePagesOn");

            Visio.Application app = Globals.ThisAddIn.Application;

            Visio.Document doc = app.ActiveDocument;

            foreach (Visio.Page page in doc.Pages)
            {
                Visio_Page.AutoSizePageOn(page);
            }

            Globals.ThisAddIn.Application.EndUndoScope(undoScope, true);
        }
Esempio n. 24
0
        private void ProcessCommand_Document_Add(XElement documentElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            try
            {
                Visio.Application app = Globals.ThisAddIn.Application;

                string documentName = documentElement.Attribute("Name").Value;

                app.Documents.Add(documentName);
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }
Esempio n. 25
0
        private static void ClearPage(Visio.Page page)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name));

            try
            {
                for (int i = page.Shapes.Count - 1; i >= 0; i--)
                {
                    page.Shapes[i].Delete();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, Common.LOG_CATEGORY);
            }

            System.Diagnostics.Debug.WriteLine(string.Format("Shapes on Page: {0}", page.Shapes.Count));
        }
Esempio n. 26
0
        private static void AddTOCLinkToPage(Visio.Page page)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name));

            if (page.Background != 0)
            {
                // Skip background pages
                return;
            }

            int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("AddTOCLinkToPage");

            // Clear out any existing link.

            foreach (Visio.Shape shape in page.Shapes)
            {
                if (shape.Text == "Table of Contents" || shape.Name == "TOCLink")
                {
                    shape.Delete();
                }
            }

            Visio.Shape tocShape = page.DrawRectangle(
                cTOC_Page_Initial_xLoc, cTOC_PageLink_Initial_yLoc,
                cTOC_Page_Initial_xLoc + cTOC_PageLink_Width, cTOC_PageLink_Initial_yLoc + cTOC_PageLink_Height);

            tocShape.Name = "TOCLink";

            tocShape.Text             = "Table of Contents";
            tocShape.TextStyle        = "Normal";
            tocShape.LineStyle        = "Text Only";
            tocShape.FillStyle        = "Text Only";
            tocShape.Characters.Begin = 0;
            tocShape.Characters.End   = 0;
            tocShape.Characters.set_CharProps((short)Visio.VisCellIndices.visCharacterSize, 6);

            Visio.Hyperlink hlink = tocShape.Hyperlinks.Add();
            // hlink.Name = "do we need a name?";
            hlink.SubAddress = "Table of Contents";

            Globals.ThisAddIn.Application.EndUndoScope(undoScope, true);
        }
Esempio n. 27
0
        private void ProcessCommand_ActiveDocument(XElement activeDocumentElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            Visio.Application app = Globals.ThisAddIn.Application;

            Visio.Document doc = app.ActiveDocument;

            if (activeDocumentElement.Elements("Layers").Any())
            {
                ProcessCommand_Layers(activeDocumentElement.Element("Layers").Elements());
            }

            if (activeDocumentElement.Elements("ShapeSheet").Any())
            {
                ProcessCommand_ShapeSheet(doc, activeDocumentElement.Element("ShapeSheet"));
            }
        }
Esempio n. 28
0
        private void ProcessCommand_Shape(Visio.Shape shape, XElement shapeElement)
        {
            foreach (XElement element in shapeElement.Elements())
            {
                VisioHlp.DisplayInWatchWindow(element.ToString());
                VisioHlp.DisplayInWatchWindow(element.Name.LocalName);

                switch (element.Name.LocalName)
                {
                case "ShapeSheet":
                    ProcessCommand_ShapeSheet(shape, element);
                    break;

                default:
                    VisioHlp.DisplayInWatchWindow(string.Format("Element >{0}< not supported", element.Name.LocalName));
                    break;
                }
            }
        }
Esempio n. 29
0
        private void ProcessCommand_Pages(Visio.Document doc, IEnumerable <XElement> pagesElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

            foreach (XElement element in pagesElement)
            {
                VisioHlp.DisplayInWatchWindow(element.ToString());
                VisioHlp.DisplayInWatchWindow(element.Name.LocalName);

                switch (element.Name.LocalName)
                {
                case "Add":
                    ProcessCommand_Page_Add(doc, element);
                    break;

                case "Delete":
                    ProcessCommand_Page_Delete(doc, element);
                    break;

                case "DeleteAll":
                    ProcessCommand_Page_DeleteAll(element);
                    break;

                case "Page":
                    ProcessCommand_Page(doc, element);
                    break;

                case "Layers":
                    foreach (Visio.Page page in doc.Pages)
                    {
                        ProcessCommand_Layers(page, element.Elements());
                    }

                    break;

                default:
                    VisioHlp.DisplayInWatchWindow(string.Format("Element >{0}< not supported", element.Name.LocalName));
                    break;
                }
            }
        }
Esempio n. 30
0
        public static void CreateTableOfContents()
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name));

            Visio.Page pageTOC = CreateTOCPage();

            // Use Navigation Links instead.

            //foreach (Visio.Page page in Globals.ThisAddIn.Application.ActiveDocument.Pages)
            //{
            //    if ( ! page.NameU.Equals("Table of Contents"))
            //    {

            //        //AddTOCLinkToPage(page);
            //    }
            //}

            // Should drive this off a calculation based on page size, # of pages, etc..  Hack it for now.

            double xLoc = cTOC_Initial_xLoc;
            double yLoc = cTOC_Initial_yLoc;

            int columnCount = 0;

            foreach (Visio.Page page in Globals.ThisAddIn.Application.ActiveDocument.Pages)
            {
                if (!page.NameU.Equals("Table of Contents"))
                {
                    AddPageLinkToTOCPage(pageTOC, page, xLoc, yLoc);
                    yLoc -= cTOC_Offset_Row;
                    columnCount++;

                    if (columnCount > cTOC_MaxItemsInColumn)
                    {
                        xLoc       += cTOC_Offset_Column;
                        yLoc        = cTOC_Initial_yLoc;
                        columnCount = 0;
                    }
                }
            }
        }