Tools for graphs were added
This commit is contained in:
37
StructureHelperCommon/Models/Parameters/ArrayParameter.cs
Normal file
37
StructureHelperCommon/Models/Parameters/ArrayParameter.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Parameters
|
||||
{
|
||||
public class ArrayParameter<T> : IArrayParameter<T>
|
||||
{
|
||||
private string[] columnLabels;
|
||||
public string[] ColumnLabels
|
||||
{
|
||||
get { return columnLabels; }
|
||||
set
|
||||
{
|
||||
var labelCount = value.Count();
|
||||
var columnCount = Data.GetLength(1);
|
||||
if (labelCount != columnCount)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.IncorrectValue + $" of label count: expected {columnCount}, but was {labelCount}");
|
||||
}
|
||||
columnLabels = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T[,] Data { get; private set; }
|
||||
|
||||
public ArrayParameter(int rowCount, int columnCount, string[] columnLabels = null)
|
||||
{
|
||||
Data = new T[rowCount, columnCount];
|
||||
if (columnLabels is not null) { ColumnLabels = columnLabels; }
|
||||
}
|
||||
}
|
||||
}
|
||||
14
StructureHelperCommon/Models/Parameters/IArrayParameter.cs
Normal file
14
StructureHelperCommon/Models/Parameters/IArrayParameter.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Parameters
|
||||
{
|
||||
public interface IArrayParameter<T>
|
||||
{
|
||||
T[,] Data { get; }
|
||||
string[] ColumnLabels { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,18 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelperCommon.Models.Parameters
|
||||
{
|
||||
public interface ITextParameter
|
||||
public interface IValueParameter<T>
|
||||
{
|
||||
bool IsValid { get; set; }
|
||||
string Name { get; set; }
|
||||
string ShortName { get; set; }
|
||||
Color Color { get; set; }
|
||||
string MeasurementUnit { get; set; }
|
||||
double Value { get; set; }
|
||||
T Value { get; set; }
|
||||
string Description { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,18 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelperCommon.Models.Parameters
|
||||
{
|
||||
public class TextParameter : ITextParameter
|
||||
public class ValueParameter<T> : IValueParameter<T>
|
||||
{
|
||||
public bool IsValid { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ShortName { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public string MeasurementUnit { get; set; }
|
||||
public double Value { get; set; }
|
||||
public T Value { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,22 @@ namespace StructureHelperCommon.Services.ColorServices
|
||||
{
|
||||
public static class ColorProcessor
|
||||
{
|
||||
private static readonly Random random = new Random();
|
||||
public static Color GetRandomColor()
|
||||
{
|
||||
var randomR = new Random(new Random((int)DateTime.Now.Ticks % 1000).Next(50)).Next(0, 255);
|
||||
var randomG = new Random(new Random((int)DateTime.Now.Ticks % 200).Next(100, 200)).Next(0, 255);
|
||||
var randomB = new Random(new Random((int)DateTime.Now.Ticks % 50).Next(500, 1000)).Next(0, 255);
|
||||
return Color.FromRgb((byte)randomR, (byte)randomG, (byte)randomB);
|
||||
int r = random.Next(0, 255);
|
||||
int g = random.Next(0, 255);
|
||||
int b = random.Next(0, 255);
|
||||
|
||||
// check, that colors are different
|
||||
while (Math.Abs(r - g) < 30 || Math.Abs(g - b) < 30 || Math.Abs(b - r) < 30)
|
||||
{
|
||||
r = random.Next(0, 255);
|
||||
g = random.Next(0, 255);
|
||||
b = random.Next(0, 255);
|
||||
}
|
||||
|
||||
return Color.FromRgb((byte)r, (byte)g, (byte)b);
|
||||
}
|
||||
public static void EditColor(ref Color wpfColor)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user