private void lbxSl_Selected(object sender, RoutedEventArgs e) { ListBoxItem i = sender as ListBoxItem; if (i == null) { return; } if (mBrd.vSl.ContainsKey(i.Content as string)) { return; } ExamSlot sl = new ExamSlot(); DateTime dt; DT.To_(mBrd.mDt.ToString(DT._) + ' ' + i.Content as string, DT.H, out dt); sl.Dt = dt; string emsg; if ((emsg = sl.DBSelRoomId()) != null) { WPopup.s.ShowDialog(emsg); return; } sl.DBSelStt(); sl.DBSelQPkR(); sl.DBSelNee(); if (sl.DBSelArchieve(out emsg)) { WPopup.s.ShowDialog(emsg); return; } Op0SlotView tbi = new Op0SlotView(sl); tbi.DeepCopy(tbcRefSl); tbi.ShowExaminee(); tbi.ShowQSHeader(); tbcSl.Items.Add(tbi); QuestSheet.DBUpdateCurQSId(mBrd.mDt); mBrd.vSl.Add(i.Content as string, sl); if ((tbi = tbcSl.SelectedItem as Op0SlotView) != null && tbi.mSl.eStt == ExamStt.Prep) { EnableQSGen(); } else { DisableQSGen(); } }
private void lbxNee_Selected(object sender, RoutedEventArgs e) { ListBoxItem i = sender as ListBoxItem; if (i == null) { return; } ExamineeS0 nee = new ExamineeS0(); List <TabItem> l = new List <TabItem>(); foreach (TabItem ti in tbcSl.Items) { if (!nee.ParseLvId(ti.Header as string)) { l.Add(ti); } } foreach (TabItem ti in l) { tbcSl.Items.Remove(ti); } if (nee.ParseLvId(i.Content as string)) { return; } TabItem tbi = new TabItem(); tbi.Header = i.Content; // nee.mDt = mBrd.mDt; int qsid = nee.DBGetQSId(); if (qsid < 0) { return; } QuestSheet qs = null; foreach (ExamSlot sl in mBrd.vSl.Values) { if (sl.vQPack[nee.eLv].vSheet.ContainsKey(qsid)) { qs = sl.vQPack[nee.eLv].vSheet[qsid]; break; } else if (sl.vQPackAlt[nee.eLv].vSheet.ContainsKey(qsid)) { qs = sl.vQPackAlt[nee.eLv].vSheet[qsid]; break; } } if (qs == null) { string t = nee.DBGetT(); if (!mBrd.vSl.ContainsKey(t)) { ExamSlot sl = new ExamSlot(); DateTime dati; DT.To_(mBrd.mDt.ToString(DT._) + ' ' + t, DT.HS, out dati); sl.Dt = dati; string emsg; if ((emsg = sl.DBSelRoomId()) != null) { WPopup.s.ShowDialog(emsg); return; } sl.DBSelStt(); sl.DBSelQPkR(); sl.DBSelNee(); if (sl.DBSelArchieve(out emsg)) { WPopup.s.ShowDialog(emsg); return; } mBrd.vSl.Add(t.Substring(0, 5), sl); // if (sl.vQPack[nee.eLv].vSheet.ContainsKey(qsid)) { qs = sl.vQPack[nee.eLv].vSheet[qsid]; } else if (sl.vQPackAlt[nee.eLv].vSheet.ContainsKey(qsid)) { qs = sl.vQPackAlt[nee.eLv].vSheet[qsid]; } } } if (qs == null) { return; } nee.DBSelGrade(); StackPanel spl = new StackPanel(); TextBlock tx = new TextBlock(); tx.Text = Txt.s._[(int)TxI.QS_ID] + ' ' + qs.tId + ", "; spl.Children.Add(tx); tx = new TextBlock(); tx.Text = Txt.s._[(int)TxI.MARK] + ' ' + nee.Grade; spl.Children.Add(tx); ScrollViewer svwr = new ScrollViewer(); svwr.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; StackPanel sp = new StackPanel(); int x = 0; SolidColorBrush evenbg = Theme.s._[(int)BrushId.BG]; SolidColorBrush oddbg = Theme.s._[(int)BrushId.Q_BG]; SolidColorBrush difbg = Theme.s._[(int)BrushId.Ans_TopLine]; SolidColorBrush bg; bool even = false; char[] ans = nee.DBGetAns(); int k = -1; foreach (Question q in qs.ShallowCopy()) { /*if (q.bDiff) * bg = difbg; * else*/if (even) { bg = evenbg; } else { bg = oddbg; } even = !even; TextBlock j = new TextBlock(); j.Width = tbcSl.Width - SystemParameters.ScrollWidth; j.TextWrapping = TextWrapping.Wrap; j.Text = ++x + ". " + q.Stmt; j.Background = bg; sp.Children.Add(j); for (int idx = 0; idx < Question.N_ANS; ++idx) { j = new TextBlock(); j.Width = tbcSl.Width - SystemParameters.ScrollWidth; j.TextWrapping = TextWrapping.Wrap; j.Text = ((char)('A' + idx)).ToString() + ") " + q.vAns[idx]; j.Background = bg; if (q.vKeys[idx]) { j.FontWeight = FontWeights.Bold; } if (ans[++k] == Question.C1) { j.Background = Theme.s._[(int)BrushId.Ans_Highlight]; } sp.Children.Add(j); } } svwr.Content = sp; svwr.Height = 560; spl.Children.Add(svwr); tbi.Content = spl; // tbcSl.Items.Add(tbi); }