Your class should look like this:
using System; using System.Runtime.InteropServices; using Microsoft.MapPoint.Rendering3D.Steps.Actors; namespace SimpleFlightSimulator |
There are three methods, Name, Activate and the Deactivate methods, that are a part of the PlugIn class which you will want to override.
public override string Name public SimpleFlightSimulatorPlugin(Host host) public override void Activate(object activationObject) public override void Deactivate() } |
You will now create an Airplane class. This class will have three methods, Load, UpdateCockpit, and UpdateGauges. The Load method will create a ScreenImageActor to overlay the airplane cockpit imagery over the map and a ScreenTextActor to create gauge readings. The gauges will display the coordinates of the Airplane (camera), altitude, pitch (horizon) and heading. The UpdateCockpit method will allow you to change the airplane cockpit image. The UpdateGauges method will retrieve all the data required for the gauges and update the ScreenTextActor. The Airplane class should look like this:
using System; namespace SimpleFlightSimulator public Aiplane(Host host) public void Load(string imageSource, Point imagePosition, Size imageSize, Color gaugeColor, Point gaugePosition) Stream data = Assembly.GetExecutingAssembly().GetManifestResourceStream(imageSource); imageActor = new ScreenImageActor(cockpit, imagePosition, imageSize, null); public void UpdateCockpit(Host host, string imageSource, Point imagePosition, Size imageSize, Color gaugeColor, Point gaugePosition) imageActor.Size = new Size(0, 0); Stream data = Assembly.GetExecutingAssembly().GetManifestResourceStream(imageSource); ScreenImageActor newImageActor = new ScreenImageActor(cockpit, imagePosition, imageSize, null); imageActor = newImageActor; public void UpdateGauges(object state) if (heading <= 0) GeodeticPositionSnapshot position = this._host.Navigation.CameraPosition; //Altitude in meters this.gauges.Text = String.Format("Heading: {0:N2}º\r\nPitch: {1:N2}º\r\nAltitude: {2:N2} m\r\nLatitude: {3:N5}º\r\nLongitude: {4:N5}º", |
Part 1 – http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!756.entry
Part 3 – http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!751.entry
Part 4 – http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!750.entry