private void addedPuzzleToLis(PuzzleBox puzleBox)
 {
     for (int i = 0; i < selectListPuzzleBox.Count; i++)
     {
         PuzzleBox selectPuzzleBox = selectListPuzzleBox.ToArray()[i];
         if (puzleBox.pictures.Tag.ToString().CompareTo(selectPuzzleBox.pictures.Tag.ToString()) == 0)
         {
             selectPuzzleBox.namePic = puzleBox.namePic;
             selectPuzzleBox.pictures = puzleBox.pictures;
             selectPuzzleBox.tag = puzleBox.tag;
             return;
         }
     }
     selectListPuzzleBox.Add(puzleBox);
 }
        void nameImage_MouseUp(object sender, MouseEventArgs e)
        {
            curentMoveLabel = null;
            mousePosition = null;

            Label curentLabel = (Label)sender;
            PictureBox curentPic = isCheckAreaEntering(curentLabel);
            if (curentPic != null)
            {
                Rectangle rectLabel = curentLabel.Bounds;
                Rectangle rectPic = curentPic.Bounds;
                rectLabel.X = rectPic.X + 1;
                rectLabel.Y = rectPic.Y + rectPic.Height + 1;
                curentLabel.Bounds = rectLabel;
                PuzzleBox puzzleBox = new PuzzleBox();
                puzzleBox.namePic = curentLabel.Text;
                puzzleBox.pictures = curentPic;
                puzzleBox.tag = curentPic.Tag;
                addedPuzzleToLis(puzzleBox);
            }
        }
        private void loadTask(string nameTask)
        {
            DataBaseModel curentBase = DataBaseModel.getInstance();
            List<links> listLinks = new List<links>();
            System.Collections.IEnumerator enumerator = curentBase.getContext().links.GetEnumerator();
            while (enumerator.MoveNext())
            {
                links curentLinks = (links)enumerator.Current;
                task curentTask = curentLinks.task;
                string curentTestName = curentTask.tname;
                if (curentTestName.CompareTo(nameTask) == 0)
                {
                    listLinks.Add(curentLinks);
                }
            }

            if (listLinks.Count == 0) return;

            TaskSetup taskSetup = new TaskSetup();
            taskSetup.counPage = 1;
            taskSetup.listPuzzleBox = new List<PuzzleBox>();

            for (int i = 0; i < listLinks.Count; i++)
            {
                links curentLinks = listLinks.ToArray()[i];
                pic curentPic = curentLinks.pic;

                if (curentPic.opic == null)
                    continue;

                System.IO.MemoryStream memory = new System.IO.MemoryStream(curentPic.opic);
                System.IO.BinaryWriter writer = new System.IO.BinaryWriter(memory);
                Image image = Image.FromStream(writer.BaseStream);
                PictureBox picBox = new PictureBox();
                picBox.Image = image;

                PuzzleBox puzzleBox = new PuzzleBox();
                puzzleBox.pictures = picBox;
                puzzleBox.namePic = curentLinks.tname;
                taskSetup.listPuzzleBox.Add(puzzleBox);
            }
            taskSetup.countPictures = taskSetup.listPuzzleBox.Count;
            createTaskDelegate.showPresentTaskController(taskSetup);
        }