示例#1
0
 public MapInfo(IMapInfoApp _MapinfoApp)
 {
     MapinfoApp = _MapinfoApp;
     instance   = MapinfoApp.CreateInstance();
     mapGen     = instance.MIMapGen;
     GetTableList();
 }
        /// <summary>
        /// Creates a new instance of Mapinfo and returns a <see cref="MapInfoSession"/>
        /// which contains the instance.
        /// <para>The returned objet can be passed into objects and
        /// methods that need it in the MapinfoWrapper API.</para>
        /// </summary>
        /// <returns>A new <see cref="ComMapInfo"/> containing the running instance of Mapinfo.</returns>
        public static IMapInfoWrapper CreateMapInfoInstance()
        {
            DMapInfo   instance = CreateMapinfoInstance();
            ComMapInfo map_info = new ComMapInfo(instance);

            return(map_info);
        }
示例#3
0
 public Row(DMapInfo mapInfo, string parent, int rowId, Fields fields)
 {
     Application = mapInfo;
     Parent      = parent;
     RowID       = rowId;
     Fields      = fields;
 }
 public MapInfoAppControls(IMapInfoApp _MapinfoApp)
 {
     MapinfoApp = _MapinfoApp;
     instance   = MapinfoApp.CreateInstance();
     tables     = new List <Table>();
     GetTableList();
 }
        private static DMapInfo CreateMapinfoInstance()
        {
            Type     mapinfotype = Type.GetTypeFromProgID("Mapinfo.Application");
            DMapInfo instance    = (DMapInfo)Activator.CreateInstance(mapinfotype);

            return(instance);
        }
示例#6
0
 public Rows(DMapInfo Application, string Parent, int nCols, Fields fields)
 {
     rows = new List <Row>(); int i = 0;
     while (i < nCols)
     {
         rows.Add(new Row(Application, Parent, i + 1, fields));
         i++;
     }
 }
示例#7
0
        public COMMapinfo CreateCOMInstance()
        {
            DMapInfo   instance   = CreateMapinfoInstance();
            COMMapinfo olemapinfo = new COMMapinfo(instance);

            Bootstrapper.WireUp(olemapinfo);

            return(olemapinfo);
        }
        public void GetUnderlyingInstanceReturnsAssignedInstance()
        {
            DMapInfo expected = mockmapinfo.Object;

            COMMapinfo mapinfo = new COMMapinfo(expected);

            object result = mapinfo.GetUnderlyingMapinfoInstance();

            Assert.IsInstanceOf(typeof(DMapInfo), result);
            Assert.AreSame(expected, result);
        }
        /// <summary>
        /// Creates a new instance of Mapinfo and returns a <see cref="MapinfoSession"/>
        /// which contains the instance.
        /// <para>The returned objet can be passed into objects and
        /// methods that need it in the MapinfoWrapper API.</para>
        /// </summary>
        /// <returns>A new <see cref="COMMapinfo"/> containing the running instance of Mapinfo.</returns>
        public static MapinfoSession CreateMapInfoInstance()
        {
            DMapInfo       instance = CreateMapinfoInstance();
            COMMapinfo     mapinfo  = new COMMapinfo(instance);
            MapinfoSession session  = new MapinfoSession(mapinfo);

            if (SessionCreated != null)
            {
                SessionCreated(session);
            }
            return(session);
        }
示例#10
0
        public static Table CreateTable(DMapInfo _instance, string _tabName)
        {
            Table table = new Table();

            table.instance = _instance;
            table.name     = _tabName;
            table.tableId  = table.GetTableID(_tabName);
            table.lenght   = table.GetLenght();
            table.Fields   = new Fields(table.GetFields());
            table.Rows     = new Rows(table.instance, table.Name, table.Lenght, table.Fields);
            return(table);
        }
示例#11
0
        private void SpecialMethod()
        {
            var map     = MapInfo.CreateMap();
            var mapinfo = map.mapInfo;

            Table tab = mapinfo.GetTable();



            DMapInfo  inst   = map.mapInfo.instance;
            DMIMapGen mapGen = inst.MIMapGen;
            DMITable  table  = mapGen.GetTable("БТИ_2019");

            DMIFields columns = table.Fields;

            foreach (DMIField col in columns)
            {
                Console.WriteLine(col.Name());
                Console.WriteLine(col.Type());
            }

            DMIRows rows = table.Rows;

            List <string> list = new List <string>();



            foreach (DMIRow row in rows)
            {
                list.Add(row.Value[(object)"VRI"]);
            }

            var set     = new List <string>();
            var pattern = @"\d+[.]\d+([.]\d+)?([.]\d+)?";

            foreach (var val in list)
            {
                if (!string.IsNullOrEmpty(val))
                {
                    var result = Regex.Matches(val, pattern).Cast <Match>().Select(p => p.Value).ToList();
                    set.AddRange(result);
                }
            }

            var res = set.Distinct();

            foreach (var val in res)
            {
                Console.WriteLine(val);
            }
        }
