Автоматизируйте MapInfo с помощью C#

Привет, я разрабатываю приложение, которое анализирует данные, а затем я хочу визуализировать некоторые данные на карте с помощью MapInfo, я правильно создал экземпляр MapInfo, но до сих пор я не знаю, как отображать данные на экземпляре или как его использовать. экземпляр, который я создал, не виден даже после того, как я сделал его видимым.

ниже мой код

namespace JA3_Trace_Viewer
{
public partial class JA3Main : Form
{
    public JA3Main()
    {
        InitializeComponent();
    }

    private void JA3Main_Load(object sender, EventArgs e)
    {

        MapInfo.MapInfoApplication mapinfoinstance = new MapInfo.MapInfoApplication();
        mapinfoinstance.Visible = true;
        DDockWindow winM = new DDockWindow();
        winM.Activate();            
    }
}

Данные, которые я хочу визуализировать на карте, - это долгота и широта, а другие столбцы позволяют называть их данными, поэтому, пожалуйста, помогите мне.

Заранее спасибо.

Новый код:

    public partial class Form1 : Form
{
    // Sets the parent of a window.
    [DllImport("User32", CharSet = CharSet.Auto, ExactSpelling = true)]
    internal static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndParent);

    //Sets window attributes
    [DllImport("USER32.DLL")]
    public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

    //Gets window attributes
    [DllImport("USER32.DLL")]
    public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

    //assorted constants needed
    public static int GWL_STYLE = -16;
    public static int WS_CHILD = 0x40000000; //child window
    public static int WS_BORDER = 0x00800000; //window with border
    public static int WS_DLGFRAME = 0x00400000; //window with double border but no title
    public static int WS_CAPTION= WS_BORDER | WS_DLGFRAME; //window with a title bar
    public static int WS_MAXIMIZE = 0x1000000;

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        // Create a new instance of MapInfo.
        MapInfoApplication mapinfo = new MapInfoApplication();

        // Get the handle to the whole MapInfo application.
        // 9 = SYS_INFO_MAPINFOWND.
        string handle = mapinfo.Eval("SystemInfo(9)");

        // Convert the handle to an IntPtr type.
        IntPtr oldhandle = new IntPtr(Convert.ToInt32(handle));

        //Make mapinfo visible otherwise it won't show up in our control.
        mapinfo.Visible = true;

        //Set the parent of MapInfo to a picture box on the form.
        SetParent(oldhandle, this.pictureBox1.Handle);

        //Get current window style of MapInfo window
        int style = GetWindowLong(oldhandle, GWL_STYLE);

        //Take current window style and remove WS_CAPTION(title bar) from it
        SetWindowLong(oldhandle, GWL_STYLE, (style & ~WS_CAPTION));

        //Maximize MapInfo so that it fits into our control.
        mapinfo.Do("Set Window 1011 Max");
    }
}

person Anas Alwindawee    schedule 17.03.2015    source источник
comment
Вы не открываете никакую таблицу MapInfo (файл .TAB), поэтому отображать нечего.   -  person Wernfried Domscheit    schedule 18.03.2015
comment
Должен ли я сначала получить окно mapinfo в моей форме, на самом деле я думаю, что окно mapinfo не открыто в моей форме.   -  person Anas Alwindawee    schedule 18.03.2015
comment
Нет, вы не получаете полноценную встроенную MapInfo с полосами меню и т. д. Пока вы не открываете ни одну таблицу, вы ничего не видите.   -  person Wernfried Domscheit    schedule 18.03.2015
comment
Привет, я открыл новую таблицу и сказал, что ничего не появилось, ниже мой код, пожалуйста, посмотрите. mapinfo.Do(@Открыть таблицу E:\test.TAB);   -  person Anas Alwindawee    schedule 19.03.2015
comment
Сравните свой код с образцом кода из \Samples\DOTNET\IntegratedMapping\IntegratedMappingCS.sln в папке MapBasic. Исходя из этого, вы должны быть в состоянии заставить его работать.   -  person Wernfried Domscheit    schedule 19.03.2015


Ответы (1)


Класс MapInfoApplication имеет метод с именами Do() и Eval(), туда вы можете передать командную строку, например. mapinfoinstance.Do('Open Table foo_bar.TAB as foo')

Посмотрите образцы MapBasic в папке Samples\DOTNET\... вашей папки MapBasic.

person Wernfried Domscheit    schedule 17.03.2015
comment
Привет, спасибо за ваши комментарии, я добавил новый код в основной пост, который я использовал, и он все еще не решает проблему, не могли бы вы его увидеть. - person Anas Alwindawee; 18.03.2015