57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using System;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Input;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Markup.Xaml;
|
|
using Eremex.AvaloniaUI.Controls.Utils;
|
|
using PortfolioManager.ViewModels;
|
|
using ScottPlot;
|
|
using ScottPlot.Avalonia;
|
|
using ScottPlot.DataSources;
|
|
using ScottPlot.Plottables;
|
|
|
|
namespace PortfolioManager.Views;
|
|
|
|
public partial class BollingerBandView : UserControl
|
|
{
|
|
public BollingerBandView()
|
|
{
|
|
this.DataContextChanged += OnDataContextChanged;
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void OnDataContextChanged(object sender, EventArgs e)
|
|
{
|
|
if (default != (sender as BollingerBandView))
|
|
{
|
|
BollingerBandView view = (sender as BollingerBandView);
|
|
PlotterWorkspaceViewModel viewModel = (DataContext as PlotterWorkspaceViewModel);
|
|
if (null!=viewModel && default == viewModel.Plotter)
|
|
{
|
|
viewModel.Plotter = new AvaPlot();
|
|
viewModel.Plotter.PointerMoved+=OnPointerMoved;
|
|
viewModel.OnPlotterLoaded(viewModel.Plotter);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnPointerMoved(object sender, PointerEventArgs pointerEventArgs)
|
|
{
|
|
// AvaPlot avaPlot = (sender as AvaPlot);
|
|
// if(default == avaPlot)return;
|
|
// Point position = pointerEventArgs.GetPosition(this);
|
|
// avaPlot.Plot.Remove<Crosshair>();
|
|
// avaPlot.Plot.Add.Crosshair(position.X,position.Y);
|
|
// avaPlot.Refresh();
|
|
|
|
// Point clientMousePosition = avaPlot.PointToClient(new PixelPoint((int)position.X,(int)position.Y));
|
|
// avaPlot.Plot.Add.Crosshair(clientMousePosition.X,clientMousePosition.Y);
|
|
// PointerPoint point = pointerEventArgs.GetCurrentPoint(null);
|
|
// Point position = point.Position;
|
|
// Point clientPoint = avaPlot.PointToClient(new PixelPoint((int)position.X,(int)position.Y));
|
|
// Coordinates coordinates = avaPlot.Plot.GetCoordinates(position.X, position.Y);
|
|
// avaPlot.Plot.Remove<Crosshair>();
|
|
// avaPlot.Plot.Add.Crosshair(position.X,position.Y);
|
|
}
|
|
} |