Ejemplo n.º 1
0
 /// <summary>
 /// Called when items are updated: firest the event
 /// </summary>
 void OnItemsUpdated()
 {
     if (ItemsUpdated != null)
     {
         ItemsUpdated.Invoke(this);
     }
 }
Ejemplo n.º 2
0
        private void Insert(LogEntry entry)
        {
            if (_filters.Any() && !_filters.All(x => x.ShouldLogItem(entry)))
            {
                return;
            }

            if (_clock.Now.Ticks < _lastLogRecord + _minInterLogDuration)
            {
                Dropped++; return;
            }

            lock (_lock)
            {
                if (Dropped > 0)
                {
                    _items.Add(new LogEntry(_clock.Now,
                                            GetType().FullName, LogLevel.Critical,
                                            0, null, null,
                                            $"Logging overloaded: dropped {Dropped} items"));
                    Dropped = 0;
                }

                _items.Add(entry);

                if (_items.Count >= _reserved + _reserved / 2)
                {
                    _items.RemoveRange(0, _reserved / 2);
                }

                _lastLogRecord = _clock.Now.Ticks;
            }

            ItemsUpdated?.Invoke();
        }
Ejemplo n.º 3
0
        private void ClickOk(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBoxNewTask.Text))
            {
                //TODO add show error message to the user
                return;
            }

            var newTask = new Item
            {
                Name   = textBoxNewTask.Text,
                IsDone = false,
                Id     = Form1.items.GetMaxId() + 1
            };

            Form1.items.itemList.Add(newTask);
            Actions.SaveData(Form1.items.itemList);
            //WorkWithFile.TaskListToJson(Form1.items, @"D:\Sneghka\IT\Visual Studio\TODO List\Tasks.json");
            this.Close();
            ItemsUpdated?.Invoke(this, e);
        }
Ejemplo n.º 4
0
        private void OnPhotoDeleted(object sender, FileSystemEventArgs e)
        {
            var index = -1;

            for (var i = 0; i < Items.Count; i++)
            {
                if (Items[i].FullPath == e.FullPath)
                {
                    index = i;
                    break;
                }
            }

            if (index >= 0)
            {
                Items.RemoveAt(index);
            }

            if (ItemsUpdated != null)
            {
                ItemsUpdated.Invoke(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 5
0
 protected virtual void OnItemsUpdated(List <T> items)
 {
     ItemsUpdated?.Invoke(this, new PersistedEventArgs <T>(items));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Refreshes the items by invoking the <see cref="ItemsUpdated"/> event with default and 0.
 /// </summary>
 public void RefreshItems() => ItemsUpdated?.Invoke();
Ejemplo n.º 7
0
 /// <summary>
 /// Removes an item from the player's inventory and invokes <see cref="ItemsUpdated"/>.
 /// </summary>
 /// <param name="item">The item to be removed</param>
 public void RemoveItem(Item item)
 {
     items.Remove(item);
     ItemRemoved?.Invoke(item);
     ItemsUpdated?.Invoke();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Adds an item to the player's inventory and invokes <see cref="ItemsUpdated"/>.
 /// </summary>
 /// <param name="item">The item to add</param>
 public void AddItem(Item item)
 {
     items.Add(item);
     ItemAdded?.Invoke(item);
     ItemsUpdated?.Invoke();
 }