first commit

This commit is contained in:
mikx
2025-06-28 15:38:37 -04:00
commit 9e08b88d81
22 changed files with 2910 additions and 0 deletions

112
PoEco.Net/Utilities/Draw.cs Normal file
View File

@@ -0,0 +1,112 @@
using Org.BouncyCastle.Asn1.Cms;
using PoEco.Net.JSON;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
using Image = System.Drawing.Image;
namespace PoEco.Net.Utilities
{
internal class Draw
{
public static void GenQuad(int w, int h, int x, int y, string imgUrl, double min, double max, string type, string user, string discriminator)
{
int fontsize = 16;
int calculatedW = w * 47;
int calculatedH = h * 47;
int calculatedX = x * 47;
int calculatedY = y * 47;
Color cborder = Color.FromArgb(61,235,52);
// Adjust font size by item size
// w == item width
// h == item height
switch (w)
{
case 1:
switch (h)
{
case 1:
fontsize = 12;
break;
case 3:
fontsize = 12;
break;
}
break;
}
ColorConverter cc = new ColorConverter();
Color fontc = (Color)cc.ConvertFromString("#3d3d3b");
switch (type)
{
case "c":
if (min < 10) { fontc = (Color)cc.ConvertFromString("#fc0303"); }
if (min >= 10 && min < 20) { fontc = (Color)cc.ConvertFromString("#fc5e03"); }
if (min >= 20 && min < 50) { fontc = (Color)cc.ConvertFromString("#fcce03"); }
if (min >= 50) { fontc = (Color)cc.ConvertFromString("#29f705"); }
break;
case "d":
fontc = (Color)cc.ConvertFromString("#29f705");
break;
}
var fontFamily = new FontFamily("Verdana");
var vfont = new Font(fontFamily, fontsize, FontStyle.Regular, GraphicsUnit.Pixel);
Image imageFile = Image.FromFile($@"data/tabmap/{user}#{discriminator}.png");
Graphics newGraphics = Graphics.FromImage(imageFile);
Pen border = new Pen(cborder, 2);
Pen backPen = new Pen(cborder, 0);
SolidBrush back = new SolidBrush((Color)cc.ConvertFromString("#3d3d3b"));
SolidBrush font = new SolidBrush(fontc);
Rectangle rect = new Rectangle(calculatedX, calculatedY, calculatedW, calculatedH);
Rectangle backgroundRect = new Rectangle(calculatedX, calculatedY, calculatedW-5, calculatedH-5);
newGraphics.DrawRectangle(border, rect);
newGraphics.FillRectangle(back, rect);
newGraphics.DrawRectangle(border, rect);
WebClient wc = new WebClient();
byte[] bytes = wc.DownloadData(imgUrl);
MemoryStream ms = new MemoryStream(bytes);
Image itemIcon = Image.FromStream(ms);
Bitmap bmp = new Bitmap(itemIcon.Width, itemIcon.Height);
ColorMatrix matrix = new ColorMatrix();
matrix.Matrix33 = 0.3f;
ImageAttributes attributes = new ImageAttributes();
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
newGraphics.DrawImage(itemIcon, new Rectangle(x * 47, y * 47, bmp.Width, bmp.Height), 0 , 0, itemIcon.Width, itemIcon.Height, GraphicsUnit.Pixel, attributes);
StringFormat stringFormatMin = new StringFormat();
stringFormatMin.Alignment = StringAlignment.Center;
stringFormatMin.LineAlignment = StringAlignment.Near;
newGraphics.DrawString(min.ToString() + type, vfont, font, rect, stringFormatMin);
StringFormat stringFormatMax = new StringFormat();
stringFormatMax.Alignment = StringAlignment.Center;
stringFormatMax.LineAlignment = StringAlignment.Far;
newGraphics.DrawString(max.ToString() + type, vfont, font, rect, stringFormatMax);
imageFile.Save($@"data/tabmap/{user}#{discriminator}.png", ImageFormat.Bmp);
if (Settings.GetWeb()) { File.Copy($@"data/tabmap/{user}#{discriminator}.png", $@"{Settings.GetWebPath()}/{user}#{discriminator}.png", true); }
}
}
}

View File

@@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PoEco.Net.Utilities
{
internal class Message
{
public static void CMW(string msg, bool time, int color)
{
DateTime now;
string str1;
int num;
if (DateTime.Now.Second < 10)
{
now = DateTime.Now;
str1 = string.Format("0{0}", (object)now.Second);
}
else
{
num = DateTime.Now.Second;
str1 = num.ToString();
}
now = DateTime.Now;
string str2;
if (now.Minute < 10)
{
now = DateTime.Now;
str2 = string.Format("0{0}", (object)now.Minute);
}
else
{
now = DateTime.Now;
num = now.Minute;
str2 = num.ToString();
}
now = DateTime.Now;
string str3;
if (now.Hour < 10)
{
now = DateTime.Now;
str3 = string.Format("0{0}", (object)now.Hour);
}
else
{
now = DateTime.Now;
num = now.Hour;
str3 = num.ToString();
}
string str4 = string.Format("{0}:{1}:{2}", (object)str3, (object)str2, (object)str1);
File.AppendAllText("mxfiltergen.logs", string.Format("[{0}] {1}", (object)str4, (object)msg) + Environment.NewLine);
ConsoleColor consoleColor = ConsoleColor.White;
switch (color)
{
case 1:
consoleColor = ConsoleColor.Cyan;
break;
case 2:
consoleColor = ConsoleColor.Green;
break;
case 3:
consoleColor = ConsoleColor.Red;
break;
}
if (time)
{
Console.ForegroundColor = consoleColor;
Console.WriteLine(string.Format("[{0}] {1}", (object)str4, (object)msg));
}
else
{
Console.ForegroundColor = consoleColor;
Console.WriteLine(string.Format(""));
}
Console.ForegroundColor = ConsoleColor.White;
}
public static void drawProgress(int progress, int total)
{
DateTime now;
string str1;
int num;
if (DateTime.Now.Second < 10)
{
now = DateTime.Now;
str1 = string.Format("0{0}", (object)now.Second);
}
else
{
num = DateTime.Now.Second;
str1 = num.ToString();
}
now = DateTime.Now;
string str2;
if (now.Minute < 10)
{
now = DateTime.Now;
str2 = string.Format("0{0}", (object)now.Minute);
}
else
{
now = DateTime.Now;
num = now.Minute;
str2 = num.ToString();
}
now = DateTime.Now;
string str3;
if (now.Hour < 10)
{
now = DateTime.Now;
str3 = string.Format("0{0}", (object)now.Hour);
}
else
{
now = DateTime.Now;
num = now.Hour;
str3 = num.ToString();
}
string str4 = string.Format("[{0}] [", (object)string.Format("{0}:{1}:{2}", (object)str3, (object)str2, (object)str1));
Console.ForegroundColor = ConsoleColor.Cyan;
if (progress == 1)
{
Console.Write(str4);
Console.CursorLeft = total + str4.Length;
Console.Write("]");
}
Console.CursorLeft = progress + str4.Length - 1;
Console.Write("#");
Console.CursorLeft = str4.Length + total + 2;
Console.Write(string.Format("{0}/{1}", (object)progress, (object)total));
if (progress != total)
return;
Console.WriteLine();
}
public static void Splash(string progname, string dev)
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("");
Console.WriteLine($"#### {progname}");
Console.WriteLine(string.Format("#### VERSION: {0}", (object)Program.version));
Console.WriteLine($"#### DEV: {dev}");
Console.WriteLine("#### POWERED BY: poe.ninja / poeprices.info");
Console.WriteLine("");
Console.ForegroundColor = ConsoleColor.White;
}
}
}