Exemple #1
0
        void IconURLMenuItem_Click(object sender, EventArgs s)
        {
            try
            {
                if (!ClickableActionURL.Contains(@"worldwind://"))
                {
                    if (World.Settings.UseInternalBrowser && ClickableActionURL.StartsWith("http"))
                    {
                        SplitContainer          sc      = (SplitContainer)DrawArgs.ParentControl.Parent.Parent;
                        InternalWebBrowserPanel browser = (InternalWebBrowserPanel)sc.Panel1.Controls[0];
                        browser.NavigateTo(ClickableActionURL);
                    }
                    else
                    {
                        ProcessStartInfo psi = new ProcessStartInfo();
                        psi.FileName        = ClickableActionURL;
                        psi.Verb            = "open";
                        psi.UseShellExecute = true;

                        psi.CreateNoWindow = true;
                        Process.Start(psi);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message.ToString());
            }
        }
Exemple #2
0
            /// <summary>
            /// Goes to icon if camera positions set.  Also opens URL if it exists
            /// </summary>
            /// <param name="drawArgs"></param>
            /// <returns></returns>
            protected virtual bool PerformLMBAction(DrawArgs drawArgs)
            {
                try
                {
                    // Goto to URL if we have one
                    if (Url != null && !Url.Contains(@"worldwind://"))
                    {
                        if (World.Settings.UseInternalBrowser && Url.StartsWith("http"))
                        {
                            SplitContainer          sc      = (SplitContainer)drawArgs.parentControl.Parent.Parent;
                            InternalWebBrowserPanel browser = (InternalWebBrowserPanel)sc.Panel1.Controls[0];
                            browser.NavigateTo(Url);
                        }
                        else
                        {
                            ProcessStartInfo psi = new ProcessStartInfo();
                            psi.FileName        = Url;
                            psi.Verb            = "open";
                            psi.UseShellExecute = true;

                            psi.CreateNoWindow = true;
                            Process.Start(psi);
                        }
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message.ToString());
                }
                return(false);
            }
Exemple #3
0
        private void GetFeatureDlComplete(WorldWind.Net.WebDownload dl)
        {
            if (World.Settings.UseInternalBrowser)
            {
                SplitContainer          sc      = (SplitContainer)drawArgs.parentControl.Parent.Parent;
                InternalWebBrowserPanel browser = (InternalWebBrowserPanel)sc.Panel1.Controls[0];
                browser.NavigateTo(dl.SavedFilePath);
            }
            else
            {
                System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
                psi.FileName        = dl.SavedFilePath;
                psi.Verb            = "open";
                psi.UseShellExecute = true;

                psi.CreateNoWindow = true;
                System.Diagnostics.Process.Start(psi);
            }
        }
Exemple #4
0
        public bool OnMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            if (!Visible)
            {
                return(false);
            }

            bool handled = false;

            if (e.X > AbsoluteLocation.X + clickBuffer && e.X < AbsoluteLocation.X + ClientSize.Width - clickBuffer &&
                e.Y > AbsoluteLocation.Y + clickBuffer && e.Y < AbsoluteLocation.Y + ClientSize.Height - clickBuffer)
            {
                if (OnMouseUpEvent != null)
                {
                    OnMouseUpEvent(this, e);
                }

                handled = true;
            }

            if (ClickableUrl != null && e.X > AbsoluteLocation.X + clickBuffer && e.X < AbsoluteLocation.X + ClientSize.Width - clickBuffer &&
                e.Y > AbsoluteLocation.Y + clickBuffer && e.Y < AbsoluteLocation.Y + ClientSize.Height - clickBuffer)
            {
                if ((World.Settings.UseInternalBrowser && ClickableUrl.StartsWith("http")) || ClickableUrl.StartsWith(@"worldwind://"))
                {
                    SplitContainer          sc      = (SplitContainer)DrawArgs.ParentControl.Parent.Parent;
                    InternalWebBrowserPanel browser = (InternalWebBrowserPanel)sc.Panel1.Controls[0];
                    browser.NavigateTo(ClickableUrl);
                }
                else
                {
                    ProcessStartInfo psi = new ProcessStartInfo();
                    psi.FileName        = ClickableUrl;
                    psi.Verb            = "open";
                    psi.UseShellExecute = true;

                    psi.CreateNoWindow = true;
                    Process.Start(psi);
                }
                handled = true;
            }
            return(handled);
        }
