public void AddNotification(NotifyFlashMessage flash) { if (flash == null) { return; } if (flash.Balloon != null && flash.Balloon.DisplayTime >= 500) { var existing = notificationBalloons.ToSyncArray().FirstOrDefault(x => x.TitleText == flash.Balloon.TitleText && x.Icon == flash.Balloon.Icon); if (existing == null) { if (!SnappedToBottom) { notificationBalloons.Add(flash.Balloon); } else { notificationBalloons.Insert(0, flash.Balloon); } } else { if (flash.Balloon.EventType == EventType.Whisper) { if (!SnappedToBottom) { notificationBalloons.Add(flash.Balloon); } else { notificationBalloons.Insert(0, flash.Balloon); } } else { existing.UpdateBody(flash.Balloon.BodyText); existing.Refresh(); } } Topmost = false; Topmost = true; if (!IsVisible) { ShowWindow(); } } if (!BasicTeraData.Instance.WindowData.MuteSound && flash.Sound != null) { Task.Run(() => flash.Sound.Play()); } }
public void It_inserts_the_item_when_index_is_equal_to_count() { var collection = new SynchronizedObservableCollection <string>(); Assert.DoesNotThrow(() => { collection.Insert(0, "0"); }); Assert.That(collection.Count, Is.EqualTo(1)); }
public void It_inserts_the_item_when_index_is_in_range() { var collection = new SynchronizedObservableCollection <string>(new List <string> { "1", "2", "3" }); Assert.DoesNotThrow(() => { collection.Insert(1, "0"); }); Assert.That(collection.Count, Is.EqualTo(4)); Assert.That(collection[0], Is.EqualTo("1")); Assert.That(collection[1], Is.EqualTo("0")); Assert.That(collection[2], Is.EqualTo("2")); Assert.That(collection[3], Is.EqualTo("3")); }
public void It_invokes_PropertyChanged_when_index_is_in_range() { var collection = new SynchronizedObservableCollection <string>(new List <string> { "1", "2", "3" }); var propertyChangedEventArgs = new List <PropertyChangedEventArgs>(); ((INotifyPropertyChanged)collection).PropertyChanged += (sender, args) => { propertyChangedEventArgs.Add(args); }; collection.Insert(3, "4"); Assert.That(propertyChangedEventArgs.Count, Is.EqualTo(2)); Assert.That(propertyChangedEventArgs.Any(p => p.PropertyName.Equals("Count")), Is.True); Assert.That(propertyChangedEventArgs.Any(p => p.PropertyName.Equals("Item[]")), Is.True); }
public void It_invokes_CollectionChanged_when_index_is_in_range() { var collection = new SynchronizedObservableCollection <string>(new List <string> { "1", "2", "3" }); NotifyCollectionChangedEventArgs collectionChangedEventArgs = null; collection.CollectionChanged += (sender, args) => { collectionChangedEventArgs = args; }; collection.Insert(3, "4"); Assert.That(collectionChangedEventArgs.Action, Is.EqualTo(NotifyCollectionChangedAction.Add)); Assert.That(collectionChangedEventArgs.NewItems[0], Is.EqualTo("4")); Assert.That(collectionChangedEventArgs.NewStartingIndex, Is.EqualTo(3)); }
public void enumeratorTestInternalEntry() { //test object SynchronizedObservableCollection<int> testCol = new SynchronizedObservableCollection<int>(); //the items to add var r = (Enumerable.Range(0, 100)); var z = (Enumerable.Range(100, 100)); //add a range of numbers (0-4) to increment on foreach (int i in r) { testCol.Add(i); } //the list that will contain the enumerated items. List<int> k = new List<int>(); Thread s = new Thread(new ThreadStart(() => { //for-each item in the test wait a bit so the adder //thread has a chance to add more items then add to the //counter of how many items the enumerator got. foreach (int i in testCol) { Thread.Sleep(10); k.Add(i); } })); s.Start(); //add more numbers during the execution of the other thread. adds //(5-14) at a random location. Random rnd = new Random(); foreach (int i in z) { testCol.Insert(rnd.Next(0, testCol.Count-1),i); } s.Join(); //assert that there are no duplicate items. (that the enumerator did //not back over something already enumerated) all items in testCol //are distinct in this test. Assert.AreEqual(k.Distinct().Count(), k.Count()); //assert that the enumerator is not adding any items. Assert.IsTrue(k.Count() <= testCol.Count); }
public void Add(WuRemoteCallContext item) { _callHistory.Insert(0, item); item.PropertyChanged += PropChangedHandler; }