示例#1
0
        /// <summary>
        /// Callback for when the Add Feed button is clicked.
        /// </summary>
        /// <param name="sender">Object that triggered the event.</param>
        /// <param name="e">Arguments for the click event.</param>
        private async void AddFeedButton_Clicked(object sender,
                                                 EventArgs e)
        {
            // Check if the maximum number of entries for the day is
            // already reached
            if (this.entries.Count >= MAX_ENTRIES_PER_DAY)
            {
                ToastController.ShortToast("Cannot add any more records for the day!");
                return;
            }

            // Create a new record book entry and insert it into the
            // database to obtain a unique Id
            FeedRecordEntry entry = new FeedRecordEntry()
            {
                HorseId = HorseManager.GetInstance().ActiveHorse.Id,
                Date    = date
            };
            await AppDatabase.GetInstance().Save <FeedRecordEntry>(entry);

            // Add a new record view to the stack
            this.entries.Add(entry);
            FeedRecordView view = new FeedRecordView(entry);

            this.FeedRecordStack.Children.Add(view);
        }
示例#2
0
        /// <summary>
        /// Method for when the page appears.
        /// </summary>
        protected override async void OnAppearing()
        {
            // Set the horse/date display at the page bottom
            this.SelectedDateLabel.Text =
                RecordBookTabbedPage.SelectedDate.ToString("MMM. dd, yyyy");
            this.SelectedHorseLabel.Text =
                HorseManager.GetInstance().ActiveHorse.Name;

            // Get all of the records for the page
            this.entries.Clear();
            this.entries = await RecordBookEntry.GetInRange
                           <FeedRecordEntry>(HorseManager.GetInstance().ActiveHorse.Id,
                                             this.date,
                                             this.date.AddDays(1));

            // Clear all of the contents from the activity record stack
            this.FeedRecordStack.Children.Clear();

            // Render all of the entries on the screen
            foreach (FeedRecordEntry entry in this.entries)
            {
                // Add a new record frame for each activity
                Device.BeginInvokeOnMainThread(() => {
                    FeedRecordView view = new FeedRecordView(entry);
                    this.FeedRecordStack.Children.Add(view);
                });
            }
        }