示例#1
0
        public void setButtonUpOrDown(BtnType bt, string Cls)
        {
            if (id == 0)
            {
                return;
            }
            List <ButtonDate> btndate = PubulicData.sourceData[PubulicData.ClassName.ButtonDate.ToString()] as List <ButtonDate>;
            ButtonDate        btnd    = btndate.FirstOrDefault(c => c.ID == id);

            if (btnd == null)
            {
                return;
            }
            int NewIndex = btnd.Index;
            int NexIndex = 0;

            if (Cls == "上移" && NewIndex > btndate.Where(c => c.Type == bt.ToString() && c.State == "show").Min(c => c.Index))
            {
                NexIndex = btndate.Where(c => c.Type == bt.ToString() && c.Index < NewIndex && c.State == "show").Max(c => c.Index);
            }
            else if (Cls == "下移" && NewIndex < btndate.Where(c => c.Type == bt.ToString() && c.State == "show").Max(c => c.Index))
            {
                NexIndex = btndate.Where(c => c.Type == bt.ToString() && c.Index > NewIndex && c.State == "show").Min(c => c.Index);
            }
            if (NexIndex != 0)
            {
                var model = btndate.FirstOrDefault(c => c.Index == NexIndex && c.Type == bt.ToString());
                btnd.Index  = NexIndex;
                model.Index = NewIndex;
            }
            PubulicData.sourceData[PubulicData.ClassName.ButtonDate.ToString()] = btndate;
            SX();
        }
示例#2
0
        /// <summary>
        /// 当前选择按钮置顶
        /// </summary>
        public void setButtonTop(BtnType tp)
        {
            if (id == 0)
            {
                return;
            }

            List <ButtonDate> btndate = PubulicData.sourceData[PubulicData.ClassName.ButtonDate.ToString()] as List <ButtonDate>;
            ButtonDate        btnd    = btndate.FirstOrDefault(c => c.ID == id);

            if (btnd == null)
            {
                return;
            }
            if (btndate.FirstOrDefault(c => c.Index == 1 && c.Type == tp.ToString()) == null)
            {
                btnd.Index = 1;
            }
            else
            {
                var        dbty  = btndate.Where(c => c.Type == tp.ToString());
                List <int> index = dbty.Select(c => c.Index).ToList();
                foreach (ButtonDate item in dbty)
                {
                    if (item.Index == 1)
                    {
                        item.Index++;
                    }
                    else
                    {
                        if (index.Contains(item.Index - 1))
                        {
                            item.Index++;
                        }
                    }
                }
            }
            PubulicData.sourceData[PubulicData.ClassName.ButtonDate.ToString()] = btndate;
            SX();
        }