本文整理汇总了C#中Microsoft.Office.Interop.Visio.CreateSelection方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Visio.CreateSelection方法的具体用法?C# Microsoft.Office.Interop.Visio.CreateSelection怎么用?C# Microsoft.Office.Interop.Visio.CreateSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Visio
的用法示例。
在下文中一共展示了Microsoft.Office.Interop.Visio.CreateSelection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyPage
/// <summary>
/// Formats the to Page similar to the from page and
/// copies all from FromPage to ToPage
/// </summary>
/// <param name="fromPage">Source page</param>
/// <param name="toPage">Destination page</param>
private void CopyPage(Visio.Page fromPage, Visio.Page toPage)
{
SetupDestinationPage(fromPage, toPage);
//Copy shapes
fromPage.AddGuide((short)Visio.VisGuideTypes.visPoint, 0, 0);
Visio.Selection selection = fromPage.CreateSelection(Visio.VisSelectionTypes.visSelTypeAll);
selection.Copy();
toPage.Paste();
Visio.Selection resultSelection = toPage.CreateSelection(Visio.VisSelectionTypes.visSelTypeAll);
double origX, origY, newX, newY, dummy1, dummy2;
selection.BoundingBox(1, out origX, out origY, out dummy1, out dummy2);
resultSelection.BoundingBox(1, out newX, out newY, out dummy1, out dummy2);
double diffX = origX - newX;
double diffY = origY - newY;
resultSelection.Move(diffX, diffY);
}
示例2: VisualizeURP
public static Program.ExitCode VisualizeURP(Visio.Page targetPage, rbacLINQ2SQLDataContext db, User user_in)
{
Visio.Application visioApplication = null;
Visio.Document stencilUMLUseCase = null;
Visio.Document stencilBasicU = null;
Visio.Shape shape = null;
Visio.Shape shapeContainer = null;
Visio.Shape shapeConnector = null;
List<Visio.Shape> shapeRoles = null;
List<Visio.Shape> shapePermissions = null;
Visio.Selection selection = null;
Visio.Document targetDocument = null;
Visio.ContainerProperties containerProperties = null;
int currentDiagramServices = -1;
int prevDiagramServices;
System.Array containerMembers = null;
if (user_in == null || targetPage == null)
return Program.ExitCode.Error;
var users = from usr in db.User
where usr.Name == user_in.Name && usr.Policy_Id == user_in.Policy_Id
select usr;
//if doesn't exist, return Error status:
if (users.Count() == 0)
return Program.ExitCode.ElementDoesNotExists;
try
{
// Turn on all Visio diagram services
targetDocument = targetPage.Document;
visioApplication = targetPage.Application;
// Enable All Diagram Services to enable adding huge-named members to the container
prevDiagramServices = targetDocument.DiagramServicesEnabled;
targetDocument.DiagramServicesEnabled = currentDiagramServices;
stencilUMLUseCase = visioApplication.Documents.
OpenEx(@"C:\MyTestProjects\MCD\diploma\pmtool\pmt\pmt\UML_Use_Case.vssx",
(short)Visio.VisOpenSaveArgs.visOpenHidden);
stencilBasicU = visioApplication.Documents.
OpenEx(@"Basic_U.vssx",
(short)Visio.VisOpenSaveArgs.visOpenHidden);
selection = targetPage.CreateSelection(Visio.VisSelectionTypes.visSelTypeEmpty,
Visio.VisSelectMode.visSelModeOnlySuper, null);
//=======================================
// Get all necessary data for drawing a diagram
User u = users.First();
var roles = from auth in u.AuthUserRole
select auth.Role;
Dictionary<Role, List<Permission>> rpSet = new Dictionary<Role, List<Permission>>();
shapePermissions = new List<Visio.Shape>();
foreach (Role r in roles)
{
var perms = from roleperm in r.RolePermission
select roleperm.Permission;
rpSet.Add(r, perms.ToList<Permission>());
}
double H = 0.5;
double W = 4;
double gap = 0.5;
double centerX = 5;
double centerY = 1;
double border = 0.1;
// Draw permissions with general method DropConnected
List<string> strPerms = new List<string>();
int maxStrLenPerms = 0;
foreach (var rp in rpSet)
{
if (rp.Value.Count == 0)
{
strPerms.Add("NO PERMISSION ASSIGNED");
maxStrLenPerms = strPerms.Last().Length;
}
else
{
foreach (Permission p in rp.Value)
{
if (maxStrLenPerms == 0)
strPerms.Add(String.Format("Name: {0}, Policy_Id: {1}", p.Name, p.Policy_Id));
else
strPerms.Add(String.Format("\nName: {0}, Policy_Id: {1}", p.Name, p.Policy_Id));
if (strPerms.Last().Length > maxStrLenPerms)
maxStrLenPerms = strPerms.Last().Length;
}
}
shape = targetPage.Drop(stencilBasicU.Masters["Rectangle"],centerX, centerY += H + gap);
double charSize = shape.get_Cells("Char.Size").ResultIU;
shape.get_Cells("Height").ResultIU = charSize * strPerms.Count + 2 * border;
shape.get_Cells("Width").ResultIU = charSize * maxStrLenPerms;
shape.Text = String.Concat(strPerms);
shapePermissions.Add(shape);
strPerms.Clear();
//.........这里部分代码省略.........