/// <summary>User has renamed a node.</summary> /// <param name="sender">Sending object</param> /// <param name="e">Event node arguments</param> private void OnRename(object sender, NodeRenameArgs e) { try { e.CancelEdit = false; if (e.NewName != null) { if (this.IsValidName(e.NewName)) { Model model = this.ApsimXFile.FindByPath(e.NodePath)?.Value as Model; if (model != null && model.GetType().Name != "Simulations" && e.NewName != string.Empty) { this.HideRightHandPanel(); RenameModelCommand cmd = new RenameModelCommand(model, e.NewName); CommandHistory.Add(cmd); this.ShowRightHandPanel(); e.CancelEdit = model.Name != e.NewName; } } else { MainPresenter.ShowError("Use alpha numeric characters only!"); e.CancelEdit = true; } } } catch (Exception err) { MainPresenter.ShowError(err); } }
/// <summary>User has renamed a node.</summary> /// <param name="sender">Sending object</param> /// <param name="e">Event node arguments</param> private void OnRename(object sender, NodeRenameArgs e) { e.CancelEdit = false; if (e.NewName != null) { if (this.IsValidName(e.NewName)) { Model model = Apsim.Get(this.ApsimXFile, e.NodePath) as Model; if (model != null && model.GetType().Name != "Simulations" && e.NewName != string.Empty) { this.HideRightHandPanel(); string parentModelPath = StringUtilities.ParentName(e.NodePath); RenameModelCommand cmd = new RenameModelCommand(model, e.NewName, view); CommandHistory.Add(cmd); this.ShowRightHandPanel(); e.CancelEdit = (model.Name != e.NewName); } } else { MainPresenter.ShowMessage("Use alpha numeric characters only!", DataStore.ErrorLevel.Error); e.CancelEdit = true; } } }
/// <summary>User has renamed a node.</summary> /// <param name="sender">Sending object</param> /// <param name="e">Event node arguments</param> private void OnRename(object sender, NodeRenameArgs e) { e.CancelEdit = false; if (e.NewName != null) { if (this.IsValidName(e.NewName)) { Model model = Apsim.Get(this.ApsimXFile, e.NodePath) as Model; if (model != null && model.GetType().Name != "Simulations" && e.NewName != string.Empty) { this.HideRightHandPanel(); string parentModelPath = StringUtilities.ParentName(e.NodePath); RenameModelCommand cmd = new RenameModelCommand(model, e.NewName, view); CommandHistory.Add(cmd); this.ShowRightHandPanel(); e.CancelEdit = (model.Name != e.NewName); } } else { MainPresenter.ShowMessage("Use alpha numeric characters only!", DataStore.ErrorLevel.Error); e.CancelEdit = true; } } }