Exemplo n.º 1
0
        public List <T> GetPageData(JumpOperation mode)
        {
            switch (mode)
            {
            case JumpOperation.GoHome:
                CurrentIndex_ = 1;
                break;

            case JumpOperation.GoPrePrevious:
                if (CurrentIndex_ > 1)
                {
                    CurrentIndex_ -= 1;
                }
                break;

            case JumpOperation.GoNext:
                if (CurrentIndex_ < PageCount_)
                {
                    CurrentIndex_ += 1;
                }
                break;

            case JumpOperation.GoEnd:
                CurrentIndex_ = PageCount_;
                break;
            }

            List <T> listPageData = new List <T>();

            try
            {
                int pageCountTo = PageSize_;
                if (PageCount_ == CurrentIndex_ && DataSource_.Count % PageSize_ > 0)
                {
                    pageCountTo = DataSource_.Count % PageSize_;
                }
                if (null != DataSource_)
                {
                    for (int i = 0; i < pageCountTo; i++)
                    {
                        if ((CurrentIndex_ - 1) * PageSize_ + i < DataSource_.Count)
                        {
                            listPageData.Add(DataSource_[(CurrentIndex_ - 1) * PageSize_ + i]);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                return(listPageData);
            }
            catch
            {
                return(listPageData);
            }
        }
Exemplo n.º 2
0
        public List <T> GetPageData(JumpOperation jo)
        {
            switch (jo)
            {
            case JumpOperation.GoHome:
                currentIndex = 1;
                break;

            case JumpOperation.GoPrePrevious:
                if (currentIndex > 1)
                {
                    currentIndex -= 1;
                }
                break;

            case JumpOperation.GoNext:
                if (currentIndex < pagecount)
                {
                    currentIndex += 1;
                }
                break;

            case JumpOperation.GoEnd:
                currentIndex = pagecount;
                break;
            }
            List <T> listPageData = new List <T>();

            try
            {
                int pageCountTo = pageSize;
                if (pagecount == currentIndex && dataSource.Count % pageSize > 0)
                {
                    pageCountTo = dataSource.Count % pageSize;
                }
                if (null != dataSource)
                {
                    for (int i = 0; i < pageCountTo; i++)
                    {
                        if ((currentIndex - 1) * pageSize + i < dataSource.Count)
                        {
                            listPageData.Add(dataSource[(currentIndex - 1) * pageSize + i]);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                return(listPageData);
            }
            catch
            {
                return(listPageData);
            }
        }
Exemplo n.º 3
0
        void ITreeWalker.Visit(IfStatement statement)
        {
            statement.Validate(this);
            statement.Condition.Accept(this);
            _operations.Add(PopIfOperation.Instance);
            var jumpToElse = InsertMarker();

            statement.Primary.Accept(this);
            var jumpToEnd = InsertMarker();

            statement.Secondary.Accept(this);
            var end = _operations.Count;

            _operations[jumpToElse] = new JumpOperation(jumpToEnd);
            _operations[jumpToEnd]  = new JumpOperation(end - 1);
        }
Exemplo n.º 4
0
        void ITreeWalker.Visit(WhileStatement statement)
        {
            statement.Validate(this);
            var start = _operations.Count;

            statement.Condition.Accept(this);
            _operations.Add(PopIfOperation.Instance);
            var jump = InsertMarker();

            _loops.Push(new LoopInfo {
                Break = jump, Continue = start
            });
            statement.Body.Accept(this);
            _loops.Pop();
            _operations.Add(new JumpOperation(start - 1));
            var end = _operations.Count;

            _operations[jump] = new JumpOperation(end - 1);
        }
Exemplo n.º 5
0
        public void GetPageData(JumpOperation jo)
        {
            this.PageCount = dataSource.Count / this.pageSize;
            if (dataSource.Count >= pageSize)
            {
                this.PageCount += (dataSource.Count % this.pageSize) != 0 ? 1 : 0;
            }
            switch (jo)
            {
            case JumpOperation.GoHome:
                CurrentIndex = 1;
                break;

            case JumpOperation.GoPrevious:
                if (CurrentIndex > 1)
                {
                    CurrentIndex -= 1;
                }
                break;

            case JumpOperation.GoNext:
                if (CurrentIndex < PageCount)
                {
                    CurrentIndex += 1;
                }
                break;

            case JumpOperation.GoEnd:
                CurrentIndex = PageCount;
                break;

            case JumpOperation.Refresh:
                break;
            }
            Paging();
        }
Exemplo n.º 6
0
 public FieldCommand(GameViewModel vm) : base()
 {
     this.vm   = vm;
     cloneMove = new CloneMoveOperation(vm.Model);
     jump      = new JumpOperation(vm.Model);
 }
Exemplo n.º 7
0
 private void InsertJump(Int32 index, Int32 target)
 {
     _operations[index] = new JumpOperation(target - index);
 }
Exemplo n.º 8
0
 public GameBase()
 {
     cloneMove = new CloneMoveOperation(this);
     jump      = new JumpOperation(this);
 }