recipe name filter
This commit is contained in:
@@ -5,11 +5,23 @@ namespace VisionBuilder.UI.Windows.Components
|
||||
{
|
||||
public partial class Stats : UserControl
|
||||
{
|
||||
private const string StartedAtLabel = "Started at";
|
||||
private const string RecipeLabel = "Recipe";
|
||||
private const string ProcessingTimeLabel = "Processing time";
|
||||
private const string GoodLabel = "Good";
|
||||
private const string BadLabel = "Bad";
|
||||
private const string TotalLabel = "Total";
|
||||
private const string DetailsLabel = "Details";
|
||||
private const string ErrorRateLabel = "Error rate";
|
||||
|
||||
private const string FontFamilyName = "Verdana";
|
||||
private const string Ellipsis = "...";
|
||||
|
||||
public void SetViewModel(StatisticsVM statisticsVm)
|
||||
{
|
||||
_statisticsVm = statisticsVm;
|
||||
_statisticsVm.PropertyChanged += _statisticsVm_PropertyChanged;
|
||||
Clear();
|
||||
}
|
||||
|
||||
private void _statisticsVm_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
@@ -17,29 +29,46 @@ namespace VisionBuilder.UI.Windows.Components
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(StatisticsVM.SessionStarted):
|
||||
UpdateMeta("Started at", _statisticsVm.SessionStarted, true);
|
||||
UpdateMeta(StartedAtLabel, _statisticsVm.SessionStarted, true);
|
||||
break;
|
||||
case nameof(StatisticsVM.RecipeName):
|
||||
UpdateMeta("Recipe", _statisticsVm.RecipeName, true);
|
||||
// we don't use RecipeName(it's on button)
|
||||
//UpdateMeta(RecipeLabel, _statisticsVm.RecipeName, true);
|
||||
break;
|
||||
case nameof(StatisticsVM.ProcessingTime):
|
||||
UpdateMeta("Processing time", _statisticsVm.ProcessingTime, true);
|
||||
UpdateMeta(ProcessingTimeLabel, _statisticsVm.ProcessingTime, true);
|
||||
break;
|
||||
case nameof(StatisticsVM.Good):
|
||||
UpdateMeta("Good", _statisticsVm.Good.ToString(), true);
|
||||
// don't need to show good count
|
||||
//UpdateMeta(GoodLabel, _statisticsVm.Good.ToString(), false);
|
||||
break;
|
||||
case nameof(StatisticsVM.Bad):
|
||||
UpdateMeta("Bad", _statisticsVm.Bad.ToString(), true);
|
||||
UpdateMeta(BadLabel, _statisticsVm.Bad.ToString(), false);
|
||||
break;
|
||||
case nameof(StatisticsVM.Total):
|
||||
UpdateMeta("Total", _statisticsVm.Total.ToString(), true);
|
||||
UpdateMeta(TotalLabel, _statisticsVm.Total.ToString(), false);
|
||||
break;
|
||||
case nameof(StatisticsVM.StatisticsDetails):
|
||||
UpdateMeta("Details", _statisticsVm.StatisticsDetails, false);
|
||||
UpdateMeta(DetailsLabel, _statisticsVm.StatisticsDetails, false);
|
||||
break;
|
||||
case nameof(StatisticsVM.ErrorRate):
|
||||
UpdateMeta(ErrorRateLabel, _statisticsVm.ErrorRate, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeFields()
|
||||
{
|
||||
UpdateMeta(StartedAtLabel,"");
|
||||
UpdateMeta(ProcessingTimeLabel, "");
|
||||
UpdateMeta(TotalLabel, "0");
|
||||
UpdateMeta(BadLabel, "0");
|
||||
UpdateMeta(ErrorRateLabel, "0");
|
||||
UpdateMeta(DetailsLabel, "");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Stats()
|
||||
{
|
||||
|
||||
@@ -64,15 +93,27 @@ namespace VisionBuilder.UI.Windows.Components
|
||||
private readonly Bitmap _imageBadIndicator;
|
||||
private StatisticsVM _statisticsVm;
|
||||
|
||||
public void UpdateMeta(string name, string text, bool bold=false)
|
||||
public static string ShortenString(string input, int maxLength)
|
||||
{
|
||||
if (input.Length <= maxLength)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
else
|
||||
{
|
||||
return input.Substring(0, maxLength) + Ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateMeta(string name, string text, bool bold = false)
|
||||
{
|
||||
Action a = new Action(() =>
|
||||
{
|
||||
if (!_meta.ContainsKey(name))
|
||||
{
|
||||
metaPanel.Controls.Add(new Label() { AutoSize = true, Margin = new Padding(0, 8, 0, 0), Text = name + ":", Font = new Font(new FontFamily("Verdana"), 8, FontStyle.Bold) });
|
||||
metaPanel.Controls.Add(new Label() { AutoSize = true, Margin = new Padding(0, 8, 0, 0), Text = name + ":", Font = new Font(new FontFamily(FontFamilyName), 8, FontStyle.Bold) });
|
||||
_meta[name] = new Label() { AutoSize = true, Margin = new Padding(0) };
|
||||
_meta[name].Font = new Font(new FontFamily("Verdana"), 8, bold?FontStyle.Bold:FontStyle.Regular);
|
||||
_meta[name].Font = new Font(new FontFamily(FontFamilyName), 8, bold ? FontStyle.Bold : FontStyle.Regular);
|
||||
metaPanel.Controls.Add(_meta[name]);
|
||||
|
||||
}
|
||||
@@ -94,22 +135,11 @@ namespace VisionBuilder.UI.Windows.Components
|
||||
|
||||
|
||||
|
||||
public static string ShortenString(string input, int maxLength)
|
||||
{
|
||||
if (input.Length <= maxLength)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
else
|
||||
{
|
||||
return input.Substring(0, maxLength) + "...";
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_meta.Clear();
|
||||
metaPanel.Controls.Clear();
|
||||
InitializeFields();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user