Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            TextContainer tc = new TextContainer(_currentPanelQuestion.Entity, this);

            ControlMover.Add(tc.Instance);
            // _currentTask.Identifier++;
        }
Пример #2
0
        public void panelQuestion_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            foreach (string file in files)
            {
                _currentTask.PictureIndex++;
                var pictureBoxScalable = new PictureBoxScalable(_currentTask.PictureIndex, this, _currentPanelQuestion.Entity)
                {
                    Instance = { Parent = _currentPanelQuestion.Entity, SizeMode = PictureBoxSizeMode.StretchImage }
                };
                ControlMover.Add(pictureBoxScalable.Instance);

                try
                {
                    var image = new Bitmap(file); //Bitmap для открываемого изображения

                    pictureBoxScalable.Instance.Size = image.Size;
                    pictureBoxScalable.Instance.Size = new Size(pictureBoxScalable.Instance.Size.Width > 600 ? 600 : pictureBoxScalable.Instance.Size.Width,
                                                                pictureBoxScalable.Instance.Size.Height > 400 ? 400 : pictureBoxScalable.Instance.Size.Height);
                    pictureBoxScalable.Instance.Image    = image;
                    pictureBoxScalable.Instance.Location = new Point(new Size(80, 80));
                    pictureBoxScalable.Instance.Invalidate();
                }
                catch
                {
                    var result = MessageBox.Show("Невозможно добавить файл " + file, @"Есть несохраненные результаты!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
        public void pastePic(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsImage())
            {
                return;
            }

            _currentTask.PictureIndex++;
            var pictureBoxScalable = new PictureBoxScalable(_currentTask.PictureIndex, this, _currentPanelQuestion.Entity)
            {
                Instance = { Parent = _currentPanelQuestion.Entity, SizeMode = PictureBoxSizeMode.StretchImage }
            };

            ControlMover.Add(pictureBoxScalable.Instance);

            Image clipboard_image = Clipboard.GetImage();

            var image = new Bitmap(clipboard_image); //Bitmap для открываемого изображения

            pictureBoxScalable.Instance.Size = image.Size;
            pictureBoxScalable.Instance.Size = new Size(pictureBoxScalable.Instance.Size.Width > 600 ? 600 : pictureBoxScalable.Instance.Size.Width,
                                                        pictureBoxScalable.Instance.Size.Height > 400 ? 400 : pictureBoxScalable.Instance.Size.Height);
            pictureBoxScalable.Instance.Image    = image;
            pictureBoxScalable.Instance.Location = new Point(new Size(80, 80));
            pictureBoxScalable.Instance.Invalidate();
        }
Пример #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            Title ttl = new Title(_currentPanelQuestion.Entity, this, _currentTask.Identifier);

            ControlMover.Add(ttl.Instance);
            //_currentTask.Identifier++;
            ttl.Instance.BackColor = Color.White;
            ttl.Instance.Font      = new Font("Times New Roman", 14f);
            ttl.Instance.Width     = 500;
        }
Пример #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            using (var openFileDialog = new OpenFileDialog {
                Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*"
            })
            {
                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                _currentTask.PictureIndex++;
                var pictureBoxScalable =
                    new PictureBoxScalable(_currentTask.PictureIndex, this, _currentPanelQuestion.Entity)
                {
                    Instance = { Parent = _currentPanelQuestion.Entity, SizeMode = PictureBoxSizeMode.StretchImage }
                };
                ControlMover.Add(pictureBoxScalable.Instance);

                try
                {
                    var image = new Bitmap(openFileDialog.FileName); //Bitmap для открываемого изображения

                    pictureBoxScalable.Instance.Size = image.Size;
                    pictureBoxScalable.Instance.Size = new Size(pictureBoxScalable.Instance.Size.Width > 600 ? 600 : pictureBoxScalable.Instance.Size.Width,
                                                                pictureBoxScalable.Instance.Size.Height > 400 ? 400 : pictureBoxScalable.Instance.Size.Height);
                    pictureBoxScalable.Instance.Image    = image;
                    pictureBoxScalable.Instance.Location = new Point(new Size(80, 80));
                    pictureBoxScalable.Instance.Invalidate();
                }
                catch
                {
                    var result = MessageBox.Show(@"Закрыть без сохранения результатов? 
(Чтобы сохранить результаты, войдите как преподаватель)",
                                                 @"Есть несохраненные результаты!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            using (var openFileDialog = new OpenFileDialog {
                Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*"
            })
            {
                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                _currentTask.PictureIndex++;
                var pictureBoxScalable =
                    new PictureBoxScalable(_currentTask.PictureIndex, this, _currentPanelQuestion.Entity)
                {
                    Instance = { Parent = _currentPanelQuestion.Entity, SizeMode = PictureBoxSizeMode.StretchImage }
                };
                ControlMover.Add(pictureBoxScalable.Instance);

                try
                {
                    var image = new Bitmap(openFileDialog.FileName); //Bitmap для открываемого изображения

                    pictureBoxScalable.Instance.Size = image.Size;
                    PictureResizable(pictureBoxScalable.Instance);
                    pictureBoxScalable.Instance.Image    = image;
                    pictureBoxScalable.Instance.Location = new Point(new Size(80, 80));
                    pictureBoxScalable.Instance.Invalidate();
                }
                catch
                {
                    var result = MessageBox.Show("Невозможно открыть выбранный файл",
                                                 "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #7
0
        private void InitTest(Wrappers.Test fromLoadTest, Test toTest)
        {
            List <Task> listTasksInTest = new List <Task> ();
            Dictionary <Task, List <Title> > rtbInTask             = new Dictionary <Task, List <Title> > ();
            Dictionary <Task, List <PictureBoxScalable> > pbInTask = new Dictionary <Task, List <PictureBoxScalable> > ();
            Dictionary <Task, List <TextContainer> >      tbInTask = new Dictionary <Task, List <TextContainer> > ();
            List <Panel> listPanelTasks = new List <Panel> ();

            //Dictionary<Task, List<Label>> _listTBLabels = new Dictionary<Task, List<Label>> ();

            foreach (Task paneltask in fromLoadTest.Tasks)
            {
                //int textBoxNumber = 0;
                rtbInTask.Add(paneltask, new List <Title>());
                pbInTask.Add(paneltask, new List <PictureBoxScalable>());
                tbInTask.Add(paneltask, new List <TextContainer>());
                //_listTBLabels.Add(paneltask, new List<Label> ());

                listTasksInTest.Add(paneltask);

                foreach (TaskElement taskElem in paneltask.TaskElements)
                {
                    if (taskElem.Type.Equals("RichTextBox"))
                    {
                        Title bufTitle = new Title(taskElem.Name)
                        {
                            Instance =
                            {
                                Height   = taskElem.Height,
                                Width    = taskElem.Width,
                                Location = taskElem.Point,
                                Text     = taskElem.Text,
                                Font     = new Font("Microsoft Sans Serif", 15.75F, FontStyle.Regular, GraphicsUnit.Point, 204),
                            }
                        };
                        rtbInTask[paneltask].Add(bufTitle);
                    }

                    if (taskElem.Type.Equals("PictureBox"))
                    {
                        using (var stream = File.Open(new DynamicParams().GetPath() + "\\" + taskElem.Media, FileMode.Open))
                        {
                            var ms = new MemoryStream((int)stream.Length);
                            stream.CopyTo(ms);
                            ms.Position = 0;
                            PictureBoxScalable bufPbs = new PictureBoxScalable(taskElem.Name)
                            {
                                Instance =
                                {
                                    Size     = new Size(taskElem.Width, taskElem.Height),
                                    Image    = new Bitmap(ms),
                                    Location = taskElem.Point
                                }
                            };
                            pbInTask[paneltask].Add(bufPbs);
                        }
                    }

                    if (taskElem.Type.Equals("TextBox"))
                    {
                        TextContainer bufTc = new TextContainer(taskElem.Name)
                        {
                            Instance =
                            {
                                Height   = taskElem.Height,
                                Width    = taskElem.Width,
                                Location = taskElem.Point,
                                Text     = taskElem.Answer,
                                TabIndex = taskElem.Index
                            }
                        };
                        tbInTask[paneltask].Insert(0, bufTc);
                    }
                }
            }

            foreach (Task task in listTasksInTest)
            {
                var indexLabel = 1;
                var buf1       = new Panel
                {
                    BackColor = SystemColors.ControlDark,
                    Location  = new Point(0, 0),
                    Name      = task.Name,
                    Size      = new Size(1110, 618),
                    TabIndex  = 0
                };
                listPanelTasks.Add(buf1);

                //Добавление панели с заданием

                var panelQestionFoo = new Panel
                {
                    BackColor  = SystemColors.GradientInactiveCaption,
                    Location   = new Point(5, 5),
                    Name       = "panelQuestion",
                    Size       = new Size(761, 610),
                    TabIndex   = 0,
                    AutoScroll = true,
                    AllowDrop  = true
                };

                panelQestionFoo.DragEnter += toTest.panelQuestion_DragEnter;
                panelQestionFoo.DragDrop  += toTest.panelQuestion_DragDrop;

                toTest.createPasteFunc(panelQestionFoo);

                foreach (var pb in pbInTask[task])
                {
                    pb.setParent(panelQestionFoo);
                    panelQestionFoo.Controls.Add(pb.Instance);
                    ControlMover.Add(pb.Instance);
                    pb.Instance.SizeMode = PictureBoxSizeMode.StretchImage;
                }



                int j = tbInTask[task].Count;
                foreach (TextContainer tb in tbInTask[task])
                {
                    tb.Instance.Name = "TextBox, Text: " + j;
                    tb.setParent(panelQestionFoo);
                    tb.AddAnswerTitle(tb.Instance.TabIndex);
                    panelQestionFoo.Controls.Add(tb.Instance);
                    tb.Instance.BringToFront();
                    ControlMover.Add(tb.Instance);

                    indexLabel++;


                    TbList.Add(tb.Instance);
                    j--;
                }

                foreach (Title rtb in rtbInTask[task])
                {
                    rtb.setParent(panelQestionFoo);
                    panelQestionFoo.Controls.Add(rtb.Instance);
                    ControlMover.Add(rtb.Instance);
                    rtb.Instance.BringToFront();
                }



                listPanelTasks[listPanelTasks.Count - 1].Controls.Add(panelQestionFoo);
                toTest.Controls.Find("panelMiddle", true)[0].Controls.Add(listPanelTasks[listPanelTasks.Count - 1]);

                PanelWrapper bufPw = new PanelWrapper
                {
                    Entity       = listPanelTasks[listPanelTasks.Count - 1],
                    Identifier   = indexLabel,
                    PictureIndex = pbInTask[task].Count
                };
                indexLabel++;

                var bufLl = toTest.createLinkLabel(listPanelTasks.Count - 1);

                bufPw.Entity.Name = bufLl.Text;

                toTest.ListPanelsTasks.Add(bufLl, bufPw);
                toTest.LinkLabelButtonDel.Add(bufLl, toTest.createButtonDelTask(listPanelTasks.Count - 1));


                PanelWrapper bufPw2 = new PanelWrapper {
                    Entity = panelQestionFoo
                };
                toTest._currentPanelQuestion = bufPw2;
            }


            Control currentPanelListOfTasks = toTest.Controls.Find("panelListOfTasks", true)[0];


            toTest.ListPanelsTasks.Remove((LinkLabel)currentPanelListOfTasks.Controls[1]);
            toTest.LinkLabelButtonDel.Remove((LinkLabel)currentPanelListOfTasks.Controls[1]);

            currentPanelListOfTasks.Controls.Remove(currentPanelListOfTasks.Controls[1]);
            currentPanelListOfTasks.Controls.Remove(currentPanelListOfTasks.Controls[1]);

            toTest._currentTask = toTest.ListPanelsTasks[(LinkLabel)(toTest.Controls.Find("panelListOfTasks", true)[0].Controls[1])];
            toTest._currentPanelQuestion.Entity = (Panel)toTest._currentTask.Entity.Controls.Find("panelQuestion", true)[0];
        }
Пример #8
0
        private void initTest(Wrappers.Test fromLoadTest, Test toTest)
        {
            List <Task> _listTasksInTest = new List <Task> {
            };
            Dictionary <Task, List <Title> > _RTBInTask             = new Dictionary <Task, List <Title> > {
            };
            Dictionary <Task, List <PictureBoxScalable> > _PBInTask = new Dictionary <Task, List <PictureBoxScalable> > {
            };
            Dictionary <Task, List <TextContainer> > _TBInTask      = new Dictionary <Task, List <TextContainer> > {
            };
            List <Panel> _listPanelTasks = new List <Panel> {
            };

            //Dictionary<Task, List<Label>> _listTBLabels = new Dictionary<Task, List<Label>> { };

            foreach (Task paneltask in fromLoadTest.Tasks)
            {
                //int textBoxNumber = 0;
                _RTBInTask.Add(paneltask, new List <Title> {
                });
                _PBInTask.Add(paneltask, new List <PictureBoxScalable> {
                });
                _TBInTask.Add(paneltask, new List <TextContainer> {
                });
                //_listTBLabels.Add(paneltask, new List<Label> { });

                _listTasksInTest.Add(paneltask);


                //foreach (TaskElement taskElem in paneltask.TaskElements)
                //{
                //    if (taskElem.Type.Equals("System.Windows.Forms.TextBox"))
                //    {

                //        textBoxNumber++;

                //    }
                //}

                foreach (TaskElement taskElem in paneltask.TaskElements)
                {
                    if (taskElem.Type.Equals("System.Windows.Forms.RichTextBox"))
                    {
                        Title bufTitle = new Title(taskElem.Name)
                        {
                            Instance =
                            {
                                Height   = taskElem.Height,
                                Width    = taskElem.Width,
                                Location = taskElem.Point,
                                Text     = taskElem.Text,
                                Font     = new System.Drawing.Font("Microsoft Sans Serif", 15.75F,
                                                                   System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
                                                                   ((byte)(204))),
                            }
                        };
                        _RTBInTask[paneltask].Add(bufTitle);
                    }

                    if (taskElem.Type.Equals("System.Windows.Forms.PictureBox"))
                    {
                        using (var stream = File.Open(new DynamicParams().GetPath() + "/" + taskElem.Media,
                                                      FileMode.Open))
                        {
                            var binaryFormatter = new BinaryFormatter();
                            var image           = ((SerializablePicture)binaryFormatter.Deserialize(stream)).Picture;


                            PictureBoxScalable bufPBS = new PictureBoxScalable(taskElem.Name)
                            {
                                Instance =
                                {
                                    Size     = new Size(taskElem.Width, taskElem.Height),
                                    Image    = image,
                                    Location = taskElem.Point
                                }
                            };
                            _PBInTask[paneltask].Add(bufPBS);
                        }
                    }

                    if (taskElem.Type.Equals("System.Windows.Forms.TextBox"))
                    {
                        TextContainer bufTC = new TextContainer(taskElem.Name)
                        {
                            Instance =
                            {
                                Height   = taskElem.Height,
                                Width    = taskElem.Width,
                                Location = taskElem.Point,
                                Text     = taskElem.Answer,
                                TabIndex = taskElem.Index
                            }
                        };
                        _TBInTask[paneltask].Insert(0, bufTC);


                        //textBoxNumber--;
                    }
                }
            }

            foreach (Task task in _listTasksInTest)
            {
                var indexLabel = 1;
                var buf1       = new Panel
                {
                    BackColor = System.Drawing.SystemColors.ControlDark,
                    Location  = new System.Drawing.Point(0, 0),
                    Name      = task.Name,
                    Size      = new System.Drawing.Size(1110, 618),
                    TabIndex  = 0
                };
                _listPanelTasks.Add(buf1);

                //Добавление панели с заданием

                var panelQestionFoo = new Panel();
                panelQestionFoo.BackColor  = System.Drawing.SystemColors.GradientInactiveCaption;
                panelQestionFoo.Location   = new System.Drawing.Point(5, 5);
                panelQestionFoo.Name       = "panelQuestion";
                panelQestionFoo.Size       = new System.Drawing.Size(761, 610);
                panelQestionFoo.TabIndex   = 0;
                panelQestionFoo.AutoScroll = true;

                panelQestionFoo.AllowDrop  = true;
                panelQestionFoo.DragEnter += new DragEventHandler(toTest.panelQuestion_DragEnter);
                panelQestionFoo.DragDrop  += new DragEventHandler(toTest.panelQuestion_DragDrop);

                toTest.createPasteFunc(panelQestionFoo);

                foreach (PictureBoxScalable pb in _PBInTask[task])
                {
                    pb.SetParent(panelQestionFoo);
                    panelQestionFoo.Controls.Add(pb.Instance);
                    ControlMover.Add(pb.Instance);
                    pb.Instance.SizeMode = PictureBoxSizeMode.StretchImage;
                }


                int j = _TBInTask[task].Count;
                foreach (TextContainer tb in _TBInTask[task])
                {
                    tb.Instance.Name = "System.Windows.Forms.TextBox, Text: " + j;
                    tb.SetParent(panelQestionFoo);
                    tb.AddAnswerTitle(tb.Instance.TabIndex);
                    panelQestionFoo.Controls.Add(tb.Instance);
                    tb.Instance.BringToFront();
                    ControlMover.Add(tb.Instance);

                    indexLabel++;


                    TBList.Add(tb.Instance);
                    j--;
                }

                foreach (Title rtb in _RTBInTask[task])
                {
                    rtb.SetParent(panelQestionFoo);
                    panelQestionFoo.Controls.Add(rtb.Instance);
                    ControlMover.Add(rtb.Instance);
                    rtb.Instance.BringToFront();
                }


                _listPanelTasks[_listPanelTasks.Count - 1].Controls.Add(panelQestionFoo);
                toTest.Controls.Find("panelMiddle", true)[0].Controls.Add(_listPanelTasks[_listPanelTasks.Count - 1]);

                PanelWrapper bufPW = new PanelWrapper();
                bufPW.Entity       = _listPanelTasks[_listPanelTasks.Count - 1];
                bufPW.Identifier   = indexLabel;
                bufPW.PictureIndex = _PBInTask[task].Count;
                indexLabel++;

                LinkLabel bufLL = toTest.createLinkLabel(_listPanelTasks.Count - 1);

                bufPW.Entity.Name = bufLL.Text;

                toTest.ListPanelsTasks.Add(bufLL, bufPW);
                toTest.LinkLabelButtonDel.Add(bufLL, toTest.createButtonDelTask(_listPanelTasks.Count - 1));


                PanelWrapper bufPW2 = new PanelWrapper();
                bufPW2.Entity = panelQestionFoo;
                toTest._currentPanelQuestion = bufPW2;
            }


            Control currentPanelListOfTasks = toTest.Controls.Find("panelListOfTasks", true)[0];


            toTest.ListPanelsTasks.Remove((LinkLabel)currentPanelListOfTasks.Controls[1]);
            toTest.LinkLabelButtonDel.Remove((LinkLabel)currentPanelListOfTasks.Controls[1]);

            currentPanelListOfTasks.Controls.Remove(currentPanelListOfTasks.Controls[1]);
            currentPanelListOfTasks.Controls.Remove(currentPanelListOfTasks.Controls[1]);

            //toTest.ListPanelsTasks.Remove((LinkLabel)currentPanelListOfTasks.Controls[1]);


            toTest._currentTask =
                toTest.ListPanelsTasks[(LinkLabel)(toTest.Controls.Find("panelListOfTasks", true)[0].Controls[1])];
            toTest._currentPanelQuestion.Entity =
                (Panel)toTest._currentTask.Entity.Controls.Find("panelQuestion", true)[0];


            //foreach (TextBox tb in TBList)
            //{
            //    tb.Move += moveTBWithLB;
            //}
        }