20170130 Setting up a C# application for solving an assignment

20170130 Setting up a C# application for solving an assignment
This document briefly explains how to set up your own C# application for solving an assignment (except
for the DI assignments; for that case, see the document “An explanation …” posted on 20170125 on the
course web page). Below, it will be assumed that you have already define the C# solution in which the
application should be added. If not, see the document mentioned above (“An explanation …”).
For most of the assignments, you need to set up your own application. Consider, for example, the first
image processing assignment (IP1). Do the following:
Step 1: Open your solution in the C# IDE
Step 1: Opening your solution. If you have already started with the DI1 assignment, the solution will probably
look like above (see also the document “An explanation …”, posted 20170125 on the web page).
Step 2: Right-click on the solution, and select Add – New project … The following window appears:
Step 3: Change the name of the application as appropriate. In this case, write AssignmentIP1:
Step 3: Naming the assignment. It is important to set the correct name at this stage!
Step 4: Click OK: Your new project (application) now appears in the Solution Explorer.
Step 4: The new project (AssignmentIP1) appears in the Solution Explorer (left panel above). In Windows Explorer,
you can see that a new folder has been added (right panel). (AssigmentDI1/ contains the Agent, Listener, and
Speech applications, if you have followed the setup described in “An explanation … (20170125)).
Step 5 (optional): Set the new project as the StartUp project: Right-click on AssignmentIP1 and select Set
as StartUp Project. Now you can just press F5 or the green arrow to run the project. If you do that, you
will simply see Form1 displayed on the screen.
Now you are done with the setup of the application.
Next, you should rename the form (Form1 is not an appropriate name). To do so, right-click on Form1.cs,
select Rename … and set a more suitable name (e.g. MainForm.cs) (then click Yes, when asked).
Finally, for the IP1 application, you will need access to the ImageProcessing library, which is not yet in the
solution. Do the following: Right-click on the solution, and select Add – Existing Project… Then browse to
the Libraries/ folder, and then continue to ImageProcessingLibrary, and then open (or double-click)
ImageProcessingLibrary.csproj. Now the ImageProcessingLibrary is in your solution, but you can still not
see it from your application. To solve that, right-click on References in AssignmentIP1, click on Projects
in the left margin, and then select the ImageProcessingLibrary (see the figure above), and click OK. Now
the ImageProcessingLibrary appears in your solution. In order to use it (for example in the MainForm of
AssignmentIP1), add a using-clause in MainForm.cs, as follows: