aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/WixToolset.WixBA/BrowserProperties.cs
blob: c8fb61779bc5ef2b3527d028dfe49c327d7c0b3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.

namespace WixToolset.WixBA
{
    using System.Windows;
    using System.Windows.Controls;

    /// <summary>
    /// Dependency Properties to support using a WebBrowser object.
    /// </summary>
    class BrowserProperties
    {
        /// <summary>
        /// Dependency Propery used to pass an HTML string to the webBrowser object.
        /// </summary>
        public static readonly DependencyProperty HtmlDocProperty =
            DependencyProperty.RegisterAttached("HtmlDoc", typeof(string), typeof(BrowserProperties), new PropertyMetadata(OnHtmlDocChanged));

        public static string GetHtmlDoc(DependencyObject dependencyObject)
        {
            return (string)dependencyObject.GetValue(HtmlDocProperty);
        }

        public static void SetHtmlDoc(DependencyObject dependencyObject, string htmldoc)
        {
            dependencyObject.SetValue(HtmlDocProperty, htmldoc);
        }

        /// <summary>
        /// Event handler that passes the HtmlDoc Dependency Property to MavigateToString method.
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnHtmlDocChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var webBrowser = (WebBrowser)d;
            webBrowser.NavigateToString((string)e.NewValue);
        }
    }
}