当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.Office.Interop.Visio.OpenStencil方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Visio.OpenStencil方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Visio.OpenStencil方法的具体用法?C# Microsoft.Office.Interop.Visio.OpenStencil怎么用?C# Microsoft.Office.Interop.Visio.OpenStencil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Visio的用法示例。


在下文中一共展示了Microsoft.Office.Interop.Visio.OpenStencil方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Resolve

        public void Resolve(IVisio.Documents docs)
        {
            // first get the unique stencils (ignoring case)
            var comparer = System.StringComparer.CurrentCultureIgnoreCase;
            var unique_stencils = new HashSet<string>(comparer);
            foreach (var master_ref in this.master_ref_dic.Values)
            {
                unique_stencils.Add(master_ref.StencilName);
            }

            // for each unique stencil, load the stencil doc
            var name_to_stencildoc = new Dictionary<string, IVisio.Document>(comparer);
            foreach (var stencil in unique_stencils.Where(s=>s!=null))
            {
                // If a stencil was stencified open the stencil if needed
                var stencil_doc = docs.OpenStencil(stencil);
                if (stencil_doc == null)
                {
                    string msg = $"Failed to open stencil \"{stencil}\"";
                    throw new AutomationException(msg);
                }

                name_to_stencildoc[stencil] = stencil_doc;
            }

            // identify real master objects for all deferred shapes
            foreach (var master_ref in this.master_ref_dic.Values)
            {
                if (master_ref.VisioMaster == null)
                {
                    if (master_ref.StencilName != null)
                    {
                        // The stencil doc was specified so try to find the master in that stencil doc
                        var stencildoc = name_to_stencildoc[master_ref.StencilName];
                        var stencilmasters = stencildoc.Masters;

                        var master_object = this.TryGetMaster(stencilmasters, master_ref.MasterName);
                        if (master_object == null)
                        {
                            string msg =
                                $"No such master \"{master_ref.MasterName}\" in stencil \"{master_ref.StencilName}\"";
                            throw new AutomationException(msg);
                        }
                        master_ref.VisioMaster = master_object;                        
                    }
                    else
                    {
                        // the stencil doc was not specified so try to find the master int the current doc
                        var app = docs.Application;
                        var stencildoc = app.ActiveDocument;
                        var stencilmasters = stencildoc.Masters;

                        var master_object = this.TryGetMaster(stencilmasters, master_ref.MasterName);
                        if (master_object == null)
                        {
                            string msg =
                                $"No such master \"{master_ref.MasterName}\" in Active Document \"{stencildoc.Name}\"";
                            throw new AutomationException(msg);
                        }
                        master_ref.VisioMaster = master_object;
                    }
                }
            }
        }
开发者ID:shekharssorot2002,项目名称:VisioAutomation2.0,代码行数:64,代码来源:MasterLoader.cs


注:本文中的Microsoft.Office.Interop.Visio.OpenStencil方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。