コード例 #1
0
ファイル: SettingsViewModel.cs プロジェクト: Aishaj/AGC.v3
 public SettingsViewModel(IRepository commonRepository, IMessanger commonMessanger)
 {
     repository = commonRepository;            
     dateTimePreferences = repository.GetDateTimePreferences();
     messanger = commonMessanger;
     LoadDateTimePreferences();            
     SaveDateTimePreferencesCommand = new RelayCommand(SaveDateTimePreferences);
 }
コード例 #2
0
ファイル: DateTimePreferences.cs プロジェクト: niab/AGC
        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);
        }
コード例 #3
0
ファイル: Repository.cs プロジェクト: Aishaj/AGC.v3
 public void SetDateTimePreferences(DateTimePreferences preferences)
 {
     dateTimePreferences = preferences;
 }
コード例 #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);
            }
        }
コード例 #5
0
ファイル: CalendarEventService.cs プロジェクト: Aishaj/AGC.v3
        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;
            }
        }
コード例 #6
0
ファイル: DateTimePreferences.cs プロジェクト: Aishaj/AGC.v3
        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;
        }