Beispiel #1
0
        /// <summary>
        /// Prepocita to.
        /// </summary>
        public void Recalc()
        {
            lock (this)
            {
                // Reset
                foreach (var item in tracked.Values)
                {
                    item.Changed -= new ObjectChangedEventHandler(item_Changed);
                }
                tracked.Clear();

                int a = 0;

                if (Track)
                {
                    Notepad.WriteLine("collection " + collection.Count());
                }
                // Calculate
                foreach (var item in collection)
                {
                    int foundTypes = this.types.Count(i => i.Graphic == item.Graphic && i.Color == item.Color);
                    //if (item.Graphic != type || item.Color != color)

                    if (foundTypes <= 0)
                    {
                        continue;
                    }

                    if (Track)
                    {
                        Notepad.WriteLine("tracked add " + item.Description);
                    }

                    tracked.Add(item.Serial, item);
                    a += (item.Amount == 0 ? 1 : item.Amount);
                }

                amount = a;
            }

            // Fire event
            OnAmountChanged(EventArgs.Empty);
        }