From 830944c2a92cd884734796cca8ad062d467556d2 Mon Sep 17 00:00:00 2001 From: Sven Thierfelder Date: Sat, 22 Jun 2024 11:21:18 +0200 Subject: [PATCH] add check for free space to insert an entry --- LoxStatFileForm.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/LoxStatFileForm.cs b/LoxStatFileForm.cs index 6029885..cd2b1b7 100644 --- a/LoxStatFileForm.cs +++ b/LoxStatFileForm.cs @@ -307,11 +307,18 @@ private void mnuInsertEntry_Click(object sender, EventArgs e) } else { beforeDP = _loxStatFile.DataPoints[atDP.Index - 2]; - newDP = beforeDP.Clone(); - newDP.Index = atInsert.Index; - newDP.Timestamp = beforeDP.Timestamp.AddHours(1); - _dataGridView.Rows.Insert(atInsert.Index-1, newRow); - _loxStatFile.DataPoints.Insert(atInsert.Index-1, newDP); + if (beforeDP.Timestamp < atDP.Timestamp.AddMinutes(-119)) + { + newDP = beforeDP.Clone(); + newDP.Index = atInsert.Index; + newDP.Timestamp = beforeDP.Timestamp.AddHours(1); + _dataGridView.Rows.Insert(atInsert.Index - 1, newRow); + _loxStatFile.DataPoints.Insert(atInsert.Index - 1, newDP); + } else + { + MessageBox.Show("There is not place to insert an entry! You should delete an entry first?!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } Cursor = Cursors.Default; }