private void toolNewField_Click(object sender, EventArgs e) { if (parent.SupportsFields) { Field field = parent.AddField(); AddNewField(field); } }
private void toolNewField_Click(object sender, EventArgs e) { if (parent.SupportsFields) { Field field = parent.AddField(); ListViewItem item = AddFieldToList(field); OnContentsChanged(EventArgs.Empty); item.Focused = true; item.Selected = true; txtName.SelectAll(); txtName.Focus(); } }
/// <summary> /// Reflects all fields within the type <paramref name="xType"/>. Reflected /// fields are added to <paramref name="xFieldContainer"/>. /// </summary> /// <param name="xType">The fields are taken from this type.</param> /// <param name="xFieldContainer">Reflected fields are added to this FieldContainer.</param> private void ReflectFields(Type xType, CompositeType xFieldContainer) { #region --- Events EventInfo[] axEvents = xType.GetEvents(xStandardBindingFlags); List <string> astEvents = new List <string>(); foreach (EventInfo xEvent in axEvents) { //Don't display derived events if (xEvent.DeclaringType != xType) { continue; } //The access modifier isn't stored at the event. So we have to take //that from the corresponding add_XXX (or perhaps remove_XXX) method. MethodInfo xAddMethodInfo = xType.GetMethod("add_" + xEvent.Name, xStandardBindingFlags); if (!xImportSettings.CheckImportEvent(xAddMethodInfo)) { continue; } Event xNewEvent = xFieldContainer.AddEvent(); xNewEvent.Name = xEvent.Name; xNewEvent.AccessModifier = GetMethodAccessModifier(xAddMethodInfo); xNewEvent.IsStatic = xAddMethodInfo.IsStatic; xNewEvent.Type = GetTypeName(xEvent.EventHandlerType); astEvents.Add(xEvent.Name); } #endregion #region --- Fields FieldInfo[] axFields = xType.GetFields(xStandardBindingFlags); foreach (FieldInfo xField in axFields) { if (!xImportSettings.CheckImportField(xField)) { continue; } //Don't import fields belonging to events if (astEvents.Contains(xField.Name)) { continue; } //Don't display derived fields if (xField.DeclaringType != xType) { continue; } //Don't add compiler generated fields (thaks to Luca) if (xField.GetCustomAttributes(typeof(CompilerGeneratedAttribute), true).Length > 0) { continue; } Field xNewField = xFieldContainer.AddField(); xNewField.Name = xField.Name; xNewField.AccessModifier = GetFieldAccessModifier(xField); xNewField.IsReadonly = xField.IsInitOnly; xNewField.IsStatic = xField.IsStatic; if (xField.IsLiteral) { xNewField.InitialValue = xField.GetValue(null).ToString(); xNewField.IsStatic = false; xNewField.IsConstant = true; } xNewField.Type = GetTypeName(xField.FieldType); } #endregion ReflectOperations(xType, (CompositeType)xFieldContainer); }