Exemple #1
0
        private void CmdOk_Click(object sender, EventArgs e)
        {
            if (!this.MapViewToModel())
            {
                return;
            }

            try
            {
                // Save the decoder
                AccessoryDecoder.Save(this.Decoder);

                // Save the decoder outputs
                if (this.Decoder.IsNew)
                {
                    foreach (AccessoryDecoderOutput output in this.Decoder.Outputs)
                    {
                        AccessoryDecoderOutput.Save(output);
                    }
                }

                // Add the decoder into the project
                if (!OTCContext.Project.AccessoryDecoders.Contains(this.Decoder))
                {
                    OTCContext.Project.AccessoryDecoders.Add(this.Decoder);
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;

                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }