'[eyeshot]How can I add a new Viewport into a viewer
what is the best way to add a new viewport into the viewer with the same drawing?
Regards Jürgen
Solution 1:[1]
You can check the Custom ViewportLayout source code sample.
Here is the code extracted from the above sample
private static void InitializeViewportsByLayoutType(Design design, viewportLayoutType layout)
{
int viewportsNumber;
switch (layout)
{
case viewportLayoutType.SingleViewport:
viewportsNumber = 1;
break;
case viewportLayoutType.TwoViewportsVertical:
case viewportLayoutType.TwoViewportsHorizontal:
viewportsNumber = 2;
break;
case viewportLayoutType.ThreeViewportsWithOneOnBottom:
case viewportLayoutType.ThreeViewportsWithOneOnLeft:
case viewportLayoutType.ThreeViewportsWithOneOnRight:
case viewportLayoutType.ThreeViewportsWithOneOnTop:
viewportsNumber = 3;
break;
case viewportLayoutType.FourViewports:
case viewportLayoutType.Stacked:
viewportsNumber = 4;
break;
default:
viewportsNumber = 1;
break;
}
if (design.Viewports.Count > viewportsNumber)
{
while (design.Viewports.Count > viewportsNumber)
design.Viewports.RemoveAt(design.Viewports.Count - 1);
}
else
{
while (design.Viewports.Count < viewportsNumber)
{
design.Viewports.Add((Viewport)design.Viewports[0].Clone());
}
}
// When changing the LayoutMode, the UpdateViewportsSizeAndLocation() method is called as well.
design.LayoutMode = layout;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |