GraphsTabPageCtrl : 1. Unlimited history, 2. Dynamic subnodes.

This commit is contained in:
Milan Hanajik 2021-07-26 13:36:42 +02:00
parent 7bdf6efd9d
commit dfd6399d6c

View File

@ -1,16 +1,14 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
/// Copyright (c) 2018-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using TBF.Resources;
using TBF.UiBridge;
using GraphLib;
using log4net;
using TBF.BenchControl.Sequences;
using TBF.Resources;
namespace TBF.UI.Graphs
{
@ -139,53 +137,37 @@ namespace TBF.UI.Graphs
}
Array.Sort(batchNrs);
treeView.Nodes.Clear();
for (int j = batchNrs.Length - 1; j >= Math.Max(0, batchNrs.Length - 40); j--)
Cursor.Current = Cursors.WaitCursor;
treeView.BeginUpdate();
treeView.Nodes.Clear();
for (int j = batchNrs.Length - 1; j >= 0; j--)
{
string batchNrSstr = batchNrs[j].ToString();
string b = Path.Combine(Program.GraphsDir, batchNrSstr);
string rootNodeName = batchNrSstr;
if ((TBF.BenchControl.Sequences.ProcessData.BatchRslts != null) && rootNodeName.Equals(TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.BatchNr.ToString()))
{
rootNodeName = Strings.current;
}
TreeNode node = new TreeNode(rootNodeName);
string batchNrStr = batchNrs[j].ToString();
string b = Path.Combine(Program.GraphsDir, batchNrStr);
TreeNode node = new TreeNode(batchNrStr);
node.Tag = null;
treeView.Nodes.Add(node);
string[] tests = Directory.GetDirectories(b);
foreach (var t in tests)
{
string testNameStr = Path.GetFileName(t);
TreeNode subnode = new TreeNode(testNameStr);
node.Nodes.Add(subnode);
string[] repetitions = Directory.GetDirectories(t);
if (repetitions.Length == 1)
{
subnode.Tag = string.Format("{0}~{1}~{2}", repetitions[0], batchNrSstr, testNameStr);
}
else if (repetitions.Length > 1)
{
subnode.Tag = null;
foreach (var r in repetitions)
{
string repetStr = Path.GetFileName(r);
TreeNode subsubnode = new TreeNode(repetStr);
subsubnode.Tag = string.Format("{0}~{1}~{2}/{3}", r, batchNrSstr, testNameStr, repetStr);
subnode.Nodes.Add(subsubnode);
}
}
else
{
subnode.Tag = null;
}
}
}
}
if (j == batchNrs.Length - 1)
{
AddSubnodesToBatchNode(node);
node.Expand();
if (ProcessData.BatchRslts != null && batchNrStr == ProcessData.BatchRslts.Batch.BatchNr.ToString())
{
node.Text = string.Format("{0} ({1})", batchNrStr, Strings.current);
}
}
}
}
catch (Exception exc)
{
log.ErrorFormat("UpdateTestsHistory() failed: {0}", exc.Message);
}
}
treeView.EndUpdate();
Cursor.Current = Cursors.Default;
}
private void testsHistoryTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
@ -198,8 +180,43 @@ namespace TBF.UI.Graphs
selectedTestName = fields[2];
ShowGraphs(plotterDisplayEx, selectedGraphsPath, selectedBatchNr, selectedTestName);
}
else if (e.Node.Tag == null && e.Node.Nodes.Count == 0)
{
AddSubnodesToBatchNode(e.Node);
}
}
void AddSubnodesToBatchNode(TreeNode node)
{
string[] tests = Directory.GetDirectories(Path.Combine(Program.GraphsDir, node.Text));
foreach (var t in tests)
{
string testNameStr = Path.GetFileName(t);
TreeNode subnode = new TreeNode(testNameStr);
node.Nodes.Add(subnode);
string[] repetitions = Directory.GetDirectories(t);
if (repetitions.Length == 1)
{
subnode.Tag = string.Format("{0}~{1}~{2}", repetitions[0], node.Text, testNameStr);
}
else if (repetitions.Length > 1)
{
subnode.Tag = null;
foreach (var r in repetitions)
{
string repetStr = Path.GetFileName(r);
TreeNode subsubnode = new TreeNode(repetStr);
subsubnode.Tag = string.Format("{0}~{1}~{2}/{3}", r, node.Text, testNameStr, repetStr);
subnode.Nodes.Add(subsubnode);
}
}
else
{
subnode.Tag = null;
}
}
}
void ShowGraphs(PlotterDisplayEx display, string path, int batchNr, string testName)
{