private void txtInput_ButtonClick(object sender, ButtonPressedEventArgs e) { if (e.Button.Index == 0) { FeedbackConnectionFindView form = new FeedbackConnectionFindView(this.SelectedInput); form.ShowDialog(this); if (form.DialogResult == DialogResult.OK) { this.SelectedInput = form.SelectedConnection; this.SelectedDecoder = form.SelectedDecoder; this.SelectedInput.ElementPinIndex = this.ConnectionIndex; this.SelectedInput.Element = this.Element; FeedbackEncoderInput.Save(this.SelectedInput); } } else if (e.Button.Index == 1) { if (this.SelectedInput == null) { MessageBox.Show("This connection is not connected to any decoder input.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } AccessoryDecoderConnection.Delete(this.SelectedInput.ID); this.SelectedInput = null; this.SelectedDecoder = null; } ShowSelectedOutput(); }
private void CmdOk_Click(object sender, EventArgs e) { try { if (!this.MapViewToModel()) { return; } Cursor.Current = Cursors.WaitCursor; /// Save the decoder FeedbackEncoder.Save(this.Decoder); // Save the inputs if (this.Decoder.IsNew) { foreach (FeedbackEncoderInput input in this.Decoder.Inputs) { FeedbackEncoderInput.Save(input); } } // Add the decoder into the project if (!OTCContext.Project.FeedbackEncoders.Contains(this.Decoder)) { OTCContext.Project.FeedbackEncoders.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; } }