Exemple #1
0
        /// <summary>
        /// If items is null, selected items will be gathered and used.
        /// </summary>
        void MakeItems(IEnumerable <FinancialNewsEvent> items, bool markRead, bool markDeleted, bool markFavourite, bool markNotFavourite)
        {
            if (items == null)
            {
                items = new List <FinancialNewsEvent>();
                foreach (int index in this.listView.SelectedIndices)
                {
                    ((List <FinancialNewsEvent>)items).Add(_items[index]);
                }
            }

            Dictionary <EventSourceChannel, List <EventBase> > itemsModified = new Dictionary <EventSourceChannel, List <EventBase> >();

            foreach (FinancialNewsEvent item in items)
            {
                if (markRead && item.IsRead == false)
                {
                    if (itemsModified.ContainsKey(item.Channel) == false)
                    {
                        itemsModified.Add(item.Channel, new List <EventBase>());
                    }

                    if (itemsModified[item.Channel].Contains(item) == false)
                    {
                        itemsModified[item.Channel].Add(item);
                    }
                    item.IsRead = true;
                }

                if (markDeleted && item.IsVisible)
                {
                    if (itemsModified.ContainsKey(item.Channel) == false)
                    {
                        itemsModified.Add(item.Channel, new List <EventBase>());
                    }
                    if (itemsModified[item.Channel].Contains(item) == false)
                    {
                        itemsModified[item.Channel].Add(item);
                    }
                    item.IsVisible = false;
                }

                if (markFavourite && item.IsFavourite == false)
                {
                    if (itemsModified.ContainsKey(item.Channel) == false)
                    {
                        itemsModified.Add(item.Channel, new List <EventBase>());
                    }
                    if (itemsModified[item.Channel].Contains(item) == false)
                    {
                        itemsModified[item.Channel].Add(item);
                    }
                    item.IsFavourite = true;
                }
                else
                if (markNotFavourite && item.IsFavourite)
                {
                    if (itemsModified.ContainsKey(item.Channel) == false)
                    {
                        itemsModified.Add(item.Channel, new List <EventBase>());
                    }
                    if (itemsModified[item.Channel].Contains(item) == false)
                    {
                        itemsModified[item.Channel].Add(item);
                    }
                    item.IsFavourite = false;
                }
            }

            foreach (KeyValuePair <EventSourceChannel, List <EventBase> > channelPair in itemsModified)
            {
                foreach (EventBase item in channelPair.Value)
                {
                    SystemMonitor.Report(item.Id.ToString());
                }

                channelPair.Key.HandleItemsUpdated(channelPair.Value);
            }
        }