public Question FindQuestion(Question question,QuestionGroup questionGroup) { Question foundQuestion = questionGroup.Questions.SingleOrDefault(q => q.Id == question.Id); if (foundQuestion != null) { return foundQuestion; } throw new Exception("kunne ikke finde dit spørgsmål i filtret"); }
public Answer FindAnswer(Question question, int answerId) { Answer foundAnswer = question.Answers.Single(a => a.Id == answerId); if (foundAnswer != null) { return foundAnswer; } throw new SearchException("Fejl i FilterLinqSearch:FindAnswer.Kunne ikke finde Answer id "+answerId+" i question "+question.Title); }
public Answer FindAnswer(Question question, int answerId) { try { return Search.FindAnswer(question, answerId); } catch (Exception ex) { throw ex; } }
public bool IsCopy(Question question) { try { rows.Single(r => r.QuestionObject.Rank == question.Rank); return true; } catch { return false; } }
public AnswerView(MainWindow mainWindow,QuestionGroup questionGroup, Question question) { InitializeComponent(); //AnimationClass.fadeOut(viewGrid, 0); AnimationClass.fadeIn(viewGrid, MainWindow.AnimationSpeed); this.mainWindow = mainWindow; this.questionGroup = questionGroup; this.question = question; TitleLabel.Content = "Svarmulighed til " + question.Title; AnswerListBox.ItemsSource = question.Answers.OrderBy(o => o.Rank).ToList(); }
public RowEntity addRow(decimal decimalRank,Question question,bool textBox = false) { int rank = calcRank(decimalRank); createNewRowDefinition(); if (rank < grid.Children.Count -2) { clearMyRow(rank); } RowEntity newRow = new RowEntity(rank, grid, question, textBox); rows.Add(newRow); return newRow; }
public void RemoveRow(Question question) { RowEntity rowToRemove = rows.Single(r => r.QuestionObject.Rank == question.Rank); grid.Children.Remove(rowToRemove.AnswerComboBox); grid.Children.Remove(rowToRemove.QuestionLabel); rows.Remove(rowToRemove); int emptyRank = rowToRemove.Rank; int count = rows.Count; int rowRankToMove = count - emptyRank +1; int x = 1; while (rowRankToMove >= x) { RowEntity rowToMove = rows.Single(r => r.Rank == (x+emptyRank)); rowToMove.Rank = x + emptyRank - 1; Grid.SetRow(rowToMove.AnswerComboBox, rowToMove.Rank); Grid.SetRow(rowToMove.QuestionLabel, rowToMove.Rank); x++; } }
private void CreateNewAnswer(string title, decimal rank, string value, Question question = null) { try { this.question.Answers.Add(new Answer() { Rank = rank, Title = title, Value = value, Question = this.question, Required = question }); saveAndUpdate(); } catch (Exception ex) { mainWindow.ShowError(ex.Message, true); } }
public RowEntity(int row, Grid grid, Question question, bool textBox = false) { Rank = row; QuestionObject = question; QuestionLabel = new TextBlock(); QuestionLabel.Text = question.Title; QuestionLabel.FontSize = 12; QuestionLabel.Height = 30; QuestionLabel.FontWeight = FontWeights.Bold; Grid.SetRow(QuestionLabel, row); Grid.SetColumn(QuestionLabel, 0); grid.Children.Add(QuestionLabel); if (!textBox) { AnswerComboBox = new ComboBox(); AnswerComboBox.Height = 25; AnswerComboBox.Margin = new Thickness(0, 0, 20, 0); AnswerComboBox.Uid = question.Rank.ToString(); AnswerComboBox.ItemsSource = question.Answers; int x = 0; if (question.Default != null) { foreach (Answer a in question.Answers) { if (question.Default.Title == a.Title) { question.Value = a; AnswerComboBox.SelectedIndex = x; break; } x++; } } else if (question.Answers.Count == 1) { AnswerComboBox.SelectedIndex = 0; question.Value = question.Answers.First(); } Grid.SetRow(AnswerComboBox, row); Grid.SetColumn(AnswerComboBox, 1); grid.Children.Add(AnswerComboBox); AnswerComboBox.AddHandler(ComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(selectionChange)); } else { TextBox tb = new TextBox(); tb.Height = 25; tb.Margin = new Thickness(0, 0, 20, 0); Grid.SetRow(tb, row); Grid.SetColumn(tb, 1); grid.Children.Add(tb); AnswerTextBox = tb; } }
// Window event private void CreateNewQuestionWindow(string printTitle,string title, decimal rank, Question required = null) { try { questionGroup.Questions.Add(new Question() { PrintTitle = printTitle, Title = title, Rank = rank, QuestionGroup = questionGroup, Required = required }); updateListViewAndSave(); } catch (Exception ex) { mainWindow.ShowError(ex.Message, true); } }