R
rubycon
Hello all,
I get the following errormessage when trying to compile this class, can
somebody tell me what's wrong?
The errormessage:
GraphicObjects.cs(203):
'GraphicObjects.GraphicObjectCollection.GraphicObjectEnumerator' does
not implement interface member
'System.Collections.IEnumerator.Current'.
'GraphicObjects.GraphicObjectCollection.GraphicObjectEnumerator.Current'
is either static, not public, or has the wrong return type.
The class(es) (the compiler complains on the "public class
GraphicObjectEnumerator : object, IEnumerator" statement):
using System.Drawing;
using System;
using System.Collections;
namespace GraphicObjects
{
[Serializable()]
public class GraphicObjectCollection : CollectionBase
{
protected int m_HorizRes = 72;
protected int m_VertRes = 72;
public void DrawSelectedObject(Graphics g, GraphicObject
selectedObject, float Scale)
{
Drawing2D.GraphicsContainer gCon1;
Drawing2D.GraphicsContainer gCon2;
gCon1 = g.BeginContainer;
g.ScaleTransform(Scale, Scale,
Drawing.Drawing2D.MatrixOrder.Append);
gCon2 = g.BeginContainer;
g.PageUnit = GraphicsUnit.Pixel;
if (!(selectedObject == null))
{
Pen selectionPen = new
Pen(Color.FromKnownColor(KnownColor.HotTrack));
selectionPen.DashStyle = Drawing2D.DashStyle.Dot;
selectionPen.Width = 1;
if (selectedObject.Rotation != 0)
{
Drawing2D.Matrix myMatrix;
myMatrix = g.Transform();
myMatrix.RotateAt(selectedObject.Rotation, new
PointF(selectedObject.X, selectedObject.Y),
Drawing.Drawing2D.MatrixOrder.Append);
g.Transform = myMatrix;
}
g.DrawRectangle(selectionPen, selectedObject.X, selectedObject.Y,
selectedObject.Width, selectedObject.Height);
}
g.EndContainer(gCon2);
g.EndContainer(gCon1);
}
public void DrawObjects(Graphics g, float Scale)
{
GraphicObject drawObj;
int i;
Drawing2D.GraphicsContainer gCon;
Drawing2D.Matrix myOriginalMatrix;
myOriginalMatrix = g.Transform();
gCon = g.BeginContainer;
g.PageUnit = GraphicsUnit.Pixel;
g.ScaleTransform(Scale, Scale);
if (!(this.InnerList == null && this.InnerList.Count > 0))
{
for (int i = 0; i <= this.InnerList.Count - 1; i++)
{
drawObj = ((GraphicObject)(this.InnerList(i)));
drawObj.Draw(g);
}
}
g.EndContainer(gCon);
g.Transform = myOriginalMatrix;
}
public void PrintObjects(Graphics g)
{
GraphicObject drawObj;
int i;
g.PageUnit = GraphicsUnit.Pixel;
if (!(this.InnerList == null && this.InnerList.Count > 0))
{
for (int i = 0; i <= this.InnerList.Count - 1; i++)
{
drawObj = ((GraphicObject)(this.InnerList(i)));
drawObj.Draw(g);
}
}
}
public GraphicObject FindObjectAtPoint(Point pt)
{
GraphicObject drawObj;
int i;
if (!(this.InnerList == null && this.InnerList.Count > 0))
{
for (int i = this.InnerList.Count - 1; i >= 0; i--)
{
drawObj = ((GraphicObject)(this.InnerList(i)));
if (drawObj.HitTest(pt))
{
return drawObj;
goto exitForStatement0;
}
}
exitForStatement0: ;
}
return null;
}
public int HorizontalResolution
{
get
{
return m_HorizRes;
}
set
{
m_HorizRes = Value;
}
}
public int VerticalResolution
{
get
{
return m_VertRes;
}
set
{
m_VertRes = Value;
}
}
public GraphicObjectCollection()
{
base.New();
}
public GraphicObjectCollection(GraphicObjectCollection value)
{
base.New();
this.AddRange(value);
}
public GraphicObjectCollection(GraphicObject[] value)
{
base.New();
this.AddRange(value);
}
public GraphicObject Item
{
get
{
return ((GraphicObject)(List(index)));
}
set
{
List(index) = Value;
}
}
public int Add(GraphicObject value)
{
value.Container = this;
return List.Add(value);
}
public void AddRange(GraphicObject[] value)
{
int i = 0;
while ((i < value.Length))
{
this.Add(value(i));
i = (i + 1);
}
}
public void AddRange(GraphicObjectCollection value)
{
int i = 0;
while ((i < value.Count))
{
this.Add(value(i));
i = (i + 1);
}
}
public bool Contains(GraphicObject value)
{
return List.Contains(value);
}
public void CopyTo(GraphicObject[] array, int index)
{
List.CopyTo(array, index);
}
public int IndexOf(GraphicObject value)
{
return List.IndexOf(value);
}
public void Insert(int index, GraphicObject value)
{
List.Insert(index, value);
}
public new GraphicObjectEnumerator GetEnumerator()
{
return new GraphicObjectEnumerator(this);
}
public void Remove(GraphicObject value)
{
List.Remove(value);
}
public class GraphicObjectEnumerator : object, IEnumerator
{
private IEnumerator baseEnumerator;
private IEnumerable temp;
public GraphicObjectEnumerator(GraphicObjectCollection mappings)
{
base.New();
this.temp = ((IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator;
}
public GraphicObject Current
{
get
{
return ((GraphicObject)(baseEnumerator.Current));
}
}
object IEnumerator_Current
{
get
{
return baseEnumerator.Current;
}
}
public bool MoveNext()
{
return baseEnumerator.MoveNext;
}
bool IEnumerator_MoveNext()
{
return baseEnumerator.MoveNext;
}
public void Reset()
{
baseEnumerator.Reset();
}
void IEnumerator_Reset()
{
baseEnumerator.Reset();
}
}
}
}
I get the following errormessage when trying to compile this class, can
somebody tell me what's wrong?
The errormessage:
GraphicObjects.cs(203):
'GraphicObjects.GraphicObjectCollection.GraphicObjectEnumerator' does
not implement interface member
'System.Collections.IEnumerator.Current'.
'GraphicObjects.GraphicObjectCollection.GraphicObjectEnumerator.Current'
is either static, not public, or has the wrong return type.
The class(es) (the compiler complains on the "public class
GraphicObjectEnumerator : object, IEnumerator" statement):
using System.Drawing;
using System;
using System.Collections;
namespace GraphicObjects
{
[Serializable()]
public class GraphicObjectCollection : CollectionBase
{
protected int m_HorizRes = 72;
protected int m_VertRes = 72;
public void DrawSelectedObject(Graphics g, GraphicObject
selectedObject, float Scale)
{
Drawing2D.GraphicsContainer gCon1;
Drawing2D.GraphicsContainer gCon2;
gCon1 = g.BeginContainer;
g.ScaleTransform(Scale, Scale,
Drawing.Drawing2D.MatrixOrder.Append);
gCon2 = g.BeginContainer;
g.PageUnit = GraphicsUnit.Pixel;
if (!(selectedObject == null))
{
Pen selectionPen = new
Pen(Color.FromKnownColor(KnownColor.HotTrack));
selectionPen.DashStyle = Drawing2D.DashStyle.Dot;
selectionPen.Width = 1;
if (selectedObject.Rotation != 0)
{
Drawing2D.Matrix myMatrix;
myMatrix = g.Transform();
myMatrix.RotateAt(selectedObject.Rotation, new
PointF(selectedObject.X, selectedObject.Y),
Drawing.Drawing2D.MatrixOrder.Append);
g.Transform = myMatrix;
}
g.DrawRectangle(selectionPen, selectedObject.X, selectedObject.Y,
selectedObject.Width, selectedObject.Height);
}
g.EndContainer(gCon2);
g.EndContainer(gCon1);
}
public void DrawObjects(Graphics g, float Scale)
{
GraphicObject drawObj;
int i;
Drawing2D.GraphicsContainer gCon;
Drawing2D.Matrix myOriginalMatrix;
myOriginalMatrix = g.Transform();
gCon = g.BeginContainer;
g.PageUnit = GraphicsUnit.Pixel;
g.ScaleTransform(Scale, Scale);
if (!(this.InnerList == null && this.InnerList.Count > 0))
{
for (int i = 0; i <= this.InnerList.Count - 1; i++)
{
drawObj = ((GraphicObject)(this.InnerList(i)));
drawObj.Draw(g);
}
}
g.EndContainer(gCon);
g.Transform = myOriginalMatrix;
}
public void PrintObjects(Graphics g)
{
GraphicObject drawObj;
int i;
g.PageUnit = GraphicsUnit.Pixel;
if (!(this.InnerList == null && this.InnerList.Count > 0))
{
for (int i = 0; i <= this.InnerList.Count - 1; i++)
{
drawObj = ((GraphicObject)(this.InnerList(i)));
drawObj.Draw(g);
}
}
}
public GraphicObject FindObjectAtPoint(Point pt)
{
GraphicObject drawObj;
int i;
if (!(this.InnerList == null && this.InnerList.Count > 0))
{
for (int i = this.InnerList.Count - 1; i >= 0; i--)
{
drawObj = ((GraphicObject)(this.InnerList(i)));
if (drawObj.HitTest(pt))
{
return drawObj;
goto exitForStatement0;
}
}
exitForStatement0: ;
}
return null;
}
public int HorizontalResolution
{
get
{
return m_HorizRes;
}
set
{
m_HorizRes = Value;
}
}
public int VerticalResolution
{
get
{
return m_VertRes;
}
set
{
m_VertRes = Value;
}
}
public GraphicObjectCollection()
{
base.New();
}
public GraphicObjectCollection(GraphicObjectCollection value)
{
base.New();
this.AddRange(value);
}
public GraphicObjectCollection(GraphicObject[] value)
{
base.New();
this.AddRange(value);
}
public GraphicObject Item
{
get
{
return ((GraphicObject)(List(index)));
}
set
{
List(index) = Value;
}
}
public int Add(GraphicObject value)
{
value.Container = this;
return List.Add(value);
}
public void AddRange(GraphicObject[] value)
{
int i = 0;
while ((i < value.Length))
{
this.Add(value(i));
i = (i + 1);
}
}
public void AddRange(GraphicObjectCollection value)
{
int i = 0;
while ((i < value.Count))
{
this.Add(value(i));
i = (i + 1);
}
}
public bool Contains(GraphicObject value)
{
return List.Contains(value);
}
public void CopyTo(GraphicObject[] array, int index)
{
List.CopyTo(array, index);
}
public int IndexOf(GraphicObject value)
{
return List.IndexOf(value);
}
public void Insert(int index, GraphicObject value)
{
List.Insert(index, value);
}
public new GraphicObjectEnumerator GetEnumerator()
{
return new GraphicObjectEnumerator(this);
}
public void Remove(GraphicObject value)
{
List.Remove(value);
}
public class GraphicObjectEnumerator : object, IEnumerator
{
private IEnumerator baseEnumerator;
private IEnumerable temp;
public GraphicObjectEnumerator(GraphicObjectCollection mappings)
{
base.New();
this.temp = ((IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator;
}
public GraphicObject Current
{
get
{
return ((GraphicObject)(baseEnumerator.Current));
}
}
object IEnumerator_Current
{
get
{
return baseEnumerator.Current;
}
}
public bool MoveNext()
{
return baseEnumerator.MoveNext;
}
bool IEnumerator_MoveNext()
{
return baseEnumerator.MoveNext;
}
public void Reset()
{
baseEnumerator.Reset();
}
void IEnumerator_Reset()
{
baseEnumerator.Reset();
}
}
}
}