Commit ae41b88b authored by Rene Hampölz's avatar Rene Hampölz 💻

Bug fixes

parent fc8e161d
No preview for this file type
......@@ -19,6 +19,43 @@
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;
......@@ -23,6 +25,74 @@ namespace Main.Account
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>
......@@ -16,7 +16,7 @@
FontFamily="{DynamicResource MaterialDesignFont}"
d:DesignHeight="290" d:DesignWidth="320"
Title="Anmelden">
Title="Anmelden" Loaded="Page_Loaded">
<Grid>
<StackPanel Margin="20,10,20,10">
......@@ -43,8 +43,8 @@
</Grid>
<Grid>
<Button x:Name="btn_Skip" HorizontalAlignment="Right" Content="Überspringen" Width="120" Click="Skip_Click" Style="{DynamicResource MaterialDesignFlatButton}"/>
<Button x:Name="btn_Login" HorizontalAlignment="Left" Content="Anmelden" Width="100" Foreground="White" Click="Login_Click"/>
<Button x:Name="btn_Skip" HorizontalAlignment="Right" Content="Überspringen" Width="120" Click="Skip_Click" Style="{DynamicResource MaterialDesignFlatButton}"/>
</Grid>
</StackPanel>
</Grid>
......
......@@ -43,6 +43,15 @@ namespace Main
}
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (App.Register)
{
App.Register = false;
Index.Set(@"Account\Register");
}
}
private void MainWindow()
{
if (Application.Current.MainWindow is MainWindow MW)
......@@ -53,16 +62,16 @@ namespace Main
private void Login_Click(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
if (Email.Text == "")
{
MSG.show("error", "Gib bitte deine E-Mail Adresse ein!");
MSG.Show("error", "Gib bitte deine E-Mail Adresse ein!");
return;
}
else if (Password.Password.ToString() == "")
{
MSG.show("error", "Gib bitte ein Passwort ein!");
MSG.Show("error", "Gib bitte ein Passwort ein!");
return;
}
else
......@@ -73,14 +82,18 @@ namespace Main
}
catch (FormatException)
{
MSG.show("error", "Gib bitte eine gültige E-Mail Adresse ein!");
MSG.Show("error", "Gib bitte eine gültige E-Mail Adresse ein!");
return;
}
}
//MySQL Abfrage
MSG.show();
Properties.Settings.Default.Username = Email.Text;
Properties.Settings.Default.Password = Password.Password;
Properties.Settings.Default.Save();
MSG.Show();
MainWindow();
}
......@@ -90,7 +103,7 @@ namespace Main
Properties.Settings.Default.SkipLogin = true;
Properties.Settings.Default.Save();
MSG.show();
MSG.Show();
MainWindow();
}
......@@ -107,12 +120,12 @@ namespace Main
private void Email_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.show();
MSG.Show();
}
private void Password_PasswordChanged(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
}
}
}
......@@ -28,8 +28,7 @@ namespace Main
{
InitializeComponent();
MainWindow MW = Application.Current.MainWindow as MainWindow;
if (MW != null)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Height = 465;
MW.Width = 320;
......@@ -50,50 +49,50 @@ namespace Main
private void Register_Click(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
RandomCode.Code = RandomCode.RandomString(9);
String Code = RandomCode.Code;
if (FName.Text == "")
{
MSG.show("error", "Bitte gib deinen Vornamen ein!");
MSG.Show("error", "Bitte gib deinen Vornamen ein!");
return;
}
if (LName.Text == "")
{
MSG.show("error", "Bitte gib deinen Nachnamen ein!");
MSG.Show("error", "Bitte gib deinen Nachnamen ein!");
return;
}
else if (Email.Text == "")
{
MSG.show("error", "Bitte gib deine E-Mail Adresse ein!");
MSG.Show("error", "Bitte gib deine E-Mail Adresse ein!");
return;
}
else if (Password.Password.ToString() == "")
{
MSG.show("error", "Bitte gib ein Passwort ein!");
MSG.Show("error", "Bitte gib ein Passwort ein!");
return;
}
else if (ReTypePassword.Password.ToString() == "")
{
MSG.show("error", "Bitte wiederhohle das Passwort!");
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!");
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);
MSG.Show("error", "Du musst die Datenschutz-Bestimmungen zustimmen, um fortzufahren!", 65);
return;
}
......@@ -105,7 +104,7 @@ namespace Main
}
catch (FormatException)
{
MSG.show("error", "Bitte gib eine gültige E-Mail-Adresse ein!");
MSG.Show("error", "Bitte gib eine gültige E-Mail-Adresse ein!");
return;
}
......@@ -126,10 +125,9 @@ namespace Main
{
RandomCode.Code = null;
MSG.show();
MSG.Show();
MainWindow MW = Application.Current.MainWindow as MainWindow;
if (MW != null)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Index.GoBack();
}
......@@ -142,32 +140,32 @@ namespace Main
private void FName_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.show();
MSG.Show();
}
private void LName_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.show();
MSG.Show();
}
private void Email_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.show();
MSG.Show();
}
private void Password_PasswordChanged(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
}
private void ReTypePassword_PasswordChanged(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
}
private void Cb_PrivacyPolicy_Checked(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
}
}
}
......@@ -24,8 +24,7 @@ namespace Main
{
InitializeComponent();
MainWindow MW = Application.Current.MainWindow as MainWindow;
if (MW != null)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Height = 230;
MW.Width = 320;
......@@ -52,19 +51,19 @@ namespace Main
private void Check_Click(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
String Code = RandomCode.Code;
if (VCode.Text == "")
{
MSG.show("error", "Bitte gib den Bestätigungscode ein!");
MSG.Show("error", "Bitte gib den Bestätigungscode ein!");
return;
}
if (VCode.Text != Code)
{
MSG.show("error", "Der Bestätigungscode ist ungültig!");
MSG.Show("error", "Der Bestätigungscode ist ungültig!");
return;
}
......@@ -75,17 +74,16 @@ namespace Main
Index.Set("Account/Login");
MSG.show("success", "Du hast dich erfollgreich registriert!");
MSG.Show("success", "Du hast dich erfollgreich registriert!");
}
private void Back_Click(object sender, RoutedEventArgs e)
{
RandomCode.Code = null;
MSG.show();
MSG.Show();
MainWindow MW = Application.Current.MainWindow as MainWindow;
if (MW != null)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Index.GoBack();
}
......@@ -93,7 +91,7 @@ namespace Main
private void VCode_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.show();
MSG.Show();
}
}
}
......@@ -25,8 +25,7 @@ namespace Main
{
InitializeComponent();
MainWindow MW = Application.Current.MainWindow as MainWindow;
if (MW != null)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Height = 220;
MW.Width = 320;
......@@ -47,14 +46,14 @@ namespace Main
private void ResetPassword_Click(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
RandomCode.Code = RandomCode.RandomString(9);
String Code = RandomCode.Code;
if (Email.Text == "")
{
MSG.show("error", "Bitte gib deine E-Mail-Adresse ein!");
MSG.Show("error", "Bitte gib deine E-Mail-Adresse ein!");
return;
}
......@@ -66,7 +65,7 @@ namespace Main
}
catch (FormatException)
{
MSG.show("error", "Bitte gib eine gültige E-Mail-Adresse ein!");
MSG.Show("error", "Bitte gib eine gültige E-Mail-Adresse ein!");
return;
}
......@@ -81,17 +80,16 @@ namespace Main
private void Email_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.show();
MSG.Show();
}
private void Back_Click(object sender, RoutedEventArgs e)
{
RandomCode.Code = null;
MSG.show();
MSG.Show();
MainWindow MW = Application.Current.MainWindow as MainWindow;
if (MW != null)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Index.GoBack();
}
......
......@@ -44,19 +44,19 @@ namespace Main
private void ResetPassword_Click(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
String Code = RandomCode.Code;
if (VCode.Text == "")
{
MSG.show("error", "Bitte gib den Bestätigungscode ein!");
MSG.Show("error", "Bitte gib den Bestätigungscode ein!");
return;
}
if (VCode.Text != Code)
{
MSG.show("error", "Der Bestätigungscode ist ungültig!");
MSG.Show("error", "Der Bestätigungscode ist ungültig!");
return;
}
......@@ -68,10 +68,9 @@ namespace Main
{
RandomCode.Code = null;
MSG.show();
MSG.Show();
MainWindow MW = Application.Current.MainWindow as MainWindow;
if (MW != null)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Index.GoBack();
}
......@@ -79,7 +78,7 @@ namespace Main
private void VCode_TextChanged(object sender, TextChangedEventArgs e)
{
MSG.show();
MSG.Show();
}
}
}
......@@ -22,8 +22,7 @@ namespace Main
{
InitializeComponent();
MainWindow MW = Application.Current.MainWindow as MainWindow;
if (MW != null)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Height = 255;
MW.Width = 320;
......@@ -44,23 +43,23 @@ namespace Main
private void ResetPassword_Click(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
if (Password.Password.ToString() == "")
{
MSG.show("error", "Bitte gib ein Passwort ein!");
MSG.Show("error", "Bitte gib ein Passwort ein!");
return;
}
else if (ReTypePassword.Password.ToString() == "")
{
MSG.show("error", "Bitte wiederhohle das Passwort!");
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!");
MSG.Show("error", "Die eingegebenen Passwörter stimmen nicht überein!");
return;
}
......@@ -69,15 +68,14 @@ namespace Main
Index.Set("Account/Login");
MSG.show("success", "Du hast dein Passwort erfollgreich geändert!");
MSG.Show("success", "Du hast dein Passwort erfollgreich geändert!");
}
private void Back_Click(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
MainWindow MW = Application.Current.MainWindow as MainWindow;
if (MW != null)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Index.GoBack();
MW.Index.GoBack();
......@@ -86,12 +84,12 @@ namespace Main
private void Password_PasswordChanged(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
}
private void ReTypePassword_PasswordChanged(object sender, RoutedEventArgs e)
{
MSG.show();
MSG.Show();
}
}
}
......@@ -28,7 +28,8 @@ namespace Main
public static String[] SiteIcon = {"account.png"};
public static Boolean SkipLogin;
public static Boolean ShowLogin;
public static Boolean Login;
public static Boolean Register;
public static String File;
......@@ -38,23 +39,28 @@ namespace Main
{
if (e.Args[i] == "-Config")
{
File = e.Args[1];
AppName = XML.Read(e.Args[1], "AppName");
Theme = XML.Read(e.Args[1], "Theme");
File = e.Args[i + 1];
AppName = XML.Read(e.Args[i + 1], "AppName");
Theme = XML.Read(e.Args[i + 1], "Theme");
SiteTitle = XML.ReadList(e.Args[1], "SiteTitle");
SitePath = XML.ReadList(e.Args[1], "SitePath");
SiteIcon = XML.ReadList(e.Args[1], "SiteIcon");
SiteTitle = XML.ReadList(e.Args[i + 1], "SiteTitle");
SitePath = XML.ReadList(e.Args[i + 1], "SitePath");
SiteIcon = XML.ReadList(e.Args[i + 1], "SiteIcon");
}
if (e.Args[i] == "-ShowLogin")
if (e.Args[i] == "-Login")
{
ShowLogin = true;
Login = true;
}
else if (e.Args[i] == "-SkipLogin")
{
SkipLogin = true;
}
if (e.Args[i] == "-Register")
{
Register = true;
}
}
if (AppName == "")
......@@ -62,20 +68,23 @@ namespace Main
AppName = "RH Utensils";
}
Mutex mutex = new Mutex(true, this.GetType().GUID.ToString(), out bool createdNew);
if (createdNew)
{
Window window = new MainWindow();
window.Closed += (sender2, args) => mutex.Close();
window.Show();
}
else
{
MoveToForeground.move();
Window window = new MainWindow();
window.Show();
mutex.Close();
Application.Current.Shutdown();
}
//Mutex mutex = new Mutex(true, this.GetType().GUID.ToString(), out bool createdNew);
//if (createdNew)
//{
// Window window = new MainWindow();
// window.Closed += (sender2, args) => mutex.Close();
// window.Show();
//}
//else
//{
// MoveToForeground.move();
// mutex.Close();
// Application.Current.Shutdown();
//}
}
}
}
......@@ -19,7 +19,7 @@ namespace Main
if (removeMSG)
{
MSG.show();
MSG.Show();
}
}
......