コード例 #1
0
        public void Remove(QueueRunner selectedItem)
        {
            //Placeholder
            var helper  = QueueRunners.ToList();
            var helper2 = new List <QueueRunner>();

            helper.Remove(selectedItem);

            //Clear and update plus update position
            QueueRunners.Clear();
            int i = 0;

            foreach (var item in helper)
            {
                item.Position = i + 1;
                helper2.Add(item);
                //QueueRunners.Add(item);
                i++;
            }

            //Update database
            DataService.UpdateQueueAsync(helper2);
            DataService.RemoveFromQueueAsync(selectedItem);

            UpdateCollections();
        }
コード例 #2
0
        public void MoveDown(QueueRunner selectedItem)
        {
            var index = selectedItem.Position;

            //Bound check
            if (index >= QueueRunners.Count)
            {
                return;
            }

            //Placeholders
            var helper = QueueRunners.ToList();
            var other  = helper[index];

            //Switch positions
            selectedItem.Position += 1;
            other.Position        -= 1;

            //Switch indexes in List
            helper[selectedItem.Position - 1] = selectedItem;
            helper[other.Position - 1]        = other;

            ////Clear and update
            //QueueRunners.Clear();
            //foreach (var item in helper)
            //{
            //    QueueRunners.Add(item);
            //}

            //Update database
            DataService.UpdateQueueAsync(helper);
            UpdateCollections();
        }
コード例 #3
0
        //do not use Refresh or implement AllQueueRunners (use it like updatecollections)
        public void Refresh()
        {
            var helper = QueueRunners.ToList().OrderBy(x => x.Position);

            QueueRunners.Clear();
            foreach (var item in helper)
            {
                QueueRunners.Add(item);
            }
        }
コード例 #4
0
        public void QueueNextRunner(TimeSpan ts)
        {
            //Update all position in the queue
            var helper = QueueRunners.ToList();

            foreach (var item in helper)
            {
                item.Position -= 1;
            }


            //Register run and Update database
            if (CurrentRunner != null && helper.Count() != 0)
            {
                //Update database
                DataService.UpdateQueueAsync(helper);
                RegisterRun(ts);
                DataService.RemoveFromQueueAsync(CurrentRunner);
            }

            UpdateCollections();
        }