private void CmdCancel_Click(object sender, EventArgs e) { this.SelectedInput = null; this.DialogResult = DialogResult.Cancel; this.Close(); }
public FeedbackConnectionFindView(FeedbackEncoderInput connection) { InitializeComponent(); ShowInputs(connection); chkShowUnused.Checked = true; }
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 FeedbackConnectionsReport_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { // Accessory decoders report data bindings int moduleId = NumericUtils.ToInteger(lblModuleId.Text); System.Collections.Generic.ICollection <FeedbackEncoderInput> data = FeedbackEncoderInput.FindByModule(moduleId); FeedbackConnectionsReport.DataSource = data; // Hide the feedback encoders section when no data is present FeedbackConnectionsGroupHeader.Visible = (data.Count > 0); FeedbackConnectionsDetail.Visible = (data.Count > 0); }
/// <summary> /// Returns a new instance of <see cref="OutputEditorControl"/>. /// </summary> /// <remarks>Constructor for design purposes. Don't use in runtime.</remarks> public InputEditorControl(FeedbackEncoderInput output) { InitializeComponent(); Initialize(); this.FixedHeight = this.Height; this.SelectedInput = output; this.SelectedDecoder = output.Device; this.Element = output.Element; ShowSelectedOutput(); }
private void TvwOutputs_Click(object sender, EventArgs e) { if (tvwOutputs.Selection.Count <= 0) { this.SelectedInput = null; } else if (tvwOutputs.Selection[0].Tag is FeedbackEncoderInput selected) { this.SelectedInput = selected; } cmdOK.Enabled = (this.SelectedInput != null); }
private void FilterUsedConnections(TreeListNode root, bool unusedOnly) { foreach (TreeListNode node in root.Nodes) { if (node.HasChildren) { this.FilterUsedConnections(node, unusedOnly); } else { FeedbackEncoderInput output = node.Tag as FeedbackEncoderInput; node.Visible = !unusedOnly || (output?.Element == null); } } }
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; } }
void ShowInputs(FeedbackEncoderInput connection) { TreeListNode root; TreeListNode mod; TreeListNode output; TreeListColumn col; Dictionary <int, FeedbackEncoderInput> connections; tvwConnections.BeginUpdate(); tvwConnections.Nodes.Clear(); tvwConnections.Columns.Clear(); col = tvwConnections.Columns.Add(); col.Caption = "Decoder input"; col.VisibleIndex = 0; col = tvwConnections.Columns.Add(); col.Caption = "Address"; col.VisibleIndex = 1; col = tvwConnections.Columns.Add(); col.Caption = "Element"; col.VisibleIndex = 2; tvwConnections.EndUpdate(); tvwConnections.BeginUnboundLoad(); root = tvwConnections.AppendNode(new object[] { "Modules", string.Empty, string.Empty }, null); root.StateImageIndex = 4; root.Expanded = true; foreach (FeedbackEncoder decoder in OTCContext.Project.FeedbackEncoders) { mod = tvwConnections.AppendNode(new object[] { decoder.Name, string.Empty, string.Empty }, root); mod.StateImageIndex = 1; mod.Tag = decoder; connections = new Dictionary <int, FeedbackEncoderInput>(); // Create the non existing connections foreach (FeedbackEncoderInput inputConn in decoder.Connections) { connections.Add(inputConn.DecoderInput, inputConn); } for (int inputidx = 1; inputidx <= decoder.Inputs; inputidx++) { if (!connections.ContainsKey(inputidx)) { connections.Add(inputidx, new FeedbackEncoderInput() { DecoderInput = inputidx, Address = decoder.StartAddress + inputidx - 1, Device = decoder, Element = null }); } } foreach (FeedbackEncoderInput con in connections.Values) { if (con.IsNew || this.ShowUsedConnections) { output = tvwConnections.AppendNode(new object[] { con.DecoderInput, con.Address.ToString("D4"), con.Element == null ? "<empty>" : con.Element.Name }, mod); output.StateImageIndex = (con.Element == null ? 2 : 3); output.Tag = con; if (connection?.ID == con.ID) { tvwConnections.FocusedNode = output; } } } } if (tvwConnections.FocusedNode != null && tvwConnections.FocusedNode != root) { tvwConnections.MakeNodeVisible(tvwConnections.FocusedNode); } else { root.Expanded = true; } tvwConnections.EndUnboundLoad(); }