Files
OpenFace/gui/OpenFace-offline/UI_items/MultiBarGraph.xaml.cs
Tadas Baltrusaitis e6e547b0a1 GUI initial work (WIP)
2016-05-20 16:48:43 -04:00

60 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for MultiBarGraph.xaml
/// </summary>
public partial class MultiBarGraph : UserControl
{
int num_bars = 0;
List<BarGraph> graphs;
public MultiBarGraph()
{
InitializeComponent();
graphs = new List<BarGraph>();
}
public void Update(List<double> data)
{
// Create new bars if necessary
if (num_bars != data.Count)
{
num_bars = data.Count;
barGrid.Children.Clear();
foreach (var value in data)
{
BarGraph newBar = new BarGraph();
graphs.Add(newBar);
barGrid.ColumnDefinitions.Add(new ColumnDefinition());
Grid.SetColumn(newBar, graphs.Count);
barGrid.Children.Add(newBar);
}
}
// Update the bars
for (int i = 0; i < data.Count; ++i)
{
graphs[i].SetValue(data[i]);
}
}
}
}