using C1.Xaml.Chart;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace ControlExplorer.Controls.Chart
{
    public sealed partial class Markers : UserControl
    {
        public Markers()
        {
            this.InitializeComponent();

            // can't set NaN in XAML so we must set in code
            ((ChartPanel)c1Chart2.View.Layers[0]).Children[0].DataPoint = new Point(-1, double.NaN);
            ((ChartPanel)c1Chart_Crosshairs.View.Layers[0]).Children[0].DataPoint = new Point(-1, double.NaN);
            ((ChartPanel)c1Chart_Crosshairs.View.Layers[0]).Children[1].DataPoint = new Point(double.NaN, -1);
        }

        private void chkSnap_Checked(object sender, RoutedEventArgs e)
        {
            if(c1Chart_Crosshairs != null)
            {
                ((ChartPanel)c1Chart_Crosshairs.View.Layers[0]).Children[0].Attach = ChartPanelAttach.DataXY;
                ((ChartPanel)c1Chart_Crosshairs.View.Layers[0]).Children[1].Attach = ChartPanelAttach.DataXY;
                ((ChartPanel)c1Chart_Crosshairs.View.Layers[0]).Children[2].Attach = ChartPanelAttach.DataXY;
            }
        }

        private void chkSnap_Unchecked(object sender, RoutedEventArgs e)
        {
            ((ChartPanel)c1Chart_Crosshairs.View.Layers[0]).Children[0].Attach = ChartPanelAttach.None;
            ((ChartPanel)c1Chart_Crosshairs.View.Layers[0]).Children[1].Attach = ChartPanelAttach.None;
            ((ChartPanel)c1Chart_Crosshairs.View.Layers[0]).Children[2].Attach = ChartPanelAttach.None;
        }
    }

    
}
