Save function tree done

This commit is contained in:
Иван Ивашкин
2025-02-19 11:50:10 +05:00
parent 68a1e62c18
commit 27d4ca95c8
5 changed files with 68 additions and 32 deletions

View File

@@ -38,11 +38,13 @@ namespace StructureHelper.Windows.MainGraph
{
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(FunctionList.ItemsSource);
PropertyGroupDescription groupDescription = new PropertyGroupDescription(GROUP_FACTOR);
view.GroupDescriptions.Clear();
view.GroupDescriptions.Add(groupDescription);
}
public void Refresh()
{
FunctionList.Items.Refresh();
}
}
}

View File

@@ -5,6 +5,7 @@ using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.TreeGraph;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Functions;
using StructureHelperLogics.Models.Graphs;
using System;
@@ -49,8 +50,8 @@ namespace StructureHelper.Windows.MainGraph
OnPropertyChanged(nameof(labels));
}
}
public GraphVisualProps VisualProps
{
public GraphVisualProps VisualProps
{
get => visualProps;
set
{
@@ -82,8 +83,9 @@ namespace StructureHelper.Windows.MainGraph
private RelayCommand copyCommand;
private RelayCommand treeCommand;
private RelayCommand drawGraphCommand;
private RelayCommand _saveCommand;
public ICommand AddTableCommand
{
{
get => addTableCommand ??= new RelayCommand(o => AddTable());
}
public ICommand AddFormulaCommand
@@ -110,39 +112,48 @@ namespace StructureHelper.Windows.MainGraph
{
get => drawGraphCommand ??= new RelayCommand(o => DrawGraph());
}
public ICommand SaveCommand
{
get => _saveCommand ??= new RelayCommand(o => Save());
}
public GraphViewModel()
{
//Пример 1
Functions = new ObservableCollection<IOneVariableFunction>();
var f1 = new TableFunction();
f1.Name = "Табличная системная функция";
f1.Table = new List<GraphPoint>()
Functions = null;
if (ProgramSetting.Functions is null)
{
new GraphPoint(1, 1),
new GraphPoint(2, 2),
new GraphPoint(3, 3),
new GraphPoint(4, 4),
new GraphPoint(5, 5),
new GraphPoint(6, 6),
};
f1.IsUser = false;
f1.Description = "Описание табличной системной функции";
//Пример 2
var f2 = new FormulaFunction();
f2.Name = "Формульная системная функция";
f2.Formula = "x^2";
f2.Step = 100;
f2.MinArg = 1;
f2.MaxArg = 1000;
f2.IsUser = false;
f2.Description = "Описание формульной системной функции";
//Пример 1
Functions = new ObservableCollection<IOneVariableFunction>();
var f1 = new TableFunction();
f1.Name = "Табличная системная функция";
f1.Table = new List<GraphPoint>()
{
new GraphPoint(1, 1),
new GraphPoint(2, 2),
new GraphPoint(3, 3),
new GraphPoint(4, 4),
new GraphPoint(5, 5),
new GraphPoint(6, 6),
};
f1.IsUser = false;
f1.Description = "Описание табличной системной функции";
//Пример 2
var f2 = new FormulaFunction();
f2.Name = ормульная системная функция";
f2.Formula = "x^2";
f2.Step = 100;
f2.MinArg = 1;
f2.MaxArg = 1000;
f2.IsUser = false;
f2.Description = "Описание формульной системной функции";
Functions.Add(f1);
Functions.Add(f2);
Functions.Add(f1);
Functions.Add(f2);
}
else
{
Functions = ProgramSetting.Functions;
}
}
/*public GraphViewModel(IGraph graph)
{
}*/
private void AddTable()
{
var tableViewModel = new TableViewModel();
@@ -153,6 +164,7 @@ namespace StructureHelper.Windows.MainGraph
Functions.Add(tableViewModel.Function);
SelectedFuntion = tableViewModel.Function;
}
Save();
}
private void AddFormula()
{
@@ -164,6 +176,7 @@ namespace StructureHelper.Windows.MainGraph
Functions.Add(formulaViewModel.Function);
SelectedFuntion = formulaViewModel.Function;
}
Save();
}
private void Edit(object parameter)
{
@@ -189,6 +202,7 @@ namespace StructureHelper.Windows.MainGraph
}
var graphView = parameter as GraphView;
graphView.Refresh();
Save();
}
private void Delete()
{
@@ -204,6 +218,7 @@ namespace StructureHelper.Windows.MainGraph
{
Functions.Remove(SelectedFuntion);
}
Save();
}
private void Copy()
{
@@ -219,6 +234,7 @@ namespace StructureHelper.Windows.MainGraph
{
Functions.Add(SelectedFuntion.Clone() as FormulaFunction);
}
Save();
}
private void Tree()
{
@@ -244,6 +260,11 @@ namespace StructureHelper.Windows.MainGraph
GraphService.SetVisualProps(LineSeries, VisualProps);
SeriesCollection = new SeriesCollection();
SeriesCollection.Add(LineSeries);
Save();
}
public void Save()
{
ProgramSetting.Functions = Functions;
}
}
}

View File

@@ -29,6 +29,7 @@ namespace StructureHelper.Windows.TreeGraph
private RelayCommand _scaleCommand;
private RelayCommand _limCommand;
private RelayCommand _deleteCommand;
private RelayCommand _saveCommand;
private TreeGraphView _treeGraphView_win;
private IOneVariableFunction selectedFunction;
public IOneVariableFunction SelectedFuntion
@@ -96,6 +97,10 @@ namespace StructureHelper.Windows.TreeGraph
{
get => _deleteCommand ??= new RelayCommand(o => Delete());
}
public ICommand SaveCommand
{
get => _saveCommand ??= new RelayCommand(o => Save());
}
public TreeGraphViewModel(IOneVariableFunction rootFunction)
{
_rootFunction = new TreeViewItemViewModel(rootFunction, this);
@@ -232,5 +237,9 @@ namespace StructureHelper.Windows.TreeGraph
SeriesCollection = new SeriesCollection();
SeriesCollection.Add(LineSeries);
}
public void Save()
{
}
}
}

View File

@@ -1,10 +1,12 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Codes;
using StructureHelperCommon.Models.Codes.Factories;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperCommon.Models.Projects;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Design.Serialization;
using System.Linq;
using System.Windows.Documents;
@@ -90,5 +92,6 @@ namespace StructureHelperCommon.Infrastructures.Settings
SubVersionNumber = 0
};
}
public static ObservableCollection<IOneVariableFunction> Functions { get; set; }
}
}

View File

@@ -1,6 +1,7 @@
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials.Logics;
using System;
@@ -28,7 +29,7 @@ namespace StructureHelperLogics.Models.Materials
}
public FunctionMaterial() : this(Guid.NewGuid())
{
Function = ProgramSetting.Functions.First();
}
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{