Пример #1
0
 private void OpenProject(string projectFile)
 {
     tsMainProgressBar.Visible = true;
     try {
         tsMainProgressBar.Maximum = 0;
         //foreach (string dir in System.IO.Directory.GetDirectories(System.IO.Path.GetDirectoryName(projectFile), "spectra", System.IO.SearchOption.AllDirectories))
         //    tsMainProgressBar.Maximum += System.IO.Directory.GetFiles(dir, "*.*", System.IO.SearchOption.TopDirectoryOnly).Length;
         //}
         IProject project = AvailableAssemblies.getProject(projectFile, new ReturnAttributeValue(delegate(string name, string value) {
             if (name == "spectraCount")
             {
                 tsMainProgressBar.Maximum = int.Parse(value);
             }
         }));
         CreateProjectWindow(project);
         tsMainProgressBar.Value = tsMainProgressBar.Maximum;
         //adding to recent projects list
         refreshRecentProjectsList(projectFile);
         appendProjectToRecoveryFile(projectFile);
     } catch (SpectrumLoadException sle) {
         MessageBox.Show(sle.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     } catch (System.Reflection.TargetInvocationException tiex) {
         Exception finalException = Evel.share.Utilities.findException(tiex);
         if (finalException.GetType() == typeof(FileNotFoundException) ||
             finalException.GetType() == typeof(SpectrumLoadException) ||
             finalException.GetType() == typeof(IOException))
         {
             MessageBox.Show(finalException.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             ExceptionSendForm exForm = new ExceptionSendForm(finalException);
             exForm.ShowDialog();
         }
     } catch (System.IO.FileNotFoundException fnfe) {
         MessageBox.Show(fnfe.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     } catch (System.IO.DirectoryNotFoundException dnfe) {
         MessageBox.Show(dnfe.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     } catch (Exception ex) {
         //System.Windows.Forms.MessageBox.Show(ex.Message, "LT10", MessageBoxButtons.OK, MessageBoxIcon.Error);
         ExceptionSendForm exForm = new ExceptionSendForm(ex);
         exForm.ShowDialog();
     }
     tsMainProgressBar.Visible = false;
 }
Пример #2
0
        public void CreateNewProject(WizardEventHandler wizardEventHandler)
        {
            NewProjectDialog npd = new NewProjectDialog(null);

            npd = new NewProjectDialog(null);
            if (this.CurrentWizard != null)
            {
                this.CurrentWizard.DialogOpened(npd);
            }
            toolStripStatusLabel.Text = "Creating new project";
            if (npd.ShowDialog() == DialogResult.OK)
            {
                //OpeningSpectraCount = 0;
                tsMainProgressBar.Maximum = 0;
                tsMainProgressBar.Visible = true;
                //toolStripStatusLabel.Text = String.Format("Creating Project {0}...", npd.projectNameTextBox.Text);
                foreach (SpectraContainerDescription scd in npd.ContainerDescriptions)
                {
                    tsMainProgressBar.Maximum += scd.spectraPaths.Length;
                }
                string   defaultProjectName = getDefaultProjectName();
                IProject project            = AvailableAssemblies.getProject(
                    npd.ProjectType.ToString(),
                    new object[] {
                    defaultProjectName,     //npd.projectNameTextBox.Text,
                    npd.ContainerDescriptions
                });
                //project.Save(System.IO.Path.Combine(npd.projectPathTextBox.Text, npd.projectNameTextBox.Text), false);
                ProjectForm form = CreateProjectWindow(project);
                form.NotSavedChanges      = true;
                tsMainProgressBar.Visible = false;
                if (wizardEventHandler != null)
                {
                    wizardEventHandler(this, new WizardEventArgs(form, WizardEventType.Created));
                }
            }
            if (CurrentWizard != null)
            {
                CurrentWizard.DialogClosed();
            }
            npd.Dispose();
            toolStripStatusLabel.Text = "Ready";
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Program for testing NEED capabilities. (31 May 2011)");
            CultureInfo culture = new CultureInfo(CultureInfo.CurrentCulture.LCID);

            culture.NumberFormat.NumberDecimalSeparator = ".";
            Thread.CurrentThread.CurrentCulture         = culture;
            AvailableAssemblies.LibraryDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
            ReturnAttributeValue rav = null;

            try {
                if (args.Length == 1)
                {
                    project = AvailableAssemblies.getProject(args[0], rav);
                }
            } catch (Exception) {
                Console.WriteLine("Project not found");
            }
            string command = "";

            string[] commandArgs;
            int      docId = 0;

            while ((command = GetCommand(out commandArgs)) != "exit")
            {
                try {
                    switch (command)
                    {
                    case "commands": Console.WriteLine("load\nunload\ntest1\nIntsChange\ndocuments\nprompt\nfsearch\nssearch\nspecdb"); break;

                    case "load": project = AvailableAssemblies.getProject(commandArgs[1], rav); break;

                    case "unload": project = null; break;

                    case "test1": Test.Run <Test1>(commandArgs, project); break;

                    case "IntsChange": Test.Run <IntsChangeTest>(commandArgs, project); break;

                    case "prompt": Test.Run <PromptTest>(commandArgs, project); break;

                    case "fsearch": Test.Run <SearchTest>(commandArgs, project); break;

                    case "ssearch": Test.Run <SeriesSearchTest>(commandArgs, project); break;

                    case "specdb": Test.Run <ParametersDBTest>(commandArgs, project); break;

                    case "documents":
                        if (project != null)
                        {
                            foreach (ISpectraContainer container in project.Containers)
                            {
                                Console.WriteLine("\t{0}: {1}\t{2}\n\t\t{3}\n\t\tSpectra: {4}", docId++, container.Name, (container.Enabled) ? "" : "Disabled", container.Model.Name, container.Spectra[0].Name + " (" + (container.Spectra.Count - 1).ToString() + " more)");
                            }
                        }
                        else
                        {
                            Console.WriteLine("No project is loaded!");
                        }
                        break;

                    default: Console.WriteLine("Unknown command"); break;
                    }
                } catch (IndexOutOfRangeException) {
                    Console.WriteLine("This command requires arguments!");
                    //System.Diagnostics.Debug.WriteLine(String.Format("{0}\n{1}", e.Message, e.StackTrace));
                } catch (TestException e) {
                    Console.WriteLine("Test has thrown exception:\n{0}\n{1}", e.InnerException.Message, e.InnerException.StackTrace);
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                }
            }
        }