/// <summary>
        /// Initializes a new instance of the <see cref="GitObjectViewModelBase" /> class.
        /// </summary>
        /// <param name="actions">Additional actions provided by the derived class.</param>
        protected GitObjectViewModelBase(IReadOnlyList <IGitObjectAction> actions = null)
        {
            var validGitObject = this.WhenAnyValue(x => x.SelectedGitObject).Select(x => x != null);

            var gitObjectActions = new ObservableCollectionExtended <IGitObjectAction>();

            if (actions != null)
            {
                gitObjectActions.AddRange(actions);
            }

            var resetActions = new List <IGitObjectAction>()
            {
                new ObservableGitObjectAction("Hard - Delete Changes", ReactiveCommand.CreateFromObservable(() => ResetImpl(SelectedGitObject, ResetMode.Hard), validGitObject)),
                new ObservableGitObjectAction("Soft - Keep Changes", ReactiveCommand.CreateFromObservable(() => ResetImpl(SelectedGitObject, ResetMode.Soft), validGitObject)),
                new ObservableGitObjectAction("Mixed - Reset Index/Keep Working Directory", ReactiveCommand.CreateFromObservable(() => ResetImpl(SelectedGitObject, ResetMode.Mixed), validGitObject)),
            };

            gitObjectActions.Add(new InfoGitObjectAction("Reset", resetActions));

            gitObjectActions.Add(new ObservableGitObjectAction("Checkout", ReactiveCommand.CreateFromObservable(() => CheckoutImpl(SelectedGitObject, false), validGitObject)));
            gitObjectActions.Add(new ObservableGitObjectAction("Checkout (force)", ReactiveCommand.CreateFromObservable(() => CheckoutImpl(SelectedGitObject, true), validGitObject)));

            Actions = gitObjectActions;
        }
Exemple #2
0
        public void Add()
        {
            _collection.Add(1);

            _results.Messages.Count.Should().Be(1);
            _results.Data.Count.Should().Be(1);
            _results.Data.Items.First().Should().Be(1);
        }
Exemple #3
0
        public void Test1()
        {
            ObservableCollectionExtended <int> collection = new ObservableCollectionExtended <int>();

            collection.Add(1);
            collection.Add(2);
            collection.Add(3);

            test(collection);
        }
        private static void ConstructorAssertions(Verify verify, ObservableCollectionExtended <object> result, WeakNotifier weakNotifier, Notifier notifier)
        {
            var itemAssert = new ItemPropertyChangedEventTest(verify, result);

            var itemAddedEventQueue = new Queue <Tuple <object, ItemEventArgs <object> > >();

            result.ItemAdded += (s, e) => itemAddedEventQueue.Enqueue(Tuple.Create(s, e));

            var itemRemovedEventQueue = new Queue <Tuple <object, ItemEventArgs <object> > >();

            result.ItemRemoved += (s, e) => itemRemovedEventQueue.Enqueue(Tuple.Create(s, e));


            weakNotifier.Age += 1;
            itemAssert.ExpectEvent(weakNotifier, "Age");

            notifier.Age += 1;
            itemAssert.ExpectEvent(notifier, "Age");


            var oldCount = result.Count;

            result.Clear();
            verify.AreEqual(oldCount, itemRemovedEventQueue.Count, "incorrect number of items reported as being removed");

            weakNotifier.Age += 1;
            notifier.Age     += 1;

            verify.AreEqual(0, result.Count, "The collection should be empty");
            itemAssert.ExpectCountEquals(0, "ItemPropertyChanged events were fired when the collection was supposed to be empty.");

            result.Add(weakNotifier);
            result.Add(notifier);
            verify.AreEqual(2, result.Count, "The new items were not added");
            verify.AreEqual(2, itemAddedEventQueue.Count, "The new item events didn't fire");
            CollectionAssert.AreEqual(result, result.ReadOnlyWrapper);

            itemRemovedEventQueue.Clear();
            result.RemoveAt(0);
            verify.AreEqual(1, itemRemovedEventQueue.Count, "the item wasn't removed");
            verify.AreSame(notifier, result[0], "the wrong item was removed");
            CollectionAssert.AreEqual(result, result.ReadOnlyWrapper);

            itemAddedEventQueue.Clear();
            itemRemovedEventQueue.Clear();
            result[0] = weakNotifier;
            verify.AreSame(weakNotifier, result[0], "the item wasn't updated");
            verify.AreEqual(1, itemAddedEventQueue.Count, "the add event for replacing an item didn't fire");
            verify.AreEqual(1, itemRemovedEventQueue.Count, "the remove event for replacing an item didn't fire");
            CollectionAssert.AreEqual(result, result.ReadOnlyWrapper);
        }
Exemple #5
0
            public GameRestoreObject(Mod.MEGame game, IEnumerable <GameTarget> availableBackupSources, Window window)
            {
                this.window = window;
                this.Game   = game;
                this.AvailableBackupSources.AddRange(availableBackupSources);
                AvailableBackupSources.Add(new GameTarget(Game, "Restore to custom location", false, true));
                LoadCommands();
                switch (Game)
                {
                case Mod.MEGame.ME1:
                    GameTitle      = "Mass Effect";
                    GameIconSource = "/images/gameicons/ME1_48.ico";
                    break;

                case Mod.MEGame.ME2:
                    GameTitle      = "Mass Effect 2";
                    GameIconSource = "/images/gameicons/ME2_48.ico";
                    break;

                case Mod.MEGame.ME3:
                    GameTitle      = "Mass Effect 3";
                    GameIconSource = "/images/gameicons/ME3_48.ico";
                    break;
                }

                ResetRestoreStatus();
            }
        public void AutoPersistCollectionSmokeTest()
        {
            new TestScheduler().With(sched =>
            {
                var manualSave = new Subject <Unit>();

                var item    = new TestFixture();
                var fixture = new ObservableCollectionExtended <TestFixture> {
                    item
                };

                var timesSaved = 0;
                fixture.AutoPersistCollection(x =>
                {
                    timesSaved++;
                    return(Observables.Unit);
                },
                                              manualSave,
                                              TimeSpan.FromMilliseconds(100));

                sched.AdvanceByMs(2 * 100);
                Assert.Equal(0, timesSaved);

                // By being added to collection, AutoPersist is enabled for item
                item.IsNotNullString = "Foo";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(1, timesSaved);

                // Removed from collection = no save
                fixture.Clear();
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(1, timesSaved);

                // Item isn't in the collection, it doesn't get persisted anymore
                item.IsNotNullString = "Bar";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(1, timesSaved);

                // Added back item gets saved
                fixture.Add(item);
                sched.AdvanceByMs(100);  // Compensate for scheduling
                item.IsNotNullString = "Baz";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(2, timesSaved);

                // Even if we issue a reset
                fixture.SuspendNotifications().Dispose(); // Will cause a reset.

                sched.AdvanceByMs(100);                   // Compensate for scheduling
                item.IsNotNullString = "Bamf";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(3, timesSaved);

                // Remove by hand = no save
                fixture.RemoveAt(0);
                item.IsNotNullString = "Blomf";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(3, timesSaved);
            });
        }
            public GameRestoreObject(MEGame game, IEnumerable <GameTarget> availableBackupSources, MainWindow window)
            {
                this.window = window;
                this.Game   = game;
                this.AvailableBackupSources.AddRange(availableBackupSources);
                AvailableBackupSources.Add(new GameTarget(Game, M3L.GetString(M3L.string_restoreToCustomLocation), false, true));
                LoadCommands();
                switch (Game)
                {
                case MEGame.ME1:
                    GameTitle      = @"Mass Effect";
                    GameIconSource = @"/images/gameicons/ME1_48.ico";
                    break;

                case MEGame.ME2:
                    GameTitle      = @"Mass Effect 2";
                    GameIconSource = @"/images/gameicons/ME2_48.ico";
                    break;

                case MEGame.ME3:
                    GameTitle      = @"Mass Effect 3";
                    GameIconSource = @"/images/gameicons/ME3_48.ico";
                    break;
                }

                ResetRestoreStatus();
            }
Exemple #8
0
        private async Task UpdatePage(int page)
        {
            Debug.WriteLine($"Update page: {page}");

            var links = await _insecamSelector.GetSourceLinksAsync(page);

            if (Sources == null)
            {
                Sources = new ObservableCollectionExtended <PlayerViewModel>();

                foreach (var item in links)
                {
                    IStreamDecoder decoder = Locator.Current.GetService <IStreamDecoder>();

                    Sources.Add(new PlayerViewModel(decoder)
                    {
                        Location = item.Location,
                        Uri      = item.StreamUri
                    });
                }
            }
            else
            {
                for (int i = 0; i < links.Count; i++)
                {
                    Sources[i].Location = links[i].Location;
                    Sources[i].Uri      = links[i].StreamUri;
                }
            }
        }
Exemple #9
0
        public NewGameViewModel()
        {
            Players = new ObservableCollectionExtended <string>();

            var canStart = this.Players.ToObservableChangeSet().CountChanged().Select(_ => this.Players.Count >= 3);

            StartGame      = ReactiveCommand.Create(() => { }, canStart);
            RandomizeOrder = ReactiveCommand.Create(() => {
                using (Players.SuspendNotifications()) {
                    var r        = new Random();
                    var newOrder = Players.OrderBy(x => r.NextDouble()).ToList();
                    Players.Clear();
                    Players.AddRange(newOrder);
                }
            },
                                                    canStart);

            RemovePlayer = ReactiveCommand.Create <string>(player => this.Players.Remove(player));
            var canAddPlayer = this.WhenAnyValue(x => x.Players.Count, x => x.NewPlayerName,
                                                 (count, newPlayerName) => count < 7 && !string.IsNullOrWhiteSpace(newPlayerName) && !this.Players.Contains(newPlayerName));

            AddPlayer = ReactiveCommand.Create(() => {
                Players.Add(NewPlayerName.Trim());
                NewPlayerName = string.Empty;
            },
                                               canAddPlayer);
        }
Exemple #10
0
        public void ShouldUnselectSelectedProvider() => new TestScheduler().With(scheduler =>
        {
            var collection = new ObservableCollectionExtended <IProvider>();
            var changes    = collection.ToObservableChangeSet(x => x.Id);

            _providerStorage.Read().Returns(changes);
            _providerStorage
            .When(storage => storage.Refresh())
            .Do(args => collection.Add(Substitute.For <IProvider>()));

            var model = BuildMainViewModel(scheduler);
            scheduler.AdvanceBy(2);

            model.Providers.Should().BeEmpty();
            model.Refresh.Execute(null);
            scheduler.AdvanceBy(3);

            model.Providers.Should().NotBeEmpty();
            model.SelectedProvider.Should().NotBeNull();
            model.Unselect.CanExecute(null).Should().BeTrue();
            model.Unselect.Execute(null);

            scheduler.AdvanceBy(3);
            model.Providers.Should().NotBeEmpty();
            model.SelectedProvider.Should().BeNull();
        });
Exemple #11
0
        public void Test_ObservableCollectionExtended_AddNewObject_NoPropertyChangedEventRaised()
        {
            _persons.Add(new Person {
                FirstName = "John", LastName = "Smith"
            });

            Assert.AreEqual(0, _recievedEvents.Count);
        }
Exemple #12
0
        public void ExtendedObservableCollection_ConstructorTest1()
        {
            using (var verify = new Verify())
            {
                var result = new ObservableCollectionExtended <object>();
                result.Add(1);
                result.Add("Boat");

                var weakNotifier = new WeakNotifier();
                var notifier     = new Notifier();

                result.Add(weakNotifier);
                result.Add(notifier);

                ConstructorAssertions(verify, result, weakNotifier, notifier);
            }
        }
        public void ExtendedReadOnlyObservableCollection_MemoryTest()
        {
            using (var verify = new Verify())
            {
                Func <WeakReference> builder = () =>
                {
                    var source = new ObservableCollectionExtended <int>();
                    var target = new ReadOnlyObservableCollectionExtended <int>(source);

                    var sourceEvents = new Queue <NotifyCollectionChangedEventArgs>();
                    var targetEvents = new Queue <NotifyCollectionChangedEventArgs>();

                    var sourceEvents2 = new Queue <PropertyChangedEventArgs>();
                    var targetEvents2 = new Queue <PropertyChangedEventArgs>();

                    source.CollectionChanged += (s, e) => sourceEvents.Enqueue(e);
                    target.CollectionChanged += (s, e) => targetEvents.Enqueue(e);

                    source.PropertyChanged += (s, e) => sourceEvents2.Enqueue(e);
                    target.PropertyChanged += (s, e) => targetEvents2.Enqueue(e);

                    Memory.CycleGC();

                    source.Add(1);
                    source.Add(2);
                    source.Add(3);

                    verify.AreEqual(3, sourceEvents.Count, "NotifyCollectionChangedEventArgs in source was wrong");
                    verify.AreEqual(3, targetEvents.Count, "NotifyCollectionChangedEventArgs in target was wrong");
                    verify.AreEqual(6, sourceEvents2.Count, "PropertyChangedEventArgs in source was wrong.  There should be 2 per add.");
                    verify.AreEqual(6, targetEvents2.Count, "PropertyChangedEventArgs in target was wrong. There should be 2 per add.");

                    verify.ItemsAreEqual(source, target, "");

                    return(new WeakReference(target));
                };

                var wr = builder();


                Memory.CycleGC();

                verify.IsFalse(wr.IsAlive, "wr wasn't GC'd");
            }
        }
        private void SetupStartState()
        {
            string name = Nodes.Any(x => x.Name == "Start") ? GetNameForNewNode() : "Start";

            StartState = new ViewModelNode(this, name, new Point());
            SetAsStart(StartState);
            Nodes.Add(StartState);
            this.ItSaved = true;
        }
Exemple #15
0
        public void ExtendedObservableCollection_SerializationTest1()
        {
            using (var verify = new Verify())
            {
                var collection = new ObservableCollectionExtended <Foo>();
                collection.Add(new Foo());
                collection.Add(new Foo());
                collection.Add(new Foo());

                var stream        = new System.IO.MemoryStream();
                var fooSerializer = new DataContractSerializer(typeof(ObservableCollectionExtended <Foo>));
                fooSerializer.WriteObject(stream, collection);
                stream.Position = 0;
                var newFoo = (ObservableCollectionExtended <Foo>)fooSerializer.ReadObject(stream);

                verify.AreEqual(collection.Count, newFoo.Count, "collection count was off");
            }
        }
Exemple #16
0
        public void SelectingPathFromListChangesCurrentPath()
        {
            const string pathFromList = "M:/y/path";

            _settingsLoadedSolutions.Add(pathFromList);

            _sut.SelectedPath = pathFromList;

            _sut.Path.Should().Be(pathFromList);
        }
