Go Back   Horror.com Forums - Talk about horror. > Horror.com Lobby > Horror.com General Forum
Register FAQ Community Calendar

Reply
 
Thread Tools
  #21  
Old 12-26-2006, 06:53 AM
Vodstok's Avatar
Vodstok Vodstok is offline
Fear scented candle
 
Join Date: Jan 2004
Location: The edge of forever
Posts: 13,650
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)
Reply With Quote
  #22  
Old 01-03-2007, 09:41 AM
Vodstok's Avatar
Vodstok Vodstok is offline
Fear scented candle
 
Join Date: Jan 2004
Location: The edge of forever
Posts: 13,650
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 05:15 PM.