I can’t figure out the easiest way to add a pallet of custom symbols that can be dragged onto the diagram.
What I’m trying to accomplish is add a group of symbols like these:
A cable-break symbol:
and a measurement tool with a textblock where a user can type a measurement:
I’ve tried various methods based on the samples but I literally don’t need these symbols to do anything other than be dragged onto the diagram surface. They don’t need links or attributes.
How can I very simply add a custom defined path ‘figure’ to a pallet?
I tried the following but the path isn’t showing up and I’m not even sure that what I’m trying to do is possible:
<span ="Apple-tab-span" style="white-space:pre"> </span><go:DataTemplateDictionary x:Key="NodeTemplateDictionary" />
<DataTemplate x:Key="MiscFigureTemplate">
<StackPanel go:Part.SelectionElementName="Shape"
go:Part.SelectionAdorned="True"
go:Node.Rotatable="True"
go:Node.Resizable="True"
go:Node.LocationElementName="Shape">
<TextBlock Style="{StaticResource TextBlockStyle}"
Text="{Binding Path=Data.Text, Mode=TwoWay}"
HorizontalAlignment="Center" VerticalAlignment="Center" />
<go:NodePanel x:Name="Shape"
HorizontalAlignment="Center" VerticalAlignment="Center">
<Path Stroke="Black" StrokeThickness="{Binding Path=Data.PathStrokeThickness, Mode=TwoWay}" Stretch="Fill"
Data="{Binding Path=Data.PathData, Mode=TwoWay}"
go:Node.PortId="" Cursor="Hand"
go:Node.LinkableFrom="False" go:Node.LinkableTo="False">
</Path>
</go:NodePanel>
</StackPanel>
</DataTemplate>
...........
<go:Palette Grid.Row="0" x:Name="pMisc" NodeTemplate="{StaticResource PaletteNodeTemplate}" Template="{StaticResource DiagramTemplate}" MinHeight="100" Margin="15,20,0,0">
<go:Palette.LayoutManager>
<go:LayoutManager Animated="False" AnimationTime="0" />
</go:Palette.LayoutManager>
<go:Palette.Layout>
<golayout:GridLayout Sorting="Forward" CellSize="10 10" Spacing="25 25" />
</go:Palette.Layout>
</go:Palette>
DataTemplateDictionary dtd = Diagram.FindResource<DataTemplateDictionary>(this, "NodeTemplateDictionary");
dtd.Add("MiscFigureTemplate", Diagram.FindResource<DataTemplate>(this, "MiscFigureTemplate"));
..............
//Misc
var mpmodel = new GraphModel<MiscNode, String>();
mpmodel.NodesSource = new List<MiscNode>() {
<span ="Apple-tab-span" style="white-space:pre"> </span>new MiscNode() { Category="MiscFigureTemplate", Key="MeasurementTool", PathData="M130.5,0.5 L130.5,30.5 M0.5,15.5 L130.5,15.5 M0.5,30.5 L0.5,0.5", PathStrokeThickness="2"
<span ="Apple-tab-span" style="white-space:pre"> </span>},
};
mpmodel.Modifiable = true;
pMisc.TemplateApplied += (s, e) => { pMisc.Panel.ZoomTime = 0; };
pMisc.Model = mpmodel;
.............
public class MiscNode : GraphModelNodeData<String>
{
public string PathData { get; set; }
public string PathStrokeThickness { get; set; }
}