Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Dispatcher.Invoke(() =>
            {
                void Update()
                {
                    ViewModel.Updater
                    .Update(ViewModel.Summary, new Progress <double>(d => { ViewModel.Progress = (int)(d * 100); }))
                    .ContinueWith(x => this.Dispatcher.Invoke(this.Close));
                }

                if (ApplicationInstanceTracker.GetAllProcesses(out _))
                {
                    var messageBox = new MessageBoxOkCancel(_xamlUpdateModConfirmTitle.Get(), _xamlUpdateModConfirmMessage.Get());
                    messageBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    messageBox.ShowDialog();

                    if (messageBox.DialogResult.HasValue && messageBox.DialogResult.Value)
                    {
                        Update();
                    }
                }
                else
                {
                    Update();
                }
            });
        }
Пример #2
0
        public ApplicationViewModel(ImageApplicationPathTuple tuple, ManageModsViewModel modsViewModel)
        {
            ApplicationTuple    = tuple;
            ManageModsViewModel = modsViewModel;


            IoC.Kernel.Rebind <ApplicationViewModel>().ToConstant(this);
            InstanceTracker = new ApplicationInstanceTracker(tuple.Config.AppLocation);
            ManageModsViewModel.OnGetModifications += OnGetModifications;
            InstanceTracker.OnProcessesChanged     += OnProcessesChanged;

            UpdateReloadedProcesses();
            GetModsForThisApp();
            RefreshProcessesWithLoaderTimer = new Timer(RefreshTimerCallback, null, 500, _xamlProcessRefreshInterval.Get());
            Page = ApplicationSubPage.ApplicationSummary;
        }
Пример #3
0
        public ApplicationViewModel(PathTuple <ApplicationConfig> tuple, ModConfigService modConfigService)
        {
            ApplicationTuple    = tuple;
            ModConfigService    = modConfigService;
            MakeShortcutCommand = new MakeShortcutCommand(tuple);

            IoC.Kernel.Rebind <ApplicationViewModel>().ToConstant(this);
            InstanceTracker = new ApplicationInstanceTracker(tuple.Config.AppLocation);
            ModConfigService.Mods.CollectionChanged += OnGetModifications;
            InstanceTracker.OnProcessesChanged      += OnProcessesChanged;

            UpdateReloadedProcesses();
            GetModsForThisApp();
            RefreshProcessesWithLoaderTimer = new Timer(RefreshTimerCallback, null, 500, _xamlProcessRefreshInterval.Get());
            Page = ApplicationSubPage.ApplicationSummary;
        }
    /// <inheritdoc />
    public ApplicationViewModel(PathTuple <ApplicationConfig> tuple, ModConfigService modConfigService, ModUserConfigService modUserConfigService, LoaderConfig loaderConfig)
    {
        ApplicationTuple      = tuple;
        _modConfigService     = modConfigService;
        _modUserConfigService = modUserConfigService;
        _instanceTracker      = new ApplicationInstanceTracker(ApplicationConfig.GetAbsoluteAppLocation(tuple), _initialiseTokenSrc.Token);

        if (_initialiseTokenSrc.IsCancellationRequested)
        {
            return;
        }

        MakeShortcutCommand = new MakeShortcutCommand(tuple, Lib.IconConverter);
        _modConfigService.Items.CollectionChanged += OnGetModifications;
        _instanceTracker.OnProcessesChanged       += OnProcessesChanged;

        UpdateReloadedProcesses();
        GetModsForThisApp();
        _refreshProcessesWithLoaderTimer = new Timer(RefreshTimerCallback, null, 500, loaderConfig.ProcessRefreshInterval);
    }
Пример #5
0
    private async Task <bool> PerformUpdateAsync()
    {
        if (ApplicationInstanceTracker.GetAllProcesses(out _))
        {
            Actions.DisplayMessagebox.Invoke(Resources.ErrorUpdateModInUseTitle.Get(), Resources.ErrorUpdateModInUse.Get(), new Actions.DisplayMessageBoxParams()
            {
                StartupLocation = Actions.WindowStartupLocation.CenterScreen, Type = Actions.MessageBoxType.Ok
            });
            return(false);
        }

        // Remove disabled items from summary.
        CanDownload = false;
        var disabledModIds = UpdateInfo.Where(x => !x.Enabled).Select(x => x.ModId);

        Summary.RemoveByModId(disabledModIds);

        await Updater.Update(Summary, new Progress <double>(d =>
        {
            Progress = d * 100;
        }));

        return(true);
    }