Add graph service
This commit is contained in:
@@ -22,7 +22,7 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
lineSeries.LineSmoothness = visualProps.LineSmoothness;
|
lineSeries.LineSmoothness = visualProps.LineSmoothness;
|
||||||
lineSeries.PointGeometry = DefaultGeometries.Circle;
|
lineSeries.PointGeometry = DefaultGeometries.Circle;
|
||||||
lineSeries.PointGeometrySize = visualProps.StrokeSize;
|
lineSeries.PointGeometrySize = visualProps.StrokeSize;
|
||||||
Color lineColor = (lineSeries.Stroke as SolidColorBrush)?.Color ?? Colors.Black;
|
Color lineColor = (lineSeries.Stroke as SolidColorBrush)?.Color ?? Colors.LightGray;
|
||||||
//lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
//lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
||||||
lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
OnPropertyChanged(nameof(Opacity));
|
OnPropertyChanged(nameof(Opacity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphVisualProps()
|
public GraphVisualProps()
|
||||||
{
|
{
|
||||||
MaxLineSmoothness = 1d;
|
MaxLineSmoothness = 1d;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="170"/>
|
||||||
<RowDefinition Height="100"/>
|
<RowDefinition Height="100"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ListView Name="FunctionList"
|
<ListView Name="FunctionList"
|
||||||
@@ -120,7 +121,10 @@
|
|||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</ListView.ContextMenu>
|
</ListView.ContextMenu>
|
||||||
</ListView>
|
</ListView>
|
||||||
<Grid Grid.Row="1" Grid.Column="0">
|
<ContentControl Grid.Row="1"
|
||||||
|
ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}"
|
||||||
|
Content="{Binding VisualProps}"/>
|
||||||
|
<Grid Grid.Row="2" Grid.Column="0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="100"/>
|
<ColumnDefinition Width="100"/>
|
||||||
<ColumnDefinition Width="100"/>
|
<ColumnDefinition Width="100"/>
|
||||||
@@ -153,7 +157,7 @@
|
|||||||
Command="{Binding TreeCommand}"
|
Command="{Binding TreeCommand}"
|
||||||
Background="AntiqueWhite"/>
|
Background="AntiqueWhite"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<lvc:CartesianChart Grid.Row="0" Grid.Column="1"
|
<lvc:CartesianChart Grid.Row="0" Grid.Column="1" Grid.RowSpan="2"
|
||||||
Series="{Binding SeriesCollection, UpdateSourceTrigger=PropertyChanged}" Margin="5"
|
Series="{Binding SeriesCollection, UpdateSourceTrigger=PropertyChanged}" Margin="5"
|
||||||
Zoom="Xy">
|
Zoom="Xy">
|
||||||
<lvc:CartesianChart.AxisY>
|
<lvc:CartesianChart.AxisY>
|
||||||
@@ -163,7 +167,7 @@
|
|||||||
<lvc:Axis Title="X" Labels="{Binding Labels, UpdateSourceTrigger=PropertyChanged}"></lvc:Axis>
|
<lvc:Axis Title="X" Labels="{Binding Labels, UpdateSourceTrigger=PropertyChanged}"></lvc:Axis>
|
||||||
</lvc:CartesianChart.AxisX>
|
</lvc:CartesianChart.AxisX>
|
||||||
</lvc:CartesianChart>
|
</lvc:CartesianChart>
|
||||||
<Grid Grid.Row="1" Grid.Column="1">
|
<Grid Grid.Row="2" Grid.Column="1">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="30"/>
|
<RowDefinition Height="30"/>
|
||||||
<RowDefinition Height="70"/>
|
<RowDefinition Height="70"/>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using LiveCharts;
|
using LiveCharts;
|
||||||
using LiveCharts.Wpf;
|
using LiveCharts.Wpf;
|
||||||
using StructureHelper.Infrastructure;
|
using StructureHelper.Infrastructure;
|
||||||
|
using StructureHelper.Windows.Graphs;
|
||||||
using StructureHelper.Windows.TreeGraph;
|
using StructureHelper.Windows.TreeGraph;
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
@@ -17,15 +18,26 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
{
|
{
|
||||||
public class GraphViewModel : ViewModelBase
|
public class GraphViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
private LineSeries lineSeries;
|
||||||
private SeriesCollection seriesCollection;
|
private SeriesCollection seriesCollection;
|
||||||
private List<string> labels;
|
private List<string> labels;
|
||||||
|
private GraphVisualProps visualProps = new();
|
||||||
|
public LineSeries LineSeries
|
||||||
|
{
|
||||||
|
get => lineSeries;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lineSeries = value;
|
||||||
|
OnPropertyChanged(nameof(lineSeries));
|
||||||
|
}
|
||||||
|
}
|
||||||
public SeriesCollection SeriesCollection
|
public SeriesCollection SeriesCollection
|
||||||
{
|
{
|
||||||
get => seriesCollection;
|
get => seriesCollection;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
seriesCollection = value;
|
seriesCollection = value;
|
||||||
OnPropertyChanged(nameof(seriesCollection));
|
OnPropertyChanged(nameof(SeriesCollection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public List<string> Labels
|
public List<string> Labels
|
||||||
@@ -37,6 +49,15 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
OnPropertyChanged(nameof(labels));
|
OnPropertyChanged(nameof(labels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public GraphVisualProps VisualProps
|
||||||
|
{
|
||||||
|
get => visualProps;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
visualProps = value;
|
||||||
|
DrawGraph();
|
||||||
|
}
|
||||||
|
}
|
||||||
private IOneVariableFunction selectedFunction;
|
private IOneVariableFunction selectedFunction;
|
||||||
public IOneVariableFunction SelectedFuntion
|
public IOneVariableFunction SelectedFuntion
|
||||||
{
|
{
|
||||||
@@ -219,7 +240,10 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
{
|
{
|
||||||
var graphSettings = SelectedFuntion.GetGraphSettings();
|
var graphSettings = SelectedFuntion.GetGraphSettings();
|
||||||
Labels = graphSettings.GetLabels();
|
Labels = graphSettings.GetLabels();
|
||||||
SeriesCollection = graphSettings.GetSeriesCollection();
|
LineSeries = graphSettings.GetLineSeries();
|
||||||
|
GraphService.SetVisualProps(LineSeries, VisualProps);
|
||||||
|
SeriesCollection = new SeriesCollection();
|
||||||
|
SeriesCollection.Add(LineSeries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="170"/>
|
||||||
<RowDefinition Height="50"/>
|
<RowDefinition Height="50"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TreeView Name="FunctionTreeView"
|
<TreeView Name="FunctionTreeView"
|
||||||
@@ -85,7 +86,10 @@
|
|||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</TreeView.ContextMenu>
|
</TreeView.ContextMenu>
|
||||||
</TreeView>
|
</TreeView>
|
||||||
<Grid Grid.Row="1" Grid.Column="0">
|
<ContentControl Grid.Row="1"
|
||||||
|
ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}"
|
||||||
|
Content="{Binding VisualProps}"/>
|
||||||
|
<Grid Grid.Row="2" Grid.Column="0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="50"/>
|
<ColumnDefinition Width="50"/>
|
||||||
<ColumnDefinition Width="50"/>
|
<ColumnDefinition Width="50"/>
|
||||||
|
|||||||
@@ -13,11 +13,13 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using StructureHelperCommon.Models.Functions.Decorator;
|
using StructureHelperCommon.Models.Functions.Decorator;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using StructureHelper.Windows.Graphs;
|
||||||
|
|
||||||
namespace StructureHelper.Windows.TreeGraph
|
namespace StructureHelper.Windows.TreeGraph
|
||||||
{
|
{
|
||||||
public class TreeGraphViewModel : ViewModelBase
|
public class TreeGraphViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
private LineSeries lineSeries;
|
||||||
private SeriesCollection seriesCollection;
|
private SeriesCollection seriesCollection;
|
||||||
private List<string> labels;
|
private List<string> labels;
|
||||||
readonly ObservableCollection<TreeViewItemViewModel> _firstGeneration;
|
readonly ObservableCollection<TreeViewItemViewModel> _firstGeneration;
|
||||||
@@ -47,7 +49,7 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
seriesCollection = value;
|
seriesCollection = value;
|
||||||
OnPropertyChanged(nameof(seriesCollection));
|
OnPropertyChanged(nameof(SeriesCollection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public List<string> Labels
|
public List<string> Labels
|
||||||
@@ -59,6 +61,15 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
OnPropertyChanged(nameof(labels));
|
OnPropertyChanged(nameof(labels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public LineSeries LineSeries
|
||||||
|
{
|
||||||
|
get => lineSeries;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lineSeries = value;
|
||||||
|
OnPropertyChanged(nameof(lineSeries));
|
||||||
|
}
|
||||||
|
}
|
||||||
public TreeGraphView TreeGraphView_win
|
public TreeGraphView TreeGraphView_win
|
||||||
{
|
{
|
||||||
get => _treeGraphView_win;
|
get => _treeGraphView_win;
|
||||||
@@ -68,6 +79,7 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
{
|
{
|
||||||
get => _firstGeneration;
|
get => _firstGeneration;
|
||||||
}
|
}
|
||||||
|
public GraphVisualProps VisualProps { get; } = new GraphVisualProps();
|
||||||
public ICommand GetYCommand
|
public ICommand GetYCommand
|
||||||
{
|
{
|
||||||
get => _getYCommand ??= new RelayCommand(o => GetY());
|
get => _getYCommand ??= new RelayCommand(o => GetY());
|
||||||
@@ -215,7 +227,10 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
SelectedFuntion = selectedTreeViewItem.Function;
|
SelectedFuntion = selectedTreeViewItem.Function;
|
||||||
var graphSettings = SelectedFuntion.GetGraphSettings();
|
var graphSettings = SelectedFuntion.GetGraphSettings();
|
||||||
Labels = graphSettings.GetLabels();
|
Labels = graphSettings.GetLabels();
|
||||||
SeriesCollection = graphSettings.GetSeriesCollection();
|
LineSeries = graphSettings.GetLineSeries();
|
||||||
|
GraphService.SetVisualProps(LineSeries, VisualProps);
|
||||||
|
SeriesCollection = new SeriesCollection();
|
||||||
|
SeriesCollection.Add(LineSeries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
{
|
{
|
||||||
double yValue = 0;
|
double yValue = 0;
|
||||||
current_xValue = xValue;
|
current_xValue = xValue;
|
||||||
Check();
|
|
||||||
yValue = Math.Round(Expression.CalculateValue(new double[] { xValue }), 2);
|
yValue = Math.Round(Expression.CalculateValue(new double[] { xValue }), 2);
|
||||||
return yValue;
|
return yValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace StructureHelperCommon.Services
|
|||||||
}
|
}
|
||||||
return _labels;
|
return _labels;
|
||||||
}
|
}
|
||||||
public SeriesCollection GetSeriesCollection()
|
public LineSeries GetLineSeries()
|
||||||
{
|
{
|
||||||
foreach (GraphPoint point in GraphPoints)
|
foreach (GraphPoint point in GraphPoints)
|
||||||
{
|
{
|
||||||
@@ -41,9 +41,21 @@ namespace StructureHelperCommon.Services
|
|||||||
}
|
}
|
||||||
_lineSeries.Values = _chartValues;
|
_lineSeries.Values = _chartValues;
|
||||||
_lineSeries.Stroke = new SolidColorBrush(_strokeColor);
|
_lineSeries.Stroke = new SolidColorBrush(_strokeColor);
|
||||||
|
_lineSeries.Fill = Brushes.Transparent;
|
||||||
|
return _lineSeries;
|
||||||
|
}
|
||||||
|
/*public SeriesCollection GetSeriesCollection()
|
||||||
|
{
|
||||||
|
foreach (GraphPoint point in GraphPoints)
|
||||||
|
{
|
||||||
|
_chartValues.Add(Math.Round(point.Y, 2));
|
||||||
|
}
|
||||||
|
_lineSeries.Values = _chartValues;
|
||||||
|
_lineSeries.Stroke = new SolidColorBrush(_strokeColor);
|
||||||
|
|
||||||
_lineSeries.Fill = Brushes.Transparent;
|
_lineSeries.Fill = Brushes.Transparent;
|
||||||
_seriesCollection.Add(_lineSeries);
|
_seriesCollection.Add(_lineSeries);
|
||||||
return _seriesCollection;
|
return _seriesCollection;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user