Added shared UI library and finished the ColorPicker

This commit is contained in:
Robert committed 2019-12-09 19:25:45 +01:00
1 parent 515348241a
commit cec6fb45dc
30 files changed
+875 -321

No files matched your search

@@ -5,11 +5,25 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Workshop"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:controls="clr-namespace:Artemis.UI.Controls"
xmlns:controls="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock Text="{Binding TestColor}"></TextBlock>
<controls:ColorPicker Color="{Binding TestColor}" VerticalAlignment="Center" HorizontalAlignment="Center"></controls:ColorPicker>
</Grid>
<StackPanel>
<Rectangle Width="100" Height="100" HorizontalAlignment="Left">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding TestColor}" />
</Rectangle.Fill>
</Rectangle>
<TextBlock Text="{Binding TestColor}" />
<Button Command="{s:Action UpdateValues}" Style="{StaticResource MaterialDesignRaisedButton}"
HorizontalAlignment="Left" Margin="0 10">
Update values
</Button>
<CheckBox IsChecked="{Binding TestPopupOpen}">Test</CheckBox>
<controls:ColorPicker Color="{Binding TestColor, Mode=TwoWay}" PopupOpen="{Binding TestPopupOpen}" materialDesign:HintAssist.Hint="Custom hint" />
</StackPanel>
</UserControl>
@@ -1,38 +1,18 @@
using System;
using System.ComponentModel;
using System.Windows.Media;
using System.Windows.Media;
using Stylet;
namespace Artemis.UI.Screens.Workshop
{
public class WorkshopViewModel : Screen, IScreenViewModel
{
public Color TestColor { get; set; }
public bool TestPopupOpen { get; set; }
public string Title => "Workshop";
public WorkshopViewModel()
public void UpdateValues()
{
PropertyChanged += OnPropertyChanged;
}
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
Console.WriteLine("Property changed:" + e.PropertyName);
Console.WriteLine(TestColor);
}
public Color TestColor { get; set; }
protected override void OnActivate()
{
TestColor = Color.FromRgb(255, 0, 0);
base.OnActivate();
}
protected override void OnDeactivate()
{
Console.WriteLine(TestColor);
base.OnDeactivate();
TestPopupOpen = !TestPopupOpen;
TestColor = Color.FromRgb(5, 174, 255);
}
}
}