public ResourceRefListControl(PropertyEditorControlContext context)
            {
                m_context = context;
                UrhoBackend.ResourceRefList Ref = context.GetValue() as UrhoBackend.ResourceRefList;

                m_textBoxes     = new List <TextBox>();
                m_browseButtons = new List <Button>();
                if (Ref != null)
                {
                    for (int i = 0; i < Ref.Size(); ++i)
                    {
                        TextBox tb = new TextBox();
                        tb.Width        = 160;
                        tb.TextChanged += checkBox_CheckedChanged;
                        tb.Tag          = i;
                        m_textBoxes.Add(tb);

                        Button btn = new Button();
                        btn.Text   = "...";
                        btn.Width  = 32;
                        btn.Height = 32;
                        btn.Tag    = tb;
                        btn.Click += btn_Click;
                        m_browseButtons.Add(btn);

                        Controls.Add(tb);
                        Controls.Add(btn);
                        Height += tb.Height;
                    }
                }

                RefreshValue();
            }
Example #2
0
        public Control GetEditingControl(PropertyEditorControlContext context)
        {
            var combo = new ComboBox();

            Sce.Atf.Applications.SkinService.ApplyActiveSkin(combo);
            combo.DropDownStyle = ComboBoxStyle.DropDownList;
            combo.FlatStyle     = FlatStyle.Flat;
            combo.DisplayMember = "Name";
            combo.ValueMember   = "Value";

            var value = context.GetValue();

            for (int i = 0; i < m_names.Length; i++)
            {
                combo.Items.Add(new { Name = m_names[i], Value = m_values[i] });
                if (m_names[i].Equals(value) || m_values[i].Equals(value))
                {
                    combo.SelectedIndex = i;
                }
            }

            bool useIndex = value is int;

            combo.SelectedIndexChanged +=
                (object sender, EventArgs args) =>
            {
                dynamic o = combo.SelectedItem;
                context.SetValue(useIndex ? o.Value : o.Name);
            };

            return(combo);
        }