private void Edit(int pos) { DlgEditPerson dlg = null; Person p = null; Person backupPerson = null; if (pos >= 0 && pos < this.agendaSystem.PersonsList.Size()) { this.SetStatus("Editing contact..."); try { // Get the person and eliminate it of all lists p = this.agendaSystem.PersonsList.Get(pos); backupPerson = p.Clone(); this.ErasePerson(p); // Edit the person data dlg = new DlgEditPerson(this, agendaSystem.CategoryList, p); if (((Gtk.ResponseType)dlg.Run()) == Gtk.ResponseType.Ok) { dlg.UpdateToPerson(); this.InsertPerson(p); } else { this.InsertPerson(backupPerson); p = backupPerson; } } catch (Exception exc) { Util.MsgError(this, AppInfo.Name, exc.Message); } finally { int rowIndex = this.persons.Find(p); if (dlg != null) { dlg.Destroy(); } if (rowIndex < 0) { p = backupPerson; this.InsertPerson(p); rowIndex = this.persons.Find(p); } this.UpdatePersons(); this.SetCurrentPositionInDocument(rowIndex, 0); this.SetStatus(); } } else { Util.MsgError(this, AppInfo.Name, "person position out of bounds"); } return; }
private void Edit(int pos) { DlgEditPerson dlg = null; Person p = null; Person backupPerson = null; if ( pos >= 0 && pos < this.agendaSystem.PersonsList.Size() ) { this.SetStatus( "Editing contact..." ); try { // Get the person and eliminate it of all lists p = this.agendaSystem.PersonsList.Get( pos ); backupPerson = p.Clone(); this.ErasePerson( p ); // Edit the person data dlg = new DlgEditPerson( this, agendaSystem.CategoryList, p ); if ( ( (Gtk.ResponseType) dlg.Run() ) == Gtk.ResponseType.Ok ) { dlg.UpdateToPerson(); this.InsertPerson( p ); } else { this.InsertPerson( backupPerson ); p = backupPerson; } } catch(Exception exc) { Util.MsgError( this, AppInfo.Name, exc.Message ); } finally { int rowIndex = this.persons.Find( p ); if ( dlg != null ) { dlg.Destroy(); } if ( rowIndex < 0 ) { p = backupPerson; this.InsertPerson( p ); rowIndex = this.persons.Find( p ); } this.UpdatePersons(); this.SetCurrentPositionInDocument( rowIndex, 0 ); this.SetStatus(); } } else { Util.MsgError( this, AppInfo.Name, "person position out of bounds" ); } return; }