示例#1
0
        private void SetExerciseOrders(object sender, ReorderExercisesEventArgs e)
        {
            bool moveUp = (e.NewPosition < e.OldPosition);
            ucExercise exSender = (ucExercise) sender;
            List<ucExercise> tempList = new List<ucExercise>();
            if (moveUp)
            {
                foreach (ucExercise ex in Exercises)
                {
                    if ((ex.SortOrder + 1) == exSender.SortOrder)
                    {
                        ex.SortOrder = exSender.SortOrder;
                        exSender.SortOrder -= 1;
                        tempList.Add(ex);
                        ex.SaveSortOrder(ex.SortOrder);
                        exSender.SaveSortOrder(exSender.SortOrder);
                    }
                    else if (ex == exSender)
                        tempList.Insert(ex.SortOrder - 1, ex);
                    else
                    {
                        tempList.Add(ex);
                    }

                }
            }
            else
            {
                foreach (ucExercise ex in Exercises)
                {
                    if ((ex.SortOrder) == exSender.SortOrder + 1)
                    {
                        exSender.SortOrder = ex.SortOrder;
                        ex.SortOrder -= 1;
                        tempList.Insert(ex.SortOrder, ex);
                        ex.SaveSortOrder(ex.SortOrder);
                        exSender.SaveSortOrder(exSender.SortOrder);
                    }
                    else if (ex == exSender)
                        if (ex.SortOrder == 0)
                            tempList.Add(ex);
                        else
                            tempList.Add(ex);
                    else
                    {
                        tempList.Add(ex);
                    }
                }
            }
            SortExercises(tempList);
        }
示例#2
0
 private void btnDown_Click(object sender, EventArgs e)
 {
     ReorderExercisesEventArgs args = new ReorderExercisesEventArgs();
     args.OldPosition = SortOrder;
     args.NewPosition = SortOrder + 1;
     ExerciseReordered(args);
 }
示例#3
0
 private void btnUp_Click(object sender, EventArgs e)
 {
     ReorderExercisesEventArgs args = new ReorderExercisesEventArgs();
     args.OldPosition = SortOrder;
     args.NewPosition = SortOrder - 1;
     if (args.NewPosition == 1)
         btnUp.Enabled = false;
     btnDown.Enabled = true;
     ExerciseReordered(args);
 }
示例#4
0
 protected virtual void ExerciseReordered(ReorderExercisesEventArgs e)
 {
     EventHandler<ReorderExercisesEventArgs> handler = ExerciseReorderedEvent;
     if (handler != null)
         handler(this, e);
 }