Beispiel #1
0
        public static void Main()
        {
            NotebookTempFiles.Init();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var clickOnceFiles = AppDomain.CurrentDomain.SetupInformation.ActivationArguments?.ActivationData ?? new string[0];

            foreach (var extraFilePath in clickOnceFiles.Skip(1))
            {
                Process.Start(Application.ExecutablePath, $"\"{extraFilePath}");
            }

            string filePath;
            bool   isNew;

            if (clickOnceFiles.Any())
            {
                filePath = clickOnceFiles.First();
                isNew    = false;
            }
            else if (Environment.GetCommandLineArgs().Length == 2)
            {
                filePath = Environment.GetCommandLineArgs()[1];
                isNew    = false;
            }
            else
            {
                filePath = NotebookTempFiles.GetTempFilePath(".sqlnb");
                isNew    = true;
            }

            if (!File.Exists(filePath))
            {
                MessageBox.Show("File does not exist: " + filePath, "SQL Notebook", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try {
                Application.Run(new MainForm(filePath, isNew));
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "SQL Notebook", MessageBoxButtons.OK, MessageBoxIcon.Error);
            } finally {
                NotebookTempFiles.DeleteFiles();
            }
        }
Beispiel #2
0
 public TempFile(string extension)
 {
     FilePath = NotebookTempFiles.GetTempFilePath(extension);
 }