Newer
Older
JumpListUtil / ShortcutUtil / Program.cs
using Entries;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ShortcutUtil
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            string[] args = Environment.GetCommandLineArgs();

            if (args.Length < 2)
            {
                MessageBox.Show("Drag a shortcuts.json onto this executable");
                return;
            }

            EntryList entryList = null;
            try
            {
                entryList = EntryList.FromFile(args[1]);
            }
            catch (Exception e)
            {
                MessageBox.Show("Couldn't load settings file " + args[1] + "\n" + e);
                return;
            }

            if (entryList.Entries.Count == 0)
            {
                MessageBox.Show("No shorcuts in that settings file!");
                return;
            }

            Environment.CurrentDirectory = Path.GetDirectoryName(Path.Combine(Environment.CurrentDirectory, args[1]));


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(entryList));
        }
    }
}