Exemple #5
0
        void WorldWindow_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            if (m_Form == null)
            {
                return;
            }

            if (!m_Form.Visible)
            {
                return;
            }

            if (m_Form.KeyLayer == null)
            {
                return;
            }

            QuadTileSet qts = m_Form.KeyLayer;

            WorldWind.Net.Wms.WmsImageStore wms = (WorldWind.Net.Wms.WmsImageStore)qts.ImageStores[0];

            string requestUrl = wms.ServerGetMapUrl;

            string[] layerNameParts = wms.WMSLayerName.Split('&');
            string   layerName      = layerNameParts[0];
            string   getMapParts    =
                requestUrl += "?QUERY_LAYERS=" + layerName + "&SERVICE=WMS&VERSION=" + wms.Version + "&REQUEST=GetFeatureInfo&SRS=EPSG:4326&FEATURE_COUNT=10&INFO_FORMAT=text/plain&EXCEPTIONS=text/plain";

            // From Servir-Viz...
            Angle  LowerLeftX;
            Angle  LowerLeftY;
            Angle  UpperRightX;
            Angle  UpperRightY;
            string minx, miny, maxx, maxy;

            char[] degreeChar = { '°' };

            int mouseX = e.X;
            int mouseY = e.Y;

            int queryBoxWidth  = 2 * queryBoxOffset + 1;
            int queryBoxHeight = 2 * queryBoxOffset + 1;

            int queryX = queryBoxOffset + 1;
            int queryY = queryBoxOffset + 1;

            drawArgs.WorldCamera.PickingRayIntersectionWithTerrain(mouseX - queryBoxOffset, mouseY + queryBoxOffset, out LowerLeftY, out LowerLeftX, drawArgs.CurrentWorld);
            drawArgs.WorldCamera.PickingRayIntersectionWithTerrain(mouseX + queryBoxOffset, mouseY - queryBoxOffset, out UpperRightY, out UpperRightX, drawArgs.CurrentWorld);

            //drawArgs.WorldCamera.PickingRayIntersectionWithTerrain(0, 0 + drawArgs.screenHeight, out LowerLeftY, out LowerLeftX, drawArgs.CurrentWorld);
            //drawArgs.WorldCamera.PickingRayIntersectionWithTerrain(drawArgs.screenWidth, 0, out UpperRightY, out UpperRightX, drawArgs.CurrentWorld);

            minx = LowerLeftX.ToString().Contains("NaN") ? "-180.0" : LowerLeftX.ToString().TrimEnd(degreeChar);
            miny = LowerLeftY.ToString().Contains("NaN") ? "-90.0" : LowerLeftY.ToString().TrimEnd(degreeChar);
            maxx = UpperRightX.ToString().Contains("NaN") ? "180.0" : UpperRightX.ToString().TrimEnd(degreeChar);
            maxy = UpperRightY.ToString().Contains("NaN") ? "90.0" : UpperRightY.ToString().TrimEnd(degreeChar);

            // request has to include a bbox and the requested pixel coords relative to that box...
            requestUrl += "&layers=" + wms.WMSLayerName;
            requestUrl += "&WIDTH=" + queryBoxWidth.ToString() + "&HEIGHT=" + queryBoxHeight.ToString();
            requestUrl += "&BBOX=" + minx + "," + miny + "," + maxx + "," + maxy;
            requestUrl += "&X=" + queryX.ToString() + "&Y=" + queryY.ToString();

            if (!World.Settings.WorkOffline)
            {
                WorldWind.Net.WebDownload dl = new WorldWind.Net.WebDownload(requestUrl);
                System.IO.FileInfo        fi = new System.IO.FileInfo("GetFeatureInfo_response.txt");
                dl.DownloadFile(fi.FullName);
                //dl.SavedFilePath = fi.FullName;
                //dl.BackgroundDownloadFile(GetFeatureDlComplete);


                if (World.Settings.UseInternalBrowser)
                {
                    SplitContainer          sc      = (SplitContainer)drawArgs.parentControl.Parent.Parent;
                    InternalWebBrowserPanel browser = (InternalWebBrowserPanel)sc.Panel1.Controls[0];
                    browser.NavigateTo(fi.FullName);
                }
                else
                {
                    System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
                    psi.FileName        = fi.FullName;
                    psi.Verb            = "open";
                    psi.UseShellExecute = true;

                    psi.CreateNoWindow = true;
                    System.Diagnostics.Process.Start(psi);
                }
            }
        }
