Exemple #1
0
        public void saveProject(String filename, BackgroundWorker worker)
        {
            worker.ReportProgress(20);
            //Ajouter l'extension si el ne l'es pas
            if (!filename.EndsWith(".krp"))
            {
                filename += ".krp";
            }

            //---Get current version
            this.KreaProjectVersion = new KreaProjectVersion(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Version.txt");

            worker.ReportProgress(40);

            MemoryStream ms;

            try
            {
                ms = SerializerHelper.SerializeBinary(this);
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Error during project saving!\n" + ex.Message, "ERROR", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return;
            }

            CgeProjectFilename = filename;



            try
            {
                FileStream fs = File.Create(filename.Replace(".krp", "_temp.krp"));

                fs.Write(ms.GetBuffer(), 0, (int)ms.Length);
                ms.Flush();

                fs.Close();
                worker.ReportProgress(60);
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Error during project saving!\n" + ex.Message, "ERROR", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return;
            }

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            File.Move(filename.Replace(".krp", "_temp.krp"), filename);
        }
Exemple #2
0
        public void saveProject(String filename, BackgroundWorker worker )
        {
            worker.ReportProgress(20);
            //Ajouter l'extension si el ne l'es pas
            if (!filename.EndsWith(".krp"))
                filename += ".krp";

            //---Get current version
            this.KreaProjectVersion = new KreaProjectVersion(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Version.txt");

            worker.ReportProgress(40);

            MemoryStream ms;
            try
            {
                ms = SerializerHelper.SerializeBinary(this);
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Error during project saving!\n" + ex.Message, "ERROR", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return;
            }

            CgeProjectFilename = filename;

            try
            {

                FileStream fs = File.Create(filename.Replace(".krp","_temp.krp"));

                fs.Write(ms.GetBuffer(), 0, (int)ms.Length);
                ms.Flush();

                fs.Close();
                worker.ReportProgress(60);
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Error during project saving!\n" + ex.Message, "ERROR", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return;
            }

            if (File.Exists(filename))
                File.Delete(filename);

            File.Move(filename.Replace(".krp", "_temp.krp"), filename);
        }