private void AddAlbumSets(List<AlbumUserControl> albumSets,WrapPanel wrapPanel) { //Getting fileNames in the directory which storage the paths of pictures string[] fileNames = GetFileNames(albumSets); //There is no files in the directory if(fileNames.Count()==0) { return; } //Creating AlbumSet foreach(string s in fileNames) { AlbumUserControl albumSet = CreateAlbumSet(wrapPanel, s); #region if (albumSets.Equals(familyAlbumSets)) { albumSet.BelongsTo = "familyAlbumSets"; } else if (albumSets.Equals(travelAlbumSets)) { albumSet.BelongsTo = "travelAlbumSets"; } else if (albumSets.Equals(sceneAlbumSets)) { albumSet.BelongsTo = "sceneAlbumSets"; } else if (albumSets.Equals(campusAlbumSets)) { albumSet.BelongsTo = "campusAlbumSets"; } else if (albumSets.Equals(personalAlbumSets)) { albumSet.BelongsTo = "personalAlbumSets"; } ReadPicturePaths(albumSet); #endregion AlbumSet aSet = new AlbumSet(); aSet.ImagePath = albumSet.PicturePathList[0]; aSet.AlbumSetName = albumSet.Name; //Creating a new AlbumSet, //for the purpose to add the first picture as the AlbumSet's background AlbumUserControl userControl = new AlbumUserControl(); userControl.Name = aSet.AlbumSetName; userControl.Content = aSet; userControl.ContentTemplate = (DataTemplate)FindResource("AlbumSetDataTemplate"); userControl.IsSelected = true; userControl.PicturePathList = albumSet.PicturePathList; userControl.BelongsTo = albumSet.BelongsTo; userControl.MouseDown += albumUserControl_MouseDown; userControl.MouseDoubleClick += albumUserControl_MouseDoubleClick; albumSet = userControl;//Referencing to the new AlbumSet List<Image> pictureList=new List<Image>(); foreach(string ss in albumSet.PicturePathList) { Image i=new Image(); i.Source=new BitmapImage(new Uri(ss,UriKind.Absolute)); i.Stretch = Stretch.UniformToFill; pictureList.Add(i); } albumSet.PictureList = pictureList; albumSets.Add(albumSet); UpdateAlbumSets(albumSets, wrapPanel); } }
private void ShowPictures(AlbumUserControl userControl) { pictureViewer.pictureWrapPanel.Children.Clear(); WrapPanel wp = pictureViewer.pictureWrapPanel; foreach(Image i in userControl.PictureList) { Picture p = new Picture(i); wp.Children.Add(p); } }
private void ResetUnselectedState(List<AlbumUserControl> albumSets, AlbumUserControl uc) { foreach(AlbumUserControl asuc in albumSets) { if(asuc.Name!=uc.Name) { asuc.IsSelected = false; } } }
private AlbumUserControl ReferenceNewAlbumSet(AlbumUserControl albumSet,string[] fileNames) { AlbumSet aSet = new AlbumSet(); aSet.ImagePath = fileNames[0];//Image path has been set to AlbumSet aSet.AlbumSetName = albumSet.Name; //Creating a new AlbumSet, //for the purpose to add the first picture as the AlbumSet's background AlbumUserControl userControl = new AlbumUserControl(); userControl.Name = aSet.AlbumSetName; userControl.Content = aSet; userControl.ContentTemplate = (DataTemplate)FindResource("AlbumSetDataTemplate"); userControl.IsSelected = true; userControl.PicturePathList = albumSet.PicturePathList; userControl.BelongsTo = albumSet.BelongsTo; userControl.MouseDown += albumUserControl_MouseDown; userControl.MouseDoubleClick += albumUserControl_MouseDoubleClick; albumSet = userControl;//Referencing to the new AlbumSet return albumSet; }
private void ReadPicturePaths(AlbumUserControl albumSet) { using(StreamReader reader=new StreamReader(albumSet.BelongsTo+@"\"+albumSet.Name+".txt",Encoding.Default)) { string line; while((line=reader.ReadLine())!=null) { albumSet.PicturePathList.Add(line); } } }
private AlbumUserControl CreateAlbumSet(WrapPanel wrapPanel,string name) { //Adding AlbumSet to panel AlbumSet albumSet = new AlbumSet(); albumSet.AlbumSetName = name; //Having not getting and dealing with the message //albumSet.CreateTime=; AlbumUserControl albumUserControl = new AlbumUserControl(); albumUserControl.Name = albumSet.AlbumSetName; albumUserControl.Content = albumSet; albumUserControl.ContentTemplate = (DataTemplate)FindResource("AlbumSetDataTemplate"); switch (GetSelectedTabItem()) { case "familyTabItem": albumUserControl.BelongsTo = "familyAlbumSets"; break; case "travelTabItem": albumUserControl.BelongsTo = "travelAlbumSets"; break; case "sceneTabItem": albumUserControl.BelongsTo = "sceneAlbumSets"; break; case "campusTabItem": albumUserControl.BelongsTo = "campusAlbumSets"; break; case "personalTabItem": albumUserControl.BelongsTo = "personalAlbumSets"; break; } //AlbumSet's event handlers albumUserControl.MouseDown += albumUserControl_MouseDown; albumUserControl.MouseDoubleClick += albumUserControl_MouseDoubleClick; return albumUserControl; }