0

I have logo in Xaml format.

Logo should be used as icon in custom (not mine) WPF control.

Logo contains several System.Windows.Media.Geometry objects:

<?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>

Using this way I can parse one geometry object and it can be successfully used as control icon:

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

Now I need to combine several Geometry objects. Obvious Method Geometry.Combine(Geometry, Geometry, GeometryCombineMode, Transform, Double, ToleranceType) returns PathGeometry object witch is not acceptable (by fact).

Is there any way to join several Geometry objects in one Geometry object?

  • Currently you have multiple Paths. If it were multiple Geometries, you could use a GeometryGroup. Since the Paths all seem to have the same Stroke and Fill, you could perhaps simply concat their Data strings to a single string and parse a single Geometry from it. – Clemens Aug 23 '18 at 16:48
  • Yes, It can be great way. I, would be glad to perform it manually. But, I learned [Path Markup Syntax](https://learn.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/path-markup-syntax) and can't build in my imagination reliable and universal algorithm. – Andrii Vdovenko Aug 23 '18 at 18:44
  • Just join the Data strings with a whitespace. – Clemens Aug 23 '18 at 18:47
  • I am trying right now and see it really works. But, as for as I see, closing `z` command should removed from all paths, except the very last. Not sure is it really universal, but it works with 3 different drawings. It look a bit different in Inkscape, and on control, but it works. Thank You. – Andrii Vdovenko Aug 23 '18 at 19:02

0 Answers0