Exemplo n.º 1
0
        void SetLatestHit_FlowBoxModel(GridCell hitCell)
        {
            if (hitCell != _beginSelectedCell)
            {
                _moreThan1Cell = true;

                if (hitCell.ColumnIndex > _beginSelectedCell.ColumnIndex)
                {
                    //select next to right side of the begin
                    if (hitCell.RowIndex == _beginSelectedCell.RowIndex)
                    {
                        //same row
                        _bodyBox.SetSize(hitCell.Right - _beginSelectedCell.X, hitCell.Bottom - _beginSelectedCell.Y);
                        _bodyBox.Visible = true;
                        _headBox.Visible = _tailBox.Visible = false;
                    }
                    else if (hitCell.RowIndex < _beginSelectedCell.RowIndex)
                    {
                        //move upper
                        int rowDiff = _beginSelectedCell.RowIndex - hitCell.RowIndex;
                        if (rowDiff == 1)
                        {
                            //just head and tail
                            //select to end of the row
                            int colCount = _targetGridView.ColumnCount;
                            {
                                //
                                GridCell lastCellOfHeadRow = _targetGridView.GetCell(hitCell.RowIndex, _targetGridView.ColumnCount - 1);
                                _headBox.SetLocation(hitCell.X, hitCell.Y);
                                _headBox.SetSize(lastCellOfHeadRow.Right - hitCell.X, lastCellOfHeadRow.Height);
                            }
                            //-----
                            {
                                GridCell lastCellOfTailRow = _targetGridView.GetCell(_beginSelectedCell.RowIndex, 0);
                                _tailBox.SetLocation(0, _beginSelectedCell.Y);
                                _tailBox.SetSize(hitCell.Right, lastCellOfTailRow.Height);
                            }


                            _headBox.Visible = _tailBox.Visible = true;
                            _bodyBox.Visible = false;
                        }
                        else
                        {
                            //more than 2 row
                            //so set head-body-tail

                            int colCount = _targetGridView.ColumnCount;
                            {
                                //
                                GridCell lastCellOfHeadRow = _targetGridView.GetCell(hitCell.RowIndex, _targetGridView.ColumnCount - 1);
                                _headBox.SetLocation(hitCell.X, hitCell.Y);
                                _headBox.SetSize(lastCellOfHeadRow.Right - _headBox.Left, lastCellOfHeadRow.Height);
                            }
                            //-----
                            //in between


                            //-----
                            {
                                GridCell lastCellOfTailRow = _targetGridView.GetCell(_beginSelectedCell.RowIndex, 0);
                                _headBox.SetLocation(0, _beginSelectedCell.Y);
                                _headBox.SetSize(_beginSelectedCell.X, lastCellOfTailRow.Height);
                            }


                            _headBox.Visible = _tailBox.Visible = true;
                            _bodyBox.Visible = false;
                        }
                    }
                    else
                    {
                        //move to lower
                        _bodyBox.SetSize(hitCell.Right - _beginSelectedCell.X, hitCell.Bottom - _beginSelectedCell.Y);
                    }
                }
                else if (hitCell.ColumnIndex < _beginSelectedCell.ColumnIndex)
                {
                    //select to left side
                    //move
                    if (hitCell.RowIndex == _beginSelectedCell.RowIndex)
                    {
                        //same row
                        _bodyBox.SetLocation(hitCell.X, hitCell.Y);
                        _bodyBox.SetSize(_beginSelectedCell.Right - hitCell.X, _beginSelectedCell.Bottom - _beginSelectedCell.Y);
                    }
                    else if (hitCell.RowIndex < _beginSelectedCell.RowIndex)
                    {
                        //move upper

                        _bodyBox.SetLocation(hitCell.X, hitCell.Y);
                        _bodyBox.SetSize(_beginSelectedCell.Right - hitCell.X, _beginSelectedCell.Bottom - hitCell.Y);
                    }
                    else
                    {
                        //select to lower
                        _bodyBox.SetLocation(hitCell.X, _beginSelectedCell.Y);
                        _bodyBox.SetSize(_beginSelectedCell.Right - hitCell.X, hitCell.Bottom - _beginSelectedCell.Y);
                    }
                }
                else
                {
                    //same column

                    if (hitCell.RowIndex == _beginSelectedCell.RowIndex)
                    {
                        //same row
                    }
                    else if (hitCell.RowIndex < _beginSelectedCell.RowIndex)
                    {
                        //move upper
                        _bodyBox.SetLocation(hitCell.X, hitCell.Y);
                        _bodyBox.SetSize(_beginSelectedCell.Right - hitCell.X, _beginSelectedCell.Bottom - hitCell.Y);
                    }
                    else
                    {
                        //select to lower
                        _bodyBox.SetSize(hitCell.Right - _beginSelectedCell.X, hitCell.Bottom - _beginSelectedCell.Y);
                    }
                }
            }
            else
            {
                if (_moreThan1Cell)
                {
                    _bodyBox.SetSize(hitCell.Width, hitCell.Height);
                    _bodyBox.SetLocation(hitCell.X, hitCell.Y);
                    _moreThan1Cell = false;
                    //_endSelectedCell = hitCell;
                }
            }
            _latestHitCell = hitCell;
        }
Exemplo n.º 2
0
        public void StartAt(GridCell hitCell)
        {
            _moreThan1Cell     = false;
            _beginSelectedCell = _latestHitCell = hitCell;

            _bodyBox.SetSize(hitCell.Width, hitCell.Height);
            _bodyBox.SetLocation(hitCell.X, hitCell.Y);
            _bodyBox.Visible = true;
            Started          = true;
        }