optisch einheitlicher gemacht (buttons) und booltoscale rausgeschmissen, da wir keine flip animation mehr haben)
This commit is contained in:
parent
eae41e1218
commit
f2646952c1
@ -2,23 +2,12 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:conv="clr-namespace:Project_Periodensystem.View.Converters"
|
xmlns:conv="clr-namespace:Project_Periodensystem.View.Converters"
|
||||||
x:Class="Project_Periodensystem.View.Components.ElementTile"
|
x:Class="Project_Periodensystem.View.Components.ElementTile"
|
||||||
Width="80" Height="80"
|
Width="80" Height="80">
|
||||||
RenderTransformOrigin="0.5,0.5">
|
|
||||||
|
|
||||||
<!-- 1) Converter registrieren -->
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<conv:BoolToScaleXConverter x:Key="FlipConverter"/>
|
<conv:SeriesToColorConverter x:Key="SeriesToColorConverter"/>
|
||||||
<conv:SeriesToColorConverter x:Key="SeriesToColorConverter"/>
|
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<!-- (optional) Flip-Transform beibehalten -->
|
|
||||||
<UserControl.RenderTransform>
|
|
||||||
<ScaleTransform
|
|
||||||
ScaleX="{Binding IsFlipped, Converter={StaticResource FlipConverter}}"
|
|
||||||
ScaleY="1"/>
|
|
||||||
</UserControl.RenderTransform>
|
|
||||||
|
|
||||||
<!-- 2) Border.Background an die Series binden -->
|
|
||||||
<Border CornerRadius="4" Padding="4"
|
<Border CornerRadius="4" Padding="4"
|
||||||
Background="{Binding Series, Converter={StaticResource SeriesToColorConverter}}">
|
Background="{Binding Series, Converter={StaticResource SeriesToColorConverter}}">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|||||||
@ -1,26 +1,14 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Project_Periodensystem.View.Components
|
namespace Project_Periodensystem.View.Components
|
||||||
{
|
{
|
||||||
public partial class ElementTile : UserControl
|
public partial class ElementTile : UserControl
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<bool> IsFlippedProperty =
|
|
||||||
AvaloniaProperty.Register<ElementTile, bool>(nameof(IsFlipped));
|
|
||||||
|
|
||||||
public bool IsFlipped
|
|
||||||
{
|
|
||||||
get => GetValue(IsFlippedProperty);
|
|
||||||
set => SetValue(IsFlippedProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElementTile()
|
public ElementTile()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.PointerPressed += (_, __) => IsFlipped = !IsFlipped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
using Avalonia.Data.Converters;
|
|
||||||
using System;
|
|
||||||
using System.Globalization;
|
|
||||||
|
|
||||||
namespace Project_Periodensystem.View.Converters
|
|
||||||
{
|
|
||||||
public class BoolToScaleXConverter : IValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
||||||
=> (value is bool b && b) ? -1 : 1;
|
|
||||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
||||||
=> throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -14,8 +14,16 @@
|
|||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Width="200"
|
Width="200"
|
||||||
Height="50"
|
Height="50"
|
||||||
Background="DarkRed"
|
Background="Black"
|
||||||
Foreground="White">
|
Foreground="White">
|
||||||
|
<Button.Styles>
|
||||||
|
<Style Selector="Button:pointerover /template/ ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="DarkRed"/>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button:pressed /template/ ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="Red"/>
|
||||||
|
</Style>
|
||||||
|
</Button.Styles>
|
||||||
<TextBlock Text="Start"
|
<TextBlock Text="Start"
|
||||||
FontSize="24"
|
FontSize="24"
|
||||||
HorizontalAlignment="Center"/>
|
HorizontalAlignment="Center"/>
|
||||||
|
|||||||
BIN
project_structure.txt
Normal file
BIN
project_structure.txt
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user