private IEnumerable <TimeSpan> RunProgram(GloProgram prog) { foreach (var elem in RunSequence(prog.Root.Commands)) { yield return(elem); } }
public SequenceAnimator(Canvas colorPanel, GloProgram program) { this.colorPanel = colorPanel; Running = true; programQueue = RunProgram(program).GetEnumerator(); nextExecutionTime = DateTime.Now; }
private void Button_Click(object sender, RoutedEventArgs _) { var diag = new Microsoft.Win32.OpenFileDialog(); diag.DefaultExt = ".glo"; diag.Filter = "Glo files (*.glo)|*.glo|All files|*.*"; diag.FilterIndex = 1; diag.Multiselect = true; if (diag.ShowDialog(this) == true) { timer.Stop(); runningAnimators.Clear(); trackContainer.Items.Clear(); foreach (string file in diag.FileNames) { GloProgram prog; try { prog = GloProgram.LoadFromFile(file); } catch (FileFormatException e) { MessageBox.Show(this, "Could not load file '" + file + "':" + Environment.NewLine + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Warning); return; } Canvas c = new Canvas(); c.Width = 50; c.Height = 50; c.Margin = new Thickness(10); c.Background = new SolidColorBrush(Colors.Black); Label l = new Label(); l.Content = new string(System.IO.Path.GetFileNameWithoutExtension(file).Reverse().Take(6).Reverse().ToArray()); l.Foreground = new SolidColorBrush(Colors.White); c.Children.Add(l); trackContainer.Items.Add(c); runningAnimators.Add(new SequenceAnimator(c, prog)); } StartFromBeginning(); } }