Пример #1
0
        protected async void Execute()
        {
            await Commands.HandleAsync(new SetExchangeRate(SourceCurrency, TargetCurrency, ValidFrom, Rate));

            OnAdded?.Invoke();
            Reset();
        }
Пример #2
0
 public void AddItem(Item item, int count)
 {
     item.Inventory = this;
     item.Count     = count;
     items.Add(item);
     OnAdded?.Invoke(item);
 }
        public void AddRangeWithHistory(IEnumerable <SlamTrackedObject> items, IEnumerable <IList <SlamLine> > histories)
        {
            var list          = items.ToList();
            var historiesList = histories.ToList();

            lock (_objects)
            {
                foreach (var(i, h) in list.Zip(historiesList, (i, h) => (i, h)))
                {
                    if (_objects.ContainsKey(i.Id))
                    {
                        return;
                    }

                    var container = CreateTrackContainer(i, h);
                    _objects.Add(i.Id, (i, container));
                }

                if (historiesList.Count != 0)
                {
                    _maxId = historiesList.SelectMany(l => l).Max(l => l.Id);
                }
            }

            OnAdded?.Invoke(this, new AddedEventArgs <SlamTrackedObject>(list));
        }
 public void SetRenderer(ISourceRenderer renderer)
 {
     if (renderer is ICloudRenderer <SlamLine> typedRenderer)
     {
         OnAdded          += typedRenderer.OnItemsAdded;
         OnUpdated        += typedRenderer.OnItemsUpdated;
         OnRemoved        += typedRenderer.OnItemsRemoved;
         OnVisibleChanged += visible =>
         {
             if (visible)
             {
                 typedRenderer.OnItemsAdded(this, new AddedEventArgs <SlamLine>(this));
             }
             else
             {
                 typedRenderer.OnClear(this);
             }
         };
         if (Count > 0)
         {
             OnAdded?.Invoke(this, new AddedEventArgs <SlamLine>(this));
         }
     }
     else if (renderer is TrackedObjectCloud trackedRenderer)
     {
         OnFollowed   += trackedRenderer.FollowCamera;
         OnUnfollowed += trackedRenderer.StopFollowCamera;
     }
 }
Пример #5
0
        public void LoadAnnObjects(string path)
        {
            if (!File.Exists(path))
            {
                return;
            }
            var jArray = JsonConvert.DeserializeObject(File.ReadAllText(path)) as JArray;

            foreach (var i in jArray)
            {
                AnnObject annObject;
                switch ((AnnObjectType)i["Type"].Value <int>())
                {
                case AnnObjectType.Ruler:
                    annObject = i.ToObject <LineAnnObject>();
                    break;

                case AnnObjectType.Ellipse:
                    annObject = i.ToObject <EllipseAnnObject>();
                    break;

                case AnnObjectType.Rectangle:
                    annObject = i.ToObject <RectangleAnnObject>();
                    break;

                default:
                    throw new NotSupportedException();
                }
                annObjects.Add(annObject);
                OnAdded?.Invoke(annObject);
            }
        }
Пример #6
0
        /// <summary>
        /// Adds/Creates a component associated with the given entity id.
        /// </summary>
        public C AddComponent <C>(int eid)
            where C : Component, new()
        {
            IComponentCollection collection = null;

            componentCollectionCache.TryGetValue(typeof(C), out collection);

            if (collection == null)
            {
                // Assigns the component collection a filter identifier
                collection = new ComponentCollection <C>(caboodle, _count++);
                componentCollections.Add(collection);
                componentCollectionCache.Add(typeof(C), collection);
            }

            var c = collection.Add(eid) as C;

            ComponentInfo info;

            info.id        = collection.GetId();
            info.component = c;

            OnAdded?.Invoke(eid, info);

            return(c);
        }
Пример #7
0
        public void Produce(CancellationToken ct, params T[] items)
        {
            if (items.Length == 0)
            {
                return;
            }
            int index = 0;
            T   item  = default;

            do
            {
                try {
                    item = items[index];
                    if (_collection.TryAdd(item, 10, ct))
                    {
                        Interlocked.Increment(ref index);
                        OnAdded?.Invoke(this, item);
                    }
                    else
                    {
                        OnAddBlocked?.Invoke(this, item);
                    }
                } catch (OperationCanceledException) {
                    OnAddingCanceled?.Invoke(this, item);
                    break;
                } catch (Exception ex) {
                    OnException?.Invoke(this, ex);
                }
            }while (index < items.Length);
        }
Пример #8
0
 public void Add(TCloudItem item)
 {
     lock (_items)
     {
         _items.Add(item.Id, item);
         OnAdded?.Invoke(this, new AddedEventArgs <TCloudItem>(new[] { item }));
     }
 }
Пример #9
0
 /// <summary>
 /// Add the newObject to the list if it is not there from before
 /// </summary>
 /// <param name="newObject"></param>
 public void Add(T newObject)
 {
     if (!objects.Contains(newObject))
     {
         objects.Add(newObject);
         OnAdded?.Invoke(newObject);
     }
 }
Пример #10
0
        /// <summary>
        /// Creates an entity.
        /// </summary>
        /// <returns></returns>
        public Entity Create()
        {
            var entity = caboodle.Pool.CreateEntity();

            entities.Set(entity.Id, entity);
            OnAdded?.Invoke(entity);
            return(entity);
        }
        public void Insert(int index, SlamLine item)
        {
            lock (_lines)
            {
                _lines.Insert(index, item);
            }

            OnAdded?.Invoke(this, new AddedEventArgs <SlamLine>(new[] { item }));
        }
