Ejemplo n.º 1
0
        private void NewDatabaseClick(object sender, EventArgs e)
        {
            SaveFileDialog fd = new SaveFileDialog();

            fd.Title      = "Create a new Database";
            fd.DefaultExt = "*.pdb";
            fd.Filter     = "Pisces database (*.pdb)|*.pdb";
            if (fd.ShowDialog() == DialogResult.OK)
            {
                explorer1.Open(fd.FileName, true);
                DatabaseChanged();
                UserPreference.Save("fileName", fd.FileName);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Logger.EnableLogger(true);
            var x = HdbPoet.Hdb.Instance; // force this assembly to load.

            try
            {
                string fileName = "";
                if (args.Length == 1)
                {
                    fileName = args[0];
                    if (!File.Exists(fileName))
                    {
                        MessageBox.Show("Could not open file '" + fileName + "'");
                        return;
                    }
                }

                else if (UserPreference.Lookup("fileName") != "" &&
                         File.Exists(UserPreference.Lookup("fileName")) &&
                         Path.GetExtension(UserPreference.Lookup("fileName")) != ".sdf")
                {
                    fileName = UserPreference.Lookup("fileName");
                }
                else
                {// open default database
                    fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\tsdatabase.pdb";
                }

                if (!File.Exists(fileName))
                {
                    SQLiteServer.CreateNewDatabase(fileName);
                }

                HydrometInfoUtility.SetDefaultHydrometServer();


                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.ThreadExit      += new EventHandler(Application_ThreadExit);
                Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
                //Application.Idle += new EventHandler(Application_Idle);
                //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);


                explorer = new PiscesSettings(new ExplorerView());
                // explorer.Database

                explorer.Open(fileName);
                db = explorer.Database;

                piscesForm1 = new PiscesForm(explorer);



                piscesForm1.FormClosed += new FormClosedEventHandler(explorerForm1_FormClosed);
                //Pisces2 p2 = new Pisces2(explorer);
                //p2.FormClosed += new FormClosedEventHandler(explorerForm1_FormClosed);

                Application.Run(piscesForm1);
                explorer.Database.SaveSettingsToDatabase(explorer.TimeWindow);
                //db.SaveSettingsToDatabase(explorer.TimeWindow);

                PostgreSQL.ClearAllPools();

                FileUtility.CleanTempPath();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString());
            }
        }