StructureHelper: View fixes

This commit is contained in:
NickAppLab
2022-06-15 12:34:27 +05:00
parent a7cf3a1daf
commit 82bbd22e67
4 changed files with 78 additions and 11 deletions

View File

@@ -1,11 +1,69 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Media;
using StructureHelper.Annotations;
using StructureHelper.Infrastructure;
namespace StructureHelper
{
//public class ColorPickerViewModel : ViewModelBase
//{
// private int red, green, blue;
// public int Red
// {
// get => red;
// set => OnColorItemChanged(value, ref red);
// }
// public int Green
// {
// get => green;
// set => OnColorItemChanged(value, ref green);
// }
// public int Blue
// {
// get => blue;
// set => OnColorItemChanged(value, ref blue);
// }
// private SolidColorBrush selectedColor;
// public SolidColorBrush SelectedColor
// {
// get => selectedColor;
// set => OnPropertyChanged(value, selectedColor);
// }
// public ICommand SetColor { get; }
// public ColorPickerViewModel(PrimitiveDefinitionBase primitive)
// {
// if (primitive != null)
// {
// var solidBrush = primitive.Brush;
// Red = solidBrush.Color.R;
// Green = solidBrush.Color.G;
// Blue = solidBrush.Color.B;
// SetColor = new RelayCommand(o => primitive.Brush = SelectedColor);
// }
// }
// private void OnColorItemChanged(int value, ref int colorItem, [CallerMemberName] string propertyName = null)
// {
// if (value >= 0 && value <= 255 && Math.Abs(colorItem - value) > 0.001)
// {
// colorItem = value;
// OnPropertyChanged(propertyName);
// UpdateSelectedColor();
// }
// }
// private void UpdateSelectedColor()
// {
// var color = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue);
// SelectedColor = new SolidColorBrush(color);
// OnPropertyChanged(nameof(SelectedColor));
// }
//}
public class ColorPickerViewModel : ViewModelBase
{
private int red, green, blue;
@@ -30,7 +88,8 @@ namespace StructureHelper
public SolidColorBrush SelectedColor
{
get => selectedColor;
set => OnPropertyChanged(value, selectedColor);
//selectedColor = value;
set => OnPropertyChanged(value, ref selectedColor);
}
public ICommand SetColor { get; }
public ColorPickerViewModel(PrimitiveDefinitionBase primitive)