feat: add frame header control
This commit is contained in:
@@ -60,4 +60,29 @@ namespace BallanceTasEditor.Frontend.Converters {
|
||||
}
|
||||
}
|
||||
|
||||
[ValueConversion(typeof(bool), typeof(Brush))]
|
||||
public class HeaderIsSelectedToColorConverter : IValueConverter {
|
||||
public static readonly HeaderIsSelectedToColorConverter Instance = new HeaderIsSelectedToColorConverter();
|
||||
|
||||
private static readonly SolidColorBrush SELECTED_BRUSH = new(Color.FromRgb(30, 144, 255));
|
||||
private static readonly SolidColorBrush DESELECTED_BRUSH = new(Color.FromRgb(255, 255, 255));
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
var isSelected = value as bool?;
|
||||
if (isSelected is null) {
|
||||
return Binding.DoNothing;
|
||||
} else {
|
||||
if (isSelected.Value) {
|
||||
return SELECTED_BRUSH;
|
||||
} else {
|
||||
return DESELECTED_BRUSH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
return Binding.DoNothing;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<UserControl x:Class="BallanceTasEditor.Frontend.Widgets.FrameHeader"
|
||||
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:BallanceTasEditor.Frontend.Widgets"
|
||||
xmlns:conveter="clr-namespace:BallanceTasEditor.Frontend.Converters"
|
||||
mc:Ignorable="d"
|
||||
x:Name="Root"
|
||||
d:DesignHeight="120" d:DesignWidth="60">
|
||||
<Rectangle Stroke="#9E9E9E" StrokeThickness="2"
|
||||
Fill="{Binding ElementName=Root, Path=IsSelected, Mode=OneWay, Converter={x:Static conveter:CellIsSetToColorConverter.Instance}}"/>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,35 @@
|
||||
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 BallanceTasEditor.Frontend.Widgets {
|
||||
/// <summary>
|
||||
/// Interaction logic for FrameHeader.xaml
|
||||
/// </summary>
|
||||
public partial class FrameHeader : UserControl {
|
||||
public FrameHeader() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public bool IsSelected {
|
||||
get { return (bool)GetValue(IsSelectedProperty); }
|
||||
set { SetValue(IsSelectedProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for IsSelected. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty IsSelectedProperty =
|
||||
DependencyProperty.Register("IsSelected", typeof(bool), typeof(FrameCell), new PropertyMetadata(false));
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user