public void AddImage(MyImage img)
        {
            Random rand = new Random();

            FileInfo fi = new FileInfo(img.OriginalPath);

            char [] separator = new char[1];
            separator[0]='_';

            string [] liststr = fi.Name.Split(separator);

            string path;
            if (liststr.Length == 2)
            {
                path = LoginControler.getUserDirectory() + liststr[0] + "_selection" + rand.Next().ToString() + ".jpg";
            }
            else
            {
                path = LoginControler.getUserDirectory() + "selection" + rand.Next().ToString() + ".jpg";
            }

            saveImage(ref img, path, FileMode.Create);
            userSelectionImage.Add(new UserImgSelected(path));

            LoginManager m = LoginControler.getLoginManager();
            if (m != null)
            {
                if (m.isImageAlreadyIn(img.OriginalPath) == false)
                {
                    m.AddImage(path, img.OriginalPath);
                }
            }
            else
            {
                MessageBox.Show("Error LoginManager NULL");
            }
        }
 /*
 public void AddImage(ImageSource imgsrc)
 {
     MyImage img = new MyImage();
     img.OriginalPath = imgsrc.ToString();
     img.Source = imgsrc;
     AddImage(img);
 }
  * */
 private void saveImage(ref MyImage img,string filename,System.IO.FileMode fm)
 {
     try
     {
         FileStream stream5 = new FileStream(filename, fm);
         JpegBitmapEncoder encoder5 = new JpegBitmapEncoder();
         encoder5.QualityLevel = 100;
         encoder5.Frames.Add(BitmapFrame.Create((BitmapSource)img.Source));
         encoder5.Save(stream5);
         encoder5 = null;
     }
     catch (Exception e)
     {
         MessageBox.Show("Exception saving Image " + filename + " " + e.Message);
     }
     GC.Collect();
 }