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 WinFormUtility Library

PREQUISITES: Tutorial 2

 

Collecting and Organizing

 

  1. First Startup a new Application as you have done before
  2. Inside the Solution Explorer, Right-Mouse-Button click ‘Solution’ Tutorial and select Add ->> Existing Project
  3. Navigate to the WinFormUtility Project folder
  4. Inside the WinFormUtility Project folder find the WinFormUtility.csproj file and click Open
  5. Right-Mouse-Button click ‘Solution’ Tutorial and select Project Dependicies...
  6. Select your project name in the drop-down-menu and then click on the checkbox next to ‘WinFormUtility
  7. Finally in the Solution Explorer Right-Mouse-Buttom click on the References tab for your project and Add Reference ->> WinFormUtility
  8. 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