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();
                }
            });
        }
Example #2
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);
    }