Beispiel #1
0
        /// <summary>
        /// Unloads this plugin. Removes layers and menu items
        /// </summary>
        public override void Unload()
        {
            // Cleanup
            Cleanup();

            m_parser.Cleanup();

            // Save settings
            Settings.SaveSettings(Path.Combine(KmlDirectory, "KMLImporter.xml"));

            // Remove the icon layer
            Global.worldWindow.CurrentWorld.RenderableObjects.Remove(m_KMLIcons);

            // Disable Drag&Drop functionality
            Global.worldWindow.DragEnter -= new DragEventHandler(WorldWindow_DragEnter);
            Global.worldWindow.DragDrop  -= new DragEventHandler(WorldWindow_DragDrop);

            try
            {
                // Delete the temp kmz extract directory
                if (Directory.Exists(Path.Combine(KmlDirectory, "kmz")))
                {
                    Directory.Delete(Path.Combine(KmlDirectory, "kmz"), true);
                }

                foreach (string kmlfile in Directory.GetFiles(KmlDirectory, "*.kml"))
                {
                    try
                    {
                        File.Delete(kmlfile);
                    }
                    catch (System.IO.IOException)
                    { }
                }

                foreach (string kmzfile in Directory.GetFiles(KmlDirectory, "*.kmz"))
                {
                    try
                    {
                        File.Delete(kmzfile);
                    }
                    catch (System.IO.IOException)
                    { }
                }
            }
            catch (Exception) { }

            base.Unload();
        }
Beispiel #2
0
        /// <summary>
        /// Unloads this plugin. Removes layers and menu items
        /// </summary>
        public override void Unload()
        {
            // Cleanup
            Cleanup();

            m_parser.Cleanup();

            // Save settings
            Settings.SaveSettings(Path.Combine(KmlDirectory, "KMLImporter.xml"));

            // Remove the icon layer
            m_Application.WorldWindow.CurrentWorld.RenderableObjects.Remove(m_KMLIcons);

            // Disable Drag&Drop functionality
            this.Application.WorldWindow.DragEnter -= new DragEventHandler(WorldWindow_DragEnter);
            this.Application.WorldWindow.DragDrop  -= new DragEventHandler(WorldWindow_DragDrop);

            // Remove the menu items
            foreach (MenuItem menuItem in m_Application.MainMenu.MenuItems)
            {
                if (menuItem.Text.Replace("&", "") == "File")
                {
                    foreach (MenuItem subMenuItem in menuItem.MenuItems)
                    {
                        if (subMenuItem.Text == tempMenu.MenuItems[0].Text)
                        {
                            menuItem.MenuItems.RemoveAt(subMenuItem.Index + 1);
                            menuItem.MenuItems.RemoveAt(subMenuItem.Index);
                            break;
                        }
                    }
                }

                if (menuItem.Text.Replace("&", "") == "Help")
                {
                    menuItem.MenuItems.Remove(aboutMenuItem);
                }
            }
            tempMenu.MenuItems.Clear();
            //m_Application.PluginsMenu.MenuItems.Remove(napalmMenuItem);
            m_Application.PluginsMenu.MenuItems.Remove(pluginMenuItem);

            try
            {
                // Delete the temp kmz extract directory
                if (Directory.Exists(Path.Combine(KmlDirectory, "kmz")))
                {
                    Directory.Delete(Path.Combine(KmlDirectory, "kmz"), true);
                }

                foreach (string kmlfile in Directory.GetFiles(KmlDirectory, "*.kml"))
                {
                    try
                    {
                        File.Delete(kmlfile);
                    }
                    catch (System.IO.IOException)
                    {       }
                }

                foreach (string kmzfile in Directory.GetFiles(KmlDirectory, "*.kmz"))
                {
                    try
                    {
                        File.Delete(kmzfile);
                    }
                    catch (System.IO.IOException)
                    {       }
                }
            }
            catch (Exception) {}

            base.Unload();
        }