Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

WPF Diagram Designer - Part 2

, 8 Oct 2008
Designer Canvas with Zoombox
DiagramDesignerPart2.zip
DiagramDesigner
Adorners
bin
Debug
DiagramDesigner.exe
DiagramDesigner.csproj.user
Images
attention.png
chart1.png
chart2.png
chart3.png
cross.png
mail.png
new.png
newBold.png
nuclear.png
plus.png
ring.png
rotateLeft.png
rotateRight.png
rt1.png
rt2.png
rt3.png
rt4.png
rt5.png
rt6.png
software.png
walk.png
world.png
Properties
Settings.settings
Resources
Stencils
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="ToggleButtonStyle"
           TargetType="ToggleButton">
        <Setter Property="SnapsToDevicePixels"
                Value="true" />
        <Setter Property="OverridesDefaultStyle"
                Value="true" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Border x:Name="Border"
                            CornerRadius="2"
                            BorderThickness="1"
                            Background="{StaticResource NormalBrush}"
                            BorderBrush="{StaticResource NormalBorderBrush}">
                        <ContentPresenter Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="true">
                            <Setter TargetName="Border"
                                    Property="Background"
                                    Value="{StaticResource DarkBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed"
                                 Value="true">
                            <Setter TargetName="Border"
                                    Property="Background"
                                    Value="{StaticResource PressedBrush}" />
                            <Setter TargetName="Border"
                                    Property="BorderBrush"
                                    Value="{StaticResource PressedBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Expander">
        <Setter Property="Padding"
                Value="8" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Expander">
                    <DockPanel>
                        <ToggleButton Style="{StaticResource ToggleButtonStyle}"
                                      DockPanel.Dock="Top"
                                      IsChecked="{Binding Path=IsExpanded,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                      HorizontalContentAlignment="Left"
                                      VerticalContentAlignment="Center">
                            <ToggleButton.Content>
                                <StackPanel Orientation="Horizontal">
                                    <Path SnapsToDevicePixels="True"
                                          Name="Arrow"
                                          Margin="8,0,8,0"
                                          Fill="{TemplateBinding Foreground}"
                                          Stroke="{TemplateBinding Foreground}"
                                          StrokeThickness="0.5"
                                          RenderTransformOrigin="0.5,0.5"
                                          HorizontalAlignment="Right"
                                          VerticalAlignment="Center"
                                          Data="M 0 0 L 0 8 L 5 4 Z">
                                        <Path.RenderTransform>
                                            <RotateTransform Angle="0" />
                                        </Path.RenderTransform>
                                    </Path>
                                    <ContentPresenter Name="HeaderContent"
                                                      Margin="4"
                                                      ContentSource="Header" />
                                </StackPanel>
                            </ToggleButton.Content>
                        </ToggleButton>
                        <Border Name="Content"
                                BorderThickness="1,0,1,1"
                                BorderBrush="{StaticResource NormalBorderBrush}"
                                Background="{TemplateBinding Background}"
                                CornerRadius="0,0,1,1"
                                SnapsToDevicePixels="True">
                            <Border.LayoutTransform>
                                <ScaleTransform ScaleY="0" />
                            </Border.LayoutTransform>
                            <ContentPresenter Content="{TemplateBinding Content}"
                                              ToolTipService.IsEnabled="False" />
                        </Border>
                    </DockPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Expander.IsExpanded"
                                 Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Content"
                                                         Storyboard.TargetProperty="LayoutTransform.ScaleY"
                                                         To="1"
                                                         Duration="0:0:0.5" />
                                        <DoubleAnimation Storyboard.TargetName="Content"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0:0:0.5" />
                                        <DoubleAnimation Storyboard.TargetName="Arrow"
                                                         Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)"
                                                         Duration="0:0:0.2"
                                                         To="90"
                                                         DecelerationRatio="1" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Content"
                                                         Storyboard.TargetProperty="LayoutTransform.ScaleY"
                                                         To="0"
                                                         Duration="0:0:0.5" />
                                        <DoubleAnimation Storyboard.TargetName="Content"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0"
                                                         Duration="0:0:0.5" />
                                        <DoubleAnimation Storyboard.TargetName="Arrow"
                                                         Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)"
                                                         Duration="0:0:0.2"
                                                         AccelerationRatio="1" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</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)

Share

About the Author

sukram

Austria Austria
No Biography provided

| Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 8 Oct 2008
Article Copyright 2008 by sukram
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid