本文整理汇总了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;
}
}
}
}