Esempio n. 1
0
            /// <summary>
            /// Resizes the map using the Null Insert method
            /// </summary>
            /// <param name="newWidth"></param>
            /// <param name="newHeight"></param>
            private void NullInsertResize(short newWidth, short newHeight)
            {
                using (ObservableCollectionEx <byte?> safeMapData = this.data.DisableNotifications())
                {
                    //TODO merge a bunch of stuff in here
                    if (newWidth > width)
                    {
                        for (int i = height - 1; i >= 0; i--)
                        {
                            for (int _i = width; _i < newWidth; _i++)
                            {
                                safeMapData.Insert(width + (i * width), null);
                            }
                        }
                    }
                    else if (newWidth < width)
                    {
                        for (int i = height - 1; i >= 0; i--)
                        {
                            for (int _i = width; _i > newWidth; _i--)
                            {
                                safeMapData.RemoveAt((i * width) + newWidth);
                            }
                        }
                    }
                    this.width = newWidth;

                    if (newHeight > height)
                    {
                        for (int i = 0; i < width * (newHeight - height); i++)
                        {
                            if ((height * width) + i < safeMapData.Count)
                            {
                                safeMapData[(height * width) + i] = null;
                            }
                            else
                            {
                                safeMapData.Insert((height * width) + i, null);
                            }
                        }
                    }
                    else if (newHeight < height)
                    {
                        while (safeMapData.Count > newHeight * newWidth)
                        {
                            safeMapData.RemoveAt(safeMapData.Count - 1);
                        }
                    }
                    this.height = newHeight;
                }
            }
Esempio n. 2
0
        void ActiveEvents_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case   NotifyCollectionChangedAction.Add:
                foreach (IEvent ev in e.NewItems)
                {
                    if (_filter.Apply(ev.Definition))
                    {
                        _events.Insert(0, new EventViewModel(ev));
                    }
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (IEvent ev in e.OldItems)
                {
                    foreach (EventViewModel evm in _events)
                    {
                        if (evm.Definition.Id == ev.Definition.Id)
                        {
                            _events.Remove(evm);
                            break;
                        }
                    }
                }

                break;

            case NotifyCollectionChangedAction.Reset:
                _events.Clear();
                break;
            }
        }
Esempio n. 3
0
        private void InsertVideo(Video video)
        {
            for (var i = 0; i < _videosNowPlaying.Count; i++)
            {
                var compare = String.Compare(_videosNowPlaying[i].Title, video.Title, StringComparison.OrdinalIgnoreCase);
                if (compare >= 0)
                {
                    _videosNowPlaying.Insert(i, video);
                    return;
                }
            }

            _videosNowPlaying.Add(video);
        }
Esempio n. 4
0
        /// <summary>
        /// Sort Playlist by Rally-Number
        /// </summary>
        public void Sort()
        {
            List <Guid> sorted = rallyIDs.OrderBy(x => match.Rallies.Where <Rally>(r => r.ID == x).FirstOrDefault <Rally>().Number).ToList();
            int         ptr    = 0;

            while (ptr < sorted.Count)
            {
                if (!rallyIDs[ptr].Equals(sorted[ptr]))
                {
                    Guid t = rallyIDs[ptr];
                    rallyIDs.RemoveAt(ptr);
                    rallyIDs.Insert(sorted.IndexOf(t), t);
                }
                else
                {
                    ptr++;
                }
            }
        }