예제 #1
0
 /// <summary>
 /// Adds an option.
 /// </summary>
 /// <param name="lrb">Radio button.</param>
 public virtual void AddOption(LabeledRadioButton lrb)
 {
     lrb.Checked += OnRadioClicked;
     lrb.Margin   = new Margin(0, 0, 0, 1);
     lrb.KeyboardInputEnabled = false;
     lrb.IsTabable            = true;
 }
예제 #2
0
        /// <summary>
        /// Adds a new option.
        /// </summary>
        /// <param name="text">Option text.</param>
        /// <param name="optionName">Internal name.</param>
        /// <param name="userData">User data.</param>
        /// <returns>Newly created control.</returns>
        public virtual LabeledRadioButton AddOption(string text, string optionName = null, object userData = null)
        {
            LabeledRadioButton lrb = new LabeledRadioButton(this);

            lrb.Name                 = optionName;
            lrb.UserData             = userData;
            lrb.Text                 = text;
            lrb.Checked             += OnRadioClicked;
            lrb.Margin               = new Margin(0, 0, 0, 1);
            lrb.KeyboardInputEnabled = false;
            lrb.IsTabable            = true;

            return(lrb);
        }
예제 #3
0
        public EnumRadioButtonGroup(ControlBase parent) : base(parent)
        {
            if (!typeof(T).IsEnum)
            {
                throw new Exception("T must be an enumerated type!");
            }

            for (int i = 0; i < Enum.GetValues(typeof(T)).Length; i++)
            {
                string             name = Enum.GetNames(typeof(T))[i];
                LabeledRadioButton lrb  = this.AddOption(name);
                lrb.UserData = Enum.GetValues(typeof(T)).GetValue(i);
            }
        }
예제 #4
0
        /// <summary>
        /// Handler for the option change.
        /// </summary>
        /// <param name="fromPanel">Event source.</param>
        protected virtual void OnRadioClicked(ControlBase fromPanel, EventArgs args)
        {
            RadioButton @checked = fromPanel as RadioButton;

            foreach (LabeledRadioButton rb in Children.OfType <LabeledRadioButton>()) // todo: optimize
            {
                if (rb.RadioButton == @checked)
                {
                    m_Selected = rb;
                }
                else
                {
                    rb.RadioButton.IsChecked = false;
                }
            }

            OnChanged(m_Selected);
        }