private void InitMappedSignals() { var hiddenColumns = new[] { 0, 1, 5, 6, 7, 8, 9, 10 }; var signalMappingDao = new SignalMappingDAO(); List <SourceSignalMapBean> sourceSignals = signalMappingDao.GetSourceSignals("ATLAS"); List <SourceSignalMapBean> filteredSourceSignals = new List <SourceSignalMapBean>(); foreach (SourceSignalMapBean bean in sourceSignals) { if (_usedSignalList.Contains(bean.sourceName)) { filteredSourceSignals.Add(bean); } } mappedSignals.DataSource = filteredSourceSignals; //sourceSignals; foreach (int hiddenColumn in hiddenColumns) { mappedSignals.Columns[hiddenColumn].Visible = false; } mappedSignals.Columns[2].DefaultCellStyle.BackColor = Color.Honeydew; mappedSignals.Columns[2].ReadOnly = true; mappedSignals.Columns[2].HeaderText = @"Source Name"; mappedSignals.Columns[3].HeaderText = @"Target Type"; mappedSignals.Columns[4].HeaderText = @"Target Name"; mappedSignals.RowEnter += MappedSignalsOnRowEnter; mappedSignals.RowLeave += MappedSignalsOnRowLeave; mappedSignals.RowValidating += MappedSignalsOnRowValidating; ResizeMappedSignals(); }
public TranslationLibrary() { var signalMappingDao = new SignalMappingDAO(); _signalMap = new Dictionary <string, Dictionary <object, SignalMappingNounModifier> >(); _sourceSignalMap = new Dictionary <string, SourceSignalMapBean>(); List <SourceSignalMapBean> signals = signalMappingDao.GetSourceSignals("ATLAS"); foreach (var sourceSignalMapBean in signals) { if (!_sourceSignalMap.ContainsKey(sourceSignalMapBean.sourceName)) { _sourceSignalMap.Add(sourceSignalMapBean.sourceName, sourceSignalMapBean); } if (!_signalMap.ContainsKey(sourceSignalMapBean.sourceName)) { _signalMap.Add(sourceSignalMapBean.sourceName, new Dictionary <object, SignalMappingNounModifier>()); } Dictionary <object, SignalMappingNounModifier> attributeMap = _signalMap[sourceSignalMapBean.sourceName]; List <SourceSignalAttributeMapBean> attributes = signalMappingDao.GetSignalAttributes(sourceSignalMapBean.id); foreach (var attribute in attributes) { if (!attributeMap.ContainsKey(attribute.sourceName)) { var smnm = new SignalMappingNounModifier(); smnm.Name = attribute.sourceName; smnm.Attribute = string.IsNullOrEmpty(attribute.targetName) ? attribute.sourceName + "->[UNKNOWN]" : attribute.targetName; smnm.Default = attribute.targetDefault; smnm.Type = attribute.targetType; smnm.Suffix = attribute.sourceSuffix; smnm.Qualifier = attribute.targetQualifier; attributeMap.Add(smnm.Name, smnm); } } } }
public SignalMapper() { _signalDao = new SignalDAO(); _signalMappingDao = new SignalMappingDAO(); }
private void MappedSignalsOnRowEnter(object sender, DataGridViewCellEventArgs dataGridViewCellEventArgs) { //signalModelLibrary.ResetBackColors(Color.White); signalModelLibrary.ResetImages(0); int idxOld = -1; if (mappedSignals.CurrentRow != null) { idxOld = mappedSignals.CurrentRow.Index; SaveMappedAttributes(); } int idx = dataGridViewCellEventArgs.RowIndex; string signalName = mappedSignals.Rows[idx].Cells[2].Value.ToString(); string targetName = mappedSignals.Rows[idx].Cells[4].Value != null?mappedSignals.Rows[idx].Cells[4].Value.ToString():null; TreeNode selectedSignalModelNode = null; if (idx != idxOld) { var bean = mappedSignals.Rows[idx].DataBoundItem as SourceSignalMapBean; if (bean != null) { selectedSignalModelNode = signalModelLibrary.FindNode("TSF", bean.targetType, bean.targetName); if (selectedSignalModelNode != null) { signalModelLibrary.SelectedNode = selectedSignalModelNode; signalModelLibrary.SelectedNode.SelectedImageIndex = 1; signalModelLibrary.SelectedNode.ImageIndex = 1; } var signalMappingDao = new SignalMappingDAO(); var hiddenColumns = new[] { 0, 1, 3, 4, 5, 6, 12, 13, 14, 15, 16, 17 }; mappedSignalAttributes.DataSource = signalMappingDao.GetSignalAttributes(bean.id); foreach (int hiddenColumn in hiddenColumns) { mappedSignalAttributes.Columns[hiddenColumn].Visible = false; } mappedSignalAttributes.Columns[2].DefaultCellStyle.BackColor = Color.Honeydew; mappedSignalAttributes.Columns[2].ReadOnly = true; mappedSignalAttributes.Columns[2].HeaderText = @"Source Name"; mappedSignalAttributes.Columns[3].HeaderText = @"Source Type"; mappedSignalAttributes.Columns[4].HeaderText = @"Source Default"; mappedSignalAttributes.Columns[5].HeaderText = @"Source Suffix"; mappedSignalAttributes.Columns[6].HeaderText = @"Source Unit"; mappedSignalAttributes.Columns[7].HeaderText = @"Target Name"; mappedSignalAttributes.Columns[8].HeaderText = @"Target Type"; mappedSignalAttributes.Columns[9].HeaderText = @"Target Default"; mappedSignalAttributes.Columns[10].HeaderText = @"Target Suffix"; mappedSignalAttributes.Columns[11].HeaderText = @"Target Unit"; mappedSignalAttributes.CellLeave += mappedSignalAttributes_CellEndEdit; //--- Save original Values ---// foreach (DataGridViewRow row in mappedSignalAttributes.Rows) { foreach (DataGridViewCell cell in row.Cells) { if (cell != null) { cell.Tag = cell.Value as string; } } } } if (string.IsNullOrEmpty(targetName) || selectedSignalModelNode == null) { XmlElement bestMatch = DetermineBestModelForSelectedSignal(signalName); if (bestMatch != null) { TreeNode node = signalModelLibrary.FindNodeByTagValue(bestMatch); if (node != null) { //node.BackColor = Color.GreenYellow; node.ImageIndex = 1; node.SelectedImageIndex = 1; } } } } }