Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// We get this message from the person informant when a person's UI ID has changed.
        /// When that happens, we just need to update the Text in the participant control. No
        /// change is needed (or desirable) in the underlying metadata.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void HandlePersonsUiIdChanged(object sender, ElementIdChangedArgs e)
        {
            var allParticipants = FieldInstance.GetMultipleValuesFromText(_participants.Text);
            var newNames        = allParticipants.Select(name => (name == e.OldId ? e.NewId : name));

            _participants.Text = FieldInstance.GetTextFromMultipleValues(newNames);
        }
Exemple #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Replace comma with correct delimiter in MultiValueDropDownBox. Translate full names
        /// of persons into strings acceptable to show in UI (use "code" instead of Full Name
        /// when available).
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void HandleBinderTranslateBoundValueBeingRetrieved(object sender,
                                                                   TranslateBoundValueBeingRetrievedArgs args)
        {
            if (!(args.BoundControl is MultiValueDropDownBox))
            {
                return;
            }

            if (args.ValueFromFile.Contains(","))
            {
                args.TranslatedValue = args.ValueFromFile.Replace(",", FieldInstance.kDefaultMultiValueDelimiter.ToString(CultureInfo.InvariantCulture));
            }

            if (args.BoundControl == _participants)
            {
                var val = args.TranslatedValue ?? args.ValueFromFile;
                if (!string.IsNullOrEmpty(val))
                {
                    var participantNames = FieldInstance.GetMultipleValuesFromText(val).ToArray();
                    for (int index = 0; index < participantNames.Length; index++)
                    {
                        participantNames[index] = _personInformant.GetUiIdByName(participantNames[index]);
                    }

                    args.TranslatedValue = FieldInstance.GetTextFromMultipleValues(participantNames);
                }
            }
        }
Exemple #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// We get this message from the person informant when a person's name has changed.
        /// When that happens, we need to make sure we update the participant field in case
        /// it contains a name that changed.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void HandlePersonsNameChanged(object sender, ElementIdChangedArgs e)
        {
            var allParticipants = GetAllParticipants();
            var newNames        = allParticipants.Select(name => (name == e.OldId ? e.NewId : name));

            MetaDataFile.SetStringValue(SessionFileType.kParticipantsFieldName,
                                        FieldInstance.GetTextFromMultipleValues(newNames));

            MetaDataFile.Save();

            ProcessContributorNameChange(e);
        }
Exemple #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// When the binding helper gets to writing field values to the metadata file, we need
        /// to make sure the English values for male and female are written to the file, not
        /// the localized values for male and female (which is what is in the gender combo box).
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void HandleBinderTranslateBoundValueBeingSaved(object sender,
                                                               TranslateBoundValueBeingSavedArgs args)
        {
            if (args.BoundControl == _participants)
            {
                var participantNames = FieldInstance.GetMultipleValuesFromText(_participants.Text).ToArray();
                for (int index = 0; index < participantNames.Length; index++)
                {
                    var person = _personInformant.GetPersonByNameOrCode(participantNames[index]);
                    if (person != null)
                    {
                        participantNames[index] = person.Id;
                    }
                }

                args.NewValue = FieldInstance.GetTextFromMultipleValues(participantNames);
            }
        }
 public void GetTextFromMultipleValues_ListIncludesNull_ReturnExcludesNull()
 {
     Assert.AreEqual("ferrari; Jaguar",
                     FieldInstance.GetTextFromMultipleValues(new[] { "ferrari", null, "Jaguar" }));
 }
 public void GetTextFromMultipleValues_ListIncludesEmptyItem_ReturnExcludesEmptyItem()
 {
     Assert.AreEqual("ferrari; Lotus",
                     FieldInstance.GetTextFromMultipleValues(new[] { "ferrari", "Lotus", "  " }));
 }
 public void GetTextFromMultipleValues_MultipleItems_ReturnsThemDelimited()
 {
     Assert.AreEqual("ferrari; Lotus; Jaguar",
                     FieldInstance.GetTextFromMultipleValues(new[] { "ferrari", "Lotus", "Jaguar" }));
 }
 public void GetTextFromMultipleValues_ListOfOne_ReturnsWithoutDelimiter()
 {
     Assert.AreEqual("ferrari", FieldInstance.GetTextFromMultipleValues(new[] { "ferrari" }));
 }
 public void GetTextFromMultipleValues_EmptyList_ReturnsEmptyString()
 {
     Assert.AreEqual(string.Empty, FieldInstance.GetTextFromMultipleValues(new string[] { }));
 }