diff --git a/StructureHelper/Windows/MainGraph/FormulaViewModel.cs b/StructureHelper/Windows/MainGraph/FormulaViewModel.cs
index 3582c24..c682af8 100644
--- a/StructureHelper/Windows/MainGraph/FormulaViewModel.cs
+++ b/StructureHelper/Windows/MainGraph/FormulaViewModel.cs
@@ -177,6 +177,7 @@ namespace StructureHelper.Windows.MainGraph
Function = new FormulaFunction(isUser: true);
}
Function.Name = Name;
+ Function.FullName = Name;
Function.Description = Description;
Function.IsUser = true;
(Function as FormulaFunction).Step = Step;
diff --git a/StructureHelper/Windows/MainGraph/TableViewModel.cs b/StructureHelper/Windows/MainGraph/TableViewModel.cs
index e41dc46..bde5d84 100644
--- a/StructureHelper/Windows/MainGraph/TableViewModel.cs
+++ b/StructureHelper/Windows/MainGraph/TableViewModel.cs
@@ -141,6 +141,7 @@ namespace StructureHelper.Windows.MainGraph
Function = new TableFunction(isUser: true);
}
Function.Name = Name;
+ Function.FullName = Name;
Function.Description = Description;
Function.IsUser = true;
(Function as TableFunction).Table = Table.OrderBy(x => x.X).ToList();
diff --git a/StructureHelper/Windows/TreeGraph/TreeGraphView.xaml b/StructureHelper/Windows/TreeGraph/TreeGraphView.xaml
index 7fa4f13..2d74ec2 100644
--- a/StructureHelper/Windows/TreeGraph/TreeGraphView.xaml
+++ b/StructureHelper/Windows/TreeGraph/TreeGraphView.xaml
@@ -21,6 +21,7 @@
labels;
- readonly ObservableCollection _tree;
- readonly TreeViewItemViewModel _root;
+ private ObservableCollection _tree;
+ private TreeViewItemViewModel _root;
readonly ICommand _searchCommand;
private RelayCommand _getYCommand;
private RelayCommand _scaleCommand;
@@ -96,6 +96,11 @@ namespace StructureHelper.Windows.TreeGraph
public ObservableCollection Tree
{
get => _tree;
+ set
+ {
+ _tree = value;
+ OnPropertyChanged(nameof(Tree));
+ }
}
public GraphVisualProps VisualProps { get; } = new GraphVisualProps();
public ICommand GetYCommand
@@ -129,8 +134,12 @@ namespace StructureHelper.Windows.TreeGraph
public TreeGraphViewModel(IOneVariableFunction rootFunction)
{
RootFunction = rootFunction;
+ RunTreeView(rootFunction);
+ }
+ private void RunTreeView(IOneVariableFunction rootFunction)
+ {
_root = new TreeViewItemViewModel(rootFunction, this);
- _tree = new ObservableCollection
+ Tree = new ObservableCollection
(
new ObservableCollection()
{
@@ -189,6 +198,7 @@ namespace StructureHelper.Windows.TreeGraph
{
return;
}
+ Save();
}
private void Limit(object parameter)
{
@@ -228,6 +238,7 @@ namespace StructureHelper.Windows.TreeGraph
{
return;
}
+ Save();
}
private void Delete()
{
@@ -242,6 +253,7 @@ namespace StructureHelper.Windows.TreeGraph
return;
}
selectedTreeViewItemParent.Children.Remove(selectedTreeViewItem);
+ Save();
}
private void Rename(object parameter)
{
@@ -262,6 +274,7 @@ namespace StructureHelper.Windows.TreeGraph
{
selectedTreeViewItem.Name = renameViewModel.FunctionName;
}
+ Save();
}
private void NewTree()
{
@@ -274,7 +287,8 @@ namespace StructureHelper.Windows.TreeGraph
treeGraph.DataContext = treeGraphVM;
treeGraphVM.TreeGraphView_win = treeGraph;
treeGraph.ShowDialog();
- //Сохранить поддерево
+ Save();
+ RunTreeView(RootFunction);
}
public void DrawGraph()
{
@@ -297,13 +311,24 @@ namespace StructureHelper.Windows.TreeGraph
}
public void Save()
{
-
-
-
+ GetFunctionTree(Tree, RootFunction);
}
- private List GetFunctionChildern(TreeViewItemViewModel item)
+ private void GetFunctionTree(ObservableCollection tree, IOneVariableFunction function)
{
- return null;
+ function.Functions.Clear();
+ foreach (TreeViewItemViewModel item in tree)
+ {
+ if (item.Function is null)
+ {
+ return;
+ }
+ function.Functions.Add(item.Function);
+ if (item.Children.Count > 0)
+ {
+ var newTree = item.Children;
+ GetFunctionTree(newTree, item.Function);
+ }
+ }
}
}
}
diff --git a/StructureHelper/Windows/TreeGraph/TreeViewItemViewModel.cs b/StructureHelper/Windows/TreeGraph/TreeViewItemViewModel.cs
index f527197..317c2c6 100644
--- a/StructureHelper/Windows/TreeGraph/TreeViewItemViewModel.cs
+++ b/StructureHelper/Windows/TreeGraph/TreeViewItemViewModel.cs
@@ -17,7 +17,7 @@ namespace StructureHelper.Windows.TreeGraph
readonly IOneVariableFunction _function;
readonly TreeGraphViewModel _treeGraphViewModel;
- bool _isExpanded;
+ bool _isExpanded = true;
bool _isSelected;
public TreeViewItemViewModel(IOneVariableFunction function, TreeGraphViewModel treeGraphViewModel) : this(function, null, treeGraphViewModel)
diff --git a/StructureHelperCommon/Infrastructures/Interfaces/FunctionDecorator.cs b/StructureHelperCommon/Infrastructures/Interfaces/FunctionDecorator.cs
index fe97b0a..9657210 100644
--- a/StructureHelperCommon/Infrastructures/Interfaces/FunctionDecorator.cs
+++ b/StructureHelperCommon/Infrastructures/Interfaces/FunctionDecorator.cs
@@ -21,6 +21,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
public FunctionType Type { get; set; }
public FunctionPurpose FunctionPurpose { get; set; }
public string Name { get; set; }
+ public string FullName { get; set; }
public string Description { get; set; }
public List Table { get; set; }
public double MinArg { get; set; }
diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IOneVariableFunction.cs b/StructureHelperCommon/Infrastructures/Interfaces/IOneVariableFunction.cs
index d49008d..ef7c3ee 100644
--- a/StructureHelperCommon/Infrastructures/Interfaces/IOneVariableFunction.cs
+++ b/StructureHelperCommon/Infrastructures/Interfaces/IOneVariableFunction.cs
@@ -22,6 +22,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
public FunctionType Type { get; set; }
public FunctionPurpose FunctionPurpose { get; set; }
public string Name { get; set; }
+ public string FullName { get; set; }
public string Description { get; set; }
public double MinArg { get; set; }
public double MaxArg { get; set; }
diff --git a/StructureHelperCommon/Infrastructures/Settings/ProgramSetting.cs b/StructureHelperCommon/Infrastructures/Settings/ProgramSetting.cs
index d22aabc..3998b8b 100644
--- a/StructureHelperCommon/Infrastructures/Settings/ProgramSetting.cs
+++ b/StructureHelperCommon/Infrastructures/Settings/ProgramSetting.cs
@@ -99,6 +99,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
new TableFunction()
{
Name = "Not StressStrain",
+ FullName = "Not StressStrain",
FunctionPurpose = FunctionPurpose.FireProtection,
Table = new List()
{
@@ -115,6 +116,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
new TableFunction()
{
Name = "Табличная системная функция",
+ FullName = "Табличная системная функция",
FunctionPurpose = FunctionPurpose.StressStrain,
Table = new List()
{
@@ -131,6 +133,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
new FormulaFunction()
{
Name = "Формульная системная функция",
+ FullName = "Формульная системная функция",
FunctionPurpose = FunctionPurpose.StressStrain,
Formula = "x^2",
Step = 100,
diff --git a/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs b/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs
index c30873d..78d1496 100644
--- a/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs
+++ b/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs
@@ -17,6 +17,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
public LimXDecorator(IOneVariableFunction function, double leftBound, double rightBound) : base(function)
{
Name = $"x\u2208[{leftBound};{rightBound}]";
+ FullName = $"{function.FullName}/{Name}";
this.leftBound = leftBound;
this.rightBound = rightBound;
}
diff --git a/StructureHelperCommon/Models/Functions/Decorator/LimYDecorator.cs b/StructureHelperCommon/Models/Functions/Decorator/LimYDecorator.cs
index 4dd3b96..12b5f1e 100644
--- a/StructureHelperCommon/Models/Functions/Decorator/LimYDecorator.cs
+++ b/StructureHelperCommon/Models/Functions/Decorator/LimYDecorator.cs
@@ -16,6 +16,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
public LimYDecorator(IOneVariableFunction function, double downBound, double upBound) : base(function)
{
Name = $"y\u2208[{downBound};{upBound}]";
+ FullName = $"{function.FullName}/{Name}";
this.downBound = downBound;
this.upBound = upBound;
}
diff --git a/StructureHelperCommon/Models/Functions/Decorator/ScaleXDecorator.cs b/StructureHelperCommon/Models/Functions/Decorator/ScaleXDecorator.cs
index cc86197..1fb74dd 100644
--- a/StructureHelperCommon/Models/Functions/Decorator/ScaleXDecorator.cs
+++ b/StructureHelperCommon/Models/Functions/Decorator/ScaleXDecorator.cs
@@ -16,6 +16,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
{
this.factor = factor;
Name = $"y=f({factor}x)";
+ FullName = $"{function.FullName}/{Name}";
}
public override bool Check()
{
diff --git a/StructureHelperCommon/Models/Functions/Decorator/ScaleYDecorator.cs b/StructureHelperCommon/Models/Functions/Decorator/ScaleYDecorator.cs
index feb6034..2b58020 100644
--- a/StructureHelperCommon/Models/Functions/Decorator/ScaleYDecorator.cs
+++ b/StructureHelperCommon/Models/Functions/Decorator/ScaleYDecorator.cs
@@ -16,6 +16,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
{
this.factor = factor;
Name = $"y={factor}f(x)";
+ FullName = $"{function.FullName}/{Name}";
}
public override bool Check()
{
diff --git a/StructureHelperCommon/Models/Functions/FormulaFunction.cs b/StructureHelperCommon/Models/Functions/FormulaFunction.cs
index 0c2b1bf..1e48cdd 100644
--- a/StructureHelperCommon/Models/Functions/FormulaFunction.cs
+++ b/StructureHelperCommon/Models/Functions/FormulaFunction.cs
@@ -30,6 +30,7 @@ namespace StructureHelperCommon.Models.Functions
public FunctionPurpose FunctionPurpose { get; set; }
public string Group { get; set; }
public string Name { get; set; }
+ public string FullName { get; set; }
public string Description { get ; set; }
public int Step { get; set; }
public string Formula
@@ -87,7 +88,8 @@ namespace StructureHelperCommon.Models.Functions
{
var formulaFunction = new FormulaFunction();
formulaFunction.Type = Type;
- formulaFunction.Name = $"{Name} {COPY}";
+ formulaFunction.Name = $"{Name} {COPY}";
+ formulaFunction.FullName = formulaFunction.Name;
formulaFunction.Description = Description;
formulaFunction.Formula = Formula;
formulaFunction.IsUser = true;
diff --git a/StructureHelperCommon/Models/Functions/TableFunction.cs b/StructureHelperCommon/Models/Functions/TableFunction.cs
index 0be3560..2e6dab2 100644
--- a/StructureHelperCommon/Models/Functions/TableFunction.cs
+++ b/StructureHelperCommon/Models/Functions/TableFunction.cs
@@ -27,6 +27,7 @@ namespace StructureHelperCommon.Models.Functions
public FunctionPurpose FunctionPurpose { get; set; }
public string Group { get; set; }
public string Name { get; set; }
+ public string FullName { get; set; }
public string Description { get; set; }
public List Table { get; set; }
public Guid Id => throw new NotImplementedException();
@@ -62,6 +63,7 @@ namespace StructureHelperCommon.Models.Functions
var tableFunction = new TableFunction();
tableFunction.Type = Type;
tableFunction.Name = $"{Name} {COPY}";
+ tableFunction.FullName = tableFunction.Name;
tableFunction.Description = Description;
var newTable = new List();
Table.ForEach(x => newTable.Add(x.Clone() as GraphPoint));
@@ -71,7 +73,6 @@ namespace StructureHelperCommon.Models.Functions
tableFunction.FunctionPurpose = FunctionPurpose;
return tableFunction;
}
-
public double GetByX(double xValue)
{
double yValue = 0;
diff --git a/StructureHelperCommon/Windows/FunctionSelectionVM.cs b/StructureHelperCommon/Windows/FunctionSelectionVM.cs
index f9d6fa3..595ffdd 100644
--- a/StructureHelperCommon/Windows/FunctionSelectionVM.cs
+++ b/StructureHelperCommon/Windows/FunctionSelectionVM.cs
@@ -1,4 +1,5 @@
-using StructureHelperCommon.Infrastructures.Commands;
+using LiveCharts.Wpf;
+using StructureHelperCommon.Infrastructures.Commands;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Functions;
@@ -27,7 +28,7 @@ namespace StructureHelperCommon.Windows
public string SPECIAL { get; } = "Special Limit State";
public string CREATE_MATERIAL { get; } = "Create Function Material";
private const string ERROR_TEXT_1 = "Not all material states have functions ";
- public ObservableCollection Functions { get; set; }
+ public ObservableCollection Functions { get; set; } = new ObservableCollection();
public IOneVariableFunction Func_ST_ULS { get; set; }
public IOneVariableFunction Func_ST_SLS { get; set; }
public IOneVariableFunction Func_ST_Special { get; set; }
@@ -37,8 +38,23 @@ namespace StructureHelperCommon.Windows
public FunctionStorage FunctionStorage { get; set; } = new();
public FunctionSelectionVM()
{
- var listFunctions = ProgramSetting.Functions.Where(x => x.FunctionPurpose == Infrastructures.Enums.FunctionPurpose.StressStrain).ToList();
- Functions = new ObservableCollection();
+ var stressStrainFunctions = new ObservableCollection
+ (
+ ProgramSetting.Functions
+ .Where(x => x.FunctionPurpose == Infrastructures.Enums.FunctionPurpose.StressStrain)
+ );
+ GetFunctionsFromTree(stressStrainFunctions);
+ }
+ private void GetFunctionsFromTree(ObservableCollection stressStrainFunctions)
+ {
+ foreach (IOneVariableFunction func in stressStrainFunctions)
+ {
+ Functions.Add(func);
+ if (func.Functions.Count > 0)
+ {
+ GetFunctionsFromTree(func.Functions);
+ }
+ }
}
private void CreateFunctionMaterial(object parameter)
{
diff --git a/StructureHelperCommon/Windows/FunctionSelectionView.xaml b/StructureHelperCommon/Windows/FunctionSelectionView.xaml
index 4a95d35..207f670 100644
--- a/StructureHelperCommon/Windows/FunctionSelectionView.xaml
+++ b/StructureHelperCommon/Windows/FunctionSelectionView.xaml
@@ -33,7 +33,7 @@