Пример #12
0
        public override void Add(IItem item)
        {
            Content = item;
            var quantity = item is StackableItem stackableItem ? stackableItem.Quantity : 0;

            Set(item.Definition.Icon.Data, item.Definition.ItemColor());
            m_quantityLabel.text = quantity == 0 ? "" : quantity.ToString();
            OnAdded?.Invoke(item);
        }
        public void Add(SlamLine item)
        {
            lock (_lines)
            {
                _lines.Add(item);
            }

            OnAdded?.Invoke(this, new AddedEventArgs <SlamLine>(new[] { item }));
        }
Пример #14
0
        public int Add(int x, int y)
        {
            int z = x + y;

            if (OnAdded != null)
            {
                OnAdded.Invoke(x, y, z);
            }
            return(z);
        }
        private void OnUnlockChange(string identifier, bool value)
        {
            if (value == true)
            {
                IEnumerable <IContentCachedPrefab> newlyUnlocked = _allPrefabs
                                                                   .Where(x => ContainsComponent(x.GetCache().GetComponent <TurretAssembly>(), identifier))
                                                                   .Where(x => IsUnlocked(x.GetCache().GetComponent <TurretAssembly>()));

                OnAdded?.Invoke(newlyUnlocked);
            }
        }
Пример #16
0
        private void PerformAdds()
        {
            foreach (var tr in _Additions.ToList())
            {
                _Contents.Add(tr);
                tr.Completed += Remove;
                OnAdded?.Invoke(this, tr);
            }

            _Additions.Clear();
        }
        private static void OnOperationStateCreated(int id)
        {
            if (!s_Initialized)
            {
                return;
            }
            var item = CreateProgressItem(id);

            s_ProgressDirty = true;
            OnAdded?.Invoke(new[] { item });
        }
Пример #18
0
 public void Add(T item)
 {
     if (!Items.Contains(item))
     {
         Items.Add(item);
         if (OnAdded != null)
         {
             OnAdded.Invoke(item);
         }
     }
 }
Пример #19
0
        public T AddItem <T>(int count) where T : Item, new()
        {
            T item = new T()
            {
                Inventory = this, Count = count
            };

            items.Add(item);
            OnAdded?.Invoke(item);
            return(item);
        }
Пример #20
0
        public T AddItem <T>() where T : Item, new()
        {
            T item = new T()
            {
                Inventory = this
            };

            items.Add(item);
            OnAdded?.Invoke(item);
            return(item);
        }
Пример #21
0
 public void Add(Entity data)
 {
     if (!entities.Contains(data))
     {
         data.OnDestroyed += Data_OnDestroyed;
         entities.Add(data);
         if (OnAdded != null)
         {
             OnAdded.Invoke(this, new AddedEventArgs <Entity>(data));
         }
     }
 }
Пример #22
0
        public override void Add(IItem item)
        {
            var definition = (WeaponDefinition)item.Definition;

            if (definition.WeaponType == m_weaponType)
            {
                Content = item;
                Set(definition.Icon.Data, definition.ItemColor());
                m_typeIcon.enabled = false;
                OnAdded?.Invoke(item);
            }
        }
Пример #23
0
        internal void DoAdded(GuiContainer parent)
        {
            Parent = parent;
            OnAdded?.Invoke();

            if (parent is GuiView)
            {
                DoAddedToView((GuiView)parent);
            }
            else if (parent.View != null)
            {
                DoAddedToView(parent.View);
            }
        }
        public void Add(SlamTrackedObject item)
        {
            lock (_objects)
            {
                if (_objects.ContainsKey(item.Id))
                {
                    return;
                }
                var container = CreateTrackContainer(item);
                _objects[item.Id] = (item, container);
            }

            OnAdded?.Invoke(this, new AddedEventArgs <SlamTrackedObject>(new[] { item }));
        }
Пример #25
0
        internal void Added(Scene scene)
        {
            if (changeLock)
            {
                throw new Exception("Cannot add a manager in its add/remove callbacks.");
            }

            changeLock = true;

            Scene = scene;
            OnAdded?.Invoke();

            changeLock = false;
        }
Пример #26
0
        internal void Add()
        {
            var block = new Block(this, Blocks.Count);

            Blocks.Add(block);
            OnAdded?.Invoke(this, block);
            if (UpdateBitmapSize())
            {
                DrawAll();
            }
            else
            {
                DrawOne(block);
            }
        }
        public void AddRange(IEnumerable <SlamLine> items)
        {
            if (items is null)
            {
                return;
            }
            var list = items.ToList();

            lock (_lines)
            {
                _lines.AddRange(list);
            }

            OnAdded?.Invoke(this, new AddedEventArgs <SlamLine>(list));
        }
        public void AddWithHistory(SlamTrackedObject item, IList <SlamLine> history)
        {
            lock (_objects)
            {
                if (_objects.ContainsKey(item.Id))
                {
                    return;
                }

                var container = CreateTrackContainer(item, history);
                _objects.Add(item.Id, (item, container));
                _maxId = history.Count > 0 ? history.Max(l => l.Id) : 0;
            }

            OnAdded?.Invoke(this, new AddedEventArgs <SlamTrackedObject>(new[] { item }));
        }
Пример #29
0
 public TValue this[TKey key]
 {
     get { return(Value[key]); }
     set
     {
         if (Value.ContainsKey(key))
         {
             Value[key] = value;
             OnItemValueChanged?.Invoke(key, value);
         }
         else
         {
             Value[key] = value;
             OnAdded?.Invoke(key);
         }
     }
 }
Пример #30
0
        public void AddRange(IEnumerable <TCloudItem> items)
        {
            if (items is null)
            {
                return;
            }
            lock (_items)
            {
                var list = items.ToList();
                foreach (var ci in list)
                {
                    _items.Add(ci.Id, ci);
                }

                OnAdded?.Invoke(this, new AddedEventArgs <TCloudItem>(list));
            }
        }