78 lines
2.9 KiB
C#
78 lines
2.9 KiB
C#
using GraphicsManager.Enums;
|
|
using GraphicsManager.Interfaces;
|
|
using GraphicsManager.Objects;
|
|
using Luski.GUI.MainScreen.Interfaces;
|
|
using Luski.GUI.MainScreen.UI.LuskiControls;
|
|
using Luski.net.Structures.Public;
|
|
|
|
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
|
|
|
public class AddChannel : UserControl
|
|
{
|
|
private TextBox cn, cd;
|
|
private UserControl btn;
|
|
private SocketCategory Cat;
|
|
private IChannelAdder CA;
|
|
|
|
public AddChannel(IChannelAdder CA, SocketCategory cat)
|
|
{
|
|
this.CA = CA;
|
|
Cat = cat;
|
|
base.Size = Globals.ms.Size;
|
|
base.BackgroundColor = new(0, 0, 0, 130);
|
|
Anchor = ObjectAnchor.All;
|
|
FlowLayout fl = new()
|
|
{
|
|
SpaceBetweenObjects = (int)(5 * Globals.Settings.Scale),
|
|
Size = new((int)(350 * Globals.Settings.Scale), (int)(220 * Globals.Settings.Scale)),
|
|
BackgroundColor = new(32,32,32,255),
|
|
//Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
|
//TextureDisplay = TextureDisplay.Center
|
|
};
|
|
fl.Location = new((base.Size.X - fl.Size.X) / 2, (base.Size.Y - fl.Size.Y) / 2, 0);
|
|
fl.Controls.Add(new Label(Globals.DefaultFont) {Text = "Channel Name"});
|
|
fl.Controls.Add(cn =new TextBox()
|
|
{
|
|
WatermarkText = "Channel Name",
|
|
Size = new((int)(34 * Globals.Settings.Scale)),
|
|
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right,
|
|
TextLocation = TextLocation.PostiveTureCenterLeft
|
|
});
|
|
fl.Controls.Add(new Label(Globals.DefaultFont) {Text = "Channel Description"});
|
|
fl.Controls.Add(cd =new TextBox()
|
|
{
|
|
WatermarkText = "Channel Description",
|
|
Size = new((int)(34 * Globals.Settings.Scale)),
|
|
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right,
|
|
TextLocation = TextLocation.PostiveTureCenterLeft
|
|
});
|
|
fl.Controls.Add(new Label(Globals.DefaultFont) {Text = "\n "});
|
|
fl.Controls.Add(btn = new(Globals.ms.TextureManager.GetTextureResource("Textbox.png"))
|
|
{
|
|
Size = new((int)(40 * Globals.Settings.Scale)),
|
|
TextureDisplay = TextureDisplay.Center
|
|
});
|
|
Label sub = new(Globals.DefaultFont)
|
|
{
|
|
Text = "Submit",
|
|
IgnoreHover = true
|
|
};
|
|
sub.Location = new((btn.Size.X / 2) - (sub.Size.X / 2),
|
|
(btn.Size.Y / 2) - ((int)sub.Font.PixelHeight) + (sub.PostiveTrueHeight / 2)
|
|
, 0);
|
|
btn.Clicked += BtnOnClicked;
|
|
sub.ForceDistanceUpdate(btn);
|
|
btn.Controls.Add(sub);
|
|
fl.ForceDistanceUpdate(this);
|
|
Controls.Add(fl);
|
|
Anchor = ObjectAnchor.All;
|
|
}
|
|
|
|
private async Task BtnOnClicked(IRenderObject arg)
|
|
{
|
|
SocketChannel chan = await Cat.Server.MakeChannel(Cat, cn.Text, cd.Text);
|
|
await CA.AddChannel(chan);
|
|
Globals.ms.Controls.Remove(this);
|
|
Globals.ms.DrawFrame();
|
|
}
|
|
} |