Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        public void Save()
        {
            // SP-875: Project Access field reverting to "None"
            if (!_isLoaded)
            {
                return;
            }

            // check for changes
            var project = Program.CurrentProject;

            // happens during testing
            if (project == null)
            {
                return;
            }

            var changed = (_projectAccess.Text != project.AccessProtocol);

            // check if custom access choices changed
            ArchiveAccessProtocol custom = (ArchiveAccessProtocol)_projectAccess.Items[_projectAccess.Items.Count - 1];

            if (_customAccessChoices.Text != custom.ChoicesToCsv())
            {
                var customs     = AccessProtocols.LoadCustom();
                var firstCustom = customs.First();
                firstCustom.SetChoicesFromCsv(_customAccessChoices.Text);
                _customAccessChoices.Text = firstCustom.ChoicesToCsv();
                AccessProtocols.SaveCustom(customs);
                changed = true;
            }

            if (!changed)
            {
                return;
            }

            // save changes
            project.AccessProtocol = _projectAccess.Text;
            project.Save();
        }