private static void Main(string[] args) { var parser = new ArgumentParser(args); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); PreferredSiteList.InitCulture(); //Init the Maestro connection registry with additional providers from ConnectionProviders.xml ConnectionProviderRegistry.InitRegistry(); IServerConnection conn = null; if (!parser.IsDefined(CommandLineArguments.Provider) || !parser.IsDefined(CommandLineArguments.Session)) { var login = new LoginDialog(); if (login.ShowDialog() == System.Windows.Forms.DialogResult.OK) { conn = login.Connection; } } else { string prov = parser.GetValue(CommandLineArguments.Provider); conn = ConnectionProviderRegistry.CreateConnection(prov, parser.GetAllArgumentsWithValues()); } if (conn == null) { return; } Application.Run(new MainForm(new EditorServiceImpl(conn))); }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); string lang = PreferredSiteList.InitCulture(); //var btw = BroadcastTextWriter.Instance; // Logging service by default uses System.Diagnostics.Debug. Re-route this // to our writer //var wfmsg = WinFormsMessageService.Instance; //ServiceManager.LoggingService = new TextWriterLoggingService(btw); //ServiceManager.MessageService = wfmsg; ServiceManager.Instance = new MaestroServiceManager(); LoggingService.Info("Application start"); //NOXLATE // Setup Platform.ini if required if (!Platform.IsRunningOnMono) { if (!File.Exists("Platform.ini") && File.Exists("LocalConfigure.exe")) //NOXLATE { var proc = new ProcessStartInfo("LocalConfigure.exe"); if (Environment.OSVersion.Version.Major >= 6) { proc.Verb = "runas"; //NOXLATE } var p = Process.Start(proc); p.WaitForExit(); } } if (Platform.IsRunningOnMono) { LoggingService.Info(Strings.Warn_Mono); } //Init our default set of resource validators ResourceValidatorLoader.LoadStockValidators(); AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(CurrentDomain_AssemblyLoad); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); // Get a reference to the entry assembly (Startup.exe) Assembly exe = typeof(Program).Assembly; // Set the root path of our application. ICSharpCode.Core looks for some other // paths relative to the application root: // "data/resources" for language resources, "data/options" for default options FileUtility.ApplicationRootPath = Path.GetDirectoryName(exe.Location); LoggingService.Info("Starting core services..."); //NOXLATE // CoreStartup is a helper class making starting the Core easier. // The parameter is used as the application name, e.g. for the default title of // MessageService.ShowMessage() calls. CoreStartup coreStartup = new CoreStartup("MapGuide Maestro"); //NOXLATE // It is also used as default storage location for the application settings: // "%Application Data%\%Application Name%", but you can override that by setting c.ConfigDirectory // #1955: Each version of Maestro from here on in will store their user data under // %APPDATA%\Maestro-x.y coreStartup.ConfigDirectory = MaestroPaths.BasePath; // Specify the name of the application settings file (.xml is automatically appended) coreStartup.PropertiesName = "AppProperties"; //NOXLATE // Initializes the Core services (ResourceService, PropertyService, etc.) coreStartup.StartCoreServices(); LoggingService.Info("Looking for AddIns..."); //NOXLATE // Searches for ".addin" files in the application directory. coreStartup.AddAddInsFromDirectory(Path.Combine(FileUtility.ApplicationRootPath, "AddIns")); //NOXLATE // Searches for a "AddIns.xml" in the user profile that specifies the names of the // add-ins that were deactivated by the user, and adds "external" AddIns. coreStartup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); //NOXLATE // Searches for add-ins installed by the user into his profile directory. This also // performs the job of installing, uninstalling or upgrading add-ins if the user // requested it the last time this application was running. coreStartup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), //NOXLATE Path.Combine(PropertyService.ConfigDirectory, "AddIns")); //NOXLATE ResourceService.Language = lang; LoggingService.Info("Loading AddInTree..."); //NOXLATE // Now finally initialize the application. This parses the ".addin" files and // creates the AddIn tree. It also automatically runs the commands in // "/Workspace/Autostart" coreStartup.RunInitialization(); LoggingService.Info("Initializing Workbench..."); //NOXLATE // Workbench is our class from the base project, this method creates an instance // of the main form. ServiceRegistry.Initialize(() => { //DIRTY DIRTY HACK: I'm getting tired of Mono workarounds. But background resource //preview preparation has a chance of clogging up if the main window is initially maximized Workbench.InitializeWorkbench(new WorkbenchInitializer(!Platform.IsRunningOnMono)); try { LoggingService.Info("Running application..."); //NOXLATE // Workbench.Instance is the instance of the main form, run the message loop. Application.Run(Workbench.Instance); } finally { try { // Save changed properties PropertyService.Save(); } catch (Exception ex) { ErrorDialog.Show(Strings.Error_StoreProperties, ex.ToString()); } } LoggingService.Info("Application shutdown"); //NOXLATE }); }
public static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.DoEvents(); PreferredSiteList.InitCulture(); //Init the Maestro connection registry with additional providers from ConnectionProviders.xml ConnectionProviderRegistry.InitRegistry(); //Parameters: //mapagent= //username= //password= //mapdefinition= //scaleindex=0,1,2,3,4,5 //basegroups="x","y" //extentoverride=minx,miny,maxx,maxy bool cmdLineMode = false; string mapdefinitions = string.Empty; string scaleindex = string.Empty; string basegroups = string.Empty; string limitRows = string.Empty; string limitCols = string.Empty; string tileWidth = string.Empty; string tileHeight = string.Empty; string DPI = string.Empty; string metersPerUnit = string.Empty; IEnvelope overrideExtents = null; List <string> largs = new List <string>(args); Dictionary <string, string> opts = CommandLineParser.ExtractOptions(largs); if (opts.ContainsKey(TileRunParameters.MAPDEFINITIONS)) { mapdefinitions = opts[TileRunParameters.MAPDEFINITIONS]; } if (opts.ContainsKey(TileRunParameters.SCALEINDEX)) { scaleindex = opts[TileRunParameters.SCALEINDEX]; } if (opts.ContainsKey(TileRunParameters.BASEGROUPS)) { basegroups = opts[TileRunParameters.BASEGROUPS]; } if (opts.ContainsKey(TileRunParameters.LIMITROWS)) { limitRows = opts[TileRunParameters.LIMITROWS]; } if (opts.ContainsKey(TileRunParameters.LIMITCOLS)) { limitCols = opts[TileRunParameters.LIMITCOLS]; } if (opts.ContainsKey(TileRunParameters.TILEWIDTH)) { tileWidth = opts[TileRunParameters.TILEWIDTH]; } if (opts.ContainsKey(TileRunParameters.TILEHEIGHT)) { tileHeight = opts[TileRunParameters.TILEHEIGHT]; } if (opts.ContainsKey(TileRunParameters.DOTSPERINCH)) { DPI = opts[TileRunParameters.DOTSPERINCH]; } if (opts.ContainsKey(TileRunParameters.METERSPERUNIT)) { metersPerUnit = opts[TileRunParameters.METERSPERUNIT]; } if (opts.ContainsKey(TileRunParameters.EXTENTOVERRIDE)) { string[] parts = opts[TileRunParameters.EXTENTOVERRIDE].Split(','); if (parts.Length == 4) { double minx; double miny; double maxx; double maxy; if ( double.TryParse(parts[0], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out minx) && double.TryParse(parts[1], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out miny) && double.TryParse(parts[2], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out maxx) && double.TryParse(parts[3], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out maxy) ) { overrideExtents = ObjectFactory.CreateEnvelope(minx, miny, maxx, maxy); } } } if (largs.IndexOf("batch") >= 0 || largs.IndexOf("/batch") >= 0 || largs.IndexOf("commandline") >= 0 || largs.IndexOf("/commandline") >= 0) { cmdLineMode = true; } try { Console.Clear(); m_loggableProgress = true; } catch { hasConsole = false; m_loggableProgress = false; } IServerConnection connection = null; string[] maps = mapdefinitions.Split(','); string username = string.Empty; string password = string.Empty; if (opts.ContainsKey(TileRunParameters.PROVIDER) && opts.ContainsKey(TileRunParameters.CONNECTIONPARAMS)) { var initP = ConnectionProviderRegistry.ParseConnectionString(opts[TileRunParameters.CONNECTIONPARAMS]); connection = ConnectionProviderRegistry.CreateConnection(opts[TileRunParameters.PROVIDER], initP); } else { if (cmdLineMode) { throw new ArgumentException(string.Format(Strings.MissingRequiredConnectionParameters, TileRunParameters.PROVIDER, TileRunParameters.CONNECTIONPARAMS)); } var frm = new LoginDialog(); if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } username = frm.Username; password = frm.Password; connection = frm.Connection; } if (connection == null) { if (opts.ContainsKey(TileRunParameters.PROVIDER) && opts.ContainsKey(TileRunParameters.CONNECTIONPARAMS)) { var initP = ConnectionProviderRegistry.ParseConnectionString(opts[TileRunParameters.CONNECTIONPARAMS]); connection = ConnectionProviderRegistry.CreateConnection(opts[TileRunParameters.PROVIDER], initP); } else { throw new ArgumentException(string.Format(Strings.MissingRequiredConnectionParameters, TileRunParameters.PROVIDER, TileRunParameters.CONNECTIONPARAMS)); } } if (!cmdLineMode) { SetupRun sr = null; if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { sr = new SetupRun(username, password, connection, maps, opts); } else { sr = new SetupRun(connection, maps, opts); } using (sr) { sr.ShowDialog(); return; } } TilingRunCollection bx = new TilingRunCollection(connection); int x; if (!string.IsNullOrEmpty(limitCols) && int.TryParse(limitCols, out x)) { bx.LimitCols(x); } if (!string.IsNullOrEmpty(limitRows) && int.TryParse(limitRows, out x)) { bx.LimitRows(x); } if (!string.IsNullOrEmpty(tileWidth) && int.TryParse(tileWidth, out x)) { bx.Config.TileWidth = x; } if (!string.IsNullOrEmpty(tileHeight) && int.TryParse(tileHeight, out x)) { bx.Config.TileHeight = x; } if (!string.IsNullOrEmpty(DPI) && int.TryParse(DPI, out x)) { bx.Config.DPI = x; } double d; if (!string.IsNullOrEmpty(metersPerUnit) && double.TryParse(metersPerUnit, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.CurrentCulture, out d)) { bx.Config.MetersPerUnit = d; } if (opts.ContainsKey(TileRunParameters.RANDOMTILEORDER)) { bx.Config.RandomizeTileSequence = true; } if (opts.ContainsKey(TileRunParameters.THREADCOUNT) && int.TryParse(opts[TileRunParameters.THREADCOUNT], out x) && x > 0) { bx.Config.ThreadCount = x; } //Now that all global parameters are set, we can now add the map definitions bx.AddMapDefinitions(maps); //basegroups must be set in each mapdefinition if (!string.IsNullOrEmpty(basegroups)) { List <string> groups = new List <string>(); foreach (string s in basegroups.Split(',')) { string f = s; if (f.StartsWith("\"")) { f = f.Substring(1); } if (f.EndsWith("\"")) { f = f.Substring(0, f.Length - 1); } groups.Add(f); } bx.SetGroups(groups.ToArray()); } if (overrideExtents != null) { List <int> scales = new List <int>(); int tmp; foreach (string s in scaleindex.Split(',')) { if (int.TryParse(s, out tmp)) { scales.Add(tmp); } } foreach (MapTilingConfiguration bm in bx.Maps) { bm.SetScalesAndExtend(scales.ToArray(), overrideExtents); } } else if (!string.IsNullOrEmpty(scaleindex)) { List <int> scales = new List <int>(); int tmp; foreach (string s in scaleindex.Split(',')) { if (int.TryParse(s, out tmp)) { scales.Add(tmp); } } bx.SetScales(scales.ToArray()); } if (!cmdLineMode) { Progress pg = new Progress(bx); pg.ShowDialog(); } else { bx.BeginRenderingMap += OnBeginRenderingMap; bx.FinishRenderingMap += OnFinishRenderingMap; bx.BeginRenderingGroup += OnBeginRenderingGroup; bx.FinishRenderingGroup += OnFinishRenderingGroup; bx.BeginRenderingScale += OnBeginRenderingScale; bx.FinishRenderingScale += OnFinishRenderingScale; bx.BeginRenderingTile += OnBeginRenderingTile; bx.FinishRenderingTile += OnFinishRenderingTile; bx.FailedRenderingTile += OnFailedRenderingTile; mapCount = 0; lastUpdate = DateTime.Now; bx.RenderAll(); } }