private void AddType(NodeView nodeView) { AddEditInstrumentTypeDialog dialog = new AddEditInstrumentTypeDialog(); AddEditInstrumentTypeModel model = new AddEditInstrumentTypeModel(); model.View = dialog; dialog.DataContext = model; dialog.Show(); dialog.Closed += (s1, e1) => { NodeView parentNode = nodeView; if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { NodeView child = new NodeView(parentNode) { Id = dialog.InstrumentType.Id, Name = string.Format("{0} ({1})", dialog.InstrumentType.Name, dialog.InstrumentType.Description), Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png", Type = NodeType.InstrumentTypeNode, Description = dialog.InstrumentType.Description, HasChildren = false, SortField = dialog.InstrumentType.Ordinal.ToString(), IsActive = dialog.InstrumentType.IsActive }; parentNode.Children.Add(child); nodeView.Parent.Sort(true); } }; }
private void EditType(NodeView nodeView) { AddEditInstrumentTypeDialog dialog = new AddEditInstrumentTypeDialog(nodeView.Id); dialog.Title = "Edit Instrument Equipment Type"; dialog.Show(); dialog.Closed += (s1, e1) => { if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { nodeView.Name = string.Format("{0} ({1})", dialog.InstrumentType.Name, dialog.InstrumentType.Description); nodeView.Description = dialog.InstrumentType.Description; nodeView.SortField = dialog.InstrumentType.Ordinal.ToString(); nodeView.IsActive = dialog.InstrumentType.IsActive; nodeView.Parent.Sort(true); } }; }