Wednesday, April 13, 2022

12-Digital Simulator Project Setup

In this post, we will add a new project called "DigitalSim" to the solution. Right click on the solution name > Add > New Project... Name: DigitalSim. Set Digital Sim as the start up project. Change the name of Form1.cs to MainForm.cs.

MainForm Design

MainForm properties:

  • Text: Digital Simulator
  • StartPosition: CenterScreen

From the toolbox, add the following controls to the MainForm

  • MenuStrip
    • BackColor: LightSteelBlue
    • MenuStrip Menu Items
      • File
        • New
        • Load
        • Save
        • Exit
  • ToolStrip
    • BackColor: LightSteelBlue
    • ToolStrip Buttons
      • AND
      • OR
      • NOT
      • Switch
      • LED
      • Wire
      • Modern UI
  • Picture Box
    • Name: schematicCanvas
    • BackColor: LightBlue
    • Dock: Fill

MenuStrip Button Handlers

Switch to the Menu Strip events, create empty click events for New, Load, Save, Exit by double clicking in the empty field to the right of the Click event for each.

ToolStrip Button Handlers

Switch to the Tool Strip events, create empty click events for AND, OR, NOT, Switch, LED, Wire, Modern UI by double clicking in the empty field to the right of the Click event for each.

PictureBox Event Handlers

Select the schematicCanvas PictureBox and add empty events for Paint, Resize, MouseDown, MouseMove, and MouseUp.

Organizing Classes into Folders

This project will use folders to organize classes. Note that folders are also namespaces for C# classes. Add three new folders in the DigitalSim project:

  1. Circuits
  2. Components
  3. Wires

Circuit Class

Right click on the Circuits folder > Add > Class, Name: Circuit.cs. This class will manage schematics and provide analysis, file save, and file load functionality. Note that the namespace for this class includes the folder name.

Component Classes

Right click on the Components folder > Add > Class, Name: Comp.cs. This class is the base class for all digital components. It will include a list of wires connected to the component input and output ports.

Add the AND, OR, NOT, Switch, and LED classes to the components folder.

Wire Class

Right click on the Wires folder > Add > Class, Name: Wire.cs. Interconnections between digital components are wires.

No comments:

Post a Comment

34-Microwave Tools with Analysis (Series Final Post)

In this final blog post, I have integrated Y-Matrix analysis into the Microwave Tools project. This version has addition Lumped, Ideal, Micr...