private void RadioButtonDirection_CheckedChanged(object sender, EventArgs e) { int iSelIndex = lbPortList.SelectedIndex; if (iSelIndex >= 0) { VHDL_Port pi = PortList[iSelIndex]; if (rbIn.Checked) { pi.Direction = VHDLPortDirection.In; } if (rbOut.Checked) { pi.Direction = VHDLPortDirection.Out; } if (rbInOut.Checked) { pi.Direction = VHDLPortDirection.InOut; } if (rbBuffer.Checked) { pi.Direction = VHDLPortDirection.Buffer; } PortList[iSelIndex] = pi; pictureBoxPreview.Invalidate(); } }
private void btnAdd_Click(object sender, EventArgs e) { VHDLPortDirection inout = VHDLPortDirection.In; if (rbOut.Checked) { inout = VHDLPortDirection.Out; } if (rbInOut.Checked) { inout = VHDLPortDirection.InOut; } if (rbBuffer.Checked) { inout = VHDLPortDirection.Buffer; } VHDL_Port newPort = new VHDL_Port("", "STD_LOGIC", inout); tbPortName.Enabled = true; rbIn.Enabled = true; rbOut.Enabled = true; rbInOut.Enabled = true; rbBuffer.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 BoundsChanged(object sender, EventArgs e) { int iSelIndex = lbPortList.SelectedIndex; if (iSelIndex >= 0) { VHDL_Port pi = PortList[iSelIndex]; pi.LeftIndex = (int)LeftIndex.Value; pi.RightIndex = (int)RightIndex.Value; PortList[iSelIndex] = pi; pictureBoxPreview.Invalidate(); } }
private void comboBoxUserDefinitionType_SelectedIndexChanged(object sender, EventArgs e) { string type = comboBoxUserDefinitionType.Text; if (string.IsNullOrEmpty(type)) { type = comboBoxUserDefinitionType.SelectedText; } int iSelIndex = lbPortList.SelectedIndex; if (iSelIndex >= 0) { VHDL_Port pi = PortList[iSelIndex]; pi.Type = type; //SelectedText; PortList[iSelIndex] = pi; pictureBoxPreview.Invalidate(); } }
private void cbPortType_SelectedIndexChanged(object sender, EventArgs e) { int iSelIndex = cbPortType.SelectedIndex; if (iSelIndex >= 0) { bool bEnable = (iSelIndex == 1) || (iSelIndex == 3); // BIT_VECTOR or STD_LOGIC_VECTOR LeftIndex.Enabled = bEnable; RightIndex.Enabled = bEnable; } comboBoxUserDefinitionType.Visible = (iSelIndex == 7); iSelIndex = lbPortList.SelectedIndex; if ((iSelIndex >= 0) && (iSelIndex != 7)) { VHDL_Port pi = PortList[iSelIndex]; pi.Type = (string)cbPortType.Items[cbPortType.SelectedIndex]; //SelectedText; PortList[iSelIndex] = pi; pictureBoxPreview.Invalidate(); } }
private void tbPortName_TextChanged(object sender, EventArgs e) { bool bEnabled = tbPortName.Text != ""; int iSelIndex = lbPortList.SelectedIndex; if (iSelIndex >= 0) { VHDL_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; } }
/// <summary> /// Создание порта по имеющимся данным с VHDL_Port /// </summary> /// <param name="info"></param> /// <param name="center_point"></param> /// <param name="core"></param> /// <returns></returns> public static My_Port CreatePort(VHDL_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 VHDLPortDirection.In: res.Direction = Schematix.FSM.My_Port.PortDirection.In; break; case VHDLPortDirection.Out: res.Direction = Schematix.FSM.My_Port.PortDirection.Out; break; case VHDLPortDirection.InOut: res.Direction = Schematix.FSM.My_Port.PortDirection.InOut; break; case VHDLPortDirection.Buffer: res.Direction = Schematix.FSM.My_Port.PortDirection.Buffer; break; } return(res); }
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(EntityName, 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 == VHDLPortDirection.In) { cLeft++; } else if (PortList[i].Direction == VHDLPortDirection.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++) { VHDL_Port pi = PortList[i]; sPortName = pi.Name; if ((pi.Type == "STD_LOGIC_VECTOR") || (pi.Type == "BIT_VECTOR")) { LinePen = ThickPen; sPortName = sPortName + '(' + pi.LeftIndex + ':' + pi.RightIndex + ')'; } else { LinePen = ThinPen; } if ((pi.Direction == VHDLPortDirection.In) || ((pi.Direction == VHDLPortDirection.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); } } }