Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        public void ThrowsArgumentOutOfRangeException_WhenListIsEmpty()
        {
            var list  = new RecentCollection <int>(10);
            int first = list[0];

            Console.WriteLine(first);
        }
Esempio n. 3
0
        public void CanRemoveFromEmptyList()
        {
            var  list    = new RecentCollection <int>(10);
            bool removed = list.Remove(int.MaxValue);

            Assert.IsFalse(removed);
            Assert.AreEqual(0, list.Count);
        }
Esempio n. 4
0
        public void AddRecent(Collection collection)
        {
            var recentModSet = new RecentCollection(collection);

            RecentCollections.AddLocked(recentModSet);
            recentModSet.Collection = collection;
            collection.RefreshLastJoinedOn();
            SaveSettings();
        }
Esempio n. 5
0
 public RecentJumpTask(RecentCollection collection)
 {
     Id               = collection.Id;
     Title            = collection.Name;
     Description      = "Launch: " + collection.Name;
     CustomCategory   = "Recent";
     ApplicationPath  = collection.GetLaunchUrl();
     IconResourcePath = Common.Paths.EntryLocation.ToString();
 }
Esempio n. 6
0
        public void SyncRootsAreDifferent()
        {
            var list1 = new RecentCollection <int>(10);
            var list2 = new RecentCollection <int>(10);

            Assert.IsFalse(ReferenceEquals(
                               ((ICollection)list1).SyncRoot,
                               ((ICollection)list2).SyncRoot
                               ));
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 9
0
        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);
            }
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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]);
        }
Esempio n. 15
0
        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]);
        }
Esempio n. 16
0
        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));
            }
        }
Esempio n. 17
0
 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);
 }
Esempio n. 18
0
        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]);
        }
Esempio n. 19
0
        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));
            }
        }
Esempio n. 20
0
        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]);
        }
Esempio n. 21
0
        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]);
        }
Esempio n. 22
0
        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]);
        }
Esempio n. 23
0
        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]);
            }
        }
Esempio n. 24
0
        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]);
            }
        }
Esempio n. 25
0
        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);
            }
        }
Esempio n. 26
0
 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));
                    }
                });
            }
        }
Esempio n. 28
0
        public MainForm()
        {
            InitializeComponent();

            recentFiles = new RecentCollection<string>(10);
        }
Esempio n. 29
0
        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));
            }
        }
Esempio n. 30
0
        public void CountIsZero_ForNewList()
        {
            var list = new RecentCollection <string>(10);

            Assert.AreEqual(0, list.Count);
        }
Esempio n. 31
0
 public void AddThrowsOnNullValue()
 {
     var list = new RecentCollection<string>(3);
     list.Add(null);
 }
Esempio n. 32
0
        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();
        }
Esempio n. 33
0
 public void SyncRootsAreDifferent()
 {
     var list1 = new RecentCollection<int>(10);
     var list2 = new RecentCollection<int>(10);
     Assert.IsFalse(ReferenceEquals(
         ((ICollection)list1).SyncRoot,
         ((ICollection)list2).SyncRoot
     ));
 }
Esempio n. 34
0
        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]);
            //}
        }
Esempio n. 35
0
 public void CountIsZero_ForNewList()
 {
     var list = new RecentCollection<string>(10);
     Assert.AreEqual(0, list.Count);
 }
Esempio n. 36
0
 Collection FindModSet(RecentCollection x) => _game.Lists.Collections.FirstOrDefault(x.Matches) ??
 _game.Lists.CustomCollections.FirstOrDefault(x.Matches);
Esempio n. 37
0
        public void CanRemoveFromEmptyList()
        {
            var list = new RecentCollection<int>(10);
            bool removed = list.Remove(int.MaxValue);

            Assert.IsFalse(removed);
            Assert.AreEqual(0, list.Count);
        }
Esempio n. 38
0
 public RecentMenuItem(RecentCollection collection)
 {
     Id     = collection.Id;
     Name   = collection.Name;
     Action = () => Process.Start(collection.GetLaunchUrl());
 }
Esempio n. 39
0
 void InsertRecentItem(RecentCollection collection)
 {
     Items.Insert(0, new RecentMenuItem(collection));
 }
Esempio n. 40
0
        /// <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);
            }
        }
Esempio n. 41
0
        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));
            }
        }
Esempio n. 42
0
        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);
        }
Esempio n. 43
0
 public void CountIsZero_AfterClear()
 {
     var list = new RecentCollection<int>(10) { 1, 2, 3, 4 };
     list.Clear();
     Assert.AreEqual(0, list.Count);
 }
Esempio n. 44
0
        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);
        }
Esempio n. 45
0
 public void IsReadOnly_IsFalse()
 {
     var list = new RecentCollection<int>(10);
     Assert.IsFalse(list.IsReadOnly);
 }
Esempio n. 46
0
        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);
            }
        }
Esempio n. 47
0
 public void SyncRootIsNotNull()
 {
     var list = new RecentCollection<int>(10);
     Assert.IsNotNull(((ICollection)list).SyncRoot);
 }
Esempio n. 48
0
        public void CapacityIsNonZero_ForNewList()
        {
            var list = new RecentCollection <string>(10);

            Assert.AreEqual(10, list.Capacity);
        }
Esempio n. 49
0
 public void ThrowsArgumentOutOfRangeException_WhenListIsEmpty()
 {
     var list = new RecentCollection<int>(10);
     int first = list[0];
     Console.WriteLine(first);
 }
Esempio n. 50
0
 public void CapacityIsNonZero_ForNewList()
 {
     var list = new RecentCollection<string>(10);
     Assert.AreEqual(10, list.Capacity);
 }
Esempio n. 51
0
        public void IsReadOnly_IsFalse()
        {
            var list = new RecentCollection <int>(10);

            Assert.IsFalse(list.IsReadOnly);
        }
Esempio n. 52
0
 public void ConstructorThrowsArgumentOutOfRangeException_WhenZeroIsPassed()
 {
     var list = new RecentCollection<string>(0);
     Assert.IsNotNull(list);
 }
Esempio n. 53
0
        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]);
            }
        }
Esempio n. 54
0
 void RemoveRecentItem(RecentCollection collection)
 {
     Items.RemoveAll <IMenuItem, RecentMenuItem>(x => x.Id == collection.Id);
 }