示例#1
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

            int           index = dataGridView1.SelectedRows[0].Index, pos = 0;
            DuplicateItem item = items[index];

            foreach (DuplicateItem item2 in items)
            {
                if (item == item2)
                {
                    item2.Similarity = "---";
                }
                else
                {
                    int dist = DHash.Distance(item.image.hash, item2.image.hash);
                    item2.Similarity = $"{DHash.ToSimilarity(dist)}%";
                }

                if (!inInit)
                {
                    bindingList.ResetItem(pos);
                    ++pos;
                }
            }

            if (pictureBox1.Image != null)
            {
                pictureBox1.Image.Dispose();
            }
            try
            {
                pictureBox1.Image = ImageLoader.Load(item.image.path);
            }
            catch (Exception)
            {
                pictureBox1.Image = null;
            }
        }
示例#2
0
        public DialogResult Show(Image image1, Image image2, int?dist = null, int?complex = null)
        {
            this.image1 = image1;
            this.image2 = image2;

            pictureBox1.Image = ImageLoader.Load(image1.path);
            pictureBox2.Image = ImageLoader.Load(image2.path);
            DialogResult      = DialogResult.None;
            textBox1.Text     = $"File:​\u200B{image1.Filename.TrimExt(100)} Size:\u200B{Utility.BytesToString(image1.size)} Resolution:\u200B{image1.Resolution}";
            if (image1.score > 0)
            {
                textBox2.Text += $" Score:\u200B{db.GetScore(image1)}";
            }
            textBox2.Text = $"File:\u200B{image2.Filename.TrimExt(100)} Size:\u200B{Utility.BytesToString(image2.size)} Resolution:\u200B{image2.Resolution}";
            if (image2.score > 0)
            {
                textBox2.Text += $" Score:\u200B{db.GetScore(image2)}";
            }
            if (dist.HasValue)
            {
                btBoth.Text = $"Keep both\n({DHash.ToSimilarity(dist.Value)}% similarity)";
                if (image2.size >= image1.size && image2.ResolutionValue >= image1.ResolutionValue && complex == null)
                {
                    btRight.Font = boldFont;
                    btLeft.Font  = normalFont;
                }
                else if (image1.size >= image2.size && image1.ResolutionValue >= image2.ResolutionValue && complex == null)
                {
                    btLeft.Font  = boldFont;
                    btRight.Font = normalFont;
                }
                else
                {
                    btLeft.Font  = normalFont;
                    btRight.Font = normalFont;
                }

                if (complex.HasValue)
                {
                    btComplex.Enabled = true;
                    btComplex.Text    = $"Multi compare ({complex.Value})";
                    btComplex.Font    = boldFont;
                }
                else
                {
                    btComplex.Enabled = false;
                    btComplex.Text    = "Multi compare";
                    btComplex.Font    = normalFont;
                }
            }

            Show();
            while (DialogResult == DialogResult.None)
            {
                System.Threading.Thread.Sleep(10);
                Application.DoEvents();
            }

            pictureBox1.Image.Dispose();
            pictureBox1.Image = null;
            pictureBox2.Image.Dispose();
            pictureBox2.Image = null;

            return(DialogResult);
        }