Interface member implementation

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();
}
}
}
}
 
C

Claes Bergefall

The error message you get is pretty self explaining; your implementation of
the Current property has the wrong return type (it should return object)

/claes

rubycon said:
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();
}
}
}
}
 
N

Nicholas Paldino [.NET/C# MVP]

rubycon,

The compiler error is pretty specific about the error. You aren't
implementing the Current property on the IEnumerator interface.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

rubycon said:
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();
}
}
}
}
 
R

rubycon

Thanks for the responses, all I was basically looking for is a design
surface. This is going to take a lot longer than I was hoping for or
have the time for. Different avenues perhaps or forget all about it.
Nicholas Paldino [.NET/C# MVP] schreef:
rubycon,

The compiler error is pretty specific about the error. You aren't
implementing the Current property on the IEnumerator interface.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

rubycon said:
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();
}
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top