using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

using Microsoft.Win32;

namespace hMarkdown
{
    internal static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            SetBrowserEmulationMode();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            
            string fn = "";
            if (args.Length > 0)
            {
                fn = string.Join(" ", args);
            }
            Application.Run(new Form1(fn));
        }

        private static void SetBrowserEmulationMode()
        {
            try
            {
                string appName = System.IO.Path.GetFileName(System.Windows.Forms.Application.ExecutablePath);
                using (var key = Registry.CurrentUser.CreateSubKey(
                    @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION",
                    RegistryKeyPermissionCheck.ReadWriteSubTree))
                {
                    if (key != null)
                    {
                        key.SetValue(appName, 11001, RegistryValueKind.DWord);
                    }
                }
            }
            catch { }
        }
    }
}
