private void AddFieldBtn_Click(object sender, EventArgs e)
 {
     var editor = new CreateInnerElementForm(InnerElementType.Field);
     if(editor.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) {
         return;
     }
     FieldListItem newField = new FieldListItem();
     newField.Name = editor.ItemName.Text;
     newField.Type = editor.Type.Text;
     newField.AccessModifier = editor.AccessList.SelectedItem != null ? editor.AccessList.SelectedItem.ToString() : "";
     newField.IsStatic = editor.StaticChkBx.Checked;
     FieldsListBox.Items.Add(newField);
 }
 private void AddPropertyBtn_Click(object sender, EventArgs e)
 {
     var editor = new CreateInnerElementForm(InnerElementType.Property);
     if(editor.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) {
         return;
     }
     PropertyListItem newProperty = new PropertyListItem();
     newProperty.Name = editor.ItemName.Text;
     newProperty.Type = editor.Type.Text;
     newProperty.MainAccessorModifier = editor.AccessList.SelectedItem != null ? editor.AccessList.SelectedItem.ToString() : "";
     if(newProperty.IsGetEnabled = editor.GetChkBx.Checked) {
         newProperty.GetAccessModifier = editor.getAccessList.SelectedItem != null ? editor.getAccessList.SelectedItem.ToString() : "";
     }
     if(newProperty.IsSetEnabled = editor.SetChkBx.Checked) {
         newProperty.SetAccessModifier = editor.setAccessList.SelectedItem != null ? editor.setAccessList.SelectedItem.ToString() : "";
     }
     PropertiesListBox.Items.Add(newProperty);
 }
        private void AddMethodBtn_Click(object sender, EventArgs e)
        {
            var editor = new CreateInnerElementForm(InnerElementType.Method);
            if(editor.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) {
                return;
            }
            MethodListItem newMethod = new MethodListItem();
            newMethod.AccessModifier = editor.AccessList.SelectedItem != null ? editor.AccessList.SelectedItem.ToString() : "";
            newMethod.IsStatic = editor.StaticChkBx.Checked;
            newMethod.Name = editor.ItemName.Text;
            newMethod.Type = editor.Type.Text;

            var @params = editor.ParamsTxtBx.Text.Split(',');
            foreach(var p in @params) {
                newMethod.ParamsTypes.Add(p.Trim());
            }
            MethodsListBox.Items.Add(newMethod);
        }
        private void EditFieldBtn_Click(object sender, EventArgs e)
        {
            var selectedItem = FieldsListBox.SelectedItem as FieldListItem;
            if(selectedItem == null) {
                return;
            }
            var editor = new CreateInnerElementForm(InnerElementType.Field);
            editor.ItemName.Text = selectedItem.Name;
            editor.Type.Text = selectedItem.Type;
            editor.AccessList.SelectedItem = selectedItem.AccessModifier;
            editor.StaticChkBx.Checked = selectedItem.IsStatic;
            if(editor.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) {
                return;
            }
            FieldListItem newField = new FieldListItem();
            newField.Name = editor.ItemName.Text;
            newField.Type = editor.Type.Text;
            newField.AccessModifier = editor.AccessList.SelectedItem != null ? editor.AccessList.SelectedItem.ToString() : "";
            newField.IsStatic = editor.StaticChkBx.Checked;

            int index = FieldsListBox.SelectedIndex;
            FieldsListBox.Items.RemoveAt(index);
            FieldsListBox.Items.Insert(index, newField);
            FieldsListBox.SelectedIndex = index;
        }
        private void EditPropertyBtn_Click(object sender, EventArgs e)
        {
            var selectedItem = PropertiesListBox.SelectedItem as PropertyListItem;
            if(selectedItem == null) {
                return;
            }
            var editor = new CreateInnerElementForm(InnerElementType.Property);
            editor.ItemName.Text = selectedItem.Name;
            editor.Type.Text = selectedItem.Type;
            editor.AccessList.SelectedItem = selectedItem.MainAccessorModifier;
            if(editor.GetChkBx.Checked = selectedItem.IsGetEnabled) {
                editor.getAccessList.SelectedItem = selectedItem.GetAccessModifier;
            }
            if(editor.SetChkBx.Checked = selectedItem.IsSetEnabled) {
                editor.setAccessList.SelectedItem = selectedItem.SetAccessModifier;
            }
            if(editor.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) {
                return;
            }
            PropertyListItem newProperty = new PropertyListItem();
            newProperty.Name = editor.ItemName.Text;
            newProperty.Type = editor.Type.Text;
            newProperty.MainAccessorModifier = editor.AccessList.SelectedItem != null ? editor.AccessList.SelectedItem.ToString() : "";
            if(newProperty.IsGetEnabled = editor.GetChkBx.Checked) {
                newProperty.GetAccessModifier = editor.getAccessList.SelectedItem != null ? editor.getAccessList.SelectedItem.ToString() : "";
            }
            if(newProperty.IsSetEnabled = editor.SetChkBx.Checked) {
                newProperty.SetAccessModifier = editor.setAccessList.SelectedItem != null ? editor.setAccessList.SelectedItem.ToString() : "";
            }

            int index = PropertiesListBox.SelectedIndex;
            PropertiesListBox.Items.RemoveAt(index);
            PropertiesListBox.Items.Insert(index, newProperty);
            PropertiesListBox.SelectedIndex = index;
        }
        private void EditMethodBtn_Click(object sender, EventArgs e)
        {
            var selectedItem = MethodsListBox.SelectedItem as MethodListItem;
            if(selectedItem == null) {
                return;
            }
            var editor = new CreateInnerElementForm(InnerElementType.Method);
            editor.AccessList.SelectedItem = selectedItem.AccessModifier;
            editor.StaticChkBx.Checked = selectedItem.IsStatic;
            editor.ItemName.Text = selectedItem.Name;
            editor.Type.Text = selectedItem.Type;
            editor.ParamsTxtBx.Text = String.Join(", ", selectedItem.ParamsTypes.ToArray());
            if(editor.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) {
                return;
            }
            var newMethod = new MethodListItem();
            newMethod.AccessModifier = editor.AccessList.SelectedItem != null ? editor.AccessList.SelectedItem.ToString() : "";
            newMethod.IsStatic = editor.StaticChkBx.Checked;
            newMethod.Name = editor.ItemName.Text;
            newMethod.Type = editor.Type.Text;
            var @params = editor.ParamsTxtBx.Text.Split(',');
            foreach(var p in @params) {
                newMethod.ParamsTypes.Add(p.Trim());
            }

            int index = MethodsListBox.SelectedIndex;
            MethodsListBox.Items.RemoveAt(index);
            MethodsListBox.Items.Insert(index, newMethod);
            MethodsListBox.SelectedIndex = index;
        }