Add an Image to an Application

Some controls in the APF framework can be enriched by adding graphics to enhance the user experience. This page describes the steps to add these graphics to your project.

Contents

Add Image to Project

The first step is to add an image resource to the project. The instructions below creates an empty image in the Resources folder, that can be modified afterwards.

  1. In the Solution Explorer, Open the context menu for Resources
  2. Choose Add -> New Item...
  3. In Add New Item dialog, select category Visual C# Project Items
  4. Select Bitmap File.
  5. Enter a suitable name for your image and click Add to close the dialog.
  6. Select the newly added image in the Solution Explorer. Set the property Build Action to Embedded Resource in the Properties window for the image.

Figure 1: Adding a new image to the project.

Note: Images you already have on disk can be added directly by choosing Add -> Existing Item... Make sure to set the Build Action for the image to Embedded Resource.

Add Sal Resource

The next step is to add a SalResource that the APF framework can use.

  1. Locate the Res class in your project. For ported projects this class is usually located in the Res.cs file in the Globals folder.
    If you do not have a Res class, you can add it to the project. To make it work, the class must be called Res and it must be in the default namespace of the project.
  2. In the Res class, add a public static instance of a SalResourceImage for an image resource as added above.
  3. Build the project.
namespace Ifs.Application.Order_
{
    public sealed class Res
    {
        public static SalResourceImage bmpMyImage = new SalResourceImage("MyImage.bmp");
    }
}

Figure 2: Example of a SalResourceImage instance added to the Res class.