Exemple #17
0
        // Метод для добавления контакта
        public void AddContactMethod()
        {
            Contact c = new Contact {
                Name = "Новый контакт"
            };

            _contacts.Add(c);
            this.RaisePropertyChanged(() => this.Contacts);
            SelectedContact = c;
        }
 public GameRestoreObject(MEGame game, IEnumerable <GameTarget> availableBackupSources, MainWindow window)
 {
     this.window = window;
     this.Game   = game;
     this.AvailableBackupSources.AddRange(availableBackupSources);
     AvailableBackupSources.Add(new GameTarget(Game, M3L.GetString(M3L.string_restoreToCustomLocation), false, true));
     LoadCommands();
     GameTitle = Game.ToGameName();
     ResetRestoreStatus();
 }
        /// <summary>
        /// Opens a repository and creates all the view models.
        /// </summary>
        /// <param name="repositoryDirectoryPath">The path to the repository to open.</param>
        private void OpenRepository(string repositoryDirectoryPath)
        {
            if (string.IsNullOrWhiteSpace(repositoryDirectoryPath))
            {
                return;
            }

            IRepositoryDetails newModel = _repositoryFactory.CreateRepositoryDetails(repositoryDirectoryPath);

            _repositoryViewModels.Add(_viewModelFactory.CreateRepositoryViewModel(newModel));
            SelectedRepositoryViewModel = _repositoryViewModels.Last();
        }
        public MainViewModel()
        {
            _mailController             = DummyTrivialSingleton.GetMailControllerService();
            ThemeColorToggleBaseCommand = new AnotherCommandImplementation(o => SetAppColor((bool)o));

            SetAppColor(true);

            // ToDo: Move menu creation to better place or add it in xaml or generate base on some other data.
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Inbox   ", NumberOfEmails = 3, Content = new MailBoxView("Inbox"), IconContent = new PackIcon {
                    Kind = PackIconKind.Inbox
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Drafts", IconContent = new PackIcon {
                    Kind = PackIconKind.Draft
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Sent", IconContent = new PackIcon {
                    Kind = PackIconKind.Send
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Archived", IconContent = new PackIcon {
                    Kind = PackIconKind.Archive
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Important", IconContent = new PackIcon {
                    Kind = PackIconKind.ImportantDevices
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Spam   ", NumberOfEmails = 99, IconContent = new PackIcon {
                    Kind = PackIconKind.Adb
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Trash", IconContent = new PackIcon {
                    Kind = PackIconKind.Trash
                }
            });

            // Subscribe for controller state updates.
            _mailController.ControllerStateStream.ObserveOnDispatcher().Subscribe(state => ConnectionState = state);
        }
Exemple #21
0
        public MultiSelectValueDialog(MultiSelectValueEditor multiSelectValueEditor)
        {
            _multiSelectValueEditor = multiSelectValueEditor;

            var items = new ObservableCollectionExtended <MultiSelectValueEditor.Item>();

            foreach (var item in _multiSelectValueEditor.Items)
            {
                items.Add(new MultiSelectValueEditor.Item(item.Id, item.Name, item.IsSelected, item.OriginalItem));
            }

            this.Items = items;
        }
        public void ExtendedReadOnlyObservableCollection_OnItemPropertyChanged()
        {
            using (var verify = new Verify())
            {
                var list               = new ObservableCollectionExtended <Notifier>();
                var result             = new ReadOnlyObservableCollectionExtended <Notifier>(list);
                var itemPropertyAssert = new ItemPropertyChangedEventTest(verify, result);

                var notifier = new Notifier();
                list.Add(notifier);
                notifier.Name = "Frank";

                itemPropertyAssert.ExpectEvent(notifier, "Name");
            }
        }
        public DownloadTaskListViewModel()
        {
            result = new ObservableCollectionExtended <DownloadTaskItemViewModel>(Aria2Helper.Aria2.DownloadTasks
                                                                                  .Select(p => p.ConvertToViewModel()).ToList());
            result.ToObservableChangeSet().Bind(out _tasks).Subscribe();
            DispatcherTimer.Run(() =>
            {
                if (Aria2Helper.Aria2 == null)
                {
                    return(false);
                }

                lock (refreshLock)
                {
                    var tasks  = Aria2Helper.Aria2.DownloadTasks;
                    var allGid = tasks.Select(p => p.GID).Union(result.Select(p => p.GID)).ToList();

                    allGid.ForEach(gid =>
                    {
                        var oriTask = result.FirstOrDefault(p => p.GID == gid);
                        var ar2Task = tasks.Find(p => p.GID == gid);

                        if (oriTask == null)
                        {
                            result.Add(ar2Task.ConvertToViewModel());
                            return;
                        }

                        if (ar2Task == null)
                        {
                            result.Remove(oriTask);
                            return;
                        }

                        oriTask.TaskName      = ar2Task.TaskName;
                        oriTask.DownloadSpeed = ar2Task.DownloadSpeed;
                        oriTask.Status        = ar2Task.Status;
                        oriTask.TotalSize     = ar2Task.TotalLength;
                        oriTask.CompleteSize  = ar2Task.CompletedLength;
                    });

                    //ViewModelListMerge(_tasks, tasks);
                }

                return(true);
            }, new TimeSpan(0, 0, 0, 0, 500));
        }
