private void Connect(int inputPin, AccessoryDecoderConnection connection) { try { if (connection != null) { if (MessageBox.Show("The selected input is currently connected. Are you sure you want to connect the input to another decoder output?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } AccesoryConnectionFindView form = new AccesoryConnectionFindView(connection); if (form.ShowDialog(this) == DialogResult.Cancel) { return; } // Delete the existing connection if (connection != null) { AccessoryDecoderConnection.Delete(connection); connection.DecoderOutput.AccessoryConnection = null; connection.Element.AccessoryConnections.Remove(connection); } AccessoryDecoderConnection newconnection = new AccessoryDecoderConnection(); newconnection.DecoderOutput = form.SelectedOutput; newconnection.Element = this.Element; newconnection.ElementPinIndex = inputPin; newconnection.Inverted = false; AccessoryDecoderConnection.Save(newconnection); form.SelectedOutput.AccessoryConnection = newconnection; this.Element.AccessoryConnections.Add(newconnection); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.RefreshConnectionList(); } }
private void TxtOutput_ButtonClick(object sender, ButtonPressedEventArgs e) { if (e.Button.Index == 0) { AccesoryConnectionFindView form = new AccesoryConnectionFindView(this.SelectedConnection); if (form.ShowDialog(this) == DialogResult.OK) { // Remove existing connection if (form.SelectedOutput.AccessoryConnection != null) { AccessoryDecoderConnection.Delete(form.SelectedOutput.AccessoryConnection); } // Create new connection this.SelectedConnection = new AccessoryDecoderConnection(); this.SelectedConnection.DecoderOutput = form.SelectedOutput; this.SelectedConnection.Element = this.Element; this.SelectedConnection.ElementPinIndex = this.ConnectionIndex; AccessoryDecoderConnection.Save(this.SelectedConnection); form.SelectedOutput.AccessoryConnection = this.SelectedConnection; this.ConnectionChanged?.Invoke(this, new ConnectionChangedEventArgs(this.ConnectionIndex, this.SelectedConnection)); } } else if (e.Button.Index == 1) { if (this.SelectedConnection == null) { MessageBox.Show("Current element input is not connected to any decoder output.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } AccessoryDecoderConnection.Delete(this.SelectedConnection); this.SelectedConnection = null; this.ConnectionChanged?.Invoke(this, new ConnectionChangedEventArgs(this.ConnectionIndex, this.SelectedConnection)); } ShowSelectedOutput(); }
private void TxtOutput_ButtonClick(object sender, ButtonPressedEventArgs e) { if (e.Button.Index == 0) { AccesoryConnectionFindView form = new AccesoryConnectionFindView(this.SelectedOutput); form.ShowDialog(this); if (form.DialogResult == DialogResult.OK) { this.SelectedOutput = form.SelectedConnection; this.SelectedDecoder = form.SelectedDecoder; this.SelectedOutput.ElementPinIndex = this.ConnectionIndex; this.SelectedOutput.Element = this.Element; AccessoryDecoderConnection.Save(this.SelectedOutput); this.ConnectionChanged?.Invoke(this, new ConnectionChangedEventArgs(this.ConnectionIndex, this.SelectedOutput)); } } else if (e.Button.Index == 1) { if (this.SelectedOutput == null) { MessageBox.Show("This connection is not connected to any decoder output.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } AccessoryDecoderConnection.Delete(this.SelectedOutput.ID); this.SelectedOutput = null; this.SelectedDecoder = null; this.ConnectionChanged?.Invoke(this, new ConnectionChangedEventArgs(this.ConnectionIndex, this.SelectedOutput)); } ShowSelectedOutput(); }