Skip to content

Commit

Permalink
Add TraitView
Browse files Browse the repository at this point in the history
  • Loading branch information
tylercamp committed Apr 20, 2024
1 parent b49c3f2 commit 763909e
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 3 deletions.
6 changes: 6 additions & 0 deletions PalCalc.UI/PalCalc.UI.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<Compile Update="View\SolverControlsView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="View\TraitView.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
Expand All @@ -54,5 +57,8 @@
<Page Update="View\SolverControlsView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="View\TraitView.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>
19 changes: 16 additions & 3 deletions PalCalc.UI/View/BreedingResultView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@
<UserControl.Resources>
<DataTemplate x:Key="DemoTemplate" DataType="{x:Type m:BreedingTreeNodeViewModel}">
<StackPanel Orientation="Horizontal" Margin="5">
<Image Source="{Binding Pal.Icon}" />

<TextBlock Text="{Binding Value.Description}" Foreground="White" />
<Border Width="50" Height="50" CornerRadius="25" BorderThickness="1" BorderBrush="White" Margin="0,0,5,0">
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="{Binding Pal.Icon}" />
</Border.Background>
</Border>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Gender}" Foreground="White" />
<TextBlock Text="{Binding Location.Description}" Foreground="White" />
<ItemsControl ItemsSource="{Binding Traits}" Background="Black" Foreground="Black" BorderThickness="0" Margin="0,0,0,0">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="vm:TraitViewModel">
<local:TraitView DataContext="{Binding}" MinWidth="100" Margin="0,2,0,0" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</StackPanel>
</DataTemplate>

Expand Down
47 changes: 47 additions & 0 deletions PalCalc.UI/View/TraitView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<UserControl x:Class="PalCalc.UI.View.TraitView"
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:PalCalc.UI.View"
xmlns:vm="clr-namespace:PalCalc.UI.ViewModel"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:TraitViewModel, IsDesignTimeCreatable=True}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" VerticalAlignment="Stretch">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding RankColor}" />
</Rectangle.Fill>
</Rectangle>
<Border Grid.Column="2" BorderThickness="0,1,1,1">
<Border.BorderBrush>
<SolidColorBrush Color="{Binding RankColor}" Opacity="0.5" />
</Border.BorderBrush>
</Border>
<Grid Grid.Column="1" Margin="5,2,2,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Viewbox StretchDirection="DownOnly" Stretch="Uniform">
<TextBlock Grid.Column="0" Text="{Binding Name}" Height="14" FontSize="10" VerticalAlignment="Center" Foreground="White" />
</Viewbox>
<Grid Grid.Column="2" Margin="10,0,0,0">
<Rectangle Width="12" Height="12">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding RankColor}" />
</Rectangle.Fill>
<Rectangle.OpacityMask>
<ImageBrush ImageSource="{Binding RankIcon}" />
</Rectangle.OpacityMask>
</Rectangle>
</Grid>
</Grid>
</Grid>
</UserControl>
28 changes: 28 additions & 0 deletions PalCalc.UI/View/TraitView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PalCalc.UI.View
{
/// <summary>
/// Interaction logic for TraitView.xaml
/// </summary>
public partial class TraitView : UserControl
{
public TraitView()
{
InitializeComponent();
}
}
}
6 changes: 6 additions & 0 deletions PalCalc.UI/ViewModel/MappedViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public class TraitViewModel
{ 3, new Color() { R = 255, G = 221, B = 0, A = 255 } },
};

// for XAML designer view
public TraitViewModel()
{
ModelObject = new Trait("Runner", "runner", 2);
}

public TraitViewModel(Trait trait)
{
ModelObject = trait;
Expand Down

0 comments on commit 763909e

Please sign in to comment.