项目结构调整

This commit is contained in:
艾竹
2023-04-16 20:11:40 +08:00
parent cbfbf96033
commit 81f91f3f35
2124 changed files with 218 additions and 5516 deletions

View File

@@ -0,0 +1,38 @@
<UserControl x:Class="Wpf.CartesianChart.MixingSeries.MixingTypes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wpf.CartesianChart"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:mixingSeries="clr-namespace:Wpf.CartesianChart.MixingSeries"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance mixingSeries:MixingTypes}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" TextWrapping="Wrap">
Yes you can mix any series supported by a cartesian chart, just add the series and the chart wll handle it, charts are smart enough to scale according to the contained series.
In this case we will only use ObservableClasses, so the chart updates automatically when a property changes, there are already some observable classes defined in thsi library, you
can also build your own
<Hyperlink NavigateUri="http://lvcharts.net/#/examples/v1/iocp-wpf?path=WPF-Observable" RequestNavigate="OnLinkRequest">
here
</Hyperlink>
is an example
</TextBlock>
<Button Grid.Row="1" Margin="7" Click="UpdateAllOnClick">Click me to update all points</Button>
<lvc:CartesianChart Grid.Row="2" Series="{Binding SeriesCollection}"
Background="#303030">
<lvc:CartesianChart.AxisY>
<lvc:Axis>
<lvc:Axis.Separator>
<lvc:Separator Stroke="#606060"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,101 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Navigation;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
namespace Wpf.CartesianChart.MixingSeries
{
/// <summary>
/// Interaction logic for MixingSeries.xaml
/// </summary>
public partial class MixingTypes : UserControl
{
public MixingTypes()
{
InitializeComponent();
LineSeries = new LineSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(5),
new ObservableValue(7),
new ObservableValue(2),
new ObservableValue(3)
},
PointForeground = new SolidColorBrush(Color.FromRgb(50,50,50)),
AreaLimit = 0
};
ScatterSeries = new ScatterSeries
{
Values = new ChartValues<ScatterPoint>
{
new ScatterPoint(0, 2, 10),
new ScatterPoint(1, 1, 2),
new ScatterPoint(2, 3, 7),
new ScatterPoint(3, 4, 9)
}
};
ColumnSeries = new ColumnSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(5),
new ObservableValue(7),
new ObservableValue(2),
new ObservableValue(3)
}
};
SeriesCollection = new SeriesCollection
{
LineSeries,
ScatterSeries,
ColumnSeries
};
DataContext = this;
}
public ScatterSeries ScatterSeries { get; set; }
public LineSeries LineSeries { get; set; }
public ColumnSeries ColumnSeries { get; set; }
public SeriesCollection SeriesCollection { get; set; }
private void OnLinkRequest(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
private void UpdateAllOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
foreach (var value in LineSeries.Values.Cast<ObservableValue>())
{
value.Value = r.Next(-20, 20);
}
foreach (var value in ColumnSeries.Values.Cast<ObservableValue>())
{
value.Value = r.Next(-20, 20);
}
var i = 0;
foreach (var value in ScatterSeries.Values.Cast<ScatterPoint>())
{
value.X = i;
value.Y = r.Next(-20, 20);
value.Weight = r.Next(-20, 20);
i++;
}
}
}
}