public MainWindow() { InitializeComponent(); this.Closing += new System.ComponentModel.CancelEventHandler(Window_Closing); this.Loaded += Window_Loaded; WindowState = WindowState.Maximized; con = new Controller(); Gvm = new GraphicViewModel(con, ""); Mwvm = new MainWindowViewModel(con); this.DataContext = Gvm; currentSelectedForShares = "open"; currentSelectedForCrypto = "open"; titleOfSeries.AddData(con, FileType.SHARE); nameOfCurrency.AddData(con, FileType.CURRENCY); nameOfCryptoCurrency.AddData(con, FileType.CRYPTO_CURRENCY); System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 1, 0); dispatcherTimer.Start(); }
/// <summary> /// 调整级别 /// </summary> /// <param name="graphic">图对象</param> /// <param name="level">目标级别</param> public void SetLevel(GraphicViewModel graphic, TopicState level) { switch (level) { case TopicState.None: if (_observers.Remove(graphic)) { _subscribers.Remove(graphic); } break; case TopicState.Subscribed: if (!_subscribers.Remove(graphic)) { _observers.Add(graphic); } break; case TopicState.Active: if (_subscribers.Add(graphic)) { _observers.Add(graphic); } break; } }
public async Task <ActionResult> ShowIncome(GraphicViewModel model) { ApplicationDbContext ctx = ApplicationDbContext.Create(); string id = User.Identity.GetUserId(); var locationToShow = new Location(); var locationId = ctx.Database.SqlQuery <String>("select MyLocationId from AspNetUsers where id = '" + id + "'").FirstOrDefault(); Guid idLoc = new Guid(locationId); List <Location> allLocations = new List <Location>(); var projections = ctx.Database.SqlQuery <Projection>("select * from Projections where Location_Id = '" + idLoc + "'").ToList(); allLocations = ctx.Locations.ToList(); foreach (Location loc in allLocations) { if (loc.Id.Equals(locationId)) { locationToShow = loc; } } locationToShow.ProjectionsList = projections; List <Ticket> tickets = new List <Ticket>(); List <Ticket> ticketsToCalculate = new List <Ticket>(); tickets = ctx.Reservations.ToList(); Ticket ticket = new Ticket(); string time = "00:00 PM"; string vreme1 = model.DatumOd + " " + time; DateTime datum1 = DateTime.Parse(vreme1); string vreme2 = model.DatumDo + " " + time; DateTime datum2 = DateTime.Parse(vreme2); foreach (Ticket t in tickets) { ticket = await ctx.Reservations.Include(x => x.Projection).FirstOrDefaultAsync(x => x.Id == t.Id); HallTimeProjection pr = new HallTimeProjection(); pr = await ctx.HallTimeProjection.Include(x => x.Hall).FirstOrDefaultAsync(x => x.Id == ticket.Projection.Id); if (pr.Hall.ParentLocation.Id.Equals(new Guid(locationId)) && DateTime.Compare(pr.Time, datum1) > 0 && DateTime.Compare(pr.Time, datum2) < 0) { ticketsToCalculate.Add(ticket); } } double prihod = 0; foreach (Ticket t in ticketsToCalculate) { prihod += t.Price * t.DiscountMultiplier; } ViewBag.prihod = prihod; return(await ShowStatistics()); }
protected override void OnNavigatedTo(NavigationEventArgs e) { Debug.Assert(GridView.Items != null, "GridView.Items != null"); Debug.Assert(Pivot.Items != null, "Pivot.Items != null"); Memory["默认"] = new GraphicViewModel(); foreach (var(topic, viewModel) in Memory) { var graphic = new GraphicView(viewModel); Pivot.Items.Add(new PivotItem { Header = topic, Content = graphic }); GridView.Items.Insert(GridView.Items.Count - 1, new GridViewItem { Height = 200, Width = 200, Tag = topic, Content = new TextBlock { Text = topic, FontSize = 36 } }); } }
public IActionResult View(Guid apikey, int field, int?take) { var model = new GraphicViewModel(); var values = _context.Entries .Where(x => x.ChannelId == apikey) .OrderByDescending(x => x.Id) .Take(take == null ? 20 : take.Value) .OrderBy(x => x.Id); if (values.Count() > 0) { var xValues = values.Select(x => x.CreatedAt.ToString(System.Globalization.CultureInfo.InvariantCulture)); IEnumerable <string> yValues = values.Select(x => x.Field1.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); switch (field) { case 1: yValues = values.Select(x => x.Field1.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); model.graphName = _context.Channels.First(x => x.Id == apikey).Field1_Name; break; case 2: yValues = values.Select(x => x.Field2.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); model.graphName = _context.Channels.First(x => x.Id == apikey).Field2_Name; break; case 3: yValues = values.Select(x => x.Field3.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); model.graphName = _context.Channels.First(x => x.Id == apikey).Field3_Name; break; case 4: yValues = values.Select(x => x.Field4.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); model.graphName = _context.Channels.First(x => x.Id == apikey).Field4_Name; break; case 5: yValues = values.Select(x => x.Field5.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); model.graphName = _context.Channels.First(x => x.Id == apikey).Field5_Name; break; case 6: yValues = values.Select(x => x.Field6.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); model.graphName = _context.Channels.First(x => x.Id == apikey).Field6_Name; break; case 7: yValues = values.Select(x => x.Field7.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); model.graphName = _context.Channels.First(x => x.Id == apikey).Field7_Name; break; case 8: yValues = values.Select(x => x.Field8.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); model.graphName = _context.Channels.First(x => x.Id == apikey).Field8_Name; break; } model.xValues = $"[\"{String.Join("\", \"", xValues)}\"]"; model.yValues = $"[\"{String.Join("\", \"", yValues)}\"]"; } return(View(model)); }
public DialogForOneGraphic(string title, string currentSelected, string timeSeriesType, string interval, string market, Controller con, MainWindowViewModel mwvm) { InitializeComponent(); this.currentSelected = currentSelected; //selektujOdgovarajuciRadioButton(); if (!market.Equals("")) { if (timeSeriesType.Equals("INTRADAY")) { addRadioButtons(contentsForRadioButtonsIntraday, this.currentSelected); } else { addRadioButtons(contentsForRadioButtonsAnother, this.currentSelected); } } else { addRadioButtons(contentsForRadioButtonsForShares, currentSelected); } Title = title; TimeSeriesTypeComboBox.Text = timeSeriesType; if (!interval.Equals("")) { IntervalComboBox.Visibility = Visibility.Visible; IntervalComboBox.Text = interval; } Mwvm = mwvm; Gvm = new GraphicViewModel(con, Title); this.DataContext = Gvm; Gvm.addSeriesWithOutCheck(currentSelected.ToUpper()); string contentOfTimeSeriesComboBox = TimeSeriesTypeComboBox.Text; string symbol; if (Title.Contains("__")) { string[] tokens = Title.Split(new string[] { "__" }, System.StringSplitOptions.None); symbol = tokens[0]; } else { symbol = Title; } List <DataPoint> dataPoints = Mwvm.getSpecificData(symbol, contentOfTimeSeriesComboBox, currentSelected, interval, market); if (dataPoints != null) { Gvm.addPoints(currentSelected.ToUpper(), dataPoints); } else { MessageBox.Show("Problem with data delivery for " + Title, "Error"); } PlotView.InvalidatePlot(true); // refresh }
public GraphicView(GraphicViewModel model) { InitializeComponent(); _viewModel = model ?? throw new ArgumentNullException(paramName: nameof(model)); _viewModel.SetControl(MainCanvas); }
public async Task <ActionResult> ShowStatistics() { ApplicationDbContext ctx = ApplicationDbContext.Create(); string id = User.Identity.GetUserId(); var locationToShow = new Location(); var locationId = ctx.Database.SqlQuery <String>("select MyLocationId from AspNetUsers where id = '" + id + "'").FirstOrDefault(); Guid idLoc = new Guid(locationId); List <Location> allLocations = new List <Location>(); var projections = ctx.Database.SqlQuery <Projection>("select * from Projections where Location_Id = '" + idLoc + "'").ToList(); allLocations = ctx.Locations.ToList(); foreach (Location loc in allLocations) { if (loc.Id.Equals(locationId)) { locationToShow = loc; } } locationToShow.ProjectionsList = projections; List <Ticket> tickets = new List <Ticket>(); List <Ticket> ticketsToCalculate = new List <Ticket>(); tickets = ctx.Reservations.ToList(); Ticket ticket = new Ticket(); foreach (Ticket t in tickets) { ticket = await ctx.Reservations.Include(x => x.Projection).FirstOrDefaultAsync(x => x.Id == t.Id); HallTimeProjection pr = new HallTimeProjection(); pr = await ctx.HallTimeProjection.Include(x => x.Hall).FirstOrDefaultAsync(x => x.Id == ticket.Projection.Id); if (pr.Hall.ParentLocation.Id.Equals(new Guid(locationId))) { ticketsToCalculate.Add(ticket); } } List <Pair> parovi = new List <Pair>(); foreach (Ticket t in ticketsToCalculate) { Pair par = new Pair(); par.date = t.Projection.Time.ToString(); par.date = par.date.Split(' ')[0]; DateTime dt = DateTime.Now; int trenutnidan = dt.DayOfYear; int trenutnagod = dt.Year; par.numberofday = t.Projection.Time.DayOfYear; par.year = t.Projection.Time.Year; par.number = 0; if (t.Projection.Time.DayOfYear < 105) { int k = 8; } int ima = 1; for (int i = 0; i < parovi.Count; i++) { if (parovi[i].numberofday.Equals(par.numberofday) && parovi[i].year.Equals(par.year) && trenutnidan - par.numberofday < 7 && trenutnagod - par.year == 0) { ima = 0; } } if (ima == 1) { if (trenutnidan - par.numberofday < 7) { parovi.Insert(0, par); } } ima = 1; } foreach (Ticket t in ticketsToCalculate) { for (int i = 0; i < parovi.Count; i++) { if (t.Projection.Time.DayOfYear.Equals(parovi[i].numberofday) && t.Projection.Time.Year.Equals(parovi[i].year)) { parovi[i].number++; break; } } } List <Pair> nedeljno = new List <Pair>(); int b = 0; for (int i = 0; i < 12; i++) { Pair par = new Pair(); int p = b + 2; par.date = b + "-" + p; par.number = 0; DateTime now = DateTime.Now; par.year = now.Year; par.numberofday = now.DayOfYear; nedeljno.Add(par); b += 2; } foreach (Ticket t in ticketsToCalculate) { for (int i = 0; i < nedeljno.Count; i++) { if (t.Projection.Time.DayOfYear.Equals(nedeljno[i].numberofday) && t.Projection.Time.Year.Equals(nedeljno[i].year)) { int donja = 44; int.TryParse(nedeljno[i].date.Split('-')[0], out donja); int gornja = 44; int.TryParse(nedeljno[i].date.Split('-')[1], out gornja); if (t.Projection.Time.Hour >= donja && t.Projection.Time.Hour < gornja) { nedeljno[i].number++; break; } } } } List <Pair2> mesecno = new List <Pair2>(); foreach (Ticket t in ticketsToCalculate) { Pair2 par = new Pair2(); par.date = t.Projection.Time.ToString(); par.date = par.date.Split(' ')[0]; DateTime dt = DateTime.Now; int trenutnidan = dt.DayOfYear; int trenutnagod = dt.Year; par.numberofday = t.Projection.Time.DayOfYear; par.numberofmonth = t.Projection.Time.Month; int trenutnimesec = dt.Month; par.year = t.Projection.Time.Year; par.number = 0; int ima = 1; for (int i = 0; i < mesecno.Count; i++) { if (mesecno[i].numberofday.Equals(par.numberofday) && mesecno[i].year.Equals(par.year) && trenutnimesec - par.numberofmonth == 0 && trenutnagod - par.year == 0) { ima = 0; } } if (ima == 1) { if (trenutnimesec - par.numberofmonth == 0) { mesecno.Insert(0, par); } } ima = 1; } foreach (Ticket t in ticketsToCalculate) { for (int i = 0; i < mesecno.Count; i++) { if (t.Projection.Time.DayOfYear.Equals(mesecno[i].numberofday) && t.Projection.Time.Year.Equals(mesecno[i].year)) { mesecno[i].number++; break; } } } GraphicViewModel graph = new GraphicViewModel { loc = locationToShow, pairs = parovi, nedeljni = nedeljno, mesecni = mesecno }; if (ViewBag.prihod == null) { ViewBag.prihod = 0; } return(View("ShowStatistics", graph)); }