项目结构调整

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,26 @@
<UserControl x:Class="Wpf.CartesianChart.Financial.CandleStickExample"
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.Financial"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0">
<Bold>New in 0.7.0</Bold> Financial series
</TextBlock>
<Button Grid.Row="1" Click="UpdateAllOnClick">Update Open and Close</Button>
<lvc:CartesianChart Grid.Row="2" Series="{Binding SeriesCollection}">
<lvc:CartesianChart.AxisX>
<lvc:Axis Labels="{Binding Labels}"/>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,108 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
namespace Wpf.CartesianChart.Financial
{
/// <summary>
/// Interaction logic for CandleStickExample.xaml
/// </summary>
public partial class CandleStickExample : UserControl, INotifyPropertyChanged
{
private string[] _labels;
public CandleStickExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new CandleSeries
{
Values = new ChartValues<OhlcPoint>
{
new OhlcPoint(32, 35, 30, 32),
new OhlcPoint(33, 38, 31, 37),
new OhlcPoint(35, 42, 30, 40),
new OhlcPoint(37, 40, 35, 38),
new OhlcPoint(35, 38, 32, 33),
new OhlcPoint(32, 35, 30, 32),
new OhlcPoint(33, 38, 31, 37),
new OhlcPoint(35, 42, 30, 40),
new OhlcPoint(37, 40, 35, 38),
new OhlcPoint(35, 38, 32, 33),
new OhlcPoint(32, 35, 30, 32),
new OhlcPoint(33, 38, 31, 37),
new OhlcPoint(35, 42, 30, 40),
new OhlcPoint(37, 40, 35, 38),
new OhlcPoint(35, 38, 32, 33),
new OhlcPoint(32, 35, 30, 32),
new OhlcPoint(33, 38, 31, 37),
new OhlcPoint(35, 42, 30, 40),
new OhlcPoint(37, 40, 35, 38),
new OhlcPoint(35, 38, 32, 33),
new OhlcPoint(32, 35, 30, 32),
new OhlcPoint(33, 38, 31, 37),
new OhlcPoint(35, 42, 30, 40),
new OhlcPoint(37, 40, 35, 38),
new OhlcPoint(35, 38, 32, 33)
}
}
};
//based on https://github.com/beto-rodriguez/Live-Charts/issues/166
//The Ohcl point X property is zero based indexed.
//this means the first point is 0, second 1, third 2.... and so on
//then you can use the Axis.Labels properties to map the chart X with a label in the array.
//for more info see (mapped labels section)
//http://lvcharts.net/#/examples/v1/labels-wpf?path=WPF-Components-Labels
Labels = new[]
{
DateTime.Now.ToString("dd MMM"),
DateTime.Now.AddDays(1).ToString("dd MMM"),
DateTime.Now.AddDays(2).ToString("dd MMM"),
DateTime.Now.AddDays(3).ToString("dd MMM"),
DateTime.Now.AddDays(4).ToString("dd MMM"),
};
DataContext = this;
}
public SeriesCollection SeriesCollection { get; set; }
public string[] Labels
{
get { return _labels; }
set
{
_labels = value;
OnPropertyChanged("Labels");
}
}
private void UpdateAllOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
foreach (var point in SeriesCollection[0].Values.Cast<OhlcPoint>())
{
point.Open = r.Next((int)point.Low, (int)point.High);
point.Close = r.Next((int)point.Low, (int)point.High);
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName = null)
{
if (PropertyChanged != null) PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -0,0 +1,24 @@
<UserControl x:Class="Wpf.CartesianChart.Financial.OhclExample"
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:financial="clr-namespace:Wpf.CartesianChart.Financial"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance financial:OhclExample }">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="1" Click="UpdateAllOnClick">Update Open and Close</Button>
<lvc:CartesianChart Grid.Row="2" Series="{Binding SeriesCollection}">
<lvc:CartesianChart.AxisX>
<lvc:Axis Labels="{Binding Labels}"/>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,91 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
using Wpf.Annotations;
namespace Wpf.CartesianChart.Financial
{
public partial class OhclExample : UserControl, INotifyPropertyChanged
{
private string[] _labels;
public OhclExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new OhlcSeries()
{
Values = new ChartValues<OhlcPoint>
{
new OhlcPoint(32, 35, 30, 32),
new OhlcPoint(33, 38, 31, 37),
new OhlcPoint(35, 42, 30, 40),
new OhlcPoint(37, 40, 35, 38),
new OhlcPoint(35, 38, 32, 33)
}
},
new LineSeries
{
Values = new ChartValues<double> {30, 32, 35, 30, 28},
Fill = Brushes.Transparent
}
};
//based on https://github.com/beto-rodriguez/Live-Charts/issues/166
//The Ohcl point X property is zero based indexed.
//this means the first point is 0, second 1, third 2.... and so on
//then you can use the Axis.Labels properties to map the chart X with a label in the array.
//for more info see (mapped labels section)
//http://lvcharts.net/#/examples/v1/labels-wpf?path=WPF-Components-Labels
Labels = new []
{
DateTime.Now.ToString("dd MMM"),
DateTime.Now.AddDays(1).ToString("dd MMM"),
DateTime.Now.AddDays(2).ToString("dd MMM"),
DateTime.Now.AddDays(3).ToString("dd MMM"),
DateTime.Now.AddDays(4).ToString("dd MMM"),
};
DataContext = this;
}
public SeriesCollection SeriesCollection { get; set; }
public string[] Labels
{
get { return _labels; }
set
{
_labels = value;
OnPropertyChanged("Labels");
}
}
private void UpdateAllOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
foreach (var point in SeriesCollection[0].Values.Cast<OhlcPoint>())
{
point.Open = r.Next((int) point.Low, (int) point.High);
point.Close = r.Next((int) point.Low, (int) point.High);
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName = null)
{
if (PropertyChanged != null) PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}