Exemple #1
0
 public MyPictures()
 {
     InitializeComponent();
     move = 0;
     maxValX = 0;
     maxValY = 0;
     this.TopLevel = true;
     trackBar.Maximum = 255;
     trackBar.Minimum = 40;
     oldList = new ListView();
     currentAlbum = new Album();
     currentAlbum.pict_tab.ImageSize = new Size(40, 40);
     currentAlbum.pict_tab.ColorDepth = ColorDepth.Depth32Bit;
     // Initialize Albums stored on computer
     try
     {
         this.load_Albums();
         this.checkForDefaultAlbum();
         this.miniatureView.CheckBoxes = true;
         // Display grid lines.
         this.miniatureView.GridLines = true;
         this.newFolder = new AddFolder();
     }
     catch (Exception e){ Console.WriteLine(e); }
 }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            NextAlbum = new Album();

            NextAlbum.tags.Clear();
            NextAlbum.tags.AddRange(this.richTextBox1.Lines);

            NextAlbum.name = this.title.Text;

            NextAlbum.place = this.place.Text;

            NextAlbum.fname = "./Albums/" + NextAlbum.name + ".xml";

            IsReal = true;
        }
Exemple #3
0
        public void addFolder_button1_Click(object sender, EventArgs e)
        {
            // MessageBox.Show("IN IT BITCH !!!");
            // C'est crade... CA PIQUE LES TETONS :OOOOO !
            // M'enfin...
            if (this.newFolder.title != null)
            {

                Album ttt = new Album();

                ttt.name = this.newFolder.title.Text;
                ttt.place = this.newFolder.place.Text;
                ttt.tags.AddRange(this.newFolder.richTextBox1.Lines);

                // setting up saving path...
                ttt.setAlbumsFname();

                addFolderToList(ttt);

                this.newFolder.Close();
            }
        }
Exemple #4
0
        private void load_Albums()
        {
            IEnumerable<String> paths = Album.EnumerateFiles(".\\Albums\\");
            this.album_list = new List<Album>();

            this.list_folders.BeginUpdate();

            foreach (String e in paths)
            {
                Album test = Album.Deserializer(e);
                this.album_list.Add(test);
                if (test.name != "default")
                {
                    TreeNode t = new TreeNode(test.name);
                    t.Name = test.name;
                    this.list_folders.Nodes.Add(t);
                }
                else
                    this.defaultAlbum = test;
            }
            this.list_folders.EndUpdate();
        }
Exemple #5
0
        private void list_folders_Click(object sender, TreeViewEventArgs e)
        {
            try
            {
                // on récupère de quel album il s'agit
                // On charge les images dans l'album
               currentAlbum = loadImageToAlbum(this.list_folders.SelectedNode.Name);

                //on met a jour les tags
               foreach (string tag in currentAlbum.tags)
                   list_tags.Items.Add(tag);

               updateInformation(getAllDataAlbum());
                // et on actualise la list view...
                updateListView(currentAlbum);
            }
            catch (Exception a) { MessageBox.Show(a.ToString()); }
        }
Exemple #6
0
        private void list_folders_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                // on récupère de quel album il s'agit
                // On charge les images dans l'album
                currentAlbum = loadImageToAlbum(this.list_folders.SelectedNode.Name);

                // et on actualise la list view...
                updateListView(currentAlbum);

            }
            catch (Exception a) { MessageBox.Show(a.ToString()); }
        }
Exemple #7
0
        private void deletePicture()
        {
            Album z = new Album();
            bool pict_deletion = false;
            Picture temp = new Picture();
            ListViewItem tmp = new ListViewItem();

            // On regarde de quelle image il s'agit et de quel album !
            foreach (Album u in this.album_list)
            {
                if (u.name == this.currentAlbum.name && u.name != "default")
                {
                    foreach (Picture i in u.content)
                    {
                        foreach (ListViewItem a in this.miniatureView.SelectedItems)
                        {
                            if (a.Text == i.name || a.Text == i.fname)
                            {
                                temp = i;
                                tmp = a;
                                pict_deletion = true;
                                break;
                            }
                        }
                        if (pict_deletion)
                        {
                            // this.miniatureView.BeginUpdate();
                            // this.miniatureView.Items.Remove(tmp);
                            // this.miniatureView.EndUpdate();
                            break;
                        }
                    }

                    if (pict_deletion)
                    {
                        u.content.Remove(temp);
                        break;
                    }
                    z = u;
                }
            }

            foreach (Album a in this.album_list)
                if (a.name == "default")
                {
                    foreach (Picture b in a.content)
                    {
                        if (b.name == temp.name || b.fname == temp.fname)
                        { temp = b; break; }
                    }
                    a.content.Remove(temp);
                    break;
                }

            updateListView(z);
        }
Exemple #8
0
        private void deleteAlbum(Album z)
        {
            // on supprime toute les photos de l'album en question...
            foreach (Picture i in z.content)
            {
                deletePicturefromDefaultAlbum(i); // On supprime de l'album defaut...
            }

            z.content.Clear();

            // OnActivated updateListView la listview
            this.updateListView(z);
        }
