/**************** * Constructors * ****************/ #region Public Constructors /// <summary>Initializes a HelpWindow object.</summary> public HelpWindow() { /* This browser containing the (HTML) help text will serve as the content of the window. */ this.Browser = new WebBrowser(); this.Browser.NavigateToString(Properties.Resources.HelpText); /* Build the window. */ this.Content = this.Browser; this.Icon = MIDIopsyApp.CreateBitmapSource("Help.ico"); this.Title = MIDIopsyApp.Name + " " + ApplicationCommands.Help.Text; this.Restore(Properties.Settings.Default.HelpWindowMaximized, Properties.Settings.Default.HelpWindowBounds); this.Loaded += this.HelpWindow_Loaded; this.Closing += this.HelpWindow_Closing; }
/*********** * Methods * ***********/ #region Public Methods /// <summary>Displays an About box in front of the specified window.</summary> /// <param name="owner">The owner window of the About box.</param> public static void Show(Window owner) { /* Define the grid content panel. */ Grid grid = new Grid(); grid.Width = AboutBox.BannerWidth; grid.Height = 2 * AboutBox.BannerHeight; grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions[0].Width = new GridLength(AboutBox.BannerWidth - AboutBox.BannerHeight); /* Initialize the banner image. (Note: "Build Action" property must be set to "Resource") */ Image image = new Image(); image.Source = MIDIopsyApp.CreateBitmapSource("Banner.bmp"); Grid.SetRow(image, 0); Grid.SetColumn(image, 0); Grid.SetColumnSpan(image, 2); grid.Children.Add(image); /* Initialize the info text block. */ TextBlock textBlock = new TextBlock(); textBlock.Margin = new Thickness(AboutBox.MarginLength, AboutBox.MarginLength / 2, 0, 0); textBlock.Inlines.Add(AboutBox.Product); textBlock.Inlines.Add(new LineBreak()); string s = string.Format("{0} {1}", Properties.Resources.Version, AboutBox.Version); textBlock.Inlines.Add(s); textBlock.Inlines.Add(new LineBreak()); textBlock.Inlines.Add(AboutBox.Copyright); textBlock.Inlines.Add(new LineBreak()); Hyperlink hyperlink = new Hyperlink(); hyperlink.NavigateUri = new Uri("https://jeffbourdier.github.io/" + MIDIopsyApp.Name.ToLower()); hyperlink.Inlines.Add(hyperlink.NavigateUri.AbsoluteUri); hyperlink.RequestNavigate += AboutBox.Hyperlink_RequestNavigate; textBlock.Inlines.Add(hyperlink); Grid.SetRow(textBlock, 1); Grid.SetColumn(textBlock, 0); grid.Children.Add(textBlock); /* Initialize the OK button. */ Button button = new Button(); button.Margin = new Thickness(AboutBox.MarginLength); button.Content = Properties.Resources.OK; button.Click += UI.OkButton_Click; button.IsCancel = true; button.IsDefault = true; Grid.SetRow(button, 1); Grid.SetColumn(button, 1); grid.Children.Add(button); /* Build and show the window. */ Window window = new Window(); window.WindowStyle = WindowStyle.ToolWindow; window.ResizeMode = ResizeMode.NoResize; window.Title = Properties.Resources.About + " " + MIDIopsyApp.Name; window.Content = grid; window.SizeToContent = SizeToContent.WidthAndHeight; window.Owner = owner; FocusManager.SetFocusedElement(window, button); window.ShowDialog(); }