示例#1
0
        private void btnSaveLayer_Click(object sender, EventArgs e)
        {
            /* ArcGIS Snippet Title:
             * Display save dialog
             *
             * Intended ArcGIS Products for this snippet:
             * ArcGIS Engine
             *
             * Notes:
             * This snippet is intended to be inserted into the Click event of a Visual Studio button
             * The code assumes that a module-level variable (m_layer) has been declared as ILayer */

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "Layer File|*.lyr|All Files|*.*";
            saveFileDialog.Title            = "Create Layer File";
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.FileName         = System.IO.Path.Combine(saveFileDialog.InitialDirectory, (m_layer.Name + ".lyr"));
            saveFileDialog.ShowDialog();
            string path;

            path = saveFileDialog.FileName;

            //the code for save
            ILayerFile layerFile = new LayerFile();

            layerFile.New(path);
            layerFile.ReplaceContents(m_layer as ILayer);
            layerFile.Save();
        }
示例#2
0
        /// <summary>
        /// 加载.lyr文件
        /// </summary>
        /// <param name="fileName"></param>
        private void OpenLyrFile(string fileName)
        {
            try
            {
                LayerFile playerFile = new LayerFile();
                playerFile.New(fileName);
                ILayer pLayer = playerFile.Layer;
                axGlobeControl.Globe.AddLayerType(pLayer, esriGlobeLayerType.esriGlobeLayerTypeDraped, false);

                IGlobeDisplayLayers globeDisplayLayers = axGlobeControl.Globe.GlobeDisplay as IGlobeDisplayLayers;
                globeDisplayLayers.RefreshLayer(pLayer);
            }
            catch (Exception)
            {
            }
        }
示例#3
0
    public LayerFile ParseFile()
    {
        var file = new LayerFile();

        file.Index   = Index;
        file.Hided   = Hided;
        file.Locked  = Locked;
        file.Content = content;
//		file.Content = new LayerFile.ColorPair[content.Count];
//		int i = 0;
//		foreach (var pair in content) {
//			file.Content[i] = new LayerFile.ColorPair(pair.Key, pair.Value);
//			i++;
//		}

        return(file);
    }
示例#4
0
        /// <summary>
        /// Writes an instance of MapChunk as a file. The object is for now a json string compressed
        /// </summary>
        /// <param name="mapChunkFilePath"></param>
        /// <param name="mapChunk"></param>
        public void MapChunkToFile(string mapChunkFilePath, MapChunk mapChunk)
        {
            Dictionary <string, int> mappedUsedImages = new Dictionary <string, int>();
            //Dictionary<string, int[,]> rawMapChunk = new Dictionary<string, int[,]>();
            List <LayerFile> layerFiles = new List <LayerFile>();

            mappedUsedImages.Add(string.Empty, 0);
            int mappedUsedImageCursor = 1;

            //Spaghetti saving to ram for later saving it to a local file... -.-
            foreach (var layer in mapChunk.Layers)
            {
                int[,] currentMapChunk = new int[mapChunk.SizeX, mapChunk.SizeY];
                var layerFile = new LayerFile();
                layerFile.Name = layer.Name;
                layer.Tiles.ToList().ForEach(tile =>
                {
                    var imgPath = tile.CurrentImage.Path.Replace(MapImage.BasePath, "");
                    if (!mappedUsedImages.ContainsKey(imgPath))
                    {
                        mappedUsedImages.Add(imgPath, mappedUsedImageCursor);
                        mappedUsedImageCursor += 1;
                    }
                    currentMapChunk
                    [
                        Convert.ToInt32(tile.LocationUnit.X),
                        Convert.ToInt32(tile.LocationUnit.Y)
                    ] = mappedUsedImages[imgPath];
                });
                layerFile.Depth = layer.LayerDepth;
                layerFile.Chunk = currentMapChunk;
                layerFiles.Add(layerFile);
            }
            MapChunkFile mapChunkFile = new MapChunkFile()
            {
                Layers           = layerFiles,
                SizeX            = mapChunk.SizeX,
                SizeY            = mapChunk.SizeY,
                MappedUsedImages = mappedUsedImages
                                   .GroupBy(p => p.Value)
                                   .ToDictionary(g => g.Key, g => g.Select(pp => pp.Key).ToList().Single())
            };
            var stringCompressorService = new StringCompressorService();

            File.WriteAllText(mapChunkFilePath, stringCompressorService.CompressString(JsonConvert.SerializeObject(mapChunkFile)));
        }
示例#5
0
        public void InitData(string SvgDataUid)
        {
            LayerFile temp = new LayerFile();

            temp.SvgDataUid = SvgDataUid;
            IList layerList = Services.BaseService.GetList("SelectLayerFileBySvgDataUid", temp);

            //DataTable dt = Itop.Common.DataConverter.ToDataTable(layerList, typeof(LayerFile));
            //ln.Properties.DataSource = dt;
            //ln.Properties.DisplayMember = "LayerFileName";
            checkedListBox1.Items.Clear();
            checkedListBox1.BeginUpdate();
            foreach (LayerFile lay in layerList)
            {
                checkedListBox1.Items.Add(lay);
            }
            checkedListBox1.DisplayMember = "LayerFileName";
            checkedListBox1.EndUpdate();
        }
示例#6
0
    public Layer(LayerFile file, Short2 size, LayerController layerUi)
    {
        this.size    = size;
        this.layerUi = layerUi;

        layerUi.Index = file.Index;
        if (file.Hided)
        {
            layerUi.OnHideToggleClicked();
        }
        if (file.Locked)
        {
            layerUi.OnLockToggleClicked();
        }
//		layerUi.Hided = file.Hided;
//		layerUi.Locked = file.Locked;
        content = file.Content;
//		foreach (var pair in file.Content)
//			content.Add(pair.k, pair.c);

        RenderLayer();
    }