Esempio n. 1
0
        public static void OpenWindow(string url, int width = 1100, int height = 600)
        {
            string host = Application.Current.Host.Source.Host;
            int    port = Application.Current.Host.Source.Port;
            Uri    uri  = new Uri(String.Format("http://{0}:{1}/{2}", host, port, url));

            if (!Application.Current.IsRunningOutOfBrowser)
            {
                System.Windows.Browser.HtmlPopupWindowOptions options = new System.Windows.Browser.HtmlPopupWindowOptions();
                options.Resizeable  = true;
                options.Width       = width;
                options.Height      = height;
                options.Menubar     = true;
                options.Directories = true;
                options.Toolbar     = true;
                options.Status      = true;
                System.Windows.Browser.HtmlPage.PopupWindow(uri, "_blank", options);
                //System.Windows.Browser.HtmlPage.Window.Navigate(uri);
            }
            else
            {
                //WebBrowserBridge.OpenURL(uri, "_blank");
                using (var shell = AutomationFactory.CreateObject("WScript.Shell")) {
                    shell.Run("iexplore.exe " + uri.AbsoluteUri);
                }
            }
        }
        /// <summary>
        /// Graphic Click Event Handler; An inheriting widget must override this method, but run this method at last
        /// </summary>
        protected virtual void OnGraphicsLayerMouseUp(object sender, GraphicMouseButtonEventArgs e)
        {
            PopupWindow tipGrid = ((this.graphicsLayer.MapTip == null) ? e.Graphic.MapTip : this.graphicsLayer.MapTip) as PopupWindow;

            if (tipGrid != null)
            {
                ModifierKeys keys       = Keyboard.Modifiers;
                bool         controlKey = (keys & ModifierKeys.Control) != 0;
                if (controlKey && tipGrid.Resources.Contains("HyperlinkField"))
                {
                    string hyperlinkField = tipGrid.Resources["HyperlinkField"] as string;
                    string sUrl           = (e.Graphic.Attributes.ContainsKey(hyperlinkField)) ? (e.Graphic.Attributes[hyperlinkField] as string) : "";

                    if (!string.IsNullOrEmpty(sUrl))
                    {
                        System.Windows.Browser.HtmlPopupWindowOptions winOptions = new System.Windows.Browser.HtmlPopupWindowOptions()
                        {
                            Resizeable = true, Width = 800, Height = 700
                        };
                        System.Windows.Browser.HtmlWindow win = System.Windows.Browser.HtmlPage.PopupWindow(new Uri(sUrl), "_blank", winOptions);
                    }
                }
            }

            this.DrawObject.IsEnabled = this.wasDrawObjectEnabled;
        }
Esempio n. 3
0
		public static void OpenWindow(string url, int width = 1100, int height = 600) {
			string host = Application.Current.Host.Source.Host;
			int port = Application.Current.Host.Source.Port;
			Uri uri = new Uri(String.Format("http://{0}:{1}/{2}", host, port, url));
			if (!Application.Current.IsRunningOutOfBrowser) {
				System.Windows.Browser.HtmlPopupWindowOptions options = new System.Windows.Browser.HtmlPopupWindowOptions();
				options.Resizeable = true;
				options.Width = width;
				options.Height = height;
				options.Menubar = true;
				options.Directories = true;
				options.Toolbar = true;
				options.Status = true;
				System.Windows.Browser.HtmlPage.PopupWindow(uri, "_blank", options);
				//System.Windows.Browser.HtmlPage.Window.Navigate(uri);
			} else {
				//WebBrowserBridge.OpenURL(uri, "_blank");
				using (var shell = AutomationFactory.CreateObject("WScript.Shell")) {
					shell.Run("iexplore.exe " + uri.AbsoluteUri);
				}
			}
		}
        private void LinkMenuButton_MenuItemClick(object sender, MenuItemClickEventArgs e)
        {
            string sUrl = (string)e.ItemTag;

            if (!string.IsNullOrEmpty(sUrl))
            {
                if (sUrl.Equals("About"))
                {
                    if (AboutWindow == null)
                    {
                        AboutWindow = new PopupWindow()
                        {
                            Title = "About", Background = this.Background, ShowArrow = false, IsResizable = false, IsFloatable = true
                        };
                        StackPanel aboutContent = new StackPanel()
                        {
                            Orientation = Orientation.Vertical, Margin = new Thickness(12, 12, 12, 12)
                        };
                        AboutWindow.Content = aboutContent;

                        string[] contentLines = Regex.Split(AppConfig.AppHelpMenu.About.Text, @"\\n");
                        for (int i = 0; i < contentLines.Length; i++)
                        {
                            if (contentLines[i].Trim().StartsWith("http://", StringComparison.CurrentCultureIgnoreCase))
                            {
                                HyperlinkButton linkBlock = new HyperlinkButton()
                                {
                                    NavigateUri = new Uri(contentLines[i].Trim(), UriKind.Absolute), Content = contentLines[i].Trim(), Margin = new Thickness(2), FontSize = 12.5, Foreground = new SolidColorBrush(Colors.Blue), HorizontalAlignment = System.Windows.HorizontalAlignment.Center, TargetName = "_blank"
                                };
                                aboutContent.Children.Add(linkBlock);
                            }
                            else
                            {
                                TextBlock textBlock = new TextBlock()
                                {
                                    Text = contentLines[i].Trim(), Margin = new Thickness(2), FontSize = 12.5, HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                                };
                                aboutContent.Children.Add(textBlock);
                            }
                        }
                    }

                    FloatingPopup.Show(AboutWindow);
                }
                else
                {
                    try
                    {
                        System.Windows.Browser.HtmlPopupWindowOptions winOptions = new System.Windows.Browser.HtmlPopupWindowOptions()
                        {
                            Resizeable = true, Width = 1000, Height = 800
                        };
                        System.Windows.Browser.HtmlWindow win = System.Windows.Browser.HtmlPage.PopupWindow(new Uri(sUrl, UriKind.Absolute), "_blank", winOptions);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }