dev #17

Merged
JacobTech merged 29 commits from dev into main 2024-04-11 15:50:14 -04:00
Showing only changes of commit d617e84f4c - Show all commits

View File

@ -0,0 +1,43 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using File = Luski.net.JsonTypes.File;
namespace Luski.GUI.MainScreen.UI;
public class ContentEmbed : UserControl
{
readonly File file;
long channel;
private Label fileNameLabel, fileSizeLabel;
private Rectangle downloadButton;
public ContentEmbed(File file, long channel)
{
this.channel = channel;
this.file = file;
string fst = "";
ulong size = file.Size;
if (size < 1000)
{
fst = size + " bytes";
} else if (size < 1000000)
{
fst= Math.Round((double)size / (double)1000, 2) + " KB";
} else if (size < 1000000000)
{
fst = Math.Round((double)size / (double)1000000, 2) + " MB";
} else if (size < 1000000000000)
{
fst = Math.Round((double)size / (double)1000000000, 2) + " GB";
}
Controls.Add(fileSizeLabel = new Label() {Text = fst, Location = new(64, 39)});
Controls.Add(fileNameLabel = new Label() {Text = file.Name, Location = new(64, 6)});
Controls.Add(new Rectangle(new Texture(Tools.GetResourceBytes(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.Download.png"))) { Location = new(8, 6), Size = new(50, 50)});
int temp = fileNameLabel.Size.X + fileNameLabel.Location.X;
int temp2 = fileSizeLabel.Size.X + fileSizeLabel.Location.X; ;
if (temp >= temp2) Size = new(temp + 4, Size.Y);
else Size = new(temp2 + 4, Size.Y);
}
}