Exemplo n.º 1
0
        private void ChooseSaveBtn_Click(object sender, EventArgs e)
        {
            if (ViewModel.BackupType.Value != BackupType.LuckyPatcher)
            {
                var(success, filePath) = PickerUtils.PickFile(filter: MainResources.Archives + @" (*.tar.gz)|*.tar.gz");

                if (success)
                {
                    ViewModel.CurrentSave.Value = filePath;
                }
            }
            else
            {
                var(success, folderPath) = PickerUtils.PickFolder();

                if (success)
                {
                    ViewModel.CurrentSave.Value = folderPath;
                }
            }
        }
Exemplo n.º 2
0
        public InstallApkViewModel(
            [NotNull] IAppSettings appSettings,
            [NotNull] NotificationManager notificationManager,
            [NotNull] TempUtils tempUtils,
            [NotNull] GlobalVariables globalVariables,
            [NotNull] Provider <IApktool> apktoolProvider,
            [NotNull] Provider <AdbInstallWindow> adbInstallWindowProvider
            )
        {
            _settings                 = appSettings;
            _notificationManager      = notificationManager;
            _tempUtils                = tempUtils;
            _globalVariables          = globalVariables;
            _apktoolProvider          = apktoolProvider;
            _adbInstallWindowProvider = adbInstallWindowProvider;

            AppTitle = new DelegatedProperty <string>(
                valueResolver: () => Path.GetFileNameWithoutExtension(Apk.Value) + " mod",
                valueApplier: null
                ).DependsOn(Apk).AsReadonly();

            string iconsFolder = Path.Combine(_globalVariables.PathToResources, "icons");

            BitmapSource GetImage(string name) =>
            LFile.ReadAllBytes(Path.Combine(iconsFolder, name)).ToBitmap().ToBitmapSource();

            IconsStorage = new AppIconsStorage
            {
                Icon_xxhdpi = { Value = GetImage("xxhdpi.png") },
                Icon_xhdpi  = { Value = GetImage("xhdpi.png") },
                Icon_hdpi   = { Value = GetImage("hdpi.png") },
                Icon_mdpi   = { Value = GetImage("mdpi.png") }
            };

            // commands
            ChooseApkCommand = new ActionCommand(() =>
            {
                var(success, filePath) = PickerUtils.PickFile(filter: MainResources.AndroidFiles + @" (*.apk)|*.apk");

                if (success)
                {
                    Apk.Value = filePath;
                }
            }, () => !Working.Value).BindCanExecute(Working);
            ChooseSaveCommand = new ActionCommand(() =>
            {
                if (_settings.BackupType == BackupType.LuckyPatcher)
                {
                    var(success, folderPath) = PickerUtils.PickFolder();

                    if (success)
                    {
                        Save.Value = folderPath;
                    }
                }
                else
                {
                    var(success, filePath) = PickerUtils.PickFile(filter: MainResources.Archives + @" (*.tar.gz)|*.tar.gz");

                    if (success)
                    {
                        Save.Value = filePath;
                    }
                }
            }, () => !Working.Value).BindCanExecute(Working);
            ChooseDataCommand = new ActionCommand(() =>
            {
                var(success, filePath) = PickerUtils.PickFile(filter: MainResources.ZipArchives + @" (*.zip)|*.zip");

                if (success)
                {
                    Data.Value = filePath;
                }
            }, () => !Working.Value).BindCanExecute(Working);
            ChooseObbCommand = new ActionCommand(() =>
            {
                var(success, filePaths) = PickerUtils.PickFiles(filter: MainResources.CacheFiles + @" (*.obb)|*.obb");

                if (success)
                {
                    Obb.Value = filePaths;
                }
            }, () => !Working.Value).BindCanExecute(Working);
            StartCommand = new ActionCommand(StartCommand_Execute, () => !Working.Value).BindCanExecute(Working);
        }