private ObservableCollection<MainHubViewModel> InitializeHubs(Presentation presentList, List<News> newsList, List<Event> eventList, List<Project> projectList) { DateToStringConverter dateToStringConverter = new DateToStringConverter(); MainHubViewModel tempHub = new MainHubViewModel(); ObservableCollection<MainHubViewModel> tempHubs = new ObservableCollection<MainHubViewModel>(); #region Presentation formater tempHub.ID = tempHub.Count; tempHub.HubName = _res.GetString("Presentation"); tempHub.NbItemsVisibility = Visibility.Collapsed; tempHub.Add(new MainItemViewModel() { BigPhoto = presentList.BigPictureURI, IsDescription = true, DescriptionVisibility = Visibility.Visible, OtherVisibility = Visibility.Collapsed, ImageOnlyVisibility = Visibility.Collapsed, Description = presentList.Description, Photo1 = presentList.PicturesURI[0], Photo2 = presentList.PicturesURI[1], Photo3 = presentList.PicturesURI[2] }); for (int i = 3; i < presentList.PicturesURI.Count; i++) { tempHub.Add(new MainItemViewModel() { Photo = presentList.PicturesURI[i], IsDescription = true, DescriptionVisibility = Visibility.Collapsed, OtherVisibility = Visibility.Collapsed, ImageOnlyVisibility = Visibility.Visible }); } tempHubs.Add(tempHub); #endregion #region News formater tempHub = new MainHubViewModel(); tempHub.ID = tempHubs.Count; tempHub.HubName = _res.GetString("NewsPageTitleMain"); tempHub.NbItems = newsList.Count; tempHub.NbItemsVisibility = Visibility.Visible; int cpt = 0; foreach (News news in newsList) { string img; if (news.ImageURL == "") img = "/Content/Images/News/default.png"; else img = news.ImageURL; tempHub.Add(new MainItemViewModel() { ID = news.ID, Photo = img, Title = news.Title, Subtitle = dateToStringConverter.ConvertDateToString(news.PubDate, news.Schedule, false), IsDescription = false, LabelImage = "/Content/Images/News/label.png", DescriptionVisibility = Visibility.Collapsed, OtherVisibility = Visibility.Visible, ImageOnlyVisibility = Visibility.Collapsed, IsEvent = false, IsNews = true, IsProject = false }); } tempHubs.Add(tempHub); #endregion #region Events formater tempHub = new MainHubViewModel(); tempHub.ID = tempHubs.Count; tempHub.HubName = _res.GetString("EventsPageTitleMain"); tempHub.NbItems = eventList.Count; tempHub.NbItemsVisibility = Visibility.Visible; cpt = 0; foreach (Event events in eventList) { string img; if (events.PictureURI == "") img = "/Content/Images/Events/default.png"; else img = events.PictureURI; tempHub.Add(new MainItemViewModel() { ID = events.ID, Photo = img, Title = events.Title, Subtitle = dateToStringConverter.ConvertDateToString(events.Date, events.Schedule, false), LabelImage = "/Content/Images/Events/label.png", IsDescription = false, DescriptionVisibility = Visibility.Collapsed, ImageOnlyVisibility = Visibility.Collapsed, OtherVisibility = Visibility.Visible, IsEvent = true, IsNews = false, IsProject = false }); cpt++; } tempHubs.Add(tempHub); #endregion #region Projects formater tempHub = new MainHubViewModel(); tempHub.ID = tempHubs.Count; tempHub.HubName = _res.GetString("ProjectsPageTitleMain"); tempHub.NbItems = projectList.Count; tempHub.NbItemsVisibility = Visibility.Visible; foreach (Project project in projectList) { string img; if (project.PictureURI == "") img = "/Content/Images/Projects/default.png"; else img = project.PictureURI; tempHub.Add(new MainItemViewModel() { ID = project.ID, Photo = img, Title = project.Title, Subtitle = project.SubTitle, LabelImage = "/Content/Images/Projects/label.png", IsDescription = false, DescriptionVisibility = Visibility.Collapsed, OtherVisibility = Visibility.Visible, ImageOnlyVisibility = Visibility.Collapsed, IsEvent = false, IsNews = false, IsProject = true }); } tempHubs.Add(tempHub); #endregion return tempHubs; }
public void LoadHubsFromOnlineData() { Presentation presentList = new Presentation(); List<News> newsList = new List<News>(); List<Event> eventList = new List<Event>(); List<Project> projectList = new List<Project>(); List<Member> memberList = new List<Member>(); List<OfficeMember> officeMembersList = new List<OfficeMember>(); presentList = ProcessData.GetPresentation(); newsList = ProcessData.GetNews(); eventList = ProcessData.GetEvents(); projectList = ProcessData.GetProjects(); memberList = ProcessData.GetMembers(); officeMembersList = ProcessData.GetOfficeMembers(); NbMembers = _res.GetString("MembersMainPage") + " (" + (memberList.Count + officeMembersList.Count) + ")"; this.Hubs = this.InitializeHubsFromOnlineData(presentList, newsList, eventList, projectList); this.IsDataLoaded = true; }
/// <summary> /// Get Presentation from XML Document /// </summary> /// <param name="path"></param> /// <returns></returns> public static Presentation GetPresentation() { if (AllPresentation == null) { try { AllPresentation = new Presentation(); XDocument doc = XDocument.Load(CurrentSettings.PresentationSourceURI); AllPresentation.BigPictureURI = doc.Root.Element("bigPictureURI").Value; AllPresentation.Description = doc.Root.Element("description").Value; foreach (var elem in doc.Root.Element("images").Descendants("image")) { AllPresentation.PicturesURI.Add(elem.Value); } return AllPresentation; } catch (Exception e) { Debug.WriteLine("Error in GetPresentation [MonAssoce.DataLayer.ProcessData]\n"); Debug.WriteLine(e.Message); } } return AllPresentation; }
public async Task LoadHubs() { await ProcessData.LoadSettings(); if (!ProcessData.CurrentSettings.PresentationSourceURI.Equals("Presentation")) { Presentation presentList = new Presentation(); List<News> newsList = new List<News>(); List<Event> eventList = new List<Event>(); List<Project> projectList = new List<Project>(); List<Member> memberList = new List<Member>(); List<OfficeMember> officeMembersList = new List<OfficeMember>(); presentList = ProcessData.GetPresentation(); newsList = ProcessData.GetNews(); eventList = ProcessData.GetEvents(); projectList = ProcessData.GetProjects(); memberList = ProcessData.GetMembers(); officeMembersList = ProcessData.GetOfficeMembers(); NbMembers = _res.GetString("MembersMainPage") + " (" + (memberList.Count + officeMembersList.Count) + ")"; this.Hubs = this.InitializeHubs(presentList, newsList, eventList, projectList); this.IsDataLoaded = true; } }
public static void Reset() { CurrentSettings = null; AllPresentation = null; AllNews = null; AllEvents = null; UpcomingEvents = null; AllMembers = null; AllProjects = null; AllOfficeMembers = null; }