Click here to Skip to main content
15,879,326 members
Articles / Desktop Programming / WPF

WPF Diagram Designer - Part 4

Rate me:
Please Sign up or sign in to vote.
4.97/5 (243 votes)
26 Mar 2008CPOL6 min read 1.1M   39.6K   515  
A Frankenbuild
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:s="clr-namespace:DiagramDesigner"
                    xmlns:c="clr-namespace:DiagramDesigner.Controls">

  <RadialGradientBrush x:Key="RadialBrushOrange" Center="0.2, 0.2" GradientOrigin="0.2, 0.2" RadiusX="0.8" RadiusY="0.8">
    <GradientStop Color="White" Offset="0"/>
    <GradientStop Color="Orange" Offset="0.9"/>
  </RadialGradientBrush>

  <RadialGradientBrush x:Key="RadialBrushGreen" Center="0.2, 0.2" GradientOrigin="0.2, 0.2" RadiusX="0.8" RadiusY="0.8">
    <GradientStop Color="White" Offset="0"/>
    <GradientStop Color="Green" Offset="0.9"/>
  </RadialGradientBrush>

  <RadialGradientBrush x:Key="RadialBrushBlue" Center="0.2, 0.2" GradientOrigin="0.2, 0.2" RadiusX="0.8" RadiusY="0.8">
    <GradientStop Color="White" Offset="0"/>
    <GradientStop Color="Blue" Offset="0.9"/>
  </RadialGradientBrush>

  <LinearGradientBrush x:Key="BrushStar" StartPoint="0,0" EndPoint="0,1" Opacity="1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#FAFBE9" Offset="0.1" />
      <GradientStop Color="Orange" Offset="1" />
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush>

  <s:Toolbox x:Key="ShapeStencils" ItemSize="60,60">
    <ItemsControl.Items>

      <Ellipse Fill="{StaticResource RadialBrushOrange}" ToolTip="Ellipse" IsHitTestVisible="false"/>
      <Ellipse Fill="{StaticResource RadialBrushBlue}" ToolTip="Ellipse" IsHitTestVisible="false"/>
      <Ellipse Fill="{StaticResource RadialBrushGreen}" ToolTip="Ellipse" IsHitTestVisible="false"/>

      <Path Stretch="Fill" IsHitTestVisible="false"
            StrokeLineJoin="Round"
            Fill="{StaticResource BrushStar}"
            Stroke="#AAFF8C00"
            StrokeThickness="3"
            Data="M 9,2 11,7 17,7 12,10 14,15 9,12 4,15 6,10 1,7 7,7 Z">
        <s:DesignerItem.DragThumbTemplate>
          <ControlTemplate>
            <Path Fill="Transparent" Stretch="Fill" Data="M 9,2 11,7 17,7 12,10 14,15 9,12 4,15 6,10 1,7 7,7 Z"/>
          </ControlTemplate>
        </s:DesignerItem.DragThumbTemplate>
        <s:DesignerItem.ConnectorDecoratorTemplate>
          <ControlTemplate>
            <c:RelativePositionPanel Margin="-4">
              <s:Connector x:Name="Top1" Orientation="Top" c:RelativePositionPanel.RelativePosition="0.5,0"/>
              <s:Connector x:Name="Top2" Orientation="Left" c:RelativePositionPanel.RelativePosition="0,0.385"/>
              <s:Connector x:Name="Top3" Orientation="Right" c:RelativePositionPanel.RelativePosition="1,0.385"/>
              <s:Connector x:Name="Top4" Orientation="Bottom" c:RelativePositionPanel.RelativePosition="0.185,1"/>
              <s:Connector x:Name="Top5" Orientation="Bottom" c:RelativePositionPanel.RelativePosition="0.815,1"/>
            </c:RelativePositionPanel>
          </ControlTemplate>
        </s:DesignerItem.ConnectorDecoratorTemplate>
      </Path>

    </ItemsControl.Items>
  </s:Toolbox>
</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions