Example #1
0
 public NewTask(string name, string given, Rectangle r, string phenomenas)
 {
     Task n = new Task();
     this._name = name;
     this._description = given;
     this._phenomenas = phenomenas;
     Serialize(name, r);
 }
Example #2
0
 public NewTask(string name, string given, Rectangle r, string oldTaskName, string currentModule,string phenomenas)
 {
     Task n = new Task();
     this._name = name;
     this._description = given;
     this._phenomenas = phenomenas;
     if (oldTaskName != name)
     {
         Directory.Move(@"modules\" + currentModule + @"\" + oldTaskName, @"modules\" + currentModule + @"\" + _name);
     }
     SerializeEdit(name, r, @"modules\" + currentModule + @"\" + _name, phenomenas);
 }
Example #3
0
 public void CreateFromXML(string path)
 {
     FileStream fs = new FileStream(path, FileMode.Open);
     XmlSerializer xs = new XmlSerializer(typeof(Task));
     Task n = new Task();
     Task tempTask = (Task)xs.Deserialize(fs);
     n._name = tempTask._name;
     n._given = tempTask._given;
     n._toFind = tempTask._toFind;
     n._description = tempTask._description;
     n._phenomenas = tempTask._phenomenas;
     fs.Close();
 }
Example #4
0
 public void Serialize(string name, Rectangle r)
 {
     string path = @"modules\" + FormNewModule._currentModuleName + @"\" + name + @"\main.xml";
     try
     {
         Task n = new Task();
         n._name = this._name;
         n._description = this._description;
         n._toFind = this._toFind;
         n._given = this._given;
         n._phenomenas = this._phenomenas;
         FileStream fs = new FileStream(path, FileMode.Create);
         XmlSerializer xs = new XmlSerializer(typeof(Task));
         xs.Serialize(fs, n);
         fs.Close();
         SaveImage(r, name);
     }
     catch (DirectoryNotFoundException)
     {
         Directory.CreateDirectory(@"modules\" + FormNewModule._currentModuleName + @"\" + name);
         FileStream fs = new FileStream(path, FileMode.Create);
         Task n = new Task();
         n._name = this._name;
         n._description = this._description;
         n._toFind = this._toFind;
         n._given = this._given;
         n._phenomenas = this._phenomenas;
         XmlSerializer xs = new XmlSerializer(typeof(Task));
         xs.Serialize(fs, n);
         fs.Close();
         SaveImage(r, name);
     }
 }
Example #5
0
 private void SerializeEdit(string name, Rectangle r, string modulePath,string phenomenas)
 {
     string path = modulePath;
     Task n = new Task();
     n._name = this._name;
     n._description = this._description;
     n._toFind = this._toFind;
     n._given = this._given;
     n._phenomenas = this._phenomenas;
     FileStream fs = new FileStream(path + @"\main.xml", FileMode.Create);
     XmlSerializer xs = new XmlSerializer(typeof(Task));
     xs.Serialize(fs, n);
     fs.Close();
     SaveImage(r, name, path);
 }
Example #6
0
        public FormEditTask()
        {
            InitializeComponent();
            if (Program.p.AdminMode)
            {
                label2.Visible = false;
                label3.Visible = false;
            }
            this.FormClosing += Program.ApplicationQuit;
            this.MouseWheel += new MouseEventHandler(tb_MouseWheel);
            Module currentModule = Program.p.currentModule;
            this.Size = Program.currentSize;
            this.Location = Program.currentLocation;
            label2.Text = Program.p.CurrentFullName;
            string[] modulePaths = {};
            try
            {
                modulePaths = Directory.GetDirectories(@"modules/" + currentModule._filename + @"/");
            }
            catch (NullReferenceException)
            {
                modulePaths = Directory.GetDirectories(@"modules/" + Program.p.currentModuleFilename + @"/");
            }
            // read
            tasks = new List<Task>();
            /*Task task01 = new Task("Космические шаттлы", "Есть шаттлы и космос", "Найдите ответ на все вопросы"); //(string name, string given, string toFind)
            task01._description = "Эта задача про космос и шаттлы";
            Task task02 = new Task("Космические звезды", "Есть звезды и космос", "Найдите ответ на все вопросы про здвезды"); //(string name, string given, string toFind)
            task02._description = "Задача о звездах и космос";*/

            //tasks.Add(task01);
            //tasks.Add(task02);
            for (int i = 0; i < modulePaths.Length; i++)
            {
                // MessageBox.Show(modulePaths[i] + @"/main.xml");
                Task tempTask = new Task(modulePaths[i] + @"/main.xml");
                tempTask._path = modulePaths[i] + @"/";
                tasks.Add(tempTask);
            }
            int ypos = 10;

            PictureBox addTask = new PictureBox();
            addTask.Cursor = Cursors.Hand;
            addTask.Size = new Size(780, 170);
            addTask.Location = new Point(0, ypos + 20);
            addTask.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(226)))), ((int)(((byte)(226)))), ((int)(((byte)(226)))));
            addTask.MouseEnter += new EventHandler(addTask_MouseEnter);
            addTask.MouseLeave += new EventHandler(addTask_MouseLeave);
            addTask.Click += new EventHandler(addTask_Click);
            addTask.Image = Properties.Resources.add_task;
            addTask.SizeMode = PictureBoxSizeMode.CenterImage;
            panelForElements.Controls.Add(addTask);
            ypos += 200;
            for (int i = 0; i < tasks.Count; i++)
            {
                Button btnDeleteTask = new Button();
                Button btnEditTaskEntity = new Button();
                Label title = new Label();
                Label description = new Label();
                PictureBox pbox = new PictureBox();

                pbox.Location = new Point(0, ypos);
                pbox.Size = new Size(430, 270);
                pbox.ImageLocation = tasks[i]._path + "mainpic.png";
                pbox.Cursor = Cursors.Hand;
                pbox.Tag = i;
                pbox.Click += btnEditTaskEntity_Click;

                title.Location = new Point(440, ypos);
                title.Text = tasks[i]._name;
                title.Font = new System.Drawing.Font("Segoe UI Light", 17F);
                title.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(101)))), ((int)(((byte)(101)))), ((int)(((byte)(101)))));
                title.Size = new System.Drawing.Size(340, 43);
                title.Tag = i;
                title.Cursor = Cursors.Hand;
                title.Click += btnEditTaskEntity_Click;

                description.Location = new Point(440, ypos + 40);
                description.Text = tasks[i]._description;
                description.Font = new System.Drawing.Font("Segoe UI Light", 10F);
                description.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(101)))), ((int)(((byte)(101)))), ((int)(((byte)(101)))));
                description.Size = new System.Drawing.Size(340, 189);
                description.Tag = i;
                description.Cursor = Cursors.Hand;
                description.Click += btnEditTaskEntity_Click;

                btnEditTaskEntity.Text = "Редактировать задание";
                btnEditTaskEntity.Location = new Point(448, ypos + 238);
                btnEditTaskEntity.Size = new Size(162, 31);
                btnEditTaskEntity.Anchor = System.Windows.Forms.AnchorStyles.Top;
                btnEditTaskEntity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(103)))), ((int)(((byte)(103)))), ((int)(((byte)(103)))));
                btnEditTaskEntity.Cursor = System.Windows.Forms.Cursors.Hand;
                btnEditTaskEntity.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(103)))), ((int)(((byte)(103)))), ((int)(((byte)(103)))));
                btnEditTaskEntity.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
                btnEditTaskEntity.Font = new System.Drawing.Font("Segoe UI Light", 10F);
                btnEditTaskEntity.ForeColor = System.Drawing.Color.White;
                btnEditTaskEntity.UseVisualStyleBackColor = false;
                btnEditTaskEntity.Click += new EventHandler(btnEditTaskEntity_Click);
                btnEditTaskEntity.Tag = i;

                btnDeleteTask.Text = "Удалить задание";
                btnDeleteTask.Location = new Point(624, ypos + 238);
                btnDeleteTask.Size = new Size(162, 31);
                btnDeleteTask.Anchor = System.Windows.Forms.AnchorStyles.Top;
                btnDeleteTask.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(103)))), ((int)(((byte)(103)))), ((int)(((byte)(103)))));
                btnDeleteTask.Cursor = System.Windows.Forms.Cursors.Hand;
                btnDeleteTask.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(103)))), ((int)(((byte)(103)))), ((int)(((byte)(103)))));
                btnDeleteTask.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
                btnDeleteTask.Font = new System.Drawing.Font("Segoe UI Light", 10F);
                btnDeleteTask.ForeColor = System.Drawing.Color.White;
                btnDeleteTask.UseVisualStyleBackColor = false;
                btnDeleteTask.Click += new EventHandler(btnDeleteTask_Click);
                btnDeleteTask.Tag = i;

                panelForElements.Controls.Add(title);
                panelForElements.Controls.Add(description);
                panelForElements.Controls.Add(pbox);
                panelForElements.Controls.Add(btnEditTaskEntity);
                panelForElements.Controls.Add(btnDeleteTask);

                // Если название не помещается в одну строку, то сдвигаем описание ниже
                // description.Location = new Point(description.Location.X, description.Location.Y + (title.Size.Height - 31));
                ypos += 300;
            }
            panelForElements.Focus();
        }