Option.xaml.cs
上传用户:jxqhsy
上传日期:2020-12-31
资源大小:1793k
文件大小:4k
源码类别:

SilverLight

开发平台:

HTML/CSS

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Shapes;
  12. namespace SFGS
  13. {
  14.     public partial class Option : UserControl
  15.     {
  16.         public Option()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.         public Option(string groupName)
  21.         {
  22.             InitializeComponent();
  23.             this.rbA.GroupName = groupName;
  24.             this.rbB.GroupName = groupName;
  25.             this.rbC.GroupName = groupName;
  26.             this.rbD.GroupName = groupName;
  27.         }
  28.         public Option(string serialNumber, string questionName, string optionA, string optionB, string optionC, string optionD,string groupName)
  29.         {
  30.             InitializeComponent();
  31.             this.txtSerialNumber.Text = serialNumber + ".";
  32.             this.txtQuestionName.Text = questionName;
  33.             this.rbA.Content = optionA;
  34.             this.rbB.Content = optionB;
  35.             this.rbC.Content = optionC;
  36.             this.rbD.Content = optionD;
  37.             this.rbA.GroupName = groupName;
  38.             this.rbB.GroupName = groupName;
  39.             this.rbC.GroupName = groupName;
  40.             this.rbD.GroupName = groupName;
  41.         }
  42.         public string SerialNumber
  43.         {
  44.             get { return this.txtSerialNumber.Text.Trim().Substring(0, this.txtSerialNumber.Text.Trim().Length - 1); }
  45.             set { this.txtSerialNumber.Text = value + "."; }
  46.         }
  47.         public string QuestionName
  48.         {
  49.             get { return this.txtQuestionName.Text.Trim(); }
  50.             set { this.txtQuestionName.Text = value; }
  51.         }
  52.         public string OptionA
  53.         {
  54.             get { return this.rbA.Content.ToString().Trim(); }
  55.             set { this.rbA.Content = value; }
  56.         }
  57.         public string OptionB
  58.         {
  59.             get { return this.rbB.Content.ToString().Trim(); }
  60.             set { this.rbB.Content = value; }
  61.         }
  62.         public string OptionC
  63.         {
  64.             get { return this.rbC.Content.ToString().Trim(); }
  65.             set { this.rbC.Content = value; }
  66.         }
  67.         public string OptionD
  68.         {
  69.             get { return this.rbD.Content.ToString().Trim(); }
  70.             set { this.rbD.Content = value; }
  71.         }
  72.         public string DefaultOption
  73.         {
  74.             set
  75.             {
  76.                 switch(value.ToUpper())
  77.                 {
  78.                     case "A":
  79.                         this.rbA.IsChecked = true;
  80.                         break;
  81.                     case "B":
  82.                         this.rbB.IsChecked = true;
  83.                         break;
  84.                     case "C":
  85.                         this.rbC.IsChecked = true;
  86.                         break;
  87.                     case "D":
  88.                         this.rbD.IsChecked = true;
  89.                         break;
  90.                     default:
  91.                         this.rbA.IsChecked = true;
  92.                         break;
  93.                 }
  94.             }
  95.         }
  96.         public string GroupName
  97.         {
  98.             set
  99.             {
  100.                 this.rbA.GroupName = value;
  101.                 this.rbB.GroupName = value;
  102.                 this.rbC.GroupName = value;
  103.                 this.rbD.GroupName = value;
  104.             }
  105.             get
  106.             {
  107.                 return this.rbA.GroupName;
  108.             }
  109.         }
  110.         public string Checked
  111.         {
  112.             get
  113.             {
  114.                 if (this.rbA.IsChecked==true)
  115.                 {
  116.                     return "A";
  117.                 }
  118.                 else if(this.rbB.IsChecked==true)
  119.                 {
  120.                     return "B";
  121.                 }
  122.                 else if(this.rbC.IsChecked==true)
  123.                 {
  124.                     return "C";
  125.                 }
  126.                 else
  127.                 {
  128.                     return "D";
  129.                 }
  130.             }
  131.         }
  132.     }
  133. }