Exemple #24
0
        public ObservableCollectionExtended <FriendsMusicViewModel> DownloadFriendsWithOpenAudio()
        {
            var friends = GetFriendsWithOpenAudio();
            ObservableCollectionExtended <FriendsMusicViewModel> friendsMusics =
                new ObservableCollectionExtended <FriendsMusicViewModel>();

            foreach (var friend in friends)
            {
                friendsMusics.Add(new FriendsMusicViewModel()
                {
                    UserName    = $"{friend.FirstName} {friend.LastName}",
                    CountAudio  = $"{ApiDatas.Api.Audio.GetCount(friend.Id)} аудиозаписей",
                    ImageSourse = friend.Photo200.ToString()
                });
            }

            return(friendsMusics);
        }
Exemple #25
0
        private void LoadSources()
        {
            int previousSourceCount = _sources.Count;

            ClearSources();

            // TODO: if a midi message comes in between clearing and reloading, it could theoretically be lost. In practice, there doesn't seem to be enough time for that to happen.

            Enumerable.Range(0, MidiIn.NumberOfDevices).Execute(i => _sources.Add(new MidiIn(i)));
            foreach (MidiIn source in _sources)
            {
                source.MessageReceived += HandleMidiMessageReceived;
                source.ErrorReceived   += HandleMidiError;
                source.Start();
            }

            //if (_sources.Count == 0 && previousSourceCount > 0)
            //    DelegateToListeners(listener => listener.HandleAllNotesOff(MidiChannel.Omni), MidiChannel.Omni);
        }
Exemple #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommitHistoryViewModel" /> class.
        /// </summary>
        /// <param name="repositoryDetails">The details of the repository.</param>
        /// <exception cref="ArgumentException">If the repository does not exist.</exception>
        public CommitHistoryViewModel(IRepositoryDetails repositoryDetails)
        {
            if (repositoryDetails == null)
            {
                throw new ArgumentNullException(nameof(repositoryDetails));
            }

            RepositoryDetails = repositoryDetails;
            IObservable <bool> isCurrentBranchObservable =
                this.WhenAnyValue(x => x.RepositoryDetails.SelectedBranch).Select(x => x != null);

            _refresh =
                ReactiveCommand.CreateFromObservable(
                    () => GetCommitsImpl(RepositoryDetails.SelectedBranch),
                    isCurrentBranchObservable);
            _refresh.Subscribe(x => _commitHistory.Add(new CommitHistoryItemViewModel(x)));

            isCurrentBranchObservable.Subscribe(x => Refresh.InvokeCommand());
        }
Exemple #27
0
        public void ExtendedObservableCollection_MemoryTest1()
        {
            using (var verify = new Verify())
            {
                Func <WeakReference> builder = () =>
                {
                    var result       = new ObservableCollectionExtended <object>();
                    var weakNotifier = new WeakNotifier();
                    result.Add(weakNotifier);

                    return(new WeakReference(result));
                };

                var wr = builder();

                Memory.CycleGC();

                verify.IsFalse(wr.IsAlive, "An item in the collection is preventing the collection from being collected");
            }
        }
Exemple #28
0
        public void ActivationShouldTriggerLoad() => new TestScheduler().With(scheduler =>
        {
            var collection = new ObservableCollectionExtended <IProvider>();
            var set        = collection.ToObservableChangeSet(x => x.Id);

            _providerStorage.Read().Returns(set);
            _providerStorage
            .When(storage => storage.Refresh())
            .Do(args => collection.Add(Substitute.For <IProvider>()));

            var model = BuildMainViewModel(scheduler);
            scheduler.AdvanceBy(2);

            model.Providers.Should().BeEmpty();
            model.Activator.Activate();
            scheduler.AdvanceBy(4);

            model.Providers.Should().NotBeEmpty();
            model.SelectedProvider.Should().NotBeNull();
        });
