parent
b2f0fdc64f
commit
aec8055491
@ -31,16 +31,28 @@ public class MainScreen : Window
|
||||
private FlowLayout? channelpicker, friends, friend_request;
|
||||
private RoundedButton? FriendManagerBtn;
|
||||
public Chat? chat;
|
||||
Login login;
|
||||
CreateAccount ca;
|
||||
|
||||
public MainScreen() : base(Settings)
|
||||
{
|
||||
Login login;
|
||||
Controls.Add(ca = new CreateAccount() {Visible = false});
|
||||
ca.ChangeToApp += LoginOnChangeToApp;
|
||||
Controls.Add(login = new Login());
|
||||
login.ChangeToApp += LoginOnChangeToApp;
|
||||
login.ChangeToCa += LoginOnChangeToCa;
|
||||
Thread t = new(_ => Encryption.GenerateKeys());
|
||||
t.Start();
|
||||
}
|
||||
|
||||
private Task LoginOnChangeToCa()
|
||||
{
|
||||
Title = "Create Account";
|
||||
ca.Visible = true;
|
||||
login.Visible = false;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void AddGroup(SocketGroupChannel group)
|
||||
{
|
||||
Group friend = new(group);
|
||||
|
101
Luski/GUI/StartPage/UI/CreateAccount.cs
Normal file
101
Luski/GUI/StartPage/UI/CreateAccount.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects;
|
||||
using Luski.net;
|
||||
using Luski.net.Enums;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
|
||||
namespace Luski.GUI.StartPage.UI;
|
||||
|
||||
public class CreateAccount : UserControl
|
||||
{
|
||||
private RoundedButton button;
|
||||
private Textbox Password, Email, Username;
|
||||
private Rectangle rec;
|
||||
private string pfp = null;
|
||||
|
||||
public event Func<Task> ChangeToApp;
|
||||
|
||||
public CreateAccount()
|
||||
{
|
||||
Size = new(481, 838);
|
||||
Controls.Add(new Rectangle(Globals.LuskiTexture) { Location = new(103,8), Size = new(276, 289)});
|
||||
Controls.Add(new Label() { Scale = 1.4f, Location = new(173,305), Text = "Luski", Color = new(243, 119, 53, 255) });
|
||||
Controls.Add(new Label() { Location = new(41,395), Text = "Email"});
|
||||
Controls.Add(Email = new Textbox() { Location = new(41,431), Size = new(401,41), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan });
|
||||
Controls.Add(new Label() { Location = new(41,490), Text = "Password" });
|
||||
Controls.Add(Password = new Textbox() { PasswordChar = '●', Location = new(41,531), Size = new(401, 41), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||
Controls.Add(new Label() { Location = new(41,580), Text = "Display Name" });
|
||||
Controls.Add(Username = new Textbox() { Location = new(41,616), Size = new(300, 41), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||
Controls.Add(button = new() { Text = "Create Account", Location = new(41, 700), Size = new(401, 71), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||
Controls.Add(rec = new Rectangle(){ Location = new(350, 585), Size = new(100), BackgroundColor = Color4.Red});
|
||||
Password.KeyPress += PasswordOnKeyPress;
|
||||
Email.KeyPress += EmailOnKeyPress;
|
||||
button.Clicked += ButtonOnClicked;
|
||||
Username.KeyPress += UsernameOnKeyPress;
|
||||
rec.FilesDroped += RecOnFilesDroped;
|
||||
}
|
||||
|
||||
private Task UsernameOnKeyPress(KeyboardKeyEventArgs arg)
|
||||
{
|
||||
if (arg.Key != Keys.Enter && arg.Key != Keys.KeyPadEnter && arg.Key != Keys.Tab) return Task.CompletedTask;
|
||||
if (arg.Key == Keys.Tab && arg.Shift) { Password.Focus(); return Task.CompletedTask; }
|
||||
if (arg.Key == Keys.Enter || arg.Key == Keys.KeyPadEnter) ButtonOnClicked(Username);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task RecOnFilesDroped(string[] arg)
|
||||
{
|
||||
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;
|
||||
Controls.Remove(rec);
|
||||
pfp = arg[0];
|
||||
rec = new(new(File.ReadAllBytes(arg[0]))){ Location = new(350, 585), Size = new(100) };
|
||||
Controls.Add(rec);
|
||||
Window!.DrawFrame();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private bool tab;
|
||||
private Task EmailOnKeyPress(KeyboardKeyEventArgs arg)
|
||||
{
|
||||
if (arg.Key != Keys.Tab) return Task.CompletedTask;
|
||||
if (arg.Key == Keys.Tab){ Password.Focus(); tab = true;}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task PasswordOnKeyPress(KeyboardKeyEventArgs arg)
|
||||
{
|
||||
if (tab)
|
||||
{
|
||||
tab = false;
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
if (arg.Key != Keys.Enter && arg.Key != Keys.KeyPadEnter && arg.Key != Keys.Tab) return Task.CompletedTask;
|
||||
if (arg.Key == Keys.Tab && arg.Shift) { Email.Focus(); return Task.CompletedTask; }
|
||||
if (arg.Key == Keys.Tab ){ Username.Focus(); return Task.CompletedTask; }
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task ButtonOnClicked(IRenderObject arg)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] arr = new string[]
|
||||
{
|
||||
Email.Text,
|
||||
Password.Text,
|
||||
Username.Text,
|
||||
pfp
|
||||
};
|
||||
if (arr.Any(s => string.IsNullOrEmpty(s))) return Task.CompletedTask;
|
||||
Globals.Luski = Server.CreateAccount(Email.Text, Password.Text, Username.Text, pfp, Globals.Branch);
|
||||
ChangeToApp.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
@ -1,10 +1,6 @@
|
||||
using System.Reflection;
|
||||
using GraphicsManager;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using Luski.net;
|
||||
using Luski.net.Enums;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
@ -15,21 +11,37 @@ public class Login : UserControl
|
||||
{
|
||||
private RoundedButton button;
|
||||
private Textbox Password, Email;
|
||||
private Label ca;
|
||||
public event Func<Task> ChangeToApp;
|
||||
public event Func<Task> ChangeToCa;
|
||||
public Login()
|
||||
{
|
||||
Size = new(481, 838);
|
||||
Controls.Add(new Rectangle(Globals.LuskiTexture) { Location = new(103,8), Size = new(276, 289)});
|
||||
Controls.Add(new Label() { Location = new(173,305), Text = "Luski", Color = new(243, 119, 53, 255) });
|
||||
Controls.Add(new Label() { Scale = 1.4f, Location = new(173,305), Text = "Luski", Color = new(243, 119, 53, 255) });
|
||||
Controls.Add(new Label() { Location = new(41,395), Text = "Email"});
|
||||
Controls.Add(Email = new Textbox() { Location = new(41,431), Size = new(401,41), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan });
|
||||
Controls.Add(new Label() { Location = new(41,521), Text = "Password" });
|
||||
Controls.Add(Password = new Textbox() { PasswordChar = '●', Location = new(41,562), Size = new(401, 41), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||
Controls.Add(new Label() { Location = new(41,664), Text = "Create Account" });
|
||||
Controls.Add(ca = new Label() { Location = new(41,664), Text = "Create Account" });
|
||||
Controls.Add(button = new() { Text = "Login", Location = new(41, 700), Size = new(401, 71), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||
Password.KeyPress += PasswordOnKeyPress;
|
||||
Email.KeyPress += EmailOnKeyPress;
|
||||
button.Clicked += ButtonOnClicked;
|
||||
ca.Clicked += CaOnClicked;
|
||||
this.WindowLoaded += OnWindowLoaded;
|
||||
}
|
||||
|
||||
private Task OnWindowLoaded(IRenderObject arg)
|
||||
{
|
||||
Email.Focus();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task CaOnClicked(IRenderObject arg)
|
||||
{
|
||||
ChangeToCa.Invoke();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task EmailOnKeyPress(KeyboardKeyEventArgs arg)
|
||||
@ -41,8 +53,9 @@ public class Login : UserControl
|
||||
|
||||
private Task PasswordOnKeyPress(KeyboardKeyEventArgs arg)
|
||||
{
|
||||
if (arg.Key != Keys.Enter && arg.Key != Keys.KeyPadEnter) return Task.CompletedTask;
|
||||
ButtonOnClicked(Password);
|
||||
if (arg.Key != Keys.Enter && arg.Key != Keys.KeyPadEnter && arg.Key != Keys.Tab) return Task.CompletedTask;
|
||||
if (arg.Key == Keys.Tab && arg.Shift) Email.Focus();
|
||||
if (arg.Key != Keys.Tab ) ButtonOnClicked(Password);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@ -50,7 +63,7 @@ public class Login : UserControl
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals.Luski = Server.Login(Email.Text, Password.Text, Branch.Dev).Result;
|
||||
Globals.Luski = Server.Login(Email.Text, Password.Text, Globals.Branch).Result;
|
||||
ChangeToApp.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -2,6 +2,7 @@ using System.Reflection;
|
||||
using GraphicsManager;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using Luski.net;
|
||||
using Luski.net.Enums;
|
||||
|
||||
namespace Luski;
|
||||
|
||||
@ -10,4 +11,33 @@ public class Globals
|
||||
public static Server Luski = null!;
|
||||
|
||||
public static Texture LuskiTexture = new(Tools.GetResourceBytes(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.Luski.png"));
|
||||
|
||||
public static string JT
|
||||
{
|
||||
get
|
||||
{
|
||||
string tmp = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "JacobTech");
|
||||
if (OperatingSystem.IsLinux())
|
||||
{
|
||||
tmp = Path.Combine(Environment.GetEnvironmentVariable("HOME")!, ".config/");
|
||||
tmp += "JacobTech";
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
public static Branch Branch
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!File.Exists(Path.Combine(Environment.CurrentDirectory, "branch.txt"))) File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "branch.txt"), ((int)Branch.Beta).ToString());
|
||||
return File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "branch.txt")) switch
|
||||
{
|
||||
"0" => Branch.Dev,
|
||||
"1" => Branch.Beta,
|
||||
"2" => Branch.Master,
|
||||
_ => Branch.Beta
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -8,8 +8,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GraphicsManager" Version="1.0.0-alpha9999999999999999996" />
|
||||
<PackageReference Include="Luski.net" Version="1.0.0-alpha91" />
|
||||
<PackageReference Include="GraphicsManager" Version="1.0.0-beta4" />
|
||||
<PackageReference Include="Luski.net" Version="1.0.0-beta1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user