Refactoring WIP

This commit is contained in:
Nikolai Smirnov
2022-07-08 11:38:25 +05:00
parent fc4f1f1db3
commit 2c4df04c5c
43 changed files with 832 additions and 833 deletions

View File

@@ -1,4 +1,4 @@
<Window x:Class="StructureHelper.ColorPickerView"
<Window x:Class="StructureHelper.Windows.ColorPickerWindow.ColorPickerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

View File

@@ -1,13 +1,14 @@
using System.Windows;
using StructureHelper.Infrastructure.UI.DataContexts;
namespace StructureHelper
namespace StructureHelper.Windows.ColorPickerWindow
{
/// <summary>
/// Логика взаимодействия для ColorPickerView.xaml
/// </summary>
public partial class ColorPickerView : Window
{
public ColorPickerView(PrimitiveDefinitionBase primitive)
public ColorPickerView(PrimitiveBase primitive)
{
var viewModel = new ColorPickerViewModel(primitive);
DataContext = viewModel;

View File

@@ -1,69 +1,12 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Media;
using StructureHelper.Annotations;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
namespace StructureHelper
namespace StructureHelper.Windows.ColorPickerWindow
{
//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;
@@ -84,19 +27,18 @@ namespace StructureHelper
set => OnColorItemChanged(value, ref blue);
}
private SolidColorBrush selectedColor;
public SolidColorBrush SelectedColor
private Brush selectedColor;
public Brush SelectedColor
{
get => selectedColor;
//selectedColor = value;
set => OnPropertyChanged(value, ref selectedColor);
set => OnPropertyChanged(value, selectedColor);
}
public ICommand SetColor { get; }
public ColorPickerViewModel(PrimitiveDefinitionBase primitive)
public ColorPickerViewModel(PrimitiveBase primitive)
{
if (primitive != null)
{
var solidBrush = primitive.Brush;
var solidBrush = (SolidColorBrush)primitive.Brush;
Red = solidBrush.Color.R;
Green = solidBrush.Color.G;
Blue = solidBrush.Color.B;