Ejemplo n.º 1
0
    private void DeleteCurrentPages(PageTabState currentState, int pPageTab)
    {
        BookInfomation bf        = BookInfomation._isntance;
        bool           changeFlg = false;

        switch (currentState)
        {
        case PageTabState.Left:
            for (int i = bf.CatalogueLen, j = 1; i < bf.promotion.PageList.Count; i++)
            {
                if (changeFlg)
                {
                    bf.promotion.PageList[i].PageTab = pPageTab + j;
                    j++;
                }
                if (!(bf.promotion.PageList[i] is CataloguePage) && bf.promotion.PageList[i].PageTab == pPageTab)
                {
                    Debug.Log("Delete: " + bf.promotion.PageList[i].PageTab);
                    bf.promotion.PageList.RemoveAt(i);
                    Debug.Log("i: " + i + "; count: " + bf.promotion.PageList.Count);
                    bf.AllModelBtnControllSc.HideAllBtn();
                    if (i + 1 < bf.promotion.PageList.Count)
                    {
                        bf.promotion.PageList[i].PageTab     = pPageTab;
                        bf.promotion.PageList[i + 1].PageTab = pPageTab + j;
                        changeFlg = true;
                        if (bf.LastIsLeft)
                        {
                            bf.NextCurrentPage = bf.promotion.PageList[i + 1];
                            bf.NextSeletedPage = bf.promotion.PageList[i + 1];
                            bf.ChangeNextRender(bf.promotion.PageList[i]);
                            bf.ChangeNextCurrentRender(bf.promotion.PageList[i + 1]);
                        }
                        else
                        {
                            bf.LastSeletedPage    = bf.promotion.PageList[i];
                            bf.CurrentSeletedPage = bf.promotion.PageList[i + 1];
                            bf.ChangeLastRender(bf.promotion.PageList[i]);
                            bf.ChangeCurrentRender(bf.promotion.PageList[i + 1]);
                        }
                        bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[i]);
                        bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[i + 1]);
                    }
                    else if (i + 1 == bf.promotion.PageList.Count)
                    {
                        bf.promotion.PageList[i].PageTab = pPageTab;
                        bf.CurrentSeletedPage            = null;
                        bf.ChangeCurrentRender(null);
                        if (bf.LastIsLeft)
                        {
                            bf.NextCurrentPage = null;
                            bf.ChangeNextCurrentRender(null);
                            bf.NextSeletedPage = bf.promotion.PageList[i];
                            bf.ChangeNextRender(bf.promotion.PageList[i]);
                        }
                        else
                        {
                            bf.CurrentSeletedPage = null;
                            bf.ChangeNextCurrentRender(null);
                            bf.LastSeletedPage = bf.promotion.PageList[i];
                            bf.ChangeLastRender(bf.promotion.PageList[i]);
                        }
                        bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[i]);
                        // bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[i + 1]);
                    }
                    else if (i == bf.promotion.PageList.Count)
                    {
                        if (i - 2 >= 0)
                        {
                            if (bf.LastIsLeft)
                            {
                                bf.NextCurrentPage = bf.promotion.PageList[i - 1];
                                bf.ChangeNextCurrentRender(bf.promotion.PageList[i - 1]);
                                bf.NextCurrentPage = bf.promotion.PageList[i - 2];
                                bf.ChangeNextRender(bf.promotion.PageList[i - 2]);
                                bf.NextSeletedPage = bf.promotion.PageList[i - 2];
                            }
                            else
                            {
                                bf.CurrentSeletedPage = bf.promotion.PageList[i - 1];
                                bf.ChangeCurrentRender(bf.promotion.PageList[i - 1]);
                                bf.CurrentSeletedPage = bf.promotion.PageList[i - 2];
                                bf.ChangeLastRender(bf.promotion.PageList[i - 2]);
                            }
                            bf.index          -= 2;
                            bf.LastSeletedPage = bf.promotion.PageList[i - 2];
                            bf.ChangeLastRender(bf.promotion.PageList[i - 2]);
                            bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[i - 1]);
                            bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[i - 2]);
                        }
                        else if (i - 1 >= 0)
                        {
                            if (bf.LastIsLeft)
                            {
                                bf.ChangeNextCurrentRender(bf.promotion.PageList[i - 1]);
                            }
                            else
                            {
                                bf.ChangeCurrentRender(bf.promotion.PageList[i - 1]);
                            }
                            bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[i - 1]);
                        }
                        else
                        {
                            if (bf.LastIsLeft)
                            {
                                bf.NextCurrentPage = null;
                                bf.ChangeNextCurrentRender(null);
                            }
                            else
                            {
                                bf.CurrentSeletedPage = null;
                                bf.ChangeCurrentRender(null);
                            }
                        }
                    }
                    else
                    {
                        if (bf.LastIsLeft)
                        {
                            bf.NextCurrentPage = null;
                            bf.ChangeNextCurrentRender(null);
                        }
                        else
                        {
                            bf.CurrentSeletedPage = null;
                            bf.ChangeCurrentRender(null);
                        }
                        break;
                    }
                }
            }
            break;

        case PageTabState.Right:
            for (int i = bf.CatalogueLen, j = 1; i < bf.promotion.PageList.Count; i++)
            {
                if (changeFlg)
                {
                    bf.promotion.PageList[i].PageTab = pPageTab + j;
                    j++;
                }
                if (!changeFlg && !(bf.promotion.PageList[i] is CataloguePage) && bf.promotion.PageList[i].PageTab == pPageTab)
                {
                    //Debug.Log("Delete is CataloguePage: " + bf.promotion.PageList[i] is CataloguePage);
                    bf.promotion.PageList.RemoveAt(i);
                    Debug.Log("i: " + i + "; Count: " + bf.promotion.PageList.Count);
                    bf.AllModelBtnControllSc.HideAllBtn();
                    if (i < bf.promotion.PageList.Count)
                    {
                        bf.promotion.PageList[i].PageTab = pPageTab;
                        changeFlg = true;
                        if (i + 1 != bf.promotion.PageList.Count)
                        {
                            if (bf.LastIsLeft)
                            {
                                bf.NextCurrentPage = bf.promotion.PageList[i];
                                bf.ChangeNextCurrentRender(bf.promotion.PageList[i]);
                                Debug.Log("NextCurrentPage: " + bf.promotion.PageList[i].PageTab);
                            }
                            else
                            {
                                Debug.Log("CurrentSeletedPage");
                                bf.CurrentSeletedPage = bf.promotion.PageList[i];
                                bf.ChangeCurrentRender(bf.promotion.PageList[i]);
                            }
                            bf.ChangeNextCurrentRender(bf.promotion.PageList[i]);
                            bf.NextCurrentPage = bf.promotion.PageList[i];
                            bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[i]);
                        }
                        else
                        {
                            bf.NextCurrentPage = null;
                            bf.ChangeNextCurrentRender(null);
                            if (!bf.LastIsLeft)
                            {
                                bf.CurrentSeletedPage = null;
                                bf.ChangeCurrentRender(null);
                            }
                        }
                        //bf.CurrentSeletedPage = bf.promotion.PageList[i];
                    }
                    else if (i == bf.promotion.PageList.Count)
                    {
                        if (i - 1 >= 0)
                        {
                            Debug.Log(bf.promotion.PageList[i - 1].PageTab);
                            bf.ChangeCurrentRender(null);
                            bf.CurrentSeletedPage = null;
                            bf.NextCurrentPage    = null;
                            bf.ChangeNextCurrentRender(null);
                            //bf.NextSeletedPage = bf.promotion.PageList[i - 1];
                            bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[i - 1]);
                        }
                        else
                        {
                            if (bf.LastIsLeft)
                            {
                                bf.ChangeNextCurrentRender(null);
                                bf.NextSeletedPage = null;
                            }
                            else
                            {
                                bf.ChangeCurrentRender(null);
                                bf.CurrentSeletedPage = null;
                            }
                        }
                    }
                    else       // 消除最后一页的显示信息
                    {
                        if (bf.LastIsLeft)
                        {
                            bf.ChangeNextCurrentRender(null);
                        }
                        else
                        {
                            bf.ChangeCurrentRender(null);
                        }
                    }
                }
            }
            break;

        case PageTabState.None:
            for (int i = bf.CatalogueLen, j = 1; i < bf.promotion.PageList.Count; i++)
            {
                if (changeFlg)
                {
                    bf.promotion.PageList[i].PageTab = pPageTab + j;
                    j++;
                }
                if (!(bf.promotion.PageList[i] is CataloguePage) && bf.promotion.PageList[i].PageTab == pPageTab)
                {
                    //Debug.Log("Delete: " + bf.promotion.PageList[i].PageTab);
                    bf.promotion.PageList.RemoveAt(i);
                    //Debug.Log("New target: " + bf.promotion.PageList[i].PageTab);
                    bf.promotion.PageList[i].PageTab     = pPageTab;
                    bf.promotion.PageList[i + 1].PageTab = pPageTab + j;
                    changeFlg = true;
                }
            }
            break;

        default:
            break;
        }
        bf.PageNControl_A.HideAllHeightShine();
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 从指定页插入一页
    /// </summary>
    /// <param name="currentPage"></param>
    /// <param name="readState"></param>
    private void AddPage(Page newPage, int targetPage, bool isCurrent)
    {
        BookInfomation bf        = BookInfomation._isntance;
        int            currIndex = -1;

        for (int i = bf.CatalogueLen; i < bf.promotion.PageList.Count; i++)
        {
            if (targetPage == bf.promotion.PageList[i].PageTab)
            {
                currIndex = i;
                break;
            }
        }
        if (currIndex != -1 || targetPage == -1)
        {
            if (targetPage == -1)
            {
                bf.promotion.PageList.Add(newPage);
            }
            else
            {
                bf.promotion.PageList.Insert(currIndex, newPage);
                currIndex++;
                for (int i = currIndex; i < bf.promotion.PageList.Count; i++)
                {
                    bf.promotion.PageList[i].PageTab++;
                }
            }

            if (isCurrent && CurrentPage != null && !(CurrentPage is CataloguePage))
            {
                bf.AllModelBtnControllSc.HideAllBtn();
                if (readState == PageTabState.Left)
                {
                    if (bf.LastIsLeft)
                    {
                        bf.ChangeNextRender(newPage);
                        bf.ChangeNextCurrentRender(bf.promotion.PageList[currIndex]);
                    }
                    else
                    {
                        bf.ChangeLastRender(newPage);
                        bf.ChangeCurrentRender(bf.promotion.PageList[currIndex]);
                    }
                    bf.AllModelBtnControllSc.Initialize(newPage);
                    bf.AllModelBtnControllSc.Initialize(bf.promotion.PageList[currIndex]);
                }
                else
                {
                    if (bf.LastIsLeft)
                    {
                        bf.ChangeNextCurrentRender(newPage);
                    }
                    else
                    {
                        bf.ChangeCurrentRender(newPage);
                    }
                    bf.AllModelBtnControllSc.Initialize(newPage);
                }
            }
            else if (isCurrent && targetPage == -1)
            {
                if (bf.LastIsLeft)
                {
                    bf.ChangeNextCurrentRender(newPage);
                }
                else
                {
                    bf.ChangeCurrentRender(newPage);
                }
                bf.AllModelBtnControllSc.Initialize(newPage);
                if (readState == PageTabState.Left)
                {
                    bf.LastSeletedPage = newPage;
                }
                else if (readState == PageTabState.Right)
                {
                    if (bf.LastIsLeft)
                    {
                        bf.NextCurrentPage = newPage;
                    }
                    else
                    {
                        bf.CurrentSeletedPage = newPage;
                    }
                }
            }
        }
        bf.PageNControl_A.HideAllHeightShine();
    }