Back To Introduction

Prev Tutorial 6

 

Tutorial 7

Using a WinForm Library

 

GOAL: Demonstrate the advantage of collecting function specific files into a separate software library, and look at the functionality of the WinForm Utility Library

PREQUISITES: Tutorial 2

 

Collecting and Organizing

 

  1. Within an existing solution that you're working on, inside the Solution Explorer, Right-Mouse-Button click ‘Solution’ and then select Add → Existing Project
  2. Navigate to the WinFormUtility Project folder
  3. Inside the WinFormUtility Project folder find the WinFormUtility.csproj file and click Open
  4. Right-Mouse-Button click ‘Solution’ Tutorial and select Project Dependencies...
  5. Select your project name in the drop-down-menu and then click on the checkbox next to ‘WinFormUtility
  6. Finally in the Solution Explorer Right-Mouse-Buttom click on the References tab for your project and Add Reference.  In the dialog box that pops up, if you then click on the "Projects" tab, you should see WinFormUtility’ listed.  Select it, and then push the 'Ok' button
  7. You have now finished adding this Library to your project, next we will see the functionality of it.

 

Using the WinFormUtility Library to Setup a Graphics Window

 

  1. First add a Quit Button and a Timer to your form, if you don’t remember how to do this, go back to the past Tutorials.
  2. Set the Timer interval to 40, and add a timer1_Tick Event
  3. Now Navigate your way to the code to your [Design] Window
  4. Add a private GraphicsPanel variable to your code.

  1. Next in your [Design]Window drag out a regular panel onto the window, and resize it to however large you want.  Change the name of this panel to “Placeholder”.

 

  1. Initialize/Setup your GraphicsPanel variable in your Form Constructor as follows

  1.  Now inside the function code block for timer1_Tick(...), add the following

 

 

  • You now have a simple Graphics Window.  The Graphics Project comes with its own Model Class, although currently the Model Class is completely blank. 
  • When you do choose to add stuff to the Model Class, you will have to go into the GraphicsPanel Class and un-comment out the line in the Draw() function that draws the Model.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

§         In the Visual Studio project window, click

    1. Build >> Build Solution
    2. Debug >> Start to run

 

 

 

 

Next Tutorial 8