Beispiel #1
0
        void _webHelpService_GetWebHelpCompleted(object sender, EventArgs <String> e)
        {
#if SILVERLIGHT
            TB_View.Text = e.Value;
            //Web_View.NavigateToString(e.Value);
#else
            Web_View.Visibility = Visibility.Visible;
            Web_View.NavigateToString(e.Value);

            /* The following code is to save the file locally as cached. It does work but I found the
             * NavigateToString function and would rather just use that.
             * string RootDir = AppDomain.CurrentDomain.BaseDirectory;
             * string pagelocation = string.Format(RootDir + "helppages\\{0}.html", uri);
             * Uri uriLocal = new Uri(pagelocation, UriKind.Absolute);
             * // Ensure directory paths
             * if (!Directory.Exists(RootDir + "helppages\\")) { Directory.CreateDirectory(RootDir + "helppages\\"); }
             *
             * try {
             *  using (var filestream = new StreamWriter(pagelocation))
             *  {
             *      filestream.Write(e.Value);
             *      filestream.Close();
             *  }
             *  Web_View.Navigate(uriLocal);
             * } catch (System.IO.FileFormatException) {
             *  // ignore it, we couldn't save the file because the web server has a corrupted image
             *  Web_View.Navigate("about:blank");
             * } catch (Exception) {
             *  // for now, ignore it
             *  Web_View.Navigate("about:blank");
             * }*/
#endif
        }
Beispiel #2
0
        private void runlink(string relativeUri, string overrideText = "")
        {
            uri = relativeUri;
            UpdateCurrentButtonColor();
            overridetext        = overrideText;
            BT_Open.NavigateUri = new Uri(BT_Open.NavigateUri + relativeUri);
#if !SILVERLIGHT
            if (overrideText != "")
            {
                //TB_View.Text = overrideText;
                Web_View.NavigateToString(overrideText);
            }
            else
            {
                // Let the user know we need to download it
                Web_View.NavigateToString("Loading...");
                // Give it the right callback so it knows what to do when we get it
                _webHelpService.GetWebHelpCompleted += new EventHandler <EventArgs <String> >(_webHelpService_GetWebHelpCompleted);
                // Call the page
                _webHelpService.GetWebHelpAsync(uri, true);
                //Web_View.Navigate(new Uri(string.Format(WebHelpService.URL_WEBHELP, uri)));
            }
#else
            if (overrideText != "")
            {
                TB_View.Text = overrideText;
                //Web_View.NavigateToString(overrideText);
            }
            else if (Application.Current.IsRunningOutOfBrowser)
            {
                // Let the user know we can't download it due to cross domain access
                // TODO: Make it call through Rawr4.com instead to see if that gets around it
                overrideText = "Silverlight does not function with this feature yet due to security issues."
                               + " We are working on a way around this."
                               + " In the meantime, please use the link below to open it in your browser."
                               + " You can also select a different content on the left before opening in your browser.";
                TB_View.Text = overrideText;
                //Web_View.NavigateToString(overrideText);
                //_webHelpService.GetWebHelpAsync(uri, true);
            }
            else
            {
                //Web_View.MaxHeight = 0;
                //Web_View.Visibility = Visibility.Collapsed;
                //this.LayoutRoot.Children.Remove(Web_View);
                //TB_View.Visibility = Visibility.Visible;
                TB_View.Text = "Silverlight does not function with this feature yet due to security issues."
                               + " We are working on a way around this."
                               + " In the meantime, please use the link below to open it in your browser."
                               + " You can also select a different content on the left before opening in your browser.";
            }
#endif
        }