Exemple #29
0
        private ObservableCollectionExtended <VkNet.Model.User> GetFriendsWithOpenAudio()
        {
            ObservableCollectionExtended <VkNet.Model.User> friendsWithOpenAudio =
                new ObservableCollectionExtended <VkNet.Model.User>();
            var friends = ApiDatas.Api.Friends.Get(new FriendsGetParams
            {
                Fields = ProfileFields.All,
                Order  = VkNet.Enums.SafetyEnums.FriendsOrder.Hints
            });

            foreach (var friend in friends)
            {
                if (friend.CanSeeAudio)
                {
                    friendsWithOpenAudio.Add(friend);
                }
            }

            return(friendsWithOpenAudio);
        }
        private void InitLogUploaderUI()
        {
            AvailableLogs.ClearEx();
            var directory = new DirectoryInfo(App.LogDir);
            var logfiles  = directory.GetFiles(@"modmanagerlog*.txt").OrderByDescending(f => f.LastWriteTime).ToList();

            AvailableLogs.Add(new LogItem("Select an application log")
            {
                Selectable = false
            });
            AvailableLogs.AddRange(logfiles.Select(x => new LogItem(x.FullName)));
            SelectedLog = AvailableLogs.FirstOrDefault();
            var targets = mainwindow.InstallationTargets.Where(x => x.Selectable);

            DiagnosticTargets.Add(new GameTarget(Mod.MEGame.Unknown, "Select a game target to generate diagnostics for", false));
            DiagnosticTargets.AddRange(targets);
            SelectedDiagnosticTarget = DiagnosticTargets.FirstOrDefault();
            //if (LogSelector_ComboBox.Items.Count > 0)
            //{
            //    LogSelector_ComboBox.SelectedIndex = 0;
            //}
        }
        public void ExtendedReadOnlyObservableCollection_OnItemPropertyChanged()
        {
            using (var verify = new Verify())
            {
                var list = new ObservableCollectionExtended<Notifier>();
                var result = new ReadOnlyObservableCollectionExtended<Notifier>(list);
                var itemPropertyAssert = new ItemPropertyChangedEventTest(verify, result);

                var notifier = new Notifier();
                list.Add(notifier);
                notifier.Name = "Frank";

                itemPropertyAssert.ExpectEvent(notifier, "Name");
            }
        }
        public void ExtendedObservableCollection_ConstructorTest1()
        {
            using (var verify = new Verify())
            {
                var result = new ObservableCollectionExtended<object>();
                result.Add(1);
                result.Add("Boat");

                var weakNotifier = new WeakNotifier();
                var notifier = new Notifier();

                result.Add(weakNotifier);
                result.Add(notifier);

                ConstructorAssertions(verify, result, weakNotifier, notifier);
            }
        }
        public void ExtendedObservableCollection_MemoryTest1()
        {
            using (var verify = new Verify())
            {
                Func<WeakReference> builder = () =>
                {

                    var result = new ObservableCollectionExtended<object>();
                    var weakNotifier = new WeakNotifier();
                    result.Add(weakNotifier);

                    return new WeakReference(result);
                };

                var wr = builder();

                Memory.CycleGC();

                verify.IsFalse(wr.IsAlive, "An item in the collection is preventing the collection from being collected");
            }
        }
        public void ExtendedObservableCollection_SerializationTest1()
        {
            using (var verify = new Verify())
            {
                var collection = new ObservableCollectionExtended<Foo>();
                collection.Add(new Foo());
                collection.Add(new Foo());
                collection.Add(new Foo());

                var stream = new System.IO.MemoryStream();
                var fooSerializer = new DataContractSerializer(typeof(ObservableCollectionExtended<Foo>));
                fooSerializer.WriteObject(stream, collection);
                stream.Position = 0;
                var newFoo = (ObservableCollectionExtended<Foo>)fooSerializer.ReadObject(stream);

                verify.AreEqual(collection.Count, newFoo.Count, "collection count was off");

            }
        }
        private static void ConstructorAssertions(Verify verify, ObservableCollectionExtended<object> result, WeakNotifier weakNotifier, Notifier notifier)
        {
            var itemAssert = new ItemPropertyChangedEventTest(verify, result);

            var itemAddedEventQueue = new Queue<Tuple<object, ItemEventArgs<object>>>();
            result.ItemAdded += (s, e) => itemAddedEventQueue.Enqueue(Tuple.Create(s, e));

            var itemRemovedEventQueue = new Queue<Tuple<object, ItemEventArgs<object>>>();
            result.ItemRemoved += (s, e) => itemRemovedEventQueue.Enqueue(Tuple.Create(s, e));

            weakNotifier.Age += 1;
            itemAssert.ExpectEvent(weakNotifier, "Age");

            notifier.Age += 1;
            itemAssert.ExpectEvent(notifier, "Age");

            var oldCount = result.Count;
            result.Clear();
            verify.AreEqual(oldCount, itemRemovedEventQueue.Count, "incorrect number of items reported as being removed");

            weakNotifier.Age += 1;
            notifier.Age += 1;

            verify.AreEqual(0, result.Count, "The collection should be empty");
            itemAssert.ExpectCountEquals(0, "ItemPropertyChanged events were fired when the collection was supposed to be empty.");

            result.Add(weakNotifier);
            result.Add(notifier);
            verify.AreEqual(2, result.Count, "The new items were not added");
            verify.AreEqual(2, itemAddedEventQueue.Count, "The new item events didn't fire");
            CollectionAssert.AreEqual(result, result.ReadOnlyWrapper);

            itemRemovedEventQueue.Clear();
            result.RemoveAt(0);
            verify.AreEqual(1, itemRemovedEventQueue.Count, "the item wasn't removed");
            verify.AreSame(notifier, result[0], "the wrong item was removed");
            CollectionAssert.AreEqual(result, result.ReadOnlyWrapper);

            itemAddedEventQueue.Clear();
            itemRemovedEventQueue.Clear();
            result[0] = weakNotifier;
            verify.AreSame(weakNotifier, result[0], "the item wasn't updated");
            verify.AreEqual(1, itemAddedEventQueue.Count, "the add event for replacing an item didn't fire");
            verify.AreEqual(1, itemRemovedEventQueue.Count, "the remove event for replacing an item didn't fire");
            CollectionAssert.AreEqual(result, result.ReadOnlyWrapper);
        }
        public void ExtendedReadOnlyObservableCollection_MemoryTest()
        {
            using (var verify = new Verify())
            {

                Func<WeakReference> builder = () =>
                {

                    var source = new ObservableCollectionExtended<int>();
                    var target = new ReadOnlyObservableCollectionExtended<int>(source);

                    var sourceEvents = new Queue<NotifyCollectionChangedEventArgs>();
                    var targetEvents = new Queue<NotifyCollectionChangedEventArgs>();

                    var sourceEvents2 = new Queue<PropertyChangedEventArgs>();
                    var targetEvents2 = new Queue<PropertyChangedEventArgs>();

                    source.CollectionChanged += (s, e) => sourceEvents.Enqueue(e);
                    target.CollectionChanged += (s, e) => targetEvents.Enqueue(e);

                    source.PropertyChanged += (s, e) => sourceEvents2.Enqueue(e);
                    target.PropertyChanged += (s, e) => targetEvents2.Enqueue(e);

                    Memory.CycleGC();

                    source.Add(1);
                    source.Add(2);
                    source.Add(3);

                    verify.AreEqual(3, sourceEvents.Count, "NotifyCollectionChangedEventArgs in source was wrong");
                    verify.AreEqual(3, targetEvents.Count, "NotifyCollectionChangedEventArgs in target was wrong");
                    verify.AreEqual(6, sourceEvents2.Count, "PropertyChangedEventArgs in source was wrong.  There should be 2 per add.");
                    verify.AreEqual(6, targetEvents2.Count, "PropertyChangedEventArgs in target was wrong. There should be 2 per add.");

                    verify.ItemsAreEqual(source, target, "");

                    return new WeakReference(target);
                };

                var wr = builder();

                Memory.CycleGC();

                verify.IsFalse(wr.IsAlive, "wr wasn't GC'd");
            }
        }