예제 #1
0
        private bool JudgeCanDrag(int view_index_, int model_width, ENUM_ITEM_DIRECTION neighbour_dir)
        {
            int neighbour_index = -1;

            switch (neighbour_dir)
            {
            case ENUM_ITEM_DIRECTION.E_UP:
                neighbour_index = CartoonUtil.GetUpIndex(view_index_, model_width, this.anchor_w_size, this.anchor_h_size);
                break;

            case ENUM_ITEM_DIRECTION.E_DOWN:
                neighbour_index = CartoonUtil.GetDownIndex(view_index_, model_width, this.anchor_w_size, this.anchor_h_size);
                break;

            case ENUM_ITEM_DIRECTION.E_LEFT:
                neighbour_index = CartoonUtil.GetLeftIndex(view_index_, model_width, this.anchor_w_size, this.anchor_h_size);
                break;

            case ENUM_ITEM_DIRECTION.E_RIGHT:
                neighbour_index = CartoonUtil.GetRightIndex(view_index_, model_width, this.anchor_w_size, this.anchor_h_size);
                break;
            }

            if (-1 == neighbour_index)
            {
                return(false);
            }

            return(CanBeExchanged(neighbour_index));
        }
예제 #2
0
    private void Dragging(CartoonLongRotateView view_, CartoonRotate model_)
    {
        int exchanged_index = -1;

        switch (view_.m_dir)
        {
        case ENUM_ITEM_DIRECTION.E_LEFT:
            exchanged_index = CartoonUtil.GetLeftIndex(view_.Item_index, model_.m_width_unit, this.anchor_w_size, this.anchor_h_size);
            break;

        case ENUM_ITEM_DIRECTION.E_UP:
            exchanged_index = CartoonUtil.GetUpIndex(view_.Item_index, model_.m_width_unit, this.anchor_w_size, this.anchor_h_size);
            break;

        case ENUM_ITEM_DIRECTION.E_RIGHT:
            exchanged_index = CartoonUtil.GetRightIndex(view_.Item_index, model_.m_width_unit, this.anchor_w_size, this.anchor_h_size);
            break;

        case ENUM_ITEM_DIRECTION.E_DOWN:
            exchanged_index = CartoonUtil.GetDownIndex(view_.Item_index, model_.m_width_unit, this.anchor_w_size, this.anchor_h_size);
            break;
        }

        if (-1 == exchanged_index)
        {
            return;
        }

        if (false == this.CanBeExchanged(exchanged_index))
        {
            return;
        }

        AnchorPos exchanged    = this.m_anchor_positions[exchanged_index];
        int       exchanged_id = exchanged.cur_ocuppied_cartoon_item_id;

        CartoonFixedView exchange_view = m_cartoon_views[exchanged_id];
        CartoonFixed     exchange_item = m_cartoon.m_cartoon_items[exchanged_id];

        //我的钉子点不动,尾巴被替换
        int my_tail_index = view_.Tail_index;
        int my_id         = model_.m_item_id;

        //来我的位置
        this.ChangeAnchorPos(exchange_view, exchange_item, my_tail_index, m_anchor_positions[my_tail_index].m_pos);

        //目的地记录换成我
        m_anchor_positions[exchanged_index].cur_ocuppied_cartoon_item_id = my_id;
        //我的anchor记录换成目的地的
        view_.Tail_index = exchanged_index;
    }