コード例 #1
0
ファイル: frmMain.cs プロジェクト: zwq00000/SharpAIS
        public frmMain()
        {
            InitializeComponent();

            uxMap.Projection = KnownCoordinateSystems.Projected.World.WebMercator;
            uxMap.BackColor  = Color.FromArgb(181, 208, 208);

            backgroundLayer = BruTileLayer.CreateOsmLayer();
            uxMap.Layers.Add(backgroundLayer);

            pseudoAisPort.LogFilePath   = Application.StartupPath + "\\AIS.log";
            pseudoAisPort.DataReceived += new EventHandler <SerialDataReceivedEventArgs>(pseudoAisPortDataReceived);

            refreshTimer.Enabled  = false;
            refreshTimer.Interval = 1500;
            refreshTimer.Tick    += new EventHandler(refreshTimerTick);

            helper       = new AISHelper(uxMap.Projection);
            vesselsLayer = helper.VesselsLayer;
            uxMap.MapFrame.Add(vesselsLayer);

            uxMap.ViewExtents = new Extent(1642982.27031471, 4063251.12000095, 3802748.48786722, 5126261.05520257);

            if (DotSpatial.Plugins.AISViewer.Properties.Settings.Default.UsePseudoPort)
            {
                pseudoAisPort.Open();
            }
            else
            {
                aisPort.Open();
            }

            refreshTimer.Enabled = true;
        }
コード例 #2
0
        public static void ToggleSatelliteLayer(frmMain pFrm, bool pRemove = false)
        {
            if (pFrm.satellite == null)
            {
                pFrm.satellite = BruTileLayer.CreateOsmLayer();
                //pFrm.satellite = BruTileLayer.CreateBingAerialLayer();
                pFrm.satellite.LegendText = "OSM Tile Layer";
            }

            ILayer mLandLayer = null;

            foreach (var mGroup in pFrm.theMap.GetAllLayers())
            {
                if (mGroup.LegendText == "Abu Dhabi Emirate")
                {
                    mLandLayer = mGroup;
                    break;
                }
            }

            if (pFrm.theMap.Layers.Contains(pFrm.satellite) || pRemove)
            {
                pFrm.theMap.Layers.Remove(pFrm.satellite);
                if (mLandLayer != null)
                {
                    mLandLayer.IsVisible = true;
                }
            }
            else
            {
                pFrm.theMap.Layers.Insert(0, pFrm.satellite);
                pFrm.satellite.LegendText = "Bing (satellite)";
                if (mLandLayer != null)
                {
                    mLandLayer.IsVisible = false;
                }
            }
        }