项目结构调整

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,43 @@
<UserControl x:Class="Wpf.CartesianChart.Sections.SectionsExample"
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:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:sections="clr-namespace:Wpf.CartesianChart.Sections"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance sections:SectionsExample}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="1" Click="UpdateAllOnClick">
Move All
</Button>
<lvc:CartesianChart Name="Chart" Grid.Row="2" Series="{Binding SeriesCollection}" >
<lvc:CartesianChart.AxisY>
<lvc:Axis Name="Axis">
<lvc:Axis.Sections>
<lvc:AxisSection Value="8.5" StrokeThickness="3" Stroke="#F9D648">
<lvc:AxisSection.Fill>
<SolidColorBrush Color="#A3A3FF" Opacity=".4"></SolidColorBrush>
</lvc:AxisSection.Fill>
</lvc:AxisSection>
<lvc:AxisSection Value="4" SectionWidth="8" Label="Good">
<lvc:AxisSection.Fill>
<SolidColorBrush Color="#CDCDCD" Opacity=".4"></SolidColorBrush>
</lvc:AxisSection.Fill>
</lvc:AxisSection>
<lvc:AxisSection Value="0" SectionWidth="4" Label="Bad">
<lvc:AxisSection.Fill>
<SolidColorBrush Color="#FF8585" Opacity=".4"></SolidColorBrush>
</lvc:AxisSection.Fill>
</lvc:AxisSection>
</lvc:Axis.Sections>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,72 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
namespace Wpf.CartesianChart.Sections
{
public partial class SectionsExample : UserControl
{
public SectionsExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new LineSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(3),
new ObservableValue(5),
new ObservableValue(2),
new ObservableValue(7),
new ObservableValue(7),
new ObservableValue(4)
},
PointGeometrySize = 0,
StrokeThickness = 4,
Fill = Brushes.Transparent
},
new LineSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(3),
new ObservableValue(4),
new ObservableValue(6),
new ObservableValue(8),
new ObservableValue(7),
new ObservableValue(5)
},
PointGeometrySize = 0,
StrokeThickness = 4,
Fill = Brushes.Transparent
}
};
DataContext = this;
}
public SeriesCollection SeriesCollection { get; set; }
private void UpdateAllOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
foreach (var series in SeriesCollection)
{
foreach (var observable in series.Values.Cast<ObservableValue>())
{
observable.Value = r.Next(0, 10);
}
}
}
}
}