private ClassDefinitionCtrl(ClassDefinitionDecorator cls, SchemaDesignContext context, NodeUpdateHandler updater, NodeUpdateHandler idUpdater) : this() { _cls = cls; _context = context; txtName.DataBindings.Add("Text", cls, "Name"); txtDescription.DataBindings.Add("Text", cls, "Description"); txtType.Text = cls.ClassType.ToString(); BindIdentityProperties(cls, idUpdater); //cmbBaseClass.DisplayMember = "Name"; //cmbBaseClass.DataSource = _context.GetClassesExceptFor(cls.ParentName, cls.Name); //cmbBaseClass.DataBindings.Add("SelectedItem", cls, "BaseClass"); chkAbstract.DataBindings.Add("Checked", cls, "IsAbstract"); chkComputed.DataBindings.Add("Checked", cls, "IsComputed"); cls.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") updater(); }; lstUniqueConstraints.DataSource = cls.GetUniqueConstraints(); lnkEditUniqueConstraints.Enabled = _context.CanHaveUniqueConstraints; }
private void BindIdentityProperties(ClassDefinitionDecorator cls, NodeUpdateHandler idUpdater) { //Fill the list foreach (PropertyDefinition p in cls.Properties) { if (p.PropertyType == PropertyType.PropertyType_DataProperty) { chkIdentityProperties.Items.Add(p.Name, false); } } //Now check the ones which are identity foreach (DataPropertyDefinition p in cls.IdentityProperties) { var idx = chkIdentityProperties.Items.IndexOf(p.Name); if (idx >= 0) chkIdentityProperties.SetItemChecked(idx, true); } //Now wire up change listener chkIdentityProperties.ItemCheck += (s, e) => { var idx = e.Index; string name = chkIdentityProperties.Items[idx].ToString(); if (e.NewValue == CheckState.Checked) { cls.MarkAsIdentity(name); idUpdater(); } else if (e.NewValue == CheckState.Unchecked) { cls.RemoveIdentityProperty(name); idUpdater(); } }; }