Following the same pattern as posts 21 & 22, create new classes in the Microstrip folder for MLIN, MCROS & MTEE.
MLIN Class
- Create a new class in the Microstrip folder called MLIN.cs
- Make it a public class that inherits from Comp
- Add two constructors: 1 with no arguments and 1 that initializes the component parameters
- Add the print() method
- Add the Draw() method
- Modify MainForm.cs by adding a MLIN button handler to create the MLIN
// Let the MLIN draw itself called from the canvas paint event
public override void
Draw(Graphics gr)
{
Point p1 =
Loc; // Assume p1 is the end of the lead at the output of Pin
Point p2 = new Point(p1.X + 10, p1.Y);
Point p3 = new Point(p2.X, p2.Y - 10); // Location of MLIN rectangle
Point p4 = new Point(p2.X + 40, p2.Y);
Point p5 = new Point(p4.X + 10, p4.Y);
gr.DrawLine(drawPen, p1, p2);
gr.DrawLine(drawPen, p4, p5);
gr.DrawRectangle(drawPen, p3.X, p3.Y, 40, 20);
}
MCROS Class
- Create a new class in the Microstrip folder called MCROS.cs
- Make it a public class that inherits from Comp
- Add two constructors: 1 with no arguments and 1 that initializes the component parameters
- Add the print() method
- Add the Draw() method
- Modify MainForm.cs by adding a MCROS button handler to create the MCROS
// Let the MCROS draw itself called from the canvas paint event
public override void
Draw(Graphics gr)
{
Point[] p = new Point[21];
p[1] = Loc; // Assume p1 is
the input lead to the left
p[2] = new Point(p[1].X + 10, p[1].Y);
p[3] = new Point(p[2].X, p[2].Y - 10);
p[4] = new Point(p[3].X + 10, p[3].Y);
p[5] = new Point(p[4].X, p[4].Y - 10);
p[6] = new Point(p[5].X + 20, p[5].Y);
p[7] = new Point(p[6].X, p[6].Y + 10);
p[8] = new Point(p[7].X + 10, p[7].Y);
p[9] = new Point(p[8].X, p[8].Y + 20);
p[10] = new Point(p[9].X - 10, p[9].Y);
p[11] = new Point(p[10].X, p[10].Y + 10);
p[12] = new Point(p[11].X - 20, p[11].Y);
p[13] = new Point(p[12].X, p[12].Y - 10);
p[14] = new Point(p[13].X - 10, p[13].Y);
p[15] = new Point(p[5].X + 10, p[5].Y - 10);
p[16] = new Point(p[15].X, p[15].Y + 10);
p[17] = new Point(p[8].X + 10, p[8].Y + 10);
p[18] = new Point(p[17].X - 10, p[17].Y);
p[19] = new Point(p[11].X - 10, p[11].Y + 10);
p[20] = new Point(p[19].X, p[19].Y - 10);
for (int i = 1; i < 14; i++)
gr.DrawLine(drawPen, p[i], p[i + 1]);
gr.DrawLine(drawPen, p[14], p[2]);
for (int i = 15; i < 21; i += 2)
gr.DrawLine(drawPen, p[i], p[i + 1]);
}
MTEE Class
- Create a new class in the Microstrip folder called MTEE.cs
- Make it a public class that inherits from Comp
- Add two constructors: 1 with no arguments and 1 that initializes the component parameters
- Add the print() method
- Add the Draw() method
- Modify MainForm.cs by adding a MTEE button handler to create the MTEE
No comments:
Post a Comment