public AboutWindowViewModel(
            [NotNull] ApplicationUtils applicationUtils,
            [NotNull] GlobalVariables globalVariables
            )
        {
            // properties
            Version = new DelegatedProperty <string>(applicationUtils.GetVersion, null).AsReadonly();

            // commands
            ShowDeveloperCommand = new ActionCommand(() =>
            {
                WebUtils.OpenLinkInBrowser("https://www.andnixsh.com/");
            });
            ThankDeveloperCommand = new ActionCommand(() =>
            {
                WebUtils.OpenLinkInBrowser("http://4pda.ru/forum/index.php?showtopic=477614&st=980");
            });
            OpenAppDataFolderCommand = new ActionCommand(() =>
            {
                Process.Start(globalVariables.AppDataPath);
            });
            OpenSourcesPage = new ActionCommand(() =>
            {
                WebUtils.OpenLinkInBrowser("https://github.com/AndnixSH/SaveToGame");
            });
        }
        public AboutWindowViewModel(
            [NotNull] ApplicationUtils applicationUtils,
            [NotNull] GlobalVariables globalVariables
            )
        {
            // properties
            Version = new DelegatedProperty <string>(applicationUtils.GetVersion, null).AsReadonly();

            // commands
            ShowDeveloperCommand = new ActionCommand(() =>
            {
                WebUtils.OpenLinkInBrowser("http://www.4pda.ru/forum/index.php?showuser=2114045");
            });
            ThankDeveloperCommand = new ActionCommand(() =>
            {
                WebUtils.OpenLinkInBrowser("http://4pda.ru/forum/index.php?act=rep&type=win_add&mid=2114045&p=23243303");
            });
            OpenAppDataFolderCommand = new ActionCommand(() =>
            {
                Process.Start(globalVariables.AppDataPath);
            });
            OpenSourcesPage = new ActionCommand(() =>
            {
                WebUtils.OpenLinkInBrowser("https://github.com/And42/SaveToGame");
            });
        }
        public MainWindowViewModel(
            [NotNull] IAppSettings appSettings
            )
        {
            Working      = new FieldProperty <bool>();
            OnlySave     = new FieldProperty <bool>();
            SavePlusMess = new FieldProperty <bool>(true);
            OnlyMess     = new FieldProperty <bool>();

            PopupBoxText  = new FieldProperty <string>(appSettings.PopupMessage);
            MessagesCount = new FieldProperty <int>(1);

            CurrentApk  = new FieldProperty <string>();
            CurrentSave = new FieldProperty <string>();

            BackupType = new DelegatedProperty <BackupType>(
                valueResolver: () => appSettings.BackupType,
                valueApplier: value => appSettings.BackupType = value
                ).DependsOn(appSettings, nameof(IAppSettings.BackupType));

            AppTheme = new DelegatedProperty <string>(
                valueResolver: () => appSettings.Theme,
                valueApplier: value => appSettings.Theme = value
                ).DependsOn(appSettings, nameof(IAppSettings.Theme));

            AlternativeSigning = new DelegatedProperty <bool>(
                valueResolver: () => appSettings.AlternativeSigning,
                valueApplier: value => appSettings.AlternativeSigning = value
                ).DependsOn(appSettings, nameof(IAppSettings.AlternativeSigning));

            NotificationsEnabled = new DelegatedProperty <bool>(
                valueResolver: () => appSettings.Notifications,
                valueApplier: value => appSettings.Notifications = value
                ).DependsOn(appSettings, nameof(IAppSettings.Notifications));

            Title = new DelegatedProperty <string>(
                valueResolver: FormatTitle,
                valueApplier: null
                ).DependsOn(CurrentApk).AsReadonly();

            EnIsChecked = new DelegatedProperty <bool>(
                valueResolver: () => Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.ToLower() == "en",
                valueApplier: null
                ).AsReadonly();

            RuIsChecked = new DelegatedProperty <bool>(
                valueResolver: () => !EnIsChecked.Value,
                valueApplier: null
                ).DependsOn(EnIsChecked).AsReadonly();
        }
Example #4
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);
        }