Commit 804f000f authored by Rene Hampölz's avatar Rene Hampölz 💻

Bug fixes, Code cleanup, Add login functionality (via Wordpress), Add an option to open links via the menu
parent e7d70717
No preview for this file type
<Page x:Class="Main.Account.Account"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Main"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
d:DesignHeight="400" d:DesignWidth="700"
Title="Account">
<Grid>
<Grid Name="Info" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed">
<materialDesign:Card Padding="10" Width="400" Height="115" Background="#33b5e5" VerticalAlignment="Stretch">
<Grid>
<materialDesign:PackIcon VerticalAlignment="Top" Kind="Information" Height="30" Width="30" Foreground="White"/>
<TextBlock VerticalAlignment="Top" TextWrapping="Wrap" Margin="45,0,10,0" Foreground="White">Um Konto-Einstellungen vornehmen zu können, musst du dich anmelden. Wenn du noch kein Konto besitzt kannst du dich auch registrieren</TextBlock>
<Button Name="Login" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="110" Height="30" Background="Transparent" BorderBrush="White" Foreground="White" Content="Anmelden" Margin="45,65,0,0" Click="Login_Click"/>
<Button Name="Register" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="110" Height="30" Background="Transparent" BorderBrush="White" Foreground="White" Content="Registrieren" Margin="0,0,45,0" Click="Register_Click"/>
</Grid>
</materialDesign:Card>
</Grid>
<Grid Name="Password" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed">
<materialDesign:Card Padding="10" Width="400" Height="130" Background="#33b5e5" VerticalAlignment="Stretch">
<Grid>
<materialDesign:PackIcon VerticalAlignment="Top" Kind="Information" Height="30" Width="30" Foreground="White"/>
<TextBlock VerticalAlignment="Top" TextWrapping="Wrap" Margin="45,0" Foreground="White">Um Konto-Einstellungen vornehmen zu können, musst du dein Passwort eingeben.</TextBlock>
<PasswordBox Name="PasswordBox" VerticalAlignment="Center" materialDesign:HintAssist.Hint="Passwort" Margin="45,0" Foreground="White" PasswordChanged="Password_PasswordChanged">
<PasswordBox.Resources>
<SolidColorBrush x:Key="PrimaryHueMidBrush" Color="White"/>
<SolidColorBrush x:Key="MaterialDesignTextBoxBorder" Color="White"/>
</PasswordBox.Resources>
</PasswordBox>
<Button Name="CheckPassword" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="110" Height="30" Background="Transparent" BorderBrush="White" Foreground="White" Content="Bestätigen" Margin="45,0" Click="CheckPassword_Click"/>
</Grid>
</materialDesign:Card>
</Grid>
<ScrollViewer Name="Settings" Visibility="Visible">
<Grid>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" TextWrapping="Wrap" Text="Dein Konto" FontSize="30" Margin="20,20,0,0"/>
<Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Height="65" Margin="30,70,0,0" Width="328" StrokeThickness="2" Stroke="{DynamicResource PrimaryHueMidBrush}"/>
<TextBlock Name="Name" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="40,85,0,0" TextWrapping="Wrap" Text="Your Name" FontSize="18"/>
<TextBlock Name="Mail" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="40,105,0,0" TextWrapping="Wrap" Text="you.mail@provider.tld"/>
<CheckBox Name="cb_Newsletter" Content="Ich möchte den Newsletter erhalten" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="30,145,0,0" />
<Button Content="Abmelden" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="30,175,0,0"/>
<Button Content="Lösche dein Konto" Foreground="White" Background="Red" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="209,175,0,0" BorderBrush="Red"/>
</Grid>
</ScrollViewer>
</Grid>
</Page>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Main.Account
{
/// <summary>
/// Interaktionslogik für Account.xaml
/// </summary>
public partial class Account : Page
{
public Account()
{
InitializeComponent();
if (Properties.Settings.Default.Username != "" && Properties.Settings.Default.Password != "")
{
Info.Visibility = Visibility.Collapsed;
Settings.Visibility = Visibility.Collapsed;
Password.Visibility = Visibility.Visible;
}
else
{
Info.Visibility = Visibility.Visible;
Settings.Visibility = Visibility.Collapsed;
Password.Visibility = Visibility.Collapsed;
}
}
private void Login_Click(object sender, RoutedEventArgs e)
{
ProcessStartInfo ps = new ProcessStartInfo(System.Reflection.Assembly.GetEntryAssembly().Location)
{
Arguments = "-Config \"" + App.File + "\" -Login"
};
if (!File.Exists(App.File))
{
ps.Arguments = "-Login";
}
Process p = Process.Start(ps);
Application.Current.Shutdown();
}
private void Register_Click(object sender, RoutedEventArgs e)
{
ProcessStartInfo ps = new ProcessStartInfo(System.Reflection.Assembly.GetEntryAssembly().Location)
{
Arguments = "-Config \"" + App.File + "\" -Register"
};
if (!File.Exists(App.File))
{
ps.Arguments = "-Register";
}
Process p = Process.Start(ps);
Application.Current.Shutdown();
}
private void CheckPassword_Click(object sender, RoutedEventArgs e)
{
if (PasswordBox.Password == Properties.Settings.Default.Password)
{
Mail.Text = Properties.Settings.Default.Username;
Info.Visibility = Visibility.Collapsed;
Password.Visibility = Visibility.Collapsed;
Settings.Visibility = Visibility.Visible;
}
else
{
MSG.Show("error", "Das eingegebene Passwort stimmt nicht mit deinem Konto Passwort ein!");
}
}
private void Password_PasswordChanged(object sender, RoutedEventArgs e)
{
MSG.Show();
}
}
}
<Page x:Class="Main.Account.Account"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Main"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
d:DesignHeight="400" d:DesignWidth="700"
Title="Account">
<Grid>
</Grid>
</Page>
<Page x:Class="Main.Account.Account"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Main"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
d:DesignHeight="400" d:DesignWidth="700"
Title="Account">
<Grid>
</Grid>
</Page>
<Page x:Class="Main.Register"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Main"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
d:DesignHeight="465" d:DesignWidth="320"
Title="Registrieren">
<Grid Margin="0,0,0,0">
<StackPanel Margin="20,10,20,10">
<Label Content="Registrieren" FontFamily="Segoe UI Black" FontSize="24" Margin="0,10" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" TextWrapping="Wrap"><Run Text="Erstellen dir ein Konto, um alle deine Einstellungen online zu speichern und sie zwischen deinen Geräten zu synchronisieren."/></TextBlock>
<StackPanel Margin="0,15" Orientation="Horizontal">
<materialDesign:PackIcon Kind="AccountCardDetails" VerticalAlignment="Center"/>
<TextBox Name="FName" materialDesign:HintAssist.Hint="Vorname" Margin="5,5,10,5" Width="112" TextChanged="FName_TextChanged"/>
<materialDesign:PackIcon Kind="AccountCardDetails" VerticalAlignment="Center"/>
<TextBox Name="LName" materialDesign:HintAssist.Hint="Nachname" Margin="5" Width="112" TextChanged="LName_TextChanged"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Email" VerticalAlignment="Center"/>
<TextBox Name="Email" materialDesign:HintAssist.Hint="E-Mail Adresse" Margin="5" Width="255" TextChanged="Email_TextChanged"/>
</StackPanel>
<StackPanel Margin="0,15" Orientation="Horizontal">
<materialDesign:PackIcon Kind="Key" VerticalAlignment="Center"/>
<PasswordBox Name="Password" materialDesign:HintAssist.Hint="Passwort" Margin="5" Width="255" PasswordChanged="Password_PasswordChanged"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Key" VerticalAlignment="Center"/>
<PasswordBox Name="ReTypePassword" materialDesign:HintAssist.Hint="Passwort wiederhohlen" Margin="5" Width="255" PasswordChanged="ReTypePassword_PasswordChanged"/>
</StackPanel>
<StackPanel Margin="0,15" Orientation="Vertical">
<CheckBox Name="cb_PrivacyPolicy" Margin="5" Checked="Cb_PrivacyPolicy_Checked">
<TextBlock TextWrapping="Wrap">
Ich habe die
<Hyperlink Click="Hyperlink_RequestNavigate" Foreground="{DynamicResource PrimaryHueMidBrush}">
Datenschutz-Bestimmungen
</Hyperlink>
gelesen und verstanden
</TextBlock>
</CheckBox>
<CheckBox Name="cb_Newsletter" Margin="5" >
<TextBlock>
<AccessText TextWrapping="Wrap" Text="Ich möchte den Newsletter erhalten"/>
</TextBlock>
</CheckBox>
</StackPanel>
<Grid>
<Button x:Name="btn_Register" HorizontalAlignment="Right" Content="Registrieren" Width="120" Foreground="White" Click="Register_Click"/>
<Button x:Name="btn_Back" HorizontalAlignment="Left" Content="Zurück" Width="100" Click="Back_Click" Style="{DynamicResource MaterialDesignFlatButton}"/>
</Grid>
</StackPanel>
</Grid>
</Page>
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Net.Mail;
using System.IO;
using System.Windows.Media.Animation;
namespace Main
{
/// <summary>
/// Interaktionslogik für Login.xaml
/// </summary>
public partial class Register : Page
{
public Register()
{
InitializeComponent();
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Height = 465;
MW.Width = 320;
MW.ShowTitleBar = false;
MW.ShowMinButton = false;
MW.CenterWindowOnScreen();
MW.Title = this.Title + " - " + App.AppName;
#pragma warning disable CS0618 // Typ oder Element ist veraltet
MW.WindowCloseButtonStyle = (Style)FindResource("CloseButtonStyle");
MW.WindowMinButtonStyle = null;
#pragma warning restore CS0618 // Typ oder Element ist veraltet
}
}
private void Register_Click(object sender, RoutedEventArgs e)
{
MSG.Show();
RandomCode.Code = RandomCode.RandomString(9);
String Code = RandomCode.Code;
if (FName.Text == "")
{
MSG.Show("error", "Bitte gib deinen Vornamen ein!");
return;
}
if (LName.Text == "")
{
MSG.Show("error", "Bitte gib deinen Nachnamen ein!");
return;
}
else if (Email.Text == "")
{
MSG.Show("error", "Bitte gib deine E-Mail Adresse ein!");
return;
}
else if (Password.Password.ToString() == "")
{
MSG.Show("error", "Bitte gib ein Passwort ein!");
return;
}
else if (ReTypePassword.Password.ToString() == "")
{
MSG.Show("error", "Bitte wiederhohle das Passwort!");
return;
}
else if (Password.Password.ToString() != ReTypePassword.Password.ToString())
{
MSG.Show("error", "Die eingegebenen Passwörter stimmen nicht überein!");
return;
}
else if (cb_PrivacyPolicy.IsChecked == false)
{
MSG.Show("error", "Du musst die Datenschutz-Bestimmungen zustimmen, um fortzufahren!", 65);
return;
}
else
{
try
{
var eMailValidator = new MailAddress(Email.Text);
}
catch (FormatException)
{
MSG.Show("error", "Bitte gib eine gültige E-Mail-Adresse ein!");
return;
}
}
RegisterCheck.FirstName = FName.Text;
RegisterCheck.LastName = LName.Text;
RegisterCheck.Email = Email.Text;
RegisterCheck.Password = Password.Password.ToString();
RegisterCheck.Newsletter = cb_Newsletter.IsChecked.Value;
Index.Set("Account/RegisterCheck");
Mail.send(Email.Text, "Aktiviere dein Konto", File.ReadAllText("../../MailTemplates/RegisterCode.html").Replace("'VerifyCode'", Code));
}
private void Back_Click(object sender, RoutedEventArgs e)
{
RandomCode.Code = null;
MSG.Show();
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Index.GoBack();
}
}
private void Hyperlink_RequestNavigate(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("https://rh-utensils.ml/impressum/#datenschutz");
}
private void FName_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.Show();
}
private void LName_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.Show();
}
private void Email_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.Show();
}
private void Password_PasswordChanged(object sender, RoutedEventArgs e)
{
MSG.Show();
}
private void ReTypePassword_PasswordChanged(object sender, RoutedEventArgs e)
{
MSG.Show();
}
private void Cb_PrivacyPolicy_Checked(object sender, RoutedEventArgs e)
{
MSG.Show();
}
}
}
<Page x:Class="Main.RegisterCheck"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Main"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
d:DesignHeight="230" d:DesignWidth="320"
Title="Registrieren">
<Grid Margin="0,0,0,0">
<StackPanel Margin="20,10,20,10">
<Label Content="Registrieren" FontFamily="Segoe UI Black" FontSize="24" Margin="0,10" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<TextBlock x:Name="Description" HorizontalAlignment="Left" VerticalAlignment="Top" TextWrapping="Wrap"><Run Text="Du hast eine E-Mail mit einem Bestätigungscode erhalten. Gib diesen Code hier ein."/></TextBlock>
<StackPanel Margin="0,15" Orientation="Horizontal">
<materialDesign:PackIcon Kind="Keyboard" VerticalAlignment="Center"/>
<TextBox x:Name="VCode" materialDesign:HintAssist.Hint="Bestätigungscode" Margin="5" Width="255" TextChanged="VCode_TextChanged"/>
</StackPanel>
<Grid>
<Button x:Name="btn_Check" HorizontalAlignment="Right" Content="Überprüfen" Width="120" Foreground="White" Click="Check_Click"/>
<Button x:Name="btn_Back" HorizontalAlignment="Left" Content="Zurück" Width="100" Click="Back_Click" Style="{DynamicResource MaterialDesignFlatButton}"/>
</Grid>
</StackPanel>
</Grid>
</Page>
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Main
{
public partial class RegisterCheck : Page
{
public RegisterCheck()
{
InitializeComponent();
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Height = 230;
MW.Width = 320;
MW.ShowTitleBar = false;
MW.ShowMinButton = false;
MW.CenterWindowOnScreen();
MW.Title = this.Title + " - " + App.AppName;
#pragma warning disable CS0618 // Typ oder Element ist veraltet
MW.WindowCloseButtonStyle = (Style)FindResource("CloseButtonStyle");
MW.WindowMinButtonStyle = null;
#pragma warning restore CS0618 // Typ oder Element ist veraltet
}
}
public static String FirstName;
public static String LastName;
public static String Email;
public static String Password;
public static Boolean Newsletter;
private void Check_Click(object sender, RoutedEventArgs e)
{
MSG.Show();