private void RefreshValue() { try { m_refreshing = true; object value = m_context.GetValue(); UrhoBackend.ResourceRefList Ref = m_context.GetValue() as UrhoBackend.ResourceRefList; if (Ref == null) { return; } for (int i = 0; i < Ref.Size(); ++i) { if (i > m_textBoxes.Count - 1) { m_textBoxes.Add(new TextBox()); } TextBox cb = m_textBoxes[i]; if (value == null) { cb.Enabled = false; } else { cb.Text = Ref.Get(i).GetName(); cb.Enabled = (!m_context.IsReadOnly) && !DisableEditing; } } } finally { m_refreshing = false; } }
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(); }
private void checkBox_CheckedChanged(object sender, EventArgs e) { if (!m_refreshing) { List <string> values = new List <string>(); foreach (TextBox cb in m_textBoxes) { values.Add(cb.Text); } UrhoBackend.ResourceRefList Ref = m_context.GetValue() as UrhoBackend.ResourceRefList; Ref.FromList(values); m_context.SetValue(Ref); } }