ÀÌ ¹®¼¿¡¼´Â
ProgressBar ÄÁÆ®·ÑÀÇ ½ºÅ©·Ñ ºÎµå·¯¿î ¸¸µé ¼ö ÀÖ´Â °£´ÜÇÑ »ç¿ëÀÚ ÁöÁ¤
UserControl ¸¸µå´Â ¹æ¹ýÀ» º¸¿© ÁÝ´Ï´Ù.
ÀÌÀü ¹öÀüÀÇ Microsoft Windows °ø¿ë ÄÁÆ®·ÑÀ» ActiveX ÄÁÆ®·Ñ°ú ÇÔ²² Á¦°øµÈ ¹öÀü °°Àº
ProgressBar ÄÁÆ®·ÑÀÇ µÎ °¡Áö ºä ÁøÇà »óȲÀ» º¼ ¼ö ÀÖ½À´Ï´Ù. ÀÌ·¯ÇÑ º¸±â¸¦ Á¦¾îÇÏ·Á¸é Ç¥ÁØ ¹× ¿øÈ°ÇÑ ¼³Á¤ÀÌ Æ÷ÇÔµÈ
½ºÅ©·Ñ ¼Ó¼ºÀ» »ç¿ëÇÕ´Ï´Ù. ºÎµå·¯¿î ȸé À̵¿ µé¾î ÁøÇà·üÀ» ³ªÅ¸³»´Â »öÀ¸·Î ´Ü»ö ºí·ÏÀÌ »ý¼ºµÇ°í Ç¥ÁØ ½ºÅ©·Ñ ¼¼±×¸ÕÆ®ÈµÈ ³ªÅ¸³ª°í ÀÏ·ÃÀÇ ÀÛÀº ºí·ÏÀ̳ª Á÷»ç°¢ÇüÀÌ ±¸¼ºµË´Ï´Ù.
Microsoft Visual C# À» »ç¿ëÇÏ¿© Æ÷ÇԵǾî ÀÖ´Â
ProgressBar ÄÁÆ®·ÑÀÇ Ç¥ÁØ ¼³Á¤À» Áö¿øÇÕ´Ï´Ù.
ÀÌ ¹®¼ÀÇ ¿¹Á¦ ÄÚµå´Â ´ÙÀ½°ú °°Àº ¼Ó¼ºÀ» Áö¿øÇÏ´Â ÄÁÆ®·ÑÀ» ¸¸µå´Â ¹æ¹ýÀ» º¸¿© ÁÝ´Ï´Ù.
- ÃÖ¼Ò. ÀÌ ¼Ó¼º¿¡ ´ëÇÑ À¯È¿ °ª ¹üÀ§¿¡ ´ëÇØ ³·Àº °ªÀ» ¼³Á¤Çϰųª °¡Á®¿É´Ï´Ù. ÀÌ ¼Ó¼ºÀÇ ±âº»°ªÀº ¿µ (0) À̰í, ÀÌ ¼Ó¼ºÀ» À½¼ö °ªÀ¸·Î ¼³Á¤ÇÒ ¼ö ¾ø½À´Ï´Ù.
- ÃÖ´ë. ÀÌ ¼Ó¼º¿¡ ´ëÇÑ À¯È¿ °ª ¹üÀ§ÀÇ »óÇÑ °ªÀ» ¼³Á¤Çϰųª °¡Á®¿É´Ï´Ù. ÀÌ ¼Ó¼ºÀÇ ±âº» °ªÀº 100ÀÔ´Ï´Ù.
- °ªÀÔ´Ï´Ù. ÀÌ ¼Ó¼ºÀº ÁøÇà·ü ÇöÀç ¼öÁØÀ» ¼³Á¤Çϰųª °¡Á®¿É´Ï´Ù. °ªÀÌ ÃÖ¼Ò ¹× ÃÖ´ë ¼Ó¼ºÀ» Á¤ÀÇÇÏ´Â ¹üÀ§¿¡ ÀÖ¾î¾ß ÇÕ´Ï´Ù.
- ProgressBarColor. ÀÌ ¼Ó¼ºÀº ÁøÇà·ü Ç¥½ÃÁÙÀÇ »öÀ» ¼³Á¤Çϰųª °¡Á®¿É´Ï´Ù.
»ç¿ëÀÚ ÁöÁ¤ ProgressBar ÄÁÆ®·ÑÀ» ¸¸µé±â
- Visual C# ¿¡¼ »õ Windows ÄÁÆ®·Ñ ¶óÀ̺귯¸® ÇÁ·ÎÁ§Æ®¸¦ ¸¸µé·Á¸é ´ÙÀ½°ú °°ÀÌ ÇϽʽÿÀ.
- Microsoft Visual Studio ½ÃÀÛÇϽʽÿÀ.
- ÆÄÀÏ ¸Þ´º¿¡¼ »õ·Î ¸¸µé±â¸¦ °¡¸®Å² ´ÙÀ½ ÇÁ·ÎÁ§Æ® ¸¦ Ŭ¸¯ÇϽʽÿÀ.
- »õ ÇÁ·ÎÁ§Æ® ´ëÈ »óÀÚ¿¡¼ Visual C#ÇÁ·ÎÁ§Æ® Çü½Ä Ŭ¸¯ÇÑ ´ÙÀ½ ÅÛÇø´ ¿¡¼ Windows Forms ÄÁÆ®·Ñ ¶óÀ̺귯¸® ¸¦ ´©¸¨´Ï´Ù.
Âü°í Visual Studio .NET 2003¿¡¼ Visual C# ´ë½Å Visual C# ÇÁ·ÎÁ§Æ® ¸¦ Ŭ¸¯ÇϽʽÿÀ. - À̸§ »óÀÚ¿¡ SmoothProgressBar ¸¦ ÀÔ·ÂÇÑ ´ÙÀ½ È®ÀÎ À» ´©¸¨´Ï´Ù.
- ÇÁ·ÎÁ§Æ® Ž»ö±â¿¡¼ ±âº» Ŭ·¡½º ¸ðµâ¿¡¼¸¦ UserControl1.cs SmoothProgressBar.cs·Î À̸§À» ¹Ù²ß´Ï´Ù.
- UserControl °³Ã¼ÀÇ ¼Ó¼º â¿¡¼ Name ¼Ó¼ºÀ» À§ÇØ SmoothProgressBar ¿¡¼ UserControl1 º¯°æÇϽʽÿÀ.
- ÀÌ ½ÃÁ¡¿¡¼ ÀϹÝÀûÀ¸·Î ÇØ´ç ÄÁÆ®·Ñ Ŭ·¡½º¿¡¼ »ó¼Ó ¹× ±âÁ¸ ÄÁÆ®·ÑÀ» È®ÀåÇÏ¿© Ãß°¡ ±â´ÉÀ» Ãß°¡ÇÕ´Ï´Ù. ±×·¯³ª ProgressBar Ŭ·¡½º´Â ºÀÀΠŬ·¡½ºÀ̹ǷΠ»ó¼ÓµÉ ¼ö ¾ø½À´Ï´Ù. µû¶ó¼ óÀ½ºÎÅÍ ÄÁÆ®·ÑÀ» ºôµåÇØ¾ß ÇÕ´Ï´Ù.
UserControl¿¡¼ ÆÄ»ýµÈ Ŭ·¡½º SmoothProgressBar.cs ÆÄÀÏ¿¡¼ ´ÙÀ½ Äڵ带 Ãß°¡ÇϽʽÿÀ.
Âü°í Visual Studio .NET 2003¿¡¼ Äڵ带 ¡° Windows Form µðÀÚÀ̳ʿ¡¼ »ý¼ºÇÑ ÄÚµå ¡± ±¸¿ª ¹Ù·Î ´ÙÀ½¿¡ UserControl ÆÄ»ýµÈ Ŭ·¡½ºÀÇ Å¬·¡½º ¸ðµâ¿¡ Ãß°¡ÇϽʽÿÀ.
int min = 0; // Minimum value for progress range
int max = 100; // Maximum value for progress range
int val = 0; // Current progress
Color BarColor = Color.Blue; // Color of progress meter
protected override void OnResize(EventArgs e)
{
// Invalidate the control to get a repaint.
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
SolidBrush brush = new SolidBrush(BarColor);
float percent = (float)(val - min) / (float)(max - min);
Rectangle rect = this.ClientRectangle;
// Calculate area for drawing the progress.
rect.Width = (int)((float)rect.Width * percent);
// Draw the progress meter.
g.FillRectangle(brush, rect);
// Draw a three-dimensional border around the control.
Draw3DBorder(g);
// Clean up.
brush.Dispose();
g.Dispose();
}
public int Minimum
{
get
{
return min;
}
set
{
// Prevent a negative value.
if (value < 0)
{
min = 0;
}
// Make sure that the minimum value is never set higher than the maximum value.
if (value > max)
{
min = value;
min = value;
}
// Ensure value is still in range
if (val < min)
{
val = min;
}
// Invalidate the control to get a repaint.
this.Invalidate();
}
}
public int Maximum
{
get
{
return max;
}
set
{
// Make sure that the maximum value is never set lower than the minimum value.
if (value < min)
{
min = value;
}
max = value;
// Make sure that value is still in range.
if (val > max)
{
val = max;
}
// Invalidate the control to get a repaint.
this.Invalidate();
}
}
public int Value
{
get
{
return val;
}
set
{
int oldValue = val;
// Make sure that the value does not stray outside the valid range.
if (value < min)
{
val = min;
}
else if (value > max)
{
val = max;
}
else
{
val = value;
}
// Invalidate only the changed area.
float percent;
Rectangle newValueRect = this.ClientRectangle;
Rectangle oldValueRect = this.ClientRectangle;
// Use a new value to calculate the rectangle for progress.
percent = (float)(val - min) / (float)(max - min);
newValueRect.Width = (int)((float)newValueRect.Width * percent);
// Use an old value to calculate the rectangle for progress.
percent = (float)(oldValue - min) / (float)(max - min);
oldValueRect.Width = (int)((float)oldValueRect.Width * percent);
Rectangle updateRect = new Rectangle();
// Find only the part of the screen that must be updated.
if (newValueRect.Width > oldValueRect.Width)
{
updateRect.X = oldValueRect.Size.Width;
updateRect.Width = newValueRect.Width - oldValueRect.Width;
}
else
{
updateRect.X = newValueRect.Size.Width;
updateRect.Width = oldValueRect.Width - newValueRect.Width;
}
updateRect.Height = this.Height;
// Invalidate the intersection region only.
this.Invalidate(updateRect);
}
}
public Color ProgressBarColor
{
get
{
return BarColor;
}
set
{
BarColor = value;
// Invalidate the control to get a repaint.
this.Invalidate();
}
}
private void Draw3DBorder(Graphics g)
{
int PenWidth = (int)Pens.White.Width;
g.DrawLine(Pens.DarkGray,
new Point(this.ClientRectangle.Left, this.ClientRectangle.Top),
new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Top));
g.DrawLine(Pens.DarkGray,
new Point(this.ClientRectangle.Left, this.ClientRectangle.Top),
new Point(this.ClientRectangle.Left, this.ClientRectangle.Height - PenWidth));
g.DrawLine(Pens.White,
new Point(this.ClientRectangle.Left, this.ClientRectangle.Height - PenWidth),
new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Height - PenWidth));
g.DrawLine(Pens.White,
new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Top),
new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Height - PenWidth));
}
- ºôµå ¸Þ´º¿¡¼ ¼Ö·ç¼Ç ÇÁ·ÎÁ§Æ®¸¦ ÄÄÆÄÀÏÇÏ¿© Ŭ¸¯ÇϽʽÿÀ.
¿¹Á¦ Ŭ¶óÀÌ¾ðÆ® ÀÀ¿ë ÇÁ·Î±×·¥ ¸¸µé±â
- ÆÄÀÏ ¸Þ´º¿¡¼ »õ·Î ¸¸µé±â¸¦ °¡¸®Å² ´ÙÀ½ ÇÁ·ÎÁ§Æ® ¸¦ Ŭ¸¯ÇϽʽÿÀ.
- »õ ÇÁ·ÎÁ§Æ® Ãß°¡ ´ëÈ »óÀÚ¿¡¼ Visual C#ÇÁ·ÎÁ§Æ® Çü½Ä ¿¡¼ Windows Forms ÀÀ¿ë ÇÁ·Î±×·¥ÅÛÇø´ Â÷·Ê·Î Ŭ¸¯ÇÑ ´ÙÀ½ È®ÀÎ À» ´©¸¨´Ï´Ù.
Âü°í Visual Studio .NET 2003¿¡¼ Visual C# ´ë½Å Visual C# ÇÁ·ÎÁ§Æ® ¸¦ Ŭ¸¯ÇϽʽÿÀ. - SmoothProgressBar ÄÁÆ®·ÑÀÇ µÎ ÀνºÅϽº¸¦ Æû¿¡ Ãß°¡ÇÏ·Á¸é ´ÙÀ½°ú °°ÀÌ ÇϽʽÿÀ.
- µµ±¸ ¸Þ´º¿¡¼ µµ±¸ »óÀÚ Ç׸ñ ¼±Åà À» Ŭ¸¯ÇϽʽÿÀ.
Âü°í Visual Studio .NET 2003 µµ±¸ »óÀÚ »ç¿ëÀÚ ÁöÁ¤µµ±¸ »óÀÚ Ç׸ñ ¼±Åà ´ë½Å ¸¦ Ŭ¸¯ÇϽʽÿÀ. - .NET Framework ±¸¼º ¿ä¼Ò ÅÇÀ» Ŭ¸¯ÇϽʽÿÀ.
- ã¾Æº¸±â ¸¦ Ŭ¸¯ÇÑ ´ÙÀ½ Create a custom ProgressBar control "Àý¿¡¼ ¸¸µç SmoothProgressBar.dll ÆÄÀÏÀ» ã½À´Ï´Ù.
- È®ÀÎ À» Ŭ¸¯ÇϽʽÿÀ. SmoothProgressBar ÄÁÆ®·ÑÀ» µµ±¸ »óÀÚ¿¡ Ãß°¡µË´Ï´Ù.
- SmoothProgressBar ÄÁÆ®·ÑÀÇ µÎ ÀνºÅϽº¸¦ µµ±¸ »óÀÚ¿¡¼ Windows ÀÀ¿ë ÇÁ·Î±×·¥ ÇÁ·ÎÁ§Æ®ÀÇ ±âº» ÆûÀ¸·Î ²ø¾î ¿É´Ï´Ù.
- Timer ÄÁÆ®·ÑÀ» µµ±¸ »óÀÚ¿¡¼ ÆûÀ¸·Î ²ü´Ï´Ù.
- Timer ÄÁÆ®·ÑÀÇ Tick À̺¥Æ®¿¡ ´ÙÀ½ Äڵ带 Ãß°¡ÇÕ´Ï´Ù:
if (this.smoothProgressBar1.Value > 0)
{
this.smoothProgressBar1.Value--;
this.smoothProgressBar2.Value++;
}
else
{
this.timer1.Enabled = false;
}
- Button ÄÁÆ®·ÑÀ» µµ±¸ »óÀÚ¿¡¼ ÆûÀ¸·Î ²ø¾î ¿É´Ï´Ù.
- Button ÄÁÆ®·ÑÀÇ Click À̺¥Æ®¿¡ ´ÙÀ½ Äڵ带 Ãß°¡ÇÕ´Ï´Ù:
this.smoothProgressBar1.Value = 100;
this.smoothProgressBar2.Value = 0;
this.timer1.Interval = 1;
this.timer1.Enabled = true;
- µð¹ö±× ¸Þ´º¿¡¼ »ùÇà ÇÁ·ÎÁ§Æ®¸¦ ½ÇÇàÇÏ·Á¸é ½ÃÀÛ À» Ŭ¸¯ÇϽʽÿÀ.
- ´ÜÃ߸¦ Ŭ¸¯ÇϽʽÿÀ. µÎ °³ÀÇ ÁøÇà·ü Ç¥½Ã±â°¡ "ÁøÇà·ü" ÅØ½ºÆ®¸¦ Ç¥½ÃÇÏ´Â ¾Ë ¼ö ÀÖ½À´Ï´Ù. ÇÑ ÁøÇà·ü Ç¥½Ã±â´Â Áõ°¡ÇÏ´Â ¹æ½ÄÀ¸·Î ÁøÇà·üÀ» Ç¥½ÃÇÕ´Ï´Ù ¹× ´Ù¸¥ ÁøÇà·ü Ç¥½Ã±â¸¦ »ç¿ëÇÏ¿© ÁÙÀÌ¸é ¶Ç´Â Ä«¿îÆ®´Ù¿î ¹æ½ÄÀ¸·Î ÁøÇà·üÀ» Ç¥½ÃÇÕ´Ï´Ù.
±â¼ú ÀÚ·á: 323116 - ¸¶Áö¸· °ËÅä: 2008³â 8¿ù 1ÀÏ ±Ý¿äÀÏ - ¼öÁ¤: 4.1
º» ¹®¼ÀÇ Á¤º¸´Â ´ÙÀ½ÀÇ Á¦Ç°¿¡ Àû¿ëµË´Ï´Ù.
- Microsoft Visual C# 2008 Express Edition
- Microsoft Visual C# 2005 Express Edition
| kbmt kbsweptvs2008 kbhowtomaster KB323116 KbMtko |
±â°è ¹ø¿ªµÈ ¹®¼Áß¿ä: º» ¹®¼´Â Àü¹® ¹ø¿ª°¡°¡ ¹ø¿ªÇÑ °ÍÀÌ ¾Æ´Ï¶ó Microsoft ±â°è ¹ø¿ª ¼ÒÇÁÆ®¿þ¾î·Î ¹ø¿ªÇÑ °ÍÀÔ´Ï´Ù. Microsoft´Â ¹ø¿ª°¡°¡ ¹ø¿ªÇÑ ¹®¼ ¹× ±â°è ¹ø¿ªµÈ ¹®¼¸¦ ¸ðµÎ Á¦°øÇϹǷΠMicrosoft ±â¼ú ÀÚ·á¿¡ ÀÖ´Â ¸ðµç ¹®¼¸¦ Çѱ۷ΠÁ¢ÇÒ ¼ö ÀÖ½À´Ï´Ù. ±×·¯³ª ±â°è ¹ø¿ª ¹®¼°¡ Ç×»ó ¿Ïº®ÇÑ °ÍÀº ¾Æ´Õ´Ï´Ù. µû¶ó¼ ±â°è ¹ø¿ª ¹®¼¿¡´Â ¸¶Ä¡ ¿Ü±¹ÀÎÀÌ Çѱ¹¾î·Î ¸»ÇÒ ¶§ ½Ç¼ö¸¦ ÇÏ´Â °Íó·³ ¾îÈÖ, ±¸¹® ¶Ç´Â ¹®¹ý¿¡ ¿À·ù°¡ ÀÖÀ» ¼ö ÀÖ½À´Ï´Ù. Microsoft´Â ³»¿ë»óÀÇ ¿À¿ª ¶Ç´Â Microsoft °í°´ÀÌ ÀÌ·¯ÇÑ ¿À¿ªÀ» »ç¿ëÇÔÀ¸·Î½á ¹ß»ýÇÏ´Â ºÎ Á¤È®¼º, ¿À·ù ¶Ç´Â ¼ÕÇØ¿¡ ´ëÇØ Ã¥ÀÓÀ» ÁöÁö ¾Ê½À´Ï´Ù. Microsoft´Â ÀÌ·¯ÇÑ ¹®Á¦¸¦ ÇØ°áÇϱâ À§ÇØ ±â°è ¹ø¿ª ¼ÒÇÁÆ®¿þ¾î¸¦ ÀÚÁÖ ¾÷µ¥ÀÌÆ®Çϰí ÀÖ½À´Ï´Ù.