/**
 * Copyright 2020 Google LLC.
 * SPDX-License-Identifier: MIT
 */
using Microsoft.Toolkit.Uwp.Notifications;
using System;
using System.Windows.Forms;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;

namespace Toasty
{
  public partial class MainForm : Form
  {
    public MainForm()
    {
      InitializeComponent();
    }

    private void ShowToast()
    {
      string title = "Toasty!";
      string content = "Check out the yummy toast";

      string toastVisual =
      $@"<visual>
               <binding template='ToastGeneric'>
               <text>{title}</text>
               <text>{content}</text>
               </binding>
            </visual>";

      string argsLaunch = $"action=doSomething";

      string toastXmlString =
      $@"<toast launch='{argsLaunch}'>
                {toastVisual}
            </toast>";
      XmlDocument toastXml = new XmlDocument();
      toastXml.LoadXml(toastXmlString);

      var toast = new ToastNotification(toastXml);

      DesktopNotificationManagerCompat.CreateToastNotifier().Show(toast);
    }
    private void buttonToast_Click(object sender, EventArgs e)
    {
      ShowToast();
    }
  }
}