![]() |
||||||||||||||||||||
![]() |
![]() |
![]() |
||||||||||||||||||
![]() |
||||||||||||||||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||||||||||||
![]() |
#21
|
||||
|
||||
Now, i will address one last concept today: The "if/else" statement. Notice if you run this program, and click the Make image button with no text, you get a background, but no words. But we want words, right? so add this:
private void btnImage_Click(object sender, EventArgs e) { if (tbImage.Text.Length > 0) { Bitmap bm = new Bitmap(300, 300, PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(bm); Rectangle r = new Rectangle(0, 0, 300, 300); //g.FillRectangle(new SolidBrush(ColorRed), r); g.FillRectangle(new LinearGradientBrush(new Rectangle(0, 0, 300, 300), groupBox1.ForeColor, groupBox1.BackColor, 180), r); //SolidBrush sb = new SolidBrush(Color.Black); LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(0, 0, 300, 300), Randy, Randy, 90); //g.DrawString(tbImage.Text, new Font(FontFamily.GenericSansSerif,12), sb, 10, 10); g.DrawString(tbImage.Text, new Font(FontFamily.GenericSansSerif,12,FontStyle.Bold), lgb, 10, 10); g.SmoothingMode = SmoothingMode.AntiAlias; string path = @"c:\"; bm.Save(path + "mine.jpg", ImageFormat.Jpeg); } else { MessageBox.Show("You have no words!"); } } what the new lines say is this: if the length of the text inour textbox is greater than zero (IE, it's not empty), run as usual. BUT (that is where "else" comes in) if there is no text, show a MessageBox that says "You have no words !", and do nothing else. This prevents any boring, no worded images. You could just as easily delete : else { MessageBox.Show("You have no words!"); } with no ill effects. It wont say or do anything if there is no text, it will just sit there until you type something into the box. Post your best pics up here, i am curious to see what you guys do. :)
__________________
Some misguided people decided I was funny enough to pay. See if they're right: http://www.cracked.com/members/Vodstok/ (I tweet pretty hardcore, too) |
#22
|
||||
|
||||
Figured i would drag this guy up in case anyone is interested
made with the above program: ![]()
__________________
Some misguided people decided I was funny enough to pay. See if they're right: http://www.cracked.com/members/Vodstok/ (I tweet pretty hardcore, too) Last edited by Vodstok; 01-03-2007 at 09:43 AM. |
![]() |
|
|