如题
是用了bitmap以后出现的, 很费解!求大侠帮忙
是用了bitmap以后出现的, 很费解!求大侠帮忙
解决方案 »
- 窗口上有很多控件,怎么始终让窗体本身感知到鼠标移动的事件,而不是被控件捕获。
- winform中关闭带视频的窗体时存在死机的现象.
- [50分]求高手帮写1个动态添加控件ASP.NET VS2008
- 有关DataSet的传递问题?
- 怎么样实现gridview中的删除、更新操作?
- 如何用C#开发电子图章,HELP?????
- .NET Remoting 并发计算性能提高
- 如何在一个按钮事件中打开一个Web页?
- C# 类的转换
- 问几个问题Crystal Report动态生成Report的问题
- 100分求助devExpress8.1打包
- 【WinForm问题】关于WebBrowser控件的一个问题..谢谢关注
可能关键的就是这几部分吧 反正没用bimap的时候一点问题都没有 用了以后字就有边了 private void drawPicture(Graphics aGraphics)
{
bool today = false;
int y = Convert.ToInt32(t.Year);
int m = Convert.ToInt32(t.Month);
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
int first = 0;
GraphicsPath firstPath = new GraphicsPath();
Point[] firstArr = new Point[4];
firstArr[0] = new Point(20, 10);
firstArr[1] = new Point(20 + with * 7, 10);
firstArr[2] = new Point(20 + with * 7, 10 + 30);
firstArr[3] = new Point(20, 10 + 30);
firstPath.AddLines(firstArr);
aGraphics.FillPath(Brushes.LightBlue, firstPath);
Point[] pntArr = new Point[4];
GraphicsPath secondPath = new GraphicsPath();
pntArr[0] = new Point(20 + with * 5, 10 + 30);
pntArr[1] = new Point(20 + with * 7, 10 + 30);
pntArr[2] = new Point(20 + with * 7, 10 + 30 + height * 6);
pntArr[3] = new Point(20 + with * 5, 10 + 30 + height * 6);
secondPath.AddLines(pntArr);
aGraphics.FillPath(Brushes.AliceBlue, secondPath); if (count > 0)
{
first = findFirstDayCrossForwardOneMonth(ref m, ref y);
}
else if (count < 0)
{
first = findFirstDayCrossBackwardOneMonth(ref m, ref y);
}
else
{
first = findFirstDayOfCurrentMonth();
today = true;
} drawAssignmentsOrTests(first, m, y, aGraphics); //draw assginments and tests
aGraphics.DrawString(y.ToString(), textMonth, new SolidBrush(Color.AliceBlue), new PointF(20 + with + 10, 10 + 35));//draw year
aGraphics.DrawString(getMonth(m), textMonth, new SolidBrush(Color.White), new PointF(20 + with * 6 + 10, 10 + 20), drawFormat); //draw month
drawTable(aGraphics); //draw table
drawMonth(first, getTotalDaysOfMonth(m, y), aGraphics);
if (today == true)
{
drawToday(first, aGraphics);
}
aGraphics.Dispose();
} protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
bmp = new Bitmap(1100, 600);
Graphics g = Graphics.FromImage(bmp);
drawPicture(g);
CreateGraphics().DrawImage(bmp, 0, 0);
}
private void drawTable(Graphics g)
{
g.DrawLine(Pens.Black, new Point(20, 10), new Point(20 + with * 7, 10));
g.DrawLine(Pens.Black, new Point(20, 10 + 30), new Point(20 + with * 7, 10 + 30));
for (int i = 1; i <= 6; i++) //row
{
g.DrawLine(Pens.Black, new Point(20, 10 + 30 + height * i), new Point(20 + with * 7, 10 + 30 + height * i));
}
for (int i = 0; i < 8; i++) //column
{
g.DrawLine(Pens.Black, new Point(20 + with * i, 10), new Point(20 + with * i, 10 + 30 + height * 6));
}
for (int i = 0; i < 7; i++) //day
{
g.DrawString(day[i], head, new SolidBrush(Color.White), new PointF(20 + 20 + with * i, 15));
}
}
private void drawPicture(Graphics aGraphics)
{
bool today = false;
int y = Convert.ToInt32(t.Year);
int m = Convert.ToInt32(t.Month);
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
int first = 0;
GraphicsPath firstPath = new GraphicsPath();
Point[] firstArr = new Point[4];
firstArr[0] = new Point(20, 10);
firstArr[1] = new Point(20 + with * 7, 10);
firstArr[2] = new Point(20 + with * 7, 10 + 30);
firstArr[3] = new Point(20, 10 + 30);
firstPath.AddLines(firstArr);
aGraphics.FillPath(Brushes.LightBlue, firstPath);
Point[] pntArr = new Point[4];
GraphicsPath secondPath = new GraphicsPath();
pntArr[0] = new Point(20 + with * 5, 10 + 30);
pntArr[1] = new Point(20 + with * 7, 10 + 30);
pntArr[2] = new Point(20 + with * 7, 10 + 30 + height * 6);
pntArr[3] = new Point(20 + with * 5, 10 + 30 + height * 6);
secondPath.AddLines(pntArr);
aGraphics.FillPath(Brushes.AliceBlue, secondPath); if (count > 0)
{
first = findFirstDayCrossForwardOneMonth(ref m, ref y);
}
else if (count < 0)
{
first = findFirstDayCrossBackwardOneMonth(ref m, ref y);
}
else
{
first = findFirstDayOfCurrentMonth();
today = true;
} drawAssignmentsOrTests(first, m, y, aGraphics); //draw assginments and tests
aGraphics.DrawString(y.ToString(), textMonth, new SolidBrush(Color.AliceBlue), new PointF(20 + with + 10, 10 + 35));//draw year
aGraphics.DrawString(getMonth(m), textMonth, new SolidBrush(Color.White), new PointF(20 + with * 6 + 10, 10 + 20), drawFormat); //draw month
drawTable(aGraphics); //draw table
drawMonth(first, getTotalDaysOfMonth(m, y), aGraphics);
if (today == true)
{
drawToday(first, aGraphics);
}
aGraphics.Dispose();
} protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
bmp = new Bitmap(1100, 600);
Graphics g = Graphics.FromImage(bmp);
drawPicture(g);
CreateGraphics().DrawImage(bmp, 0, 0);
}
private void drawTable(Graphics g)
{
g.DrawLine(Pens.Black, new Point(20, 10), new Point(20 + with * 7, 10));
g.DrawLine(Pens.Black, new Point(20, 10 + 30), new Point(20 + with * 7, 10 + 30));
for (int i = 1; i <= 6; i++) //row
{
g.DrawLine(Pens.Black, new Point(20, 10 + 30 + height * i), new Point(20 + with * 7, 10 + 30 + height * i));
}
for (int i = 0; i < 8; i++) //column
{
g.DrawLine(Pens.Black, new Point(20 + with * i, 10), new Point(20 + with * i, 10 + 30 + height * 6));
}
for (int i = 0; i < 7; i++) //day
{
g.DrawString(day[i], head, new SolidBrush(Color.White), new PointF(20 + 20 + with * i, 15));
}
}
G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit'最基本的点阵模式,不会出现毛刺,但字形效果也差
G.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixel
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;//画到Bitmap上
g.DrawString("asd", new Font( "宋体 ", 70f),new SolidBrush(Color.White),0,0);//将合成后的bitmap赋给控件的image来显示。
picTime_bar.BackgroundImage = bgTimeBar;