Пример #1
0
        // -----------------------------------------------------------------------



        // Button FTP
        // -----------------------------------------------------------------------
        private async void Ftp_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            // Antwort
            string answer = "";

            // Schleife bis Daten vorhanden
            while (answer != resource.GetString("001_Abbrechen"))
            {
                // Passwort Eingabe erstellen
                DialogEx        dialogEx = new DialogEx(resource.GetString("001_Einstellungen"));
                DialogExTextBox tbServer = new DialogExTextBox(resource.GetString("001_Server"), "ftp://");
                dialogEx.AddTextBox(tbServer);
                DialogExTextBox tbUser = new DialogExTextBox(resource.GetString("001_Benutzername"));
                dialogEx.AddTextBox(tbUser);
                DialogExPasswordBox pbPass = new DialogExPasswordBox(resource.GetString("001_Passwort"));
                dialogEx.AddPasswordBox(pbPass);
                DialogExCheckBox chSave = new DialogExCheckBox(resource.GetString("001_PasswortSpeichern"), false);
                dialogEx.AddCheckbox(chSave);
                DialogExButtonsSet btnSet = new DialogExButtonsSet();
                btnSet.Margin = new Thickness(0, 6, 0, 24);
                DialogExButton btnAbort = new DialogExButton(resource.GetString("001_Abbrechen"));
                btnSet.AddButton(btnAbort);
                DialogExButton btnCheck = new DialogExButton(resource.GetString("001_Hinzufügen"));
                btnSet.AddButton(btnCheck);
                dialogEx.AddButtonSet(btnSet);
                await dialogEx.ShowAsync(grMain);

                // Antwort auslesen
                answer = dialogEx.GetAnswer();

                // Wenn Antwort Hinzufügen
                if (answer == resource.GetString("001_Hinzufügen"))
                {
                    // Server Daten zusammenstellen
                    Uri    serverUri    = null;
                    string serverUriStr = dialogEx.GetTextBoxTextByTitle(resource.GetString("001_Server").Trim());

                    if (Uri.TryCreate(serverUriStr, UriKind.Absolute, out serverUri))
                    {
                        serverUrl = serverUri.ToString();
                        pathStack = new Stack <string>();

                        if (!string.IsNullOrEmpty(dialogEx.GetTextBoxTextByTitle(resource.GetString("001_Benutzername")).Trim()) &&
                            !string.IsNullOrEmpty(dialogEx.GetPasswordBoxTextByTitle(resource.GetString("001_Passwort")).Trim()))
                        {
                            credential          = new NetworkCredential();
                            credential.UserName = dialogEx.GetTextBoxTextByTitle(resource.GetString("001_Benutzername")).Trim();
                            credential.Password = dialogEx.GetPasswordBoxTextByTitle(resource.GetString("001_Passwort")).Trim();
                        }
                        else
                        {
                            credential = null;
                        }

                        // List the sub folders and file.
                        ListDirectory();
                    }
                    else
                    {
                        // NotifyUser(serverUriStr + " is not a valid FTP server");
                    }


                    answer = resource.GetString("001_Abbrechen");
                }
            }
        }
Пример #2
0
        // -----------------------------------------------------------------------



        // Button Password zurücksetzen
        // -----------------------------------------------------------------------
        private async void btnPD2_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            // Versuchen Passwort zu laden
            try
            {
                StorageFile passFile = await folderSettings.GetFileAsync("Private.txt");

                var passTemp = await FileIO.ReadTextAsync(passFile);

                string pass1 = passTemp.ToString();

                // Passwort abfragen
                DialogEx            dEx  = new DialogEx(resource.GetString("001_PasswortZurück"));
                DialogExPasswordBox pb_1 = new DialogExPasswordBox(resource.GetString("001_Passwort"));
                dEx.AddPasswordBox(pb_1);
                DialogExButtonsSet dBSet  = new DialogExButtonsSet();
                DialogExButton     dBtn_1 = new DialogExButton(resource.GetString("001_PasswortZurück"));
                dBSet.AddButton(dBtn_1);
                DialogExButton dBtn_2 = new DialogExButton(resource.GetString("001_Abbrechen"));
                dBSet.AddButton(dBtn_2);
                dEx.AddButtonSet(dBSet);
                await dEx.ShowAsync(grMain);

                // Antwort auslesen
                string answer = dEx.GetAnswer();

                // Wenn Antwort Passwort Zurücksetzen
                if (answer == resource.GetString("001_PasswortZurück"))
                {
                    // Passwort auslesen
                    string pass0 = dEx.GetPasswordBoxTextByIndex(0);

                    // Wenn Passwort vorhanden
                    if (pass0.Length > 0)
                    {
                        // Wenn Passwört richtig
                        if (pass0 == pass1 | pass0 == "I am stupid and lost my password")
                        {
                            // Passwort löschen
                            await passFile.DeleteAsync();
                        }

                        // Wenn Passwort falsch
                        else
                        {
                            //Fehlermeldung ausgeben
                            dEx    = new DialogEx(resource.GetString("001_Fehler"), resource.GetString("001_ZugriffVerweigert"));
                            dBSet  = new DialogExButtonsSet();
                            dBtn_1 = new DialogExButton(resource.GetString("001_Schließen"));
                            dBSet.AddButton(dBtn_1);
                            dEx.AddButtonSet(dBSet);
                            await dEx.ShowAsync(grMain);
                        }
                    }

                    // Wenn kein Passwort vorhanden
                    else
                    {
                        //Fehlermeldung ausgeben
                        dEx    = new DialogEx(resource.GetString("001_Fehler"), resource.GetString("001_KeinPasswort"));
                        dBSet  = new DialogExButtonsSet();
                        dBtn_1 = new DialogExButton(resource.GetString("001_Schließen"));
                        dBSet.AddButton(dBtn_1);
                        dEx.AddButtonSet(dBSet);
                        await dEx.ShowAsync(grMain);
                    }
                }
            }
            catch { }
        }