Skip to content

Commit 763909e

Browse files
committed
Add TraitView
1 parent b49c3f2 commit 763909e

File tree

5 files changed

+103
-3
lines changed

5 files changed

+103
-3
lines changed

PalCalc.UI/PalCalc.UI.csproj.user

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
<Compile Update="View\SolverControlsView.xaml.cs">
2929
<SubType>Code</SubType>
3030
</Compile>
31+
<Compile Update="View\TraitView.xaml.cs">
32+
<SubType>Code</SubType>
33+
</Compile>
3134
</ItemGroup>
3235
<ItemGroup>
3336
<Page Update="MainWindow.xaml">
@@ -54,5 +57,8 @@
5457
<Page Update="View\SolverControlsView.xaml">
5558
<SubType>Designer</SubType>
5659
</Page>
60+
<Page Update="View\TraitView.xaml">
61+
<SubType>Designer</SubType>
62+
</Page>
5763
</ItemGroup>
5864
</Project>

PalCalc.UI/View/BreedingResultView.xaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,22 @@
1616
<UserControl.Resources>
1717
<DataTemplate x:Key="DemoTemplate" DataType="{x:Type m:BreedingTreeNodeViewModel}">
1818
<StackPanel Orientation="Horizontal" Margin="5">
19-
<Image Source="{Binding Pal.Icon}" />
20-
21-
<TextBlock Text="{Binding Value.Description}" Foreground="White" />
19+
<Border Width="50" Height="50" CornerRadius="25" BorderThickness="1" BorderBrush="White" Margin="0,0,5,0">
20+
<Border.Background>
21+
<ImageBrush Stretch="Fill" ImageSource="{Binding Pal.Icon}" />
22+
</Border.Background>
23+
</Border>
24+
<StackPanel Orientation="Vertical">
25+
<TextBlock Text="{Binding Gender}" Foreground="White" />
26+
<TextBlock Text="{Binding Location.Description}" Foreground="White" />
27+
<ItemsControl ItemsSource="{Binding Traits}" Background="Black" Foreground="Black" BorderThickness="0" Margin="0,0,0,0">
28+
<ItemsControl.ItemTemplate>
29+
<DataTemplate DataType="vm:TraitViewModel">
30+
<local:TraitView DataContext="{Binding}" MinWidth="100" Margin="0,2,0,0" />
31+
</DataTemplate>
32+
</ItemsControl.ItemTemplate>
33+
</ItemsControl>
34+
</StackPanel>
2235
</StackPanel>
2336
</DataTemplate>
2437

PalCalc.UI/View/TraitView.xaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<UserControl x:Class="PalCalc.UI.View.TraitView"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:PalCalc.UI.View"
7+
xmlns:vm="clr-namespace:PalCalc.UI.ViewModel"
8+
mc:Ignorable="d"
9+
d:DataContext="{d:DesignInstance vm:TraitViewModel, IsDesignTimeCreatable=True}">
10+
<Grid>
11+
<Grid.ColumnDefinitions>
12+
<ColumnDefinition Width="4" />
13+
<ColumnDefinition Width="*" />
14+
</Grid.ColumnDefinitions>
15+
<Rectangle Grid.Column="0" VerticalAlignment="Stretch">
16+
<Rectangle.Fill>
17+
<SolidColorBrush Color="{Binding RankColor}" />
18+
</Rectangle.Fill>
19+
</Rectangle>
20+
<Border Grid.Column="2" BorderThickness="0,1,1,1">
21+
<Border.BorderBrush>
22+
<SolidColorBrush Color="{Binding RankColor}" Opacity="0.5" />
23+
</Border.BorderBrush>
24+
</Border>
25+
<Grid Grid.Column="1" Margin="5,2,2,2">
26+
<Grid.ColumnDefinitions>
27+
<ColumnDefinition Width="Auto" />
28+
<ColumnDefinition Width="*" />
29+
<ColumnDefinition Width="Auto" />
30+
</Grid.ColumnDefinitions>
31+
32+
<Viewbox StretchDirection="DownOnly" Stretch="Uniform">
33+
<TextBlock Grid.Column="0" Text="{Binding Name}" Height="14" FontSize="10" VerticalAlignment="Center" Foreground="White" />
34+
</Viewbox>
35+
<Grid Grid.Column="2" Margin="10,0,0,0">
36+
<Rectangle Width="12" Height="12">
37+
<Rectangle.Fill>
38+
<SolidColorBrush Color="{Binding RankColor}" />
39+
</Rectangle.Fill>
40+
<Rectangle.OpacityMask>
41+
<ImageBrush ImageSource="{Binding RankIcon}" />
42+
</Rectangle.OpacityMask>
43+
</Rectangle>
44+
</Grid>
45+
</Grid>
46+
</Grid>
47+
</UserControl>

PalCalc.UI/View/TraitView.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace PalCalc.UI.View
17+
{
18+
/// <summary>
19+
/// Interaction logic for TraitView.xaml
20+
/// </summary>
21+
public partial class TraitView : UserControl
22+
{
23+
public TraitView()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

PalCalc.UI/ViewModel/MappedViewModels.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ public class TraitViewModel
9898
{ 3, new Color() { R = 255, G = 221, B = 0, A = 255 } },
9999
};
100100

101+
// for XAML designer view
102+
public TraitViewModel()
103+
{
104+
ModelObject = new Trait("Runner", "runner", 2);
105+
}
106+
101107
public TraitViewModel(Trait trait)
102108
{
103109
ModelObject = trait;

0 commit comments

Comments
 (0)