Пример #1
0
        public MainWindow()
        {
            var    args = Environment.GetCommandLineArgs();
            bool   DebugMode = false;
            string MO2Folder = null, InstallFolder = null, MO2Profile = null;

            if (args.Length > 1)
            {
                DebugMode     = true;
                MO2Folder     = args[1];
                MO2Profile    = args[2];
                InstallFolder = args[3];
            }

            InitializeComponent();

            var context = new AppState(Dispatcher, "Building");

            this.DataContext = context;
            WorkQueue.Init((id, msg, progress) => context.SetProgress(id, msg, progress),
                           (max, current) => context.SetQueueSize(max, current));


            if (DebugMode)
            {
                new Thread(() =>
                {
                    var compiler = new Compiler(MO2Folder, msg => context.LogMsg(msg));

                    compiler.MO2Profile = MO2Profile;
                    context.ModListName = compiler.MO2Profile;

                    context.Mode = "Building";
                    compiler.LoadArchives();
                    compiler.Compile();

                    var modlist = compiler.ModList.ToJSON();
                    compiler    = null;

                    context.ConfigureForInstall(modlist);
                }).Start();
            }
            else
            {
                new Thread(() =>
                {
                    var modlist = Installer.CheckForModPack();
                    if (modlist == null)
                    {
                    }
                    else
                    {
                        context.ConfigureForInstall(modlist);
                    }
                }).Start();
            }
        }
Пример #2
0
 private void ExecuteBegin()
 {
     if (Mode == "Installing")
     {
         var installer = new Installer(_modList, Location, msg => this.LogMsg(msg));
         var th        = new Thread(() =>
         {
             try
             {
                 installer.Install();
             }
             catch (AggregateException ex)
             {
                 LogMsg(ex.StackTrace);
                 LogMsg(ex.InnerException.ToString());
             }
             catch (Exception ex)
             {
                 LogMsg($"{ex.Message} - Can't continue");
             }
         });
         th.Priority = ThreadPriority.BelowNormal;
         th.Start();
     }
     else
     {
         var compiler = new Compiler(_mo2Folder, msg => LogMsg(msg));
         compiler.MO2Profile = ModListName;
         var th = new Thread(() =>
         {
             compiler.LoadArchives();
             compiler.Compile();
         });
         th.Priority = ThreadPriority.BelowNormal;
         th.Start();
     }
 }