Ejemplo n.º 1
0
 private void lvMyTagRank_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lvMyTagRank.SelectedItems.Count > 0)
     {
         string[] tags = lvMyTagRank.SelectedItems.OfType <ListViewItem>().Select(x => x.SubItems[0].Text).ToArray();
         flowLayoutPanel1.SuspendLayout();
         for (int i = 0; i < flowLayoutPanel1.Controls.Count; i++)
         {
             PicElement pe = flowLayoutPanel1.Controls[i] as PicElement;
             if (tags.All(x => pe.Log.Tags != null && pe.Log.Tags.Contains(x)))
             {
                 pe.Selected = true;
             }
             else
             {
                 pe.Selected = false;
             }
         }
         flowLayoutPanel1.ResumeLayout();
     }
     else
     {
         for (int i = 0; i < flowLayoutPanel1.Controls.Count; i++)
         {
             (flowLayoutPanel1.Controls[i] as PicElement).Selected = false;
         }
     }
 }
Ejemplo n.º 2
0
        private void load_zip(string files)
        {
            IPicElement pe;

            pe = new PicElement(this);

            pe.Path  = files;
            pe.Label = Path.GetFileNameWithoutExtension(files);

            using (var zip = ZipFile.Open(files, ZipArchiveMode.Read))
            {
                string tmp = Path.GetTempFileName();
                if (!zip.Entries[0].Name.EndsWith(".json"))
                {
                    zip.Entries[0].ExtractToFile(tmp, true);
                }
                else
                {
                    zip.Entries[1].ExtractToFile(tmp, true);
                }
                try
                {
                    pe.Log = JsonConvert.DeserializeObject <HitomiJsonModel>(new StreamReader(zip.GetEntry("Info.json").Open()).ReadToEnd());
                    if (pe.Log.Tags != null)
                    {
                        lock (tags)
                        {
                            foreach (var tag in pe.Log.Tags)
                            {
                                if (tags.ContainsKey(tag))
                                {
                                    tags[tag] += 1;
                                }
                                else
                                {
                                    tags.Add(tag, 1);
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                }
                pe.SetImageFromAddress(tmp, 150, 200);
            }

            pe.Font = this.Font;
            Interlocked.Increment(ref count_load);
            this.Post(() => Text = $"{prefix} [{count_load}/{max_load}]");
            this.Post(() => flowLayoutPanel1.Controls.Add(pe as Control));
            this.Post(() => SortThumbnail());
        }