我想创建一个能够绘制饼图或条形图的类库。 我使用如下代码...使用类库创建饼图/条形图
Graphics g = CreateGraphics();
当我使用该代码的Visual Studio告诉我,你不能用dll文件(类库)使用。
我还有问题,我怎样才能解决这个问题?O_O
询问详细信息:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Data;
namespace KouChart
{
public class Pasta
{
public void PastaCiz(int a, int b, int c)
{
float toplam = a + b + c;
float deg1 = (a/toplam) * 360;
float deg2 = (b/toplam) * 360;
float deg3 = (c/toplam) * 360;
Pen p = new Pen(Color.Red, 2);
Graphics g = this.CreateGraphics();
Rectangle rec = new Rectangle(50, 12, 150, 150);
Brush b1 = new SolidBrush(Color.Red);
Brush b2 = new SolidBrush(Color.Black);
Brush b3 = new SolidBrush(Color.Blue);
Brush b4 = new SolidBrush(Color.Yellow);
g.DrawPie(p, rec, 0, deg1);
g.FillPie(b1, rec, 0, deg1);
g.DrawPie(p, rec, deg1, deg2);
g.FillPie(b2, rec, deg1, deg2);
g.DrawPie(p, rec, deg2 + deg1, deg3);
g.FillPie(b3, rec, deg2 + deg1, deg3);
}
}
}
和错误:错误1“KouChart.Pasta”不包含'的定义CreateGraphics“,并且没有扩展方法'CreateGraphics'接受类型'KouChart.Pasta'的第一个参数可以找到(你是否缺少使用指令或程序集引用?)C:\ Users \ Muyu \ Documents \ Visual Studio 2010 \ Projects \ KouChart \ KouChart \ Pasta.cs 20 31 KouChart
你能发布实际的错误信息吗? –
请向我们展示更多代码和完整的错误细节,您当前的描述有点过于笼统;-) –
对不起,我发布了更多信息。 – TheMuyu