public void showPresentTaskController(TaskSetup taskSetup)
 {
     presentTaskViewController = new PresentTaskViewController(this);
     presentTaskViewController.setupTask(taskSetup);
     presentTaskViewController.FindForm().Text = taskSetup.nameTask;
     presentTaskViewController.ShowDialog();
 }
 private void createTaskButton_Click(object sender, EventArgs e)
 {
     if (countPictures != 0 && taskTextBox.Text.Length != 0 && counPage != 0)
     {
         TaskSetup taskSetup = new TaskSetup();
         taskSetup.countPictures = countPictures;
         taskSetup.nameTask = taskTextBox.Text;
         taskSetup.wraperControl = curentWraper;
         taskSetup.counPage = counPage;
         curentBase.createTask(countPictures, taskTextBox.Text);
         createTaskDelegate.showPresentTaskController(taskSetup);
     }
     else
     {
         MessageBox.Show("Задайте все необходимые параметры");
     }
 }
        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);
        }
        public void setupTask(TaskSetup taskSetup)
        {
            countPictures = taskSetup.countPictures;
            countPage = taskSetup.counPage;
            listPuzzleBox = taskSetup.listPuzzleBox;

            picturesPanel.Controls.Clear();

            for (int i = 1; i <= countPage; i++)
            {
                Panel curentImagePanel = new Panel();
                curentImagePanel.MouseMove += new MouseEventHandler(Control_MouseMove);
                curentImagePanel.Bounds = picturesPanel.DisplayRectangle;

                Panel curentTextPanel = new Panel();
                curentTextPanel.MouseMove += new MouseEventHandler(Control_MouseMove);
                curentTextPanel.Bounds = namePicturesPanel.DisplayRectangle;

                for (int j = 0; j < countPictures; j++)
                {
                    Label curentLabel = new Label();
                    setupLabel(curentLabel,j);

                    curentLabel.Text = listPuzzleBox.ToArray()[j].namePic;
                    addedControlToContainer(ref curentImagePanel, j, curentLabel);
                }

                for (int j = 0; j < countPictures; j++)
                {
                    picTag++;
                    PictureBox curentPictures = listPuzzleBox.ToArray()[j].pictures;
                    curentPictures.Tag = picTag;
                    listPuzzleBox.ToArray()[j].tag = picTag;

                    setupPicturesBox(curentPictures);
                    addedControlToContainer(ref curentImagePanel, j, curentPictures);
                    Puzzle puzzle = new Puzzle();
                    puzzle.imagePuzzle = curentPictures;
                    listPuzzle.Add(puzzle);
                }

                if (dictImage.ContainsKey(i.ToString()) == false)
                {
                    dictImage.Add(i.ToString(), curentImagePanel);
                }
            }

            if (countPage > 1)
            {
                navigationPanel.Visible = true;
                pageLabel.Text = curentPage.ToString() + '/' + countPage.ToString();
            }

            Panel startImagePanel = null;
            dictImage.TryGetValue("1", out startImagePanel);

            if (startImagePanel != null )
            {
                picturesPanel.Controls.Add(startImagePanel);
                picturesPanel.Refresh();
            }
        }
 public void showPresentTaskController(TaskSetup taskSetup)
 {
     if(createTestViewController != null)
     createTestViewController.FindForm().Close();
     presentNewTaskViewController = new PresentNewTaskViewController(this);
     presentNewTaskViewController.setupTask(taskSetup);
     presentNewTaskViewController.FindForm().Text = taskSetup.nameTask;
     presentNewTaskViewController.ShowDialog();
 }