Exemple #6
0
        public override bool PerformSelectionAction(DrawArgs drawArgs)
        {
            foreach (RenderableObject ro in m_children)
            {
                if (!ro.IsOn)
                {
                    continue;
                }
                if (!ro.isSelectable)
                {
                    continue;
                }

                Icon icon = ro as Icon;
                if (icon == null)
                {
                    // Child is not an icon
                    if (ro.PerformSelectionAction(drawArgs))
                    {
                        return(true);
                    }
                    continue;
                }

                if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(icon.Position))
                {
                    continue;
                }

                Vector3 referenceCenter = new Vector3(
                    (float)drawArgs.WorldCamera.ReferenceCenter.X,
                    (float)drawArgs.WorldCamera.ReferenceCenter.Y,
                    (float)drawArgs.WorldCamera.ReferenceCenter.Z);

                Vector3 projectedPoint = drawArgs.WorldCamera.Project(icon.Position - referenceCenter);
                if (!icon.SelectionRectangle.Contains(
                        DrawArgs.LastMousePosition.X - (int)projectedPoint.X,
                        DrawArgs.LastMousePosition.Y - (int)projectedPoint.Y))
                {
                    continue;
                }

                try
                {
                    if (DrawArgs.IsLeftMouseButtonDown && !DrawArgs.IsRightMouseButtonDown)
                    {
                        if (icon.OnClickZoomAltitude != double.NaN || icon.OnClickZoomHeading != double.NaN || icon.OnClickZoomTilt != double.NaN)
                        {
                            drawArgs.WorldCamera.SetPosition(
                                icon.Latitude,
                                icon.Longitude,
                                icon.OnClickZoomHeading,
                                icon.OnClickZoomAltitude,
                                icon.OnClickZoomTilt);
                        }


                        if (!icon.ClickableActionURL.Contains(@"worldwind://"))
                        {
                            if (World.Settings.UseInternalBrowser)
                            {
                                SplitContainer          sc      = (SplitContainer)drawArgs.parentControl.Parent.Parent;
                                InternalWebBrowserPanel browser = (InternalWebBrowserPanel)sc.Panel1.Controls[0];
                                browser.NavigateTo(icon.ClickableActionURL);
                            }
                            else
                            {
                                ProcessStartInfo psi = new ProcessStartInfo();
                                psi.FileName        = icon.ClickableActionURL;
                                psi.Verb            = "open";
                                psi.UseShellExecute = true;

                                psi.CreateNoWindow = true;
                                Process.Start(psi);
                            }
                        }
                    }
                    else if (!DrawArgs.IsLeftMouseButtonDown && DrawArgs.IsRightMouseButtonDown)
                    {
                        ScreenOverlay[] overlays = icon.Overlays;
                        if (overlays != null && overlays.Length > 0)
                        {
                            System.Windows.Forms.ContextMenu contextMenu = new System.Windows.Forms.ContextMenu();
                            foreach (ScreenOverlay curOverlay in overlays)
                            {
                                contextMenu.MenuItems.Add(curOverlay.Name, new System.EventHandler(icon.OverlayOnOpen));
                            }
                            contextMenu.Show(DrawArgs.ParentControl, DrawArgs.LastMousePosition);
                        }
                    }
                    return(true);
                }
                catch
                {
                }
            }
            return(false);
        }
Exemple #7
0
        public bool OnMouseUp(MouseEventArgs e)
        {
            if (e.Y < this._y)
            {
                // Above
                return(false);
            }

            if (e.Y <= this._y + 20)
            {
                if (e.X > this._x + this._itemXOffset &&
                    e.X < this._x + (this._itemXOffset + this._width) &&
                    e.Button == MouseButtons.Right)
                {
                    m_parent.ShowContextMenu(e.X, e.Y, this);
                }

                if (e.X > this._x + this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset &&
                    e.X < this._x + (this._itemXOffset + this._width) &&
                    e.Button == MouseButtons.Left &&
                    m_renderableObject != null &&
                    m_renderableObject.MetaData.Contains("InfoUri"))
                {
                    string infoUri = (string)m_renderableObject.MetaData["InfoUri"];

                    if (World.Settings.UseInternalBrowser || infoUri.StartsWith(@"worldwind://"))
                    {
                        SplitContainer          sc      = (SplitContainer)this.ParentControl.Parent.Parent;
                        InternalWebBrowserPanel browser = (InternalWebBrowserPanel)sc.Panel1.Controls[0];
                        browser.NavigateTo(infoUri);
                    }
                    else
                    {
                        ProcessStartInfo psi = new ProcessStartInfo();
                        psi.FileName        = infoUri;
                        psi.Verb            = "open";
                        psi.UseShellExecute = true;
                        psi.CreateNoWindow  = true;
                        Process.Start(psi);
                    }
                }

                if (e.X > this._x + this._itemXOffset &&
                    e.X < this._x + (this._itemXOffset + this._expandArrowXSize) &&
                    m_renderableObject is MFW3D.Renderable.RenderableObjectList)
                {
                    MFW3D.Renderable.RenderableObjectList rol = (MFW3D.Renderable.RenderableObjectList)m_renderableObject;
                    if (!rol.DisableExpansion)
                    {
                        this.isExpanded = !this.isExpanded;
                        return(true);
                    }
                }

                if (e.X > this._x + this._itemXOffset + this._expandArrowXSize &&
                    e.X < this._x + (this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset))
                {
                    if (!m_renderableObject.IsOn && m_renderableObject.ParentList != null &&
                        m_renderableObject.ParentList.ShowOnlyOneLayer)
                    {
                        m_renderableObject.ParentList.TurnOffAllChildren();
                    }

                    m_renderableObject.IsOn = !m_renderableObject.IsOn;
                    return(true);
                }
            }

            if (isExpanded)
            {
                foreach (LayerMenuItem lmi in m_subItems)
                {
                    if (lmi.OnMouseUp(e))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }