使用VisualTreeHelper.GetDrawing(Visual v)枚举所有Visual内容的对象
C#代码:
public void RetrieveDrawing(Visual v)
{
DrawingGroup dGroup = VisualTreeHelper.GetDrawing(v);
EnumDrawingGroup(dGroup);
}
public void EnumDrawingGroup(DrawingGroup drawingGroup)
{
DrawingCollection dc = drawingGroup.Children;
foreach (Drawing drawing in dc)
{
// 如果是DrawingGroup,递归枚举
if (drawing.GetType() == typeof(DrawingGroup))
{
EnumDrawingGroup((DrawingGroup)drawing);
}
else if (drawing.GetType() == typeof(GeometryDrawing))
{
// 处理代理
}
else if (drawing.GetType() == typeof(ImageDrawing))
{
// 处理代理
}
else if (drawing.GetType() == typeof(GlyphRunDrawing))
{
// 处理代理
}
else if (drawing.GetType() == typeof(VideoDrawing))
{
// 处理代理
}
}
}
由于代码很简单,不赘述.
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
WPF应用程序顶级标签一定是Window吗?
原文: WPF应用程序顶级标签一定是Window吗? WPF应用程序顶级标签一定是Window吗?很多人误以为是。可是,答案却是否定的。我们不妨来测试一下。 首先使用顶级标签为Window,这是最普通、也是最常见的情况。新建一个WPF应用程序,名称为Window1,利用工具箱在窗口中拖入一个按钮(Button)。我们发现Window1中将得到类似如下内容:// Window1.xaml<Window x:Class="LogicalOverrideApp.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <Button Height="23" Margin="96,33,107,0" Name="button1" VerticalAlignment="T...
- 下一篇
WPF公章制作之2
原文: WPF公章制作之2 早前,我曾写过一篇:“在WPF中制作正圆形公章”(http://blog.csdn.net/johnsuna/archive/2007/10/12/1821531.aspx)。有空再次研究,使用C#将此WPF程序写了出来。运行效果图:关键C#代码:// OfficialSeal.csusing System;using System.Windows;using System.Windows.Controls;using System.Windows.Input;using System.Windows.Media;using System.Windows.Shapes;using brawdrawSharp = BrawDraw.Com.Utility.PublicClasses.Shape; namespace BrawDraw.Com.WPF.PublicControls.Demo{ public classOfficialSeal : Window { [STAThread] public static void Main() { Applicatio...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Mario游戏-低调大师作品
- Docker安装Oracle12C,快速搭建Oracle学习环境
- Red5直播服务器,属于Java语言的直播服务器
- CentOS7,CentOS8安装Elasticsearch6.8.6
- CentOS8编译安装MySQL8.0.19
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- CentOS6,CentOS7官方镜像安装Oracle11G
- Jdk安装(Linux,MacOS,Windows),包含三大操作系统的最全安装
- SpringBoot2更换Tomcat为Jetty,小型站点的福音