예제 #1
0
파일: DailyEntry.cs 프로젝트: Blisse/21Days
        public DailyEntry Clone()
        {
            var dailyEntry = new DailyEntry()
            {
                ActOfKindnessEntry   = String.Copy(this.ActOfKindnessEntry ?? String.Empty),
                EntryDateTimeKey     = this.EntryDateTimeKey,
                ExerciseEntry        = String.Copy(this.ExerciseEntry ?? String.Empty),
                GratitudeEntriesList = new ObservableCollection <GratitudeEntry>(this.GratitudeEntriesList ?? new Collection <GratitudeEntry>()),
                JournalEntry         = String.Copy(this.JournalEntry ?? String.Empty),
                LastEditedDate       = this.LastEditedDate,
                MeditationEntry      = String.Copy(this.MeditationEntry ?? String.Empty)
            };

            dailyEntry.GratitudeEntriesList = new ObservableCollection <GratitudeEntry>();
            if (this.GratitudeEntriesList != null)
            {
                foreach (var gratitudeEntry in this.GratitudeEntriesList)
                {
                    dailyEntry.GratitudeEntriesList.Add(new GratitudeEntry()
                    {
                        Description = String.Copy(gratitudeEntry.Description ?? String.Empty)
                    });
                }
            }
            return(dailyEntry);
        }
예제 #2
0
        public Boolean AddToDatesList(DateTime enterDateTime)
        {
            IsLoading = true;
            Dictionary = DataManager.Instance.GetDailyEntriesData();

            if (Dictionary.ContainsKey(enterDateTime))
            {
                if (AddAlreadyAddedDate != null)
                {
                    AddAlreadyAddedDate(this, enterDateTime);
                }

                IsLoading = false;
                return false;
            }

            var dailyEntry = new DailyEntry(enterDateTime);
            Dictionary.Add(enterDateTime, dailyEntry);
            UpdateDatesList(Dictionary);

            if (!DataManager.Instance.SaveDailyEntriesData(Dictionary))
            {
                if (ErrorOccurred != null)
                {
                    ErrorOccurred(this, null);
                }

                IsLoading = false;
                return false;
            }

            IsLoading = false;
            return true;
        }
예제 #3
0
파일: DailyEntry.cs 프로젝트: Blisse/21Days
 public DailyEntry Clone()
 {
     var dailyEntry = new DailyEntry()
     {
         ActOfKindnessEntry = String.Copy(this.ActOfKindnessEntry ?? String.Empty),
         EntryDateTimeKey = this.EntryDateTimeKey,
         ExerciseEntry = String.Copy(this.ExerciseEntry ?? String.Empty),
         GratitudeEntriesList = new ObservableCollection<GratitudeEntry>(this.GratitudeEntriesList ?? new Collection<GratitudeEntry>()),
         JournalEntry = String.Copy(this.JournalEntry ?? String.Empty),
         LastEditedDate = this.LastEditedDate,
         MeditationEntry = String.Copy(this.MeditationEntry ?? String.Empty)
     };
     dailyEntry.GratitudeEntriesList = new ObservableCollection<GratitudeEntry>();
     if (this.GratitudeEntriesList != null)
     {
         foreach (var gratitudeEntry in this.GratitudeEntriesList)
         {
             dailyEntry.GratitudeEntriesList.Add(new GratitudeEntry()
             {
                 Description = String.Copy(gratitudeEntry.Description ?? String.Empty)
             });
         }
     }
     return dailyEntry;
 }
예제 #4
0
        private void EntryUpdated(object sender, DailyEntry entry)
        {
            Dispatcher.BeginInvoke(() =>
            {
                if (entry != null)
                {
                    EntryDateTimeKeyTextBlock.Foreground =
                        BooleanToEntryHeaderColorConverter.Convert(entry.IsCompleted);
                }

                foreach (PivotItem pivotItem in EntryPagePivot.Items)
                {
                    var header = pivotItem.Header as TextBlock;
                    var index = EntryPagePivot.Items.IndexOf(pivotItem);
                    if (header != null)
                    {
                        SetInactiveEntryPivotItemHeaderColour(header);
                        if (pivotItem == EntryPagePivot.SelectedItem)
                        {
                            SetActiveEntryPivotItemHeaderColour(header, index);
                        }
                    }
                }
            });
        }