Esempio n. 1
0
 public void ImageList_OnChange(object sender, ImageDataChangeEventArgs e)
 {
     if (e.ChangeType != ImageDataChangeType.Loading && e.ChangeType != ImageDataChangeType.Clear && Program.Options.SaveOnChange) // Don't save if it just loaded the database, and don't save on clear.
     {
         ImageDataList.Images.SaveDatabase();
     }
     if (Program.Options.RefreshOnChange)
     {
         this.SearchGo();
     }
 }
        private void Images_OnChange(object sender, ImageDataChangeEventArgs e)
        {
            ImageData [] keys   = new ImageData [images.Count];
            Image []     values = new Image [images.Count];
            int          i      = 0;

            foreach (KeyValuePair <ImageData, Image> kvp in images)
            {
                keys [i]   = kvp.Key;
                values [i] = kvp.Value;
                i++;
            }

            for (i = 0; i < keys.Length; i++)
            {
                KeyValuePair <ImageData, Image> kvp = new KeyValuePair <ImageData, Image> (keys [i], values [i]);
                ImageData newData;
                if ((newData = ImageDataList.Images.FromPath(kvp.Key.path)) != null)
                {
                    StringBuilder tags = new StringBuilder();

                    foreach (string tag in newData.tags)
                    {
                        if (tags.Length > 0)
                        {
                            tags.Append(", ");
                        }

                        tags.Append(tag);
                    }

                    kvp.Value.ToolTip = String.Format("Path: {0}\nDimensions: {1}x{2}\nSize: {3} MB\nTags: {4}", newData.path, newData.width, newData.height, newData.size / 1024.0f / 1024.0f, tags);

                    if (newData != kvp.Key)
                    {
                        images.Add(newData, kvp.Value);
                        images.Remove(kvp.Key);
                    }
                }
                else
                {
                    kvp.Value.ToolTip = String.Format("REMOVED IMAGE\nPath: {0}", kvp.Key.path);
                }
            }
        }