public CurrencyHistoryTrending() { InitializeComponent(); temp = new LineSeries(); _added = false; var gradientBrush = new LinearGradientBrush { StartPoint = new Point(0, 0), EndPoint = new Point(0, 1) }; gradientBrush.GradientStops.Add(new GradientStop(Color.FromRgb(64, 224, 208), 0)); gradientBrush.GradientStops.Add(new GradientStop(Colors.Transparent, 1)); //var dayConfig = Mappers.Xy<DateModel>() // .X(dayModel => (double)dayModel.DateTime.Ticks) // .Y(dayModel => dayModel.Value); _args = new FetchArgs { DefaultCurrency = Configuration.Instance.DefaultCurrency, Symbol = Configuration.Instance.Symbol, FullName = Configuration.Instance.FullName, RefreshRate = Configuration.Instance.RefreshRate }; XFormatter = value => new DateTime((long)value).ToString("dd.MM.yyyy. HH:mm:ss"); // XFormatter = value => new DateTime(Math.Max(0,((long)value / TimeSpan.FromSeconds(1).Ticks))).ToString("dd.MM.yyyy. HH:mm:ss"); //XFormatter = val => new DateTime((long)Math.Max(0, val)).ToString("dd MM yyyy HH:mm:ss"); YFormatter = val => val.ToString("0.##") + " " + _args.DefaultCurrency; SeriesCollection = new SeriesCollection { new LineSeries { // Configuration = dayConfig, //AreaLimit = -10, Values = GetData(), Fill = gradientBrush, StrokeThickness = 1, PointGeometrySize = 10, Title = _args.FullName, } }; ZoomingMode = ZoomingOptions.Xy; Title = _args.FullName; DataContext = this; }
/// <summary> /// The method to vinvoke this event. /// </summary> /// <param name="e">The given argument class (<see cref="FetchArgs"/>)</param> /// <returns></returns> protected virtual int OnFetch(FetchArgs e) { try { FetchEvent?.Invoke(this, e); return(0); } catch (Exception ex) { throw ex; } }
public DigitalCurrencyHisotryTrendind() { InitializeComponent(); temp = new LineSeries(); _added = false; var gradientBrush = new LinearGradientBrush { StartPoint = new Point(0, 0), EndPoint = new Point(0, 1) }; gradientBrush.GradientStops.Add(new GradientStop(Color.FromRgb(64, 224, 208), 0)); gradientBrush.GradientStops.Add(new GradientStop(Colors.Transparent, 1)); _connection.Connect("5XQ6Y6JJKEOQ7JRU"); _args = new FetchArgs { DefaultCurrency = Configuration.Instance.DefaultCurrency, Symbol = Configuration.Instance.Symbol, FullName = Configuration.Instance.FullName, RefreshRate = Configuration.Instance.RefreshRate }; XFormatter = val => new DateTime((long)val).ToString("dd MMM yyyy"); YFormatter = val => val.ToString("0.##") + " " + _args.DefaultCurrency; SeriesCollection = new SeriesCollection { new LineSeries { Values = GetData(), Fill = gradientBrush, StrokeThickness = 1, PointGeometrySize = 0, Title = _args.FullName, } }; ZoomingMode = ZoomingOptions.Xy; Title = _args.FullName; DataContext = this; }
public RealtimeViewer() { InitializeComponent(); addRefreshRates(); _connection.Connect("5XQ6Y6JJKEOQ7JRU"); _args = new FetchArgs { DefaultCurrency = Configuration.Instance.DefaultCurrency, Symbol = Configuration.Instance.Symbol, FullName = Configuration.Instance.FullName, RefreshRate = Configuration.Instance.RefreshRate, Type = Configuration.Instance.Type }; Init(); DataContext = this; }
/// <summary> /// The method to vinvoke this event. /// </summary> /// <param name="e">The given argument class (<see cref="FetchArgs"/>)</param> /// <returns></returns> protected virtual int OnSQLiteFetch(FetchArgs e) { FetchEvent?.Invoke(this, e); return(0); }
public RealTimeTrending() { InitializeComponent(); var dayConfig = Mappers.Xy <DateTimePoint>() .X(dayModel => (double)dayModel.DateTime.Ticks / TimeSpan.FromMilliseconds(1000).Ticks) .Y(dayModel => dayModel.Value); _connection.Connect("5XQ6Y6JJKEOQ7JRU"); _args = new FetchArgs { DefaultCurrency = "RSD", Symbol = "MSFT", RefreshRate = 5 }; LastHourSeries = new SeriesCollection { new LineSeries { Configuration = dayConfig, AreaLimit = -10, //Values = GetData(), Values = new ChartValues <DateTimePoint> { new DateTimePoint { Value = 1, DateTime = DateTime.Now }, new DateTimePoint { Value = 5, DateTime = DateTime.Now.AddSeconds(1) }, new DateTimePoint { Value = 3, DateTime = DateTime.Now.AddSeconds(2) }, new DateTimePoint { Value = 4, DateTime = DateTime.Now.AddSeconds(3) }, new DateTimePoint { Value = 7, DateTime = DateTime.Now.AddSeconds(4) }, new DateTimePoint { Value = 2, DateTime = DateTime.Now.AddSeconds(5) }, new DateTimePoint { Value = 11, DateTime = DateTime.Now.AddSeconds(6) }, new DateTimePoint { Value = 6, DateTime = DateTime.Now.AddSeconds(7) }, new DateTimePoint { Value = 9, DateTime = DateTime.Now.AddSeconds(8) }, new DateTimePoint { Value = 1, DateTime = DateTime.Now.AddSeconds(9) }, new DateTimePoint { Value = 3, DateTime = DateTime.Now.AddSeconds(10) }, new DateTimePoint { Value = 9, DateTime = DateTime.Now.AddSeconds(11) }, } }, }; Step = 0; LastLecture = 0; //timer = new DispatcherTimer(); //timer.Tick += new EventHandler(SetValues); //timer.Interval = new TimeSpan(0, 0, _args.RefreshRate); //timer.Start(); Task.Run(() => { ChartValues <DateTimePoint> values = new ChartValues <DateTimePoint>(); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); while (true) { Thread.Sleep(4000); _backgroindWork = Task.Factory.StartNew(() => { values = GetData(); }, TaskCreationOptions.LongRunning); //Dispatcher.Invoke(() => { // if (values.Count != 0) // { // LastHourSeries[0].Values = values; // Step = ((ChartValues<DateModel>)LastHourSeries[0].Values).Last().Value - // ((ChartValues<DateModel>)LastHourSeries[0].Values).ElementAt( // ((ChartValues<DateModel>)LastHourSeries[0].Values).Count - 2).Value; // if (Step > 0) // ForegroundColor = Brushes.Green; // else if (Step < 0) // ForegroundColor = Brushes.Red; // else // ForegroundColor = Brushes.Black; // LastLecture = ((ChartValues<DateModel>)LastHourSeries[0].Values).Last().Value; // } // MessageBox.Show("Refresh", "Refrash"); //}); _backgroindWork.ContinueWith(x => { Dispatcher.Invoke(() => { using (Dispatcher.DisableProcessing()) { LastHourSeries[0].Values.Add(values.Last()); LastHourSeries[0].Values.RemoveAt(0); //LastHourSeries[0].Values = values; } }, DispatcherPriority.ContextIdle); Step = ((ChartValues <DateTimePoint>)LastHourSeries[0].Values).Last().Value - ((ChartValues <DateTimePoint>)LastHourSeries[0].Values).ElementAt( ((ChartValues <DateTimePoint>)LastHourSeries[0].Values).Count - 2).Value; if (Step > 0) { ForegroundColor = Brushes.Green; } else if (Step < 0) { ForegroundColor = Brushes.Red; } else { ForegroundColor = Brushes.Black; } LastLecture = ((ChartValues <DateTimePoint>)LastHourSeries[0].Values).Last().Value; //MessageBox.Show("Refresh", "Refrash"); }, TaskScheduler.FromCurrentSynchronizationContext()); } //while (true) //{ // Thread.Sleep(5000); // Dispatcher.BeginInvoke(new Action(()=> { // values = GetData(); // }), DispatcherPriority.Background); // Application.Current.Dispatcher.Invoke(() => { // if(values.Count != 0) // { // LastHourSeries[0].Values = values; // Step = ((ChartValues<DateModel>)LastHourSeries[0].Values).Last().Value - // ((ChartValues<DateModel>)LastHourSeries[0].Values).ElementAt( // ((ChartValues<DateModel>)LastHourSeries[0].Values).Count - 2).Value; // if (Step > 0) // ForegroundColor = Brushes.Green; // else if (Step < 0) // ForegroundColor = Brushes.Red; // else // ForegroundColor = Brushes.Black; // LastLecture = ((ChartValues<DateModel>)LastHourSeries[0].Values).Last().Value; // } // }); //} }); //Task.Run(() => //{ // var r = new Random(); // while (true) // { // Thread.Sleep(5000); // //var values = GetData(); // //foreach (var temp in GetData()) // //{ // // Console.WriteLine(temp.Value + " " + temp.DateTime.ToLongTimeString()); // //} // //foreach( var temp in values) // //{ // // Thread.Sleep(1000); // // _trend = temp.Value; // // Application.Current.Dispatcher.Invoke(() => // // { // // if (_trend > ((ChartValues<DateModel>)LastHourSeries[0].Values).Last().Value) // // ForegroundColor = Brushes.Green; // // else if (_trend < ((ChartValues<DateModel>)LastHourSeries[0].Values).Last().Value) // // ForegroundColor = Brushes.Red; // // else // // ForegroundColor = Brushes.Black; // // LastHourSeries[0].Values.Add(temp); // // LastHourSeries[0].Values.RemoveAt(0); // // SetLecture(); // // }); // //} // //Thread.Sleep(1000); // _trend += (r.NextDouble() > 0.3 ? 1 : -1) * r.Next(0, 5); // Application.Current.Dispatcher.Invoke(() => // { // //LastHourSeries[0].Values.Add(new DateModel { Value = _trend, DateTime = DateTime.Now }); // //LastHourSeries[0].Values.RemoveAt(0); // LastHourSeries[0].Values = new ChartValues<DateModel> // { // new DateModel{Value = (r.NextDouble() > 0.3 ? 1 : -1) * r.Next(0, 5), DateTime = DateTime.Now}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 2 : -2) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(1)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 3 : -3) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(2)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 4 : -4) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(3)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 5 : -5) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(4)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 6 : -6) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(5)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 7 : -7) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(6)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 8 : -8) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(7)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 9 : -9) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(8)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 10 : -10) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(9)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 11 : -11) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(10)}, // new DateModel{Value = (r.NextDouble() > 0.3 ? 12 : -12) * r.Next(0, 5), DateTime = DateTime.Now.AddSeconds(11)}, // }; // Step = ((ChartValues<DateModel>)LastHourSeries[0].Values).Last().Value - // ((ChartValues<DateModel>)LastHourSeries[0].Values).ElementAt( // ((ChartValues<DateModel>)LastHourSeries[0].Values).Count - 2).Value; // if (_trend > 0) // ForegroundColor = Brushes.Green; // else if (_trend < 0) // ForegroundColor = Brushes.Red; // else // ForegroundColor = Brushes.Black; // LastLecture = ((ChartValues<DateModel>)LastHourSeries[0].Values).Last().Value; // //SetLecture(); // }); // } //}); Formatter = value => new DateTime((long)(value * TimeSpan.FromMilliseconds(1000).Ticks)).ToString("T"); //Formatter = value => new DateTime((long)value).ToString("T"); DataContext = this; }