private void dataGrid1_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { //search the object hierarchy for a datagrid row DependencyObject source = (DependencyObject)e.OriginalSource; DataGridRow row = UIExtensions.TryFindParent <DataGridRow>(source); //the user did not click on a row if (row == null) { return; } MappingGridItem item = (MappingGridItem)row.Item; DiagramView.SelectElement(item.NewVersionConstruct); if (DiagramViewOldVersion != null && item.OldVersionConstruct != null && item.OldVersionConstruct is Element) { DiagramViewOldVersion.SelectElement(item.OldVersionConstruct); } e.Handled = true; }
private void FillTable() { // load all constructs in old version foreach (Element oldE in DiagramOldVersion.DiagramElements.Keys.Where(k => !(k is Comment))) { comboItemsList.Add(oldE); if (oldE is IHasAttributes) { comboItemsList.AddRange(((IHasAttributes)oldE).Attributes); } if (oldE is IHasPSMAttributes) { comboItemsList.AddRange(((IHasPSMAttributes)oldE).PSMAttributes); } } // load all constructs in new version List <Element> newElements = DiagramNewVersion.DiagramElements.Keys.Where(k => !(k is Comment)).ToList(); // fill comboboxes with new version items ItemsList.Clear(); foreach (Element newElement in newElements) { #region item MappingGridItem mappingGridItem = new MappingGridItem { NewVersionConstructName = newElement.ToString(), NewVersionConstruct = newElement, Type = newElement.GetType().Name.Substring(1) }; ItemsList.Add(mappingGridItem); IVersionedElement elementOldVersion = newElement.GetInVersion(OldVersion); if (elementOldVersion != null) { mappingGridItem.OldVersionConstructName = elementOldVersion.ToString(); mappingGridItem.OldVersionConstruct = (Element)elementOldVersion; mappingGridItem.OriginalMapping = mappingGridItem.OldVersionConstruct; } else { Element found; if (NameMatch(comboItemsList, newElement, out found)) { mappingGridItem.OldVersionConstructName = found.ToString(); mappingGridItem.OldVersionConstruct = found; } } #endregion #region psm attributes if (newElement is IHasPSMAttributes) { foreach (PSMAttribute attribute in ((IHasPSMAttributes)newElement).PSMAttributes) { MappingGridItem attributeItem = new MappingGridItem { NewVersionConstructName = attribute.ToString(), NewVersionConstruct = attribute, Type = String.Format("PSMA in {0}", newElement) }; attributeItem.Color = Brushes.DarkGreen; IHasPSMAttributes elementOldVersionHA = null; if (mappingGridItem.OldVersionConstruct != null) { elementOldVersionHA = (IHasPSMAttributes)mappingGridItem.OldVersionConstruct; } IVersionedElement atOld = attribute.GetInVersion(OldVersion); if (atOld != null) { attributeItem.OldVersionConstruct = (Element)atOld; attributeItem.OriginalMapping = mappingGridItem.OldVersionConstruct; attributeItem.OldVersionConstructName = attributeItem.OldVersionConstruct.ToString(); } else if (elementOldVersionHA != null) { PSMAttribute found; if (NameMatch(elementOldVersionHA.PSMAttributes, attribute, out found)) { attributeItem.OldVersionConstruct = found; attributeItem.OldVersionConstructName = attributeItem.OldVersionConstruct.ToString(); } } ItemsList.Add(attributeItem); } } #endregion #region pim attributes else if (newElement is IHasAttributes) { foreach (Property attribute in ((IHasAttributes)newElement).Attributes) { MappingGridItem attributeItem = new MappingGridItem { NewVersionConstructName = attribute.ToString(), NewVersionConstruct = attribute, Type = String.Format("PSMA in {0}", newElement) }; attributeItem.Color = Brushes.DarkGreen; IHasAttributes elementOldVersionHA = null; if (mappingGridItem.OldVersionConstruct != null) { elementOldVersionHA = (IHasAttributes)mappingGridItem.OldVersionConstruct; } IVersionedElement atOld = attribute.GetInVersion(OldVersion); if (atOld != null) { attributeItem.OldVersionConstruct = (Element)atOld; attributeItem.OriginalMapping = mappingGridItem.OldVersionConstruct; attributeItem.OldVersionConstructName = attributeItem.OldVersionConstruct.ToString(); } else if (elementOldVersionHA != null) { Property found; if (NameMatch(elementOldVersionHA.Attributes, attribute, out found)) { attributeItem.OldVersionConstruct = found; attributeItem.OldVersionConstructName = attributeItem.OldVersionConstruct.ToString(); } } ItemsList.Add(attributeItem); } } #endregion } mapToColumn.ItemsSource = comboItemsList; dataGrid1.ItemsSource = ItemsList; lUnmapped.Content = ItemsList.Count(i => i.OldVersionConstruct == null); }