Ejemplo n.º 1
0
        public void passwordPickerDestroyed(object sender, EventArgs e)
        {
            if (pwdPicker.passwordChanged)
            {
                this.Modal = true;
                //update passwords in the metadata
                this.m_applicationViewModel.Experiment.ExperimentInfo.ChallengePassword  = pwdPicker.challengePwd;
                this.m_applicationViewModel.Experiment.ExperimentInfo.ExperimentPassword = pwdPicker.experimentPwd;
                string oldPath   = m_applicationViewModel.Experiment.ExperimentInfo.FilePath;
                string extension = System.IO.Path.GetFileNameWithoutExtension(oldPath);

                if (!string.IsNullOrEmpty(pwdPicker.challengePwd) || !string.IsNullOrEmpty(pwdPicker.experimentPwd))
                {
                    //there is AT LEAST one password
                    //call the procedure to save a locked esxperiment in TEMLX format
                    string path;
                    if (!extension.Equals(".temlx"))
                    {
                        path = addExt(m_applicationViewModel.Experiment.ExperimentInfo.FilePath, ".temlx");
                    }
                    else
                    {
                        //save an updated version of the experiment
                        path = m_applicationViewModel.Experiment.ExperimentInfo.FilePath;
                    }
                    ExperimentManager.SaveToCrypt(this.m_applicationViewModel.Experiment, path);
                }
                else
                {
                    //there are no password so we should decrypt the file, if this is a TEMLX
                    //save the experiment decrypted and delete the .temlx file
                    string uniquePat = GetUniqueName(m_applicationViewModel.Experiment.ExperimentInfo.FilePath, ".teml");
                    ExperimentManager.Save(this.m_applicationViewModel.Experiment, uniquePat);
                }

                //delete old file TEML
                ExperimentManager.DeleteFile(oldPath);
            }
            pwdPicker = null;
        }