diff --git a/StructureHelper/Windows/MainGraph/GraphView.xaml.cs b/StructureHelper/Windows/MainGraph/GraphView.xaml.cs index 1bfc7bb..81882a2 100644 --- a/StructureHelper/Windows/MainGraph/GraphView.xaml.cs +++ b/StructureHelper/Windows/MainGraph/GraphView.xaml.cs @@ -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(); } + } } diff --git a/StructureHelper/Windows/MainGraph/GraphViewModel.cs b/StructureHelper/Windows/MainGraph/GraphViewModel.cs index d0cad49..5851d6c 100644 --- a/StructureHelper/Windows/MainGraph/GraphViewModel.cs +++ b/StructureHelper/Windows/MainGraph/GraphViewModel.cs @@ -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(); - var f1 = new TableFunction(); - f1.Name = "Табличная системная функция"; - f1.Table = new List() + 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(); + var f1 = new TableFunction(); + f1.Name = "Табличная системная функция"; + f1.Table = new List() + { + 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; } } } diff --git a/StructureHelper/Windows/TreeGraph/TreeGraphViewModel.cs b/StructureHelper/Windows/TreeGraph/TreeGraphViewModel.cs index 84cf084..221d7ae 100644 --- a/StructureHelper/Windows/TreeGraph/TreeGraphViewModel.cs +++ b/StructureHelper/Windows/TreeGraph/TreeGraphViewModel.cs @@ -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() + { + + } } } diff --git a/StructureHelperCommon/Infrastructures/Settings/ProgramSetting.cs b/StructureHelperCommon/Infrastructures/Settings/ProgramSetting.cs index 8726a91..e4d2be7 100644 --- a/StructureHelperCommon/Infrastructures/Settings/ProgramSetting.cs +++ b/StructureHelperCommon/Infrastructures/Settings/ProgramSetting.cs @@ -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 Functions { get; set; } } } diff --git a/StructureHelperLogics/Models/Materials/FunctionMaterial.cs b/StructureHelperLogics/Models/Materials/FunctionMaterial.cs index d9c3acb..0f85526 100644 --- a/StructureHelperLogics/Models/Materials/FunctionMaterial.cs +++ b/StructureHelperLogics/Models/Materials/FunctionMaterial.cs @@ -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) {