private void ProgressReports_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded) { var toAdd = this.ProgressReports[e.NewIndex]; this.Dispatcher.Invoke(new Action(delegate() { this.AdditionDetailsPanelBorder.Visibility = System.Windows.Visibility.Visible; this.AdditionDetailsPanelBorder.Height = double.NaN; var progressBar = new TMGProgressBar() { Background = new SolidColorBrush(Color.FromArgb((byte)0x22, (byte)0x22, (byte)0x22, (byte)0x22)), Maximum = 10000, Minimum = 0, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, Height = 15 }; if (toAdd.Colour != null) { progressBar.SetForgroundColor(Color.FromRgb(toAdd.Colour.Item1, toAdd.Colour.Item2, toAdd.Colour.Item3)); } this.SubProgressBars.Add(new SubProgress() { Name = new Label() { Content = toAdd.Name, Foreground = Brushes.White }, ProgressBar = progressBar }); })); } else if (e.ListChangedType == ListChangedType.ItemDeleted) { if (this.ProgressReports.Count == 0) { this.Dispatcher.Invoke(new Action(delegate() { this.AdditionDetailsPanelBorder.Visibility = System.Windows.Visibility.Collapsed; this.AdditionDetailsPanelBorder.Height = 0; })); } } }
private void ProgressReports_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded) { var toAdd = this.ProgressReports[e.NewIndex]; this.Dispatcher.Invoke(new Action(delegate () { this.AdditionDetailsPanelBorder.Visibility = System.Windows.Visibility.Visible; this.AdditionDetailsPanelBorder.Height = double.NaN; var progressBar = new TMGProgressBar() { Background = new SolidColorBrush(Color.FromArgb((byte)0x22, (byte)0x22, (byte)0x22, (byte)0x22)), Maximum = 10000, Minimum = 0, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, Height = 15 }; if (toAdd.Colour != null) { progressBar.SetForgroundColor(Color.FromRgb(toAdd.Colour.Item1, toAdd.Colour.Item2, toAdd.Colour.Item3)); } this.SubProgressBars.Add(new SubProgress() { Name = new Label() { Content = toAdd.Name, Foreground = Brushes.White }, ProgressBar = progressBar }); })); } else if (e.ListChangedType == ListChangedType.ItemDeleted) { if (this.ProgressReports.Count == 0) { this.Dispatcher.Invoke(new Action(delegate () { this.AdditionDetailsPanelBorder.Visibility = System.Windows.Visibility.Collapsed; this.AdditionDetailsPanelBorder.Height = 0; })); } } }