Exemple #9
0
        private void updateListView(Album z)
        {
            if (z != null)
            {
                ImageList imageList1 = new ImageList();
                imageList1.ImageSize = new Size(40, 40);
                imageList1.ColorDepth = ColorDepth.Depth32Bit;

                miniatureView.CheckBoxes = false;
                this.miniatureView.BeginUpdate();
                this.miniatureView.Items.Clear();

                addPictureToImageList(imageList1,z);

                miniatureView.LargeImageList = imageList1;

                foreach (Picture o in z.content)
                {
                    miniatureView.Items.Add(new ListViewItem(o.name, findLastIndexOfListView() + 1));
                }

                this.miniatureView.EndUpdate();

                updateInformation(getAllDataAlbum());
            }

            else
                throw new Exception("Warning : Failed assignation with Albums !");
        }
Exemple #10
0
        private void button_removePicture_Click(object sender, EventArgs e)
        {
            Album u = new Album();
            // Here we remove all the picture of the album...
            foreach (Album i in this.album_list)
            {
                if (i.name == this.list_folders.SelectedNode.Name && i.name != "default")
                {
                    u = i;
                    break;
                }
            }

            this.deleteAlbum(u);
            this.updateListView(u);
        }
Exemple #11
0
        private void button_addPicture_Click(object sender, EventArgs e)
        {
            bool t = false;
            // Here we Wanna Add a Picture by HAND !
            // Yes WARRIOR SAMA !!!!!!!
            // First we set the Destination album !!!
            if (this.list_folders.SelectedNode == null)
            {
                this.currentAlbum.name = "default";

                foreach (Album uu in this.album_list)
                    if (uu.name.Contains("default") || uu.name.Contains("Default"))
                    {
                        t = true;
                        break;
                    }
                if (!t)
                {
                    Album u = new Album();
                    u.name = "default";
                    this.addFolderToList(u);
                }

            }
            else
                this.currentAlbum.name = this.list_folders.SelectedNode.Name;

            this.newPicture = new AddPicture();
            this.newPicture.addToAlbum.Click += addPictureToSelectedAlbum;

            foreach (Album y in this.album_list)
                this.newPicture.listBox1.Text += y.name;

            this.newPicture.Show();
        }
Exemple #12
0
 //ajout tag a l'album
 private bool addTag(Album ab, string addtag)
 {
     foreach (string tag in list_tags.Items)
      {
          if (ab != null && ab.tags.Contains(tag) == false)
          {
              ab.tags.Add(addtag);
              return true;
          }
      }
      return false;
 }
Exemple #13
0
        private void addPictureToSelectedAlbum(object sender, EventArgs e)
        {
            // We do know that if we arrive here it is because... The file is already validated !
            Album u = new Album();
            Album z = new Album();
            Picture n = new Picture();
            bool ret = false;
            if (newPicture.tttt  != null)
            {
                n = this.newPicture.tttt;
                n.fname = newPicture.tttt.fname;
                n.name = newPicture.tttt.name = n.fname;

                // MessageBox.Show("New Picture Added \r\n " + n.fname + "\r\n" + n.name);

                foreach (Album y in this.album_list)
                {
                    if (y.name == "default") { z = y; ret = true; break; }
                    if (y.name == this.currentAlbum.name)
                    {
                        ret = true;
                        u = y;
                        break;
                    }
                }

                if (ret)
                { u.content.Add(n); z.content.Add(n); }

                this.newPicture.Close();

                // refresh ListView...
                updateListView(u);
            }
        }
Exemple #14
0
 private void addPictureToImageList(ImageList u, Album z)
 {
     foreach (Picture i in z.content)
     {
         u.Images.Add(Image.FromFile( i.fname));
     }
 }
Exemple #15
0
 private void addFolderToList(Album toto)
 {
     this.list_folders.BeginUpdate();
     this.album_list.Add(toto);
     TreeNode ttttt = new TreeNode(toto.name);
     ttttt.Name = toto.name;
     this.list_folders.Nodes.Add(ttttt);
     this.list_folders.EndUpdate();
 }
Exemple #16
0
 private bool removeTag(Album ab, string removetag)
 {
     foreach (string tag in list_tags.Items)
      {
          if (ab != null && ab.tags.Contains(tag) == true)
          {
              ab.tags.Remove(removetag);
              return true;
          }
      }
      return false;
 }
Exemple #17
0
 private void checkForDefaultAlbum()
 {
     bool ret = false;
     foreach (Album u in this.album_list)
     {
           if(u.name == "default")
               ret = true;
     }
     if (!ret) { Album i = new Album(); i.name = "default"; this.album_list.Add(i); this.defaultAlbum = i; }
 }
Exemple #18
0
 public static void Serialize(Album details)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(Album));
     using (TextWriter writer = new StreamWriter(@details.fname))
     {
         serializer.Serialize(writer, details);
     }
 }