Getting Started

The means of adding an ActiveX Control will be specific to the ActiveX Control Container program being used. If the desired ActiveX Control Container does not appear here then consult its documentation.

Note: An ActiveX Control design-time licence is required in order to create applications.

Creating an ActiveX Control and Licensing it

All ActiveX applications and GisLink Add-Ins should target .NET Framework 4.5.

32-bit and 64-bit

Cadcorp SIS ActiveX applications must target either x86 or x64 systems. These applications will not work with ‘Any CPU’.

Use the Visual Studio.NET Build Configuration Manager to set the project’s target platform to x86 or x64.

When referencing the Cadcorp SIS ActiveX component it is necessary to select the relevant x86 or x64 installation.

Because Visual Studio is a 32-bit application, it can be awkward to create an application from scratch using the 64-bit SIS COM component. It is therefore recommended that you construct your ActiveX application using 32-bit SIS. If you require a 64-bit application then create this from the working 32-bit project as follows:

  1. Install both 32-bit and 64-bit SIS.
  2. Create a copy of the 32-bit project.
  3. Edit this copy so it links to the same forms etc. as the original (i.e. one set of code for two projects).
  4. Change the copy’s target platform to x64.
  5. Delete the copy’s references to 32-bit SIS.
  6. Add a new reference in the copy to 64-bit SIS.
  7. Build the project.

Create a control

The recommended way to do this is to use the Visual Studio Form Designer:

  1. Create or open your Windows Forms Application project;
  2. Add to the project a reference to Cadcorp.SIS.Control.ocx (located in the Cadcorp SIS 8.0 program folder) – select the x86 or x64 installation as appropriate;
  3. If this is the first time you’ve used the SIS ActiveX component you will need to add it to the toolbox:
    1. Right-click on Toolbox and select Choose items…
    2. Look in COM Components tab and tick Cadcorp SIS Control (make sure you select version 8.0 if you have multiple versions of SIS installed, e.g. 7.0, 7.1, 8.0).
  4. Drag the Cadcorp SIS Control from the Toolbox onto the windows form;
  5. You should now have a new AxSisLib.AxSis control on the form; it will be named axSis1. In the code snippets which follow this control has been renamed to sis.

Note: If you encounter problems at step 4 it is worth trying the following:

Create your SIS Constants file

Many SIS methods take parameters as arguments so it is necessary to add a file of SIS Constants to your project.

Right click In the right-hand pane of the Developer Control Bar and select Generate Programming File….

Add the resultant file to your Visual Studio project.

Licence the application

To check for a licence you need to supply:

You also need to decide whether to check for a local licence or a network licence.

The function below performs a licence check at Modeller level; it checks for either the server defined in CADCORP_LICENCE_SERVER_LIST or for a local licence.

        private bool isLicenced()
        {
            bool result = false;

            sis.LicenceKey = "PutYourLicenceKeyHere";
            sis.LicenceSuffix = "PutYourLicenceSuffixHere";
           
            // see if CADCORP_LICENCE_SERVER_LIST is set
            string sysVarLshost = Environment.GetEnvironmentVariable("CADCORP_LICENCE_SERVER_LIST");
            if (string.IsNullOrWhiteSpace(sysVarLshost))
            {
                // CADCORP_LICENCE_SERVER_LIST not set so set for local licence
                sis.SetStr(Cadcorp.SIS.Constants.SIS_OT_SYSTEM, 0, "_SentinelRMSServerList$", "no-net");   
            }
            else
            {
                // CADCORP_LICENCE_SERVER_LIST set so set which server for licence
                sis.SetStr(Cadcorp.SIS.Constants.SIS_OT_SYSTEM, 0, "_SentinelRMSServerList$", sysVarLshost);
                // allow for a longer timeout
                sis.SetInt(Cadcorp.SIS.Constants.SIS_OT_SYSTEM, 0, "_SentinelRMSTimeoutInterval&", 60);
            }

            // try to set the licence level
            sis.Level = Cadcorp.SIS.Constants.SIS_LEVEL_MODELLER;
            if (sis.Level == Cadcorp.SIS.Constants.SIS_LEVEL_MODELLER) result = true;

            return result;
        }

Load Open Streetmap Tiles (3857)

A file can be loaded into the SWD with either the InsertDataset method (results in a new read-only overlay) or the ImportDataset method (results in a new editable copy of the dataset). Multiple files can be loaded into multiple overlays in the SWD by repeatedly calling the relevant method.

The following code inserts an open streetmap tile (hardcoded file name) into the swd on top of any existing overlays:

int overlayNo = sis.GetInt(Cadcorp.SIS.Constants.SIS_OT_WINDOW, 0, "_nOverlay&");
sis.InsertDataset(@"d:\temp\acme\map.osm", (short) overlayNo);

These files load with their own in-built projection.

Changing the projection of a dataset

Shape files are loaded the same way as any file-based dataset, i.e. see section above for Open Streetmap. If there is no .prj present then the files will load in as the current projection – which will be WGS84 unless specified otherwise.

A dataset can be re-projected after loading by setting the dataset projection using the method:

sis.SetDatasetPrj(datasetNo, ProjectionString)

However, this must be used with care and an understanding of the units in the dataset.

Some examples how to use this method are:

sis.SetDatasetPrj(datasetNo, "WGS 84.World Mercator”)

sis.SetDatasetPrj(datasetNo, "ETRS89.ETRS-LCC-EPSG-3034”)

sis.SetDatasetPrj(datasetNo, "OSGB 1936.British National Grid”)

Note: These examples are for illustration purposes only and may not be generically useful.

Set scale thresholds on these overlays

These are overlay properties of type double and can be set thus:

sis.SetFlt(Cadcorp.SIS.Constants.SIS_OT_OVERLAY, overlayNo, "_scalemin#", 2500.0);

sis.SetFlt(Cadcorp.SIS.Constants.SIS_OT_OVERLAY, overlayNo, "_scalemax#", 500000.0);

Set view scale/extents and centre

The view scale can be set as shown:

sis.SetFlt(Cadcorp.SIS.Constants.SIS_OT_ WINDOW, 0, "_displayScale#", double_value);

The view extent can be set thus:

sis.SetViewExtent(x1, y1, 0, x2, y2, 0);

To change the centre of the view you calculate a new extent and set that.

Note: Extent and scale are not independent. If you change the scale then the extent also changes and vice-versa.

Get the rendered image

The current view can be exported to a file using any of the following methods:

sis.ExportBds
sis.ExportBmp
sis.ExportEcw
sis.ExportGif
sis.ExportJpeg
sis.ExportPng
sis.ExportRaster
sis.ExportTiff
sis.ExportWmff


Top of page

Send comments on this topic.

Click to return to www.cadcorp.com

© Copyright 2000-2017 Computer Aided Development Corporation Limited (Cadcorp).