static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); if (LoadConfiguration(args)) { Configuration.Environment = ExecutionEnvironment.WindowsApplication; ICommandLine commandLine = new CommandLine(args); string titleArgument = commandLine.GetArgument("title"); string projectPath = commandLine.GetArgument("project"); string viewName = commandLine.GetArgument("view"); string recordId = commandLine.GetArgument("record"); try { Epi.Windows.Enter.EnterMainForm mainForm = new Epi.Windows.Enter.EnterMainForm(); if (!mainForm.IsDisposed) { mainForm.Show(); if (mainForm.WindowState == FormWindowState.Minimized) { mainForm.WindowState = FormWindowState.Normal; } mainForm.Activate(); mainForm.Text = string.IsNullOrEmpty(titleArgument) ? mainForm.Text : titleArgument; if (!string.IsNullOrEmpty(projectPath)) { Project project = new Project(projectPath); mainForm.CurrentProject = project; if (string.IsNullOrEmpty(recordId)) { mainForm.FireOpenViewEvent(project.Views[viewName]); } else { mainForm.FireOpenViewEvent(project.Views[viewName], recordId); } } //--2225 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); //-- System.Windows.Forms.Application.Run(mainForm); } mainForm = null; } catch (Exception baseException) { MsgBox.ShowError(string.Format("Error: \n {0}", baseException.ToString())); } } }
static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); if (LoadConfiguration()) { try { Configuration.Environment = ExecutionEnvironment.WindowsApplication; string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string executablePath = System.IO.Path.Combine(path, "EpiInfo.exe"); Epi.Windows.MakeView.Forms.MakeViewMainForm makeViewMainForm = new Epi.Windows.MakeView.Forms.MakeViewMainForm(); ICommandLine commandLine = new CommandLine(args); string titleArgument = commandLine.GetArgument("title"); string projectPath = commandLine.GetArgument("project"); string viewName = commandLine.GetArgument("view"); if (titleArgument != null) { makeViewMainForm.Text = titleArgument; } if (! string.IsNullOrEmpty(projectPath)) { makeViewMainForm.LoadViewFromCommandLine(projectPath, viewName); } else { if (!makeViewMainForm.IsDisposed) { makeViewMainForm.Show(); if (makeViewMainForm.WindowState == FormWindowState.Minimized) { makeViewMainForm.WindowState = FormWindowState.Normal; } makeViewMainForm.Activate(); } if (args.Length > 0 && args[0] is string && System.IO.File.Exists(args[0])) { makeViewMainForm.GetTemplate(args[0]); } } System.Windows.Forms.Application.Run(makeViewMainForm); makeViewMainForm = null; } catch(Exception ex) { MsgBox.ShowException(ex); } } }
static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); if (LoadConfiguration(args)) { Configuration.Environment = ExecutionEnvironment.WindowsApplication; ICommandLine commandLine = new CommandLine(args); //string titleArgument = commandLine.GetArgument("title"); string scriptPath = commandLine.GetArgument("script"); string autorun = commandLine.GetArgument("autorun"); string smallsize = commandLine.GetArgument("smallsize"); try { Epi.Windows.ImportExport.Dialogs.PackageForTransportDialog M = null; bool useSmallSize = false; if (!string.IsNullOrEmpty(smallsize) && smallsize.ToLower().Equals("true")) { useSmallSize = true; } if (!string.IsNullOrEmpty(scriptPath)) { M = new Epi.Windows.ImportExport.Dialogs.PackageForTransportDialog(scriptPath, useSmallSize); } else { M = new Epi.Windows.ImportExport.Dialogs.PackageForTransportDialog(useSmallSize); } if (!string.IsNullOrEmpty(autorun) && autorun.ToLower().Equals("true") && M != null) { M.CloseOnFinish = true; M.StartCreatePackage(); } //if (!string.IsNullOrEmpty(projectPath)) //{ // Project p = new Project(projectPath); // M.FireOpenViewEvent(p.Views[viewName]); //} //else //{ if (!M.IsDisposed) { M.Show(); if (M.WindowState == FormWindowState.Minimized) { M.WindowState = FormWindowState.Normal; } M.Activate(); } //} System.Windows.Forms.Application.Run(M); M = null; } catch (Exception ex) { //MsgBox.ShowError(SharedStrings.WARNING_APPLICATION_RUNNING); MsgBox.ShowError(string.Format("Error: \n {0}", ex.ToString())); } finally { } } }
static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); if (LoadConfiguration(args)) { Configuration.Environment = ExecutionEnvironment.WindowsApplication; ICommandLine commandLine = new CommandLine(args); //string titleArgument = commandLine.GetArgument("title"); string packagePath = commandLine.GetArgument("package"); string projectPath = commandLine.GetArgument("project"); string viewName = commandLine.GetArgument("view"); string autorun = commandLine.GetArgument("autorun"); string merge = commandLine.GetArgument("merge"); try { Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog M = null; Project destinationProject = null; View destinationView = null; Epi.ImportExport.DataMergeType mergeType = Epi.ImportExport.DataMergeType.UpdateAndAppend; if (!string.IsNullOrEmpty(merge)) { switch (merge.ToLower()) { case "1": mergeType = Epi.ImportExport.DataMergeType.UpdateOnly; break; case "2": mergeType = Epi.ImportExport.DataMergeType.AppendOnly; break; default: mergeType = Epi.ImportExport.DataMergeType.UpdateAndAppend; break; } } M = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(); if (!string.IsNullOrEmpty(projectPath) && !(string.IsNullOrEmpty(viewName))) { destinationProject = new Project(projectPath); if (destinationProject.Views.Contains(viewName)) { destinationView = destinationProject.Views[viewName]; } } if (!string.IsNullOrEmpty(packagePath) && destinationView != null) { M = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(destinationView, packagePath, mergeType); } else if(destinationView != null) { M = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(destinationView, mergeType); } if (!string.IsNullOrEmpty(autorun) && autorun.ToLower().Equals("true") && M != null) { M.CloseOnFinish = true; M.StartImportPackage(); } //if (!string.IsNullOrEmpty(projectPath)) //{ // Project p = new Project(projectPath); // M.FireOpenViewEvent(p.Views[viewName]); //} //else //{ if (!M.IsDisposed) { M.Show(); if (M.WindowState == FormWindowState.Minimized) { M.WindowState = FormWindowState.Normal; } M.Activate(); } //} System.Windows.Forms.Application.Run(M); M = null; } catch (Exception ex) { //MsgBox.ShowError(SharedStrings.WARNING_APPLICATION_RUNNING); MsgBox.ShowError(string.Format("Error: \n {0}", ex.ToString())); } finally { } } }
/// <summary> /// Instantiate and load application module using supplied command line arguments /// </summary> /// <param name="commandLineArguments">The command line arguments</param> private void StartInternal(string[] commandLineArguments) { IServiceContainer serviceContainer = (IServiceContainer)this.GetService(typeof(IServiceContainer)); this.PublishServices(serviceContainer, false); this.CreateInterProcessCommunicationServer(3); System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.DoEvents(); // heal application, create default folders, etc. ApplicationManager.CreateWindowsResources(); //set thread culture System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Configuration.GetNewInstance().Settings.Language); // advertise the execution environment Configuration.Environment = ExecutionEnvironment.WindowsApplication; Configuration.MasterServiceProvider = this; ICommandLine commandLine = new CommandLine(commandLineArguments); //TODO: load default module from configuration string moduleToLoad = "Menu"; // parse Command Line string moduleArgument = commandLine.GetArgument("l"); if (moduleArgument != null) { moduleToLoad = moduleArgument; } try { // launch module IModule module = this.CreateModuleInstance(moduleToLoad); module.Load(this, commandLine); } catch (Exception ex) { throw new ApplicationException(string.Format(SharedStrings.CANNOT_LOAD_APPLICATION, moduleToLoad), ex); } finally { } }