示例#1
0
        //navigate to a url but get some user input first
        public void NavigateGeminiWithInput(System.Windows.Navigation.NavigatingCancelEventArgs e, string message)
        {
            //position input box approx in middle of main window

            var windowCentre = WindowGeometry.WindowCentre((Window)mMainWindow);
            var inputPrompt  = "Input request from Gemini server\n\n" +
                               "  " + e.Uri.Host + e.Uri.LocalPath.ToString() + "\n\n" +
                               message;

            string input = Interaction.InputBox(inputPrompt, "Server input request", "", windowCentre.Item1, windowCentre.Item2);

            if (input != "")
            {
                //encode the query
                var b = new UriBuilder();
                b.Scheme = e.Uri.Scheme;
                b.Host   = e.Uri.Host;
                if (e.Uri.Port != -1)
                {
                    b.Port = e.Uri.Port;
                }
                b.Path = e.Uri.LocalPath;
                //!%22%C2%A3$%25%5E&*()_+1234567890-=%7B%7D:@~%3C%3E?[];'#,./
                b.Query = System.Uri.EscapeDataString(input);      //escape the query result

                //ToastNotify(b.ToString());

                mWebBrowser.Navigate(b.ToString());
            }
            else
            {
                //dont do anything further with navigating the browser
                e.Cancel = true;
            }
        }
示例#2
0
        //navigate to a url but get some user input first
        private bool NavigateGopherWithInput(Uri uri)
        {
            //position input box approx in middle of main window

            var windowCentre = WindowGeometry.WindowCentre(mMainWindow);
            var inputPrompt  = "Input request from Gopher server\n\n" +
                               "  " + uri.Host + uri.LocalPath + "\n\n" +
                               "Please provide your input:";

            string input = Interaction.InputBox(inputPrompt, "Server input request", "", windowCentre.Item1, windowCentre.Item2);

            if (input != "")
            {
                //encode the query
                var b = new UriBuilder();
                b.Scheme = uri.Scheme;
                b.Host   = uri.Host;
                if (uri.Port != -1)
                {
                    b.Port = uri.Port;
                }
                b.Path = uri.LocalPath;

                //!%22%C2%A3$%25%5E&*()_+1234567890-=%7B%7D:@~%3C%3E?[];'#,./

                //use an escaped tab then the content
                var query = b.ToString() + "%09" + Uri.EscapeDataString(input);      //escape the query result;
                //ToastNotify(query);

                mMainWindow.Navigate(query);
            }
            else
            {
                //dont do anything further with navigating the browser
                return(false);
            }

            return(true);
        }
示例#3
0
        //navigate to a url but get some user input first
        public bool NavigateGeminiWithInput(Uri uri, string message)
        {
            //position input box approx in middle of main window

            var windowCentre = WindowGeometry.WindowCentre(mMainWindow);
            var inputPrompt  = "Input request from Gemini server\n\n" +
                               "  " + uri.Host + uri.LocalPath + "\n\n" +
                               message;

            string input = Interaction.InputBox(inputPrompt, "Server input request", "", windowCentre.Item1, windowCentre.Item2);

            if (input != "")
            {
                //encode the query
                var b = new UriBuilder();
                b.Scheme = uri.Scheme;
                b.Host   = uri.Host;
                if (uri.Port != -1)
                {
                    b.Port = uri.Port;
                }
                b.Path = uri.LocalPath;
                //!%22%C2%A3$%25%5E&*()_+1234567890-=%7B%7D:@~%3C%3E?[];'#,./
                b.Query = Uri.EscapeDataString(input);      //escape the query result

                //ToastNotify(b.ToString());

                mMainWindow.Navigate(b.ToString());
            }
            else
            {
                //dont do anything further with navigating the browser
                return(false);
            }

            return(true);
        }