private void update_level_description(string tag, int level) { int idx; for (idx = 0; idx < grdEvaluationScheme.Children.Count; idx++) { UIElement ui_element = grdEvaluationScheme.Children[idx]; if (ui_element is TextBox) { TextBox txt = (TextBox)ui_element; if (txt.Tag != null) { _log.Info(" textbox " + txt.Tag.ToString()); if (txt.Tag.ToString() == tag) { _log.Info("Found textbox " + txt.Tag.ToString()); if (level < 0) { txt.Text = ""; txt.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); } else { int chapter_idx = 0; int section_idx = 0; StudentEvaluationItem.DecodeTag(tag, out chapter_idx, out section_idx); string level_description = DataContainer.Instance.EvaluationScheme.GetLevelDescription(chapter_idx, section_idx, level); txt.Text = level_description; txt.Background = new SolidColorBrush(EvaluationLevel.GetLevelColor(level)); } return; } } } } }
private void on_set_evaluation_scheme() { int chapter_idx = 0; int section_idx = 0; int grid_row = 0; RowDefinition rd; TextBox tb; ComboBox cmb; int idx; // Load evaluation scheme info on UI _loading_evaluation_scheme = true; grdEvaluationScheme.Children.Clear(); grdEvaluationScheme.RowDefinitions.Clear(); if (_evaluation_scheme == null) { return; } foreach (EvaluationChapter chapter in _evaluation_scheme.Chapters) { // Chapter title rd = new RowDefinition(); rd.Height = GridLength.Auto; grdEvaluationScheme.RowDefinitions.Add(rd); tb = new TextBox(); tb.Text = (chapter_idx + 1).ToString() + ". " + chapter.Name; tb.TextWrapping = TextWrapping.Wrap; tb.IsReadOnly = true; tb.FontSize = 22; tb.SetValue(TextBlock.FontWeightProperty, FontWeights.Bold); tb.BorderThickness = new Thickness(0, 0, 0, 1); //tb.Background = new SolidColorBrush(Color.FromRgb(240, 240, 240)); tb.Padding = new Thickness(0, 2, 0, 2); tb.Margin = new Thickness(3, 40, 3, 3); grdEvaluationScheme.Children.Add(tb); Grid.SetRow(tb, grid_row); grid_row++; // Chapter description rd = new RowDefinition(); rd.Height = GridLength.Auto; grdEvaluationScheme.RowDefinitions.Add(rd); tb = new TextBox(); tb.Text = chapter.Description; tb.TextWrapping = TextWrapping.Wrap; tb.IsReadOnly = true; tb.FontSize = 12; tb.BorderThickness = new Thickness(0); grdEvaluationScheme.Children.Add(tb); Grid.SetRow(tb, grid_row); grid_row++; // Sections section_idx = 0; foreach (EvaluationSection sec in chapter.Sections) { // Section title (name) rd = new RowDefinition(); rd.Height = GridLength.Auto; grdEvaluationScheme.RowDefinitions.Add(rd); tb = new TextBox(); tb.Text = (chapter_idx + 1).ToString() + "." + (section_idx + 1).ToString() + ". " + sec.Name; tb.TextWrapping = TextWrapping.Wrap; tb.IsReadOnly = true; tb.FontSize = 14; tb.SetValue(TextBlock.FontWeightProperty, FontWeights.Bold); tb.BorderThickness = new Thickness(0); tb.Margin = new Thickness(3, 20, 3, 3); grdEvaluationScheme.Children.Add(tb); Grid.SetRow(tb, grid_row); grid_row++; // Section description rd = new RowDefinition(); rd.Height = GridLength.Auto; grdEvaluationScheme.RowDefinitions.Add(rd); tb = new TextBox(); tb.Text = sec.Description; tb.TextWrapping = TextWrapping.Wrap; tb.IsReadOnly = true; tb.FontSize = 12; tb.BorderThickness = new Thickness(0); grdEvaluationScheme.Children.Add(tb); Grid.SetRow(tb, grid_row); grid_row++; // Level rd = new RowDefinition(); rd.Height = GridLength.Auto; grdEvaluationScheme.RowDefinitions.Add(rd); cmb = new ComboBox(); cmb.Tag = StudentEvaluationItem.EncodeTag(chapter_idx, section_idx); _log.Info("Create combobox tag " + cmb.Tag.ToString()); cmb.Width = 160; cmb.Margin = new Thickness(3, 3, 3, 3); cmb.SelectionChanged += Cmb_SelectionChanged; cmb.HorizontalAlignment = HorizontalAlignment.Left; for (idx = 0; idx < sec.Levels.Count; idx++) { ComboBoxItem i = new ComboBoxItem(); i.Tag = sec.Levels[idx].Level; i.Content = "Livello " + sec.Levels[idx].Level.ToString() + " " + EvaluationLevel.GetLevelDescription(sec.Levels[idx].Level); cmb.Items.Add(i); } grdEvaluationScheme.Children.Add(cmb); Grid.SetRow(cmb, grid_row); grid_row++; // Level description rd = new RowDefinition(); rd.Height = GridLength.Auto; grdEvaluationScheme.RowDefinitions.Add(rd); tb = new TextBox(); tb.Text = ""; tb.Tag = StudentEvaluationItem.EncodeTag(chapter_idx, section_idx); _log.Info("Create textbox tag " + tb.Tag.ToString()); tb.TextWrapping = TextWrapping.Wrap; tb.IsReadOnly = true; tb.FontStyle = FontStyles.Italic; tb.FontSize = 12; tb.BorderThickness = new Thickness(0); grdEvaluationScheme.Children.Add(tb); Grid.SetRow(tb, grid_row); grid_row++; section_idx++; } chapter_idx++; } rd = new RowDefinition(); grdEvaluationScheme.RowDefinitions.Add(rd); _loading_evaluation_scheme = false; }