#1393 Scale up Sensor column on resize & Log file rotation method (#1397)

* Add CSV file rotation method

Add a new option to choose how the csv file is being rotated.
Before it was everyday, which meant that we had to make sure the csv file was deleted before recording a new session.
Now by default it's set to "Per session" meaning anytime you start a new session it create a new CSV file.
Unless the daily method is used, in this case it will behave like before (1 file per day)

* Scale up the first TreeView column ("Sensor") on resize

The first ("Sensor") column being the most important and most likely the one that need the more space as hardware names can be pretty long.
I've changed so that the first column is the one scaling up when the tree view is being resized (instead of the last one)

* Change treeview column resize behaviour

I've made so that the separator a controlling the size of the column to the left instead of the right.
This make a lot easier to scale up the last column, but worth for the first one.
Thought the previous commit made it so that the first column size is resize by the total with of the tree view.
Sounds weird like that, but feel much more natural than before, and there is no overflow anymore.

* Fix typo in daily file rotation menu item tool tip

Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>

* Fix requested changes

---------

Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>
This commit is contained in:
hcabel
2024-08-06 13:42:58 +02:00
committed by GitHub
co-authored by PhyxionNL
parent eaf35a7ab9
commit 499ac0e214
4 changed files with 361 additions and 233 deletions
+52 -1
View File
@@ -112,8 +112,11 @@ public sealed partial class MainForm : Form
nodeTextBoxMax.DrawText += NodeTextBoxText_DrawText;
nodeTextBoxText.EditorShowing += NodeTextBoxText_EditorShowing;
foreach (TreeColumn column in treeView.Columns)
for (int i = 1; i < treeView.Columns.Count; i++)
{
TreeColumn column = treeView.Columns[i];
column.Width = Math.Max(20, Math.Min(400, _settings.GetValue("treeView.Columns." + column.Header + ".Width", column.Width)));
}
TreeModel treeModel = new();
_root = new Node(Environment.MachineName) { Image = EmbeddedResources.GetImage("computer.png") };
@@ -387,6 +390,9 @@ public sealed partial class MainForm : Form
},
_settings);
perSessionFileRotationMenuItem.Checked = _logger.FileRotationMethod == LoggerFileRotation.PerSession;
dailyFileRotationMenuItem.Checked = _logger.FileRotationMethod == LoggerFileRotation.Daily;
_sensorValuesTimeWindow.Changed += (sender, e) =>
{
TimeSpan timeWindow = TimeSpan.Zero;
@@ -1259,6 +1265,37 @@ public sealed partial class MainForm : Form
_selectionDragging = false;
}
private void TreeView_SizeChanged(object sender, EventArgs e)
{
int newWidth = treeView.Width;
for (int i = 1; i < treeView.Columns.Count; i++)
{
if (treeView.Columns[i].IsVisible)
newWidth -= treeView.Columns[i].Width;
}
treeView.Columns[0].Width = newWidth;
}
private void TreeView_ColumnWidthChanged(TreeColumn column)
{
int index = treeView.Columns.IndexOf(column);
int columnsWidth = 0;
foreach (TreeColumn treeColumn in treeView.Columns)
{
if (treeColumn.IsVisible)
columnsWidth += treeColumn.Width;
}
int nextColumnIndex = index + 1;
while (nextColumnIndex < treeView.Columns.Count && treeView.Columns[nextColumnIndex].IsVisible == false)
nextColumnIndex++;
if (nextColumnIndex < treeView.Columns.Count) {
int diff = treeView.Width - columnsWidth;
treeView.Columns[nextColumnIndex].Width = Math.Max(20, treeView.Columns[nextColumnIndex].Width + diff);
}
}
private void ServerPortMenuItem_Click(object sender, EventArgs e)
{
new PortForm(this).ShowDialog();
@@ -1268,4 +1305,18 @@ public sealed partial class MainForm : Form
{
new AuthForm(this).ShowDialog();
}
private void perSessionFileRotationMenuItem_Click(object sender, EventArgs e)
{
dailyFileRotationMenuItem.Checked = false;
perSessionFileRotationMenuItem.Checked = true;
_logger.FileRotationMethod = LoggerFileRotation.PerSession;
}
private void dailyFileRotationMenuItem_Click(object sender, EventArgs e)
{
dailyFileRotationMenuItem.Checked = true;
perSessionFileRotationMenuItem.Checked = false;
_logger.FileRotationMethod = LoggerFileRotation.Daily;
}
}