Esempio n. 1
0
        public static void SaveProject(Project proj)
        {
            OnSavingFileEventArgs _osfea  = new OnSavingFileEventArgs();
            OnSavedFileEventArgs  _osdfea = new OnSavedFileEventArgs();

            //string _scriptPathCtor = Path.Combine(proj.ProjRoot, proj.ProjName);
            string _scriptFileNameCtor = proj.ProjName + ".litescript";
            string _scriptFileCtor     = Path.Combine(proj.ProjRoot, _scriptFileNameCtor);

            _osfea.Progress      = 20;
            _osfea.ProgressStyle = ProgressBarStyle.Continuous;
            OnSavingFileEvent(null, _osfea);
            try
            {
                File.WriteAllText(_scriptFileCtor, proj.FileContents);
                _osfea.Progress = 75;
                _osdfea.Result  = SaveResult.Success;
                OnSavedFileEvent(null, _osdfea);
            }
            catch
            {
                _osdfea.Result = SaveResult.Error;
                OnSavedFileEvent(null, _osdfea);
                MessageBox.Show(StaticData.LocaleProv.GetValue("messages.errors.io-file-cannot-be-written"), StaticData.LocaleProv.GetValue("messages.titles.error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        public static void SaveScript(string path, string contents)
        {
            OnSavingFileEventArgs _osfea  = new OnSavingFileEventArgs();
            OnSavedFileEventArgs  _osdfea = new OnSavedFileEventArgs();

            _osfea.Progress      = 20;
            _osfea.ProgressStyle = ProgressBarStyle.Continuous;
            OnSavingFileEvent(null, _osfea);
            try
            {
                File.WriteAllText(path, contents);
                _osfea.Progress = 75;
                _osdfea.Result  = SaveResult.Success;
                OnSavedFileEvent(null, _osdfea);
            }
            catch
            {
                _osdfea.Result = SaveResult.Error;
                OnSavedFileEvent(null, _osdfea);
                MessageBox.Show(StaticData.LocaleProv.GetValue("messages.errors.io-file-cannot-be-written"), StaticData.LocaleProv.GetValue("messages.titles.error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }