Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DownloadForm"/> class.
        /// </summary>
        /// <param name="args">Command-line arguments to pass to Virtual Paradise.</param>
        /// <param name="virtualParadise">The instance of <see cref="VirtualParadise"/> to use.</param>
        /// <param name="channel">The update channel to use.</param>
        private DownloadForm(string[] args, VirtualParadise virtualParadise, UpdateChannel channel)
        {
            this.InitializeComponent();

            this.commandLineArgs = args;
            this.virtualParadise = virtualParadise;
            this.updateChannel   = channel;
            this.updater         = new Updater(virtualParadise);
        }
Beispiel #2
0
        /// <summary>
        /// Builds a <see cref="DownloadForm"/>.
        /// </summary>
        /// <param name="args">Command-line arguments to pass to Virtual Paradise.</param>
        /// <returns>Returns a new instance of <see cref="DownloadForm"/>.</returns>
        public static async Task <DownloadForm> Build(string[] args)
        {
            UpdaterConfig config = await UpdaterConfig.Load();

            await config.LoadDefaults();

            UpdateChannel channel = (int)config["stable_only", 1] == 1
                ? UpdateChannel.Stable
                : UpdateChannel.PreRelease;

            try
            {
                VirtualParadise virtualParadise = VirtualParadise.GetCurrent();
                if (channel == UpdateChannel.PreRelease)
                {
                    VirtualParadise preVirtualParadise = VirtualParadise.GetPreRelease();
                    if (!(preVirtualParadise is null))
                    {
                        virtualParadise = preVirtualParadise;
                    }
                }

                return(new DownloadForm(args, virtualParadise, channel));
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format(Resources.VpObjectBuildError, ex.Message),
                                Resources.Error,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                // There's nothing we can do from here
                Environment.Exit(0);
                return(null);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Updater"/> class.
 /// </summary>
 /// <param name="virtualParadise">The <see cref="VirtualParadise"/> instance to use.</param>
 public Updater(VirtualParadise virtualParadise)
 {
     this.virtualParadise = virtualParadise;
 }