How do you draw a bar

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 18
Reputation: Chris11246 is an unknown quantity at this point 
Solved Threads: 0
Chris11246 Chris11246 is offline Offline
Newbie Poster

How do you draw a bar

 
0
  #1
Oct 12th, 2008
Im new to C# and im trying to create a simple RPG game. Im trying to show stats like health and exp but I dont know how to draw a line to show them.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 58
Reputation: vckicks is an unknown quantity at this point 
Solved Threads: 9
vckicks vckicks is offline Offline
Junior Poster in Training

Re: How do you draw a bar

 
0
  #2
Oct 13th, 2008
Try FillRectangle from Graphics class
Visual C# Kicks - Free C# code resources and articles.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 7
Reputation: toraj58 is an unknown quantity at this point 
Solved Threads: 0
toraj58's Avatar
toraj58 toraj58 is offline Offline
Newbie Poster

Re: How do you draw a bar

 
0
  #3
Oct 13th, 2008
here i have written some code for you using GDI that can give you the clue for your problem:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9.  
  10. namespace GDI1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. Pen BluePen = new Pen(Color.Blue, 1);
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. Graphics dc = this.CreateGraphics();
  19. this.Show();
  20.  
  21. dc.DrawRectangle(BluePen, 0, 0, 50, 50);
  22. Pen RedPen = new Pen(Color.Red, 3);
  23. Pen pen2 = new Pen(Color.LightSalmon, 10);
  24.  
  25. Pen test = new Pen(Brushes.YellowGreen,8);
  26. dc.DrawEllipse(test, 50, 50, 200, 200);
  27. Point[] p = new Point[] { new Point(1, 2), new Point(70, 120), new Point(100, 200), new Point(280, 290), new Point(1, 2) };
  28. Point[] p2 = new Point[] { new Point(10, 10), new Point(310, 10), new Point(310, 310), new Point(10, 310), new Point(10, 10) };
  29.  
  30. dc.FillEllipse(Brushes.YellowGreen, 50, 50, 200, 200);
  31.  
  32. Brush b1 = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross, Color.Red);
  33. dc.FillEllipse(b1, 50, 50, 100, 100);
  34. dc.DrawLine(BluePen, 0, 0, 600, 600);
  35. dc.DrawLine(BluePen, 600, 0, 0, 600);
  36. dc.DrawLine(RedPen, 0, 300, 600, 300);
  37. dc.DrawLine(RedPen, 300, 0, 300, 600);
  38. dc.DrawLines(pen2, p2);
  39. }
  40.  
  41. }
  42. }

Touraj Ebrahimi [toraj_e] [at] [yahoo] [dot] [com]
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC