|
|
|
@ -0,0 +1,98 @@ |
|
|
|
|
using LiveCharts; |
|
|
|
|
using LiveCharts.Defaults; |
|
|
|
|
using LiveCharts.Wpf; |
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.ComponentModel; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Text; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
using System.Windows; |
|
|
|
|
using System.Windows.Controls; |
|
|
|
|
using System.Windows.Data; |
|
|
|
|
using System.Windows.Documents; |
|
|
|
|
using System.Windows.Input; |
|
|
|
|
using System.Windows.Media; |
|
|
|
|
using System.Windows.Media.Imaging; |
|
|
|
|
using System.Windows.Shapes; |
|
|
|
|
|
|
|
|
|
namespace Tutorial |
|
|
|
|
{ |
|
|
|
|
/// <summary> |
|
|
|
|
/// FinancialWindow.xaml에 대한 상호 작용 논리 |
|
|
|
|
/// </summary> |
|
|
|
|
public partial class FinancialWindow : Window, INotifyPropertyChanged |
|
|
|
|
{ |
|
|
|
|
private string[] _labels; |
|
|
|
|
|
|
|
|
|
public SeriesCollection SeriesCollection { get; set; } |
|
|
|
|
public string[] Labels |
|
|
|
|
{ |
|
|
|
|
get { return _labels; } |
|
|
|
|
set |
|
|
|
|
{ |
|
|
|
|
_labels = value; |
|
|
|
|
OnPropertyChanged(nameof(Labels)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged; |
|
|
|
|
|
|
|
|
|
public FinancialWindow() |
|
|
|
|
{ |
|
|
|
|
InitializeComponent(); |
|
|
|
|
InitInstance(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void InitInstance() |
|
|
|
|
{ |
|
|
|
|
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 |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Labels = new string[] |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected virtual void OnPropertyChanged(string propertyName = null) |
|
|
|
|
{ |
|
|
|
|
if (PropertyChanged != null) |
|
|
|
|
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void btnUpdate_Click(object sender, RoutedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
Random rand = new Random(); |
|
|
|
|
foreach (var point in SeriesCollection[0].Values.Cast<OhlcPoint>()) |
|
|
|
|
{ |
|
|
|
|
point.Open = rand.Next((int)point.Low, (int)point.High); |
|
|
|
|
point.Close = rand.Next((int)point.Low, (int)point.High); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |