Please help me I'm having problems

using System;
using System.Diagnostics;
using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading;
using AxMapWinGIS;
using MapWinGIS;

namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
private List MyCircles = new List();
public MapWinGIS.Point MouseDowLocation;
private bool IsMouseDow = false;
private int m_StartX;
private int m_StartY;
private int m_CurX;
private int m_CurY;
private String Drawcase = “Circle”;
MapWinGIS.Point Point1 = new MapWinGIS.Point();
MapWinGIS.Point Point2 = new MapWinGIS.Point();
MapWinGIS.Point StartDowLocation = new MapWinGIS.Point();
private bool v;

    public class Circle
    {
        internal int y1;

        public int X1 { get; internal set; }
        public int X2 { get; internal set; }
        public int Y2 { get; internal set; }
    }
    public Form1()
    {
        InitializeComponent();
    }

    private void ToolStripButton9_Click(object sender, EventArgs e)
    {

    }
    // <resumo>
    // Cria um shapefile contendo polígonos com furos
    // </summary>
    private void PosteToolStripMenuItem_Click(object sender, EventArgs e)
    {
        axMap1.Projection = tkMapProjection.PROJECTION_NONE;
        
        var sf = new Shapefile();
        bool result = sf.CreateNewWithShapeID("", ShpfileType.SHP_POLYGON);

        if (!result)
        {
            MessageBox.Show(sf.ErrorMsg[sf.LastErrorCode]);
        }
        else
        {
            double xMin = 0.0;
            double yMin = 0.0;
            double xMax = 0.0;
            double yMax = 0.0;
            Random rnd = new Random(DateTime.Now.Millisecond);

            // builds 1 polygons            
            for (int i = 0; i < 1; i++)
            {
                double xCenter = xMin + (xMax - xMin) * rnd.NextDouble();
                double yCenter = yMin + (yMax - yMin) * rnd.NextDouble();

                // random radius from 10 to 100
                double radius = 3 + rnd.NextDouble() * 1;

                var shp = new Shape();
                shp.Create(ShpfileType.SHP_POLYGON);
                // o polígono deve ter a ordem dos pontos no sentido horário (primeiro argumento - true)

                this.AddRing(true, xCenter, yCenter, radius, ref shp);
                // os buracos devem ter a ordem dos pontos no sentido anti-horário (fale para o último argumento)


                this.AddRing(false, xCenter, yCenter, radius / 2.0, ref shp);


                for (int j = 0; j < shp.NumParts; j++)
                {
                    Debug.Print("Part is clocwise: " + shp.PartIsClockWise[j]);
                }

                Debug.Print("Shape is valid: " + shp.IsValid);
                if (!shp.IsValid)
                    Debug.Print("Reason: " + shp.IsValidReason);

                sf.EditInsertShape(shp, ref i);
            }

            axMap2.AddLayer(sf, true);
            axMap2.ZoomToLayer(0);

            sf.SaveAs(@"c:\polygons.shp", null);
        }
    }

    // <resumo>
    // Adiciona um anel ao polígono
    // </summary>
    private void AddRing(bool clockWise, double x, double y, double radius, ref Shape shp)
    {
        int partIndex = shp.NumParts;
        if (shp.numPoints > 0)
            shp.InsertPart(shp.numPoints, ref partIndex);

        int count = 0;
        for (int j = 0; j < 38; j++)
        {
            double dx = radius * Math.Cos(j * Math.PI / 18);
            double dy = radius * Math.Sin(j * Math.PI / 18);

            //dx *= clockWise ? -1 : 1;
            dy *= clockWise ? -1 : 1;

            var sdn = new MapWinGIS.Point();
            sdn.x = x + dx;
            sdn.y = y + dy;
            count = shp.numPoints;
            shp.InsertPoint(sdn, ref count);

        }
    }

    private void AxMap2_MouseDownEvent(object sender, _DMapEvents_MouseDownEvent e)
    {
        IsMouseDow = true;
        m_StartX = e.x;
        m_StartY = e.y;
        m_CurX = e.x;
        m_CurY = e.y;
        StartDowLocation = Point1;
    }
    private void AxMap2_MouseMoveEvent(object sender, _DMapEvents_MouseMoveEvent e)
    {
        Pen Dashed_Pen = new Pen(Color.Green, 1);
        Dashed_Pen.DashStyle = DashStyle.Dash;
        if (IsMouseDow == false) return;
        m_CurX = (int)e.x;
        m_CurY = (int)e.y;
        switch (Drawcase)
        {
            case "Circle":
                {
                    break;
                }
            case "MoveCircle":
                {
                    int i;
                    i = MyCircles.Count - 1;
                    if (i >= 0)
                    {
                        Point1.x = e.x + MyCircles[i].X1 - StartDowLocation.x;
                        Point1.y = e.y + MyCircles[i].y1 - StartDowLocation.y;
                        Point2.x = e.x + MyCircles[i].X2 - StartDowLocation.x;
                        Point2.y = e.y + MyCircles[i].Y2 - StartDowLocation.y;
                    }
                    break;
                }
        }
        axMap2.Invalidate();

    }
    private void AxMap2_MouseUpEvent(object Sender, _DMapEvents_MouseUpEvent e)
    {
        IsMouseDow = false;
        if (e.button == Left)
        {
            switch (Drawcase)
            {
                case "Circle":
                    {
                        Circle DrawCircle = new Circle();
                        DrawCircle.X1 = m_StartX;
                        DrawCircle.y1 = m_StartX;
                        DrawCircle.X2 = m_CurX;
                        DrawCircle.Y2 = m_CurY;
                        MyCircles.Add(DrawCircle);
                        break;
                    }
                case "MoveCircle":
                    {
                        Circle DrawCircle = new Circle();
                        DrawCircle.X1 = m_StartX;
                        DrawCircle.y1 = m_StartX;
                        DrawCircle.X2 = m_CurX;
                        DrawCircle.Y2 = m_CurY;
                        MyCircles.Add(DrawCircle);
                        int count = MyCircles.Count - 1;
                        MyCircles.RemoveAt(count - 1);
                        break;
                    }
            }
            axMap1.Invalidate();
        }
    }
    private void SairToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Application.Exit();
    }

    private void PosteToolStripMenuItem_Click_1(object Sender, EventArgs e)
    {
    }

    private void AxMap2_LayerAdded(object sender, _DMapEvents_LayerAddedEvent e)
    {
        int i,x1,y1,x2,y2;
        for (i = 0; i <= MyCircles.Count - 1; i++)
        {
            Pen CirclePen = new Pen(Color.FromArgb(255, 0, 0), 3);
            x1 = MyCircles[i].X1;
            x2 = MyCircles[i].X2;
            y1 = MyCircles[i].y1;
            y2 = MyCircles[i].Y2;
            e = Graphics(CirclePen, x1, y1, x2, y2);
            
        }
        if(IsMouseDow==true)
            switch (Drawcase)
            {
                case "Circle":
                    {
                        Pen dashedpen = new Pen(Color.Blue,1);
                        e = Graphics(dashedpen, m_StartX, m_StartY,  m_CurX, m_CurY);
                        break;
                    }
                case "MoveCircle":
                    {
                        Pen dashedpen = new Pen(Color.Blue, 3);
                        e = Graphics(dashedpen,Point1.x,Point2.x,Point1.y,Point2.y, m_CurX, m_CurY);
                        break;
                    }
            }
        }

    private void MoverToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Drawcase = "Move";
    }
}
}

   Please help me I'm having problems implementing code, error that is appearing is because Graphics Method did not associate to axMap2 in the line e.Graphics.DrawCircle(dashedpen,Point1.x,Point2.x,Point1.y,Point2.y, m_CurX , m_CurY); Graphics error CS1955 Non-invocatable member cannot be used as a method. Help please

Hi @mickaelschwedler,

It’s hard to decipher from what you wrote, but are you trying to use the MapWinGIS “DrawCircle” because your parameters don’t seem to match up with those expected:

Also you have an instance of class “Circle” called “DrawCircle” and you’re trying to call a DrawCircle method - something that would typically cause this type of error (although your “DrawCircle” seems to be a member of whatever “Graphics” is in this case.

And what is this line meant to do, it can’t be right surely? Setting an instance of "_DMapEvents_LayerAddedEvent " as below must be wrong?

e = Graphics(dashedpen, m_StartX, m_StartY,  m_CurX, m_CurY);

Regards,

Rob H