Exemplo n.º 1
0
        internal static ServerModelNode AddServerToHomeView(DappleModel oModel, LayerBuilder oLayer)
        {
            const bool Enabled = true;
            const bool DontAddToHomeViewYet     = false;
            const bool DontSubmitToDappleSearch = false;

            ServerModelNode result = null;

            // --- Add the server to the model ---

            if (oLayer is ArcIMSQuadLayerBuilder)
            {
                ArcIMSQuadLayerBuilder castLayer = oLayer as ArcIMSQuadLayerBuilder;
                result = oModel.AddArcIMSServer(new ArcIMSServerUri(castLayer.ServerURL), Enabled, DontAddToHomeViewYet, DontSubmitToDappleSearch);
            }
            else if (oLayer is DAPQuadLayerBuilder)
            {
                DAPQuadLayerBuilder castLayer = oLayer as DAPQuadLayerBuilder;
                result = oModel.AddDAPServer(new DapServerUri(castLayer.ServerURL), Enabled, DontAddToHomeViewYet, DontSubmitToDappleSearch);
            }
            else if (oLayer is WMSQuadLayerBuilder)
            {
                WMSQuadLayerBuilder castLayer = oLayer as WMSQuadLayerBuilder;
                result = oModel.AddWMSServer(new WMSServerUri(castLayer.ServerURL), Enabled, DontAddToHomeViewYet, DontSubmitToDappleSearch);
            }
            else
            {
                throw new ApplicationException("Don't know how to get the server of type " + oLayer.GetType().ToString());
            }

            result.AddToHomeView();

            return(result);
        }
Exemplo n.º 2
0
        internal override LayerBuilder getBuilder(DappleModel oModel)
        {
            WMSServerModelNode oServer = oModel.AddWMSServer(m_oServer as WMSServerUri, true, false, false) as WMSServerModelNode;
            if (oServer.Enabled == false)
                if (DialogResult.Yes == MessageBox.Show(String.Format(CultureInfo.InvariantCulture, "The WMS server {1} is in your server list, but is disabled.{2}'{0}' cannot be displayed unless the server is re-enabled.{2}{2}Do you wish to enable {1}?", getAttribute("layer"), m_oServer.ServerTreeDisplayName, Environment.NewLine),
                    "Server is Disabled", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1))
                    oModel.ToggleServer(oServer, true);
                else
                    return null;

            oServer.WaitForLoad();
            if (oServer.LoadState == LoadState.LoadFailed)
            {
                Program.ShowMessageBox(String.Format(CultureInfo.InvariantCulture, "'{0}' could not be added. Connection with the server at URL '{1}' failed. Refreshing the server from the Servers tab may resolve this problem.", getAttribute("layer"), m_oServer.ServerTreeDisplayName),
                    "Dataset Could Not Be Added", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error);
                return null;
            }

            WMSLayerModelNode oLayer = oServer.GetLayer(getAttribute("layer"));
            if (oLayer == null) throw new ArgumentException("'" + getAttribute("layer") + "' was not found. This dataset may have been deleted or moved." + Environment.NewLine + Environment.NewLine + "Please check with the publisher of " + m_oServer.ServerTreeDisplayName + " for more information.");
            WMSServerBuilder oDummyServer = new WMSServerBuilder(null, m_oServer as WMSServerUri, oServer.CapabilitiesFilename, true);
            return new WMSQuadLayerBuilder(oLayer.LayerData, MainForm.WorldWindowSingleton, oDummyServer, null);
        }