public AppView(MapPackageInstaller installer, IList<MapPackageOperation> operations)
        {
            InitializeComponent();

               //Sources = sources;
            Installer = installer;

            Operations = new Queue<MapPackageOperation>(operations);
            PackageListItems = operations
                .Select(op => new PackageListItem(op))
                .ToDictionary(key => key.Model.SourceUri);

            foreach (var item in PackageListItems)
                PackageListPanel.Controls.Add(item.Value.View);

            Closing += BeforeClose;

            //sign up to package loading events
            Installer.BeginPackage     += OnBeginPackage;
            Installer.BeginPackageDownload += OnBeginPackageDownload;
            Installer.PackageProgress += OnPackageProgress;
            Installer.PackageError     += OnPackageError;
            Installer.EndPackage       += OnEndPackage;
            Installer.SkipPackage      += OnSkipPackage;
            Installer.DownloadPackage  += OnDownloadPackage;
        }
        static int Main(string[] args)
        {
            //args = new[] { @"C:\ProgramData\Fifth Element Oy\Metsä Group Kotka Maps\_temp\test.lfp" };

            MapLoaderArgument arguments;

            //parse arguments
            try
            {
                string controlFile = args[0];

                //if relative path was passed, assume relative to current working directory
                if (!Path.IsPathRooted(controlFile))
                    controlFile = Path.Combine(Environment.CurrentDirectory, controlFile);

                //check that control file exists
                if (!File.Exists(controlFile))
                    throw new ArgumentException("Input file " + controlFile + " does not exist", "input");

                string json = File.ReadAllText(controlFile, Encoding.UTF8).Trim();
                arguments = JsonHelper.Deserialize<MapLoaderArgument>(json);

                if (!VerifyDiskSpaceRequirements(arguments))
                    return (int)ExitCode.Canceled;

                var operations = new List<MapPackageOperation>();

                //removals first (to enable installing large packages while removing others)
                operations.AddRange(from package in arguments.PackageInfos
                                    where package.ActionEnumValue == MapLoaderAction.Remove
                                    select new RemovalOperation(
                                        new Uri(package.Url),
                                        package.DisplayName,
                                        package.EstimatedSize
                                    ));
                //additions after
                operations.AddRange(from package in arguments.PackageInfos
                                    where package.ActionEnumValue == MapLoaderAction.Install
                                    select InstallationOperation.Create(
                                        package.Url,
                                        package.DisplayName,
                                        package.EstimatedSize
                                    ));

                var loader = new MapPackageInstaller(arguments.TargetDirectory);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Application.Run(new AppView(loader, operations));
            }
            catch (Exception ex)
            {
                Debug.WriteLine("ERROR in Program#Main. Caught, returning error code. " + ex.Message);
                return (int)ExitCode.Error;
            }

            return (int) ApplicationExitCode;
        }