예제 #1
0
        private void InitSortList()
        {
            SortListProperties.Add(new CustomComboboxItem()
            {
                DisplayText = TranslateService.ProvideValue("FileName"),
                Value       = "FileName"
            });

            SortListProperties.Add(new CustomComboboxItem()
            {
                DisplayText = TranslateService.ProvideValue("FileExt"),
                Value       = "FileExtension"
            });

            SortListProperties.Add(new CustomComboboxItem()
            {
                DisplayText = TranslateService.ProvideValue("EncryptDate"),
                Value       = "FileEncryptionDate"
            });

            SortListProperties.Add(new CustomComboboxItem()
            {
                DisplayText = TranslateService.ProvideValue("EncryptMethod"),
                Value       = "FileEncryptionMethod"
            });

            SelectedSortProperty = SortListProperties.FirstOrDefault(x => x.Value == SortListProperty);
        }
        private async void onLanguageChange(string obj)
        {
            UserDialogsService.ShowLoading(TranslateService.ProvideValue("Loading"));
            CrossMultilingual.Current.CurrentCultureInfo = new CultureInfo(obj);
            AppResources.Culture = CrossMultilingual.Current.CurrentCultureInfo;
            await NavigationService.UpdagePagesLanguage();

            UserDialogsService.HideLoading();
        }
예제 #3
0
 private async void LoginExe()
 {
     using (UserDialogs.Instance.Loading(TranslateService.ProvideValue("Loading")))
         if (CheckCredentials())
         {
             //await Task.Delay(1500);
             App.IsUserLoggedIn = true;
             await NavigationService.InsertNewRootPage("MainPage");
         }
         else
         {
             UserDialogsService.ShowAltert(TranslateService.ProvideValue("Message_WrongPassword"), TranslateService.ProvideValue("Message_LoginError"));
         }
 }
예제 #4
0
 private async void SavePassExe()
 {
     if (OldPasswordEntry == UserPassword)
     {
         if (verifyPassword())
         {
             UserPassword = _passwordEntry;
             await NavigationService.GoBack();
         }
     }
     else
     {
         UserDialogsService.ShowAltert(TranslateService.ProvideValue("Message_OldPasswordDoesntMatch"), TranslateService.ProvideValue("Message_WrongPasswrdShort"));
     }
 }
예제 #5
0
        public MainViewModel()
        {
            SettingsPageCmd     = new RelayCommand(SettingsPageExe);
            AddNewFileCmd       = new RelayCommand(AddNewFileExe);
            OpenFileCmd         = new RelayCommand(OpenFileExe);
            DeleteFileObjectCmd = new RelayCommand <object>(DeleteFileObjectExe);
            AboutPageCmd        = new RelayCommand(AboutPageExe);
            DetailsPageCmd      = new RelayCommand <object>(DetailsPageExe);
            HelpPageCmd         = new RelayCommand(HelpPageExe);
            SaveAsCmd           = new RelayCommand <object>(SaveAsExe);
            ExitAppCmd          = new RelayCommand(ExitAppExe);
            string test = TranslateService.ProvideValue("NavigationBar_Settings");

            InitSortList();
        }
예제 #6
0
        private void OpenFileExe()
        {
            try
            {
                UserDialogsService.ShowLoading("Decrypting file...");
                var bytes         = default(byte[]);
                var DecryptedData = default(byte[]);
                using (var streamReader = new StreamReader(SelectedFileObject.FilePath))
                {
                    using (var memstream = new MemoryStream())
                    {
                        streamReader.BaseStream.CopyTo(memstream);
                        bytes = memstream.ToArray();
                    }
                }

                switch (SelectedFileObject.FileEncryptionMethod)
                {
                case CryptMethod.AES:
                    DecryptedData = _AES.Decrypt(bytes, SelectedFileObject.FileDecryptionPassword);
                    break;

                case CryptMethod.DES:
                    DecryptedData = _DES.Decrypt(bytes, SelectedFileObject.FileDecryptionPassword);
                    break;

                case CryptMethod.TripleDES:
                    DecryptedData = _3DES.Decrypt(bytes, SelectedFileObject.FileDecryptionPassword);
                    break;

                default:
                    break;
                }

                string decryptedFilePath = SaveFileContentToFile(DecryptedData, $"tmpDecrypted_{Path.GetFileName(SelectedFileObject.FilePath)}");

                UserDialogsService.HideLoading();

                DependencyService.Get <IDocumentOpener>().OpenFile(decryptedFilePath);
            }
            catch (Exception ex)
            {
                UserDialogsService.HideLoading();
                //UserDialogsService.DisplayException(ex);
                UserDialogsService.ShowAltert(TranslateService.ProvideValue("CantOpenFile"), "");
            }
        }
