Example #1
0
        partial void UpdateCore(RawFleet raw, DateTimeOffset timeStamp)
        {
            HomeportShip Exclusive(HomeportShip ship)
            {
                if (ship.Fleet != null)
                {
                    ship.Fleet.Remove(ship);
                }
                return(ship);
            }

            for (int i = 0; i < ships.Count || i < raw.ShipIds.Count; i++)
            {
                if (i >= raw.ShipIds.Count)
                {
                    ships.RemoveAt(i);
                    i--;
                }
                else if (i >= ships.Count)
                {
                    ships.Add(Exclusive(owner.AllShips[raw.ShipIds[i]]));
                }
                else if (raw.ShipIds[i] != ships[i].Id)
                {
                    ships[i] = Exclusive(owner.AllShips[raw.ShipIds[i]]);
                }
            }

            Expedition = owner.MasterData.Expeditions[raw.ExpeditionId];
            CascadeUpdate();
            if (ExpeditionTimer.SetCompletionTime(raw.ExpeditionCompletionTime, timeStamp))
            {
                owner.Notification.SetExpeditionCompletion(this, raw.ExpeditionCompletionTime);
            }
        }
Example #2
0
        public void ToggleViewed(Episode e)
        {
            e.HasBeenViewed = !e.HasBeenViewed;

            if (e.HasBeenViewed)
            {
                for (var i = 0; i < backlog.Count; i++)
                {
                    if (backlog[i].Episode != e)
                    {
                        continue;
                    }
                    backlog.RemoveAt(i);
                    break;
                }
            }
            else
            {
                var show   = shows.FirstOrDefault(w => w.Name == e.ShowName);
                var season = show.Seasons.FirstOrDefault(w => w.SeasonNumber == e.SeasonNumber);

                backlog.Add(new BacklogItem {
                    Show = show, Episode = e, Season = season
                });
            }
        }
        private void target_LogReceived(object sender, LogReceivedEventArgs e)
        {
            //if (e.Message.Level == NLog.LogLevel.Fatal && !ErrorEnabled) return;
            //if (e.Message.Level == NLog.LogLevel.Error && !ErrorEnabled) return;
            //if (e.Message.Level == NLog.LogLevel.Warn && !WarnEnabled) return;
            //if (e.Message.Level == NLog.LogLevel.Info && !InfoEnabled) return;
            //if (e.Message.Level == NLog.LogLevel.Debug && !DebugEnabled) return;
            //if (e.Message.Level == NLog.LogLevel.Trace && !DiagEnabled) return;

            if (logMessages.Count > 1000)
            {
                logMessages.RemoveAt(logMessages.Count - 1);
            }
            logMessages.Insert(0, e.Message);
        }
Example #4
0
 public void PrepareCollections()
 {
     Users           = _addTransactionModel.Users;
     TransactionType = _addTransactionModel.TransactionType;
     Users.RemoveAt(0);
     TransactionType.RemoveAt(0);
 }
Example #5
0
        /// <summary>
        ///     Handles the message.
        /// </summary>
        /// <param name="message">The message.</param>
        public void Handle(GameResultDeleted message)
        {
            var index = gameResults.FindIndex(x => x.Id == message.GameId);

            if (index >= 0)
            {
                gameResults.RemoveAt(index);

                if (SelectedGame != null &&
                    SelectedGame.Id == message.GameId)
                {
                    if (index > 0)
                    {
                        SelectedGame = GameResults[index - 1];
                    }
                    if (index == 0 &&
                        GameResults.Count > 0)
                    {
                        SelectedGame = GameResults[0];
                    }
                }

                RefreshStats();
            }
            //var hasGame = this.gameResults.Any(x => x.Id == message.GameId);
            //if (hasGame)
            //{
            //    RefreshData();
            //    RefreshStats();
            //}
        }
        public void RemoveEventRaised()
        {
            BindableCollection<SimpleBusinessObject> lBindableCollection = new BindableCollection<SimpleBusinessObject>();
            bool removingRaised = false;
            lBindableCollection.ItemRemovedEvent += delegate(object sender, ItemRemovedEventArgs ea)
                {
                    removingRaised = true;
                };

            Assert.IsFalse(removingRaised);

            lBindableCollection.Add(new SimpleBusinessObject());

            Assert.IsFalse(removingRaised);

            lBindableCollection.RemoveAt(0);

            Assert.IsTrue(removingRaised);

            SimpleBusinessObject sbo = new SimpleBusinessObject();
            lBindableCollection.Add(sbo);
            removingRaised = false;

            lBindableCollection.Remove(sbo);

            Assert.IsTrue(removingRaised);
        }
        public void RemoveItemUsesDispatcherToRaiseEvents()
        {
            var collection = new BindableCollection <Element>()
            {
                new Element()
            };

            bool propertyChangedRaised = false;

            ((INotifyPropertyChanged)collection).PropertyChanged += (o, e) => propertyChangedRaised = true;
            bool collectionChangingRaised = false;

            collection.CollectionChanging += (o, e) => collectionChangingRaised = true;
            bool collectionChangedRaised = false;

            collection.CollectionChanged += (o, e) => collectionChangedRaised = true;

            var dispatcher = new TestDispatcher();

            Execute.Dispatcher = dispatcher;

            collection.RemoveAt(0);

            Assert.False(propertyChangedRaised);
            Assert.False(collectionChangingRaised);
            Assert.False(collectionChangedRaised);
            Assert.NotNull(dispatcher.SendAction);

            dispatcher.SendAction();

            Assert.True(propertyChangedRaised);
            Assert.True(collectionChangingRaised);
            Assert.True(collectionChangedRaised);
        }
Example #8
0
        private static IUndoableAction PopFront(BindableCollection <IUndoableAction> stack)
        {
            var item = stack[0];

            stack.RemoveAt(0);
            return(item);
        }
Example #9
0
        private static IUndoableAction Pop(BindableCollection <IUndoableAction> stack)
        {
            var item = stack[stack.Count - 1];

            stack.RemoveAt(stack.Count - 1);
            return(item);
        }
Example #10
0
 private void TrimGroups()
 {
     for (var i = groups.Count - 1; i >= 0; i--)
     {
         var group = groups[i];
         if (group.IsEmpty)
         {
             DetachGroupEvents(group);
             groups.RemoveAt(i);
         }
         else
         {
             break;
         }
     }
 }
Example #11
0
 private void RemoveFromTimeLine(Show show)
 {
     for (var i = timeLine.Count - 1; i >= 0; i--)
     {
         if (timeLine[i].Show == show)
         {
             timeLine.RemoveAt(i);
         }
     }
 }
Example #12
0
 public static void RemoveAll <T>(this BindableCollection <T> collection,
                                  Func <T, bool> condition)
 {
     for (var i = collection.Count - 1; i >= 0; i--)
     {
         if (condition(collection[i]))
         {
             collection.RemoveAt(i);
         }
     }
 }
Example #13
0
        partial void UpdateCore(IRawFleet raw, DateTimeOffset timeStamp)
        {
            for (int i = 0; i < ships.Count || i < raw.ShipIds.Count; i++)
            {
                if (i >= raw.ShipIds.Count)
                {
                    ships.RemoveAt(i);
                    i--;
                }
                else if (i >= ships.Count)
                {
                    ships.Add(owner.AllShips[raw.ShipIds[i]]);
                }
                else if (raw.ShipIds[i] != ships[i].Id)
                {
                    ships[i] = owner.AllShips[raw.ShipIds[i]];
                }
            }

            Expedition = owner.MasterData.Expeditions[raw.ExpeditionId];
            UpdateStatus();
            UpdateTimer(timeStamp);
        }
Example #14
0
 public void Handle(MsgItem message)
 {
     try
     {
         if (Items.Count > 20)
         {
             Items.RemoveAt(0);
         }
         Items.Add(message);
     }
     catch (Exception ex)
     {
         //    throw;
     }
 }
Example #15
0
 public SubscriptionViewModel(ISubscriptionScheduler scheduler)
 {
     _scheduler              = scheduler;
     _scheduler.NewChapters += (o, e) => {
         //BindableCollection dispatches operations on the collection to the UI thread
         foreach (var u in e.Chapters)
         {
             if (Updates.Count > 19)
             {
                 Updates.RemoveAt(0);
             }
             Updates.Add(new UpdateInfo {
                 Added   = DateTime.UtcNow,
                 Chapter = u,
                 Series  = e.MangaName
             });
         }
     };
 }
Example #16
0
 public static void Replace <T>(this BindableCollection <T> lst, Func <T, bool> expr, T newItem)
 {
     for (var i = lst.Count - 1; i >= 0; i--)
     {
         if (expr(lst[i]))
         {
             lst.RemoveAt(i);
             if (i <= lst.Count)
             {
                 lst.Insert(i, newItem);
             }
             else
             {
                 lst.Add(newItem);
             }
             // lst[i] = newItem;
             break;
         }
     }
 }
        public void RemoveItemUsesDispatcherToRemoveItems()
        {
            var collection = new BindableCollection <Element>()
            {
                new Element()
            };

            var dispatcher = new TestDispatcher();

            Execute.Dispatcher = dispatcher;

            collection.RemoveAt(0);

            Assert.AreEqual(1, collection.Count);
            Assert.NotNull(dispatcher.SendAction);

            dispatcher.SendAction();

            Assert.AreEqual(0, collection.Count);
        }
        public void RemoveItemUsesDispatcherToRemoveItems()
        {
            var collection = new BindableCollection<Element>() { new Element() };

            var dispatcher = new TestDispatcher();
            Execute.Dispatcher = dispatcher;

            collection.RemoveAt(0);

            Assert.AreEqual(1, collection.Count);
            Assert.NotNull(dispatcher.SendAction);

            dispatcher.SendAction();

            Assert.AreEqual(0, collection.Count);
        }
Example #19
0
 private static IUndoableAction Pop(BindableCollection<IUndoableAction> stack)
 {
     var item = stack[stack.Count - 1];
     stack.RemoveAt(stack.Count - 1);
     return item;
 }
        public void RemoveItemUsesDispatcherToRaiseEvents()
        {
            var collection = new BindableCollection<Element>() { new Element() };

            bool propertyChangedRaised = false;
            ((INotifyPropertyChanged)collection).PropertyChanged += (o, e) => propertyChangedRaised = true;
            bool collectionChangingRaised = false;
            collection.CollectionChanging += (o, e) => collectionChangingRaised = true;
            bool collectionChangedRaised = false;
            collection.CollectionChanged += (o, e) => collectionChangedRaised = true;

            var dispatcher = new TestDispatcher();
            Execute.Dispatcher = dispatcher;

            collection.RemoveAt(0);

            Assert.False(propertyChangedRaised);
            Assert.False(collectionChangingRaised);
            Assert.False(collectionChangedRaised);
            Assert.NotNull(dispatcher.SendAction);

            dispatcher.SendAction();

            Assert.True(propertyChangedRaised);
            Assert.True(collectionChangingRaised);
            Assert.True(collectionChangedRaised);
        }
Example #21
0
 private static IUndoableAction PopFront(BindableCollection<IUndoableAction> stack)
 {
     var item = stack[0];
     stack.RemoveAt(0);
     return item;
 }