Ejemplo n.º 1
0
        /// <summary>
        /// Create a new Device and call <see cref="MWController.CreateInterfaceOnClick(MWInterface)"/> of the <see cref="mWController"/>
        /// </summary>
        /// <param name="sender">Event arg, not used</param>
        /// <param name="e">Event arg, not used</param>
        private void createInterfaceBtn_Click(object sender, System.EventArgs e)
        {
            // Creating a new object (interface) and giving it the values of the textfields/input
            MWInterface interfaceObject = new MWInterface();

            interfaceObject.pinList = new List <MWPin>();

            try { interfaceObject.numberOfInterface = Convert.ToInt32(txtInterfaceNumber.Text); } catch (Exception ex) { MessageBox.Show("Vendor ID is in an invalid format (Expected only numbers)!"); return; }
            interfaceObject.interfaceDescription = txtInterfaceDescription.Text;
            interfaceObject.connectorType        = cmbConnectorType.Text;
            if (!String.IsNullOrWhiteSpace(txtPinCount.Text))
            {
                try { interfaceObject.amountPins = Convert.ToInt32(txtPinCount.Text); } catch (Exception ex) { MessageBox.Show("Pin Count is in an invalid format (Expected only numbers)! Ignoring!"); }
            }

            // getting the values of the DataGridView and inserting it into the pinList of the object (Interface)
            int i = (interfaceObject.amountPins - 1);

            while (i >= 0)
            {
                var pinItem = new MWPin();
                try
                {
                    pinItem.pinNumber = Convert.ToInt32(interfacePortMappingGrid.Rows[i].Cells[0].Value);
                    pinItem.attribute = Convert.ToString(interfacePortMappingGrid.Rows[i].Cells[1].Value);
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }

                interfaceObject.pinList.Add(pinItem);
                i += -1;
            }


            string result = mWController.CreateInterfaceOnClick(interfaceObject, isEditing);

            clear();
            if (result != null)
            {
                // Display error Dialog
                MessageBox.Show(result);
            }
        }
Ejemplo n.º 2
0
        // OnClickFunktion für CreateDevice
        // OnClickFunktion für CreateInterfac
        //      Daten aus allen GUI Input Feldern auslesen
        //      CreateDevice(/Interface) in MWModell mit diesen Daten als Parameter aufrufen#

        /// <summary>
        /// Pass the data of the newInterface to the MWData
        /// </summary>
        /// <param name="newInterface">the object holding the data</param>
        /// <param name="isEdit">true if the device was edited, false if the device is created</param>
        /// <returns>the result as a string</returns>
        public string CreateInterfaceOnClick(MWInterface newInterface, bool isEdit)
        {
            // create the interface
            string result = mWData.CreateInterface(newInterface, isEdit);

            // update the device list
            if (isEdit)
            {
                ReloadObjects();
            }
            else
            {
                devices.Add(newInterface);
                GetStartGUI().updateDeviceDropdown(devices);
            }

            // go to Start GUI
            ChangeGui(MWController.MWGUIType.Start);
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Fill the fields with the data of the MWInterface/>
        /// </summary>
        /// <param name="mWObject">The <see cref="MWInterface"/> with the data</param>
        internal void prefill(MWInterface mWObject)
        {
            txtInterfaceNumber.Text       = mWObject.numberOfInterface.ToString();
            txtInterfaceDescription.Text  = mWObject.interfaceDescription;
            cmbConnectorType.SelectedItem = mWObject.connectorType;

            interfacePortMappingGrid.Rows.Clear();
            foreach (MWPin pin in mWObject.pinList)
            {
                int i = interfacePortMappingGrid.Rows.Add();
                interfacePortMappingGrid.Rows[i].Cells[0].Value = i;
                interfacePortMappingGrid.Rows[i].Cells[1].Value = pin.attribute;
            }
            pinCount         = mWObject.pinList.Count;
            txtPinCount.Text = mWObject.amountPins.ToString();

            cmbConnectorType_SelectionChangeCommitted(null, null);
            pinCount = mWObject.amountPins;
            createInterfaceBtn.Text    = "Update Interface";
            txtInterfaceNumber.Enabled = false;

            this.isEditing = true;
        }