Пример #1
0
        private void ShowSelectDevices(CecLogicalAddresses list)
        {
            SelectDevices sel = new SelectDevices();

            sel.StartPosition = FormStartPosition.CenterParent;

            foreach (PropertyInfo property in sel.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
            {
                if (property.CanWrite && property.PropertyType.Equals(typeof(System.Boolean)))
                {
                    property.SetValue(sel, false, null);
                    if (list.IsSet((CecLogicalAddress)Enum.Parse(typeof(CecLogicalAddress), property.Name, true)))
                    {
                        property.SetValue(sel, true, null);
                    }
                }
            }

            if (sel.ShowDialog(this) == DialogResult.OK)
            {
                list.Clear();

                foreach (PropertyInfo property in sel.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
                {
                    if (property.CanRead && property.PropertyType.Equals(typeof(System.Boolean)))
                    {
                        if ((bool)property.GetValue(sel, null))
                        {
                            list.Set((CecLogicalAddress)Enum.Parse(typeof(CecLogicalAddress), property.Name, true));
                        }
                    }
                }

                sel = null;
            }
        }
Пример #2
0
    private void ShowSelectDevices(CecLogicalAddresses list)
    {

      SelectDevices sel = new SelectDevices();
      sel.StartPosition = FormStartPosition.CenterParent;

      foreach (PropertyInfo property in sel.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
      {
        if (property.CanWrite && property.PropertyType.Equals(typeof(System.Boolean)))
        {
          property.SetValue(sel, false, null);
          if (list.IsSet((CecLogicalAddress)Enum.Parse(typeof(CecLogicalAddress), property.Name, true)))
          {
            property.SetValue(sel, true, null);
          }
        }
      }

      if (sel.ShowDialog(this) == DialogResult.OK)
      {
        list.Clear();

        foreach (PropertyInfo property in sel.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
        {
          if (property.CanRead && property.PropertyType.Equals(typeof(System.Boolean)))
          {
            if ((bool)property.GetValue(sel, null))
            {
              list.Set((CecLogicalAddress)Enum.Parse(typeof(CecLogicalAddress), property.Name, true));
            }
          }
        }

        sel = null;
      }
    }