示例#1
0
        /// <summary>
        /// Saves map state with currently open grid proxy, then reloads and checks if grid was recognized correctly
        /// </summary>
        public static void ReloadMapStateWithGridProxy(string stateFilename)
        {
            var img = axMap1.GetActiveLayer();

            //if (img == null || !img.IsGridProxy)
            //{
            //    MessageBox.Show("Map must have one layer with grid proxy");
            //}
            //else
            //{
            if (axMap1.SaveMapState(stateFilename, true, true))
            {
                axMap1.RemoveAllLayers();
                if (!axMap1.LoadMapState(stateFilename, null))
                {
                    MessageBox.Show("Failed to load map state");
                }
                else
                {
                    img = axMap1.GetActiveLayer();
                    if (img == null)
                    {
                        MessageBox.Show("Image layer wasn't reloaded");
                    }
                    else if (!img.IsGridProxy)
                    {
                        MessageBox.Show("Image is no longer a proxy");
                    }
                    else
                    {
                        MessageBox.Show("SUCCESS: Image was successfully reloaded as proxy");
                    }
                }
            }
            else
            {
                MessageBox.Show("Failed to save map state");
            }
            //}
        }