本文整理汇总了C#中Microsoft.Office.Interop.Visio.DropIntoList方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Visio.DropIntoList方法的具体用法?C# Microsoft.Office.Interop.Visio.DropIntoList怎么用?C# Microsoft.Office.Interop.Visio.DropIntoList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Visio
的用法示例。
在下文中一共展示了Microsoft.Office.Interop.Visio.DropIntoList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisualizeUsers
// TODO:
// 1. Вычислять макс.длину строки и делать размер Контейнера соответствующим
//
public static Program.ExitCode VisualizeUsers(Visio.Page targetPage,
rbacLINQ2SQLDataContext db)
{
Visio.Application visioApplication = null;
Visio.Document stencilUML = null;
Visio.Shape shapeUser = null;
Visio.Shape shapeUserContainer = null;
int lastElemInContainer = 0;
Visio.Document targetDocument = null;
Visio.ContainerProperties containerProperties = null;
int currentDiagramServices = -1;
int prevDiagramServices;
System.Array containerMembers = null;
if (targetPage == null)
{
return Program.ExitCode.Error;
}
try
{
// Turn on all Visio diagram services
targetDocument = targetPage.Document;
visioApplication = targetPage.Application;
stencilUML = visioApplication.Documents.
OpenEx(@"C:\MyTestProjects\MCD\diploma\pmtool\pmt\pmt\UML_Class.vssx",
(short)Visio.VisOpenSaveArgs.visOpenHidden);
// Enable All Diagram Services to enable adding huge-named members to the container
prevDiagramServices = targetDocument.DiagramServicesEnabled;
targetDocument.DiagramServicesEnabled = currentDiagramServices;
// DO NOT REMOVE NEXT LINE!
//-- WTF?! Добавление этой строчки убирает из Container'а дефолтные члены.
//-- Причем только для первого раза. Если создавать еще сущности, то уже будет опять с дефолтными.
//
//-- Вместо этой строки сейчас просто удаляются дефолтные члены контейнеров.
//-- Благо, их генерится всего два, и удаление не занимает много времени.
//targetPage.Document.OpenStencilWindow();
// Just drop elements from User Table:
//foreach (User u in db.User)
//{
// System.Diagnostics.Debug.WriteLine(lastElemInContainer);
// shapeUser = targetPage.Drop(stencilUML.Masters["Member"], 0, 0);
// shapeUser.Text = String.Format("name: {0}|password: {1}|policy: {2}", u.Name, u.Password, u.Policy_Id);
// //shapeUser.Text = String.Format("name: {0}", u.Name);
// targetPage.Application.ActiveWindow.Select(shapeUser, (short)Visio.VisSelectArgs.visSelect);
//}
// Drop a container
shapeUserContainer = targetPage.DropContainer(stencilUML.Masters["Class"], null);
// Same as prev.row:
//shapeUserContainer = targetPage.Drop(stencilUML.Masters["Class"], 5, 5);
shapeUserContainer.Text = "User Table";
// Get/Set Container List Spacing Interval (gap between members in list)
//shapeUserContainer.ContainerProperties.SetListSpacing(Visio.VisUnitCodes.visInches, 0.2);
//System.Diagnostics.Debug.WriteLine(shapeUserContainer.ContainerProperties.GetListSpacing(Visio.VisUnitCodes.visInches));
// Delete default members, that appear right after a container was dropped on a page
foreach (int o in shapeUserContainer.ContainerProperties.GetMemberShapes((int)Visio.VisContainerFlags.visContainerFlagsDefault))
{
targetPage.Shapes.get_ItemFromID(o).Delete();
}
// Drop elements to the container
lastElemInContainer = shapeUserContainer.ContainerProperties.GetListMembers().Length+1;
foreach (User u in db.User)
{
System.Diagnostics.Debug.WriteLine(lastElemInContainer);
if (lastElemInContainer != 1)
{
shapeUser = targetPage.DropIntoList(stencilUML.Masters["Separator"],
shapeUserContainer,
lastElemInContainer);
lastElemInContainer += 1;
}
shapeUser = targetPage.DropIntoList(stencilUML.Masters["Member"],
shapeUserContainer,
lastElemInContainer);
lastElemInContainer += 1;
shapeUser.Text = String.Format("name: {0}|password: {1}|policy: {2}", u.Name, u.Password, u.Policy_Id);
// Same with Insert method:
//shapeUserContainer.ContainerProperties.InsertListMember(
// shapeUser = targetPage.Drop(stencilUML.Masters.get_ItemU("Member"),0,0), lastElemInContainer);
//shapeUser.Text = String.Format("Name: {0}|Password: {1}|Policy: {2}", u.Name, u.Password, u.Policy_Id);
//lastElemInContainer += 1;
}
containerProperties = shapeUserContainer.ContainerProperties;
// Report on contents of container
containerMembers = containerProperties.GetMemberShapes((int)Visio.VisContainerFlags.visContainerFlagsDefault);
foreach (int member in containerMembers)
{
System.Diagnostics.Debug.WriteLine(targetPage.Shapes.get_ItemFromID(member).NameU +
" |===> "+ targetPage.Shapes.get_ItemFromID(member).Text);
//.........这里部分代码省略.........