void UpdatedRecord(DreamRecord previous, DreamRecord record) { //Console.WriteLine("received updated record"); RemoveRecord(previous); AddNewRecord(record); }
void UpdatedRecord(DreamRecordPage sender, DreamRecord record) { Console.WriteLine("received updated record"); if (record.HasNoTags(_tags)) { _list.Remove(record); } }
void RecordUpdated(DreamRecord previous, DreamRecord record) { RemoveRecord(previous); if (record.DateRecorded.Month == _month.Date.Month) { AddNewRecord(record); } }
public DreamRecord(DreamRecord other) { ID = other.ID; Title = other.Title; Description = other.Description; DateRecorded = other.DateRecorded; Emotion = other.Emotion; Tags = other.Tags; }
public int SaveItem(DreamRecord item) { lock (_locker) { if (item.ID != 0) { _database.Update(item); return(item.ID); } else { return(_database.Insert(item)); } } }
void RemoveRecord(DreamRecord record) { string emotion = record.Emotion.ToString(); ChartDataPoint point = null; for (int index = 0; index < _points.Count; index++) { point = _points[index]; //Console.WriteLine($"{point.XValue} {record.DateRecorded}"); if (point.XValue.Equals(emotion)) { _points.Remove(point); point.YValue--; _points.Add(point); break; } } }
void RecordUpdated(DreamRecord previous, DreamRecord record) { if (record.DateRecorded.Month != previous.DateRecorded.Month) { JournalMonth month = null; for (int index = 0; index < _months.Count; index++) { month = _months[index]; if (month.Date.Month == previous.DateRecorded.Month) { month.Records.Remove(record); month.RecordCount--; } else if (month.Date.Month == record.DateRecorded.Month) { month.Records.Add(record); month.RecordCount++; } } } }
void RemoveRecord(DreamRecord record) { if (_seriesData.ContainsKey(record.Emotion)) { ObservableCollection <ChartDataPoint> list = _seriesData[record.Emotion]; ChartDataPoint point = null; for (int index = 0; index < list.Count; index++) { point = list[index]; //Console.WriteLine($"{point.XValue} {record.DateRecorded}"); if (point.XValue.Equals(record.DateRecorded)) { list.Remove(point); point.YValue--; list.Add(point); break; } } } }
public static void SaveRecord(DreamRecord record) { _database.SaveItem(record); }
void NewRecord(DreamRecordPage sender, DreamRecord record) { //Console.WriteLine("received new record"); AddNewRecord(record); }
public DreamRecordPage(DreamRecord record, bool newRecord) { _previousRecord = new DreamRecord(record); Entry title = new Entry() { Placeholder = "Enter title...", HeightRequest = 50 }; title.BindingContext = record; title.SetBinding(Entry.TextProperty, "Title"); Label descLabel = new Label() { Text = "Description", HorizontalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold, }; Editor description = new Editor() { //HeightRequest = 250, BackgroundColor = Color.Gray, VerticalOptions = LayoutOptions.FillAndExpand }; description.BindingContext = record; description.SetBinding(Editor.TextProperty, "Description"); DatePicker datePicker = new DatePicker() { Format = "D" }; datePicker.BindingContext = record; datePicker.SetBinding(DatePicker.DateProperty, "DateRecorded"); DateTime now = DateTime.Now; if (newRecord) { datePicker.Date = now; } else { datePicker.Date = record.DateRecorded; } datePicker.MinimumDate = datePicker.Date.AddYears(-1); datePicker.MaximumDate = now; Picker picker = new Picker() { Title = "Emotion" }; picker.SelectedIndexChanged += (object sender, EventArgs e) => { if (picker.SelectedIndex != -1) { record.Emotion = (Emotion)picker.SelectedIndex; } }; List <Emotion> emotions = DreamsAPI.GetEmotions(); for (int index = 0; index < emotions.Count; index++) { picker.Items.Add((emotions[index]).ToString()); } picker.SelectedIndex = (int)record.Emotion; Entry tags = new Entry() { Placeholder = "Enter comma separated tags", HeightRequest = 50, }; tags.BindingContext = record; tags.SetBinding(Entry.TextProperty, "Tags"); Button submit = new Button(); if (newRecord) { submit.Text = ADD; } else { submit.Text = UPDATE; } submit.Clicked += async(object sender, EventArgs e) => { if (newRecord) { DreamsAPI.SaveRecord(record); MessagingCenter.Send <DreamRecordPage, DreamRecord>(this, "NewRecord", record); } else { try { DreamsAPI.SaveRecord(record); if ((_previousRecord.DateRecorded != record.DateRecorded || _previousRecord.Emotion != record.Emotion) && recordUpdated != null) { recordUpdated(_previousRecord, record); } } catch (Exception er) { Console.WriteLine(er.Message); } } await Navigation.PopAsync(); }; StackLayout descStack = new StackLayout() { Children = { descLabel, description, }, VerticalOptions = LayoutOptions.FillAndExpand }; StackLayout bottomStack = new StackLayout() { Children = { datePicker, picker, tags, submit }, VerticalOptions = LayoutOptions.End }; StackLayout layout = new StackLayout() { Children = { title, descStack, bottomStack } }; Content = layout; }