/// <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;
        }
Exemple #2
0
        public void LogError(string message)
        {
            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            if (System.Windows.Browser.HtmlPage.IsEnabled)
            {
                System.Windows.Browser.HtmlWindow window = System.Windows.Browser.HtmlPage.Window;
                var isConsoleAvailable = (bool)window.Eval("typeof(console) != 'undefined' && typeof(console.log) != 'undefined'");
                if (isConsoleAvailable)
                {
                    var console = (window.Eval("console.log") as System.Windows.Browser.ScriptObject);
                    if (console != null)
                    {
                        try
                        {
                            console.InvokeSelf(message);
                        }
                        catch
                        {
                        }
                    }
                }
            }
            System.Diagnostics.Debug.WriteLine(message);
        }
        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);
                    }
                }
            }
        }