using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace EE_Image_Editor
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Bitmap naem = new Bitmap(16,16);
public Bitmap MyMap = new Bitmap(256, 256);
public void DrawBlank()
{
Bitmap Img = new Bitmap(256, 256);
Bitmap Img2 = new Bitmap("pic\\blank.png");
for (int y = 0; y <= 16; y++)
{
for (int x = 0; x <= 16; x++)
{
Overlap(Img, Img2, x * 16, y * 16);
}
}
pictureBox1.Image = Img;
MyMap = Img;
}
public void DrawSavedImg()
{
pictureBox1.Image = MyMap;
}
public Bitmap Overlap(Bitmap current, Bitmap overlap, int x, int y)
{
using (Graphics g = Graphics.FromImage(current))
{
g.DrawImageUnscaled(overlap, x, y);
}
return current;
}
public void DrawSmileAt(int x, int y, Bitmap face)
{
Bitmap Img = new Bitmap(pictureBox1.Image);
if (gmode.Checked)
{
Bitmap Img3 = new Bitmap(pictureBox1.Image);
if (radioButton1.Checked)
Img3 = new Bitmap("pic\\aura\\normal.png");
if (radioButton2.Checked)
Img3 = new Bitmap("pic\\aura\\normal.png");
if (radioButton3.Checked)
Img3 = new Bitmap("pic\\aura\\moderator.png");
if (radioButton4.Checked)
Img3 = new Bitmap("pic\\aura\\admin.png");
if (radioButton3.Checked)
{
Overlap(Img, Img3, x - 32, y - 34);
}
else
{
if (radioButton2.Checked)
Overlap(Img, Img3, x - 23, y - 23);
else
if (radioButton4.Checked)
Overlap(Img, Img3, x - 23, y - 23);
else
Overlap(Img, Img3, x - 22, y - 23);
}
}
Overlap(Img, face, x-4, y-4);
pictureBox1.Image = Img;
if (heart.Checked || fly.Checked || curseeffect.Checked)
{
string eff = "";
if (curseeffect.Checked)
{
eff = "curse";
Bitmap Effect = new Bitmap("pic\\effect\\" + eff + ".png");
Overlap(Img, Effect, x, y - 16);
}
if (heart.Checked)
{
eff = "health";
Bitmap Effect = new Bitmap("pic\\effect\\" + eff + ".png");
Overlap(Img, Effect, x, y - 16);
}
}
}
private Bitmap NameLineHorizontal(int x, int y, Bitmap ret, Color col)
{
ret.SetPixel(0 + x, y, col);
ret.SetPixel(1 + x, y, col);
ret.SetPixel(2 + x, y, col);
ret.SetPixel(3 + x, y, col);
ret.SetPixel(4 + x, y, col);
return ret;
}
private Bitmap NameLineVertical(int x, Bitmap ret, Color col)
{
ret.SetPixel(x, 0, col);
ret.SetPixel(x, 1, col);
ret.SetPixel(x, 2, col);
ret.SetPixel(x, 3, col);
ret.SetPixel(x, 4, col);
return ret;
}
private Image DrawText(String text, Font font, Color textColor, Color backColor)
{
//first, create a dummy bitmap just to get a graphics object
Image img = new Bitmap(1, 1);
Graphics drawing = Graphics.FromImage(img);
//measure the string to see how big the image needs to be
SizeF textSize = drawing.MeasureString(text, font);
//free up the dummy image and old graphics object
img.Dispose();
drawing.Dispose();
//create a new image of the right size
img = new Bitmap((int)textSize.Width, (int)textSize.Height);
drawing = Graphics.FromImage(img);
//paint the background
drawing.Clear(backColor);
//create a brush for the text
Brush textBrush = new SolidBrush(textColor);
drawing.DrawString(text, font, textBrush, 0, 0);
drawing.Save();
textBrush.Dispose();
drawing.Dispose();
return img;
}
private void SetImageName(string name , Color col)
{
int algorithm = (name.Length * 5) + name.Length;
foreach (char i in name)
{
if (i == 'i')
{
algorithm -= 3;
}
}
naem = new Bitmap(algorithm, 5);
PrivateFontCollection pfc = new PrivateFontCollection();
pfc.AddFontFile(@"pic\text\ee.ttf");
Font eefont = new Font(pfc.Families[0], 10, FontStyle.Regular);
Bitmap Name = new Bitmap(DrawText(name, eefont, col, Color.Transparent));
/*
foreach (char i in name)
{
int m = -5;
bool f = false;
foreach(char n in "abcdefghijklmnopqrstuvwxyz")
{
if (!f)
{
if (n == i)
f = true;
m += 5;
if (n == 'i')
m -= 4;
}
}
/*try
{
//vwxyz
switch (Convert.ToChar(i.ToString().ToLower()))
{
case 'a':
NameLineHorizontal(c, 0, naem, col);
naem.SetPixel(0 + c, 1, col);
naem.SetPixel(4 + c, 1, col);
NameLineHorizontal(c, 2, naem, col);
naem.SetPixel(0 + c, 3, col);
naem.SetPixel(0 + c, 4, col);
naem.SetPixel(4 + c, 3, col);
naem.SetPixel(4 + c, 4, col);
break;
case 'b':
NameLineHorizontal(c, 0, naem, col);
naem.SetPixel(0 + c, 1, col);
naem.SetPixel(4 + c, 1, col);
naem.SetPixel(0 + c, 2, col);
naem.SetPixel(1 + c, 2, col);
naem.SetPixel(2 + c, 2, col);
naem.SetPixel(3 + c, 2, col);
naem.SetPixel(0 + c, 3, col);
naem.SetPixel(4 + c, 3, col);
NameLineHorizontal(c, 4, naem, col);
break;
case 'c':
NameLineHorizontal(c, 0, naem, col);
NameLineVertical(c, naem, col);
NameLineHorizontal(c, 4, naem, col);
break;
case 'd':
NameLineHorizontal(c, 0, naem, col);
NameLineHorizontal(c, 4, naem, col);
NameLineVertical(c, naem, col);
NameLineVertical(c + 4, naem, col);
naem.SetPixel(c + 4, 0, Color.Transparent);
naem.SetPixel(c + 4, 4, Color.Transparent);
break;
case 'e':
NameLineHorizontal(c, 0, naem, col);
NameLineHorizontal(c, 2, naem, col);
NameLineHorizontal(c, 4, naem, col);
naem.SetPixel(c + 0, 1, col);
naem.SetPixel(c + 0, 3, col);
break;
case 'f':
NameLineHorizontal(c, 0, naem, col);
NameLineHorizontal(c, 2, naem, col);
NameLineVertical(c, naem, col);
break;
case 'g':
NameLineHorizontal(c, 0, naem, col);
NameLineHorizontal(c, 4, naem, col);
NameLineVertical(c, naem, col);
NameLineVertical(c + 4, naem, col);
naem.SetPixel(c + 4, 1, Color.Transparent);
naem.SetPixel(c + 2, 2, col);
naem.SetPixel(c + 3, 2, col);
break;
case 'h':
NameLineVertical(c, naem, col);
NameLineVertical(c + 4, naem, col);
NameLineHorizontal(c, 2, naem, col);
break;
case 'i':
NameLineVertical(c, naem, col);
break;
case 'j':
NameLineHorizontal(c, 4, naem, col);
NameLineVertical(c + 4, naem, col);
break;
case 'k':
NameLineVertical(c, naem, col);
naem.SetPixel(c + 1, 2, col);
naem.SetPixel(c + 2, 2, col);
naem.SetPixel(c + 3, 1, col);
naem.SetPixel(c + 3, 3, col);
naem.SetPixel(c + 4, 0, col);
naem.SetPixel(c + 4, 4, col);
break;
case 'l':
NameLineHorizontal(c, 4, naem, col);
NameLineVertical(c, naem, col);
break;
case 'm':
NameLineHorizontal(c, 0, naem, col);
NameLineVertical(c, naem, col);
NameLineVertical(c + 4, naem, col);
NameLineVertical(c + 2, naem, col);
break;
case 'n':
NameLineHorizontal(c, 0, naem, col);
NameLineVertical(c , naem, col);
NameLineVertical(c + 4, naem, col);
break;
case 'o':
NameLineHorizontal(c, 0, naem, col);
NameLineHorizontal(c, 4, naem, col);
NameLineVertical(c, naem, col);
NameLineVertical(c + 4, naem, col);
break;
case 'p':
NameLineHorizontal(c, 0, naem, col);
NameLineHorizontal(c, 2, naem, col);
NameLineVertical(c, naem, col);
naem.SetPixel(4 + c, 1, col);
break;
case 'q':
NameLineHorizontal(c, 0, naem, col);
NameLineHorizontal(c, 4, naem, col);
NameLineVertical(c, naem, col);
NameLineVertical(c + 4, naem, col);
break;
case 'r':
NameLineHorizontal(c, 0, naem, col);
NameLineVertical(c, naem, col);
NameLineHorizontal(c, 2, naem, col);
NameLineVertical(c + 4, naem, col);
naem.SetPixel(c + 4, 2, Color.Transparent);
break;
case 's':
NameLineHorizontal(c, 0, naem, col);
NameLineHorizontal(c, 2, naem, col);
NameLineHorizontal(c, 4, naem, col);
naem.SetPixel(c + 0, 1, col);
naem.SetPixel(c + 4, 3, col);
break;
case 't':
NameLineVertical(c + 2, naem, col);
NameLineHorizontal(c, 0, naem, col);
break;
case 'u':
NameLineHorizontal(c, 4, naem, col);
NameLineVertical(c,naem, col);
NameLineVertical(c + 4,naem, col);
break;
case 'v':
naem.SetPixel(0 + c, 0, col);
naem.SetPixel(4 + c, 0, col);
naem.SetPixel(0 + c, 1, col);
naem.SetPixel(4 + c, 1, col);
naem.SetPixel(0 + c, 2, col);
naem.SetPixel(4 + c, 2, col);
naem.SetPixel(1 + c, 3, col);
naem.SetPixel(3 + c, 3, col);
naem.SetPixel(2 + c, 4, col);
break;
case 'w':
NameLineHorizontal(c, 4, naem, col);
NameLineVertical(c, naem, col);
NameLineVertical(c + 4, naem, col);
NameLineVertical(c + 2, naem, col);
break;
case 'x':
naem.SetPixel(0 + c, 0, col);
naem.SetPixel(1 + c, 1, col);
naem.SetPixel(2 + c, 2, col);
naem.SetPixel(3 + c, 3, col);
naem.SetPixel(4 + c, 4, col);
naem.SetPixel(4 + c, 0, col);
naem.SetPixel(3 + c, 1, col);
naem.SetPixel(1 + c, 3, col);
naem.SetPixel(0 + c, 4, col);
break;
case 'y':
naem.SetPixel(0 + c, 0, col);
naem.SetPixel(4 + c, 0, col);
naem.SetPixel(1 + c, 1, col);
naem.SetPixel(3 + c, 1, col);
naem.SetPixel(2 + c, 2, col);
naem.SetPixel(2 + c, 3, col);
naem.SetPixel(2 + c, 4, col);
break;
case 'z':
NameLineHorizontal(0 + c, 0, naem, col);
NameLineHorizontal(0 + c, 4, naem, col);
naem.SetPixel(3 + c, 1, col);
naem.SetPixel(2 + c, 2, col);
naem.SetPixel(1 + c, 3, col);
break;
case '0':
break;
case '1':
break;
case '2':
break;
case '3':
break;
case '4':
break;
case '5':
break;
case '6':
break;
case '7':
break;
case '8':
break;
case '9':
break;
}
}
catch { }/*
if (Convert.ToChar(i.ToString().ToLower()) == 'i')
{
c -= 4;
}
c += 6;
}*/
naem = Name;
}
private void button1_Click(object sender, EventArgs e)
{
}
private ImageList ilist;
private Bitmap smileys;
public void drawname(int xpo, int ypo)
{
int cc = 0;
foreach (char i in name.Text.ToLower())
{
if (i == 'i')
{
cc += 3;
}
}
int myx = 0;
int L = name.Text.Length;
myx = ((((((L / 2) - 1) * 5) - cc) + ((L / 2)) - (L / 2)) * -1) + xpo - (((L - 1) / 2) - 1);
pictureBox1.Image = Overlap(new Bitmap(pictureBox1.Image), naem, myx, ypo + 18);
}
public int x = 0;
public int y = 0;
public string facer = "";
public Bitmap[] Smileys = new Bitmap[0];
private void button5_Click(object sender, EventArgs e)
{
CreatedPlayer = true;
CreatedBlock = false;
DrawSavedImg();
DrawSmileAt(x, y, SmileyInUse);
x = 0;
y = 0;
Color col = Color.Navy;
if (radioButton1.Checked)
col = Color.DimGray;
if (radioButton2.Checked)
col = Color.White;
if (radioButton3.Checked)
col = Color.DarkMagenta;
if (radioButton4.Checked)
col = Color.Orange;
SetImageName(name.Text, col);
drawname(x, y);
}
private void InitializeSmileys()
{
smileys = new Bitmap("pic\\smiley\\smilies.png");
if (Smileys.Length == 0)
{
List<Bitmap> lstSmileys = new List<Bitmap>();
using (Bitmap bmpSmileys = new Bitmap("pic\\smiley\\smilies.png")) // Replace with smiley image location.
{
for (int xc = 0; xc < bmpSmileys.Width; xc += 26)
{
Bitmap bmpSmiley = bmpSmileys.Clone(new Rectangle(xc, 0, 26, 26), PixelFormat.DontCare);
lstSmileys.Add(bmpSmiley);
}
}
Smileys = lstSmileys.ToArray();
}
ilist = new ImageList();
ilist.ColorDepth = ColorDepth.Depth32Bit;
ilist.ImageSize = new Size(26, 26);
listView1.View = View.Tile;
listView1.TileSize = new Size(32, 26);
for (int i = 0; i < smileys.Width / 26; i++)
{
Bitmap smil0 = new Bitmap(26, 26);
Bitmap smil1 = smileys.Clone(new Rectangle(i * 26, 0, 26, 26), smileys.PixelFormat);
Graphics tmp = Graphics.FromImage(smil0);
tmp.DrawImage(smil1, 0, 0);
ilist.Images.Add(i.ToString(), smil0);
}
listView1.LargeImageList = ilist;
for (int i = 0; i < smileys.Width / 26; i++)
{
ListViewItem lv = new ListViewItem();
lv.Name = i.ToString();
lv.ImageKey = i.ToString();
listView1.Items.Add(lv);
}
this.ActiveControl = listView1;
listView1.Items[0].Selected = true;
listView1.Items[0].EnsureVisible();
}
private void button6_Click(object sender, EventArgs e)
{
MyMap = new Bitmap(pictureBox1.Image);
}
private void button7_Click(object sender, EventArgs e)
{
SaveFileDialog dialog = new SaveFileDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
Bitmap Img = new Bitmap(pictureBox1.Image);
int width = Convert.ToInt32(Img.Width);
int height = Convert.ToInt32(Img.Height);
Bitmap bmp = new Bitmap(width, height);
pictureBox1.DrawToBitmap(bmp,new Rectangle(0,0,bmp.Width,bmp.Height));
string x = dialog.FileName;
x += ".png";
bmp.Save(x, ImageFormat.Png);
}
}
public void DiagnosticExit(object sender, FormClosingEventArgs e)
{
this.Close();
Application.Exit();
}
private void Form1_Load(object sender, EventArgs e)
{
listView1.MultiSelect = false;
listView1.Name = "listView1";
listView1.TabIndex = 0;
listView1.UseCompatibleStateImageBehavior = false;
listView1.View = System.Windows.Forms.View.Tile;
listView1.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(listView1_ItemSelectionChanged);
bool ErrorLoading = false;
if (!System.IO.Directory.Exists("pic"))
{
ErrorLoading = true;
MessageBox.Show("The folder 'pic' cannot be found.", "Error");
}
if (!System.IO.File.Exists("pic\\block\\blockappear.png"))
{
ErrorLoading = true;
MessageBox.Show("The image 'pic\\block\\blockappear.png' cannot be found.", "Error");
}
if (!System.IO.File.Exists("pic\\blank.png"))
{
ErrorLoading = true;
MessageBox.Show("The image 'pic\\blank.png' cannot be found.", "Error");
}
//Directories
string[] Directories = { "smiley", "aura", "block", "effect" };
foreach (string i in Directories)
{
if (!System.IO.Directory.Exists("pic\\" + i))
{
ErrorLoading = true;
MessageBox.Show("The folder 'pic\\" + i + "' cannot be found.", "Error");
}
}
//Files
string[] Auras = { "admin", "moderator", "normal" };
string[] Effects = { "health", "curse" };
if (!System.IO.File.Exists("pic\\smiley\\smilies.png"))
{
ErrorLoading = true;
MessageBox.Show("The image 'pic\\smiley\\smilies.png' cannot be found.", "Error");
}
foreach (string i in Auras)
{
if (!System.IO.File.Exists("pic\\aura\\" + i + ".png"))
{
ErrorLoading = true;
MessageBox.Show("The image 'pic\\aura\\" + i + ".png' cannot be found.", "Error");
}
}
foreach (string i in Effects)
{
if (!System.IO.File.Exists("pic\\effect\\" + i + ".png"))
{
ErrorLoading = true;
MessageBox.Show("The image 'pic\\effect\\" + i + ".png' cannot be found.", "Error");
}
}
this.Hide();
if (ErrorLoading)
{
this.Close();
Application.Exit();
}
else
{
InitializeSmileys();
DrawBlank();
this.Show();
}
}
private void HideAppy()
{
this.Hide();
}
delegate void HideApp();
private void diagnosticOpen_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i <= 100; i++)
{
if (this.InvokeRequired)
{
this.Invoke(new HideApp(HideAppy));
}
else
{
HideAppy();
}
System.Threading.Thread.Sleep(i * 100);
}
}
public void DrawBlockAt(int xpos, int ypos)
{
Bitmap Draw = new Bitmap(pictureBox1.Image);
Bitmap Block = new Bitmap("pic\\block\\.png");
Overlap(Draw, Block, xpos, ypos);
pictureBox1.Image = Draw;
}
public Bitmap SmileyInUse = new Bitmap(@"pic\\smiley\\smilies.png");
private void wotm8_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
SmileyInUse = Smileys[e.ItemIndex];
}
public static bool CreatedPlayer = false;
public static bool CreatedBlock = false;
private void MousePosChange(object sender, MouseEventArgs e)
{
if (CreatedPlayer)
{
int x = e.X;
int y = e.Y;
x = Convert.ToInt32(Math.Floor(Convert.ToDecimal(x) / 16)) * 16;
y = Convert.ToInt32(Math.Floor(Convert.ToDecimal(y) / 16)) * 16;
y -= 1;
x -= 1;
DrawSavedImg();
DrawSmileAt(x, y, SmileyInUse);
drawname(x, y);
} else if(CreatedBlock)
{
int x = e.X;
int y = e.Y;
x = Convert.ToInt32(Math.Floor(Convert.ToDecimal(x) / 16)) * 16;
y = Convert.ToInt32(Math.Floor(Convert.ToDecimal(y) / 16)) * 16;
DrawSavedImg();
pictureBox1.Image = Overlap(new Bitmap(pictureBox1.Image), new Bitmap("pic\\block\\blockappear.png"), x, y);
if(mDown)
Overlap(MyMap, curBlock, x, y);
}
}
private void SaveImg(object sender, MouseEventArgs e)
{
if(CreatedPlayer)
{
MyMap = new Bitmap(pictureBox1.Image);
DrawSavedImg();
CreatedPlayer = false;
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void listView2_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void listView2_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
}
public static Bitmap curBlock;
private void button1_Click_1(object sender, EventArgs e)
{
int b = Convert.ToInt32(bId.Value);
CreatedPlayer = false;
CreatedBlock = true;
if (CreatedBlock)
try
{
curBlock = new Bitmap("pic\\block\\b" + b.ToString() + ".png");
}
catch
{
MessageBox.Show("Block doesn't exist");
}
}
private void button2_Click(object sender, EventArgs e)
{
CreatedBlock = false;
}
public static bool mDown = false;
public static bool mUp = true;
private void mDowen(object sender, MouseEventArgs e)
{
mDown = true;
mUp = false;
if (CreatedBlock)
{
int x = e.X;
int y = e.Y;
x = Convert.ToInt32(Math.Floor(Convert.ToDecimal(x) / 16)) * 16;
y = Convert.ToInt32(Math.Floor(Convert.ToDecimal(y) / 16)) * 16;
DrawSavedImg();
pictureBox1.Image = Overlap(new Bitmap(pictureBox1.Image), new Bitmap("pic\\block\\blockappear.png"), x, y);
if (mDown)
Overlap(MyMap, curBlock, x, y);
}
}
private void mupwen(object sender, MouseEventArgs e)
{
mDown = false;
mUp = true;
}
}
}