private void mainWindow_Loaded(object sender, RoutedEventArgs e) { try { this.Left = Properties.Settings.Default.LocationX; this.Top = Properties.Settings.Default.LocationY; this.Width = Properties.Settings.Default.Width; this.Height = Properties.Settings.Default.Height; using (var client = new LunchTimeService.LunchTimeClient()) { var restaurants = client.GetRestaurants().Select(r => r.Name); this.restaurantsComboBox.ItemsSource = restaurants; var statistics = client.GetStatistics(); this.detailsGrid.ItemsSource = statistics.Select(s => new Statistic(s)); } this.restaurantsComboBox.SelectedIndex = Properties.Settings.Default.SelectedIndex; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnSubmit_Click(object sender, EventArgs e) { try { using (var service = new LunchTimeService.LunchTimeClient()) { if (this.ArrivalTimes != null) service.InsertArrivalTimes(this.ArrivalTimes.Select(at => at.ConvertToDto()).ToArray()); } this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void restaurantsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { using (var client = new LunchTimeService.LunchTimeClient()) { string restaurant = this.restaurantsComboBox.SelectedValue as string; Statistic statistic = new Statistic(client.GetStatistic(restaurant)); if (statistic == null) return; this.summaryGrid.ItemsSource = (new List<Statistic> { statistic }); var arrivalTimes = client.GetArrivalTimes(restaurant); if (arrivalTimes.Count() > 4) { var histogram = new HistogramGenerator(arrivalTimes); this.dataSeries.ItemsSource = arrivalTimes.GroupBy(at => histogram.GetHistogramBucket(at)) .OrderBy(group => group.Key) .Select(group => new { Index = Statistic.FormatTimeSpan(group.Key, false), Value = group.Count() }); } else { this.dataSeries.ItemsSource = null; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void SetUpGrid(IEnumerable<ArrivalTime> arrivalTimes) { try { using (var service = new LunchTimeService.LunchTimeClient()) { this.Restaurants = service.GetRestaurants().Select(r => r.Name).ToList(); } var cellStyle = new DataGridViewCellStyle(); cellStyle.Format = "MM/dd/yyyy HH:mm:ss"; this.colTime.DefaultCellStyle = cellStyle; this.gvData.AutoGenerateColumns = false; this.SetDataSources(arrivalTimes); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }