private void btnAdd_Click(object sender, EventArgs e) { VerilogPortDirection inout = VerilogPortDirection.In; if (rbOut.Checked) { inout = VerilogPortDirection.Out; } if (rbInOut.Checked) { inout = VerilogPortDirection.InOut; } Verilog_Port newPort = new Verilog_Port("", "wire", inout); tbPortName.Enabled = true; rbIn.Enabled = true; rbOut.Enabled = true; rbInOut.Enabled = true; cbPortType.Enabled = true; PortList.Add(newPort); lbPortList.Items.Add(newPort.Name); lbPortList.SelectedIndex = PortList.Count - 1; pictureBoxPreview.Invalidate(); tbPortName.Text = string.Empty; tbPortName.Focus(); }
private void cbPortType_SelectedIndexChanged(object sender, EventArgs e) { int iSelIndex = lbPortList.SelectedIndex; if ((iSelIndex >= 0)) { Verilog_Port pi = PortList[iSelIndex]; pi.Type = (string)cbPortType.Items[cbPortType.SelectedIndex]; //SelectedText; PortList[iSelIndex] = pi; pictureBoxPreview.Invalidate(); } }
private void BoundsChanged(object sender, EventArgs e) { int iSelIndex = lbPortList.SelectedIndex; if (iSelIndex >= 0) { Verilog_Port pi = PortList[iSelIndex]; pi.LeftIndex = (int)LeftIndex.Value; pi.RightIndex = (int)RightIndex.Value; PortList[iSelIndex] = pi; pictureBoxPreview.Invalidate(); } }
private void checkBoxIsBus_CheckedChanged(object sender, EventArgs e) { int iSelIndex = lbPortList.SelectedIndex; if (iSelIndex >= 0) { Verilog_Port pi = PortList[iSelIndex]; pi.isBus = checkBoxIsBus.Checked; PortList[iSelIndex] = pi; pictureBoxPreview.Invalidate(); LeftIndex.Enabled = checkBoxIsBus.Checked; RightIndex.Enabled = checkBoxIsBus.Checked; } }
/// <summary> /// Создание порта по имеющимся данным с Verilog_Port /// </summary> /// <param name="info"></param> /// <param name="center_point"></param> /// <param name="core"></param> /// <returns></returns> public static My_Port CreatePort(Verilog_Port info, Point center_point, Constructor_Core core) { My_Port res = new My_Port(info.Name, info.Type, center_point, core); switch (info.Direction) { case VerilogPortDirection.In: res.Direction = Schematix.FSM.My_Port.PortDirection.In; break; case VerilogPortDirection.Out: res.Direction = Schematix.FSM.My_Port.PortDirection.Out; break; case VerilogPortDirection.InOut: res.Direction = Schematix.FSM.My_Port.PortDirection.InOut; break; } return(res); }
private void tbPortName_TextChanged(object sender, EventArgs e) { bool bEnabled = tbPortName.Text != ""; int iSelIndex = lbPortList.SelectedIndex; if (iSelIndex >= 0) { Verilog_Port pi = PortList[iSelIndex]; pi.Name = tbPortName.Text; PortList[iSelIndex] = pi; lbPortList.Items[iSelIndex] = tbPortName.Text; pictureBoxPreview.Invalidate(); if (bEnabled) { for (int i = 0; i < PortList.Count; i++) { if ((PortList[i].Name == tbPortName.Text) && (i != iSelIndex)) { bEnabled = false; } } } btnAdd.Enabled = bEnabled; lbPortList.Enabled = bEnabled; cbPortType.Enabled = bEnabled; } if (string.IsNullOrEmpty(tbPortName.Text)) { ButtonOk.Enabled = false; } else { ButtonOk.Enabled = true; } }
private void RadioButtonDirection_CheckedChanged(object sender, EventArgs e) { int iSelIndex = lbPortList.SelectedIndex; if (iSelIndex >= 0) { Verilog_Port pi = PortList[iSelIndex]; if (rbIn.Checked) { pi.Direction = VerilogPortDirection.In; } if (rbOut.Checked) { pi.Direction = VerilogPortDirection.Out; } if (rbInOut.Checked) { pi.Direction = VerilogPortDirection.InOut; } PortList[iSelIndex] = pi; pictureBoxPreview.Invalidate(); } }
public void Draw(Graphics g) { Pen ThinPen = Pens.Black; Pen ThickPen = new Pen(Color.Black, 3); Pen LinePen; g.FillRectangle(new SolidBrush(Color.LemonChiffon), 20, 1, 100, 200); g.DrawRectangle(ThickPen, 20, 0, 100, 200); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; g.DrawString(ModuleName, Font, new SolidBrush(Color.Black), 70, 201, sf); int cLeft = 0, cRight = 0, cInOut = 0; for (int i = 0; i < PortList.Count; i++) { if (PortList[i].Direction == VerilogPortDirection.In) { cLeft++; } else if (PortList[i].Direction == VerilogPortDirection.InOut) { cInOut++; } else { cRight++; } } bool bInOutAtLeft = false; if (cLeft + cInOut < cRight) { cLeft += cInOut; bInOutAtLeft = true; } else { cRight += cInOut; } int iStepLeft = (200 / (cLeft + 1)); int iStepRight = (200 / (cRight + 1)); cLeft = cRight = 0; sf.LineAlignment = StringAlignment.Center; String sPortName; for (int i = 0; i < PortList.Count; i++) { Verilog_Port pi = PortList[i]; sPortName = pi.Name; if (pi.isBus == true) { LinePen = ThickPen; sPortName = sPortName + '(' + pi.LeftIndex + ':' + pi.RightIndex + ')'; } else { LinePen = ThinPen; } if ((pi.Direction == VerilogPortDirection.In) || ((pi.Direction == VerilogPortDirection.InOut) && bInOutAtLeft)) { // Draw at left side cLeft++; g.DrawLine(LinePen, 0, cLeft * iStepLeft, 20, cLeft * iStepLeft); sf.Alignment = StringAlignment.Near; g.DrawString(sPortName, this.Font, SystemBrushes.ControlText, 22, cLeft * iStepLeft, sf); } else { // Draw at right side cRight++; g.DrawLine(LinePen, 120, cRight * iStepRight, 140, cRight * iStepRight); sf.Alignment = StringAlignment.Far; g.DrawString(sPortName, this.Font, SystemBrushes.ControlText, 118, cRight * iStepRight, sf); } } }