Getting the transformed MilGraphic

Feb 27, 2012 at 10:15 AM
Edited Feb 28, 2012 at 9:41 AM

How to get the transformed MilGraphic without attaching it to a visual tree (layer)? I want to get the transformed path of a symbol.

1. How can I access/generate the transformed paths?

2. How can I access/generate the transformed paths without adding it to a visual tree?

3. How to get these paths transformed without adding them to a layer (because the layer has no VisualTree/WPF dependency)?

I need to draw the paths (canvas content) in a "traditional" way against an api with drawLine/drawPolygon methods.

A serialized milgraphic looks like this:

 

<MilGraphic SymbolCode="GNTPY------J**X" IsSpline="False" LabelT="Hello" LabelT1="Denver" LabelW="18.12.2010 00:00:00" LabelW1="19.12.2010 00:00:00" LabelX="2000' AGL" LabelX1="4000' AGL" Width="274" Height="274" ToolTip="GHTPY-----****X" esri:LayerCanvas.Extent="-7792364.35553915,2754108.78754045,-7792364.35551915,2754108.78756045" esri:ElementLayer.Envelope="-7792364.35553915,2754108.78754045,-7792364.35551915,2754108.78756045" xmlns="clr-namespace:MilSym.MilGraph;assembly=MilSym.MilGraph.WPF" xmlns:mses="clr-namespace:MilSym.EsriSupport;assembly=MilSym.EsriSupport.WPF" xmlns:msmgs="clr-namespace:MilSym.MilGraph.Support;assembly=MilSym.MilGraph.WPF" xmlns:msms="clr-namespace:MilSym.MilSymbol;assembly=MilSym.MilSymbol.WPF" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
  <MilGraphic.Anchors>
    <mses:EsriLocationCollection>-70,24.00575 -70,24 -70.0020000446857,24.0028749870279 -70,24.002875 -70.0020000893787,24.0057499870262 -70.0020000000015,23.9999999870297</mses:EsriLocationCollection>
  </MilGraphic.Anchors>
  <MilGraphic.Layer>
    <mses:EsriMilSymLayer />
  </MilGraphic.Layer>
  <MilGraphic.LabelOffset>
    <msmgs:Offset X="-0.25" Y="0.25" />
  </MilGraphic.LabelOffset>
  <MilGraphic.RenderTransform>
    <av:TransformGroup>
      <av:TransformGroup.Children>
        <av:ScaleTransform ScaleX="0.01" ScaleY="0.01" />
      </av:TransformGroup.Children>
    </av:TransformGroup>
  </MilGraphic.RenderTransform>
  <msms:MilSymbolBase LineThickness="3" Width="274" Height="274" av:Canvas.Left="0" av:Canvas.Top="0">
    <msms:MilSymbolBase.Template>
      <av:ControlTemplate>
        <av:Canvas>
          <av:Path StrokeThickness="1" Style="{x:Null}" Name="D65">
            <av:Path.Data>
              <av:PathGeometry Figures="M0,-110L0,-17 M0,17L0,110" />
            </av:Path.Data>
          </av:Path>
          <av:Path StrokeThickness="1" Style="{x:Null}" Name="C51">
            <av:Path.Data>
              <av:PathGeometry Figures="M355,-110L0,-110 M310,-125L355,-110L310,-95" />
            </av:Path.Data>
          </av:Path>
          <av:Path StrokeThickness="1" Style="{x:Null}" Name="B62">
            <av:Path.Data>
              <av:PathGeometry Figures="M0,17L0,110L355,110 M310,125L355,110L310,95" />
            </av:Path.Data>
          </av:Path>
          <av:TextBlock Text="B" Foreground="#FF000000" Name="A65" av:Canvas.Left="-10" av:Canvas.Top="-20">
            <av:TextBlock.Style>
              <av:Style TargetType="av:TextBlock">
                <av:Style.Resources>
                  <av:ResourceDictionary />
                </av:Style.Resources>
                <av:Setter Property="av:TextElement.FontFamily">
                  <av:Setter.Value>
                    <av:FontFamily>Arial</av:FontFamily>
                  </av:Setter.Value>
                </av:Setter>
                <av:Setter Property="av:TextElement.Foreground">
                  <av:Setter.Value>
                    <av:SolidColorBrush>#FF000000</av:SolidColorBrush>
                  </av:Setter.Value>
                </av:Setter>
                <av:Setter Property="av:TextElement.FontSize">
                  <av:Setter.Value>
                    <s:Double>35</s:Double>
                  </av:Setter.Value>
                </av:Setter>
                <av:Setter Property="av:TextElement.FontWeight">
                  <av:Setter.Value>
                    <av:FontWeight>Bold</av:FontWeight>
                  </av:Setter.Value>
                </av:Setter>
              </av:Style>
            </av:TextBlock.Style>
          </av:TextBlock>
        </av:Canvas>
      </av:ControlTemplate>
    </msms:MilSymbolBase.Template>
  </msms:MilSymbolBase>
</MilGraphic>

 

As you can see the milgraphic does not contain the transformed values at this state. I assume I need to add it to a visual tree (layer) or use something like a visualtreehelper to get the transformed values... right?

Any other ideas to gain access to the transformed paths?

I have a MilGraphic as seen in your samples:

var pg = new MilGraphic(sidc, saveLoc, false, 
  new Offset(0, 0), "T=Hello;T1=Denver;X=2000' AGL;X1=4000' AGL",
  new DateTime(2010, 12, 18).ToString(CultureInfo.InvariantCulture),
  new DateTime(2010, 12, 19).ToString(CultureInfo.InvariantCulture), "", "",  "", "");

// how to get the already transformed path here?
// how to get the used transformation (matrix/scale/...)? (got null)
var
transform = VisualTreeHelper.GetTransform(pg);
Point pt = transform.Transform(new Point(0, 355));