问题描述
我有一个包含许多标签阿贾克斯标签的容器。我想通过每个选项卡循环并绘制标签面板内容的位图。
这是我目前的codeS:
的foreach(在container.Controls obj对象)
{
如果(obj是AjaxControlToolkit.TabPanel)
{
AjaxControlToolkit.TabPanel一个tabpanel =(AjaxControlToolkit.TabPanel)目标文件; 位图m_Bitmap =新位图(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height); 显卡显卡= Graphics.FromImage(m_Bitmap为System.Drawing.Image对象);
graphics.CopyFromScreen(25,25,25,25,m_Bitmap.Size); m_Bitmap.Save(@C:\\用户\\用户\\桌面\\项目\\ PROJECT1 \\来源$ C $ C \\ PROJECT1 \\图片\\+ tabPanel.HeaderText +.JPG,System.Drawing.Imaging.ImageFormat.Jpeg) ;
}
}
现在我能循环thorugh在该选项卡容器中的每个选项卡面板和屏幕截图整个网页,然后保存图像文件夹的位图图像。但我想截图/位图只是标签面板的内容。
问:如何绘制AjaxControlToolkit的TabPanel我目前的codeS为位图
?请指引我在这,谢谢。
- 从客户端code获取的TabPanel。这是样品code:
VAR TabContainer的= $找到(Content_DemoContent_Tabs);
对于(VAR I = 0; I< tabContainer.get_tabs()长;我++)
{
tabContainer.set_activeTabIndex(ⅰ);
VAR元= tabContainer.get_tabs()[我] ._元;
}
元素
的位置。这是相当复杂和不可靠的任务,但你可以看到如何在这里做到这一点:http://stackoverflow.com/a/21274679/644496I have ajax tab container that contains many tabs. I want to loop through each tab and draw the tab panel content to bitmap.
This is my current codes:
foreach (object obj in container.Controls)
{
if (obj is AjaxControlToolkit.TabPanel)
{
AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj;
Bitmap m_Bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(m_Bitmap as System.Drawing.Image);
graphics.CopyFromScreen(25, 25, 25, 25, m_Bitmap.Size);
m_Bitmap.Save(@"C:\Users\user\Desktop\Project\Project1\Source Code\Project1\Image\" + tabPanel.HeaderText + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
Now I am able to loop thorugh each tab panel in the tab container and screenshot the whole webpage, then save the bitmap image in Image folder. But I want to screenshot/bitmap just the tab panel content.
Question: How to Draw AjaxControlToolkit TabPanel to Bitmap with my current codes?
Please guide me on this, thanks.
- Get TabPanel from client code. This is sample code:
var tabContainer = $find("Content_DemoContent_Tabs");
for(var i = 0; i < tabContainer.get_tabs().length; i++)
{
tabContainer.set_activeTabIndex(i);
var element = tabContainer.get_tabs()[i]._element;
}
- Calculate position of each
element
in screen coordinates. This is quite complex and not reliable task, but you can see how to do it here: http://stackoverflow.com/a/21274679/644496 - Send this data to server to make a screenshot. This is broad, though well-know task, so you can choose any way of doing it.
这篇关于如何绘制AjaxControlToolkit的TabPanel为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!