Example #1
0
        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);
            }
        }
Example #2
0
        private string[] GetFileNames(List<AlbumUserControl> albumsets)
        {
            string[] fileNames;
            List<string> files = new List<string>();
            if(albumsets.Equals(familyAlbumSets))
            {
                fileNames = Directory.GetFiles(@"familyAlbumSets");
                foreach(string s in fileNames)
                {
                    files.Add(System.IO.Path.GetFileNameWithoutExtension(s));
                }
            }

            else if(albumsets.Equals(travelAlbumSets))
            {
                fileNames = Directory.GetFiles(@"travelAlbumSets");
                foreach (string s in fileNames)
                {
                    files.Add(System.IO.Path.GetFileNameWithoutExtension(s));
                }
            }

            else if(albumsets.Equals(sceneAlbumSets))
            {
                fileNames = Directory.GetFiles(@"sceneAlbumSets");
                foreach (string s in fileNames)
                {
                    files.Add(System.IO.Path.GetFileNameWithoutExtension(s));
                }
            }

            else if(albumsets.Equals(campusAlbumSets))
            {
                fileNames = Directory.GetFiles(@"campusAlbumSets");
                foreach (string s in fileNames)
                {
                    files.Add(System.IO.Path.GetFileNameWithoutExtension(s));
                }
            }

            else if(albumsets.Equals(personalAlbumSets))
            {
                fileNames = Directory.GetFiles(@"personalAlbumSets");
                foreach (string s in fileNames)
                {
                    files.Add(System.IO.Path.GetFileNameWithoutExtension(s));
                }
            }
            return files.ToArray();
        }