Example #1
0
        private void button_Compare_Click(object sender, RoutedEventArgs e)
        {
            var shownComparisons = new HashSet <Tuple <string, string> >(new ReverseTupleComparer());

            long      total     = BitmapComparer.GetPermutationCount();
            const int MAX_COUNT = 5000000;
            IDictionary <Tuple <string, string>, float> diffMap = null;
            int startIdx = 0;

restart:
            GC.Collect();
            Action task = new Action(() =>
            {
                diffMap = BitmapComparer.CreateDiffMapFromDCTCache(MAX_COUNT, startIdx);
            });

            WorkWindow wwin = new WorkWindow($"Generating diff map...\n\n[{startIdx}] out of [{total}]", task);

            wwin.Owner = this;
            wwin.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            wwin.SetPBarScore(startIdx, total);
            wwin.ShowDialog();

            float threshold = float.Parse(txt_Threshold.Text, CultureInfo.InvariantCulture);

            var filteredDiffMap = diffMap.Where((kvp) => kvp.Value >= threshold);

            long idx = 0;

            foreach (var kvp in filteredDiffMap.Distinct())
            {
                string file1 = kvp.Key.Item1;
                string file2 = kvp.Key.Item2;

                var tuple = new Tuple <string, string>(file1, file2);

                if (shownComparisons.Contains(tuple))
                {
                    continue;
                }

                float diff = kvp.Value;

                CompWindow cwin = new CompWindow(file1, file2, diff);
                cwin.Owner = this;
                cwin.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                cwin.ShowDialog();

                shownComparisons.Add(tuple);
                idx++;
            }
            if (diffMap.Count != 0)
            {
                startIdx += diffMap.Count;
                goto restart;
            }
        }