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; FeedbackDecoderConnection.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 Connect(int inputPin, FeedbackEncoderConnection connection) { try { if (connection != null) { if (MessageBox.Show("The selected output is currently connected. Are you sure you want to connect the output to another encoder input?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } FeedbackConnectionFindView form = new FeedbackConnectionFindView(connection); if (form.ShowDialog(this) == DialogResult.Cancel) { return; } // Delete the existing connection if (connection != null) { FeedbackEncoderConnection.Delete(connection); connection.EncoderInput.FeedbackConnection = null; connection.Element.FeedbackConnections.Remove(connection); } FeedbackEncoderConnection newconnection = new FeedbackEncoderConnection(); newconnection.EncoderInput = form.SelectedInput; newconnection.Element = this.Element; newconnection.ElementPinIndex = inputPin; FeedbackEncoderConnection.Save(newconnection); form.SelectedInput.FeedbackConnection = newconnection; this.Element.FeedbackConnections.Add(newconnection); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.RefreshConnectionList(); } }