示例#12
0
 /// <summary>
 /// Creates and instance of MapInfo.
 /// </summary>
 /// <returns>A instance of MapInfo if it is installed.  Returns null if a error was raised.</returns>
 public static MapinfoWrapper CreateInstance()
 {
     try
     {
         Type     mapinfoType = Type.GetTypeFromProgID("MapInfo.Application");
         DMapInfo mapinfo     = (DMapInfo)Activator.CreateInstance(mapinfoType);
         return(new MapinfoWrapper(mapinfo));
     }
     catch (Exception ex)
     {
         log.Error("MapInfo could not be opened", ex);
         return(null);
     }
 }
示例#13
0
 public override bool Close()
 {
     try
     {
         if (_mapInfoApp != null)
         {
             _mapInfoApp.RunMenuCommand((int)MapInfoConstants.MenuDef95File.M_FILE_EXIT);
             _mapInfoApp = null;
             //_mapInfoComObj = null;
         }
         return true;
     }
     catch { return false; }
 }
示例#14
0
        public override bool Start(ProcessWindowStyle windowStyle)
        {
            try
            {
                // get any running MapInfo processes
                _mapInfoProcsPreStart = GetMapInfoProcesses();

                // if there are already any MapInfo processes running then tell the
                // user that they must close all instanced before starting the tool
                if (_mapInfoProcsPreStart.Count() != 0)
                {
                    MessageBox.Show("MapInfo is already running.\n\nAll existing instances of MapInfo must be stopped before the tool can be launched.",
                        "Error Starting MapInfo", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return false;
                }

                //---------------------------------------------------------------------
                // FIXED: KI94 (MapInfo Layer Control)
                // FIXED: KI98 (MapInfo user interface)
                // Start MapInfo as a process rather than as a COM object so that it
                // starts correctly (e.g. all the menu bars, etc. where the user wants).

                // Determine the default version of MapInfo
                String miver = GetDefaultOLE_MIVer();

                // Start the default version of MapInfo
                LaunchMI(miver);

                // Connect to the running version of MapInfo
                _mapInfoApp = (DMapInfo)ConnectToRunningMI(miver);
                //---------------------------------------------------------------------

                // open the HLU workspace (returns false if it is not found or not valid)
                if (!OpenWorkspace(_mapPath)) return false;

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

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Starting MapInfo", MessageBoxButton.OK, MessageBoxImage.Error);
                return false;
            }
        }
示例#15
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;
            }
        }
示例#16
0
 private MapinfoWrapper(DMapInfo mapInfo)
 {
     this.mapinfo = mapInfo;
 }
 /// <summary>
 /// <b>NOTE!</b> This is only provided to allow for testing and should not be used outside of a test, if you need to
 /// create a new instance of Mapinfo please use <see cref="T:Wrapper.Mapinfo.Factory.MapinfoFactory"/>
 ///
 /// <para>Initializes a new instance of the <see cref="T:COMMapinfo"/> class, which holds
 /// an instance of a currently running instance of Mapinfo's COM object.</para>
 /// <para>If you use this method you must wire up the needed dependencies, see example section:</para>
 /// <para><b>IT IS HIGHLY RECOMMANDED TO USE THE <see cref="T:Wrapper.Mapinfo.Factory.MapinfoFactory"/> TO CREATE
 /// AN INSTANCE OF MAPINFO.</b></para>
 /// </summary>
 /// <param name="mapinfoInstance">A currently running instance of Mapinfo's COM object.</param>
 /// <example>
 /// <code>
 /// COMMapinfo olemapinfo = new COMMapinfo(exsitingMapinfoInstance);
 /// DependencyResolver resolver = new DependencyResolver();
 /// resolver.Register(typeof(IMapinfoWrapper), olemapinfo);
 /// IoC.Initialize(resolver);
 /// </code>
 /// </example>
 internal COMMapinfo(DMapInfo mapinfoInstance)
 {
     this.mapinfoinstance = mapinfoInstance;
 }
示例#18
0
 private MapinfoWrapper(DMapInfo mapInfo)
 {
     this.mapinfo = mapInfo;
 }
 /// <summary>
 /// <b>This is only provided to allow for testing and should not be used outside of a test, if you need to
 /// create a new instance of Mapinfo please use <see cref="MapinfoSessionManager"/>
 ///
 /// <para>Initializes a new instance of the <see cref="ComMapInfo"/> class, which holds
 /// an instance of a currently running instance of Mapinfo's COM object.</para>
 /// <param name="mapinfoInstance">A currently running instance of Mapinfo's COM object.</param>
 public ComMapInfo(DMapInfo mapinfoInstance)
 {
     this.mapinfoinstance = mapinfoInstance;
 }