Esempio n. 1
0
 public SettingsViewModel(IRepository commonRepository, IMessanger commonMessanger)
 {
     repository = commonRepository;            
     dateTimePreferences = repository.GetDateTimePreferences();
     messanger = commonMessanger;
     LoadDateTimePreferences();            
     SaveDateTimePreferencesCommand = new RelayCommand(SaveDateTimePreferences);
 }
Esempio n. 2
0
        public DateTimePreferences Load()
        {
            DateTimePreferences preferences = new DateTimePreferences();

            try
            {
                if (File.Exists(CONFIG))
                {
                    log.Debug("Loading DateTimePreferences...");
                    Stream          stream     = File.Open(CONFIG, FileMode.Open);
                    BinaryFormatter bformatter = new BinaryFormatter();
                    preferences = (DateTimePreferences)bformatter.Deserialize(stream);
                    stream.Close();
                    log.Debug("DateTimePreferences were loaded");
                }
            }
            catch (Exception ex)
            {
                log.Error("Failed to load DateTimePreferences:", ex);
            }
            return(preferences);
        }
Esempio n. 3
0
 public void SetDateTimePreferences(DateTimePreferences preferences)
 {
     dateTimePreferences = preferences;
 }
Esempio n. 4
0
        public CalendarEventList FormatEventsDatesStringRepresentation(CalendarEventList allEvents, DateTimePreferences preferences)
        {
            CalendarEventList formatedEvents = new CalendarEventList();

            bool multipleMonths;

            // Find if there are events from different month in the list by comparing years and month data of the first and last event in the list
            if (allEvents.Count > 1)
            {
                multipleMonths = allEvents[0].Start.Year != allEvents[allEvents.Count - 1].Start.Year ? true :
                                 allEvents[0].Start.Month != allEvents[allEvents.Count - 1].Start.Month;
            }
            else
            {
                multipleMonths = false;
            }

            try
            {
                int month = 0;

                foreach (CalendarEvent ev in allEvents)
                {
                    if (preferences.GroupByMonth && multipleMonths && month != ev.Start.Month)
                    {
                        formatedEvents.Add(new CalendarEvent(months[ev.Start.Month]));
                        month = ev.Start.Month;
                    }

                    ev.FormatedStartDate = preferences.StartDateTime(ev);
                    ev.FormatedEndDate   = preferences.EndDateTime(ev);
                    formatedEvents.Add(ev);
                }
                return(formatedEvents);
            }
            catch (Exception ex)
            {
                log.Error("Failed to format events dates", ex);
                return(allEvents);
            }
        }
Esempio n. 5
0
        public CalendarEventList FormatEventsDatesStringRepresentation(CalendarEventList allEvents, DateTimePreferences preferences)
        {
            CalendarEventList formatedEvents = new CalendarEventList();

            bool multipleMonths;

            // Find if there are events from different month in the list by comparing years and month data of the first and last event in the list
            if (allEvents.Count > 1)
            {
                multipleMonths = allEvents[0].Start.Year != allEvents[allEvents.Count - 1].Start.Year ? true :
                                 allEvents[0].Start.Month != allEvents[allEvents.Count - 1].Start.Month;
            }
            else
            {
                multipleMonths = false;
            }
            
            try
            {
                int month = 0;

                foreach (CalendarEvent ev in allEvents)
                {
                    if (preferences.GroupByMonth && multipleMonths && month != ev.Start.Month)
                    {
                        formatedEvents.Add(new CalendarEvent(months[ev.Start.Month]));
                        month = ev.Start.Month;
                    }

                    ev.FormatedStartDate = preferences.StartDateTime(ev);
                    ev.FormatedEndDate = preferences.EndDateTime(ev);
                    formatedEvents.Add(ev);                    
                }
                return formatedEvents;
            }
            catch(Exception ex)
            {
                log.Error("Failed to format events dates", ex);
                return allEvents;
            }
        }
Esempio n. 6
0
        public DateTimePreferences Load()
        {
            DateTimePreferences preferences = new DateTimePreferences();

            try
            {
                if (File.Exists(CONFIG))
                {
                    log.Debug("Loading DateTimePreferences...");
                    Stream stream = File.Open(CONFIG, FileMode.Open);
                    BinaryFormatter bformatter = new BinaryFormatter();
                    preferences = (DateTimePreferences)bformatter.Deserialize(stream);
                    stream.Close();
                    log.Debug("DateTimePreferences were loaded");
                }
            }
            catch (Exception ex)
            {
                log.Error("Failed to load DateTimePreferences:", ex);
            }
            return preferences;
        }