Ejemplo n.º 1
0
        public PatronCounter()
        {
            this.InitializeComponent();
            this.Loaded += PatronCounter_Loaded;
            _event       = new BMXEvent();
            _occassion   = new BMXOccasion(_event);

            btn_add.Click += Btn_add_Click;
        }
        public ViewEventPage(List <BMXEvent> events, BMXEvent current_event)
        {
            this.InitializeComponent();

            Events                    = events;
            CurrentEvent              = current_event;
            txt_eventtitle.Text       = CurrentEvent.EventTitle;
            txt_eventdescription.Text = CurrentEvent.Description;
            txt_address.Text          = CurrentEvent.Address;
            control_calendar.Date     = CurrentEvent.StartDateTime;
            slider_duration.Value     = CurrentEvent.Duration.Hours;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter != null)
            {
                CurrentEvent = e.Parameter as BMXEvent;

                //brute force populate fields
                txt_eventtitle.Text       = CurrentEvent.EventTitle;
                txt_eventdescription.Text = CurrentEvent.Description;
                txt_address.Text          = CurrentEvent.Address;
                control_calendar.Date     = CurrentEvent.StartDateTime;
                slider_duration.Value     = CurrentEvent.Duration.Hours;
            }
        }
        async private void SaveEvent(object sender, RoutedEventArgs e)
        {
            var default_position = new BasicGeoposition
            {
                Latitude  = 40.7484,
                Longitude = -73.9857,
            };
            Geopoint point = new Geopoint(default_position);
            var      lat   = default_position.Latitude;
            var      lon   = default_position.Longitude;

            if (CurrentEvent == null)
            {
                CurrentEvent = new BMXEvent
                {
                    EventID       = Guid.NewGuid(),
                    EventTitle    = txt_eventtitle.Text,
                    Description   = txt_eventdescription.Text,
                    Address       = txt_address.Text,
                    Longitude     = lon,
                    Latitude      = lat,
                    CreateDate    = DateTime.Now,
                    Duration      = TimeSpan.FromHours(slider_duration.Value),
                    StartDateTime = control_calendar.Date.Value.Date.Add(control_time.Time),
                };
            }
            else
            {
                CurrentEvent.EventTitle    = txt_eventtitle.Text;
                CurrentEvent.Description   = txt_eventdescription.Text;
                CurrentEvent.Address       = txt_address.Text;
                CurrentEvent.Longitude     = lon;
                CurrentEvent.Latitude      = lat;
                CurrentEvent.CreateDate    = DateTime.Now;
                CurrentEvent.Duration      = TimeSpan.FromHours(slider_duration.Value);
                CurrentEvent.StartDateTime = control_calendar.Date.Value.Date.Add(control_time.Time);
            }

            App.State.Events.Add(CurrentEvent);
            await App.State.SaveAsync();

            Frame.GoBack();
        }