Exemple #1
0
        private void DrawInstructions()  // Отрисовка инструкций к текущему заданию
        {
            //Instructions.Clear();
            string instructions = SelectedTask
                                  .Element("description")
                                  .Value.Trim('\n', '\t');

            Instructions = ParseToStackPanel(instructions);
            //Instructions = .Add( instructions );
        }
Exemple #2
0
        private void DrawSolutionLines()                            // Отрисовка строк решения из текущего задания
        {
            var externalSolutionLines = SelectedTask
                                        .Element("solution")
                                        .Descendants("line");

            SolutionLines.Clear();
            SolutionsNames.Clear();

            foreach (var line in externalSolutionLines)
            {
                StackPanel sp = new StackPanel()
                {
                    Orientation = Orientation.Horizontal, Margin = new Thickness(5)
                };
                foreach (var item in line.Descendants())
                {
                    if (item.Name == "text")
                    {
                        sp.Children.Add(ParseToStackPanel(item.Value));
                    }
                    else if (item.Name == "field")
                    {
                        TextBox tb = new TextBox()
                        {
                            Width = 60, VerticalAlignment = VerticalAlignment.Center
                        };
                        sp.Children.Add(tb);
                        if (item.Attribute("name") != null)
                        {
                            SolutionsNames.Add(item.Attribute("name").Value, tb);
                        }
                    }
                }
                SolutionLines.Add(sp);
            }
            checker = SelectedTask.Element("solution").Element("checker");
            ButtonCheckerVisibility = checker == null ? Visibility.Collapsed : Visibility.Visible;
        }
Exemple #3
0
        private void DrawDiagrams()  // Построение и отрисовка диаграм
        {
            Diagrams.Clear();

            var Xdiagrams = SelectedTask
                            .Element("diagrams");

            if (Xdiagrams == null)
            {
                ButtonDiagramsVisibility = Visibility.Collapsed;
                return;
            }

            var diagrams = Xdiagrams.
                           Descendants("diagram")
                           .Select(i => new
            {
                x = int.Parse(i.Element("x").Attribute("column").Value),
                y = int.Parse(i.Element("y").Attribute("column").Value),
            })
                           .ToArray();

            foreach (var diagram in diagrams)
            {
                if (diagram.x > DataTable.First().Count || diagram.y > DataTable.First().Count || diagram.x < 0 || diagram.y < 0)
                {
                    throw new XMLValidationException("Diagram value is bigger than length if the table or less than 0");
                }

                StackPanel spA = ParseToStackPanel(DataTable[0][diagram.x].Text);
                StackPanel spB = ParseToStackPanel(DataTable[0][diagram.y].Text);

                Diagram d = new Diagram(diagram.x, diagram.y, spA, spB);
                Diagrams.Add(d);
            }

            ButtonDiagramsVisibility = Diagrams.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
            UpdateDiagrams();
        }
Exemple #4
0
        private void DrawTaskTable()  // Отрисовка таблицы из текущего задания
        {
            var tableHeaders = SelectedTask
                               .Element("table")
                               .Descendants("column")
                               .Select(i => new
            {
                value = i.Value,
                ai    = i.Attribute("ai") == null ? false : i.Attribute("ai").Value == "true"                   // Автоинкремент
            })
                               .ToArray();

            int length;

            int.TryParse(SelectedTask.Element("table").Attribute("tests").Value, out length);

            DataTable.Clear();

            for (int i = 0; i < length + 1; i++)
            {
                ObservableCollection <TableCell> column = new ObservableCollection <TableCell>();

                for (int j = 0; j < tableHeaders.Count(); j++)
                {
                    var tableHeader = tableHeaders[j];
                    if (i == 0)
                    {
                        column.Add(new TableCell(tableHeader.value, ParseToStackPanel(tableHeader.value)));
                    }
                    else
                    {
                        column.Add(new TableCell(tableHeader.ai ? i.ToString() : ""));
                    }
                }

                DataTable.Add(column);
            }
        }