Exemple #1
0
        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()));
                }
            }
        }
Exemple #2
0
        private void EditCase(int recordId)
        {
            Epi.Enter.EnterUIConfig uiConfig = Core.Common.GetCaseConfig(DataHelper.CaseForm, DataHelper.LabForm);

            Epi.Windows.Enter.EnterMainForm emf = new Epi.Windows.Enter.EnterMainForm(this.view.Project, this.view, uiConfig);

            emf.LoadRecord(recordId);

            emf.RecordSaved += new Epi.SaveRecordEventHandler(mainWindow.emfCases_RecordSaved);
            emf.ShowDialog();
            emf.RecordSaved -= new Epi.SaveRecordEventHandler(mainWindow.emfCases_RecordSaved);
        }
        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);
                        //--

                        GeoCoordinateWatcher locationWatcher;
                        locationWatcher = new GeoCoordinateWatcher();

                        locationWatcher.PositionChanged += (sender, e) =>
                        {
                            GeoCoordinate coordinate = e.Position.Location;
                            mainForm.LastPosition = e.Position;
                            string locationText = "";
                            if (e.Position.Location.IsUnknown == false)
                            {
                                locationText = string.Format("{0:0.0000000},{1:0.0000000},{2:h:mm:ss tt}", coordinate.Latitude, coordinate.Longitude, e.Position.Timestamp.DateTime);
                            }

                            mainForm.UpdateAppSpecificInfo(locationText);
                        };

                        locationWatcher.StatusChanged += (sender, e) =>
                        {
                            if (e.Status == GeoPositionStatus.NoData)
                            {
                                mainForm.LastPosition = null;
                            }
                        };

                        locationWatcher.Start();

                        System.Windows.Forms.Application.Run(mainForm);
                    }

                    mainForm = null;
                }
                catch (Exception baseException)
                {
                    MsgBox.ShowError(string.Format("Error: \n {0}", baseException.ToString()));
                }
            }
        }