Example #1
0
        /// <summary>
        /// Loads this plugin. Initializes variables and adds layers and menu items
        /// </summary>
        public override void Load()
        {
            // Load settings
            Settings.LoadSettings(Path.Combine(KmlDirectory, "KMLImporter.xml"));

            // Initialize the main Icons layer
            m_KMLIcons      = new Icons("KML Icons");
            m_KMLIcons.IsOn = true;

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

            // Add a menu item to the File menu and the Help menu
            MenuItem loadMenuItem = new MenuItem();

            loadMenuItem.Text   = "Import KML/KMZ file...";
            loadMenuItem.Click += new EventHandler(loadMenu_Click);
            int mergeOrder = 0;
            // Napalm enable/disable menu item
            bool bEnabled = Napalm.NapalmIsEnabled(KmlDirectory);

            // Some magic to provide backward compability

            string[] temp = null;
            // If command line arguments are available, try to find one pointing to a kml/kmz file
            if (temp != null)
            {
                foreach (string arg in temp)
                {
                    if (!File.Exists(arg))
                    {
                        continue;
                    }

                    string fExt = Path.GetExtension(arg);

                    if (fExt != ".kml" && fExt != ".kmz")
                    {
                        continue;
                    }

                    LoadDiskKM(arg);
                    break;
                }
            }


            // Add the main Icons layer to the globe
            Global.worldWindow.CurrentWorld.RenderableObjects.Add(m_KMLIcons);

            //Set the currentworld
            // m_world = m_Global.worldWindow.CurrentWorld;

            base.Load();
        }
Example #2
0
        /// <summary>
        /// Loads a KML file in a new thread
        /// </summary>
        /// <param name="path">The path to the KML file to load</param>
        private void Spawn_LoadKML(string path)
        {
            KMLPath = path;

            ThreadStart threadStart = new ThreadStart(LoadKMLFile);
            Thread      kmlThread   = new System.Threading.Thread(threadStart);

            kmlThread.Name         = "KMLImporter worker thread";
            kmlThread.IsBackground = true;
            kmlThread.Start();

            Napalm.Update(KmlDirectory, version);
        }
Example #3
0
        /// <summary>
        /// Toggles the Napalm enabled state
        /// </summary>
        private void napalmMenu_Click(object sender, EventArgs e)
        {
            bool bEnabled = Napalm.NapalmChangeStatus(KmlDirectory, napalmMenuItem.Text.StartsWith("Enable"));

            if (bEnabled)
            {
                napalmMenuItem.Text = "Disable KMLImporter autoupdate";
            }
            else
            {
                napalmMenuItem.Text = "Enable KMLImporter autoupdate";
            }
        }
Example #4
0
        /// <summary>
        /// Loads this plugin. Initializes variables and adds layers and menu items
        /// </summary>
        public override void Load()
        {
            // Load settings
            Settings.LoadSettings(Path.Combine(KmlDirectory, "KMLImporter.xml"));

            // Initialize the main Icons layer
            m_KMLIcons      = new Icons("KML Icons");
            m_KMLIcons.IsOn = false;

            // Setup Drag&Drop functionality
            m_Application.WorldWindow.DragEnter += new DragEventHandler(WorldWindow_DragEnter);
            m_Application.WorldWindow.DragDrop  += new DragEventHandler(WorldWindow_DragDrop);

            // Add a menu item to the File menu and the Help menu
            MenuItem loadMenuItem = new MenuItem();

            loadMenuItem.Text    = "Import KML/KMZ file...";
            loadMenuItem.Click  += new EventHandler(loadMenu_Click);
            aboutMenuItem.Text   = "About KMLImporter";
            aboutMenuItem.Click += new EventHandler(aboutMenu_Click);
            int mergeOrder = 0;

            foreach (MenuItem menuItem in m_Application.MainMenu.MenuItems)
            {
                if (menuItem.Text.Replace("&", "") == "File")
                {
                    foreach (MenuItem subMenuItem in menuItem.MenuItems)
                    {
                        subMenuItem.MergeOrder = mergeOrder;

                        if (subMenuItem.Text == "-")
                        {
                            mergeOrder = 2;                                     // Everything after this should come after our new items
                        }
                    }

                    tempMenu.Text       = menuItem.Text;
                    tempMenu.MergeOrder = 1;                            // MergeOrder 1 will have 0 before it and 2 after it
                    tempMenu.MenuItems.Add(loadMenuItem);
                    tempMenu.MenuItems.Add(new MenuItem("-"));
                    menuItem.MergeMenu(tempMenu);
                }

                if (menuItem.Text.Replace("&", "") == "Help")
                {
                    menuItem.MenuItems.Add(aboutMenuItem);
                }
            }

            // Napalm enable/disable menu item
            bool bEnabled = Napalm.NapalmIsEnabled(KmlDirectory);

            if (bEnabled)
            {
                napalmMenuItem.Text = "Disable KMLImporter autoupdate";
            }
            else
            {
                napalmMenuItem.Text = "Enable KMLImporter autoupdate";
            }
            napalmMenuItem.Click += new EventHandler(napalmMenu_Click);
            pluginMenuItem.MenuItems.Add(napalmMenuItem);

            // Allways show labels enable/disable menu item
            labelMenuItem.Text    = "Show all labels";
            labelMenuItem.Checked = Settings.ShowAllLabels;
            labelMenuItem.Click  += new EventHandler(labelMenuItem_Click);
            pluginMenuItem.MenuItems.Add(labelMenuItem);

            // Add a menu item to the Plugins menu
            pluginMenuItem.Text = "KMLImporter";
            m_Application.PluginsMenu.MenuItems.Add(pluginMenuItem);

            // Some magic to provide backward compability
            Type typecontroller = typeof(MainApplication);

            System.Reflection.PropertyInfo finfo = typecontroller.GetProperty("CmdArgs", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetProperty);
            string[] temp = null;
            if (finfo != null)
            {
                temp = (string[])finfo.GetValue(null, null);

                // If command line arguments are available, try to find one pointing to a kml/kmz file
                if (temp != null)
                {
                    foreach (string arg in temp)
                    {
                        if (!File.Exists(arg))
                        {
                            continue;
                        }

                        string fExt = Path.GetExtension(arg);

                        if (fExt != ".kml" && fExt != ".kmz")
                        {
                            continue;
                        }

                        LoadDiskKM(arg);
                        break;
                    }
                }
            }

            // Add the main Icons layer to the globe
            m_Application.WorldWindow.CurrentWorld.RenderableObjects.Add(m_KMLIcons);

            //Set the currentworld
            // m_world = m_Application.WorldWindow.CurrentWorld;

            base.Load();
        }