public void ClearTest() { var collection = new MyObservableCollection <int>(); var newItems = Enumerable.Range(0, 5).ToArray(); collection.AddRange(newItems); int detachedCount = 0; collection.ItemDetached += (sender, oldItem, index) => { Assert.IsTrue(ReferenceEquals(sender, collection)); detachedCount++; }; int removeCount = 0; collection.ItemRemoved += (sender, oldItem, index) => { Assert.IsTrue(ReferenceEquals(sender, collection)); removeCount++; }; collection.Clear(); Assert.AreEqual(detachedCount, newItems.Length); Assert.AreEqual(removeCount, newItems.Length); }
public void ShowMacroblock(Macroblock mb) { lock (this) { if ((m_Mb != mb) && mb != null) { m_Mb = mb; Int32[] bits4x4; UInt32 YCount = 0, UCount = 0, VCount = 0; m_DataSourceY.Clear(); m_DataSourceU.Clear(); m_DataSourceV.Clear(); m_TextBlockMacroblockInfo.Text = String.Format("{0} / MB {1}({2}, {3}) / Slice:{4} / Picture:{5} / Layer:{6}", m_Title, mb.Mb.Address, mb.Mb.X << 4, mb.Mb.Y << 4, mb.SliceId, mb.PictureId, mb.LayerId); for (uint y = 0; y < 4; y++) { MbBits4x4Row rowY = new MbBits4x4Row(); MbBits4x4Row rowU = new MbBits4x4Row(); MbBits4x4Row rowV = new MbBits4x4Row(); for (uint x = 0; x < 4; x++) { // Y bits4x4 = m_Mb.Mb.GetMbBits4x4(CommonYuvLine_t.CommonYuvLine_Y, m_DataType, x, y); if (bits4x4 != null) { rowY.Add(new MbBits4x4(YCount++, x, y, bits4x4)); } // U bits4x4 = m_Mb.Mb.GetMbBits4x4(CommonYuvLine_t.CommonYuvLine_U, m_DataType, x, y); if (bits4x4 != null) { rowU.Add(new MbBits4x4(UCount++, x, y, bits4x4)); } // V bits4x4 = m_Mb.Mb.GetMbBits4x4(CommonYuvLine_t.CommonYuvLine_V, m_DataType, x, y); if (bits4x4 != null) { rowV.Add(new MbBits4x4(VCount++, x, y, bits4x4)); } } if (rowY.Row.Count > 0) { m_DataSourceY.Add(rowY); } if (rowU.Row.Count > 0) { m_DataSourceU.Add(rowU); } if (rowV.Row.Count > 0) { m_DataSourceV.Add(rowV); } } } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { m_RunningApps.Clear(); IDictionary <IntPtr, String> runningApps = ScreenCast.EnumWindows(); foreach (var item in runningApps) { m_RunningApps.Add(new RunningApp(item.Key, item.Value, ScreenCast.GetSmallWindowIcon(item.Key))); } m_RunningApps.Add(new RunningApp(IntPtr.Zero, "Entire screen", null)); }
public void UpdateMonthDetails() { _monthDetails.Clear(); int numRows = this.Session.BudgetValues.Count; List <MonthDetailRow> monthDetails = new List <MonthDetailRow>(); for (int i = 0; i < numRows; i++) { Group currentGroup = this.Session.BudgetValues[i].Group; Category currentCategory = this.Session.BudgetValues[i].Category; MonthDetailRow currentDetail = new MonthDetailRow(currentGroup, currentCategory, _selectedMonth, this.Session.CurrentYear); currentDetail.BudgetedAmount = this.Session.BudgetValues[i].Values[_selectedMonth]; currentDetail.SpentAmount = this.Session.SpendingValues[i].Values[_selectedMonth]; monthDetails.Add(currentDetail); } numRows = this.Session.BudgetTotals.Count; for (int i = 0; i < numRows; i++) { Group currentGroup = this.Session.BudgetTotals[i].Group; Category currentCategory = this.Session.BudgetTotals[i].Category; MonthDetailRow currentDetail = new MonthDetailRow(currentGroup, currentCategory, _selectedMonth, this.Session.CurrentYear); currentDetail.BudgetedAmount = this.Session.BudgetTotals[i].Values[_selectedMonth]; currentDetail.SpentAmount = this.Session.SpendingTotals[i].Values[_selectedMonth]; monthDetails.Add(currentDetail); } //numRows = _budgetBudgetAndSum.Count; //for (int i = 0; i < numRows; i++) //{ // Group currentGroup = this.BudgetTotals.ElementAt(i).Group; // Category currentCategory = this.BudgetTotals.ElementAt(i).Category; // MonthDetailRow currentDetail = new MonthDetailRow(currentGroup, currentCategory, _selectedMonth, Int32.Parse(_currentYear)); // currentDetail.BudgetedAmount = _budgetBudgetAndSum.ElementAt(i).Values[_selectedMonth]; // currentDetail.SpentAmount = _spendingBudgetAndSum.ElementAt(i).Values[_selectedMonth]; // monthDetails.Add(currentDetail); //} this.MonthDetails.InsertRange(monthDetails); }
public void UpdateListEmployees(List <Employee> employees) { _observeEmployees.Clear(); _observeEmployees.AddRange(employees); }
public async Task When_Full_Collection_Reset() { var SUT = new ComboBox(); SUT.ItemTemplate = new DataTemplate(() => { var tb = new TextBlock(); tb.SetBinding(TextBlock.TextProperty, new Windows.UI.Xaml.Data.Binding { Path = "Text" }); tb.SetBinding(TextBlock.NameProperty, new Windows.UI.Xaml.Data.Binding { Path = "Text" }); return(tb); }); try { WindowHelper.WindowContent = SUT; var c = new MyObservableCollection <ItemModel>(); c.Add(new ItemModel { Text = "One" }); c.Add(new ItemModel { Text = "Two" }); c.Add(new ItemModel { Text = "Three" }); SUT.ItemsSource = c; await WindowHelper.WaitForIdle(); SUT.IsDropDownOpen = true; await WindowHelper.WaitForIdle(); SUT.IsDropDownOpen = false; Assert.AreEqual(SUT.Items.Count, 3); using (c.BatchUpdate()) { c.Clear(); c.Add(new ItemModel { Text = "Five" }); c.Add(new ItemModel { Text = "Six" }); c.Add(new ItemModel { Text = "Seven" }); } SUT.IsDropDownOpen = true; // Items are materialized when the popup is opened await WindowHelper.WaitForIdle(); Assert.AreEqual(3, SUT.Items.Count); Assert.IsNotNull(SUT.ContainerFromItem(c[0])); Assert.IsNotNull(SUT.ContainerFromItem(c[1])); Assert.IsNotNull(SUT.ContainerFromItem(c[2])); Assert.IsNotNull(SUT.FindName("Seven")); Assert.IsNotNull(SUT.FindName("Five")); Assert.IsNotNull(SUT.FindName("Six")); } finally { SUT.IsDropDownOpen = false; } }