예제 #1
0
        public IVisio.Layer Get(string layername)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            if (layername == null)
            {
                throw new System.ArgumentNullException(nameof(layername));
            }

            if (layername.Length < 1)
            {
                throw new System.ArgumentException("Layer name cannot be empty", nameof(layername));
            }

            var application = this.Client.Application.Get();
            var page        = application.ActivePage;

            IVisio.Layer layer = null;
            try
            {
                this.Client.WriteVerbose("Trying to find Layer named \"{0}\"", layername);
                var layers = page.Layers;
                layer = layers.ItemU[layername];
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                string msg = $"No such layer \"{layername}\"";
                throw new VisioOperationException(msg);
            }
            return(layer);
        }
예제 #2
0
        void ck_Click(object sender, RibbonControlEventArgs e)
        {
            RibbonCheckBox ck = (RibbonCheckBox)sender;

            Visio.Layer lay = (Visio.Layer)ck.Tag;
            lay.CellsC[4].Formula = ck.Checked ? "1" : "0";
        }
예제 #3
0
        public IVisio.Layer FindLayersOnPageByName(TargetPage targetpage, string name)
        {
            targetpage = targetpage.Resolve(this._client);


            if (name == null)
            {
                throw new System.ArgumentNullException(nameof(name));
            }

            if (name.Length < 1)
            {
                throw new System.ArgumentException("Layer name cannot be empty", nameof(name));
            }

            IVisio.Layer layer = null;
            try
            {
                this._client.Output.WriteVerbose("Trying to find layer named \"{0}\"", name);
                var layers = targetpage.Page.Layers;
                layer = layers.ItemU[name];
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                string msg = string.Format("No layer with name \"{0}\"", name);
                throw new VisioAutomation.Exceptions.VisioOperationException(msg);
            }
            return(layer);
        }
예제 #4
0
        public IVisio.Layer Get(string layername)
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            if (layername == null)
            {
                throw new System.ArgumentNullException("layername");
            }

            if (layername.Length < 1)
            {
                throw new System.ArgumentException("layername");
            }

            var application = this.Client.VisioApplication;
            var page        = application.ActivePage;

            IVisio.Layer layer = null;
            try
            {
                this.Client.WriteVerbose("Trying to find Layer named \"{0}\"", layername);
                var layers = page.Layers;
                layer = layers.ItemU[layername];
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                string msg = string.Format("No such layer \"{0}\"", layername);
                throw new VA.Scripting.ScriptingException(msg);
            }
            return(layer);
        }
예제 #5
0
        private void ProcessCommand_Layer(XElement layerElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

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

                Visio.Application app = Globals.ThisAddIn.Application;

                Visio.Document doc = app.ActiveDocument;

                Visio.Page page = app.ActivePage;

                string layerName = layerElement.Attribute("Name").Value;

                Visio.Layer targetLayer = page.Layers[layerName];

                if (targetLayer != null)
                {
                    string newName      = (string)layerElement.Attribute("NewName");
                    string layerVisible = (string)layerElement.Attribute("IsVisible");
                    string layerPrint   = (string)layerElement.Attribute("IsPrint");
                    string layerActive  = (string)layerElement.Attribute("IsActive");
                    string layerLock    = (string)layerElement.Attribute("IsLock");
                    string layerSnap    = (string)layerElement.Attribute("IsSnap");
                    string layerGlue    = (string)layerElement.Attribute("IsGlue");

                    if (newName != null)
                    {
                        targetLayer.Name = newName;
                    }

                    if (layerVisible != null)
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerVisible].FormulaU = layerVisible;
                    }

                    if (layerPrint != null)
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerPrint].FormulaU = layerPrint;
                    }

                    if (layerActive != null)
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerActive].FormulaU = layerActive;
                    }

                    if (layerLock != null)
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerLock].FormulaU = layerLock;
                    }

                    if (layerSnap != null)
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerSnap].FormulaU = layerSnap;
                    }

                    if (layerGlue != null)
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerGlue].FormulaU = layerGlue;
                    }
                }
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }
예제 #6
0
        private void ProcessCommand_Layer(Visio.Page page, XElement layerElement)
        {
            VisioHlp.DisplayInWatchWindow(string.Format("{0}()",
                                                        System.Reflection.MethodInfo.GetCurrentMethod().Name));

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

                Visio.Layer targetLayer = page.Layers[layerName];

                if (targetLayer != null)
                {
                    string newName      = (string)layerElement.Attribute("NewName");
                    string layerVisible = (string)layerElement.Attribute("IsVisible");
                    string layerPrint   = (string)layerElement.Attribute("IsPrint");
                    string layerActive  = (string)layerElement.Attribute("IsActive");
                    string layerLock    = (string)layerElement.Attribute("IsLock");
                    string layerSnap    = (string)layerElement.Attribute("IsSnap");
                    string layerGlue    = (string)layerElement.Attribute("IsGlue");

                    if (newName != null && newName != "")
                    {
                        targetLayer.Name = newName;
                    }

                    if (layerVisible != null && layerVisible != "")
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerVisible].FormulaU = layerVisible;
                    }

                    if (layerPrint != null && layerPrint != "")
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerPrint].FormulaU = layerPrint;
                    }

                    if (layerActive != null && layerActive != "")
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerActive].FormulaU = layerActive;
                    }

                    if (layerLock != null && layerLock != "")
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerLock].FormulaU = layerLock;
                    }

                    if (layerSnap != null && layerSnap != "")
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerSnap].FormulaU = layerSnap;
                    }

                    if (layerGlue != null && layerGlue != "")
                    {
                        targetLayer.CellsC[(short)Visio.VisCellIndices.visLayerGlue].FormulaU = layerGlue;
                    }
                }
            }
            catch (Exception ex)
            {
                VisioHlp.DisplayInWatchWindow(ex.ToString());
            }
        }