示例#1
0
 public StdDescriptor GetData()
 {
     try
     {
         if (!checkBoxUseOwnData.Checked)
         {
             return(null);
         }
         string   descriptor  = textarB_discriptor.Text.Trim().Replace(',', ',').Replace(",", " ");
         string[] arB_desdata = descriptor.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
         byte[]   arB_byte    = new byte[arB_desdata.Length];
         for (int i = 0; i < arB_desdata.Length; i++)
         {
             arB_byte[i] = Convert.ToByte(arB_desdata[i], 16);
         }
         if (arB_byte.Length == 0)
         {
             arB_byte    = new byte[1];
             arB_byte[0] = 0;
         }
         StdDescriptor Descriptor2 = new StdDescriptor
         {
             B_descriptor_tag = (byte)cbBoxB_discriptor_tag.SelectedValue,
             Br_descriptor    = arB_byte,
         };
         return(Descriptor2);
     }
     catch
     {
         return(null);
     }
 }
示例#2
0
 public void InitData(StdDescriptor des, bool canEdit = true)
 {
     Enabled = canEdit;
     try
     {
         cbBoxB_discriptor_tag.SelectedValue = des.B_descriptor_tag;
         string ar = string.Empty;
         for (int i = 0; i < des.Br_descriptor.Length; i++)
         {
             ar += Convert.ToString(des.Br_descriptor[i], 16).PadLeft(2, '0').ToUpper() + " ";
         }
         textarB_discriptor.Text = ar;
         if (des != null)
         {
             checkBoxUseOwnData.Checked = true;
             checkBoxUseOwnData_CheckedChanged(checkBoxUseOwnData, EventArgs.Empty);
         }
     }
     catch
     {
     }
 }