Example #1
0
        private void CmdOK_Click(object sender, EventArgs e)
        {
            try
            {
                // Get the properties
                this.Element.Name = txtName.Text.Trim();

                // Store the element properties
                Element.Save(this.Element);

                // Save the connections (inputs and outputs)
                foreach (AccessoryDecoderConnection output in this.Element.AccessoryConnections)
                {
                    AccessoryDecoderConnection.Save(output);
                }

                // Save the actions
                foreach (ElementAction action in this.Element.Actions)
                {
                    ElementAction.Save(action);
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR storing data:" + Environment.NewLine + Environment.NewLine + ex.Message,
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void cmdOK_Click(object sender, System.EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtDescription.Text))
            {
                MessageBox.Show("You must provide a valid descriptive name for the current action.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (cboEvent.SelectedItem == null)
            {
                MessageBox.Show("You must select the event you want to execute the current action.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (!this.Editor.CheckData())
            {
                return;
            }

            try
            {
                this.Action.Element         = this.OwnerBlock;
                this.Action.Description     = txtDescription.Text.Trim();
                this.Action.Event           = this.SelectedEvent;
                this.Action.ConditionStatus = this.SelectedStatusFilter;

                ElementAction.Save(this.Action);

                this.OwnerBlock.Actions.Add(this.Action);

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR storing action: " + ex.Message,
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }