首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

怎样将Path的Data数据存入数据库再通过程序加载到界面解决方案

2013-11-11 
怎样将Path的Data数据存入数据库再通过程序加载到界面RT,Path DataM733.5,339.37495 L738.375,338.875

怎样将Path的Data数据存入数据库再通过程序加载到界面
RT,


<Path Data="M733.5,339.37495 L738.375,338.875 738.25,335.5 739.375,334.25 739.625,332.75 740.625,330.625 741.75,330.5 743.5,332 742.375,328.87497 741.25,327.875 741.375,326.24997 743.5,325.99997 744.75,324.62497 744.75,321.24998 747.25,321.24998 749.125,321.24998 749.875,323.5 751.5,323.5 753,322.125 755.375,321.5 756.5,322.625 759.5,322.75 759.5,321.25 762,319.49998&#xa;762.16667,317.99999 764.375,315.375 766.375,315.375 767.5,319.5 770.75,319.5 773,316.875 775.5,316.375 774.125,314.375 773.375,311.5 773.875,310.125 775.5,310.125 775.5,311.5 776.625,311.5 777.625,311.5 780.5,311.5 783.5,311.5 783.5,313.5 785.25,315.625 787.625,316.625 788.125,319.5 790.125,319.5 792.75,319.5 794.125,321.125&#xa;798.375,322.125 795.75,323.75 794.5,325.125 797.125,326.125 797.625,327.5 804.875,327.5 804,332.25 802.625,332.875 802.125,335.5 800.625,335.5 800.75,338.25 801.5,338.875 802.875,337.125 803.875,337.875 807.5,337.875 809,337.625 810.75,336.875 812.125,337.375 813.75,337.75 814.375,335.5 815.5,335.5 816.625,338.25 815.5,340&#xa;814.25,341.125 814.125,343.5 815.5,343.5 817.625,344.625 816.625,344.875 815.5,347.75 815.5,348.625 817.75,349 C817.75,349 817.75,351.5 817.75,351.5 817.5,351.5 817.75,351.5 817.75,351.5 L819.75,351.5 820.5,353.125 820.56747,354.13707 820.625,355 820.25,356.5 819.5,357.75 818.5,359.5 818.5,359.5 817.5,361.875 815.5,363.125 814.125,364.625 814.125,367.5 C814.125,367.5 812.875,367.25 812,368.625 811.125,370 810,370 809.375,371 808.75,372 809,372.125 807.5,372.125 806,372.125 806.375,375.5 806.375,375.5 806.375,375.5 807.625,378 804.75,376.75 801.875,375.5 805.75,378.25001 802.625,377.50001 799.5,376.75001 801.625,375.49987 801.625,375.49987 L801.125,374.37487 799.5,373.62487 797.625,375.49987 797.75,375.49987 796.5,376.74987 795.75,377.62487 793.125,377.49987 789.625,377.49987 787.375,377.49987 786.375,377.62487 786.125,379.12486 783.5,378.99988 783.5,377.74988 781.25,376.99988 780.875,375.49988 779.75,375.49988 779.75,373.87489 779.75,370.87489 778,370.37489 777.875,367.4999 775.5,366.2499 775.5,364.9999 774.25,362.99991&#xa;773.75,361.37491 774.375,359.49991 775.5,359.49991 775.5,357.87492 773.75,356.62492 771.625,355.74992 770.25,354.99992 767.5,355.24992 767.5,356.49992 764.5,356.49992 761.375,355.24992 761,356.87492 760.625,359.49991 759.5,360.74991 754.5,360.62491 753.5,362.12491 753.125,363.49991 C753.125,363.49991 747.1178,364.89969 745.25,365.2499 743.71507,365.5377 743.5,363.74991 743.5,363.74991 L742.25,361.12491 741.875,359.49991 742.375,357.99992 742,355.87492 740.75,354.37492 738.75,353.49992 737.625,354.49992 735.5,354.49992 735.5,351.49993 732.5,351.49993 730.625,349.37493 729.625,347.74993 727.5,345.62494 727.5,343.49994 727.5,340.49995 732,340.62495 731.75,337.87495 733.375,337.74995 z" Fill="#FFF4F4F5" Stretch="None" Tag="南充"  StrokeThickness="0.5" Stroke="Black" MouseEnter="Path_MouseEnter" MouseLeave="Path_MouseLeave" />


比如把这个Path的Data数据用字符串存入数据库,然后在程序加载的时候通过用户选择不同来加载不同的图形!后台代码应该怎么写呢?怎样把String转换为Geometry Geometry wpf path 转换
[解决办法]
 Geometry g = Geometry.Parse("M100,10 L200,20 L100,30z");

通过上面的方式就可以得到Geometry,所以可以直接存储字符串
既然xaml的方式可以写出来,内部一般都会有对应的转换方式。

不过另外有一种是动态加载xaml,这样的话应该也是可以的,将写好的xaml内容存储到数据库或者文本中,通过指定的类就可以动态加载了,使用System.Windows.Markup.XamlReader的Load静态函数
[解决办法]
也可以把 Path 的 Data 绑定数据库对应的字段。

btw,楼主的那串字符串是转换过来的吗?我测试时只能写在xaml中才有效,转换时会报错,字符串里面的 &#xa; 不知是不是正常的。

热点排行