<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:graphsharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
xmlns:OverlapRemoval="clr-namespace:GraphSharp.Algorithms.OverlapRemoval;assembly=GraphSharp"
xmlns:zoom="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions"
xmlns:local="clr-namespace:AutoDiagrammer"
xmlns:CinchV2="clr-namespace:Cinch;assembly=Cinch.WPF"
xmlns:meffed="http:\\www.codeplex.com\MEFedMVVM"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="AutoDiagrammer.MainWindow"
x:Name="theView"
Background="{x:Null}"
Title="AutoDiagrammer"
Height="500"
Width="750"
MinHeight="500"
MinWidth="750"
WindowState="Maximized"
WindowStyle="ToolWindow"
Icon="../Images/logo.ico"
meffed:ViewModelLocator.ViewModel="MainWindowViewModel">
<Window.Resources>
<Style x:Key="TreeViewItemStyle" TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
<Setter Property="IsSelected" Value="{Binding IsInitiallySelected, Mode=OneTime}" />
<Setter Property="KeyboardNavigation.AcceptsReturn" Value="True" />
<Setter Property="local:VirtualToggleButton.IsVirtualToggleButton" Value="True" />
<Setter Property="local:VirtualToggleButton.IsChecked" Value="{Binding IsChecked}" />
</Style>
<Style x:Key="childVMImageStyle" TargetType="Image">
<Setter Property="Margin" Value="5,0" />
<Setter Property="Width" Value="20" />
<Setter Property="Height" Value="20" />
<Setter Property="Stretch" Value="Fill" />
<Style.Triggers>
<DataTrigger Binding="{Binding NodeType}" Value="AssemblyOrExe">
<Setter Property="Source" Value="../Images/AssemblyOrExe.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding NodeType}" Value="Class">
<Setter Property="Source" Value="../Images/Class.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding NodeType}" Value="Namespace">
<Setter Property="Source" Value="../Images/Namespace.png"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="childVMLabelStyle" TargetType="Label">
<Setter Property="Margin" Value="2,0" />
<Setter Property="Padding" Value="0" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Style.Triggers>
<DataTrigger Binding="{Binding NodeType}" Value="AssemblyOrExe">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
<HierarchicalDataTemplate x:Key="CheckBoxItemTemplate"
ItemsSource="{Binding Children, Mode=OneTime}">
<StackPanel Orientation="Horizontal">
<!-- These elements are bound to a FooViewModel object. -->
<CheckBox
Focusable="False"
IsChecked="{Binding IsChecked}"
VerticalAlignment="Center"/>
<Image Style="{StaticResource childVMImageStyle}"/>
<Label Content="{Binding Name, Mode=OneTime}"
Style="{StaticResource childVMLabelStyle}"/>
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type local:PocVertex}">
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Vertical" Background="Transparent">
<StackPanel.Visibility>
<MultiBinding Converter="{StaticResource HasDataAndShouldShowMultiConv}">
<Binding Path="HasInterfaces" />
<Binding Path="ShowInterfaces" Source="{x:Static local:SettingsViewModel.Instance}" />
</MultiBinding>
</StackPanel.Visibility>
<ListBox ItemsSource="{Binding Interfaces}"
Style="{StaticResource TransparentListBoxStyle}"
IsEnabled="False" BorderThickness="0"
Background="Transparent" Foreground="Black"/>
<Ellipse Fill="White" Stroke="Black" StrokeThickness="3" Width="20" Height="20"
VerticalAlignment="Stretch" HorizontalAlignment="Center" Margin="0" />
<Rectangle Stroke="Transparent" StrokeThickness="0" Fill="Black" Width="4"
Height="15" VerticalAlignment="Stretch" HorizontalAlignment="Center" />
</StackPanel>
<Border Grid.Row="1"
BorderBrush="Black"
Background="White"
BorderThickness="5"
CornerRadius="10,10,10,10">
<Border.Effect>
<DropShadowEffect BlurRadius="2" Color="LightGray"
Opacity="0.3" Direction="315"/>
</Border.Effect>
<Grid x:Name="vertexGrid">
<Border Background="White"
x:Name="vertBord"
BorderThickness="0"
Margin="0"
CornerRadius="10,10,10,10">
<StackPanel Orientation="Vertical">
<Border CornerRadius="5,5,0,0" Background="Black">
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}" Foreground="White"
VerticalAlignment="Center" VerticalContentAlignment="Center"
FontSize="14" FontWeight="Bold"/>
<ToggleButton x:Name="toggler" Tag="../Images/Associations.png"
IsThreeState="False" Width="25" Height="25"
Style="{StaticResource SimpleImageButtonStyle}"
ToolTip="Show Associations For This Class"
IsChecked="False"/>
</StackPanel>
</Border>
<local:ExpanderEx IsExpanded="{Binding CollapseConstructors}" Header="Constructors"
Style="{StaticResource GenericExpanderStyle}"
Visibility="{Binding Path=HasConstructors, Converter={StaticResource BoolToVisConv}, ConverterParameter='True'}">
<ListBox ItemsSource="{Binding Constructors}"
IsEnabled="True" BorderThickness="0"
Style="{StaticResource TransparentListBoxStyle}"/>
</local:ExpanderEx>
<local:ExpanderEx IsExpanded="{Binding CollapseFields}" Header="Fields"
Style="{StaticResource GenericExpanderStyle}">
<local:ExpanderEx.Visibility>
<MultiBinding Converter="{StaticResource HasDataAndShouldShowMultiConv}">
<Binding Path="HasFields" />
<Binding Path="ShowFieldTypes" Source="{x:Static local:SettingsViewModel.Instance}" />
</MultiBinding>
</local:ExpanderEx.Visibility>
<ListBox ItemsSource="{Binding Fields}" IsEnabled="True"
BorderThickness="0"
Style="{StaticResource TransparentListBoxStyle}"/>
</local:ExpanderEx>
<local:ExpanderEx IsExpanded="{Binding CollapseProperties}" Header="Properties"
Style="{StaticResource GenericExpanderStyle}">
<local:ExpanderEx.Visibility>
<MultiBinding Converter="{StaticResource HasDataAndShouldShowMultiConv}">
<Binding Path="HasProperties" />
<Binding Path="ShowPropertyTypes" Source="{x:Static local:SettingsViewModel.Instance}" />
</MultiBinding>
</local:ExpanderEx.Visibility>
<ListBox ItemsSource="{Binding Properties}" IsEnabled="True"
BorderThickness="0"
Style="{StaticResource TransparentListBoxStyle}"/>
</local:ExpanderEx>
<local:ExpanderEx IsExpanded="{Binding CollapseMethods}" Header="Methods"
Style="{StaticResource GenericExpanderStyle}"
Visibility="{Binding Path=HasMethods, Converter={StaticResource BoolToVisConv}, ConverterParameter='True'}">
<ListBox ItemsSource="{Binding Methods}" IsEnabled="True"
BorderThickness="0"
ItemTemplate="{StaticResource MethodItemTemplate}"
Style="{StaticResource TransparentListBoxStyle}"/>
</local:ExpanderEx>
<local:ExpanderEx IsExpanded="{Binding CollapseEvents}" Header="Events"
Style="{StaticResource GenericExpanderStyle}"
Margin="0,0,0,20">
<local:ExpanderEx.Visibility>
<MultiBinding Converter="{StaticResource HasDataAndShouldShowMultiConv}">
<Binding Path="HasEvents" />
<Binding Path="ShowPropertyTypes" Source="{x:Static local:SettingsViewModel.Instance}" />
</MultiBinding>
</local:ExpanderEx.Visibility>
<ListBox ItemsSource="{Binding Events}" IsEnabled="True"
BorderThickness="0"
Style="{StaticResource TransparentListBoxStyle}"/>
</local:ExpanderEx>
</StackPanel>
</Border>
<Popup x:Name="popupVertexAssociations"
PlacementTarget="{Binding ElementName=vertBord}"
Placement="Relative"
IsOpen="{Binding ElementName=toggler, Path=IsChecked}"
Width="400" Height="225"
AllowsTransparency="True"
StaysOpen="False"
PopupAnimation="Scroll"
HorizontalAlignment="Right"
RenderTransformOrigin="0.5, 0.5"
HorizontalOffset="30"
VerticalOffset="30" >
<Popup.RenderTransform>
<ScaleTransform CenterX="0.5" CenterY="0.5"
ScaleX="{Binding ElementName=theView, Path=ReciprocalZoom, Mode=OneWay}"
ScaleY="{Binding ElementName=theView, Path=ReciprocalZoom, Mode=OneWay}"/>
</Popup.RenderTransform>
<Border Background="Transparent" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderBrush="#FF000000"
BorderThickness="3"
CornerRadius="5,5,5,5">
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Thumb Grid.Row="0" Width="Auto" Height="40"
Tag="{Binding ElementName=popupVertexAssociations}"
local:PopupBehaviours.IsMoveEnabledProperty="true">
<Thumb.Template>
<ControlTemplate>
<Border Width="Auto" Height="40" BorderBrush="Black"
Background="Black" VerticalAlignment="Top"
CornerRadius="5,5,0,0" Margin="-2,-2,-2,0">
<Label Content="Associations"
FontSize="12"
FontWeight="Bold"
Foreground="White"
VerticalContentAlignment="Center"
Margin="5,0,0,0" />
</Border>
</ControlTemplate>
</Thumb.Template>
</Thumb>
<TextBox Grid.Row="1" IsReadOnly="True"
BorderBrush="Transparent"
Text="{Binding AssociationToolTip, Mode=OneWay}"
AcceptsReturn="True" TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"/>
</Grid>
</Border>
</Popup>
</Grid>
</Border>
</Grid>
</DataTemplate>
<Style TargetType="{x:Type graphsharp:VertexControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type graphsharp:VertexControl}">
<ContentControl Content="{TemplateBinding Vertex}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type graphsharp:EdgeControl}">
<Style.Resources>
<ToolTip x:Key="ToolTipContent">
<StackPanel>
<TextBlock FontWeight="Bold" Text="Edge Information"/>
<TextBlock Text="{Binding ID}"/>
</StackPanel>
</ToolTip>
</Style.Resources>
<Setter Property="ToolTip" Value="{StaticResource ToolTipContent}"/>
</Style>
<DataTemplate x:Key="NonAssociatedVertexTemplate" DataType="{x:Type local:PocVertex}">
<Label Content="{Binding ShortName}" VerticalAlignment="Center"
VerticalContentAlignment="Center" Padding="0" Margin="0"/>
</DataTemplate>
</Window.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing">
<i:InvokeCommandAction Command="{Binding SaveSettingsAsXmlCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid Background="#ffdddddd">
<Grid.RowDefinitions>
<RowDefinition Height="64.985"/>
<RowDefinition Height="2"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" HorizontalAlignment="Stretch" Background="SteelBlue"
AllowDrop="True" DragOver="MainWindow_DragOver" Drop="MainWindow_Drop">
<local:FishEyePanel Width="250" Height="40" Magnification="3" HorizontalAlignment="Right">
<Button Tag="../Images/open.png" Style="{StaticResource SimpleImageButtonStyle}" ToolTip="Open Dll/Exe" Width="25" Height="25" Margin="5" Command="{Binding OpenFileCommand}"/>
<Button Tag="../Images/print.png" Style="{StaticResource SimpleImageButtonStyle}" ToolTip="Print" Width="25" Height="25" Margin="5" Command="{Binding PrintFileCommand}"/>
<Button Tag="../Images/save.png" Style="{StaticResource SimpleImageButtonStyle}" ToolTip="Save As PNG" Width="25" Height="25" Margin="5" Command="{Binding SaveCommand}"/>
<Button Tag="../Images/settings.png" Style="{StaticResource SimpleImageButtonStyle}" ToolTip="Settings" Width="25" Height="25" Margin="5" Command="{Binding ShowSettingsWindowCommand}"/>
<Button Tag="../Images/relayout.png" Style="{StaticResource SimpleImageButtonStyle}" ToolTip="Re-Layout Graph" Width="25" Height="25" Margin="5" Command="{Binding ReLayoutCommand}"/>
<Button Tag="../Images/information.png" Style="{StaticResource SimpleImageButtonStyle}" ToolTip="About" Width="25" Height="25" Margin="5" Command="{Binding AboutCommand}"/>
<Button Tag="../Images/Help.png" Style="{StaticResource SimpleImageButtonStyle}" ToolTip="Help" Width="25" Height="25" Margin="5" Command="{Binding HelpCommand}"/>
</local:FishEyePanel>
<StackPanel Orientation="Horizontal">
<Image Source="../Images/logo.ico" Width="40" Height="40" Margin="10"
VerticalAlignment="Center" >
<Image.Effect>
<DropShadowEffect ShadowDepth="0" BlurRadius="12" Color="Black"/>
</Image.Effect>
</Image>
<Label Content="AutoDiagrammer" FontFamily="Verdana" FontSize="26.667"
FontWeight="Bold" Foreground="#FFDDDDDD"
VerticalContentAlignment="Center" HorizontalAlignment="Left">
<Label.Effect>
<DropShadowEffect ShadowDepth="0" BlurRadius="12" Color="Black"/>
</Label.Effect>
</Label>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Background="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<local:AsyncHost AsyncState="{Binding Path=MainAsyncState, Mode=OneWay}" Grid.Row="2"
AllowDrop="True" DragOver="MainWindow_DragOver" Drop="MainWindow_Drop">
<Grid x:Name="mainContent" local:AsyncHost.AsyncContentType="Content"
Visibility="{Binding Path=HasActiveAssembly,
Converter={StaticResource BoolToVisConv},
ConverterParameter='true'}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Tag="../Images/draw.png" Style="{StaticResource SimpleImageButtonStyle}"
ToolTip="Select Tree Node(s) Then Click Me" Width="25" Height="25" Margin="5"
Command="{Binding CommenceDrawingCommand}"/>
<Label Content="Select Tree Node(s) Then Click Icon" VerticalContentAlignment="Center"
VerticalAlignment="Center" FontWeight="Bold"/>
</StackPanel>
<Border CornerRadius="10" Grid.Row="1"
Background="LightGray"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TreeView x:Name="tree" Grid.Row="1" Grid.Column="0" BorderThickness="0"
Margin="10"
ItemContainerStyle="{StaticResource TreeViewItemStyle}"
ItemsSource="{Binding Path=TreeValues}"
ItemTemplate="{StaticResource CheckBoxItemTemplate}">
<TreeView.Resources>
<SolidColorBrush Color="SteelBlue" x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
</TreeView.Resources>
</TreeView>
</Border>
</Grid>
<GridSplitter Grid.Column="1"
HorizontalAlignment="Stretch"
ResizeBehavior="PreviousAndNext"
ResizeDirection="Columns"
Cursor="SizeWE"
Background="White"
Style="{DynamicResource CollapsibleGridSplitterStyle}" />
<local:AsyncHost AsyncState="{Binding Path=DrawerAsyncState, Mode=OneWay}"
Grid.Column="2" >
<Grid local:AsyncHost.AsyncContentType="Content">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Toggle All Expanders Within Classes"
Command="{Binding CollapseVertexRegionsCommand}"
CommandParameter="All"/>
<MenuItem Header="Toggle All Constructor Expanders For Classes"
Command="{Binding CollapseVertexRegionsCommand}"
CommandParameter="Constructors"/>
<MenuItem Header="Toggle All Fields Expanders For Classes"
Command="{Binding CollapseVertexRegionsCommand}"
CommandParameter="Fields"/>
<MenuItem Header="Toggle All Properties Expanders For Classes"
Command="{Binding CollapseVertexRegionsCommand}"
CommandParameter="Properties"/>
<MenuItem Header="Toggle All Methods Expanders For Classes"
Command="{Binding CollapseVertexRegionsCommand}"
CommandParameter="Methods"/>
<MenuItem Header="Toggle All Events Expanders For Classes"
Command="{Binding CollapseVertexRegionsCommand}"
CommandParameter="Events"/>
</ContextMenu>
</Grid.ContextMenu>
<zoom:ZoomControl x:Name="zoomControl" Zoom="0.2"
ZoomBoxOpacity="0.5" Background="#ffdddddd">
<ContentPresenter x:Name="graphLayout" Content="{Binding GraphLayout}" />
</zoom:ZoomControl>
<Border Width="Auto" Height="35"
VerticalAlignment="Top"
CornerRadius="0,0,20,20"
Background="White"
HorizontalAlignment="Right"
Margin="0,0,50,0"
Visibility="{Binding HasNotAssociatedVertices, Converter={StaticResource BoolToVisConv}, ConverterParameter='True'}">
<StackPanel Orientation="Horizontal" Margin="20,0,20,0">
<Label Content="Non Associated Items" VerticalAlignment="Center"
VerticalContentAlignment="Center" Foreground="Black"
Padding="0" Margin="0" FontWeight="Bold"
Height="25"/>
<ComboBox ItemsSource="{Binding NotAssociatedVertices}"
MinWidth="300" Padding="0" Margin="10,0,0,0" Height="25"
SelectedItem="{Binding SelectedNotAssociatedVertex}"
ItemTemplate="{StaticResource NonAssociatedVertexTemplate}"/>
<Button Tag="../Images/mag.png" Style="{StaticResource SimpleImageButtonStyle}" ToolTip="Show This Class"
Width="20" Height="20" Margin="10,0,10,0" Command="{Binding ShowSpecificNotAssociatedVertexCommand}"/>
</StackPanel>
</Border>
</Grid>
<Border local:AsyncHost.AsyncContentType="Busy" Visibility="Hidden"
BorderBrush="White" BorderThickness="3" Height="60" Width="Auto"
VerticalAlignment="Center" HorizontalAlignment="Center" CornerRadius="15">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF4B4B4B"/>
<GradientStop Color="#FF1B1B1B" Offset="0.5"/>
<GradientStop Color="Black" Offset="0.506"/>
</LinearGradientBrush>
</Border.Background>
<Label Content="Busy Creating Class Diagram...Please Wait" Foreground="White"
FontSize="20" FontFamily="Verdana" VerticalAlignment="Center"
VerticalContentAlignment="Center" HorizontalAlignment="Center"
HorizontalContentAlignment="Center" Margin="20,10,20,10"/>
</Border>
<local:AsyncFailedUserControl
local:AsyncHost.AsyncContentType="Error"
Error="{Binding Path=DrawerErrorText, Mode=OneWay}"
Visibility="Hidden" />
</local:AsyncHost>
</Grid>
<Border local:AsyncHost.AsyncContentType="Busy" Visibility="Hidden"
BorderBrush="White" BorderThickness="3" Height="60" Width="Auto"
VerticalAlignment="Center" HorizontalAlignment="Center" CornerRadius="15">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF4B4B4B"/>
<GradientStop Color="#FF1B1B1B" Offset="0.5"/>
<GradientStop Color="Black" Offset="0.506"/>
</LinearGradientBrush>
</Border.Background>
<Label Content="Busy Reading Dll/Exe Class Data...Please Wait" Foreground="White"
FontSize="20" FontFamily="Verdana" VerticalAlignment="Center"
VerticalContentAlignment="Center" HorizontalAlignment="Center"
HorizontalContentAlignment="Center" Margin="20,10,20,10"/>
</Border>
<local:AsyncFailedUserControl
local:AsyncHost.AsyncContentType="Error"
Error="{Binding Path=MainErrorText, Mode=OneWay}"
Visibility="Hidden" />
</local:AsyncHost>
</Grid>
</Window>