Convenience: If creating a new ship fails, the ship is shown again when the dialog is re-opened

This commit is contained in:
Daniel Schick 2024-08-28 17:35:58 +02:00
parent 65779731fd
commit b154f73ce9
3 changed files with 10 additions and 5 deletions

View File

@ -1065,7 +1065,7 @@ namespace BreCalClient
// (if the special-flag is enabled). Assigned Agency: ShipcallParticipantMap(id=628, shipcall_id=115, participant_id=10, // (if the special-flag is enabled). Assigned Agency: ShipcallParticipantMap(id=628, shipcall_id=115, participant_id=10,
// type=8, created=datetime.datetime(2024, 8, 28, 15, 13, 14), modified=None) with Flags: 42\"} // type=8, created=datetime.datetime(2024, 8, 28, 15, 13, 14), modified=None) with Flags: 42\"}
Match m = Regex.Match(message, "\\{(.*)\\}"); Match m = Regex.Match(message, "\\{(.*)\\}");
if ((m != null) && (m.Success)) if ((m != null) && m.Success)
{ {
dynamic? msg = JsonConvert.DeserializeObject(m.Value); dynamic? msg = JsonConvert.DeserializeObject(m.Value);
if(msg != null) if(msg != null)

View File

@ -90,7 +90,9 @@ namespace BreCalClient
private async void DataGridShips_CreateRequested() private async void DataGridShips_CreateRequested()
{ {
ShipModel shipModel = new(new Ship());
ShipModel shipModel = new((ShipModel.LastEditShip != null) ? ShipModel.LastEditShip : new Ship());
EditShipDialog esd = new() EditShipDialog esd = new()
{ {
Ship = shipModel.Ship Ship = shipModel.Ship
@ -111,14 +113,15 @@ namespace BreCalClient
if(!BreCalLists.ShipLookupDict.TryAdd(id.VarId, shipModel)) if(!BreCalLists.ShipLookupDict.TryAdd(id.VarId, shipModel))
BreCalLists.ShipLookupDict[id.VarId] = shipModel; BreCalLists.ShipLookupDict[id.VarId] = shipModel;
this.dataGridShips.ItemsSource = BreCalLists.AllShips; this.dataGridShips.ItemsSource = BreCalLists.AllShips;
ShipModel.LastEditShip = null;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message); ShipModel.LastEditShip = shipModel.Ship;
MessageBox.Show(ex.Message);
} }
} }
} }
#endregion #endregion

View File

@ -16,6 +16,8 @@ namespace BreCalClient
public Ship Ship { get; private set; } public Ship Ship { get; private set; }
public static Ship? LastEditShip { get; set; }
public string TugCompany public string TugCompany
{ {
get { if(this.Ship.ParticipantId.HasValue) get { if(this.Ship.ParticipantId.HasValue)