Color picker done
This commit is contained in:
@@ -149,14 +149,29 @@
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Color:"
|
||||
VerticalAlignment="Center"/>
|
||||
<ComboBox Grid.Row="1"
|
||||
Margin="5"
|
||||
ItemsSource="{Binding Colors}"
|
||||
SelectedItem="{Binding CurrentColor}"/>
|
||||
<Button Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="5,5,5,5"
|
||||
Command="{Binding EditColorCommand}"
|
||||
Content="Press to change color">
|
||||
</Button>
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="5,5,5,5">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Color, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
<Button Grid.Row="7" Margin="5" Content="Save"
|
||||
Command="{Binding SaveCommand}"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -30,6 +31,7 @@ namespace StructureHelper.Windows.MainGraph
|
||||
public char LESS { get; } = '\u2264';
|
||||
public char X { get; } = 'x';
|
||||
private RelayCommand saveCommand;
|
||||
private RelayCommand editColor;
|
||||
public int Step { get; set; }
|
||||
private double leftBound;
|
||||
public double LeftBound
|
||||
@@ -53,8 +55,11 @@ namespace StructureHelper.Windows.MainGraph
|
||||
OnPropertyChanged(nameof(RightBound));
|
||||
}
|
||||
}
|
||||
public Color CurrentColor { get; set; }
|
||||
public ObservableCollection<Color> Colors { get; set; }
|
||||
public ICommand EditColorCommand
|
||||
{
|
||||
get => editColor ??= new RelayCommand(o => EditColor());
|
||||
}
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => saveCommand ??= new RelayCommand(o => Save(o));
|
||||
@@ -107,6 +112,16 @@ namespace StructureHelper.Windows.MainGraph
|
||||
description = value;
|
||||
}
|
||||
}
|
||||
private Color color;
|
||||
public Color Color
|
||||
{
|
||||
get => color;
|
||||
set
|
||||
{
|
||||
color = value;
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
}
|
||||
private string limitText;
|
||||
public string LimitText
|
||||
{
|
||||
@@ -125,7 +140,7 @@ namespace StructureHelper.Windows.MainGraph
|
||||
LeftBound = DEFAULT_LEFT_BOUND;
|
||||
RightBound = DEFAULT_RIGHT_BOUND;
|
||||
LimitText = $"x\u2208[{LeftBound};{RightBound}]";
|
||||
CurrentColor = Brushes.AliceBlue.Color;
|
||||
Color = Brushes.Red.Color;
|
||||
}
|
||||
public FormulaViewModel(FormulaFunction formulaFunction)
|
||||
{
|
||||
@@ -136,7 +151,13 @@ namespace StructureHelper.Windows.MainGraph
|
||||
Description = Function.Description;
|
||||
LeftBound = Function.MinArg;
|
||||
RightBound = Function.MaxArg;
|
||||
CurrentColor = Function.Color;
|
||||
Color = Function.Color;
|
||||
}
|
||||
private void EditColor()
|
||||
{
|
||||
Color color = new Color();
|
||||
ColorProcessor.EditColor(ref color);
|
||||
Color = color;
|
||||
}
|
||||
private void Save(object parameter)
|
||||
{
|
||||
@@ -149,6 +170,7 @@ namespace StructureHelper.Windows.MainGraph
|
||||
Function.IsUser = true;
|
||||
(Function as FormulaFunction).Step = Step;
|
||||
(Function as FormulaFunction).Formula = Formula;
|
||||
Function.Color = Color;
|
||||
var window = parameter as Window;
|
||||
if (LeftBound > RightBound)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,17 @@
|
||||
</ListView.GroupStyle>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle
|
||||
Margin="1,1,1,1"
|
||||
Height="15"
|
||||
Width="30">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Path=Color, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<TextBlock Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
|
||||
@@ -111,11 +111,29 @@
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Color:"
|
||||
VerticalAlignment="Center"/>
|
||||
<ComboBox Grid.Row="1" Text="{Binding Description}" Margin="5"/>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Color:"
|
||||
VerticalAlignment="Center"/>
|
||||
<Button Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="5,5,5,5"
|
||||
Command="{Binding EditColorCommand}"
|
||||
Content="Press to change color">
|
||||
</Button>
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="5,5,5,5">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Color, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
<Button Grid.Row="6" Margin="5" Content="Save"
|
||||
Command="{Binding SaveCommand}"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -11,6 +12,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelper.Windows.MainGraph
|
||||
{
|
||||
@@ -21,6 +23,11 @@ namespace StructureHelper.Windows.MainGraph
|
||||
private RelayCommand saveCommand;
|
||||
private RelayCommand addPointCommand;
|
||||
private RelayCommand deletePointCommand;
|
||||
private RelayCommand editColor;
|
||||
public ICommand EditColorCommand
|
||||
{
|
||||
get => editColor ??= new RelayCommand(o => EditColor());
|
||||
}
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => saveCommand ??= new RelayCommand(o => Save(o));
|
||||
@@ -81,6 +88,16 @@ namespace StructureHelper.Windows.MainGraph
|
||||
description = value;
|
||||
}
|
||||
}
|
||||
private Color color;
|
||||
public Color Color
|
||||
{
|
||||
get => color;
|
||||
set
|
||||
{
|
||||
color = value;
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
}
|
||||
public TableViewModel()
|
||||
{
|
||||
Table = new ObservableCollection<GraphPoint>()
|
||||
@@ -90,6 +107,7 @@ namespace StructureHelper.Windows.MainGraph
|
||||
};
|
||||
Name = DEFAULT_NAME;
|
||||
Description = DEFAULT_DESCRIPTION;
|
||||
Color = Brushes.Red.Color;
|
||||
}
|
||||
public TableViewModel(TableFunction tableFunction)
|
||||
{
|
||||
@@ -97,6 +115,13 @@ namespace StructureHelper.Windows.MainGraph
|
||||
Table = new ObservableCollection<GraphPoint>((Function as TableFunction).Table);
|
||||
Name = Function.Name;
|
||||
Description = Function.Description;
|
||||
Color = Function.Color;
|
||||
}
|
||||
private void EditColor()
|
||||
{
|
||||
Color color = new Color();
|
||||
ColorProcessor.EditColor(ref color);
|
||||
Color = color;
|
||||
}
|
||||
private void Save(object parameter)
|
||||
{
|
||||
@@ -108,6 +133,7 @@ namespace StructureHelper.Windows.MainGraph
|
||||
Function.Description = Description;
|
||||
Function.IsUser = true;
|
||||
(Function as TableFunction).Table = Table.OrderBy(x => x.X).ToList();
|
||||
Function.Color = Color;
|
||||
var window = parameter as Window;
|
||||
window.DialogResult = true;
|
||||
window.Close();
|
||||
|
||||
@@ -30,7 +30,14 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
return y;
|
||||
}
|
||||
return 0;
|
||||
else if (y <= downBound)
|
||||
{
|
||||
return downBound;
|
||||
}
|
||||
else
|
||||
{
|
||||
return upBound;
|
||||
}
|
||||
}
|
||||
public override GraphSettings GetGraphSettings()
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
using StructureHelperCommon.Services;
|
||||
using LiveCharts.Wpf;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions
|
||||
{
|
||||
@@ -36,6 +37,7 @@ namespace StructureHelperCommon.Models.Functions
|
||||
|
||||
public FormulaFunction(bool isUser = false)
|
||||
{
|
||||
Color = ColorProcessor.GetRandomColor();
|
||||
Type = FunctionType.FormulaFunction;
|
||||
if (isUser)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions
|
||||
{
|
||||
@@ -36,6 +37,7 @@ namespace StructureHelperCommon.Models.Functions
|
||||
|
||||
public TableFunction(bool isUser = false)
|
||||
{
|
||||
Color = ColorProcessor.GetRandomColor();
|
||||
Type = FunctionType.TableFunction;
|
||||
if (isUser)
|
||||
{
|
||||
@@ -48,7 +50,6 @@ namespace StructureHelperCommon.Models.Functions
|
||||
Group = GROUP_TYPE_1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Check()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace StructureHelperCommon.Services
|
||||
_chartValues.Add(Math.Round(point.Y, 2));
|
||||
}
|
||||
_lineSeries.Values = _chartValues;
|
||||
_lineSeries.Stroke = Brushes.Blue; //Заменить на поле Color
|
||||
_lineSeries.Fill = Brushes.Transparent; //Заменить на поле Color
|
||||
_lineSeries.Stroke = new SolidColorBrush(_strokeColor);
|
||||
_lineSeries.Fill = Brushes.Transparent;
|
||||
_seriesCollection.Add(_lineSeries);
|
||||
return _seriesCollection;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user