Add tree graph commands

This commit is contained in:
Иван Ивашкин
2024-10-19 21:08:13 +05:00
parent 88ac95af2f
commit 11ac7c7c48
17 changed files with 366 additions and 112 deletions

View File

@@ -2,6 +2,7 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -11,14 +12,22 @@ namespace StructureHelperCommon.Models.Functions
{
public class FormulaFunction : IOneVariableFunction
{
private const string COPY = "copy";
public bool IsUser { get; set; }
public FunctionType Type { get; set; }
public string Name { get; set; }
public string Description { get ; set; }
public List<GraphPoint> Table { get; set; }
public string Formula { get; set; }
public Guid Id => throw new NotImplementedException();
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
public FormulaFunction()
{
Type = FunctionType.FormulaFunction;
}
public bool Check()
{
throw new NotImplementedException();
@@ -30,11 +39,10 @@ namespace StructureHelperCommon.Models.Functions
//Здесь будет стратегия
formulaFunction.Type = Type;
formulaFunction.Name = Name;
formulaFunction.Name = $"{Name} {COPY}";
formulaFunction.Description = Description;
formulaFunction.Formula = Formula;
formulaFunction.IsUser = true;
return formulaFunction;
}

View File

@@ -6,9 +6,20 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Functions
{
public class GraphPoint
public class GraphPoint : ICloneable
{
public double X { get; set; }
public double Y { get; set; }
public GraphPoint(double x, double y)
{
X = x;
Y = y;
}
public object Clone()
{
var clone = new GraphPoint(X,Y);
return clone;
}
}
}

View File

@@ -12,7 +12,9 @@ namespace StructureHelperCommon.Models.Functions
{
public class TableFunction : IOneVariableFunction
{
private const string COPY = "copy";
private string name;
public bool IsUser { get; set; }
public FunctionType Type { get; set; }
public string Name
@@ -27,8 +29,12 @@ namespace StructureHelperCommon.Models.Functions
public List<GraphPoint> Table { get; set; }
public Guid Id => throw new NotImplementedException();
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
public event PropertyChangedEventHandler? PropertyChanged;
public TableFunction()
{
Type = FunctionType.TableFunction;
}
public bool Check()
{
@@ -41,9 +47,11 @@ namespace StructureHelperCommon.Models.Functions
//Здесь будет стратегия
tableFunction.Type = Type;
tableFunction.Name = Name;
tableFunction.Name = $"{Name} {COPY}";
tableFunction.Description = Description;
tableFunction.Table = Table;
var newTable = new List<GraphPoint>();
Table.ForEach(x => newTable.Add(x.Clone() as GraphPoint));
tableFunction.Table = newTable;
tableFunction.IsUser = true;
return tableFunction;