名称空间`XDrawing.TestLab.Tester'已包含`TesterBase'的定义

时间:2016-03-15 21:33:53

标签: c# unity3d namespaces

已经找到了这个问题的一些答案,但似乎没有一个适合我的情况。我无法弄清楚什么是错的或如何解决它。我试图在统一中使用PDFsharp并且它给了我上面的错误,这是提出问题的代码:

using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using PdfSharp.Drawing;

namespace XDrawing.TestLab.Tester
{
/// <summary>
/// Base class for all Tester classes.
/// </summary>
public abstract class TesterBase
{
public TesterBase()
{
  this.properties = XGraphicsLab.properties;
}

public virtual void RenderPage(XGraphics gfx)
{
  //Debug.WriteLine("RenderPage");
  //gfx.Clear(this.properties.General.BackColor.Color);
  //DrawGridlines(gfx);
  gfx.SmoothingMode = XSmoothingMode.AntiAlias;
}

protected XFont CreateFont(string familyName, double emSize)
{
  XFont font;
  try
  {
    font = new XFont(familyName, emSize);
  }
  catch
  {
    font = new XFont("Courier", emSize);
  }
  return font;
}

protected XFont CreateFont(string familyName, double emSize, XFontStyle style)
{
  XFont font;
  try
  {
    font = new XFont(familyName, emSize, style);
  }
  catch
  {
    font = new XFont("Courier", emSize, style);
  }
  return font;
}

protected XFont CreateFont(string familyName, double emSize, XFontStyle style, XPdfFontOptions options)
{
  XFont font;
  try
  {
    font = new XFont(familyName, emSize, style, options);
  }
  catch
  {
    font = new XFont("Courier", emSize, style, options);
  }
  return font;
}

protected void DrawGridlines(XGraphics gfx)
{
  XPen majorpen = XPens.DarkGray.Clone();
  majorpen.Width = 1;
  XPen minorpen = XPens.LightGray.Clone();
  minorpen.Width = 0.1f;
  gfx.SmoothingMode = XSmoothingMode.HighSpeed;
  DrawGridlines(gfx, new XPoint(100, 100), majorpen, 100, minorpen, 10);

  string text = this.Description;
  XFont font = new XFont("Verdana", 14, XFontStyle.Bold);
  XSize size = gfx.MeasureString(text, font);
  gfx.DrawString(text, font, XBrushes.Black, (600 - size.Width) / 2, 30);
}

public abstract string Description {get;}

protected GraphicsProperties properties;

protected static PointF[] Pentagram
{
  get
  {
    int[] order = new int[] { 0, 3, 1, 4, 2 };
    if (pentagram == null)
    {
      pentagram = new PointF[5];
      for (int idx = 0; idx < 5; idx++)
      {
        double rad = order[idx] * 2 * Math.PI / 5 - Math.PI / 10;
        pentagram[idx].X = (float)Math.Cos(rad);
        pentagram[idx].Y = (float)Math.Sin(rad);
      }
    }
    return pentagram;
  }
}
static PointF[] pentagram;

protected static PointF[] GetPentagram(float size, PointF center)
{
  PointF[] points = Pentagram.Clone() as PointF[];
  for (int idx = 0; idx < 5; idx++)
  {
    points[idx].X = points[idx].X * size + center.X;
    points[idx].Y = points[idx].Y * size + center.Y;
  }
  return points;
}

protected const double Deg2Rad = Math.PI / 180;

public void DrawGridlines(XGraphics gfx, XPoint origin, XPen majorpen, double majordelta, XPen minorpen, double minordelta)
{
  RectangleF box = new RectangleF(0, 0, 600, 850);
  DrawGridline(gfx, origin, minorpen, minordelta, box);
  DrawGridline(gfx, origin, majorpen, majordelta, box);
  /*
        float xmin = -10000f, ymin = -10000f, xmax = 10000f, ymax = 10000f;
        float x, y;
        x = origin.X;
        while (x < xmax)
        {
          DrawLine(majorpen, x, ymin, x, ymax);
          x += majordelta;
        }
        x = origin.X - majordelta;
        while (x > xmin)
        {
          DrawLine(majorpen, x, ymin, x, ymax);
          x -= majordelta;
        }
        y = origin.Y;
        while (y < ymax)
        {
          DrawLine(majorpen, xmin, y, xmax, y);
          y += majordelta;
        }
        y = origin.Y - majordelta;
        while (y > ymin)
        {
          DrawLine(majorpen, xmin, y, xmax, y);
          y -= majordelta;
        }
   */
}

[Conditional("DEBUG")]
void DrawGridline(XGraphics gfx, XPoint origin, XPen pen, double delta, XRect box)
{
  double xmin = box.X, ymin = box.Y, xmax = box.X + box.Width, ymax = box.Y + box.Height;
  double x, y;
  y = origin.Y;
  while (y < ymax)
  {
    gfx.DrawLine(pen, xmin, y, xmax, y);
    y += delta;
  }
  y = origin.Y - delta;
  while (y > ymin)
  {
    gfx.DrawLine(pen, xmin, y, xmax, y);
    y -= delta;
  }
  x = origin.X;
  while (x < xmax)
  {
    gfx.DrawLine(pen, x, ymin, x, ymax);
    x += delta;
  }
  x = origin.X - delta;
  while (x > xmin)
  {
    gfx.DrawLine(pen, x, ymin, x, ymax);
    x -= delta;
  }
}
}
}

感谢您对此有所了解!

1 个答案:

答案 0 :(得分:0)

同一个名称空间中有两个同名

您有 XDrawing.TestLab.Tester 作为命名空间, TesterBase 是编译器抱怨的类名。您需要查看项目中的每个.CS文件,并确保它们 NOT 具有名为 TesterBase 的任何类。