Exemple #1
0
        private void btnDetails_Click(object sender, EventArgs e)
        {
            if (treeViewLTList.SelectedNode == null)
            {
                return;
            }

            DockContent detailsForm = null;

            if (treeViewLTList.SelectedNode.Tag is CurriculumNode)
            {
                CurriculumNode curr = treeViewLTList.SelectedNode.Tag as CurriculumNode;
                detailsForm      = new SchoolCurrDetailsForm(curr);
                detailsForm.Text = curr.Text;
            }
            else if (treeViewLTList.SelectedNode.Tag is LearningTaskNode)
            {
                LearningTaskNode node = treeViewLTList.SelectedNode.Tag as LearningTaskNode;
                detailsForm      = new SchoolTaskDetailsForm(node.TaskType);
                detailsForm.Text = node.Text;
            }
            if (detailsForm != null)
            {
                OpenFloatingOrActivate(detailsForm, DockPanel);
            }
        }
Exemple #2
0
        private void tree_DragOver(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(TreeNodeAdv[])) && treeViewLTList.DropPosition.Node != null)
            {
                TreeNodeAdv draggedNode = (e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[]).First();
                TreeNodeAdv parent      = treeViewLTList.DropPosition.Node;
                if (treeViewLTList.DropPosition.Position != NodePosition.Inside)
                {
                    parent = parent.Parent;
                }

                if (IsNodeAncestor(draggedNode, parent))
                {
                    e.Effect = DragDropEffects.None;
                    return;
                }

                CurriculumNode   curr = draggedNode.Tag as CurriculumNode;
                LearningTaskNode lt   = draggedNode.Tag as LearningTaskNode;

                if (curr != null && parent.Level > 0) // curriculum can only be moved - not set as someone's child
                {
                    e.Effect = DragDropEffects.None;
                }
                else if (lt != null && parent.Level != 1)    //LT can only be in curriculum. Not in root, not in other LT
                {
                    e.Effect = DragDropEffects.None;
                }
                else
                {
                    e.Effect = e.AllowedEffect;
                }
            }
        }
Exemple #3
0
        public static CurriculumNode FromCurriculumDesign(CurriculumDesign design)
        {
            CurriculumNode node = new CurriculumNode {
                Text = design.Name, IsChecked = design.Enabled, Description = design.Description
            };

            design.Tasks.Where(x => LearningTaskNode.FromLTDesign(x) != null).ToList().ForEach(x => node.Nodes.Add(LearningTaskNode.FromLTDesign(x)));
            return(node);
        }
Exemple #4
0
        private void btnNewTask_Click(object sender, EventArgs e)
        {
            if (treeViewLTList.SelectedNode == null)
            {
                return;
            }

            AddTaskView = new LearningTaskSelectionForm();
            AddTaskView.StartPosition = FormStartPosition.CenterParent;
            AddTaskView.ShowDialog(this);
            if (AddTaskView.ResultLearningTaskTypes == null)
            {
                return;
            }

            List <LearningTaskNode> newLearningTaskNodes = new List <LearningTaskNode>();

            foreach (Tuple <Type, Type> learningTaskInfo in AddTaskView.ResultLearningTaskTypes)
            {
                newLearningTaskNodes.Add(new LearningTaskNode(learningTaskInfo.Item1, learningTaskInfo.Item2));
            }
            //LearningTaskNode task = new LearningTaskNode(AddTaskView.ResultTaskType, AddTaskView.ResultWorldType);

            if (newLearningTaskNodes.Count > 0)
            {
                if (treeViewLTList.SelectedNode.Tag is CurriculumNode)
                {
                    foreach (LearningTaskNode node in newLearningTaskNodes)
                    {
                        (treeViewLTList.SelectedNode.Tag as Node).Nodes.Add(node);
                    }
                    treeViewLTList.SelectedNode.IsExpanded = true;
                }
                else if (treeViewLTList.SelectedNode.Tag is LearningTaskNode)
                {
                    LearningTaskNode source = treeViewLTList.SelectedNode.Tag as LearningTaskNode;
                    int targetPosition      = source.Parent.Nodes.IndexOf(source);
                    foreach (LearningTaskNode node in newLearningTaskNodes)
                    {
                        source.Parent.Nodes.Insert(++targetPosition, node);
                    }
                }
            }
        }
