// Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Integration;

namespace HostingAnAvalonControl {
  public partial class Form1 : Form {
    public Form1() {
      InitializeComponent(); // group boxes created in here

      // Create WPF button
      System.Windows.Controls.Button wpfButton = new System.Windows.Controls.Button();
      wpfButton.Content = "WPF Button";
      wpfButton.Click += avButton_Click;

      //wpfButton.RenderTransform = new System.Windows.Media.RotateTransform(180, 165/2.0, 40/2.0);
      wpfButton.Background = new System.Windows.Media.LinearGradientBrush(System.Windows.Media.Colors.White, System.Windows.Media.Colors.Red, new System.Windows.Point(0, 0), new System.Windows.Point(1, 1));

      // Host the WPF button
      ElementHost host = new ElementHost();
      host.Left = 39;
      host.Top = 72;
      host.Width = 165;
      host.Height = 40;
      host.Child = wpfButton;

      // Add the element host to the groupbox
      rightGroup.Controls.Add(host);
    }

    void wfButton_Click(object sender, EventArgs e) {
      System.Windows.Forms.MessageBox.Show("Hello from Windows Forms!", "Hello");
    }

    // Handle the WPF button's Click event
    void avButton_Click(object sender, System.Windows.RoutedEventArgs e) {
      System.Windows.MessageBox.Show("Hello from WPF!", "Hello");
    }

  }
}
