rendered paste bodyusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DeffenderSigMaker
{
public partial class Form1 : Form
{
Font gothicum;
Bitmap bmp;
FontFamily family;
public Form1()
{
InitializeComponent();
}
public static FontFamily LoadFontFamily(string fileName, out PrivateFontCollection fontCollection)
{
fontCollection = new PrivateFontCollection();
fontCollection.AddFontFile(fileName);
return fontCollection.Families[0];
}
public void loadFonts()
{
try
{
PrivateFontCollection fonts;
family = LoadFontFamily("fonts/gothicum.ttf", out fonts);
gothicum = new Font(family, 20.0f);
}
catch
{
MessageBox.Show("Nemohu načíst fonty.", "Chyba", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
}
}
private void Form1_Load(object sender, EventArgs e)
{
loadFonts();
// label1.Font = gothicum;
}
public int race(string name)
{
switch (name)
{
case "Člověk":
return 1;
case "Ork":
return 2;
case "Trpaslík":
return 3;
case "Noční elf":
return 4;
case "Nemrtvý":
return 5;
case "Taur":
return 6;
case "Gnóm":
return 7;
case "Troll":
return 8;
case "Blood Elf":
return 10;
case "Draenei":
return 11;
default: return 0;
}
}
public int pvp(int race)
{
switch (race)
{
case 1:
return 0;
case 2:
return 1;
case 3:
return 0;
case 4:
return 0;
case 5:
return 1;
case 6:
return 1;
case 7:
return 0;
case 8:
return 1;
case 10:
return 1;
case 11:
return 0;
default: return 0;
}
}
public int clas(string name)
{
switch (name)
{
case "Válečník":
return 1;
case "Paladin":
return 2;
case "Lovec":
return 3;
case "Zloděj":
return 4;
case "Kněz":
return 5;
case "Rytíř smrti":
return 6;
case "Šaman":
return 7;
case "Mág":
return 8;
case "Černokněžník":
return 9;
case "Druid":
return 11;
default: return 0;
}
}
public int sex(string name)
{
switch (name)
{
case "Muž":
return 0;
case "Žena":
return 1;
default: return 0;
}
}
public int level(int value)
{
if (value < 60)
return 0;
else if (value < 70)
return 60;
else if (value < 80)
return 70;
else return 80;
}
private void generate_Click(object sender, EventArgs e)
{
try
{
Image img = Image.FromFile("images/background/0.png"); ;
bmp = new Bitmap(450, 100);
int rasa = race(comboBox1.Text);
int povolani = clas(comboBox2.Text);
int pohlavi = sex(comboBox3.Text);
int lvl = level(Convert.ToInt32(numericUpDown1.Value));
Image img2 = Image.FromFile("images/" + lvl.ToString() + "/" + pohlavi.ToString() + "-" + rasa.ToString() + "-" + povolani.ToString() + ".gif");
Image img3 = Image.FromFile("images/race/" + rasa.ToString() + "-" + pohlavi.ToString() + ".gif");
Image img4 = Image.FromFile("images/class/" + povolani.ToString() + ".gif");
Image img5 = Image.FromFile("images/pvp/" + pvp(rasa).ToString() + ".gif");
using (Graphics artist = Graphics.FromImage(bmp))
{
artist.DrawImage(img2, new Point(72, 17));
artist.DrawImage(img, new Point(0, 0));
artist.DrawImage(img3, new Point(41, 17));
artist.DrawImage(img4, new Point(41, 37));
artist.DrawImage(img5, new Point(41, 57));
if (Convert.ToInt32(numericUpDown1.Value) > 9)
artist.DrawString(numericUpDown1.Value.ToString(), new Font("Verdana", 6, FontStyle.Bold), Brushes.White, new PointF(124, 72));
else
artist.DrawString(numericUpDown1.Value.ToString(), new Font("Verdana", 6, FontStyle.Bold), Brushes.White, new PointF(127, 72));
artist.DrawString(textBox1.Text, new Font(family, 12, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(155, 10));
artist.DrawString(textBox1.Text, new Font(family, 12, FontStyle.Regular), new SolidBrush(Color.FromArgb(191, 156, 8)), new PointF(153, 8));
if (textBox2.Text != "")
{
artist.DrawString("<" + textBox2.Text + ">", new Font("Verdana", 7, FontStyle.Bold), Brushes.Black, new PointF(154, 27));
artist.DrawString("<" + textBox2.Text + ">", new Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(191, 156, 8)), new PointF(153, 26));
}
if (textBox5.Text != "")
{
artist.DrawString(textBox5.Text, new Font("Verdana", 7, FontStyle.Bold), Brushes.Black, new PointF(164, 51));
artist.DrawString(textBox5.Text, new Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(191, 156, 8)), new PointF(163, 50));
}
if (textBox6.Text != "")
{
artist.DrawString(textBox6.Text, new Font("Verdana", 7, FontStyle.Bold), Brushes.Black, new PointF(164, 61));
artist.DrawString(textBox6.Text, new Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(191, 156, 8)), new PointF(163, 60));
}
if (textBox4.Text != "")
{
artist.DrawString(textBox4.Text, new Font("Verdana", 7, FontStyle.Bold), Brushes.Black, new PointF(164, 71));
artist.DrawString(textBox4.Text, new Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(191, 156, 8)), new PointF(163, 70));
}
if (textBox3.Text != "")
{
artist.DrawString(textBox3.Text, new Font("Verdana", 7, FontStyle.Bold), Brushes.Black, new PointF(306, 51));
artist.DrawString(textBox3.Text, new Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(191, 156, 8)), new PointF(305, 50));
}
if (textBox8.Text != "")
{
artist.DrawString(textBox8.Text, new Font("Verdana", 7, FontStyle.Bold), Brushes.Black, new PointF(306, 61));
artist.DrawString(textBox8.Text, new Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(191, 156, 8)), new PointF(305, 60));
}
if (textBox7.Text != "")
{
artist.DrawString(textBox7.Text, new Font("Verdana", 7, FontStyle.Bold), Brushes.Black, new PointF(306, 71));
artist.DrawString(textBox7.Text, new Font("Verdana", 7, FontStyle.Bold), new SolidBrush(Color.FromArgb(191, 156, 8)), new PointF(305, 70));
}
}
area.Image = bmp;
}
catch
{
MessageBox.Show("Neplatná kombinace rasy a povolání.", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void save_Click(object sender, EventArgs e)
{
try
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png);
}
catch
{
MessageBox.Show("Ukládání selhalo, zkuste restartovat program.", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}