diff --git a/StructureHelper/Windows/MainGraph/GraphViewModel.cs b/StructureHelper/Windows/MainGraph/GraphViewModel.cs index e410f36..a89b749 100644 --- a/StructureHelper/Windows/MainGraph/GraphViewModel.cs +++ b/StructureHelper/Windows/MainGraph/GraphViewModel.cs @@ -161,8 +161,8 @@ namespace StructureHelper.Windows.MainGraph formulaView.ShowDialog(); SelectedFuntion = formulaViewModel.Function; } - //var graphView = parameter as GraphView; - //graphView.Refresh(); + var graphView = parameter as GraphView; + graphView.Refresh(); } private void Delete() { diff --git a/StructureHelper/Windows/TreeGraph/GetValueViewModel.cs b/StructureHelper/Windows/TreeGraph/GetValueViewModel.cs index 659553e..54e932a 100644 --- a/StructureHelper/Windows/TreeGraph/GetValueViewModel.cs +++ b/StructureHelper/Windows/TreeGraph/GetValueViewModel.cs @@ -55,7 +55,7 @@ namespace StructureHelper.Windows.TreeGraph private void GetValue() { Value = Function.GetByX(Argument); - Trace = "Calculation logic"; + Trace = "трасса"; } } } diff --git a/StructureHelper/Windows/TreeGraph/LimView.xaml b/StructureHelper/Windows/TreeGraph/LimView.xaml index 3774ff7..80e0d49 100644 --- a/StructureHelper/Windows/TreeGraph/LimView.xaml +++ b/StructureHelper/Windows/TreeGraph/LimView.xaml @@ -1,4 +1,5 @@  - \ No newline at end of file diff --git a/StructureHelper/Windows/TreeGraph/LimViewModel.cs b/StructureHelper/Windows/TreeGraph/LimViewModel.cs index f94b6a7..2cb88d3 100644 --- a/StructureHelper/Windows/TreeGraph/LimViewModel.cs +++ b/StructureHelper/Windows/TreeGraph/LimViewModel.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; namespace StructureHelper.Windows.TreeGraph { @@ -20,6 +22,11 @@ namespace StructureHelper.Windows.TreeGraph private const string Y = "y"; private string x_or_y_text; private string limitText; + private RelayCommand saveCommand; + public ICommand SaveCommand + { + get => saveCommand ??= new RelayCommand(o => Save(o)); + } public string X_or_Y_text { get => x_or_y_text; @@ -69,5 +76,11 @@ namespace StructureHelper.Windows.TreeGraph } LimitText = $"{X_or_Y_text}" + $"{IN}" + $"{LEFT_BOUND}" + $"{LeftBound}" + $"{SEMICOLON}" + $"{rightBound}" + $"{RIGHT_BOUND}"; } + private void Save(object parameter) + { + var window = parameter as Window; + window.DialogResult = true; + window.Close(); + } } } diff --git a/StructureHelper/Windows/TreeGraph/ScaleView.xaml b/StructureHelper/Windows/TreeGraph/ScaleView.xaml index 39a8c46..cf01ccc 100644 --- a/StructureHelper/Windows/TreeGraph/ScaleView.xaml +++ b/StructureHelper/Windows/TreeGraph/ScaleView.xaml @@ -1,4 +1,5 @@  - diff --git a/StructureHelper/Windows/TreeGraph/ScaleViewModel.cs b/StructureHelper/Windows/TreeGraph/ScaleViewModel.cs index fdfc0d3..c3b0fb1 100644 --- a/StructureHelper/Windows/TreeGraph/ScaleViewModel.cs +++ b/StructureHelper/Windows/TreeGraph/ScaleViewModel.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; namespace StructureHelper.Windows.TreeGraph { @@ -14,6 +16,11 @@ namespace StructureHelper.Windows.TreeGraph private string scaleText; private const string X_DEFAULT_SCALE_TEXT = "y=f(sx)"; private const string Y_DEFAULT_SCALE_TEXT = "y=sf(x)"; + private RelayCommand saveCommand; + public ICommand SaveCommand + { + get => saveCommand ??= new RelayCommand(o => Save(o)); + } public double ScaleFactor { get => scaleFactor; @@ -52,5 +59,11 @@ namespace StructureHelper.Windows.TreeGraph ScaleText= $"{Y_DEFAULT_SCALE_TEXT}"; } } + private void Save(object parameter) + { + var window = parameter as Window; + window.DialogResult = true; + window.Close(); + } } } diff --git a/StructureHelper/Windows/TreeGraph/TreeGraphViewModel.cs b/StructureHelper/Windows/TreeGraph/TreeGraphViewModel.cs index 7eceab4..e7ad6a9 100644 --- a/StructureHelper/Windows/TreeGraph/TreeGraphViewModel.cs +++ b/StructureHelper/Windows/TreeGraph/TreeGraphViewModel.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; +using StructureHelperCommon.Models.Functions.Decorator; namespace StructureHelper.Windows.TreeGraph { @@ -114,11 +115,24 @@ namespace StructureHelper.Windows.TreeGraph } private void Scale(object parameter) { + var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel; + if (selectedTreeViewItem is null) + { + return; + } ScaleViewModel vm = null; var type = parameter as string; if (type.Equals("x")) { vm = new ScaleViewModel(true); + var v = new ScaleView(); + v.DataContext = vm; + if (v.ShowDialog() == true) + { + SelectedFuntion = new ScaleXDecorator(SelectedFuntion, vm.ScaleFactor); + var child = new TreeViewItemViewModel(SelectedFuntion, selectedTreeViewItem, this); + selectedTreeViewItem.Children.Add(child); + } } else if (type.Equals("y")) { @@ -128,12 +142,14 @@ namespace StructureHelper.Windows.TreeGraph { return; } - var v = new ScaleView(); - v.DataContext = vm; - v.ShowDialog(); } private void Limit(object parameter) { + var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel; + if (selectedTreeViewItem is null) + { + return; + } LimViewModel vm = null; var type = parameter as string; if (type.Equals("x")) diff --git a/StructureHelper/Windows/TreeGraph/TreeViewItemViewModel.cs b/StructureHelper/Windows/TreeGraph/TreeViewItemViewModel.cs index df1f4d6..d028f8d 100644 --- a/StructureHelper/Windows/TreeGraph/TreeViewItemViewModel.cs +++ b/StructureHelper/Windows/TreeGraph/TreeViewItemViewModel.cs @@ -23,7 +23,7 @@ namespace StructureHelper.Windows.TreeGraph public TreeViewItemViewModel(IOneVariableFunction function, TreeGraphViewModel treeGraphViewModel) : this(function, null, treeGraphViewModel) { } - private TreeViewItemViewModel(IOneVariableFunction function, TreeViewItemViewModel parent, TreeGraphViewModel treeGraphViewModel) + public TreeViewItemViewModel(IOneVariableFunction function, TreeViewItemViewModel parent, TreeGraphViewModel treeGraphViewModel) { _function = function; _parent = parent; diff --git a/StructureHelperCommon/FunctionDecorator.cd b/StructureHelperCommon/FunctionDecorator.cd index 6c994c1..a903c04 100644 --- a/StructureHelperCommon/FunctionDecorator.cd +++ b/StructureHelperCommon/FunctionDecorator.cd @@ -1,17 +1,17 @@  - + - AAAAAAgAAAAAAAAAAAAAAAQAAAAIAAAAAQAAAAAAAAA= + BAACgEgAAAAgACIAAAAAQAYAAAAMAAAAAQAAAAAAgBA= Models\Functions\TableFunction.cs - + - AAAAAAgAAAAAAAAAAAAAAAQAAAAIAAAAAQAAAAAAAAA= + BAACgEgAAAAgACJAAgAAQAYAAAAIBAAAIQAAAAAAgBA= Models\Functions\FormulaFunction.cs @@ -19,30 +19,9 @@ - AAAAAAgAAAAAAAAAAAAAAAQAAAAIAAAAAQAAAAAAAAA= + BAAAgEgAAAAgACAAAAAAQAYAAAAIAAAAAQAAAAAAgAA= Infrastructures\Interfaces\IOneVariableFunction.cs - - - - AAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAA= - Models\Functions\IScaleFunction.cs - - - - - - AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA= - Models\Functions\ILimitFunction.cs - - - - - - AAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAA= - Infrastructures\Interfaces\IFunctionDecorator.cs - - \ No newline at end of file diff --git a/StructureHelperCommon/Infrastructures/Interfaces/FunctionDecorator.cs b/StructureHelperCommon/Infrastructures/Interfaces/FunctionDecorator.cs new file mode 100644 index 0000000..fb2c0a4 --- /dev/null +++ b/StructureHelperCommon/Infrastructures/Interfaces/FunctionDecorator.cs @@ -0,0 +1,46 @@ +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Functions; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Infrastructures.Interfaces +{ + public abstract class FunctionDecorator : IOneVariableFunction + { + protected IOneVariableFunction function; + public bool IsUser { get; set; } + public string Group { get; set; } + public FunctionType Type { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public List Table { get; set; } + public double MinArg { get; set; } + public double MaxArg { get; set; } + public ObservableCollection Functions { get; set; } = new ObservableCollection(); + + public Guid Id => throw new NotImplementedException(); + + public IShiftTraceLogger? TraceLogger { get; set; } + public FunctionDecorator(IOneVariableFunction function) + { + this.function = function; + } + public virtual bool Check() + { + return function.Check(); + } + public virtual object Clone() + { + return function.Clone(); + } + public virtual double GetByX(double xValue) + { + return function.GetByX(xValue); + } + } +} diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IFunctionDecorator.cs b/StructureHelperCommon/Infrastructures/Interfaces/IFunctionDecorator.cs deleted file mode 100644 index f8d5e67..0000000 --- a/StructureHelperCommon/Infrastructures/Interfaces/IFunctionDecorator.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StructureHelperCommon.Infrastructures.Interfaces -{ - public interface IFunctionDecorator - { - public IOneVariableFunction OneVariableFunction { get; } - } -} diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IOneVariableFunction.cs b/StructureHelperCommon/Infrastructures/Interfaces/IOneVariableFunction.cs index 63f580e..a294c4c 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/IOneVariableFunction.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/IOneVariableFunction.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Infrastructures.Interfaces { - public interface IOneVariableFunction : ICloneable, ISaveable + public interface IOneVariableFunction : ICloneable, ISaveable, ILogic { public const string GROUP_TYPE_1 = "System function"; public const string GROUP_TYPE_2 = "User function"; diff --git a/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs b/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs new file mode 100644 index 0000000..fb65c89 --- /dev/null +++ b/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs @@ -0,0 +1,32 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Functions.Decorator +{ + public class LimXDecorator : FunctionDecorator + { + private double leftBound; + private double rightBound; + public LimXDecorator(IOneVariableFunction function, double leftBound, double rightBound) : base(function) + { + this.leftBound = leftBound; + this.rightBound = rightBound; + } + public override bool Check() + { + return base.Check(); + } + public override double GetByX(double xValue) + { + if (xValue > leftBound && xValue < rightBound) + { + return base.GetByX(xValue); + } + return 0; + } + } +} diff --git a/StructureHelperCommon/Models/Functions/Decorator/ScaleXDecorator.cs b/StructureHelperCommon/Models/Functions/Decorator/ScaleXDecorator.cs new file mode 100644 index 0000000..0089799 --- /dev/null +++ b/StructureHelperCommon/Models/Functions/Decorator/ScaleXDecorator.cs @@ -0,0 +1,27 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Functions.Decorator +{ + public class ScaleXDecorator : FunctionDecorator + { + private double factor; + public ScaleXDecorator(IOneVariableFunction function, double factor) : base(function) + { + this.factor = factor; + Name = $"{function.Name}, y=f({factor}x)"; + } + public override bool Check() + { + return base.Check(); + } + public override double GetByX(double xValue) + { + return base.GetByX(factor * xValue); + } + } +} diff --git a/StructureHelperCommon/Models/Functions/FormulaFunction.cs b/StructureHelperCommon/Models/Functions/FormulaFunction.cs index 9555b77..4d378e2 100644 --- a/StructureHelperCommon/Models/Functions/FormulaFunction.cs +++ b/StructureHelperCommon/Models/Functions/FormulaFunction.cs @@ -41,6 +41,7 @@ namespace StructureHelperCommon.Models.Functions public ObservableCollection Functions { get; set; } = new ObservableCollection(); public double MinArg { get; set; } public double MaxArg { get; set; } + public IShiftTraceLogger? TraceLogger { get; set; } public FormulaFunction(bool isUser = false) { diff --git a/StructureHelperCommon/Models/Functions/ILimitFunction.cs b/StructureHelperCommon/Models/Functions/ILimitFunction.cs deleted file mode 100644 index d56c643..0000000 --- a/StructureHelperCommon/Models/Functions/ILimitFunction.cs +++ /dev/null @@ -1,14 +0,0 @@ -using StructureHelperCommon.Infrastructures.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StructureHelperCommon.Models.Functions -{ - public interface ILimitFunction : IFunctionDecorator - { - public void Limit(); - } -} diff --git a/StructureHelperCommon/Models/Functions/IScaleFunction.cs b/StructureHelperCommon/Models/Functions/IScaleFunction.cs deleted file mode 100644 index 8735ccc..0000000 --- a/StructureHelperCommon/Models/Functions/IScaleFunction.cs +++ /dev/null @@ -1,14 +0,0 @@ -using StructureHelperCommon.Infrastructures.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StructureHelperCommon.Models.Functions -{ - public interface IScaleFunction : IFunctionDecorator - { - public void Scale(); - } -} diff --git a/StructureHelperCommon/Models/Functions/TableFunction.cs b/StructureHelperCommon/Models/Functions/TableFunction.cs index 743cb57..b0499a9 100644 --- a/StructureHelperCommon/Models/Functions/TableFunction.cs +++ b/StructureHelperCommon/Models/Functions/TableFunction.cs @@ -29,6 +29,7 @@ namespace StructureHelperCommon.Models.Functions public ObservableCollection Functions { get; set; } = new ObservableCollection(); public double MinArg { get; set; } public double MaxArg { get; set; } + public IShiftTraceLogger? TraceLogger { get; set; } public TableFunction(bool isUser = false) { @@ -68,7 +69,9 @@ namespace StructureHelperCommon.Models.Functions public double GetByX(double xValue) { - throw new NotImplementedException(); + //Реализовать взятие значения из таблицы и интерполяцию по таблице + + return 100; } } }