I'm 13 and pretty new to C#. I'm writing a code for Latin flash cards for my school. The way I'm doing it now is going to take forever and I was wondering if any of you guys know a way shorten it.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class ltnmain : Form
{
Font CardFont = new System.Drawing.Font("Arial", 20);
Pen CardBorder = new Pen(System.Drawing.Color.Black, 2);
Pen CardCurve = new Pen(System.Drawing.Color.Black, 2);
public ltnmain()
{
InitializeComponent();
}
private void ltnmain_Load(object sender, EventArgs e)
{
}
public void DrawNewCard(string txt1, string txt2, int l1, int l2, int l11, int l22)
{
Point[] rtt = new Point[6];
rtt[0] = new Point(40, 55);
rtt[1] = new Point(41, 52);
rtt[2] = new Point(43, 49);
rtt[3] = new Point(44, 48);
rtt[4] = new Point(47, 46);
rtt[5] = new Point(50, 45);
Point[] ltt = new Point[6];
ltt[0] = new Point(210, 55);
ltt[1] = new Point(209, 52);
ltt[2] = new Point(207, 49);
ltt[3] = new Point(206, 48);
ltt[4] = new Point(203, 46);
ltt[5] = new Point(200, 45);
System.Drawing.Graphics CardTxta = null;
CardTxta = CreateGraphics();
CardTxta.DrawString(txt1, CardFont, System.Drawing.Brushes.Black, l1, l2);
CardTxta.Dispose();
System.Drawing.Graphics CardTxtb = null;
CardTxtb = CreateGraphics();
CardTxtb.DrawString(txt2, CardFont, System.Drawing.Brushes.Black, l11, l22);
Rectangle Cardsides = new Rectangle(40, 50, 40, 250);
System.Drawing.Graphics CardsidesRight = null;
CardsidesRight = CreateGraphics();
CardsidesRight.DrawLine(CardBorder, 40, 55, 40, 250);
System.Drawing.Graphics CardsidesTop = null;
CardsidesTop = CreateGraphics();
CardsidesTop.DrawLine(CardBorder, 50, 45, 200, 45);
System.Drawing.Graphics CardsidesLeft = null;
CardsidesLeft = CreateGraphics();
CardsidesLeft.DrawLine(CardBorder, 210, 55, 210, 250);
System.Drawing.Graphics CardarchToptoRight = null;
CardarchToptoRight = CreateGraphics();
CardarchToptoRight.DrawCurve(CardCurve, rtt);
System.Drawing.Graphics CardarchToptoLeft = null;
CardarchToptoLeft = CreateGraphics();
CardarchToptoLeft.DrawCurve(CardCurve, ltt);
}
private void latinToEnglishToolStripMenuItem_Click(object sender, EventArgs e)
{
ChooseWordW1();
}
static int ranw1b;
private void ChooseWordW1()
{
string txt1;
string txt2;
Random ranw1a = new Random();
ranw1b = ranw1a.Next(1, 47);
if (ranw1b == 1)
{
txt1 = "aestas, ";
txt2 = "aestatis (f.)";
DrawNewCard(txt1, txt2, 75, 90, 55, 160);
btnCheck.Click +=new EventHandler(btnCheckClick);
}
}
private void btnCheckClick(object obj, EventArgs ea)
{
if (ranw1b == 1)
{
MessageBox.Show("The awnser was 'Summer'!", "Awnser", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
There are going to be a couple more weeks and hundreds more words. It would be very helpful if anybody could show me a simpler way to accomplish this same task.
Thanks