private void AddPracticeButton_Click(object sender, EventArgs e)
        {
            var task = new TaskControl();

            task.SetPractice();
            LayoutTask(task);
        }
 private void LayoutTask(TaskControl task)
 {
     task.SuspendLayout();
     TasksPanel.Controls.Add(task);
     TasksPanel.ScrollControlIntoView(task);
     task.ResumeLayout();
     task.Width = TasksPanel.ClientSize.Width - 10;
 }
        private void AddTextBlockButtonClick(object sender, EventArgs e)
        {
            var task = new TaskControl();

            task.SetInformational();

            LayoutTask(task);
        }
        private void AddExampleButtonClick(object sender, EventArgs e)
        {
            var task = new TaskControl();

            task.SetExample();

            LayoutTask(task);
        }
        private void OpenCopyTask()
        {
            // Create an instance of the open file dialog box.
            var ofd = new OpenFileDialog
            {
                Filter      = "Text Files (.txt)|*.txt|All Files (*.*)|*.*",
                FilterIndex = 1,
                Multiselect = false
            };

            // Set filter options and filter index.

            // Call the ShowDialog method to show the dialog box.
            var dialogResult = ofd.ShowDialog();

            // Process input if the user clicked OK.
            if (dialogResult == DialogResult.OK)
            {
                ClearAllFields();

                StreamReader inputReader = null;
                try
                {
                    // Open the selected file to read.
                    var tasksXML = new XmlDocument();
                    inputReader = new StreamReader(ofd.FileName, Encoding.UTF8);
                    tasksXML.Load(inputReader);

                    FileDirectory = Path.GetDirectoryName(ofd.FileName);

                    txtGeneralInstructions.Text   = XMLUtil.GetChildNodeValue(tasksXML["copytask"], "general_instructions");
                    txtGeneralTitle.Text          = XMLUtil.GetChildNodeValue(tasksXML["copytask"], "title");
                    txtGeneralDescription.Text    = XMLUtil.GetChildNodeValue(tasksXML["copytask"], "description");
                    LanguageComboBox.SelectedItem = XMLUtil.GetChildNodeValue(tasksXML["copytask"], "language");

                    var taskNodes = tasksXML.DocumentElement.SelectNodes("task");

                    // Create a TaskControl object for each task node in xml document and add it to the taskspanel.
                    if (taskNodes != null)
                    {
                        foreach (XmlNode node in taskNodes)
                        {
                            var task = new TaskControl(node);
                            TasksPanel.Controls.Add(task);
                            TasksPanel.ScrollControlIntoView(task);
                            task.Width = TasksPanel.ClientSize.Width - 10;
                        }

                        _isExisting = true;
                    }
                }
                finally
                {
                    inputReader?.Close();
                }
            }
        }