Ejemplo n.º 1
0
    public static void BindToEnumValue <TEnum>(this ComboBox cbo, BindingSource bs, string propertyName)
    {
        cbo.DataSource = EnumPair <TEnum> .GetValuePairList();

        cbo.ValueMember   = EnumPair <TEnum> .ValueMember;
        cbo.DisplayMember = EnumPair <TEnum> .DisplayMember;
        cbo.DataBindings.Add(new Binding("SelectedValue", bs, propertyName));
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Generates a <see cref="List<T>"/> of the values
    /// of the <see cref="Enum"/> T.
    /// </summary>
    public static List <EnumPair <T> > GetValuePairList()
    {
        List <EnumPair <T> > list = new List <EnumPair <T> >();
        EnumPair <T>         pair = new EnumPair <T>();

        foreach (var item in Enum.GetValues(typeof(T)))
        {
            pair                 = new EnumPair <T>();
            pair.EnumValue       = (T)item;
            pair.EnumStringValue = ((T)item).ToString();
            list.Add(pair);
        }

        return(list);
    }
Ejemplo n.º 3
0
 public EnumSerializer(Type enumType, EnumPair[] map)
 {
     if (enumType == null) throw new ArgumentNullException("enumType");
     this.enumType = enumType;
     this.map = map;
     if (map != null)
     {
         for (int i = 1; i < map.Length; i++)
             for (int j = 0; j < i; j++)
             {
                 if (map[i].WireValue == map[j].WireValue && !Equals(map[i].RawValue, map[j].RawValue))
                 {
                     throw new ProtoException("Multiple enums with wire-value " + map[i].WireValue.ToString());
                 }
                 if (Equals(map[i].RawValue, map[j].RawValue) && map[i].WireValue != map[j].WireValue)
                 {
                     throw new ProtoException("Multiple enums with deserialized-value " + map[i].RawValue);
                 }
             }
     }
 }
Ejemplo n.º 4
0
 public EnumSerializer(Type enumType, EnumPair[] map)
 {
     if (enumType == null) throw new ArgumentNullException("enumType");
     this.enumType = enumType;
     this.map = map;
 }
Ejemplo n.º 5
0
        private void cboAuditReason_SelectedIndexChanged(object sender, EventArgs e)
        {
            EnumPair <AuditReason> reason = cboAuditReason.SelectedItem as EnumPair <AuditReason>;

            txtExitingShopManagerName.Enabled = reason.Value == AuditReason.MANAGERCHANGE;
        }