Esempio n. 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="path">Path where the pictures are</param>
        public PictureList(string path)
        {
            _Path = path;

            _ExifPictures       = new PictureInfoList(path);
            _ConsolidatedList   = new Dictionary <string, PictureComparer>();
            _ChangesPendingList = new Dictionary <string, PictureComparer>();

            // now add all pictures having exiftool information
            foreach (KeyValuePair <string, PictureInfo> entry in _ExifPictures)
            {
                if (_ConsolidatedList.ContainsKey(entry.Key))
                {
                    _ConsolidatedList[entry.Key].ExifInfo = entry.Value as ExifPictureInfo;
                    _ConsolidatedList[entry.Key].CheckPics();
                }
                else
                {
                    PictureComparer pc = new PictureComparer();
                    pc.ExifInfo = entry.Value as ExifPictureInfo;
                    pc.CheckPics();
                    _ConsolidatedList.Add(entry.Key, pc);
                }
            }
            // setup the changes pending list
            foreach (KeyValuePair <string, PictureComparer> kvp in _ConsolidatedList)
            {
                if (kvp.Value.ExifUpdateNeeded)
                {
                    _ChangesPendingList.Add(kvp.Key, kvp.Value);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Save all changed data
 /// </summary>
 public void SaveChangedData()
 {
     _SaveResult             = "";
     _NumberOfPicturesToSave = 0;
     _PicturesToSave         = new Queue <PictureComparer>();
     foreach (KeyValuePair <string, PictureComparer> kvp in _ChangesPendingList)
     {
         _NumberOfPicturesToSave++;
         kvp.Value.Saved += new PictureComparer.OnSaved(Value_Saved);
         _PicturesToSave.Enqueue(kvp.Value);
     }
     if (_NumberOfPicturesToSave == 0)
     { // nothing to save! finish!
         if (Saved != null)
         {
             Saved(this, new OnPictureListSavedEventArgs(_SaveResult));
         }
         return;
     }
     lock (_PicturesToSave)
     {
         _TotalNumberOfPictures = _PicturesToSave.Count;
         Debug.WriteLine(_TotalNumberOfPictures.ToString() + " Pictures in Save-Queue (Starting)");
         // start with maximal four threads
         for (int i = 0; i < 4 && i < _PicturesToSave.Count; i++)
         {
             PictureComparer pc = _PicturesToSave.Dequeue();
             pc.Save();
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Value was saved. Collect info, then finish
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void Value_Saved(object sender, OnSavedEventArgs args)
        {
            lock (_PicturesToSave)
            {
                PictureComparer pc = sender as PictureComparer;
                if (pc != null)
                {
                    _SaveResult += pc.FileName + ":" + Environment.NewLine;
                }
                _SaveResult += args.ToolOutput;
                _NumberOfPicturesToSave--;

                if (PictureSaved != null)
                {
                    PictureSaved(this, new OnPictureSavedEventArgs(pc.FileName, (int)(100 - 100 * (float)((float)_NumberOfPicturesToSave / (float)_TotalNumberOfPictures))));
                }

                // one more in the queue? -> dequeue, start saving
                if (_PicturesToSave.Count > 0)
                {
                    PictureComparer pic = _PicturesToSave.Dequeue();
                    pic.Save();
                }

                Debug.WriteLine(_PicturesToSave.Count.ToString() + " Pictures in Save-Queue");

                // finished?
                if (_NumberOfPicturesToSave == 0)
                {
                    if (Saved != null)
                    {
                        Saved(this, new OnPictureListSavedEventArgs(_SaveResult));
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Delay timer, put the event for a file which is not to be changed in another thread
        /// </summary>
        /// <param name="state"></param>
        private void DelayTimer(object state)
        {
            PictureComparer p = state as PictureComparer;

            p.exifTool_Finished(p, new FinishedEventArgs("Nothing saved", ""));
        }
Esempio n. 5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="path">Path where the pictures are</param>
        public PictureList(string path)
        {
            _Path = path;

             _ExifPictures = new PictureInfoList(path);
             _ConsolidatedList = new Dictionary<string, PictureComparer>();
             _ChangesPendingList = new Dictionary<string, PictureComparer>();

             // now add all pictures having exiftool information
             foreach (KeyValuePair<string, PictureInfo> entry in _ExifPictures)
             {
            if (_ConsolidatedList.ContainsKey(entry.Key))
            {
               _ConsolidatedList[entry.Key].ExifInfo = entry.Value as ExifPictureInfo;
               _ConsolidatedList[entry.Key].CheckPics();
            }
            else
            {
               PictureComparer pc = new PictureComparer();
               pc.ExifInfo = entry.Value as ExifPictureInfo;
               pc.CheckPics();
               _ConsolidatedList.Add(entry.Key, pc);
            }
             }
             // setup the changes pending list
             foreach (KeyValuePair<string, PictureComparer> kvp in _ConsolidatedList)
             {
            if (kvp.Value.ExifUpdateNeeded)
            {
               _ChangesPendingList.Add(kvp.Key, kvp.Value);
            }
             }
        }