如何动态地将多个System.Windows.Media.Geometry合并到一个对象中?

时间:2018-08-23 16:42:50

标签: c# wpf xaml

我有Xaml格式的徽标。

徽标应在自定义(不是我的)WPF控件中用作图标。

徽标包含几个System.Windows.Media.Geometry对象:

<?xml version="1.0" encoding="UTF-8"?>
<!--This file is compatible with Silverlight-->
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg8" Width="210" Height="297">
  <Canvas.RenderTransform>
    <TranslateTransform X="0" Y="0"/>
  </Canvas.RenderTransform>
  <Canvas.Resources/>
  <!--Unknown tag: sodipodi:namedview-->
  <!--Unknown tag: metadata-->
  <Canvas Name="layer1">
    <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path10" StrokeThickness="0.26458332" Stroke="#FF000000" Data="m 52.160713 62.654762 c 1.478187 1.32658 -1.058918 2.647054 -2.204863 2.456843 -3.10544 -0.515458 -3.811195 -4.419304 -2.708823 -6.866569 1.971885 -4.377585 7.663227 -5.185566 11.528276 -2.960803 5.672116 3.264929 6.597797 10.950118 3.212783 16.189983 -4.511692 6.983916 -14.252125 8.025987 -20.85169 3.464762 C 32.831518 69.199143 31.673999 57.377674 37.419654 49.425582 44.378412 39.794533 58.29417 38.52202 67.594757 45.45686 78.555176 53.629328 79.942466 69.647101 71.815459 80.293669 62.432508 92.585554 44.307816 94.087516 32.316943 84.766351 18.692151 74.175052 17.075566 53.940127 27.592281 40.606129 39.390446 25.647397 61.737946 23.916211 76.41421 35.629487 92.707646 48.633444 94.553426 73.095239 81.642832 89.113123"/>
    <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path22" StrokeThickness="0.26458332" Stroke="#FF000000" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" Data="M 12.095238 22.589285 C 11.339286 108.76785 24.190476 119.35119 24.190476 119.35119 L 94.494047 118.59524 106.58928 28.636904 Z"/>
    <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path24" StrokeThickness="0.26458332" Stroke="#FF000000" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" Data="M 12.095238 22.589285 68.035714 6.7142857 106.58928 28.636904"/>
  </Canvas>
</Canvas>

使用this解析一个一个几何对象的方法,它可以成功用作控件图标:

System.Windows.Media.Geometry icon_geometry = Geometry.Parse("M 263,99 ... Z");
Some_Control.Icon = icon_geometry;

现在,我需要组合几个Geometry对象。明显的Method Geometry.Combine(Geometry, Geometry, GeometryCombineMode, Transform, Double, ToleranceType)返回PathGeometry对象巫婆是不可接受的(事实上)。

是否可以将多个Geometry对象合并到一个Geometry对象中?

0 个答案:

没有答案