예제 #7
0
        public void OpenFile(string path)
        {
            try
            {
                Android.Net.Uri uri;

                string auth     = "com.Linaq.LinaqStorage.Android.fileprovider";
                string mimeType = Android.Webkit.MimeTypeMap.Singleton.GetMimeTypeFromExtension(Android.Webkit.MimeTypeMap.GetFileExtensionFromUrl(path.ToLower()));
                if (mimeType == null)
                {
                    mimeType = "*/*";
                }

                if (path.StartsWith("content://"))
                {
                    uri = Android.Net.Uri.Parse(path);
                }
                else
                {
                    var file = new Java.IO.File(Path.Combine(Android.App.Application.Context.FilesDir.Path, path));
                    uri = FileProvider.GetUriForFile(Android.App.Application.Context, auth, file);
                }
                //Intent.ActionView)
                Intent intent = new Intent(Intent.ActionView);
                intent.SetDataAndType(uri, mimeType);
                intent.AddFlags(ActivityFlags.GrantReadUriPermission | ActivityFlags.GrantWriteUriPermission);
                intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.NoHistory);
                //intent.SetAction(Intent.ActionGetContent);

                // Trying to allow writing to the external app ...
                var resInfoList = Android.App.Application.Context.PackageManager.QueryIntentActivities(intent, PackageInfoFlags.MatchDefaultOnly);
                foreach (var resolveInfo in resInfoList)
                {
                    var packageName = resolveInfo.ActivityInfo.PackageName;
                    Android.App.Application.Context.GrantUriPermission(packageName, uri, ActivityFlags.GrantWriteUriPermission | ActivityFlags.GrantPrefixUriPermission | ActivityFlags.GrantReadUriPermission);
                }

                Android.App.Application.Context.StartActivity(intent);
            }
            catch (Exception ex)
            {
                UserDialogsService.ShowAltert(TranslateService.ProvideValue("CantOpenFile"), "");
                //   Toast.MakeText(Android.App.Application.Context, TranslateService.ProvideValue("CantOpenFile"), ToastLength.Long).Show();
                // Toast.MakeText(Android.App.Application.Context, $"Exception {ex.Message}, InnerException: {ex.InnerException}. StackTrace: {ex.StackTrace}", ToastLength.Long).Show();
            }
        }
예제 #8
0
        private void ResetPassword()
        {
            try
            {
                JsonService.ResetList();
                App.AppSettings.AddOrUpdateValue("UserPassword", string.Empty);
                IEnumerable <string> files = Directory.EnumerateFiles(Constants.localAppDataFolder, "*");
                foreach (string f in files)
                {
                    File.Delete(f);
                }

                UserDialogs.Instance.Alert(TranslateService.ProvideValue("PasswordPage_PasswordResetSucessfully"), TranslateService.ProvideValue("PasswordPage_PasswordReset"), "Ok");
            }
            catch (Exception ex)
            {
                UserDialogsService.DisplayException(ex);
            }
        }
예제 #9
0
        private async void ResetPasswordExe()
        {
            try
            {
                bool ConfirmResult = await UserDialogs.Instance.ConfirmAsync(new ConfirmConfig
                {
                    Title      = TranslateService.ProvideValue("PasswordPage_PasswordReset"),
                    Message    = TranslateService.ProvideValue("PasswordPage_PasswordResetInfoLoseData"),
                    OkText     = "OK",
                    CancelText = TranslateService.ProvideValue("Cancel")
                });

                if (ConfirmResult)
                {
                    ResetPassword();
                    await NavigationService.InsertNewRootPage("PasswordSetPage");
                }
            }
            catch (Exception ex)
            {
                UserDialogsService.DisplayException(ex);
            }
        }
예제 #10
0
        private bool verifyPassword()
        {
            string errorMessage = string.Empty;

            if (string.IsNullOrWhiteSpace(_passwordEntry) || string.IsNullOrWhiteSpace(_confirmPasswordEntry) || string.IsNullOrWhiteSpace(_oldPasswordEntry))
            {
                errorMessage += TranslateService.ProvideValue("Message_FilleAllFields") + "\n";
            }
            if (_passwordEntry != _confirmPasswordEntry)
            {
                errorMessage += TranslateService.ProvideValue("Message_PasswordsDoesntMatch") + "\n";
            }
            if (_passwordEntry.Length < 8)
            {
                errorMessage += TranslateService.ProvideValue("Message_PasswordTooShort") + "\n";
            }
            if (!_passwordEntry.Any(char.IsSymbol))
            {
                errorMessage += TranslateService.ProvideValue("Message_PasswordOneSymbol") + "\n";
            }
            if (!_passwordEntry.Any(char.IsUpper))
            {
                errorMessage += TranslateService.ProvideValue("Message_PasswordOneBigLetter") + "\n";
            }
            if (!_passwordEntry.Any(char.IsNumber))
            {
                errorMessage += TranslateService.ProvideValue("Message_PasswordOneNumber") + "\n";
            }

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                UserDialogsService.ShowAltert(errorMessage, TranslateService.ProvideValue("Message_WrongPasswrdShort"));
                return(false);
            }

            return(true);
        }