88 lines
5.7 KiB
XML
88 lines
5.7 KiB
XML
<UserControl x:Class="NodeNetwork.Views.NetworkView"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:local="clr-namespace:NodeNetwork.Views"
|
|
xmlns:controls="clr-namespace:NodeNetwork.Views.Controls"
|
|
xmlns:reactiveUi="http://reactiveui.net"
|
|
xmlns:viewModels="clr-namespace:NodeNetwork.ViewModels"
|
|
xmlns:wpf="clr-namespace:NodeNetwork.Utilities.WPF"
|
|
mc:Ignorable="d"
|
|
d:DesignHeight="500" d:DesignWidth="800" Focusable="True" AllowDrop="True" x:Name="self" Background="#333">
|
|
<UserControl.InputBindings>
|
|
<KeyBinding x:Name="deleteBinding" Key="Delete"/>
|
|
</UserControl.InputBindings>
|
|
<UserControl.Resources>
|
|
<wpf:BoolToZIndexConverter x:Key="BoolToZIndexConverter"/>
|
|
</UserControl.Resources>
|
|
<Grid Focusable="True" KeyboardNavigation.IsTabStop="False">
|
|
<controls:DragCanvas Zoom="DragCanvas_OnZoom" x:Name="dragCanvas" MouseLeftButtonDown="OnClickCanvas" Background="#01000000">
|
|
<Canvas Name="contentContainer" LayoutUpdated="ContentContainer_OnLayoutUpdated" Width="{Binding ActualWidth, ElementName=dragCanvas}" Height="{Binding ActualHeight, ElementName=dragCanvas}">
|
|
<Canvas.Clip>
|
|
<RectangleGeometry x:Name="clippingGeometry"/>
|
|
</Canvas.Clip>
|
|
|
|
<!-- Bit of a hack, but this allows backgrounds that move with the nodes and connections.
|
|
Had to use a separate giant canvas because contentContainer is actually pretty small and any control higher won't have the image moving properly.
|
|
-->
|
|
<Canvas Name="backgroundCanvas" IsHitTestVisible="False" Width="1E15" Height="1E15" Canvas.Left="-1E6" Canvas.Top="-1E6" Background="{Binding NetworkBackground, ElementName=self}"/>
|
|
|
|
<ItemsControl x:Name="connectionsControl" Width="{Binding ActualWidth, ElementName=contentContainer}" Height="{Binding ActualHeight, ElementName=contentContainer}" IsTabStop="False">
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate>
|
|
<controls:ViewModelViewHostNoAnimations ViewModel="{Binding}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" IsTabStop="False"/>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
<ItemsControl.ItemsPanel>
|
|
<ItemsPanelTemplate>
|
|
<Canvas></Canvas>
|
|
</ItemsPanelTemplate>
|
|
<!-- Stop connections from stacking -->
|
|
</ItemsControl.ItemsPanel>
|
|
</ItemsControl>
|
|
|
|
<ItemsControl x:Name="nodesControl" Width="{Binding ActualWidth, ElementName=contentContainer}" Height="{Binding ActualHeight, ElementName=contentContainer}" IsTabStop="False">
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate DataType="viewModels:NodeViewModel">
|
|
<Canvas>
|
|
<!-- When modifying, check the comment in NetworkView.OnNodeDragStart -->
|
|
<Thumb DragStarted="OnNodeDragStart" DragDelta="OnNodeDrag" DragCompleted="OnNodeDragEnd" Canvas.Left="{Binding Path=Position.X}" Canvas.Top="{Binding Path=Position.Y}">
|
|
<Thumb.Template>
|
|
<ControlTemplate>
|
|
<controls:ViewModelViewHostNoAnimations ViewModel="{Binding}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" IsTabStop="False"/>
|
|
</ControlTemplate>
|
|
</Thumb.Template>
|
|
</Thumb>
|
|
</Canvas>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
<ItemsControl.ItemContainerStyle>
|
|
<Style TargetType="{x:Type ContentPresenter}">
|
|
<Style.Setters>
|
|
<Setter Property="Panel.ZIndex" Value="{Binding Path=IsSelected, Converter={StaticResource BoolToZIndexConverter}}"/>
|
|
</Style.Setters>
|
|
</Style>
|
|
</ItemsControl.ItemContainerStyle>
|
|
</ItemsControl>
|
|
|
|
<Line x:Name="cutLine" Stroke="LightGray" StrokeDashArray="2, 4" StrokeThickness="1" />
|
|
|
|
<Rectangle x:Name="selectionRectangle" Stroke="White" Fill="Transparent" StrokeDashArray="2, 4" StrokeThickness="1"/>
|
|
|
|
<controls:ViewModelViewHostNoAnimations x:Name="pendingConnectionView" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" IsTabStop="False"/>
|
|
|
|
<controls:ViewModelViewHostNoAnimations x:Name="pendingNodeView" Opacity="0.5" IsTabStop="False"/>
|
|
</Canvas>
|
|
</controls:DragCanvas>
|
|
|
|
<Popup x:Name="messagePopup" Placement="Top" StaysOpen="True" HorizontalAlignment="Right">
|
|
<reactiveUi:ViewModelViewHost Name="messagePopupHost" IsTabStop="False"/>
|
|
</Popup>
|
|
|
|
<Border Name="messageHostBorder" Background="#EEE" CornerRadius="5" HorizontalAlignment="Center" VerticalAlignment="Top" Padding="10, 10, 10, 10" Margin="20">
|
|
<reactiveUi:ViewModelViewHost Name="messageHost" IsTabStop="False"/>
|
|
</Border>
|
|
</Grid>
|
|
</UserControl>
|