/// <summary> /// This method performs a merge between the Loaded links and the existing configuration /// based on the names of the loaded links. It also updates the form to match the most /// updated merge /// </summary> /// <returns></returns> private TreeMerger MergeAndUpdate() { // Setup merge to start with a fresh link, ExistingTreeView.SetTree(ExistingBaseLink.Clone()); LoadedCSVLinkNames.Clear(); LoadedCSVLinkNames.UnionWith(LoadedCSVLinks.Select(link => link.Name)); // Update correspondance with the most up-to-date names as well as the // appropriate list boxes TreeCorrespondance.BuildCorrespondance(ExistingTreeView, LoadedCSVLinks, out List <Link> matched, out List <Link> unmatched); UpdateList(MatchingLoadedLinks, matched); UpdateList(UnmatchedLoadedLinks, unmatched); // Perform merge TreeMerger merger = new TreeMerger(MassInertiaLoadedButton.IsChecked.Value, VisualLoadedButton.IsChecked.Value, JointKinematicsLoadedButton.IsChecked.Value, OtherJointLoadedButton.IsChecked.Value); Link mergedRoot = merger.Merge(ExistingTreeView, TreeCorrespondance); // Update Form Tree ExistingTreeView.SetTree(mergedRoot); return(merger); }
private void MergeClick(object sender, EventArgs e) { TreeMerger merger = MergeAndUpdate(); if (UnmatchedLoadedLinks.Items.Count > 0) { IEnumerable <string> unmatchedLinkNames = UnmatchedLoadedLinks.Items .Cast <ListBoxItem>() .Select(item => ((Link)item.Tag).Name); string unmatchedLinksStr = string.Join("\r\n", unmatchedLinkNames); string message = "The follow links loaded from the CSV " + CSVFileName + " have not " + "been matched with links in the assembly configuration, would you like to " + "continue?\r\n\r\n" + unmatchedLinksStr; MessageBoxResult result = MessageBox.Show(message, "Merge with unmatched links?", MessageBoxButton.YesNo); if (result != MessageBoxResult.Yes) { return; } } TreeMergedEventArgs mergedArgs = new TreeMergedEventArgs(ExistingTreeView, true, merger, CSVFileName); TreeMerged(this, mergedArgs); Close(); }
public TreeMergedEventArgs(URDFTreeView mergedTree, bool success, TreeMerger merger, string csvFilename) { MergedTree = mergedTree; Success = success; UsedCSVInertial = merger.UseCSVInertial; UsedCSVVisualCollision = merger.UseCSVVisualCollision; UsedCSVJointKinematics = merger.UseCSVJointKinematics; UsedCSVJointOther = merger.UseCSVJointOther; CSVFilename = csvFilename; }