Add GraphViewModel functions realization
This commit is contained in:
@@ -57,7 +57,10 @@
|
|||||||
<Compile Update="Windows\Graphs\GraphView.xaml.cs">
|
<Compile Update="Windows\Graphs\GraphView.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Windows\MainGraph\AddTable.xaml.cs">
|
<Compile Update="Windows\MainGraph\FormulaView.xaml.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="Windows\MainGraph\TableView.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Windows\MainGraph\GraphView.xaml.cs">
|
<Compile Update="Windows\MainGraph\GraphView.xaml.cs">
|
||||||
@@ -164,7 +167,10 @@
|
|||||||
<Page Update="Windows\Graphs\GraphView.xaml">
|
<Page Update="Windows\Graphs\GraphView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Update="Windows\MainGraph\AddTable.xaml">
|
<Page Update="Windows\MainGraph\FormulaView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Update="Windows\MainGraph\TableView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Update="Windows\MainGraph\GraphView.xaml">
|
<Page Update="Windows\MainGraph\GraphView.xaml">
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
<Window x:Class="StructureHelper.Windows.MainGraph.AddTable"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
ResizeMode="CanResize"
|
|
||||||
Title="AddTable" Height="450" Width="400">
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="50"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<DataGrid Grid.Row="0" Margin="5">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTextColumn Width="*" Header="X"/>
|
|
||||||
<DataGridTextColumn Width="*" Header="Y"/>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
<Button Grid.Row="1" Margin="5" Content="Build Graph">
|
|
||||||
|
|
||||||
</Button>
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
using StructureHelper.Infrastructure;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelper.Windows.MainGraph
|
|
||||||
{
|
|
||||||
class AddTableViewModel : ViewModelBase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
12
StructureHelper/Windows/MainGraph/FormulaView.xaml
Normal file
12
StructureHelper/Windows/MainGraph/FormulaView.xaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<Window x:Class="StructureHelper.Windows.MainGraph.FormulaView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="FormulaView" Height="450" Width="800">
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -15,11 +15,11 @@ using System.Windows.Shapes;
|
|||||||
namespace StructureHelper.Windows.MainGraph
|
namespace StructureHelper.Windows.MainGraph
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for AddTable.xaml
|
/// Interaction logic for FormulaView.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AddTable : Window
|
public partial class FormulaView : Window
|
||||||
{
|
{
|
||||||
public AddTable()
|
public FormulaView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
31
StructureHelper/Windows/MainGraph/FormulaViewModel.cs
Normal file
31
StructureHelper/Windows/MainGraph/FormulaViewModel.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Functions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelper.Windows.MainGraph
|
||||||
|
{
|
||||||
|
public class FormulaViewModel
|
||||||
|
{
|
||||||
|
private IOneVariableFunction function;
|
||||||
|
public IOneVariableFunction Function
|
||||||
|
{
|
||||||
|
get => function;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
function = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public FormulaViewModel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public FormulaViewModel(FormulaFunction function)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,16 +38,21 @@
|
|||||||
<RowDefinition Height="50"/>
|
<RowDefinition Height="50"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Button Grid.Column="0" Grid.Row="0" Margin="5" Content="Add table"
|
<Button Grid.Column="0" Grid.Row="0" Margin="5" Content="Add table"
|
||||||
|
Command="{Binding AddTableCommand}"
|
||||||
Background="LightGreen"/>
|
Background="LightGreen"/>
|
||||||
<Button Grid.Column="0" Grid.Row="1" Margin="5" Content="Add formula"
|
<Button Grid.Column="0" Grid.Row="1" Margin="5" Content="Add formula"
|
||||||
|
Command="{Binding AddFormulaCommand}"
|
||||||
Background="LightGreen"/>
|
Background="LightGreen"/>
|
||||||
<Button Grid.Column="1" Grid.Row="0" Margin="5" Content="Edit"
|
<Button Grid.Column="1" Grid.Row="0" Margin="5" Content="Edit"
|
||||||
|
Command="{Binding EditCommand}"
|
||||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
||||||
Background="LightYellow"/>
|
Background="LightYellow"/>
|
||||||
<Button Grid.Column="1" Grid.Row="1" Margin="5" Content="Delete"
|
<Button Grid.Column="1" Grid.Row="1" Margin="5" Content="Delete"
|
||||||
|
Command="{Binding DeleteCommand}"
|
||||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
||||||
Background="LightPink"/>
|
Background="LightPink"/>
|
||||||
<Button Grid.Column="2" Grid.Row="0" Margin="5" Content="Copy"
|
<Button Grid.Column="2" Grid.Row="0" Margin="5" Content="Copy"
|
||||||
|
Command="{Binding CopyCommand}"
|
||||||
Background="LightBlue"/>
|
Background="LightBlue"/>
|
||||||
<Button Grid.Column="2" Grid.Row="1" Margin="5" Content="Tree"
|
<Button Grid.Column="2" Grid.Row="1" Margin="5" Content="Tree"
|
||||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
using LiveCharts.Wpf;
|
using LiveCharts.Wpf;
|
||||||
using StructureHelper.Infrastructure;
|
using StructureHelper.Infrastructure;
|
||||||
using StructureHelper.Windows.TreeGraph;
|
using StructureHelper.Windows.TreeGraph;
|
||||||
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Functions;
|
using StructureHelperCommon.Models.Functions;
|
||||||
using StructureHelperLogics.Models.Graphs;
|
using StructureHelperLogics.Models.Graphs;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace StructureHelper.Windows.MainGraph
|
namespace StructureHelper.Windows.MainGraph
|
||||||
@@ -30,8 +32,8 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
OnPropertyChanged(nameof(SelectedFuntion));
|
OnPropertyChanged(nameof(SelectedFuntion));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<IOneVariableFunction> functions;
|
private ObservableCollection<IOneVariableFunction> functions;
|
||||||
public List<IOneVariableFunction> Functions { get; set; }
|
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -51,19 +53,19 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
}
|
}
|
||||||
public ICommand AddFormulaCommand
|
public ICommand AddFormulaCommand
|
||||||
{
|
{
|
||||||
get => addFormulaCommand ??= new RelayCommand(o => AddTable());
|
get => addFormulaCommand ??= new RelayCommand(o => AddFormula());
|
||||||
}
|
}
|
||||||
public ICommand EditCommand
|
public ICommand EditCommand
|
||||||
{
|
{
|
||||||
get => editCommand ??= new RelayCommand(o => AddTable());
|
get => editCommand ??= new RelayCommand(o => Edit());
|
||||||
}
|
}
|
||||||
public ICommand DeleteCommand
|
public ICommand DeleteCommand
|
||||||
{
|
{
|
||||||
get => deleteCommand ??= new RelayCommand(o => AddTable());
|
get => deleteCommand ??= new RelayCommand(o => Delete());
|
||||||
}
|
}
|
||||||
public ICommand CopyCommand
|
public ICommand CopyCommand
|
||||||
{
|
{
|
||||||
get => copyCommand ??= new RelayCommand(o => AddTable());
|
get => copyCommand ??= new RelayCommand(o => Copy());
|
||||||
}
|
}
|
||||||
public ICommand TreeCommand
|
public ICommand TreeCommand
|
||||||
{
|
{
|
||||||
@@ -71,17 +73,20 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
}
|
}
|
||||||
public GraphViewModel()
|
public GraphViewModel()
|
||||||
{
|
{
|
||||||
Functions = new List<IOneVariableFunction>();
|
Functions = new ObservableCollection<IOneVariableFunction>();
|
||||||
var f1 = new TableFunction();
|
var f1 = new TableFunction();
|
||||||
f1.Name = "Пробная табличная системная функция 1";
|
f1.Name = "Пробная табличная системная функция 1";
|
||||||
|
f1.Table = new List<GraphPoint>();
|
||||||
f1.IsUser = false;
|
f1.IsUser = false;
|
||||||
f1.Description = "Описание 1";
|
f1.Description = "Описание 1";
|
||||||
var f2 = new TableFunction();
|
var f2 = new TableFunction();
|
||||||
f2.Name = "Пробная табличная пользовательская функция 2";
|
f2.Name = "Пробная табличная пользовательская функция 2";
|
||||||
|
f2.Table = new List<GraphPoint>();
|
||||||
f2.IsUser = true;
|
f2.IsUser = true;
|
||||||
f2.Description = "Описание 2";
|
f2.Description = "Описание 2";
|
||||||
var f3 = new FormulaFunction();
|
var f3 = new FormulaFunction();
|
||||||
f3.Name = "Пробная формульная системная функция 3";
|
f3.Name = "Пробная формульная системная функция 3";
|
||||||
|
f3.Formula = "x^2";
|
||||||
f3.IsUser = false;
|
f3.IsUser = false;
|
||||||
f3.Description = "Описание 3";
|
f3.Description = "Описание 3";
|
||||||
Functions.Add(f1);
|
Functions.Add(f1);
|
||||||
@@ -113,23 +118,63 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
}*/
|
}*/
|
||||||
private void AddTable()
|
private void AddTable()
|
||||||
{
|
{
|
||||||
|
var tableViewModel = new TableViewModel();
|
||||||
|
var tableView = new TableView();
|
||||||
|
tableView.DataContext = tableViewModel;
|
||||||
|
if (tableView.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
Functions.Add(tableViewModel.Function);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void AddFormula()
|
private void AddFormula()
|
||||||
{
|
{
|
||||||
|
var formulaViewModel = new FormulaViewModel();
|
||||||
|
var formulaView = new FormulaView();
|
||||||
|
formulaView.DataContext = formulaViewModel;
|
||||||
|
if (formulaView.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
Functions.Add(formulaViewModel.Function);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void Edit()
|
private void Edit()
|
||||||
{
|
{
|
||||||
|
if (SelectedFuntion is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (SelectedFuntion.Type == FunctionType.TableFunction)
|
||||||
|
{
|
||||||
|
var tableViewModel = new TableViewModel(SelectedFuntion as TableFunction);
|
||||||
|
var tableView = new TableView();
|
||||||
|
tableView.DataContext = tableViewModel;
|
||||||
|
tableView.ShowDialog();
|
||||||
|
}
|
||||||
|
else if (SelectedFuntion.Type == FunctionType.FormulaFunction)
|
||||||
|
{
|
||||||
|
var formulaViewModel = new FormulaViewModel(SelectedFuntion as FormulaFunction);
|
||||||
|
var formulaView = new FormulaView();
|
||||||
|
formulaView.DataContext = formulaViewModel;
|
||||||
|
formulaView.ShowDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void Delete()
|
private void Delete()
|
||||||
{
|
{
|
||||||
|
Functions.Remove(SelectedFuntion);
|
||||||
}
|
}
|
||||||
private void Cppy()
|
private void Copy()
|
||||||
{
|
{
|
||||||
|
if (SelectedFuntion is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (SelectedFuntion.Type == FunctionType.TableFunction)
|
||||||
|
{
|
||||||
|
Functions.Add(SelectedFuntion.Clone() as TableFunction);
|
||||||
|
}
|
||||||
|
else if (SelectedFuntion.Type == FunctionType.FormulaFunction)
|
||||||
|
{
|
||||||
|
Functions.Add(SelectedFuntion.Clone() as FormulaFunction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void Tree()
|
private void Tree()
|
||||||
{
|
{
|
||||||
|
|||||||
113
StructureHelper/Windows/MainGraph/TableView.xaml
Normal file
113
StructureHelper/Windows/MainGraph/TableView.xaml
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<Window x:Class="StructureHelper.Windows.MainGraph.TableView"
|
||||||
|
x:Name="TableFunction_win"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
ResizeMode="CanResize"
|
||||||
|
d:DataContext="{d:DesignInstance local:TableViewModel}"
|
||||||
|
Title="TableFunction" Height="500" Width="400"
|
||||||
|
MaxWidth="400"
|
||||||
|
MinWidth="400">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="30"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="50"/>
|
||||||
|
<RowDefinition Height="50"/>
|
||||||
|
<RowDefinition Height="50"/>
|
||||||
|
<RowDefinition Height="50"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid Grid.Column="0" Margin="5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="37"/>
|
||||||
|
<ColumnDefinition Width="150"/>
|
||||||
|
<ColumnDefinition Width="150"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Rectangle Grid.Column="1"
|
||||||
|
Grid.Row="0"
|
||||||
|
Stroke="Gray"/>
|
||||||
|
<Rectangle Grid.Column="2"
|
||||||
|
Grid.Row="0"
|
||||||
|
Stroke="Gray"/>
|
||||||
|
<TextBlock Grid.Column="0">
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Grid.Column="1"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Text="X">
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Grid.Column="2"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Text="Y">
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Grid.Column="3">
|
||||||
|
</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
<ListBox Grid.Row="1" Margin="5"
|
||||||
|
ItemsSource="{Binding Table,
|
||||||
|
UpdateSourceTrigger=PropertyChanged,
|
||||||
|
Mode=TwoWay}"
|
||||||
|
SelectedItem="{Binding SelectedPoint}">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Width="30"
|
||||||
|
MaxWidth="30">
|
||||||
|
</TextBlock>
|
||||||
|
<TextBox Text="{Binding X}"
|
||||||
|
Width="150"
|
||||||
|
MaxWidth="150">
|
||||||
|
</TextBox>
|
||||||
|
<TextBox Text="{Binding Y}"
|
||||||
|
Width="150"
|
||||||
|
MaxWidth="150">
|
||||||
|
</TextBox>
|
||||||
|
<TextBlock Width="25"
|
||||||
|
MaxWidth="25">
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<Grid Grid.Row="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="50"/>
|
||||||
|
<ColumnDefinition Width="50"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button Grid.Column="1" Margin="5" Content="Add"
|
||||||
|
Background="LightGreen" Command="{Binding AddPointCommand}"/>
|
||||||
|
<Button Grid.Column="2" Margin="5" Content="Delete"
|
||||||
|
Background="LightPink" Command="{Binding DeletePointCommand}"/>
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Row="3">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock Grid.Row="0"
|
||||||
|
Margin="5"
|
||||||
|
Text="Name:"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
<TextBox Grid.Row="1" Text="{Binding Name}" Margin="5"/>
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Row="4">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock Grid.Row="0"
|
||||||
|
Margin="5"
|
||||||
|
Text="Description:"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
<TextBox Grid.Row="1" Text="{Binding Name}" Margin="5"/>
|
||||||
|
</Grid>
|
||||||
|
<Button Grid.Row="5" Margin="5" Content="Save"
|
||||||
|
Command="{Binding DrawGraphCommand}"
|
||||||
|
CommandParameter="{Binding ElementName=TableFunction_win}">
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
39
StructureHelper/Windows/MainGraph/TableView.xaml.cs
Normal file
39
StructureHelper/Windows/MainGraph/TableView.xaml.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace StructureHelper.Windows.MainGraph
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for AddTable.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class TableView : Window
|
||||||
|
{
|
||||||
|
private TableViewModel viewModel;
|
||||||
|
|
||||||
|
public TableView(TableViewModel viewModel)
|
||||||
|
{
|
||||||
|
this.viewModel = viewModel;
|
||||||
|
DataContext = this.viewModel;
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
/*public AddTable() : this(new AddTableViewModel())
|
||||||
|
{
|
||||||
|
}*/
|
||||||
|
public TableView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
123
StructureHelper/Windows/MainGraph/TableViewModel.cs
Normal file
123
StructureHelper/Windows/MainGraph/TableViewModel.cs
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
using StructureHelper.Infrastructure;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Functions;
|
||||||
|
using StructureHelperCommon.Models.Shapes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace StructureHelper.Windows.MainGraph
|
||||||
|
{
|
||||||
|
public class TableViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private const string DEFAULT_NAME = "Put function name here...";
|
||||||
|
private const string DEFAULT_DESCRIPTION = "Put function description here...";
|
||||||
|
private RelayCommand drawGraphCommand;
|
||||||
|
private RelayCommand addPointCommand;
|
||||||
|
private RelayCommand deletePointCommand;
|
||||||
|
public ICommand DrawGraphCommand
|
||||||
|
{
|
||||||
|
get => drawGraphCommand ??= new RelayCommand(o => DrawGraph(o));
|
||||||
|
}
|
||||||
|
public ICommand AddPointCommand
|
||||||
|
{
|
||||||
|
get => addPointCommand ??= new RelayCommand(o => AddPoint());
|
||||||
|
}
|
||||||
|
public ICommand DeletePointCommand
|
||||||
|
{
|
||||||
|
get => deletePointCommand ??= new RelayCommand(o => DeletePoint());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ObservableCollection<GraphPoint> table;
|
||||||
|
|
||||||
|
public ObservableCollection<GraphPoint> Table
|
||||||
|
{
|
||||||
|
get => table;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
table = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private GraphPoint selectedPoint;
|
||||||
|
public GraphPoint SelectedPoint
|
||||||
|
{
|
||||||
|
get => selectedPoint;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
selectedPoint = value;
|
||||||
|
OnPropertyChanged(nameof(SelectedPoint));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private IOneVariableFunction function;
|
||||||
|
public IOneVariableFunction Function
|
||||||
|
{
|
||||||
|
get => function;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
function = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private string name;
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => name;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
name = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private string description;
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get => description;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
description = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public TableViewModel()
|
||||||
|
{
|
||||||
|
Table = new ObservableCollection<GraphPoint>()
|
||||||
|
{
|
||||||
|
new GraphPoint(),
|
||||||
|
};
|
||||||
|
Name = DEFAULT_NAME;
|
||||||
|
Description = DEFAULT_DESCRIPTION;
|
||||||
|
}
|
||||||
|
public TableViewModel(TableFunction tableFunction)
|
||||||
|
{
|
||||||
|
Function = tableFunction;
|
||||||
|
Table = new ObservableCollection<GraphPoint>(tableFunction.Table);
|
||||||
|
Name = tableFunction.Name;
|
||||||
|
Description = tableFunction.Description;
|
||||||
|
}
|
||||||
|
private void DrawGraph(object parameter)
|
||||||
|
{
|
||||||
|
if (Function is null)
|
||||||
|
{
|
||||||
|
Function = new TableFunction();
|
||||||
|
}
|
||||||
|
Function.Name = Name;
|
||||||
|
Function.Description = Description;
|
||||||
|
Function.IsUser = true;
|
||||||
|
(Function as TableFunction).Table = Table.ToList();
|
||||||
|
var window = parameter as Window;
|
||||||
|
window.DialogResult = true;
|
||||||
|
window.Close();
|
||||||
|
}
|
||||||
|
private void AddPoint()
|
||||||
|
{
|
||||||
|
var point = new GraphPoint();
|
||||||
|
Table.Add(point);
|
||||||
|
}
|
||||||
|
private void DeletePoint()
|
||||||
|
{
|
||||||
|
Table.Remove(SelectedPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ using StructureHelper.Infrastructure;
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -11,12 +12,13 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
{
|
{
|
||||||
public class TreeGraphViewModel : ViewModelBase
|
public class TreeGraphViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
private List<IOneVariableFunction> nodes;
|
private ObservableCollection<IOneVariableFunction> nodes;
|
||||||
public List<IOneVariableFunction> Nodes { get; set; }
|
public ObservableCollection<IOneVariableFunction> Nodes { get; set; }
|
||||||
public TreeGraphViewModel(IOneVariableFunction function)
|
public TreeGraphViewModel(IOneVariableFunction function)
|
||||||
{
|
{
|
||||||
Nodes = new List<IOneVariableFunction>();
|
Nodes = new ObservableCollection<IOneVariableFunction>();
|
||||||
Nodes.Add(function);
|
Nodes.Add(function);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||||
{
|
{
|
||||||
public interface IOneVariableFunction
|
public interface IOneVariableFunction : ICloneable, ISaveable
|
||||||
{
|
{
|
||||||
|
|
||||||
public bool IsUser { get; set; }
|
public bool IsUser { get; set; }
|
||||||
public FunctionType Type { get; set; }
|
public FunctionType Type { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Functions
|
namespace StructureHelperCommon.Models.Functions
|
||||||
{
|
{
|
||||||
@@ -14,28 +15,29 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public FunctionType Type { get; set; }
|
public FunctionType Type { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Description { get ; set; }
|
public string Description { get ; set; }
|
||||||
|
public string Formula { get; set; }
|
||||||
|
|
||||||
|
public Guid Id => throw new NotImplementedException();
|
||||||
|
|
||||||
public bool Check()
|
public bool Check()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
public double GetByX(double xValue)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CopyOfFormulaFunction : IOneVariableFunction
|
public object Clone()
|
||||||
{
|
|
||||||
public bool IsUser { get; set; }
|
|
||||||
public FunctionType Type { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
|
|
||||||
public bool Check()
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var formulaFunction = new FormulaFunction();
|
||||||
|
|
||||||
|
//Здесь будет стратегия
|
||||||
|
formulaFunction.Type = Type;
|
||||||
|
formulaFunction.Name = Name;
|
||||||
|
formulaFunction.Description = Description;
|
||||||
|
formulaFunction.Formula = Formula;
|
||||||
|
formulaFunction.IsUser = true;
|
||||||
|
|
||||||
|
return formulaFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetByX(double xValue)
|
public double GetByX(double xValue)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
14
StructureHelperCommon/Models/Functions/GraphPoint.cs
Normal file
14
StructureHelperCommon/Models/Functions/GraphPoint.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Functions
|
||||||
|
{
|
||||||
|
public class GraphPoint
|
||||||
|
{
|
||||||
|
public double X { get; set; }
|
||||||
|
public double Y { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -14,28 +15,29 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public FunctionType Type { get; set; }
|
public FunctionType Type { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
public List<GraphPoint> Table { get; set; }
|
||||||
|
|
||||||
|
public Guid Id => throw new NotImplementedException();
|
||||||
|
|
||||||
public bool Check()
|
public bool Check()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
public double GetByX(double xValue)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CopyOfTableFunction : IOneVariableFunction
|
public object Clone()
|
||||||
{
|
|
||||||
public bool IsUser { get; set; }
|
|
||||||
public FunctionType Type { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
|
|
||||||
public bool Check()
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var tableFunction = new TableFunction();
|
||||||
|
|
||||||
|
//Здесь будет стратегия
|
||||||
|
tableFunction.Type = Type;
|
||||||
|
tableFunction.Name = Name;
|
||||||
|
tableFunction.Description = Description;
|
||||||
|
tableFunction.Table = Table;
|
||||||
|
tableFunction.IsUser = true;
|
||||||
|
|
||||||
|
return tableFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetByX(double xValue)
|
public double GetByX(double xValue)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
Reference in New Issue
Block a user