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