using System;
using System.Windows;
using System.Windows.Forms.Integration;

namespace HostingActiveX
{
    public partial class Window1 : Window
    {
        AxMSTSCLib.AxMsTscAxNotSafeForScripting termServ;

        public Window1()
        {
            InitializeComponent();

            // Utwórz element bazowy i kontrolkę ActiveX
            WindowsFormsHost host = new WindowsFormsHost();
            termServ = new AxMSTSCLib.AxMsTscAxNotSafeForScripting();

            // Dodaj kontrolkę ActiveX do elementu bazowego, a element bazowy do panelu WPF
            host.Child = termServ;
            panel.Children.Add(host);
        }

        void connectButton_Click(object sender, RoutedEventArgs e)
        {
            termServ.Server = serverBox.Text;
            termServ.Connect();
        }
    }
}