public Export_to_Pdf()
 {
     InitializeComponent();
     //Create object for pdf.
     document = new PdfDocument();
     page = document.AddPage();
     gfx = XGraphics.FromPdfPage(page);
     //Set by default values.
     font = new XFont("Arial", 12, XFontStyle.Regular);
     header_font = new XFont("Arial", 12, XFontStyle.Regular);
     page.Size = PageSize.A4;
     page.Orientation = PageOrientation.Portrait;
     //////////////////////////////////////////////////////////////////////
     //Create a fake questionanire to test the print process to pdf.
     if (questionaire != null)
     {
         List<Question> question_list = new List<Question>();
         List<Answer> answer_list = new List<Answer>();
         Answer ans = new Answer();
         ans.Answer_descr = "einai to dsfgdsfgsd";
         answer_list.Add(ans);
         answer_list.Add(ans);
         answer_list.Add(ans);
         Question quest = new Question() { AnswerList = answer_list };
         quest.Question_descr = "H ekfoonisi tis erotisis aytis einai blablbalbablbalblab";
         for (int i = 0; i < 10; i++)
         {
             question_list.Add(quest);
         }
     questionaire = new Quastionnaire.Model.Questionaire() { Questionaire_descr = "sdfsakdfjdflshsadflkjashflasdfkh", QuestionList = question_list };
     }
     //////////////////////////////////////////////////////////////////////
 }
        private void initialize_question(Quastionnaire.Model.Questionaire questionaire)
        {
            int number_of_erotiseis = 20;
            int number_of_answer = 4;
            //Dimiourgoume tin lista ton apantiseon.
            List<Answer> answs = new List<Answer>();
            Question quest = new Question() { AnswerList = answs};
            quest.Question_descr = "H ekfoonisi tis erotisis aytis einai blablbalbablbalblab";
            for (int i = 0; i < number_of_erotiseis; i++)
            {
                questionaire.QuestionList.Add(quest);
            }
            //MessageBox.Show(lst.Count().ToString());
            //Put the question in questionaire
            //questionaire.QuestionList.AddRange(lst);
            //List<int> deepCopy = new List<int>(originalList);
            MessageBox.Show(questionaire.QuestionList.Count.ToString());
            //List<Answer> answs = new List<Answer>();

            Answer ans = new Answer();
            ans.Answer_descr = "einai to dsfgdsfgsd";

            for (int i=0;i< questionaire.QuestionList.Count;i++)
            {
                for (int j = 0; j < number_of_answer; j++)
                {
                    questionaire.QuestionList.ElementAt(i).AnswerList.Add(ans);
                }
            }
        }
        private void btDelete_Answer_Click(object sender, RoutedEventArgs e)
        {
            lblAnswer_Description_msg.Visibility = Visibility.Hidden;
            lblCorrect_Answer_msg.Visibility = Visibility.Hidden;

            if (selected_Question == null)
            {
                MessageBox.Show("Select Question First", "Confirmation");
                return;
            }
            if (selected_Answer == null)
            {
                MessageBox.Show("Select Answer First", "Confirmation");
                return;
            }
            if (selected_Answer.Account.Username != CurrentUserInfo.USERNAME)
            {
                MessageBox.Show("Now Alloed is Not Yours", "Confirmation");
                return;
            }

            IAnswerDao answerDao = new AnswerDaoImpl();
            answerDao.deleteAnswer(selected_Answer);

            selected_Question.AnswerList.Remove(selected_Answer);
            lvAnswer.ItemsSource = null;
            lvAnswer.ItemsSource = selected_Question.AnswerList;

            clearAnswerWidgets();

            selected_Answer = null;
            MessageBox.Show("Answer Deleted", "Confirmation");
        }
        private void lvAnswer_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            lblAnswer_Description_msg.Visibility = Visibility.Hidden;
            lblCorrect_Answer_msg.Visibility = Visibility.Hidden;

            Answer answer = (Answer)lvAnswer.SelectedItem;

            if (answer == null)
                return;

            selected_Answer = answer;

            tbOwner_Answer.Text = answer.Account.Username.ToString();
            tbDate_Answer.Text = answer.Date.ToString();
            tbAnswer_Description.Text = answer.Answer_descr.ToString();
            cbCorrect_Answer.Text = answer.Correct.ToString();
        }
        private void clearAnswerWidgets()
        {
            lblAnswer_Description_msg.Visibility = Visibility.Hidden;
            lblCorrect_Answer_msg.Visibility = Visibility.Hidden;

            tbAnswer_Description.Clear();
            tbDate_Answer.Clear();
            tbOwner_Answer.Clear();

            selected_Answer = null;
        }
        //Answer ToolBAr
        private void btSave_Answer_Click(object sender, RoutedEventArgs e)
        {
            lblAnswer_Description_msg.Visibility = Visibility.Hidden;
            lblCorrect_Answer_msg.Visibility = Visibility.Hidden;

            if (selected_Question == null)
            {
                MessageBox.Show("Select Question First", "Confirmation");
                return;
            }
            if (selected_Question.Account.Username != CurrentUserInfo.USERNAME)
            {
                MessageBox.Show("Now Alloed is Not Yours", "Confirmation");
                return;
            }

            string answer_descr = tbAnswer_Description.Text;
            string correct = cbCorrect_Answer.Text;
            bool corrext_answer;
            int index_correct_answer = cbCorrect_Answer.SelectedIndex;

            if (checkAnswerForNullInput(answer_descr, correct))
            {
                MessageBox.Show("Empty", "Confirmation");
                return;
            }

            corrext_answer = index_correct_answer == 0 ? false : true;
            Answer answer = new Answer() { Answer_descr = answer_descr, Account = CurrentUserInfo.CURENT_ACCOUNT, Date = DateTime.Now, Correct = corrext_answer };

            IAnswerDao answerDao = new AnswerDaoImpl();
            answerDao.saveAnswer(answer, selected_Question.Id);

            if (selected_Question.AnswerList == null)
                selected_Question.AnswerList = new List<Answer>();

            selected_Question.AnswerList.Add(answer);
            lvAnswer.ItemsSource = null;
            lvAnswer.ItemsSource = selected_Question.AnswerList;

            selected_Answer = null;
            MessageBox.Show("Answer Saved", "Confirmation");
        }