static void Main() { ShowHelp(); RecentCollection<int> list = new RecentCollection<int>(5); bool shownFullMessage = false; for (;;) { Console.WriteLine("Введите число. Для выхода введите пустую строку."); Console.Write("> "); string line = Console.ReadLine(); if (string.IsNullOrWhiteSpace(line)) break; int num; if (!int.TryParse(line, out num)) continue; list.Add(num); if (list.IsFull && !shownFullMessage) { ShowFullMessage(); shownFullMessage = true; } int[] numbers = list.ToArray(); Console.WriteLine("{{ {0} }}", string.Join(", ", numbers)); Console.WriteLine(); } }
public void ThrowsArgumentOutOfRangeException_WhenListIsEmpty() { var list = new RecentCollection <int>(10); int first = list[0]; Console.WriteLine(first); }
public void CanRemoveFromEmptyList() { var list = new RecentCollection <int>(10); bool removed = list.Remove(int.MaxValue); Assert.IsFalse(removed); Assert.AreEqual(0, list.Count); }
public void AddRecent(Collection collection) { var recentModSet = new RecentCollection(collection); RecentCollections.AddLocked(recentModSet); recentModSet.Collection = collection; collection.RefreshLastJoinedOn(); SaveSettings(); }
public RecentJumpTask(RecentCollection collection) { Id = collection.Id; Title = collection.Name; Description = "Launch: " + collection.Name; CustomCategory = "Recent"; ApplicationPath = collection.GetLaunchUrl(); IconResourcePath = Common.Paths.EntryLocation.ToString(); }
public void SyncRootsAreDifferent() { var list1 = new RecentCollection <int>(10); var list2 = new RecentCollection <int>(10); Assert.IsFalse(ReferenceEquals( ((ICollection)list1).SyncRoot, ((ICollection)list2).SyncRoot )); }
public void CountIsZero_AfterClear() { var list = new RecentCollection <int>(10) { 1, 2, 3, 4 }; list.Clear(); Assert.AreEqual(0, list.Count); }
void AddRecentItem(RecentCollection collection) { RemoveRecentItem(collection); InsertRecentItem(collection); if (Items.Count > 10) { Items.RemoveAt(10); } }
public void MoveNextThrowsInvalidOperationException_AfterListIsChanged() { var list = new RecentCollection <string>(10) { "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle" }; var enumerator = list.GetEnumerator(); list.Add("Merovingian"); enumerator.MoveNext(); }
/// <summary> /// Fills recent item list with given xml /// </summary> public void Fill(string recentItemsXml, int maxSize) { this.recentItems = RecentCollection.CreateFromXml(recentItemsXml); this.recentItems.MaxSize = maxSize; this.recentItems.ItemPushed += this.RecentItems_ItemPushed; this.recentItems.ItemRemoved += this.RecentItems_ItemRemoved; foreach (RecentItem item in this.recentItems) { this.RecentItemAdd(item); } }
void AddRecentItem(RecentCollection collection) { _jumpList.JumpItems.RemoveAll <JumpItem, RecentJumpTask>(x => x.Id == collection.Id); _jumpList.JumpItems.Insert(0, new RecentJumpTask(collection)); if (_jumpList.JumpItems.Count > 10) { _jumpList.JumpItems.RemoveAt(10); } UiHelper.TryOnUiThread(_jumpList.Apply); }
public void CanRemoveNonExistingStringElement() { var list = new RecentCollection <string>(10) { "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle" }; int oldCount = list.Count; bool removed = list.Remove("There is no spoon"); Assert.IsFalse(removed); Assert.AreEqual(oldCount, list.Count); }
public void CanRemoveNonExistingInt32Element() { var list = new RecentCollection <int>(10) { 1, 2, 3, 4, 5 }; int oldCount = list.Count; bool removed = list.Remove(1024); Assert.IsFalse(removed); Assert.AreEqual(oldCount, list.Count); }
public void AddMovesElementToBeginning() { var list = new RecentCollection<int>(5); list.Add(1); list.Add(2); // Добавляем уже существующий элемент. // "1" и "2" должны поменяться местами list.Add(1); Assert.AreEqual(2, list.Count); Assert.AreEqual(1, list[0]); Assert.AreEqual(2, list[1]); }
public void AddMovesElementToBeginning() { var list = new RecentCollection <int>(5); list.Add(1); list.Add(2); // Добавляем уже существующий элемент. // "1" и "2" должны поменяться местами list.Add(1); Assert.AreEqual(2, list.Count); Assert.AreEqual(1, list[0]); Assert.AreEqual(2, list[1]); }
public void ContainsReturnsTrueForInt32Elements() { int[] values = new[] { int.MinValue, -100, 0, 100, int.MaxValue }; var list = new RecentCollection <int>(10); foreach (int s in values) { list.Add(s); } foreach (int s in values) { Assert.IsTrue(list.Contains(s)); } }
private void AddToRecentCollection(Mediafile mediaFile) { LibraryService = new LibraryService(new DatabaseService()); RecentCollection = LibraryService.GetRecentCollection(); if (RecentlyPlayedCollection.Any(t => t.Path == mediaFile.Path)) { RecentlyPlayedCollection.Remove(RecentlyPlayedCollection.First(t => t.Path == mediaFile.Path)); } if (RecentCollection.Exists(t => t.Path == mediaFile.Path)) { RecentCollection.Delete(t => t.Path == mediaFile.Path); } RecentlyPlayedCollection.Add(mediaFile); RecentCollection.Insert(mediaFile); }
public void AddDeletesLastElement() { var list = new RecentCollection<int>(3); list.Add(1); list.Add(2); list.Add(3); // Закончилось место в списке. // Элемент "1" должен быть удален. list.Add(4); Assert.AreEqual(3, list.Count); Assert.AreEqual(4, list[0]); Assert.AreEqual(3, list[1]); Assert.AreEqual(2, list[2]); }
public void ContainsReturnsTrueForStringElements() { string[] values = new[] { "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle" }; var list = new RecentCollection <string>(10); foreach (string s in values) { list.Add(s); } foreach (string s in values) { Assert.IsTrue(list.Contains(s)); } }
public void AddDoesNotMoveFirstElement() { var list = new RecentCollection<int>(3); list.Add(1); list.Add(2); list.Add(3); // Повторно добавляем элемент "3" который уже в начале списка. // Порядок элементов не должен измениться list.Add(3); Assert.AreEqual(3, list.Count); Assert.AreEqual(3, list[0]); Assert.AreEqual(2, list[1]); Assert.AreEqual(1, list[2]); }
public void AddDeletesLastElement() { var list = new RecentCollection <int>(3); list.Add(1); list.Add(2); list.Add(3); // Закончилось место в списке. // Элемент "1" должен быть удален. list.Add(4); Assert.AreEqual(3, list.Count); Assert.AreEqual(4, list[0]); Assert.AreEqual(3, list[1]); Assert.AreEqual(2, list[2]); }
public void AddDoesNotMoveFirstElement() { var list = new RecentCollection <int>(3); list.Add(1); list.Add(2); list.Add(3); // Повторно добавляем элемент "3" который уже в начале списка. // Порядок элементов не должен измениться list.Add(3); Assert.AreEqual(3, list.Count); Assert.AreEqual(3, list[0]); Assert.AreEqual(2, list[1]); Assert.AreEqual(1, list[2]); }
public void CanRemoveMiddleInt32Element() { var list = new RecentCollection <int>(5) { 1, 2, 3, 4, 5 }; int oldCount = list.Count; bool removed = list.Remove(3); Assert.IsTrue(removed); Assert.AreEqual(oldCount - 1, list.Count); // TODO: Use SequenceEqual int[] temp = new[] { 1, 2, 4, 5 }.Reverse().ToArray(); for (int i = 0; i < temp.Length; i++) { Assert.AreEqual(temp[i], list[i]); } }
public void CanRemoveLastStringElement() { var list = new RecentCollection <string>(10) { "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle" }; int oldCount = list.Count; bool removed = list.Remove("Neo"); Assert.IsTrue(removed); Assert.AreEqual(oldCount - 1, list.Count); // TODO: Use SequenceEqual string[] temp = new[] { "Morpheus", "Trinity", "Agent Smith", "Oracle" }.Reverse().ToArray(); for (int i = 0; i < temp.Length; i++) { Assert.AreEqual(temp[i], list[i]); } }
public void CanSerializeAndDeserialize() { var list = new RecentCollection <int>(10); list.Add(3); list.Add(2); list.Add(1); var memStream = new MemoryStream(); var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memStream, list); memStream.Position = 0; var listCopy = (RecentCollection <int>)binaryFormatter.Deserialize(memStream); memStream.Dispose(); Assert.IsNotNull(listCopy); Assert.AreEqual(list.Count, listCopy.Count); Assert.AreEqual(list.Capacity, listCopy.Capacity); var iter1 = list.GetEnumerator(); var iter2 = listCopy.GetEnumerator(); for (;;) { bool hasNext1 = iter1.MoveNext(); bool hasNext2 = iter2.MoveNext(); Assert.AreEqual(hasNext1, hasNext2); if (!hasNext1 && !hasNext2) { break; } Assert.AreEqual(iter1.Current, iter2.Current); } }
public override void Reset() { WordWrap = true; FirstBoot = true; SingleInstance = true; AddTabOnStart = true; RecentFilesEnabled = true; AddTitleToPrint = true; ShowLargeFileWarning = true; ShowSelectionMargin = true; ReadingViewTopMost = true; ReadingWidth = 800; ReadingHorizPadding = 30; OpenFilterIndex = 7; ReadingVertPadding = 30; SettingsTabIndex = 0; BootCount = 5; RecentFiles = new RecentCollection <string>(6); PrintTitleAlign = 1; MaxTabTextWidth = 150; Culture = "en-us"; Signature = String.Empty; FontColor = Color.FromKnownColor(KnownColor.ControlText); ReadingBackColor = Color.PapayaWhip; ReadingWindowColor = ReadingBackColor = Color.Tan; ReadingForeColor = Color.FromArgb(40, 40, 40); BackColor = Color.FromKnownColor(KnownColor.ControlLightLight); LineNumForeColor = Color.FromArgb(136, 136, 136); Font = new Font("Tahoma", 12f); ReadingFont = new Font("Verdana", 14.25f); ReadingViewBounds = Rectangle.Empty; MainFormBounds = new Rectangle(0, 0, 600, 600); MainFormState = FormWindowState.Normal; LastSession = new LastSession(); SetDefaultRefactexes(); }
/// <summary> /// Plays the selected file. <seealso cref="PlayCommand"/> /// </summary> /// <param name="path"><see cref="BreadPlayer.Models.Mediafile"/> to play.</param> public async void Play(object path) { if (path is Mediafile) { LibraryService = new LibraryService(new DatabaseService()); RecentCollection = LibraryService.GetRecentCollection(); Mediafile mp3File = path as Mediafile; if (RecentlyPlayedCollection.Any(t => t.Path == mp3File.Path)) { RecentlyPlayedCollection.Remove(RecentlyPlayedCollection.First(t => t.Path == mp3File.Path)); } if (RecentCollection.Exists(t => t.Path == mp3File.Path)) { RecentCollection.Delete(t => t.Path == mp3File.Path); } RecentlyPlayedCollection.Add(mp3File); RecentCollection.Insert(mp3File); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { Messenger.Instance.NotifyColleagues(MessageTypes.MSG_PLAY_SONG, new List <object>() { mp3File, true }); (PlayCommand as RelayCommand).IsEnabled = false; await Task.Delay(100); (PlayCommand as RelayCommand).IsEnabled = true; if (TracksCollection.Elements.FirstOrDefault(t => t.Path == Player?.CurrentlyPlayingFile?.Path) != null) { TracksCollection.Elements.FirstOrDefault(t => t.Path == Player?.CurrentlyPlayingFile?.Path).State = PlayerState.Playing; LibraryService.UpdateMediafile(TracksCollection.Elements.FirstOrDefault(t => t.Path == Player?.CurrentlyPlayingFile?.Path)); } }); } }
public MainForm() { InitializeComponent(); recentFiles = new RecentCollection<string>(10); }
public void ContainsReturnsTrueForInt32Elements() { int[] values = new[] { int.MinValue, -100, 0, 100, int.MaxValue }; var list = new RecentCollection<int>(10); foreach (int s in values) { list.Add(s); } foreach (int s in values) { Assert.IsTrue(list.Contains(s)); } }
public void CountIsZero_ForNewList() { var list = new RecentCollection <string>(10); Assert.AreEqual(0, list.Count); }
public void AddThrowsOnNullValue() { var list = new RecentCollection<string>(3); list.Add(null); }
public void MoveNextThrowsInvalidOperationException_AfterListIsChanged() { var list = new RecentCollection<string>(10) { "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle" }; var enumerator = list.GetEnumerator(); list.Add("Merovingian"); enumerator.MoveNext(); }
public void SyncRootsAreDifferent() { var list1 = new RecentCollection<int>(10); var list2 = new RecentCollection<int>(10); Assert.IsFalse(ReferenceEquals( ((ICollection)list1).SyncRoot, ((ICollection)list2).SyncRoot )); }
public void CanRemoveMiddleStringElement() { var list = new RecentCollection<string>(10) { "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle" }; int oldCount = list.Count; bool removed = list.Remove("Trinity"); Assert.IsTrue(removed); Assert.AreEqual(oldCount - 1, list.Count); // TODO: Use SequenceEqual string[] temp = new[] { "Neo", "Morpheus", "Agent Smith", "Oracle" }.Reverse().ToArray(); Assert.IsTrue(temp.SequenceEqual(list)); //for (int i = 0; i < temp.Length; i++) //{ // Assert.AreEqual(temp[i], list[i]); //} }
public void CountIsZero_ForNewList() { var list = new RecentCollection<string>(10); Assert.AreEqual(0, list.Count); }
Collection FindModSet(RecentCollection x) => _game.Lists.Collections.FirstOrDefault(x.Matches) ?? _game.Lists.CustomCollections.FirstOrDefault(x.Matches);
public void CanRemoveFromEmptyList() { var list = new RecentCollection<int>(10); bool removed = list.Remove(int.MaxValue); Assert.IsFalse(removed); Assert.AreEqual(0, list.Count); }
public RecentMenuItem(RecentCollection collection) { Id = collection.Id; Name = collection.Name; Action = () => Process.Start(collection.GetLaunchUrl()); }
void InsertRecentItem(RecentCollection collection) { Items.Insert(0, new RecentMenuItem(collection)); }
public void ContainsReturnsTrueForStringElements() { string[] values = new[] {"Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle"}; var list = new RecentCollection<string>(10); foreach (string s in values) { list.Add(s); } foreach (string s in values) { Assert.IsTrue(list.Contains(s)); } }
public void CanRemoveNonExistingInt32Element() { var list = new RecentCollection<int>(10) { 1, 2, 3, 4, 5 }; int oldCount = list.Count; bool removed = list.Remove(1024); Assert.IsFalse(removed); Assert.AreEqual(oldCount, list.Count); }
public void CountIsZero_AfterClear() { var list = new RecentCollection<int>(10) { 1, 2, 3, 4 }; list.Clear(); Assert.AreEqual(0, list.Count); }
public void CanRemoveNonExistingStringElement() { var list = new RecentCollection<string>(10) { "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle" }; int oldCount = list.Count; bool removed = list.Remove("There is no spoon"); Assert.IsFalse(removed); Assert.AreEqual(oldCount, list.Count); }
public void IsReadOnly_IsFalse() { var list = new RecentCollection<int>(10); Assert.IsFalse(list.IsReadOnly); }
public void CanSerializeAndDeserialize() { var list = new RecentCollection<int>(10); list.Add(3); list.Add(2); list.Add(1); var memStream = new MemoryStream(); var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memStream, list); memStream.Position = 0; var listCopy = (RecentCollection<int>)binaryFormatter.Deserialize(memStream); memStream.Dispose(); Assert.IsNotNull(listCopy); Assert.AreEqual(list.Count, listCopy.Count); Assert.AreEqual(list.Capacity, listCopy.Capacity); var iter1 = list.GetEnumerator(); var iter2 = listCopy.GetEnumerator(); for (;;) { bool hasNext1 = iter1.MoveNext(); bool hasNext2 = iter2.MoveNext(); Assert.AreEqual(hasNext1, hasNext2); if (!hasNext1 && !hasNext2) break; Assert.AreEqual(iter1.Current, iter2.Current); } }
public void SyncRootIsNotNull() { var list = new RecentCollection<int>(10); Assert.IsNotNull(((ICollection)list).SyncRoot); }
public void CapacityIsNonZero_ForNewList() { var list = new RecentCollection <string>(10); Assert.AreEqual(10, list.Capacity); }
public void ThrowsArgumentOutOfRangeException_WhenListIsEmpty() { var list = new RecentCollection<int>(10); int first = list[0]; Console.WriteLine(first); }
public void CapacityIsNonZero_ForNewList() { var list = new RecentCollection<string>(10); Assert.AreEqual(10, list.Capacity); }
public void IsReadOnly_IsFalse() { var list = new RecentCollection <int>(10); Assert.IsFalse(list.IsReadOnly); }
public void ConstructorThrowsArgumentOutOfRangeException_WhenZeroIsPassed() { var list = new RecentCollection<string>(0); Assert.IsNotNull(list); }
public void CanRemoveFirstInt32Element() { var list = new RecentCollection<int>(5) {1, 2, 3, 4, 5}; int oldCount = list.Count; bool removed = list.Remove(5); Assert.IsTrue(removed); Assert.AreEqual(oldCount - 1, list.Count); // TODO: Use SequenceEqual int[] temp = new[] { 1, 2, 3, 4 }.Reverse().ToArray(); for (int i = 0; i < temp.Length; i++) { Assert.AreEqual(temp[i], list[i]); } }
void RemoveRecentItem(RecentCollection collection) { Items.RemoveAll <IMenuItem, RecentMenuItem>(x => x.Id == collection.Id); }