public TripDetailView() { InitializeComponent(); user = (User)PhoneApplicationService.Current.State["user"]; ApplicationBar = new ApplicationBar(); ApplicationBar.Mode = ApplicationBarMode.Default; ApplicationBar.Opacity = 1.0; ApplicationBar.IsVisible = true; ApplicationBar.IsMenuEnabled = true; ApplicationBarIconButton addItem = new ApplicationBarIconButton(); addItem.IconUri = new Uri("/Assets/Images/add.png", UriKind.Relative); addItem.Text = "Add Trip"; ApplicationBar.Buttons.Add(addItem); addItem.Click += new EventHandler(addItem_Click); InputPane.GetForCurrentView().Showing += onKeyboardShowing; InputPane.GetForCurrentView().Hiding += onKeyboardHidding; Tripsss trip = PhoneApplicationService.Current.State["trip"] as Tripsss; Trip = trip; Debug.WriteLine("Trip name:" + Trip.Name); tripName.Text = trip.Name; Debug.WriteLine("main loaded"); update(); }
public TripView(Tripsss trip) { InitializeComponent(); Trip = trip; tripName.Text = trip.Name; //tripDate.Text = trip.Deadline.ToString(); packingProg.Value = 60; }
private void insertItems(Tripsss trip) { if (trip.GetItems() != null) { foreach (Item item in trip.GetItems()) { itemList.Items.Add(new TripListItemView(this, item, Trip, EditedItems)); } } }
public void AddTrip(Tripsss Trip) { List<Tripsss> TripList; if (ConvertFromJson() != null) { TripList = ConvertFromJson(); } else { TripList = new List<Tripsss>(); } TripList.Add(Trip); ConvertToJson(TripList); }
private void SaveTrip(Tripsss trip) { if (IsValidName(trip)) { user.AddTrip(trip); App.MobileService.GetTable<User>().UpdateAsync(user); NavigationService.Navigate(new Uri("/Views/Main.xaml?update=true", UriKind.Relative)); } else { MessageBox.Show("We're sorry, you can't use the same name twice."); } }
private void addTrip_Click(object sender, EventArgs e) { DateTime date = (DateTime) myDate.Value; TextBox dest = destination; Tripsss trip = new Tripsss(); trip.Name = destination.Text; trip.Deadline = date; SaveTrip(trip); }
private Boolean IsValidName(Tripsss trip) { if (user.GetTrips() == null) { // no trips yet, name valid return true; } // Just checks if name of trip == unique Boolean valid = true; foreach (Tripsss tripInList in user.GetTrips()) { if (tripInList.Name.Equals(trip.Name)) { valid = false; } } return valid; }
public void DeleteTrip(Tripsss Trip) { List<Tripsss> TripList; if (ConvertFromJson() != null) { TripList = ConvertFromJson(); } else { TripList = new List<Tripsss>(); } for (int i = 0; i < TripList.Count; i++) { if (TripList[i].Name.Equals(Trip.Name)) { TripList.RemoveAt(i); } } //TripList.Remove(Trip); ConvertToJson(TripList); }
private void DeleteItem(Tripsss trip, Item item) { trip.DeleteItem(item); updateTrip(trip); }
private void EditItem(Tripsss trip, Item oldItem, Item newItem) { Debug.WriteLine(oldItem.Name); trip.DeleteItem(oldItem); trip.AddItem(newItem); updateTrip(trip); }
private void AddItem(Tripsss trip, Item item) { if (IsValidName(trip, item)) { trip.AddItem(item); itemList.Items.Add(new TripListItemView(this, item, Trip, EditedItems)); updateTrip(trip); } else { MessageBox.Show("We're sorry, you can't use the same name twice."); } //updateTrip(trip); ////user.DeleteTrip(Trip); //trip.AddItem(item); //user.AddTrip(trip); //App.MobileService.GetTable<User>().UpdateAsync(user); }
private Boolean IsValidName(Tripsss trip, Item item) { if (trip.GetItems() == null) { return true; } // Just checks if name of item == unique Boolean valid = true; foreach (Item itemInList in trip.GetItems()) { if (itemInList.Name.Equals(item.Name)) { valid = false; } } return valid; }
private void updateTrip(Tripsss trip) { user.DeleteTrip(Trip); //trip.AddItem(item); user.AddTrip(trip); App.MobileService.GetTable<User>().UpdateAsync(user); }