Example #1
0
        private void findSimilarsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selectedItemIndex < 0 || selectedItemIndex >= items.Count)
            {
                return;
            }
            try
            {
                if (findSimilarPropertiesForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                SimilarityOptions Options = new SimilarityOptions()
                {
                    AmpEnvelope = findSimilarPropertiesForm.cbAmpEnvelope.Checked,
                    Intensity   = findSimilarPropertiesForm.cbIntensity.Checked,
                    LongRhythm  = findSimilarPropertiesForm.cbLongRhythm.Checked,
                    ShortRhythm = findSimilarPropertiesForm.cbShortRhythm.Checked,
                    VolumeDistr = findSimilarPropertiesForm.cbVolumeDistr.Checked
                };

                items.SearchBy <SearchBySimilarity>(selectedItemIndex, Options);

                ScrollToTopLeft();
                selectedItemIndex = 0;
                Invalidate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void CanHandleTwoTreeEntryChangesWithTheSamePath(SimilarityOptions similarity, Action <string, TreeChanges> verifier)
        {
            string repoPath = InitNewRepository();

            using (var repo = new Repository(repoPath))
            {
                Blob mainContent = OdbHelper.CreateBlob(repo, "awesome content\n" + new string('b', 4096));
                Blob linkContent = OdbHelper.CreateBlob(repo, "../../objc/Nu.h");

                string path = Path.Combine("include", "Nu", "Nu.h");

                var tdOld = new TreeDefinition()
                            .Add(path, linkContent, Mode.SymbolicLink)
                            .Add("objc/Nu.h", mainContent, Mode.NonExecutableFile);

                Tree treeOld = repo.ObjectDatabase.CreateTree(tdOld);

                var tdNew = new TreeDefinition()
                            .Add(path, mainContent, Mode.NonExecutableFile);

                Tree treeNew = repo.ObjectDatabase.CreateTree(tdNew);

                var changes = repo.Diff.Compare <TreeChanges>(treeOld, treeNew,
                                                              compareOptions: new CompareOptions
                {
                    Similarity = similarity,
                });

                verifier(path, changes);
            }
        }
        public SimilarityOptionsViewModel(ISchedulers schedulers, SimilarityOptions similarityOptions)
        {
            RenameDetectionMode = new EnumViewModel <RenameDetectionMode>(similarityOptions.RenameDetectionMode)
                                  .DisposeWith(_disposable);
            BreakRewriteThresholdInput = new IntegerInputViewModel(schedulers, similarityOptions.BreakRewriteThreshold)
                                         .DisposeWith(_disposable);
            CopyThresholdInput = new IntegerInputViewModel(schedulers, similarityOptions.CopyThreshold)
                                 .DisposeWith(_disposable);
            RenameFromRewriteThresholdInput = new IntegerInputViewModel(schedulers, similarityOptions.RenameFromRewriteThreshold)
                                              .DisposeWith(_disposable);
            RenameLimitInput = new IntegerInputViewModel(schedulers, similarityOptions.RenameLimit)
                               .DisposeWith(_disposable);
            RenameThresholdInput = new IntegerInputViewModel(schedulers, similarityOptions.RenameThreshold)
                                   .DisposeWith(_disposable);
            WhitespaceMode = new EnumViewModel <WhitespaceMode>(similarityOptions.WhitespaceMode)
                             .DisposeWith(_disposable);

            SimilarityObservable = Observable
                                   .CombineLatest(
                RenameDetectionMode.Value,
                BreakRewriteThresholdInput.Value,
                CopyThresholdInput.Value,
                RenameFromRewriteThresholdInput.Value,
                RenameLimitInput.Value,
                RenameThresholdInput.Value,
                WhitespaceMode.Value,
                (
                    renameDetectionMode,
                    breakRewriteThreshold,
                    copyThreshold,
                    renameFromRewirteThreshold,
                    renameLimit,
                    renameThreshold,
                    whitespaceMode)
                => new SimilarityOptions()
            {
                RenameDetectionMode        = renameDetectionMode,
                BreakRewriteThreshold      = breakRewriteThreshold,
                CopyThreshold              = copyThreshold,
                RenameFromRewriteThreshold = renameFromRewirteThreshold,
                RenameLimit     = renameLimit,
                RenameThreshold = renameThreshold,
                WhitespaceMode  = whitespaceMode,
            });
        }
Example #4
0
        public ActionResult Search(int id)
        {
            var trackList = new List <Track>();

            if (db.Tracks.Any())
            {
                trackList = db.Tracks.ToList();
            }

            if (id < 0 || id >= ShownItems.Count)
            {
                return(View(new List <Track>()));
            }

            SimilarityOptions Options = new SimilarityOptions()
            {
                AmpEnvelope = true,
                Intensity   = true,
                LongRhythm  = true,
                ShortRhythm = true,
                VolumeDistr = true
            };

            var searchItems   = ShownItems.SearchBy <SearchBySimilarity>(id, Options);
            var showTrackList = new List <Track>();

            foreach (var shownItem in searchItems)
            {
                var track = trackList.FirstOrDefault(t => t.FileName.Contains(shownItem.ShortName));
                if (track != null)
                {
                    showTrackList.Add(track);
                }
            }
            return(View(showTrackList));
        }
        private void CanHandleTwoTreeEntryChangesWithTheSamePath(SimilarityOptions similarity, Action<string, TreeChanges> verifier)
        {
            string repoPath = InitNewRepository();

            using (var repo = new Repository(repoPath))
            {
                Blob mainContent = OdbHelper.CreateBlob(repo, "awesome content\n" + new string('b', 4096));
                Blob linkContent = OdbHelper.CreateBlob(repo, "../../objc/Nu.h");

                string path = Path.Combine("include", "Nu", "Nu.h");

                var tdOld = new TreeDefinition()
                    .Add(path, linkContent, Mode.SymbolicLink)
                    .Add("objc/Nu.h", mainContent, Mode.NonExecutableFile);

                Tree treeOld = repo.ObjectDatabase.CreateTree(tdOld);

                var tdNew = new TreeDefinition()
                    .Add(path, mainContent, Mode.NonExecutableFile);

                Tree treeNew = repo.ObjectDatabase.CreateTree(tdNew);

                using (var changes = repo.Diff.Compare<TreeChanges>(treeOld, treeNew,
                    compareOptions: new CompareOptions
                    {
                        Similarity = similarity,
                    }))
                {
                    verifier(path, changes);
                }
            }
        }