- Opening a Project
- Creating a Circle
- Creating a Text Label
- Creating a Polygon
- Creating a Complex Polygon
- Creating an Image Label from Buffer
- Editing a Geometry Object
- Working with Feature Layers (Importing and Performing Spatial Queries)
- Navigating – Creating a Fly To
- Navigating – Jumping to a Defined Position
- Retrieving a Position
- Working with Project Tree Groups (Creating, Expanding, Locking)
- Traversing the Project Tree
- Working with Client Data
Opening a Project
This sample demonstrates event handling in the context of opening a project. It shows how to set the parameters for opening the project, retrieve a project interface and then open the project. This example uses the IProject80 (Open) IApplication80 (ExecutablePath) and SGWorld (OnLoadFinished) properties and methods.
private void OpenProject()
{
string tMsg = String.Empty;
// A. Set Project "Open" Method parameters
string tProjectUrl = @"C:\SomePath\SomeFile.fly";
bool bIsAsync = false;
string tUser = String.Empty;
string tPassword = String.Empty;
// B. Instantiate TerraExplorer Object and retrieve Project Interface
try
{
var SGWorld = new SGWorld80();
// C. Register to OnLoadFinished event
SGWorld.OnLoadFinished += new _ISGWorld80Events_OnLoadFinishedEventHandler(OnProjectLoadFinished);
// D. Open Project in synchronous mode
SGWorld.Project.Open(tProjectUrl, bIsAsync, tUser, tPassword);
MessageBox.Show("Opening project "+ tProjectUrl + " in async mode");
}
catch (Exception ex)
{
tMsg = String.Format("OpenProjectButton_Click Exception: {0}", ex.Message);
MessageBox.Show(tMsg);
}
}
void OnProjectLoadFinished (bool bSuccess)
{
string tMsg = String.Empty;
try
{
// OnLoadFinished event Received
MessageBox.Show("Received project loaded event: " + ((bSuccess) ? "Success" : "Failure"));
}
catch (Exception ex)
{
tMsg = String.Format("OnProjectLoadFinished Exception: {0}", ex.Message);
MessageBox.Show(tMsg);
}
}