Пример #1
0
        static void Main()
        {
            ModelSetup.Initialize();
            Application.EnableVisualStyles();
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.SetCompatibleTextRenderingDefault(false);

            //Register previewers
            var urlLauncher = new OurUrlLauncher();
            ResourcePreviewerFactory.RegisterPreviewer("Maestro.Http", new LocalMapPreviewer(new DefaultResourcePreviewer(urlLauncher), urlLauncher)); //NOXLATE
            //A stub previewer does nothing, but will use local map previews for applicable resources if the configuration
            //property is set
            ResourcePreviewerFactory.RegisterPreviewer("Maestro.LocalNative", new LocalMapPreviewer(new StubPreviewer(), urlLauncher)); //NOXLATE

            //Can't use this code, it requires a call to MgdPlatform.Initialize which we can't call indirectly :(
            /*
            //Try to tap into mg-desktop coordinate system services if possible
            try
            {
                var provEntry = ConnectionProviderRegistry.FindProvider("Maestro.Local"); //NOXLATE
                if (provEntry != null)
                {
                    string path = provEntry.AssemblyPath;
                    Assembly asm = Assembly.LoadFrom(path); //NOXLATE
                    if (asm != null)
                    {
                        Type mpuType = asm.GetType("OSGeo.MapGuide.MaestroAPI.Native.LocalNativeMpuCalculator"); //NOXLATE
                        Type catType = asm.GetType("OSGeo.MapGuide.MaestroAPI.Native.LocalNativeCoordinateSystemCatalog"); //NOXLATE

                        if (mpuType != null && catType != null)
                        {
                            IMpuCalculator calc = (IMpuCalculator)Activator.CreateInstance(mpuType);
                            ICoordinateSystemCatalog csCatalog = (ICoordinateSystemCatalog)Activator.CreateInstance(catType);

                            CsHelper.DefaultCalculator = calc;
                            CsHelper.DefaultCatalog = csCatalog;
                            Debug.WriteLine("Using mg-desktop coordinate system services where possible");
                        }
                    }
                }
                else
                {
                    Debug.WriteLine("No mg-desktop coordinate system services to tap into. Using default services");
                }
            }
            catch (Exception ex)
            {

            }
             */

            var login = new Login.LoginDialog();
            if (login.ShowDialog() == DialogResult.OK)
            {
                var conn = login.Connection;

                //TODO: Validate connection capabilities
                Application.Run(new MainForm(conn));
            }
        }
Пример #2
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.SetCompatibleTextRenderingDefault(false);

            //Init the Maestro connection registry with additional providers from ConnectionProviders.xml
            ConnectionProviderRegistry.InitRegistry();

            //Register previewers
            var urlLauncher = new OurUrlLauncher();

            ResourcePreviewerFactory.RegisterPreviewer("Maestro.Http", new LocalMapPreviewer(new DefaultResourcePreviewer(urlLauncher), urlLauncher, null)); //NOXLATE
            //A stub previewer does nothing, but will use local map previews for applicable resources if the configuration
            //property is set
            ResourcePreviewerFactory.RegisterPreviewer("Maestro.LocalNative", new LocalMapPreviewer(new StubPreviewer(), urlLauncher, null)); //NOXLATE

            //Can't use this code, it requires a call to MgdPlatform.Initialize which we can't call indirectly :(

            /*
             * //Try to tap into mg-desktop coordinate system services if possible
             * try
             * {
             *  var provEntry = ConnectionProviderRegistry.FindProvider("Maestro.Local"); //NOXLATE
             *  if (provEntry != null)
             *  {
             *      string path = provEntry.AssemblyPath;
             *      Assembly asm = Assembly.LoadFrom(path); //NOXLATE
             *      if (asm != null)
             *      {
             *          Type mpuType = asm.GetType("OSGeo.MapGuide.MaestroAPI.Native.LocalNativeMpuCalculator"); //NOXLATE
             *          Type catType = asm.GetType("OSGeo.MapGuide.MaestroAPI.Native.LocalNativeCoordinateSystemCatalog"); //NOXLATE
             *
             *          if (mpuType != null && catType != null)
             *          {
             *              IMpuCalculator calc = (IMpuCalculator)Activator.CreateInstance(mpuType);
             *              ICoordinateSystemCatalog csCatalog = (ICoordinateSystemCatalog)Activator.CreateInstance(catType);
             *
             *              CsHelper.DefaultCalculator = calc;
             *              CsHelper.DefaultCatalog = csCatalog;
             *              Debug.WriteLine("Using mg-desktop coordinate system services where possible");
             *          }
             *      }
             *  }
             *  else
             *  {
             *      Debug.WriteLine("No mg-desktop coordinate system services to tap into. Using default services");
             *  }
             * }
             * catch (Exception ex)
             * {
             * }
             */

            var login = new Login.LoginDialog();

            if (login.ShowDialog() == DialogResult.OK)
            {
                var conn = login.Connection;

                //TODO: Validate connection capabilities
                Application.Run(new MainForm(conn));
            }
        }