public void GetTableList()
 {
     if (int.TryParse(instance.Eval("NumTables()"), out var amount))
     {
         var it = 1;
         while (it <= amount)
         {
             var tableName = instance.Eval(string.Format("TableInfo({0}, 1)", it));
             if (!String.IsNullOrEmpty(tableName))
             {
                 tables.Add(Table.CreateTable(instance, tableName, it));
             }
             it++;
         }
     }
 }
Beispiel #2
0
 public void GetTableList()
 {
     Tables = new List <DMITable>();
     if (int.TryParse(instance.Eval("NumTables()"), out var amount))
     {
         var it = 1;
         while (it <= amount)
         {
             var tableName = instance.Eval(string.Format("TableInfo({0}, 1)", it));
             if (!String.IsNullOrEmpty(tableName))
             {
                 Tables.Add(mapGen.GetTable(tableName));
             }
             it++;
         }
     }
 }
Beispiel #3
0
        public override bool Start(ProcessWindowStyle windowStyle)
        {
            try
            {
                // get any running MapInfo processes
                _mapInfoProcsPreStart = GetMapInfoProcesses();

                // create a MapInfo instance
                _mapInfoComObj = COMMapinfo.CreateInstance();
                _mapInfoApp = (DMapInfo)_mapInfoComObj.GetUnderlyingMapinfoInstance();
                //_mapInfoApp = (DMapInfo)Activator.CreateInstance(Type.GetTypeFromProgID("MapInfo.Application"));

                // wire up callback
                MapInfoCustomCallback miCallback = new MapInfoCustomCallback();
                miCallback.OnStatusChanged += new Action<string>(miCallback_OnStatusChanged);
                miCallback.OnMenuItemClick += new Action<string>(miCallback_OnMenuItemClick);
                miCallback.OnWindowChanged += new Action<int>(miCallback_OnWindowChanged);
                _mapInfoComObj.Callback = miCallback;

                double mapInfoVersion;
                double.TryParse(_mapInfoApp.Version, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out mapInfoVersion);

                // open the HLU workspace
                if (!OpenWorkspace(_mapPath)) return false;

                // size MapInfo window
                Window(windowStyle, IntPtr.Zero);

                // MapInfo 10 won't display toolbars when started programmatically
                if (mapInfoVersion >= 1000)
                {
                    if (!File.Exists(String.Format("{0}{1}MapInfo{1}MapInfo{1}Professional{1}{2}{1}MICommandBarStateAutomation.xml",
                        Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Path.DirectorySeparatorChar, _mapInfoApp.Version)))
                    {
                        EnableStandardTools();
                    }
                }
                else
                {
                    try
                    {
                        string prefFolder = _mapInfoApp.Eval(String.Format("GetFolderPath$({0})",
                            (int)MapInfoConstants.GetFolderPath.FOLDER_MI_PREFERENCE));
                        string startupWS = Path.Combine(prefFolder, "Startup.wor"); // "MAPINFOW.WOR");
                        if (File.Exists(startupWS))
                        {
                            _mapInfoApp.Do(String.Format("Run Application {0}", QuoteValue(startupWS)));
                        }
                    }
                    catch { }
                    EnableStandardTools();
                    SizeWindow(_hluMapWindowID, false);
                }

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Starting MapInfo", MessageBoxButton.OK, MessageBoxImage.Error);
                return false;
            }
        }