예제 #1
0
        public FormMain(FormController controller)
        {
            InitializeComponent();

            this.controller = controller;

            this.controller.form = this;

            this.controller.textBoxEDTName          = textBoxEDTName;
            this.controller.textBoxEnumType         = textBoxEnumType;
            this.controller.textBoxExtends          = textBoxExtends;
            this.controller.textBoxFieldName        = textBoxFieldName;
            this.controller.textBoxHelpText         = textBoxHelpText;
            this.controller.textBoxLabel            = textBoxLabel;
            this.controller.comboBoxFieldType       = comboBoxFieldType;
            this.controller.numericUpDownStringSize = numericUpDownStringSize;
            this.controller.toolStripStatusLabel    = toolStripStatusLabelNotes;
            this.controller.toolTipEdtName          = toolTipEdtName;

            this.controller.init();

            this.closeOk = false;

            comboBoxFieldType.DataSource = Enum.GetValues(typeof(FieldType));

            this.comboBoxFieldType.SelectedIndexChanged += this.controller.fieldTypeSelectedIndexChanged;
            this.textBoxEDTName.Leave += this.controller.edtNameChanged;
        }
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinDesignerEventArgs e)
        {
            try
            {
                NamedElement   element    = e.SelectedElement as NamedElement;
                FormController controller = new FormController();

                if (controller.prompt())
                {
                    Building.NewFieldEngine engine = new Building.NewFieldEngine(controller, element);
                    engine.run();
                }
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }