using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using C1.Silverlight.Chart.Extended;

namespace ChartExtended.Samples
{
  public partial class MovingAverageEditor : Editor
  {
    public MovingAverageEditor()
    {
      InitializeComponent();
    }

    protected override void OnDataContextChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
    {
      base.OnDataContextChanged(obj, args);
      MovingAverage ms = DataContext as MovingAverage;
      if (ms != null)
      {
        nbPeriod.Value = ms.Period;
      }
    }

    private void nbPeriod_ValueChanged(object sender, C1.Silverlight.PropertyChangedEventArgs<double> e)
    {
      MovingAverage ms = DataContext as MovingAverage;
      if (ms != null)
      {
        ms.Period = (int)nbPeriod.Value;
        ms.Label = string.Format("MovAvg {0}", ms.Period);
      }
    }
  }
}
