Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        public void SetAccessProtocol()
        {
            if (Program.CurrentProject == null)
            {
                GetDataInBackground();
                return;
            }

            var accessProtocol = Program.CurrentProject.AccessProtocol;
            var protocols      = AccessProtocols.LoadStandardAndCustom();
            var protocol       = protocols.FirstOrDefault(i => i.ProtocolName == accessProtocol);

            // is "None" the selected protocol?
            if ((accessProtocol == "None") || (protocol == null))
            {
                _access.DataSource    = null;
                _access.DropDownStyle = ComboBoxStyle.DropDown;
            }
            else
            {
                // remember the list of possible choices
                _accessOptions = protocol.Choices;

                // localize the list
                foreach (var item in _accessOptions)
                {
                    item.Description = LocalizationManager.GetDynamicString("SayMore",
                                                                            "SessionsView.MetadataEditor.AccessProtocol." + accessProtocol + "." + item.ValueMember, item.DisplayMember, null);
                }

                _access.DropDownStyle = ComboBoxStyle.DropDownList;
            }

            SetAccessCodeListAndValue();
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        private void HandleStringsLocalized()
        {
            _archivingFileDirectoryName = GetBaseUriDirectory();
            Debug.Assert(_archivingFileDirectoryName != null);
            if (LocalizationManager.UILanguageId != "en" && Directory.Exists(Path.Combine(_archivingFileDirectoryName, LocalizationManager.UILanguageId)))
            {
                _archivingFileDirectoryName = Path.Combine(_archivingFileDirectoryName, LocalizationManager.UILanguageId);
            }

            var protocols = AccessProtocols.LoadStandardAndCustom(_archivingFileDirectoryName);

            if (protocols.Last().ProtocolName == "Custom")
            {
                protocols.Last().ProtocolName = LocalizationManager.GetString("ProjectView.AccessScreen.Custom", "Custom");
            }
            protocols.Insert(0, new ArchiveAccessProtocol {
                ProtocolName = LocalizationManager.GetString("ProjectView.AccessScreen.None", "None")
            });
            var iSelectedProtocol = _projectAccess.SelectedIndex;

            _projectAccess.DataSource = protocols;
            SizeProtocolsComboBox(_projectAccess);
            if (iSelectedProtocol >= 0)
            {
                _projectAccess.SelectedIndex = iSelectedProtocol;
            }
        }
        public void AccessProtocols_Load_LoadsProtocols()
        {
            var protocols = AccessProtocols.Load();

            Assert.NotNull(protocols);
            Assert.GreaterOrEqual(protocols.Count, 2);
        }
Esempio n. 4
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();
        }