Ejemplo n.º 1
0
        internal async static Task <string> GetContentsAsXmlAsync(string datapath)
        {
            if (datapath == null)
            {
                throw new ArgumentNullException("datapath");
            }
            if (datapath == string.Empty)
            {
                throw new ArgumentException("datapath is empty string");
            }

            if (!_cache.ContainsKey(datapath))
            {
                Trace.TraceInformation("{0}:   Begin Load ESRI Metadata for dataset path: {1}", DateTime.Now, datapath);
                await EsriLicense.GetLicenseAsync();

                await Task.Run(() => Load(datapath));

                Trace.TraceInformation("{0}:   End   Load ESRI Metadata for dataset path: {1}", DateTime.Now, datapath);
            }
            if (_cache.ContainsKey(datapath))
            {
                return(_cache[datapath]);
            }
            return(null);
        }
Ejemplo n.º 2
0
        private static async Task <bool> InitLayerFileAsync(string file)
        {
            await EsriLicense.GetLicenseAsync();

            return(await Task.Run(() => {
                _mapDocument = new MapDocumentClass();
                _mapDocument.Open(file);
                return _mapDocument.IsMapDocument[file];
            }));
        }
Ejemplo n.º 3
0
        private static async Task <ILayer> InitLayerFileAsync(string file)
        {
            await EsriLicense.GetLicenseAsync();

            var layerFile = new LayerFileClass();
            var layer     = await Task.Run(() =>
            {
                layerFile.Open(file);
                var l = layerFile.Layer;
                layerFile.Close();
                return(l);
            });

            return(layer);
        }
Ejemplo n.º 4
0
        private async Task CreateMapControlAsync()
        {
            Trace.TraceInformation("{0}: Start of CreateMapControl()", DateTime.Now); Stopwatch time = Stopwatch.StartNew();
            ShowText("Loading preview image...");

            await EsriLicense.GetLicenseAsync();

            Trace.TraceInformation("{0}: CreateMapControl()- Got License - Elapsed time: {1}", DateTime.Now, time.Elapsed);

            mapToolbar = new AxToolbarControl();
            ((ISupportInitialize)mapToolbar).BeginInit();
            mapToolbar.Name = "mapToolbar";
            //mapToolbar.Anchor = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
            mapToolbar.Location = new Point(0, 0);
            mapToolbar.Size     = new Size(600, 28);
            //AutoScaleDimensions = new System.Drawing.SizeF(6f, 13F);
            //AutoScaleMode = AutoScaleMode.Font;
            ((ISupportInitialize)mapToolbar).EndInit();

            mapControl = new AxMapControl();
            ((ISupportInitialize)mapControl).BeginInit();
            mapControl.Name     = "mapControl";
            mapControl.Anchor   = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
            mapControl.Location = new Point(0, 28);
            mapControl.Size     = new Size(_parent.ClientSize.Width, _parent.ClientSize.Height - 28);
            _form.ResizeBegin  += MapViewer_ResizeBegin;
            _form.ResizeEnd    += MapViewer_ResizeEnd;
            ((ISupportInitialize)mapControl).EndInit();

            // I can't add items until it is activated in a parent control
            PrepPageForMap();
            mapToolbar.AddItem("esriControls.ControlsMapZoomInTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            mapToolbar.AddItem("esriControls.ControlsMapZoomOutTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            mapToolbar.AddItem("esriControls.ControlsMapPanTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            mapToolbar.AddItem("esriControls.ControlsMapFullExtentCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            mapToolbar.AddItem("esriControls.ControlsMapZoomToLastExtentBackCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            mapToolbar.AddItem("esriControls.ControlsMapZoomToLastExtentForwardCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //tocControl.SetBuddyControl(mapControl);
            mapToolbar.SetBuddyControl(mapControl);

            time.Stop(); Trace.TraceInformation("{0}: End of CreateMapControl() - Elapsed time: {1}", DateTime.Now, time.Elapsed);
        }
Ejemplo n.º 5
0
 public static async Task<bool> InitializeAsync()
 {
     return await EsriLicense.StartAsync();
 }
Ejemplo n.º 6
0
 public static async Task <bool> InitializeAsync()
 {
     return(await Task.Run(() => { return EsriLicense.Start(); }));
 }