コード例 #1
0
        void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            ActionAttachEvent aae = propertyGrid1.SelectedObject as ActionAttachEvent;

            if (aae != null)
            {
                if (string.CompareOrdinal(e.ChangedItem.PropertyDescriptor.Name, "ActionName") == 0)
                {
                    if (DesignUtil.IsActionNameInUse(_rootNode, e.ChangedItem.Value.ToString(), aae.ActionId))
                    {
                        MessageBox.Show(this, "The action name is in use", "Set action name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        aae.ActionName = e.OldValue.ToString();
                    }
                }
                else
                {
                    propertyGrid1.Refresh();
                }
            }
            else
            {
                ActionClass act = propertyGrid1.SelectedObject as ActionClass;
                if (act != null)
                {
                    if (string.CompareOrdinal(e.ChangedItem.PropertyDescriptor.Name, "ActionName") == 0)
                    {
                        if (DesignUtil.IsActionNameInUse(_rootNode, e.ChangedItem.Value.ToString(), act.ActionId))
                        {
                            MessageBox.Show(this, "The action name is in use", "Set action name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            act.ActionName = e.OldValue.ToString();
                        }
                    }
                    else
                    {
                        if (act.ActionMethod != null && act.ActionMethod.Owner != null)
                        {
                            IMethodParameterAttributesProvider dmp = act.ActionMethod.Owner.ObjectInstance as IMethodParameterAttributesProvider;
                            if (dmp != null)
                            {
                                Dictionary <string, Attribute[]> pap = dmp.GetParameterAttributes(act.ActionMethod.MethodName);
                                if (pap != null && pap.Count > 0)
                                {
                                    propertyGrid1.Refresh();
                                }
                            }
                        }
                    }
                }
            }
        }