示例#1
0
        public void Remove(TripModel trip)
        {
            obdDb.Trips.DeleteOnSubmit(trip);
            obdDb.SubmitChanges();

            Trips.Remove(trip);
        }
示例#2
0
        private void Reset_Click(object sender, EventArgs e)
        {
            RadInputPrompt.Show(
                    title: "Trip Name",
                    buttons: MessageBoxButtons.OK,
                    checkBoxContent: App.SkyDriveEnabled ? "Export to SkyDrive?" : null,
                    isCheckBoxChecked: App.SkyDriveEnabled ? App.MainViewModel.SettingsViewModel.AutoUpload : false,
                    closedHandler: async (args) =>
                    {
                        if (args.Result == DialogResult.OK)
                        {
                            string tripName = null;
                            string fileName = null;
                            if (string.IsNullOrEmpty(args.Text))
                            {
                                tripName = "unnamed trip";
                                fileName = string.Format("leaflogger-export-{0:yyyyMMdd-HHmmss}.csv", DateTime.Now);
                            }
                            else
                            {
                                tripName = args.Text;
                                fileName = tripName + ".csv";
                            }

                            if (args.IsCheckBoxChecked)
                            {
                                bool exportSuccess = await this.ExportToSkyDrive(fileName);
                                if (!exportSuccess)
                                {
                                    return;
                                }
                            }

                            // before reset i want to store the trip
                            TripModel trip = new TripModel(App.MainViewModel.MapObdUpdates.First(), App.MainViewModel.MapObdUpdates.Last())
                            {
                                Name = tripName,
                                MinimumTemperature1 = App.MainViewModel.MapObdUpdates.Where(x => x.Temperature1.HasValue).Min(x => x.Temperature1),
                                MinimumTemperature2 = App.MainViewModel.MapObdUpdates.Where(x => x.Temperature2.HasValue).Min(x => x.Temperature2),
                                MinimumTemperature3 = App.MainViewModel.MapObdUpdates.Where(x => x.Temperature3.HasValue).Min(x => x.Temperature3),
                                MinimumTemperature4 = App.MainViewModel.MapObdUpdates.Where(x => x.Temperature4.HasValue).Min(x => x.Temperature4),
                                MaximumTemperature1 = App.MainViewModel.MapObdUpdates.Max(x => x.Temperature1),
                                MaximumTemperature2 = App.MainViewModel.MapObdUpdates.Max(x => x.Temperature2),
                                MaximumTemperature3 = App.MainViewModel.MapObdUpdates.Max(x => x.Temperature3),
                                MaximumTemperature4 = App.MainViewModel.MapObdUpdates.Max(x => x.Temperature4),
                                AverageTemperature1 = App.MainViewModel.MapObdUpdates.Where(x => x.Temperature1.HasValue).Average(x => x.Temperature1),
                                AverageTemperature2 = App.MainViewModel.MapObdUpdates.Where(x => x.Temperature2.HasValue).Average(x => x.Temperature2),
                                AverageTemperature3 = App.MainViewModel.MapObdUpdates.Where(x => x.Temperature3.HasValue).Average(x => x.Temperature3),
                                AverageTemperature4 = App.MainViewModel.MapObdUpdates.Where(x => x.Temperature4.HasValue).Average(x => x.Temperature4)
                            };

                            App.MainViewModel.Add(trip);

                            // clear all the database entries
                            App.MainViewModel.Clear();

                            // reset the cached values
                            App.MainViewModel.MapObdUpdates.Clear();
                            App.MainViewModel.MapPath.Clear();

                            // reset the route
                            this.map.MapElements.Remove(this.route);
                            this.map.MapElements.Add(this.route);

                            this.lastGeoCoordinate = null;
                            this.track.DataContext = null;

                            Grid.SetRowSpan(this.map, 3);

                            ShellTile shellTile = ShellTile.ActiveTiles.FirstOrDefault();
                            if (shellTile != null)
                            {
                                shellTile.Update(
                                    new FlipTileData()
                                    {
                                        BackContent = string.Empty,
                                        BackBackgroundImage = new Uri(string.Empty, UriKind.Relative),
                                        WideBackContent = string.Empty,
                                        WideBackBackgroundImage = new Uri(string.Empty, UriKind.Relative),
                                        Count = 0
                                    });
                            }

                            this.PopulateTrackingAppButtons();
                        }
                    });
        }
示例#3
0
        public void Add(TripModel newTrip)
        {
            obdDb.Trips.InsertOnSubmit(newTrip);

            obdDb.SubmitChanges();

            Trips.Insert(0, newTrip);
        }