public async void Execute(object parameter)
        {
            _canExecute = false;
            RaiseCanExecute(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));

            var updates = await Task.Run(Update.CheckForModUpdatesAsync);

            var dependencies = Update.CheckMissingDependencies(out var missingDependencies);

            if ((!updates) && (!dependencies))
            {
                var box = new MessageBox(_noUpdateDialogTitle.Get(), _noUpdateDialogMessage.Get());
                box.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                box.ShowDialog();
            }
            else if (dependencies)
            {
                try
                {
                    await Update.DownloadPackagesAsync(missingDependencies, false, false);
                }
                catch (Exception)
                {
                    // ignored
                }
            }

            _canExecute = true;
            RaiseCanExecute(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
        }
예제 #2
0
        /* Check if not duplicate. */
        public bool IsUnique()
        {
            if (ModConfigService.Mods.Any(x => x.Config.ModId.Equals(RealViewModel.Config.ModId)))
            {
                var messageBoxDialog = new MessageBox(_xamlTitleCreateModNonUniqueId.Get(),
                                                      _xamlMessageCreateModNonUniqueId.Get());
                messageBoxDialog.Owner = this;
                messageBoxDialog.ShowDialog();
                return(false);
            }

            return(true);
        }
예제 #3
0
        public void Execute(object parameter)
        {
            var applicationTuple = _addAppViewModel.MainPageViewModel.Applications.FirstOrDefault(x => x.Config.Equals(_lastConfig));
            var loaderConfig     = IoC.Get <LoaderConfig>();
            var shell            = (IShellLink) new ShellLink();

            shell.SetDescription($"Launch {applicationTuple?.Config.AppName} via Reloaded II");
            shell.SetPath($"\"{loaderConfig.LauncherPath}\"");
            shell.SetArguments($"{Constants.ParameterLaunch} \"{_lastConfig.AppLocation}\"");
            shell.SetWorkingDirectory(Path.GetDirectoryName(loaderConfig.LauncherPath));

            if (applicationTuple != null)
            {
                var hasIcon = ApplicationConfig.TryGetApplicationIcon(applicationTuple.ConfigPath, applicationTuple.Config, out var logoPath);
                if (hasIcon)
                {
                    // Make path for icon.
                    string newPath = Path.ChangeExtension(logoPath, ".ico");

                    // Convert to ICO and save.
                    var bitmapImage   = Imaging.BitmapFromUri(new Uri(logoPath, UriKind.Absolute));
                    var bitmap        = Imaging.BitmapImageToBitmap(bitmapImage);
                    var resizedBitmap = Imaging.ResizeImage(bitmap, Constants.IcoMaxWidth, Constants.IcoMaxHeight);

                    using (var newIcon = Icon.FromHandle(resizedBitmap.GetHicon()))
                        using (Stream newIconStream = new FileStream(newPath, FileMode.Create))
                        {
                            newIcon.Save(newIconStream);
                        }

                    shell.SetIconLocation(newPath, 0);
                }
                else
                {
                    shell.SetIconLocation(_lastConfig.AppLocation, 0);
                }
            }

            // Save the shortcut.
            var file = (IPersistFile)shell;
            var link = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{applicationTuple?.Config.AppName} via Reloaded II.lnk");

            file.Save(link, false);

            var messageBox = new MessageBox(_xamlShortcutCreatedTitle.Get(),
                                            $"{_xamlShortcutCreatedMessage.Get()} {link}");

            messageBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            messageBox.ShowDialog();
        }
예제 #4
0
        /* Check if not duplicate. */
        public bool IsUnique()
        {
            var modsViewModel = IoC.Get <ManageModsViewModel>();

            if (modsViewModel.Mods.Count(x => x.ModConfig.ModId.Equals(RealViewModel.Config.ModId)) > 0)
            {
                var messageBoxDialog = new MessageBox(_xamlTitleCreateModNonUniqueId.Get(),
                                                      _xamlMessageCreateModNonUniqueId.Get());
                messageBoxDialog.Owner = this;
                messageBoxDialog.ShowDialog();
                return(false);
            }

            return(true);
        }
예제 #5
0
        public void Execute(object parameter)
        {
            var loaderConfig = IoC.Get <LoaderConfig>();
            var shell        = (IShellLink) new ShellLink();

            shell.SetDescription($"Launch {_config?.Config.AppName} via Reloaded II");
            shell.SetPath($"\"{loaderConfig.LauncherPath}\"");
            shell.SetArguments($"{Constants.ParameterLaunch} \"{_config.Config.AppLocation}\"");
            shell.SetWorkingDirectory(Path.GetDirectoryName(loaderConfig.LauncherPath));

            if (_config != null)
            {
                var hasIcon = _config.Config.TryGetApplicationIcon(_config.Path, out var logoPath);
                if (hasIcon)
                {
                    // Make path for icon.
                    string newPath = Path.ChangeExtension(logoPath, ".ico");

                    // Convert to ICO.
                    Imaging.TryConvertToIcon(logoPath, newPath);
                    shell.SetIconLocation(newPath, 0);
                }
                else
                {
                    shell.SetIconLocation(_config.Config.AppLocation, 0);
                }
            }

            // Save the shortcut.
            var file = (IPersistFile)shell;
            var link = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{_config?.Config.AppName} (Reloaded).lnk");

            file.Save(link, false);

            var messageBox = new MessageBox(_xamlShortcutCreatedTitle.Get(),
                                            $"{_xamlShortcutCreatedMessage.Get()} {link}");

            messageBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            messageBox.ShowDialog();
        }