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; }
static void Main(string[] args) { //clean updates folder if any (proper entry in registry try { if (File.Exists(UpdatesFile)) { using (StreamReader reader = new StreamReader(UpdatesFile)) { string updatesSetup = reader.ReadToEnd().Trim(); string updatesPath = Path.GetDirectoryName(updatesSetup); Directory.Delete(updatesPath, true); } File.Delete(UpdatesFile); } } catch (Exception) { MessageBox.Show("Couldn't perform a clean up after updating LT10.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } bool restart = false; System.Diagnostics.Debug.Listeners.Clear(); System.Diagnostics.Debug.Listeners.Add( new System.Diagnostics.TextWriterTraceListener(@"d:\devel\ltvsneed\lt10search.log")); do { try { if (restart) { _mainWindow.CloseForm(); _mainWindow = null; //Application.Exit(); } //if (!restart) { CultureInfo culture = new CultureInfo(CultureInfo.CurrentCulture.LCID); culture.NumberFormat.NumberDecimalSeparator = "."; AvailableAssemblies.LibraryDir = Application.StartupPath; Application.CurrentCulture = culture; Application.EnableVisualStyles(); _args = args; Application.Run(MainWindow); //} else { // _mainWindow = null; // Application.Exit(); // Application.Run(MainWindow); //} restart = false; } catch (Exception e) { Evel.gui.ExceptionSendForm form = new ExceptionSendForm(Evel.share.Utilities.findException(e)); form.ShowDialog(); restart = true; } } while (restart); if (Lt10Updater.DownloadedExecutablePath != string.Empty) { using (StreamWriter writer = new StreamWriter(UpdatesFile, false)) { writer.WriteLine(Lt10Updater.DownloadedExecutablePath); } try { System.Diagnostics.Process.Start(Lt10Updater.DownloadedExecutablePath, null); } catch (Exception e) { MessageBox.Show(String.Format("Installation aborted. {0}", e.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }