Exemplo n.º 1
0
        public override void ShowHelp(bool asDialog)
        {
            var helpUri  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Resources.HelpFile);
            var document = new System.Windows.Xps.Packaging.XpsDocument(helpUri, FileAccess.Read);

            var helpWindow = new Window
            {
                Icon        = Application.Current.MainWindow.Icon,
                Title       = CommonSettings.AppName + ": " + Resources.XpsHelp,
                WindowState = WindowState.Maximized
            };

            var docViewer = new System.Windows.Controls.DocumentViewer {
                Document = document.GetFixedDocumentSequence()
            };
            var frame = new System.Windows.Controls.Frame {
                NavigationUIVisibility = System.Windows.Navigation.NavigationUIVisibility.Hidden
            };

            frame.Content      = docViewer;
            helpWindow.Content = frame;

            helpWindow.Closed += (sender, e) =>
            {
                document.Close();
            };

            docViewer.AddHandler(System.Windows.Documents.Hyperlink.RequestNavigateEvent,
                                 new System.Windows.Navigation.RequestNavigateEventHandler((sender, e) =>
            {
                if (e.Uri.IsAbsoluteUri && e.Uri.Scheme == "http")
                {
                    try
                    {
                        Process.Start(e.Uri.ToString());
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(string.Format(Resources.SiteNavigationError + "\r\n{1}", e.Uri, exc.Message), CommonSettings.AppName);
                    }

                    e.Handled = true;
                }
            }
                                                                                           ));

            if (asDialog)
            {
                helpWindow.ShowDialog();
            }
            else
            {
                helpWindow.Show();
            }
        }