Exemple #5
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            Invoke((MethodInvoker)(() =>
            {
                LearningTaskNode ltNode = SelectedLearningTask;

                // if no selection, clear table and return
                if (ltNode == null)
                {
                    tabControlLevels.TabPages.Clear();
                    prevGridViewSelection = null;
                    return;
                }
                // if there is no change, do nothing
                if (ltNode.Equals(prevGridViewSelection))
                {
                    return;
                }
                prevGridViewSelection = ltNode;

                //
                // LT text hint
                //

                richTextBoxLTInfo.Clear();

                const string HTML_DIRECTORY = @"Resources\html";
                string htmlFileName = (ltNode as LearningTaskNode).TaskType.Name + ".html";
                string fullPath = MyResources.GetMyAssemblyPath() + "\\" + HTML_DIRECTORY + "\\" + htmlFileName;


                if (File.Exists(fullPath))
                {
                    // Create a file to write to.
                    string htmlPage = File.ReadAllText(fullPath);

                    string name = System.Text.RegularExpressions.Regex.Match(htmlPage, "<title>.*</title>").ToString();
                    if (name.Length > 0)
                    {
                        name = name.Split('>', '<')[2];
                    }
                    richTextBoxLTInfo.AppendText(name + "\r\n\r\n");
                    richTextBoxLTInfo.SelectAll();
                    richTextBoxLTInfo.SelectionFont = new Font(richTextBoxLTInfo.Font, FontStyle.Bold);

                    string description = System.Text.RegularExpressions.Regex.Match(htmlPage,
                                                                                    "Description(.*?)<td(.*?)</td>", System.Text.RegularExpressions.RegexOptions.Singleline).ToString();
                    if (description.Length > 0)
                    {
                        description = description.Split('>', '<')[4];
                    }
                    description = description.Replace(System.Environment.NewLine, "");
                    richTextBoxLTInfo.AppendText(description);
                }

                //
                // LVL tab
                //
                tabControlLevels.TabPages.Clear();

                Type ltType = ltNode.TaskType;
                ILearningTask lt = LearningTaskFactory.CreateLearningTask(ltType);
                TrainingSetHints hints = lt.TSProgression[0];

                Levels = new List <LevelNode>();
                LevelGrids = new List <DataGridView>();
                Attributes = new List <List <AttributeNode> >();
                AttributesChange = new List <List <int> >();

                for (int i = 0; i < lt.TSProgression.Count; i++)
                {
                    // create tab
                    LevelNode ln = new LevelNode(i + 1);
                    Levels.Add(ln);
                    TabPage tp = new TabPage(ln.Text);
                    tabControlLevels.TabPages.Add(tp);

                    // create grid
                    DataGridView dgv = new DataGridView();

                    dgv.Parent = tp;
                    dgv.Margin = new Padding(3);
                    dgv.Dock = DockStyle.Fill;
                    dgv.RowHeadersVisible = false;
                    dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                    dgv.AllowUserToResizeRows = false;
                    // create attributes
                    Attributes.Add(new List <AttributeNode>());
                    if (i > 0)
                    {
                        hints.Set(lt.TSProgression[i]);
                    }
                    foreach (var attribute in hints)
                    {
                        AttributeNode an = new AttributeNode(attribute.Key, attribute.Value);
                        Attributes[i].Add(an);
                        // create tooltips
                    }

                    Attributes[i].Sort(Comparer <AttributeNode> .Create((x, y) => x.Name.CompareTo(y.Name)));
                    dgv.DataSource = Attributes[i];

                    dgv.Columns[0].Width = 249;
                    dgv.Columns[0].ReadOnly = true;
                    dgv.Columns[1].ReadOnly = true;

                    AttributesChange.Add(new List <int>());
                    if (i > 0)
                    {
                        foreach (var attribute in lt.TSProgression[i])
                        {
                            int attributeIdx = Attributes[i].IndexOf(new AttributeNode(attribute.Key.Name));
                            AttributesChange[i].Add(attributeIdx);
                        }
                    }

                    LevelGrids.Add(dgv);
                    dgv.ColumnWidthChanged += levelGridColumnSizeChanged;
                    dgv.CellFormatting += levelGrid_CellFormatting;
                    dgv.SelectionChanged += levelGrid_SelectionChanged;
                    dgv.ClearSelection();

                    tabControlLevels.Update();
                }
            }
                                   ));
        }
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            Invoke((MethodInvoker)(() =>
            {

                LearningTaskNode ltNode = SelectedLearningTask;

                // if no selection, clear table and return
                if (ltNode == null)
                {
                    tabControlLevels.TabPages.Clear();
                    prevGridViewSelection = null;
                    return;
                }
                // if there is no change, do nothing
                if (ltNode.Equals(prevGridViewSelection))
                {
                    return;
                }
                prevGridViewSelection = ltNode;

                //
                // LT text hint
                //

                richTextBoxLTInfo.Clear();

                const string HTML_DIRECTORY = @"Resources\html";
                string htmlFileName = (ltNode as LearningTaskNode).TaskType.Name + ".html";
                string fullPath = MyResources.GetMyAssemblyPath() + "\\" + HTML_DIRECTORY + "\\" + htmlFileName;


                if (File.Exists(fullPath))
                {
                    // Create a file to write to.
                    string htmlPage = File.ReadAllText(fullPath);

                    string name = System.Text.RegularExpressions.Regex.Match(htmlPage, "<title>.*</title>").ToString();
                    if (name.Length > 0)
                    {
                        name = name.Split('>', '<')[2];
                    }
                    richTextBoxLTInfo.AppendText(name + "\r\n\r\n");
                    richTextBoxLTInfo.SelectAll();
                    richTextBoxLTInfo.SelectionFont = new Font(richTextBoxLTInfo.Font, FontStyle.Bold);

                    string description = System.Text.RegularExpressions.Regex.Match(htmlPage,
                        "Description(.*?)<td(.*?)</td>", System.Text.RegularExpressions.RegexOptions.Singleline).ToString();
                    if (description.Length > 0)
                    {
                        description = description.Split('>', '<')[4];
                    }
                    description = description.Replace(System.Environment.NewLine, "");
                    richTextBoxLTInfo.AppendText(description);
                }

                //
                // LVL tab
                //
                tabControlLevels.TabPages.Clear();

                Type ltType = ltNode.TaskType;
                ILearningTask lt = LearningTaskFactory.CreateLearningTask(ltType);
                TrainingSetHints hints = lt.TSProgression[0];

                Levels = new List<LevelNode>();
                LevelGrids = new List<DataGridView>();
                Attributes = new List<List<AttributeNode>>();
                AttributesChange = new List<List<int>>();

                for (int i = 0; i < lt.TSProgression.Count; i++)
                {
                    // create tab
                    LevelNode ln = new LevelNode(i + 1);
                    Levels.Add(ln);
                    TabPage tp = new TabPage(ln.Text);
                    tabControlLevels.TabPages.Add(tp);

                    // create grid
                    DataGridView dgv = new DataGridView();

                    dgv.Parent = tp;
                    dgv.Margin = new Padding(3);
                    dgv.Dock = DockStyle.Fill;
                    dgv.RowHeadersVisible = false;
                    dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                    dgv.AllowUserToResizeRows = false;
                    // create attributes
                    Attributes.Add(new List<AttributeNode>());
                    if (i > 0)
                    {
                        hints.Set(lt.TSProgression[i]);
                    }
                    foreach (var attribute in hints)
                    {
                        AttributeNode an = new AttributeNode(attribute.Key, attribute.Value);
                        Attributes[i].Add(an);
                        // create tooltips
                    }

                    Attributes[i].Sort(Comparer<AttributeNode>.Create((x, y) => x.Name.CompareTo(y.Name)));
                    dgv.DataSource = Attributes[i];

                    dgv.Columns[0].Width = 249;
                    dgv.Columns[0].ReadOnly = true;
                    dgv.Columns[1].ReadOnly = true;

                    AttributesChange.Add(new List<int>());
                    if (i > 0)
                    {
                        foreach (var attribute in lt.TSProgression[i])
                        {
                            int attributeIdx = Attributes[i].IndexOf(new AttributeNode(attribute.Key.Name));
                            AttributesChange[i].Add(attributeIdx);
                        }
                    }

                    LevelGrids.Add(dgv);
                    dgv.ColumnWidthChanged += levelGridColumnSizeChanged;
                    dgv.CellFormatting += levelGrid_CellFormatting;
                    dgv.SelectionChanged += levelGrid_SelectionChanged;
                    dgv.ClearSelection();

                    tabControlLevels.Update();
                }
            }
            ));
        }